documentation.d.ts 3.7 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783347843478534786347873478834789347903479134792347933479434795347963479734798347993480034801348023480334804348053480634807348083480934810348113481234813348143481534816348173481834819348203482134822348233482434825348263482734828348293483034831348323483334834348353483634837348383483934840348413484234843348443484534846348473484834849348503485134852348533485434855348563485734858348593486034861348623486334864348653486634867348683486934870348713487234873348743487534876348773487834879348803488134882348833488434885348863488734888348893489034891348923489334894348953489634897348983489934900349013490234903349043490534906349073490834909349103491134912349133491434915349163491734918349193492034921349223492334924349253492634927349283492934930349313493234933349343493534936349373493834939349403494134942349433494434945349463494734948349493495034951349523495334954349553495634957349583495934960349613496234963349643496534966349673496834969349703497134972349733497434975349763497734978349793498034981349823498334984349853498634987349883498934990349913499234993349943499534996349973499834999350003500135002350033500435005350063500735008350093501035011350123501335014350153501635017350183501935020350213502235023350243502535026350273502835029350303503135032350333503435035350363503735038350393504035041350423504335044350453504635047350483504935050350513505235053350543505535056350573505835059350603506135062350633506435065350663506735068350693507035071350723507335074350753507635077350783507935080350813508235083350843508535086350873508835089350903509135092350933509435095350963509735098350993510035101351023510335104351053510635107351083510935110351113511235113351143511535116351173511835119351203512135122351233512435125351263512735128351293513035131351323513335134351353513635137351383513935140351413514235143351443514535146351473514835149351503515135152351533515435155351563515735158351593516035161351623516335164351653516635167351683516935170351713517235173351743517535176351773517835179351803518135182351833518435185351863518735188351893519035191351923519335194351953519635197351983519935200352013520235203352043520535206352073520835209352103521135212352133521435215352163521735218352193522035221352223522335224352253522635227352283522935230352313523235233352343523535236352373523835239352403524135242352433524435245352463524735248352493525035251352523525335254352553525635257352583525935260352613526235263352643526535266352673526835269352703527135272352733527435275352763527735278352793528035281352823528335284352853528635287352883528935290352913529235293352943529535296352973529835299353003530135302353033530435305353063530735308353093531035311353123531335314353153531635317353183531935320353213532235323353243532535326353273532835329353303533135332353333533435335353363533735338353393534035341353423534335344353453534635347353483534935350353513535235353353543535535356353573535835359353603536135362353633536435365353663536735368353693537035371353723537335374353753537635377353783537935380353813538235383353843538535386353873538835389353903539135392353933539435395353963539735398353993540035401354023540335404354053540635407354083540935410354113541235413354143541535416354173541835419354203542135422354233542435425354263542735428354293543035431354323543335434354353543635437354383543935440354413544235443354443544535446354473544835449354503545135452354533545435455354563545735458354593546035461354623546335464354653546635467354683546935470354713547235473354743547535476354773547835479354803548135482354833548435485354863548735488354893549035491354923549335494354953549635497354983549935500355013550235503355043550535506355073550835509355103551135512355133551435515355163551735518355193552035521355223552335524355253552635527355283552935530355313553235533355343553535536355373553835539355403554135542355433554435545355463554735548355493555035551355523555335554355553555635557355583555935560355613556235563355643556535566355673556835569355703557135572355733557435575355763557735578355793558035581355823558335584355853558635587355883558935590355913559235593355943559535596355973559835599356003560135602356033560435605356063560735608356093561035611356123561335614356153561635617356183561935620356213562235623356243562535626356273562835629356303563135632356333563435635356363563735638356393564035641356423564335644356453564635647356483564935650356513565235653356543565535656356573565835659356603566135662356633566435665356663566735668356693567035671356723567335674356753567635677356783567935680356813568235683356843568535686356873568835689356903569135692356933569435695356963569735698356993570035701357023570335704357053570635707357083570935710357113571235713357143571535716357173571835719357203572135722357233572435725357263572735728357293573035731357323573335734357353573635737357383573935740357413574235743357443574535746357473574835749357503575135752357533575435755357563575735758357593576035761357623576335764357653576635767357683576935770357713577235773357743577535776357773577835779357803578135782357833578435785357863578735788357893579035791357923579335794357953579635797357983579935800358013580235803358043580535806358073580835809358103581135812358133581435815358163581735818358193582035821358223582335824358253582635827358283582935830358313583235833358343583535836358373583835839358403584135842358433584435845358463584735848358493585035851358523585335854358553585635857358583585935860358613586235863358643586535866358673586835869358703587135872358733587435875358763587735878358793588035881358823588335884358853588635887358883588935890358913589235893358943589535896358973589835899359003590135902359033590435905359063590735908359093591035911359123591335914359153591635917359183591935920359213592235923359243592535926359273592835929359303593135932359333593435935359363593735938359393594035941359423594335944359453594635947359483594935950359513595235953359543595535956359573595835959359603596135962359633596435965359663596735968359693597035971359723597335974359753597635977359783597935980359813598235983359843598535986359873598835989359903599135992359933599435995359963599735998359993600036001360023600336004360053600636007360083600936010360113601236013360143601536016360173601836019360203602136022360233602436025360263602736028360293603036031360323603336034360353603636037360383603936040360413604236043360443604536046360473604836049360503605136052360533605436055360563605736058360593606036061360623606336064360653606636067360683606936070360713607236073360743607536076360773607836079360803608136082360833608436085360863608736088360893609036091360923609336094360953609636097360983609936100361013610236103361043610536106361073610836109361103611136112361133611436115361163611736118361193612036121361223612336124361253612636127361283612936130361313613236133361343613536136361373613836139361403614136142361433614436145361463614736148361493615036151361523615336154361553615636157361583615936160361613616236163361643616536166361673616836169361703617136172361733617436175361763617736178361793618036181361823618336184361853618636187361883618936190361913619236193361943619536196361973619836199362003620136202362033620436205362063620736208362093621036211362123621336214362153621636217362183621936220362213622236223362243622536226362273622836229362303623136232362333623436235362363623736238362393624036241362423624336244362453624636247362483624936250362513625236253362543625536256362573625836259362603626136262362633626436265362663626736268362693627036271362723627336274362753627636277362783627936280362813628236283362843628536286362873628836289362903629136292362933629436295362963629736298362993630036301363023630336304363053630636307363083630936310363113631236313363143631536316363173631836319363203632136322363233632436325363263632736328363293633036331363323633336334363353633636337363383633936340363413634236343363443634536346363473634836349363503635136352363533635436355363563635736358363593636036361363623636336364363653636636367363683636936370363713637236373363743637536376363773637836379363803638136382363833638436385363863638736388363893639036391363923639336394363953639636397363983639936400364013640236403364043640536406364073640836409364103641136412364133641436415364163641736418364193642036421364223642336424364253642636427364283642936430364313643236433364343643536436364373643836439364403644136442364433644436445364463644736448364493645036451364523645336454364553645636457364583645936460364613646236463364643646536466364673646836469364703647136472364733647436475364763647736478364793648036481364823648336484364853648636487364883648936490364913649236493364943649536496364973649836499365003650136502365033650436505365063650736508365093651036511365123651336514365153651636517365183651936520365213652236523365243652536526365273652836529365303653136532365333653436535365363653736538365393654036541365423654336544365453654636547365483654936550365513655236553365543655536556365573655836559365603656136562365633656436565365663656736568365693657036571365723657336574365753657636577365783657936580365813658236583365843658536586365873658836589365903659136592365933659436595365963659736598365993660036601366023660336604366053660636607366083660936610366113661236613366143661536616366173661836619366203662136622366233662436625366263662736628366293663036631366323663336634366353663636637366383663936640366413664236643366443664536646366473664836649366503665136652366533665436655366563665736658366593666036661366623666336664366653666636667366683666936670366713667236673366743667536676366773667836679366803668136682366833668436685366863668736688366893669036691366923669336694366953669636697366983669936700367013670236703367043670536706367073670836709367103671136712367133671436715367163671736718367193672036721367223672336724367253672636727367283672936730367313673236733367343673536736367373673836739367403674136742367433674436745367463674736748367493675036751367523675336754367553675636757367583675936760367613676236763367643676536766367673676836769367703677136772367733677436775367763677736778367793678036781367823678336784367853678636787367883678936790367913679236793367943679536796367973679836799368003680136802368033680436805368063680736808368093681036811368123681336814368153681636817368183681936820368213682236823368243682536826368273682836829368303683136832368333683436835368363683736838368393684036841368423684336844368453684636847368483684936850368513685236853368543685536856368573685836859368603686136862368633686436865368663686736868368693687036871368723687336874368753687636877368783687936880368813688236883368843688536886368873688836889368903689136892368933689436895368963689736898368993690036901369023690336904369053690636907369083690936910369113691236913369143691536916369173691836919369203692136922369233692436925369263692736928369293693036931369323693336934369353693636937369383693936940369413694236943369443694536946369473694836949369503695136952369533695436955369563695736958369593696036961369623696336964369653696636967369683696936970369713697236973369743697536976369773697836979369803698136982369833698436985369863698736988369893699036991369923699336994369953699636997369983699937000370013700237003370043700537006370073700837009370103701137012370133701437015370163701737018370193702037021370223702337024370253702637027370283702937030370313703237033370343703537036370373703837039370403704137042370433704437045370463704737048370493705037051370523705337054370553705637057370583705937060370613706237063370643706537066370673706837069370703707137072370733707437075370763707737078370793708037081370823708337084370853708637087370883708937090370913709237093370943709537096370973709837099371003710137102371033710437105371063710737108371093711037111371123711337114371153711637117371183711937120371213712237123371243712537126371273712837129371303713137132371333713437135371363713737138371393714037141371423714337144371453714637147371483714937150371513715237153371543715537156371573715837159371603716137162371633716437165371663716737168371693717037171371723717337174371753717637177371783717937180371813718237183371843718537186371873718837189371903719137192371933719437195371963719737198371993720037201372023720337204372053720637207372083720937210372113721237213372143721537216372173721837219372203722137222372233722437225372263722737228372293723037231372323723337234372353723637237372383723937240372413724237243372443724537246372473724837249372503725137252372533725437255372563725737258372593726037261372623726337264372653726637267372683726937270372713727237273372743727537276372773727837279372803728137282372833728437285372863728737288372893729037291372923729337294372953729637297372983729937300373013730237303373043730537306373073730837309373103731137312373133731437315373163731737318373193732037321373223732337324373253732637327373283732937330373313733237333373343733537336373373733837339373403734137342373433734437345373463734737348373493735037351373523735337354373553735637357373583735937360373613736237363373643736537366373673736837369373703737137372373733737437375373763737737378373793738037381373823738337384373853738637387373883738937390373913739237393373943739537396373973739837399374003740137402374033740437405374063740737408374093741037411374123741337414374153741637417374183741937420374213742237423374243742537426374273742837429374303743137432374333743437435374363743737438374393744037441374423744337444374453744637447374483744937450374513745237453374543745537456374573745837459374603746137462374633746437465374663746737468374693747037471374723747337474374753747637477374783747937480374813748237483374843748537486374873748837489374903749137492374933749437495374963749737498374993750037501375023750337504375053750637507375083750937510375113751237513375143751537516375173751837519375203752137522375233752437525375263752737528375293753037531375323753337534375353753637537375383753937540375413754237543375443754537546375473754837549375503755137552375533755437555375563755737558375593756037561375623756337564375653756637567375683756937570375713757237573375743757537576375773757837579375803758137582375833758437585375863758737588375893759037591375923759337594375953759637597375983759937600376013760237603376043760537606376073760837609376103761137612376133761437615376163761737618376193762037621376223762337624376253762637627376283762937630376313763237633376343763537636376373763837639376403764137642376433764437645376463764737648376493765037651376523765337654376553765637657376583765937660376613766237663376643766537666376673766837669376703767137672376733767437675376763767737678376793768037681376823768337684376853768637687376883768937690376913769237693376943769537696376973769837699377003770137702377033770437705377063770737708377093771037711377123771337714377153771637717377183771937720377213772237723377243772537726377273772837729377303773137732377333773437735377363773737738377393774037741377423774337744377453774637747377483774937750377513775237753377543775537756377573775837759377603776137762377633776437765377663776737768377693777037771377723777337774377753777637777377783777937780377813778237783377843778537786377873778837789377903779137792377933779437795377963779737798377993780037801378023780337804378053780637807378083780937810378113781237813378143781537816378173781837819378203782137822378233782437825378263782737828378293783037831378323783337834378353783637837378383783937840378413784237843378443784537846378473784837849378503785137852378533785437855378563785737858378593786037861378623786337864378653786637867378683786937870378713787237873378743787537876378773787837879378803788137882378833788437885378863788737888378893789037891378923789337894378953789637897378983789937900379013790237903379043790537906379073790837909379103791137912379133791437915379163791737918379193792037921379223792337924379253792637927379283792937930379313793237933379343793537936379373793837939379403794137942379433794437945379463794737948379493795037951379523795337954379553795637957379583795937960379613796237963379643796537966379673796837969379703797137972379733797437975379763797737978379793798037981379823798337984379853798637987379883798937990379913799237993379943799537996379973799837999380003800138002380033800438005380063800738008380093801038011380123801338014380153801638017380183801938020380213802238023380243802538026380273802838029380303803138032380333803438035380363803738038380393804038041380423804338044380453804638047380483804938050380513805238053380543805538056380573805838059380603806138062380633806438065380663806738068380693807038071380723807338074380753807638077380783807938080380813808238083380843808538086380873808838089380903809138092380933809438095380963809738098380993810038101381023810338104381053810638107381083810938110381113811238113381143811538116381173811838119381203812138122381233812438125381263812738128381293813038131381323813338134381353813638137381383813938140381413814238143381443814538146381473814838149381503815138152381533815438155381563815738158381593816038161381623816338164381653816638167381683816938170381713817238173381743817538176381773817838179381803818138182381833818438185381863818738188381893819038191381923819338194381953819638197381983819938200382013820238203382043820538206382073820838209382103821138212382133821438215382163821738218382193822038221382223822338224382253822638227382283822938230382313823238233382343823538236382373823838239382403824138242382433824438245382463824738248382493825038251382523825338254382553825638257382583825938260382613826238263382643826538266382673826838269382703827138272382733827438275382763827738278382793828038281382823828338284382853828638287382883828938290382913829238293382943829538296382973829838299383003830138302383033830438305383063830738308383093831038311383123831338314383153831638317383183831938320383213832238323383243832538326383273832838329383303833138332383333833438335383363833738338383393834038341383423834338344383453834638347383483834938350383513835238353383543835538356383573835838359383603836138362383633836438365383663836738368383693837038371383723837338374383753837638377383783837938380383813838238383383843838538386383873838838389383903839138392383933839438395383963839738398383993840038401384023840338404384053840638407384083840938410384113841238413384143841538416384173841838419384203842138422384233842438425384263842738428384293843038431384323843338434384353843638437384383843938440384413844238443384443844538446384473844838449384503845138452384533845438455384563845738458384593846038461384623846338464384653846638467384683846938470384713847238473384743847538476384773847838479384803848138482384833848438485384863848738488384893849038491384923849338494384953849638497384983849938500385013850238503385043850538506385073850838509385103851138512385133851438515385163851738518385193852038521385223852338524385253852638527385283852938530385313853238533385343853538536385373853838539385403854138542385433854438545385463854738548385493855038551385523855338554385553855638557385583855938560385613856238563385643856538566385673856838569385703857138572385733857438575385763857738578385793858038581385823858338584385853858638587385883858938590385913859238593385943859538596385973859838599386003860138602386033860438605386063860738608386093861038611386123861338614386153861638617386183861938620386213862238623386243862538626386273862838629386303863138632386333863438635386363863738638386393864038641386423864338644386453864638647386483864938650386513865238653386543865538656386573865838659386603866138662386633866438665386663866738668386693867038671386723867338674386753867638677386783867938680386813868238683386843868538686386873868838689386903869138692386933869438695386963869738698386993870038701387023870338704387053870638707387083870938710387113871238713387143871538716387173871838719387203872138722387233872438725387263872738728387293873038731387323873338734387353873638737387383873938740387413874238743387443874538746387473874838749387503875138752387533875438755387563875738758387593876038761387623876338764387653876638767387683876938770387713877238773387743877538776387773877838779387803878138782387833878438785387863878738788387893879038791387923879338794387953879638797387983879938800388013880238803388043880538806388073880838809388103881138812388133881438815388163881738818388193882038821388223882338824388253882638827388283882938830388313883238833388343883538836388373883838839388403884138842388433884438845388463884738848388493885038851388523885338854388553885638857388583885938860388613886238863388643886538866388673886838869388703887138872388733887438875388763887738878388793888038881388823888338884388853888638887388883888938890388913889238893388943889538896388973889838899389003890138902389033890438905389063890738908389093891038911389123891338914389153891638917389183891938920389213892238923389243892538926389273892838929389303893138932389333893438935389363893738938389393894038941389423894338944389453894638947389483894938950389513895238953389543895538956389573895838959389603896138962389633896438965389663896738968389693897038971389723897338974389753897638977389783897938980389813898238983389843898538986389873898838989389903899138992389933899438995389963899738998389993900039001390023900339004390053900639007390083900939010390113901239013390143901539016390173901839019390203902139022390233902439025390263902739028390293903039031390323903339034390353903639037390383903939040390413904239043390443904539046390473904839049390503905139052390533905439055390563905739058390593906039061390623906339064390653906639067390683906939070390713907239073390743907539076390773907839079390803908139082390833908439085390863908739088390893909039091390923909339094390953909639097390983909939100391013910239103391043910539106391073910839109391103911139112391133911439115391163911739118391193912039121391223912339124391253912639127391283912939130391313913239133391343913539136391373913839139391403914139142391433914439145391463914739148391493915039151391523915339154391553915639157391583915939160391613916239163391643916539166391673916839169391703917139172391733917439175391763917739178391793918039181391823918339184391853918639187391883918939190391913919239193391943919539196391973919839199392003920139202392033920439205392063920739208392093921039211392123921339214392153921639217392183921939220392213922239223392243922539226392273922839229392303923139232392333923439235392363923739238392393924039241392423924339244392453924639247392483924939250392513925239253392543925539256392573925839259392603926139262392633926439265392663926739268392693927039271392723927339274392753927639277392783927939280392813928239283392843928539286392873928839289392903929139292392933929439295392963929739298392993930039301393023930339304393053930639307393083930939310393113931239313393143931539316393173931839319393203932139322393233932439325393263932739328393293933039331393323933339334393353933639337393383933939340393413934239343393443934539346393473934839349393503935139352393533935439355393563935739358393593936039361393623936339364393653936639367393683936939370393713937239373393743937539376393773937839379393803938139382393833938439385393863938739388393893939039391393923939339394393953939639397393983939939400394013940239403394043940539406394073940839409394103941139412394133941439415394163941739418394193942039421394223942339424394253942639427394283942939430394313943239433394343943539436394373943839439394403944139442394433944439445394463944739448394493945039451394523945339454394553945639457394583945939460394613946239463394643946539466394673946839469394703947139472394733947439475394763947739478394793948039481394823948339484394853948639487394883948939490394913949239493394943949539496394973949839499395003950139502395033950439505395063950739508395093951039511395123951339514395153951639517395183951939520395213952239523395243952539526395273952839529395303953139532395333953439535395363953739538395393954039541395423954339544395453954639547395483954939550395513955239553395543955539556395573955839559395603956139562395633956439565395663956739568395693957039571395723957339574395753957639577395783957939580395813958239583395843958539586395873958839589395903959139592395933959439595395963959739598395993960039601396023960339604396053960639607396083960939610396113961239613396143961539616396173961839619396203962139622396233962439625396263962739628396293963039631396323963339634396353963639637396383963939640396413964239643396443964539646396473964839649396503965139652396533965439655396563965739658396593966039661396623966339664396653966639667396683966939670396713967239673396743967539676396773967839679396803968139682396833968439685396863968739688396893969039691396923969339694396953969639697396983969939700397013970239703397043970539706397073970839709397103971139712397133971439715397163971739718397193972039721397223972339724397253972639727397283972939730397313973239733397343973539736397373973839739397403974139742397433974439745397463974739748397493975039751397523975339754397553975639757397583975939760397613976239763397643976539766397673976839769397703977139772397733977439775397763977739778397793978039781397823978339784397853978639787397883978939790397913979239793397943979539796397973979839799398003980139802398033980439805398063980739808398093981039811398123981339814398153981639817398183981939820398213982239823398243982539826398273982839829398303983139832398333983439835398363983739838398393984039841398423984339844398453984639847398483984939850398513985239853398543985539856398573985839859398603986139862398633986439865398663986739868398693987039871398723987339874398753987639877398783987939880398813988239883398843988539886398873988839889398903989139892398933989439895398963989739898398993990039901399023990339904399053990639907399083990939910399113991239913399143991539916399173991839919399203992139922399233992439925399263992739928399293993039931399323993339934399353993639937399383993939940399413994239943399443994539946399473994839949399503995139952399533995439955399563995739958399593996039961399623996339964399653996639967399683996939970399713997239973399743997539976399773997839979399803998139982399833998439985399863998739988399893999039991399923999339994399953999639997399983999940000400014000240003400044000540006400074000840009400104001140012400134001440015400164001740018400194002040021400224002340024400254002640027400284002940030400314003240033400344003540036400374003840039400404004140042400434004440045400464004740048400494005040051400524005340054400554005640057400584005940060400614006240063400644006540066400674006840069400704007140072400734007440075400764007740078400794008040081400824008340084400854008640087400884008940090400914009240093400944009540096400974009840099401004010140102401034010440105401064010740108401094011040111401124011340114401154011640117401184011940120401214012240123401244012540126401274012840129401304013140132401334013440135401364013740138401394014040141401424014340144401454014640147401484014940150401514015240153401544015540156401574015840159401604016140162401634016440165401664016740168401694017040171401724017340174401754017640177401784017940180401814018240183401844018540186401874018840189401904019140192401934019440195401964019740198401994020040201402024020340204402054020640207402084020940210402114021240213402144021540216402174021840219402204022140222402234022440225402264022740228402294023040231402324023340234402354023640237402384023940240402414024240243402444024540246402474024840249402504025140252402534025440255402564025740258402594026040261402624026340264402654026640267402684026940270402714027240273402744027540276402774027840279402804028140282402834028440285402864028740288402894029040291402924029340294402954029640297402984029940300403014030240303403044030540306403074030840309403104031140312403134031440315403164031740318403194032040321403224032340324403254032640327403284032940330403314033240333403344033540336403374033840339403404034140342403434034440345403464034740348403494035040351403524035340354403554035640357403584035940360403614036240363403644036540366403674036840369403704037140372403734037440375403764037740378403794038040381403824038340384403854038640387403884038940390403914039240393403944039540396403974039840399404004040140402404034040440405404064040740408404094041040411404124041340414404154041640417404184041940420404214042240423404244042540426404274042840429404304043140432404334043440435404364043740438404394044040441404424044340444404454044640447404484044940450404514045240453404544045540456404574045840459404604046140462404634046440465404664046740468404694047040471404724047340474404754047640477404784047940480404814048240483404844048540486404874048840489404904049140492404934049440495404964049740498404994050040501405024050340504405054050640507405084050940510405114051240513405144051540516405174051840519405204052140522405234052440525405264052740528405294053040531405324053340534405354053640537405384053940540405414054240543405444054540546405474054840549405504055140552405534055440555405564055740558405594056040561405624056340564405654056640567405684056940570405714057240573405744057540576405774057840579405804058140582405834058440585405864058740588405894059040591405924059340594405954059640597405984059940600406014060240603406044060540606406074060840609406104061140612406134061440615406164061740618406194062040621406224062340624406254062640627406284062940630406314063240633406344063540636406374063840639406404064140642406434064440645406464064740648406494065040651406524065340654406554065640657406584065940660406614066240663406644066540666406674066840669406704067140672406734067440675406764067740678406794068040681406824068340684406854068640687406884068940690406914069240693406944069540696406974069840699407004070140702407034070440705407064070740708407094071040711407124071340714407154071640717407184071940720407214072240723407244072540726407274072840729407304073140732407334073440735407364073740738407394074040741407424074340744407454074640747407484074940750407514075240753407544075540756407574075840759407604076140762407634076440765407664076740768407694077040771407724077340774407754077640777407784077940780407814078240783407844078540786407874078840789407904079140792407934079440795407964079740798407994080040801408024080340804408054080640807408084080940810408114081240813408144081540816408174081840819408204082140822408234082440825408264082740828408294083040831408324083340834408354083640837408384083940840408414084240843408444084540846408474084840849408504085140852408534085440855408564085740858408594086040861408624086340864408654086640867408684086940870408714087240873408744087540876408774087840879408804088140882408834088440885408864088740888408894089040891408924089340894408954089640897408984089940900409014090240903409044090540906409074090840909409104091140912409134091440915409164091740918409194092040921409224092340924409254092640927409284092940930409314093240933409344093540936409374093840939409404094140942409434094440945409464094740948409494095040951409524095340954409554095640957409584095940960409614096240963409644096540966409674096840969409704097140972409734097440975409764097740978409794098040981409824098340984409854098640987409884098940990409914099240993409944099540996409974099840999410004100141002410034100441005410064100741008410094101041011410124101341014410154101641017410184101941020410214102241023410244102541026410274102841029410304103141032410334103441035410364103741038410394104041041410424104341044410454104641047410484104941050410514105241053410544105541056410574105841059410604106141062410634106441065410664106741068410694107041071410724107341074410754107641077410784107941080410814108241083410844108541086410874108841089410904109141092410934109441095410964109741098410994110041101411024110341104411054110641107411084110941110411114111241113411144111541116411174111841119411204112141122411234112441125411264112741128411294113041131411324113341134411354113641137411384113941140411414114241143411444114541146411474114841149411504115141152411534115441155411564115741158411594116041161411624116341164411654116641167411684116941170411714117241173411744117541176411774117841179411804118141182411834118441185411864118741188411894119041191411924119341194411954119641197411984119941200412014120241203412044120541206412074120841209412104121141212412134121441215412164121741218412194122041221412224122341224412254122641227412284122941230412314123241233412344123541236412374123841239412404124141242412434124441245412464124741248412494125041251412524125341254412554125641257412584125941260412614126241263412644126541266412674126841269412704127141272412734127441275412764127741278412794128041281412824128341284412854128641287412884128941290412914129241293412944129541296412974129841299413004130141302413034130441305413064130741308413094131041311413124131341314413154131641317413184131941320413214132241323413244132541326413274132841329413304133141332413334133441335413364133741338413394134041341413424134341344413454134641347413484134941350413514135241353413544135541356413574135841359413604136141362413634136441365413664136741368413694137041371413724137341374413754137641377413784137941380413814138241383413844138541386413874138841389413904139141392413934139441395413964139741398413994140041401414024140341404414054140641407414084140941410414114141241413414144141541416414174141841419414204142141422414234142441425414264142741428414294143041431414324143341434414354143641437414384143941440414414144241443414444144541446414474144841449414504145141452414534145441455414564145741458414594146041461414624146341464414654146641467414684146941470414714147241473414744147541476414774147841479414804148141482414834148441485414864148741488414894149041491414924149341494414954149641497414984149941500415014150241503415044150541506415074150841509415104151141512415134151441515415164151741518415194152041521415224152341524415254152641527415284152941530415314153241533415344153541536415374153841539415404154141542415434154441545415464154741548415494155041551415524155341554415554155641557415584155941560415614156241563415644156541566415674156841569415704157141572415734157441575415764157741578415794158041581415824158341584415854158641587415884158941590415914159241593415944159541596415974159841599416004160141602416034160441605416064160741608416094161041611416124161341614416154161641617416184161941620416214162241623416244162541626416274162841629416304163141632416334163441635416364163741638416394164041641416424164341644416454164641647416484164941650416514165241653416544165541656416574165841659416604166141662416634166441665416664166741668416694167041671416724167341674416754167641677416784167941680416814168241683416844168541686416874168841689416904169141692416934169441695416964169741698416994170041701417024170341704417054170641707417084170941710417114171241713417144171541716417174171841719417204172141722417234172441725417264172741728417294173041731417324173341734417354173641737417384173941740417414174241743417444174541746417474174841749417504175141752417534175441755417564175741758417594176041761417624176341764417654176641767417684176941770417714177241773417744177541776417774177841779417804178141782417834178441785417864178741788417894179041791417924179341794417954179641797417984179941800418014180241803418044180541806418074180841809418104181141812418134181441815418164181741818418194182041821418224182341824418254182641827418284182941830418314183241833418344183541836418374183841839418404184141842418434184441845418464184741848418494185041851418524185341854418554185641857418584185941860418614186241863418644186541866418674186841869418704187141872418734187441875418764187741878418794188041881418824188341884418854188641887418884188941890418914189241893418944189541896418974189841899419004190141902419034190441905419064190741908419094191041911419124191341914419154191641917419184191941920419214192241923419244192541926419274192841929419304193141932419334193441935419364193741938419394194041941419424194341944419454194641947419484194941950419514195241953419544195541956419574195841959419604196141962419634196441965419664196741968419694197041971419724197341974419754197641977419784197941980419814198241983419844198541986419874198841989419904199141992419934199441995419964199741998419994200042001420024200342004420054200642007420084200942010420114201242013420144201542016420174201842019420204202142022420234202442025420264202742028420294203042031420324203342034420354203642037420384203942040420414204242043420444204542046420474204842049420504205142052420534205442055420564205742058420594206042061420624206342064420654206642067420684206942070420714207242073420744207542076420774207842079420804208142082420834208442085420864208742088420894209042091420924209342094420954209642097420984209942100421014210242103421044210542106421074210842109421104211142112421134211442115421164211742118421194212042121421224212342124421254212642127421284212942130421314213242133421344213542136421374213842139421404214142142421434214442145421464214742148421494215042151421524215342154421554215642157421584215942160421614216242163421644216542166421674216842169421704217142172421734217442175421764217742178421794218042181421824218342184421854218642187421884218942190421914219242193421944219542196421974219842199422004220142202422034220442205422064220742208422094221042211422124221342214422154221642217422184221942220422214222242223422244222542226422274222842229422304223142232422334223442235422364223742238422394224042241422424224342244422454224642247422484224942250422514225242253422544225542256422574225842259422604226142262422634226442265422664226742268422694227042271422724227342274422754227642277422784227942280422814228242283422844228542286422874228842289422904229142292422934229442295422964229742298422994230042301423024230342304423054230642307423084230942310423114231242313423144231542316423174231842319423204232142322423234232442325423264232742328423294233042331423324233342334423354233642337423384233942340423414234242343423444234542346423474234842349423504235142352423534235442355423564235742358423594236042361423624236342364423654236642367423684236942370423714237242373423744237542376423774237842379423804238142382423834238442385423864238742388423894239042391423924239342394423954239642397423984239942400424014240242403424044240542406424074240842409424104241142412424134241442415424164241742418424194242042421424224242342424424254242642427424284242942430424314243242433424344243542436424374243842439424404244142442424434244442445424464244742448424494245042451424524245342454424554245642457424584245942460424614246242463424644246542466424674246842469424704247142472424734247442475424764247742478424794248042481424824248342484424854248642487424884248942490424914249242493424944249542496424974249842499425004250142502425034250442505425064250742508425094251042511425124251342514425154251642517425184251942520425214252242523425244252542526425274252842529425304253142532425334253442535425364253742538425394254042541425424254342544425454254642547425484254942550425514255242553425544255542556425574255842559425604256142562425634256442565425664256742568425694257042571425724257342574425754257642577425784257942580425814258242583425844258542586425874258842589425904259142592425934259442595425964259742598425994260042601426024260342604426054260642607426084260942610426114261242613426144261542616426174261842619426204262142622426234262442625426264262742628426294263042631426324263342634426354263642637426384263942640426414264242643426444264542646426474264842649426504265142652426534265442655426564265742658426594266042661426624266342664426654266642667426684266942670426714267242673426744267542676426774267842679426804268142682426834268442685426864268742688426894269042691426924269342694426954269642697426984269942700427014270242703427044270542706427074270842709427104271142712427134271442715427164271742718427194272042721427224272342724427254272642727427284272942730427314273242733427344273542736427374273842739427404274142742427434274442745427464274742748427494275042751427524275342754427554275642757427584275942760427614276242763427644276542766427674276842769427704277142772427734277442775427764277742778427794278042781427824278342784427854278642787427884278942790427914279242793427944279542796427974279842799428004280142802428034280442805428064280742808428094281042811428124281342814428154281642817428184281942820428214282242823428244282542826428274282842829428304283142832428334283442835428364283742838428394284042841428424284342844428454284642847428484284942850428514285242853428544285542856428574285842859428604286142862428634286442865428664286742868428694287042871428724287342874428754287642877428784287942880428814288242883428844288542886428874288842889428904289142892428934289442895428964289742898428994290042901429024290342904429054290642907429084290942910429114291242913429144291542916429174291842919429204292142922429234292442925429264292742928429294293042931429324293342934429354293642937429384293942940429414294242943429444294542946429474294842949429504295142952429534295442955429564295742958429594296042961429624296342964429654296642967429684296942970429714297242973429744297542976429774297842979429804298142982429834298442985429864298742988429894299042991429924299342994429954299642997429984299943000430014300243003430044300543006430074300843009430104301143012430134301443015430164301743018430194302043021430224302343024430254302643027430284302943030430314303243033430344303543036430374303843039430404304143042430434304443045430464304743048430494305043051430524305343054430554305643057430584305943060430614306243063430644306543066430674306843069430704307143072430734307443075430764307743078430794308043081430824308343084430854308643087430884308943090430914309243093430944309543096430974309843099431004310143102431034310443105431064310743108431094311043111431124311343114431154311643117431184311943120431214312243123431244312543126431274312843129431304313143132431334313443135431364313743138431394314043141431424314343144431454314643147431484314943150431514315243153431544315543156431574315843159431604316143162431634316443165431664316743168431694317043171431724317343174431754317643177431784317943180431814318243183431844318543186431874318843189431904319143192431934319443195431964319743198431994320043201432024320343204432054320643207432084320943210432114321243213432144321543216432174321843219432204322143222432234322443225432264322743228432294323043231432324323343234432354323643237432384323943240432414324243243432444324543246432474324843249432504325143252432534325443255432564325743258432594326043261432624326343264432654326643267432684326943270432714327243273432744327543276432774327843279432804328143282432834328443285432864328743288432894329043291432924329343294432954329643297432984329943300433014330243303433044330543306433074330843309433104331143312433134331443315433164331743318433194332043321433224332343324433254332643327433284332943330433314333243333433344333543336433374333843339433404334143342433434334443345433464334743348433494335043351433524335343354433554335643357433584335943360433614336243363433644336543366433674336843369433704337143372433734337443375433764337743378433794338043381433824338343384433854338643387433884338943390433914339243393433944339543396433974339843399434004340143402434034340443405434064340743408434094341043411434124341343414434154341643417434184341943420434214342243423434244342543426434274342843429434304343143432434334343443435434364343743438434394344043441434424344343444434454344643447434484344943450434514345243453434544345543456434574345843459434604346143462434634346443465434664346743468434694347043471434724347343474434754347643477434784347943480434814348243483434844348543486434874348843489434904349143492434934349443495434964349743498434994350043501435024350343504435054350643507435084350943510435114351243513435144351543516435174351843519435204352143522435234352443525435264352743528435294353043531435324353343534435354353643537435384353943540435414354243543435444354543546435474354843549435504355143552435534355443555435564355743558435594356043561435624356343564435654356643567435684356943570435714357243573435744357543576435774357843579435804358143582435834358443585435864358743588435894359043591435924359343594435954359643597435984359943600436014360243603436044360543606436074360843609436104361143612436134361443615436164361743618436194362043621436224362343624436254362643627436284362943630436314363243633436344363543636436374363843639436404364143642436434364443645436464364743648436494365043651436524365343654436554365643657436584365943660436614366243663436644366543666436674366843669436704367143672436734367443675436764367743678436794368043681436824368343684436854368643687436884368943690436914369243693436944369543696436974369843699437004370143702437034370443705437064370743708437094371043711437124371343714437154371643717437184371943720437214372243723437244372543726437274372843729437304373143732437334373443735437364373743738437394374043741437424374343744437454374643747437484374943750437514375243753437544375543756437574375843759437604376143762437634376443765437664376743768437694377043771437724377343774437754377643777437784377943780437814378243783437844378543786437874378843789437904379143792437934379443795437964379743798437994380043801438024380343804438054380643807438084380943810438114381243813438144381543816438174381843819438204382143822438234382443825438264382743828438294383043831438324383343834438354383643837438384383943840438414384243843438444384543846438474384843849438504385143852438534385443855438564385743858438594386043861438624386343864438654386643867438684386943870438714387243873438744387543876438774387843879438804388143882438834388443885438864388743888438894389043891438924389343894438954389643897438984389943900439014390243903439044390543906439074390843909439104391143912439134391443915439164391743918439194392043921439224392343924439254392643927439284392943930439314393243933439344393543936439374393843939439404394143942439434394443945439464394743948439494395043951439524395343954439554395643957439584395943960439614396243963439644396543966439674396843969439704397143972439734397443975439764397743978439794398043981439824398343984439854398643987439884398943990439914399243993439944399543996439974399843999440004400144002440034400444005440064400744008440094401044011440124401344014440154401644017440184401944020440214402244023440244402544026440274402844029440304403144032440334403444035440364403744038440394404044041440424404344044440454404644047440484404944050440514405244053440544405544056440574405844059440604406144062440634406444065440664406744068440694407044071440724407344074440754407644077440784407944080440814408244083440844408544086440874408844089440904409144092440934409444095440964409744098440994410044101441024410344104441054410644107441084410944110441114411244113441144411544116441174411844119441204412144122441234412444125441264412744128441294413044131441324413344134441354413644137441384413944140441414414244143441444414544146441474414844149441504415144152441534415444155441564415744158441594416044161441624416344164441654416644167441684416944170441714417244173441744417544176441774417844179441804418144182441834418444185441864418744188441894419044191441924419344194441954419644197441984419944200442014420244203442044420544206442074420844209442104421144212442134421444215442164421744218442194422044221442224422344224442254422644227442284422944230442314423244233442344423544236442374423844239442404424144242442434424444245442464424744248442494425044251442524425344254442554425644257442584425944260442614426244263442644426544266442674426844269442704427144272442734427444275442764427744278442794428044281442824428344284442854428644287442884428944290442914429244293442944429544296442974429844299443004430144302443034430444305443064430744308443094431044311443124431344314443154431644317443184431944320443214432244323443244432544326443274432844329443304433144332443334433444335443364433744338443394434044341443424434344344443454434644347443484434944350443514435244353443544435544356443574435844359443604436144362443634436444365443664436744368443694437044371443724437344374443754437644377443784437944380443814438244383443844438544386443874438844389443904439144392443934439444395443964439744398443994440044401444024440344404444054440644407444084440944410444114441244413444144441544416444174441844419444204442144422444234442444425444264442744428444294443044431444324443344434444354443644437444384443944440444414444244443444444444544446444474444844449444504445144452444534445444455444564445744458444594446044461444624446344464444654446644467444684446944470444714447244473444744447544476444774447844479444804448144482444834448444485444864448744488444894449044491444924449344494444954449644497444984449944500445014450244503445044450544506445074450844509445104451144512445134451444515445164451744518445194452044521445224452344524445254452644527445284452944530445314453244533445344453544536445374453844539445404454144542445434454444545445464454744548445494455044551445524455344554445554455644557445584455944560445614456244563445644456544566445674456844569445704457144572445734457444575445764457744578445794458044581445824458344584445854458644587445884458944590445914459244593445944459544596445974459844599446004460144602446034460444605446064460744608446094461044611446124461344614446154461644617446184461944620446214462244623446244462544626446274462844629446304463144632446334463444635446364463744638446394464044641446424464344644446454464644647446484464944650446514465244653446544465544656446574465844659446604466144662446634466444665446664466744668446694467044671446724467344674446754467644677446784467944680446814468244683446844468544686446874468844689446904469144692446934469444695446964469744698446994470044701447024470344704447054470644707447084470944710447114471244713447144471544716447174471844719447204472144722447234472444725447264472744728447294473044731447324473344734447354473644737447384473944740447414474244743447444474544746447474474844749447504475144752447534475444755447564475744758447594476044761447624476344764447654476644767447684476944770447714477244773447744477544776447774477844779447804478144782447834478444785447864478744788447894479044791447924479344794447954479644797447984479944800448014480244803448044480544806448074480844809448104481144812448134481444815448164481744818448194482044821448224482344824448254482644827448284482944830448314483244833448344483544836448374483844839448404484144842448434484444845448464484744848448494485044851448524485344854448554485644857448584485944860448614486244863448644486544866448674486844869448704487144872448734487444875448764487744878448794488044881448824488344884448854488644887448884488944890448914489244893448944489544896448974489844899449004490144902449034490444905449064490744908449094491044911449124491344914449154491644917449184491944920449214492244923449244492544926449274492844929449304493144932449334493444935449364493744938449394494044941449424494344944449454494644947449484494944950449514495244953449544495544956449574495844959449604496144962449634496444965449664496744968449694497044971449724497344974449754497644977449784497944980449814498244983449844498544986449874498844989449904499144992449934499444995449964499744998449994500045001450024500345004450054500645007450084500945010450114501245013450144501545016450174501845019450204502145022450234502445025450264502745028450294503045031450324503345034450354503645037450384503945040450414504245043450444504545046450474504845049450504505145052450534505445055450564505745058450594506045061450624506345064450654506645067450684506945070450714507245073450744507545076450774507845079450804508145082450834508445085450864508745088450894509045091450924509345094450954509645097450984509945100451014510245103451044510545106451074510845109451104511145112451134511445115451164511745118451194512045121451224512345124451254512645127451284512945130451314513245133451344513545136451374513845139451404514145142451434514445145451464514745148451494515045151451524515345154451554515645157451584515945160451614516245163451644516545166451674516845169451704517145172451734517445175451764517745178451794518045181451824518345184451854518645187451884518945190451914519245193451944519545196451974519845199452004520145202452034520445205452064520745208452094521045211452124521345214452154521645217452184521945220452214522245223452244522545226452274522845229452304523145232452334523445235452364523745238452394524045241452424524345244452454524645247452484524945250452514525245253452544525545256452574525845259452604526145262452634526445265452664526745268452694527045271452724527345274452754527645277452784527945280452814528245283452844528545286452874528845289452904529145292452934529445295452964529745298452994530045301453024530345304453054530645307453084530945310453114531245313453144531545316453174531845319453204532145322453234532445325453264532745328453294533045331453324533345334453354533645337453384533945340453414534245343453444534545346453474534845349453504535145352453534535445355453564535745358453594536045361453624536345364453654536645367453684536945370453714537245373453744537545376453774537845379453804538145382453834538445385453864538745388453894539045391453924539345394453954539645397453984539945400454014540245403454044540545406454074540845409454104541145412454134541445415454164541745418454194542045421454224542345424454254542645427454284542945430454314543245433454344543545436454374543845439454404544145442454434544445445454464544745448454494545045451454524545345454454554545645457454584545945460454614546245463454644546545466454674546845469454704547145472454734547445475454764547745478454794548045481454824548345484454854548645487454884548945490454914549245493454944549545496454974549845499455004550145502455034550445505455064550745508455094551045511455124551345514455154551645517455184551945520455214552245523455244552545526455274552845529455304553145532455334553445535455364553745538455394554045541455424554345544455454554645547455484554945550455514555245553455544555545556455574555845559455604556145562455634556445565455664556745568455694557045571455724557345574455754557645577455784557945580455814558245583455844558545586455874558845589455904559145592455934559445595455964559745598455994560045601456024560345604456054560645607456084560945610456114561245613456144561545616456174561845619456204562145622456234562445625456264562745628456294563045631456324563345634456354563645637456384563945640456414564245643456444564545646456474564845649456504565145652456534565445655456564565745658456594566045661456624566345664456654566645667456684566945670456714567245673456744567545676456774567845679456804568145682456834568445685456864568745688456894569045691456924569345694456954569645697456984569945700457014570245703457044570545706457074570845709457104571145712457134571445715457164571745718457194572045721457224572345724457254572645727457284572945730457314573245733457344573545736457374573845739457404574145742457434574445745457464574745748457494575045751457524575345754457554575645757457584575945760457614576245763457644576545766457674576845769457704577145772457734577445775457764577745778457794578045781457824578345784457854578645787457884578945790457914579245793457944579545796457974579845799458004580145802458034580445805458064580745808458094581045811458124581345814458154581645817458184581945820458214582245823458244582545826458274582845829458304583145832458334583445835458364583745838458394584045841458424584345844458454584645847458484584945850458514585245853458544585545856458574585845859458604586145862458634586445865458664586745868458694587045871458724587345874458754587645877458784587945880458814588245883458844588545886458874588845889458904589145892458934589445895458964589745898458994590045901459024590345904459054590645907459084590945910459114591245913459144591545916459174591845919459204592145922459234592445925459264592745928459294593045931459324593345934459354593645937459384593945940459414594245943459444594545946459474594845949459504595145952459534595445955459564595745958459594596045961459624596345964459654596645967459684596945970459714597245973459744597545976459774597845979459804598145982459834598445985459864598745988459894599045991459924599345994459954599645997459984599946000460014600246003460044600546006460074600846009460104601146012460134601446015460164601746018460194602046021460224602346024460254602646027460284602946030460314603246033460344603546036460374603846039460404604146042460434604446045460464604746048460494605046051460524605346054460554605646057460584605946060460614606246063460644606546066460674606846069460704607146072460734607446075460764607746078460794608046081460824608346084460854608646087460884608946090460914609246093460944609546096460974609846099461004610146102461034610446105461064610746108461094611046111461124611346114461154611646117461184611946120461214612246123461244612546126461274612846129461304613146132461334613446135461364613746138461394614046141461424614346144461454614646147461484614946150461514615246153461544615546156461574615846159461604616146162461634616446165461664616746168461694617046171461724617346174461754617646177461784617946180461814618246183461844618546186461874618846189461904619146192461934619446195461964619746198461994620046201462024620346204462054620646207462084620946210462114621246213462144621546216462174621846219462204622146222462234622446225462264622746228462294623046231462324623346234462354623646237462384623946240462414624246243462444624546246462474624846249462504625146252462534625446255462564625746258462594626046261462624626346264462654626646267462684626946270462714627246273462744627546276462774627846279462804628146282462834628446285462864628746288462894629046291462924629346294462954629646297462984629946300463014630246303463044630546306463074630846309463104631146312463134631446315463164631746318463194632046321463224632346324463254632646327463284632946330463314633246333463344633546336463374633846339463404634146342463434634446345463464634746348463494635046351463524635346354463554635646357463584635946360463614636246363463644636546366463674636846369463704637146372463734637446375463764637746378463794638046381463824638346384463854638646387463884638946390463914639246393463944639546396463974639846399464004640146402464034640446405464064640746408464094641046411464124641346414464154641646417464184641946420464214642246423464244642546426464274642846429464304643146432464334643446435464364643746438464394644046441464424644346444464454644646447464484644946450464514645246453464544645546456464574645846459464604646146462464634646446465464664646746468464694647046471464724647346474464754647646477464784647946480464814648246483464844648546486464874648846489464904649146492464934649446495464964649746498464994650046501465024650346504465054650646507465084650946510465114651246513465144651546516465174651846519465204652146522465234652446525465264652746528465294653046531465324653346534465354653646537465384653946540465414654246543465444654546546465474654846549465504655146552465534655446555465564655746558465594656046561465624656346564465654656646567465684656946570465714657246573465744657546576465774657846579465804658146582465834658446585465864658746588465894659046591465924659346594465954659646597465984659946600466014660246603466044660546606466074660846609466104661146612466134661446615466164661746618466194662046621466224662346624466254662646627466284662946630466314663246633466344663546636466374663846639466404664146642466434664446645466464664746648466494665046651466524665346654466554665646657466584665946660466614666246663466644666546666466674666846669466704667146672466734667446675466764667746678466794668046681466824668346684466854668646687466884668946690466914669246693466944669546696466974669846699467004670146702467034670446705467064670746708467094671046711467124671346714467154671646717467184671946720467214672246723467244672546726467274672846729467304673146732467334673446735467364673746738467394674046741467424674346744467454674646747467484674946750467514675246753467544675546756467574675846759467604676146762467634676446765467664676746768467694677046771467724677346774467754677646777467784677946780467814678246783467844678546786467874678846789467904679146792467934679446795467964679746798467994680046801468024680346804468054680646807468084680946810468114681246813468144681546816468174681846819468204682146822468234682446825468264682746828468294683046831468324683346834468354683646837468384683946840468414684246843468444684546846468474684846849468504685146852468534685446855468564685746858468594686046861468624686346864468654686646867468684686946870468714687246873468744687546876468774687846879468804688146882468834688446885468864688746888468894689046891468924689346894468954689646897468984689946900469014690246903469044690546906469074690846909469104691146912469134691446915469164691746918469194692046921469224692346924469254692646927469284692946930469314693246933469344693546936469374693846939469404694146942469434694446945469464694746948469494695046951469524695346954469554695646957469584695946960469614696246963469644696546966469674696846969469704697146972469734697446975469764697746978469794698046981469824698346984469854698646987469884698946990469914699246993469944699546996469974699846999470004700147002470034700447005470064700747008470094701047011470124701347014470154701647017470184701947020470214702247023470244702547026470274702847029470304703147032470334703447035470364703747038470394704047041470424704347044470454704647047470484704947050470514705247053470544705547056470574705847059470604706147062470634706447065470664706747068470694707047071470724707347074470754707647077470784707947080470814708247083470844708547086470874708847089470904709147092470934709447095470964709747098470994710047101471024710347104471054710647107471084710947110471114711247113471144711547116471174711847119471204712147122471234712447125471264712747128471294713047131471324713347134471354713647137471384713947140471414714247143471444714547146471474714847149471504715147152471534715447155471564715747158471594716047161471624716347164471654716647167471684716947170471714717247173471744717547176471774717847179471804718147182471834718447185471864718747188471894719047191471924719347194471954719647197471984719947200472014720247203472044720547206472074720847209472104721147212472134721447215472164721747218472194722047221472224722347224472254722647227472284722947230472314723247233472344723547236472374723847239472404724147242472434724447245472464724747248472494725047251472524725347254472554725647257472584725947260472614726247263472644726547266472674726847269472704727147272472734727447275472764727747278472794728047281472824728347284472854728647287472884728947290472914729247293472944729547296472974729847299473004730147302473034730447305473064730747308473094731047311473124731347314473154731647317473184731947320473214732247323473244732547326473274732847329473304733147332473334733447335473364733747338473394734047341473424734347344473454734647347473484734947350473514735247353473544735547356473574735847359473604736147362473634736447365473664736747368473694737047371473724737347374473754737647377473784737947380473814738247383473844738547386473874738847389473904739147392473934739447395473964739747398473994740047401474024740347404474054740647407474084740947410474114741247413474144741547416474174741847419474204742147422474234742447425474264742747428474294743047431474324743347434474354743647437474384743947440474414744247443474444744547446474474744847449474504745147452474534745447455474564745747458474594746047461474624746347464474654746647467474684746947470474714747247473474744747547476474774747847479474804748147482474834748447485474864748747488474894749047491474924749347494474954749647497474984749947500475014750247503475044750547506475074750847509475104751147512475134751447515475164751747518475194752047521475224752347524475254752647527475284752947530475314753247533475344753547536475374753847539475404754147542475434754447545475464754747548475494755047551475524755347554475554755647557475584755947560475614756247563475644756547566475674756847569475704757147572475734757447575475764757747578475794758047581475824758347584475854758647587475884758947590475914759247593475944759547596475974759847599476004760147602476034760447605476064760747608476094761047611476124761347614476154761647617476184761947620476214762247623476244762547626476274762847629476304763147632476334763447635476364763747638476394764047641476424764347644476454764647647476484764947650476514765247653476544765547656476574765847659476604766147662476634766447665476664766747668476694767047671476724767347674476754767647677476784767947680476814768247683476844768547686476874768847689476904769147692476934769447695476964769747698476994770047701477024770347704477054770647707477084770947710477114771247713477144771547716477174771847719477204772147722477234772447725477264772747728477294773047731477324773347734477354773647737477384773947740477414774247743477444774547746477474774847749477504775147752477534775447755477564775747758477594776047761477624776347764477654776647767477684776947770477714777247773477744777547776477774777847779477804778147782477834778447785477864778747788477894779047791477924779347794477954779647797477984779947800478014780247803478044780547806478074780847809478104781147812478134781447815478164781747818478194782047821478224782347824478254782647827478284782947830478314783247833478344783547836478374783847839478404784147842478434784447845478464784747848478494785047851478524785347854478554785647857478584785947860478614786247863478644786547866478674786847869478704787147872478734787447875478764787747878478794788047881478824788347884478854788647887478884788947890478914789247893478944789547896478974789847899479004790147902479034790447905479064790747908479094791047911479124791347914479154791647917479184791947920479214792247923479244792547926479274792847929479304793147932479334793447935479364793747938479394794047941479424794347944479454794647947479484794947950479514795247953479544795547956479574795847959479604796147962479634796447965479664796747968479694797047971479724797347974479754797647977479784797947980479814798247983479844798547986479874798847989479904799147992479934799447995479964799747998479994800048001480024800348004480054800648007480084800948010480114801248013480144801548016480174801848019480204802148022480234802448025480264802748028480294803048031480324803348034480354803648037480384803948040480414804248043480444804548046480474804848049480504805148052480534805448055480564805748058480594806048061480624806348064480654806648067480684806948070480714807248073480744807548076480774807848079480804808148082480834808448085480864808748088480894809048091480924809348094480954809648097480984809948100481014810248103481044810548106481074810848109481104811148112481134811448115481164811748118481194812048121481224812348124481254812648127481284812948130481314813248133481344813548136481374813848139481404814148142481434814448145481464814748148481494815048151481524815348154481554815648157481584815948160481614816248163481644816548166481674816848169481704817148172481734817448175481764817748178481794818048181481824818348184481854818648187481884818948190481914819248193481944819548196481974819848199482004820148202482034820448205482064820748208482094821048211482124821348214482154821648217482184821948220482214822248223482244822548226482274822848229482304823148232482334823448235482364823748238482394824048241482424824348244482454824648247482484824948250482514825248253482544825548256482574825848259482604826148262482634826448265482664826748268482694827048271482724827348274482754827648277482784827948280482814828248283482844828548286482874828848289482904829148292482934829448295482964829748298482994830048301483024830348304483054830648307483084830948310483114831248313483144831548316483174831848319483204832148322483234832448325483264832748328483294833048331483324833348334483354833648337483384833948340483414834248343483444834548346483474834848349483504835148352483534835448355483564835748358483594836048361483624836348364483654836648367483684836948370483714837248373483744837548376483774837848379483804838148382483834838448385483864838748388483894839048391483924839348394483954839648397483984839948400484014840248403484044840548406484074840848409484104841148412484134841448415484164841748418484194842048421484224842348424484254842648427484284842948430484314843248433484344843548436484374843848439484404844148442484434844448445484464844748448484494845048451484524845348454484554845648457484584845948460484614846248463484644846548466484674846848469484704847148472484734847448475484764847748478484794848048481484824848348484484854848648487484884848948490484914849248493484944849548496484974849848499485004850148502485034850448505485064850748508485094851048511485124851348514485154851648517485184851948520485214852248523485244852548526485274852848529485304853148532485334853448535485364853748538485394854048541485424854348544485454854648547485484854948550485514855248553485544855548556485574855848559485604856148562485634856448565485664856748568485694857048571485724857348574485754857648577485784857948580485814858248583485844858548586485874858848589485904859148592485934859448595485964859748598485994860048601486024860348604486054860648607486084860948610486114861248613486144861548616486174861848619486204862148622486234862448625486264862748628486294863048631486324863348634486354863648637486384863948640486414864248643486444864548646486474864848649486504865148652486534865448655486564865748658486594866048661486624866348664486654866648667486684866948670486714867248673486744867548676486774867848679486804868148682486834868448685486864868748688486894869048691486924869348694486954869648697486984869948700487014870248703487044870548706487074870848709487104871148712487134871448715487164871748718487194872048721487224872348724487254872648727487284872948730487314873248733487344873548736487374873848739487404874148742487434874448745487464874748748487494875048751487524875348754487554875648757487584875948760487614876248763487644876548766487674876848769487704877148772487734877448775487764877748778487794878048781487824878348784487854878648787487884878948790487914879248793487944879548796487974879848799488004880148802488034880448805488064880748808488094881048811488124881348814488154881648817488184881948820488214882248823488244882548826488274882848829488304883148832488334883448835488364883748838488394884048841488424884348844488454884648847488484884948850488514885248853488544885548856488574885848859488604886148862488634886448865488664886748868488694887048871488724887348874488754887648877488784887948880488814888248883488844888548886488874888848889488904889148892488934889448895488964889748898488994890048901489024890348904489054890648907489084890948910489114891248913489144891548916489174891848919489204892148922489234892448925489264892748928489294893048931489324893348934489354893648937489384893948940489414894248943489444894548946489474894848949489504895148952489534895448955489564895748958489594896048961489624896348964489654896648967489684896948970489714897248973489744897548976489774897848979489804898148982489834898448985489864898748988489894899048991489924899348994489954899648997489984899949000490014900249003490044900549006490074900849009490104901149012490134901449015490164901749018490194902049021490224902349024490254902649027490284902949030490314903249033490344903549036490374903849039490404904149042490434904449045490464904749048490494905049051490524905349054490554905649057490584905949060490614906249063490644906549066490674906849069490704907149072490734907449075490764907749078490794908049081490824908349084490854908649087490884908949090490914909249093490944909549096490974909849099491004910149102491034910449105491064910749108491094911049111491124911349114491154911649117491184911949120491214912249123491244912549126491274912849129491304913149132491334913449135491364913749138491394914049141491424914349144491454914649147491484914949150491514915249153491544915549156491574915849159491604916149162491634916449165491664916749168491694917049171491724917349174491754917649177491784917949180491814918249183491844918549186491874918849189491904919149192491934919449195491964919749198491994920049201492024920349204492054920649207492084920949210492114921249213492144921549216492174921849219492204922149222492234922449225492264922749228492294923049231492324923349234492354923649237492384923949240492414924249243492444924549246492474924849249492504925149252492534925449255492564925749258492594926049261492624926349264492654926649267492684926949270492714927249273492744927549276492774927849279492804928149282492834928449285492864928749288492894929049291492924929349294492954929649297492984929949300493014930249303493044930549306493074930849309493104931149312493134931449315493164931749318493194932049321493224932349324493254932649327493284932949330493314933249333493344933549336493374933849339493404934149342493434934449345493464934749348493494935049351493524935349354493554935649357493584935949360493614936249363493644936549366493674936849369493704937149372493734937449375493764937749378493794938049381493824938349384493854938649387493884938949390493914939249393493944939549396493974939849399494004940149402494034940449405494064940749408494094941049411494124941349414494154941649417494184941949420494214942249423494244942549426494274942849429494304943149432494334943449435494364943749438494394944049441494424944349444494454944649447494484944949450494514945249453494544945549456494574945849459494604946149462494634946449465494664946749468494694947049471494724947349474494754947649477494784947949480494814948249483494844948549486494874948849489494904949149492494934949449495494964949749498494994950049501495024950349504495054950649507495084950949510495114951249513495144951549516495174951849519495204952149522495234952449525495264952749528495294953049531495324953349534495354953649537495384953949540495414954249543495444954549546495474954849549495504955149552495534955449555495564955749558495594956049561495624956349564495654956649567495684956949570495714957249573495744957549576495774957849579495804958149582495834958449585495864958749588495894959049591495924959349594495954959649597495984959949600496014960249603496044960549606496074960849609496104961149612496134961449615496164961749618496194962049621496224962349624496254962649627496284962949630496314963249633496344963549636496374963849639496404964149642496434964449645496464964749648496494965049651496524965349654496554965649657496584965949660496614966249663496644966549666496674966849669496704967149672496734967449675496764967749678496794968049681496824968349684496854968649687496884968949690496914969249693496944969549696496974969849699497004970149702497034970449705497064970749708497094971049711497124971349714497154971649717497184971949720497214972249723497244972549726497274972849729497304973149732497334973449735497364973749738497394974049741497424974349744497454974649747497484974949750497514975249753497544975549756497574975849759497604976149762497634976449765497664976749768497694977049771497724977349774497754977649777497784977949780497814978249783497844978549786497874978849789497904979149792497934979449795497964979749798497994980049801498024980349804498054980649807498084980949810498114981249813498144981549816498174981849819498204982149822498234982449825498264982749828498294983049831498324983349834498354983649837498384983949840498414984249843498444984549846498474984849849498504985149852498534985449855498564985749858498594986049861498624986349864498654986649867498684986949870498714987249873498744987549876498774987849879498804988149882498834988449885498864988749888498894989049891498924989349894498954989649897498984989949900499014990249903499044990549906499074990849909499104991149912499134991449915499164991749918499194992049921499224992349924499254992649927499284992949930499314993249933499344993549936499374993849939499404994149942499434994449945499464994749948499494995049951499524995349954499554995649957499584995949960499614996249963499644996549966499674996849969499704997149972499734997449975499764997749978499794998049981499824998349984499854998649987499884998949990499914999249993499944999549996499974999849999500005000150002500035000450005500065000750008500095001050011500125001350014500155001650017500185001950020500215002250023500245002550026500275002850029500305003150032500335003450035500365003750038500395004050041500425004350044500455004650047500485004950050500515005250053500545005550056500575005850059500605006150062500635006450065500665006750068500695007050071500725007350074500755007650077500785007950080500815008250083500845008550086500875008850089500905009150092500935009450095500965009750098500995010050101501025010350104501055010650107501085010950110501115011250113501145011550116501175011850119501205012150122501235012450125501265012750128501295013050131501325013350134501355013650137501385013950140501415014250143501445014550146501475014850149501505015150152501535015450155501565015750158501595016050161501625016350164501655016650167501685016950170501715017250173501745017550176501775017850179501805018150182501835018450185501865018750188501895019050191501925019350194501955019650197501985019950200502015020250203502045020550206502075020850209502105021150212502135021450215502165021750218502195022050221502225022350224502255022650227502285022950230502315023250233502345023550236502375023850239502405024150242502435024450245502465024750248502495025050251502525025350254502555025650257502585025950260502615026250263502645026550266502675026850269502705027150272502735027450275502765027750278502795028050281502825028350284502855028650287502885028950290502915029250293502945029550296502975029850299503005030150302503035030450305503065030750308503095031050311503125031350314503155031650317503185031950320503215032250323503245032550326503275032850329503305033150332503335033450335503365033750338503395034050341503425034350344503455034650347503485034950350503515035250353503545035550356503575035850359503605036150362503635036450365503665036750368503695037050371503725037350374503755037650377503785037950380503815038250383503845038550386503875038850389503905039150392503935039450395503965039750398503995040050401504025040350404504055040650407504085040950410504115041250413504145041550416504175041850419504205042150422504235042450425504265042750428504295043050431504325043350434504355043650437504385043950440504415044250443504445044550446504475044850449504505045150452504535045450455504565045750458504595046050461504625046350464504655046650467504685046950470504715047250473504745047550476504775047850479504805048150482504835048450485504865048750488504895049050491504925049350494504955049650497504985049950500505015050250503505045050550506505075050850509505105051150512505135051450515505165051750518505195052050521505225052350524505255052650527505285052950530505315053250533505345053550536505375053850539505405054150542505435054450545505465054750548505495055050551505525055350554505555055650557505585055950560505615056250563505645056550566505675056850569505705057150572505735057450575505765057750578505795058050581505825058350584505855058650587505885058950590505915059250593505945059550596505975059850599506005060150602506035060450605506065060750608506095061050611506125061350614506155061650617506185061950620506215062250623506245062550626506275062850629506305063150632506335063450635506365063750638506395064050641506425064350644506455064650647506485064950650506515065250653506545065550656506575065850659506605066150662506635066450665506665066750668506695067050671506725067350674506755067650677506785067950680506815068250683506845068550686506875068850689506905069150692506935069450695506965069750698506995070050701507025070350704507055070650707507085070950710507115071250713507145071550716507175071850719507205072150722507235072450725507265072750728507295073050731507325073350734507355073650737507385073950740507415074250743507445074550746507475074850749507505075150752507535075450755507565075750758507595076050761507625076350764507655076650767507685076950770507715077250773507745077550776507775077850779507805078150782507835078450785507865078750788507895079050791507925079350794507955079650797507985079950800508015080250803508045080550806508075080850809508105081150812508135081450815508165081750818508195082050821508225082350824508255082650827508285082950830508315083250833508345083550836508375083850839508405084150842508435084450845508465084750848508495085050851508525085350854508555085650857508585085950860508615086250863508645086550866508675086850869508705087150872508735087450875508765087750878508795088050881508825088350884508855088650887508885088950890508915089250893508945089550896508975089850899509005090150902509035090450905509065090750908509095091050911509125091350914509155091650917509185091950920509215092250923509245092550926509275092850929509305093150932509335093450935509365093750938509395094050941509425094350944509455094650947509485094950950509515095250953509545095550956509575095850959509605096150962509635096450965509665096750968509695097050971509725097350974509755097650977509785097950980509815098250983509845098550986509875098850989509905099150992509935099450995509965099750998509995100051001510025100351004510055100651007510085100951010510115101251013510145101551016510175101851019510205102151022510235102451025510265102751028510295103051031510325103351034510355103651037510385103951040510415104251043510445104551046510475104851049510505105151052510535105451055510565105751058510595106051061510625106351064510655106651067510685106951070510715107251073510745107551076510775107851079510805108151082510835108451085510865108751088510895109051091510925109351094510955109651097510985109951100511015110251103511045110551106511075110851109511105111151112511135111451115511165111751118511195112051121511225112351124511255112651127511285112951130511315113251133511345113551136511375113851139511405114151142511435114451145511465114751148511495115051151511525115351154511555115651157511585115951160511615116251163511645116551166511675116851169511705117151172511735117451175511765117751178511795118051181511825118351184511855118651187511885118951190511915119251193511945119551196511975119851199512005120151202512035120451205512065120751208512095121051211512125121351214512155121651217512185121951220512215122251223512245122551226512275122851229512305123151232512335123451235512365123751238512395124051241512425124351244512455124651247512485124951250512515125251253512545125551256512575125851259512605126151262512635126451265512665126751268512695127051271512725127351274512755127651277512785127951280512815128251283512845128551286512875128851289512905129151292512935129451295512965129751298512995130051301513025130351304513055130651307513085130951310513115131251313513145131551316513175131851319513205132151322513235132451325513265132751328513295133051331513325133351334513355133651337513385133951340513415134251343513445134551346513475134851349513505135151352513535135451355513565135751358513595136051361513625136351364513655136651367513685136951370513715137251373513745137551376513775137851379513805138151382513835138451385513865138751388513895139051391513925139351394513955139651397513985139951400514015140251403514045140551406514075140851409514105141151412514135141451415514165141751418514195142051421514225142351424514255142651427514285142951430514315143251433514345143551436514375143851439514405144151442514435144451445514465144751448514495145051451514525145351454514555145651457514585145951460514615146251463514645146551466514675146851469514705147151472514735147451475514765147751478514795148051481514825148351484514855148651487514885148951490514915149251493514945149551496514975149851499515005150151502515035150451505515065150751508515095151051511515125151351514515155151651517515185151951520515215152251523515245152551526515275152851529515305153151532515335153451535515365153751538515395154051541515425154351544515455154651547515485154951550515515155251553515545155551556515575155851559515605156151562515635156451565515665156751568515695157051571515725157351574515755157651577515785157951580515815158251583515845158551586515875158851589515905159151592515935159451595515965159751598515995160051601516025160351604516055160651607516085160951610516115161251613516145161551616516175161851619516205162151622516235162451625516265162751628516295163051631516325163351634516355163651637516385163951640516415164251643516445164551646516475164851649516505165151652516535165451655516565165751658516595166051661516625166351664516655166651667516685166951670516715167251673516745167551676516775167851679516805168151682516835168451685516865168751688516895169051691516925169351694516955169651697516985169951700517015170251703517045170551706517075170851709517105171151712517135171451715517165171751718517195172051721517225172351724517255172651727517285172951730517315173251733517345173551736517375173851739517405174151742517435174451745517465174751748517495175051751517525175351754517555175651757517585175951760517615176251763517645176551766517675176851769517705177151772517735177451775517765177751778517795178051781517825178351784517855178651787517885178951790517915179251793517945179551796517975179851799518005180151802518035180451805518065180751808518095181051811518125181351814518155181651817518185181951820518215182251823518245182551826518275182851829518305183151832518335183451835518365183751838518395184051841518425184351844518455184651847518485184951850518515185251853518545185551856518575185851859518605186151862518635186451865518665186751868518695187051871518725187351874518755187651877518785187951880518815188251883518845188551886518875188851889518905189151892518935189451895518965189751898518995190051901519025190351904519055190651907519085190951910519115191251913519145191551916519175191851919519205192151922519235192451925519265192751928519295193051931519325193351934519355193651937519385193951940519415194251943519445194551946519475194851949519505195151952519535195451955519565195751958519595196051961519625196351964519655196651967519685196951970519715197251973519745197551976519775197851979519805198151982519835198451985519865198751988519895199051991519925199351994519955199651997519985199952000520015200252003520045200552006520075200852009520105201152012520135201452015520165201752018520195202052021520225202352024520255202652027520285202952030520315203252033520345203552036520375203852039520405204152042520435204452045520465204752048520495205052051520525205352054520555205652057520585205952060520615206252063520645206552066520675206852069520705207152072520735207452075520765207752078520795208052081520825208352084520855208652087520885208952090520915209252093520945209552096520975209852099521005210152102521035210452105521065210752108521095211052111521125211352114521155211652117521185211952120521215212252123521245212552126521275212852129521305213152132521335213452135521365213752138521395214052141521425214352144521455214652147521485214952150521515215252153521545215552156521575215852159521605216152162521635216452165521665216752168521695217052171521725217352174521755217652177521785217952180521815218252183521845218552186521875218852189521905219152192521935219452195521965219752198521995220052201522025220352204522055220652207522085220952210522115221252213522145221552216522175221852219522205222152222522235222452225522265222752228522295223052231522325223352234522355223652237522385223952240522415224252243522445224552246522475224852249522505225152252522535225452255522565225752258522595226052261522625226352264522655226652267522685226952270522715227252273522745227552276522775227852279522805228152282522835228452285522865228752288522895229052291522925229352294522955229652297522985229952300523015230252303523045230552306523075230852309523105231152312523135231452315523165231752318523195232052321523225232352324523255232652327523285232952330523315233252333523345233552336523375233852339523405234152342523435234452345523465234752348523495235052351523525235352354523555235652357523585235952360523615236252363523645236552366523675236852369523705237152372523735237452375523765237752378523795238052381523825238352384523855238652387523885238952390523915239252393523945239552396523975239852399524005240152402524035240452405524065240752408524095241052411524125241352414524155241652417524185241952420524215242252423524245242552426524275242852429524305243152432524335243452435524365243752438524395244052441524425244352444524455244652447524485244952450524515245252453524545245552456524575245852459524605246152462524635246452465524665246752468524695247052471524725247352474524755247652477524785247952480524815248252483524845248552486524875248852489524905249152492524935249452495524965249752498524995250052501525025250352504525055250652507525085250952510525115251252513525145251552516525175251852519525205252152522525235252452525525265252752528525295253052531525325253352534525355253652537525385253952540525415254252543525445254552546525475254852549525505255152552525535255452555525565255752558525595256052561525625256352564525655256652567525685256952570525715257252573525745257552576525775257852579525805258152582525835258452585525865258752588525895259052591525925259352594525955259652597525985259952600526015260252603526045260552606526075260852609526105261152612526135261452615526165261752618526195262052621526225262352624526255262652627526285262952630526315263252633526345263552636526375263852639526405264152642526435264452645526465264752648526495265052651526525265352654526555265652657526585265952660526615266252663526645266552666526675266852669526705267152672526735267452675526765267752678526795268052681526825268352684526855268652687526885268952690526915269252693526945269552696526975269852699527005270152702527035270452705527065270752708527095271052711527125271352714527155271652717527185271952720527215272252723527245272552726527275272852729527305273152732527335273452735527365273752738527395274052741527425274352744527455274652747527485274952750527515275252753527545275552756527575275852759527605276152762527635276452765527665276752768527695277052771527725277352774527755277652777527785277952780527815278252783527845278552786527875278852789527905279152792527935279452795527965279752798527995280052801528025280352804528055280652807528085280952810528115281252813528145281552816528175281852819528205282152822528235282452825528265282752828528295283052831528325283352834528355283652837528385283952840528415284252843528445284552846528475284852849528505285152852528535285452855528565285752858528595286052861528625286352864528655286652867528685286952870528715287252873528745287552876528775287852879528805288152882528835288452885528865288752888528895289052891528925289352894528955289652897528985289952900529015290252903529045290552906529075290852909529105291152912529135291452915529165291752918529195292052921529225292352924529255292652927529285292952930529315293252933529345293552936529375293852939529405294152942529435294452945529465294752948529495295052951529525295352954529555295652957529585295952960529615296252963529645296552966529675296852969529705297152972529735297452975529765297752978529795298052981529825298352984529855298652987529885298952990529915299252993529945299552996529975299852999530005300153002530035300453005530065300753008530095301053011530125301353014530155301653017530185301953020530215302253023530245302553026530275302853029530305303153032530335303453035530365303753038530395304053041530425304353044530455304653047530485304953050530515305253053530545305553056530575305853059530605306153062530635306453065530665306753068530695307053071530725307353074530755307653077530785307953080530815308253083530845308553086530875308853089530905309153092530935309453095530965309753098530995310053101531025310353104531055310653107531085310953110531115311253113531145311553116531175311853119531205312153122531235312453125531265312753128531295313053131531325313353134531355313653137531385313953140531415314253143531445314553146531475314853149531505315153152531535315453155531565315753158531595316053161531625316353164531655316653167531685316953170531715317253173531745317553176531775317853179531805318153182531835318453185531865318753188531895319053191531925319353194531955319653197531985319953200532015320253203532045320553206532075320853209532105321153212532135321453215532165321753218532195322053221532225322353224532255322653227532285322953230532315323253233532345323553236532375323853239532405324153242532435324453245532465324753248532495325053251532525325353254532555325653257532585325953260532615326253263532645326553266532675326853269532705327153272532735327453275532765327753278532795328053281532825328353284532855328653287532885328953290532915329253293532945329553296532975329853299533005330153302533035330453305533065330753308533095331053311533125331353314533155331653317533185331953320533215332253323533245332553326533275332853329533305333153332533335333453335533365333753338533395334053341533425334353344533455334653347533485334953350533515335253353533545335553356533575335853359533605336153362533635336453365533665336753368533695337053371533725337353374533755337653377533785337953380533815338253383533845338553386533875338853389533905339153392533935339453395533965339753398533995340053401534025340353404534055340653407534085340953410534115341253413534145341553416534175341853419534205342153422534235342453425534265342753428534295343053431534325343353434534355343653437534385343953440534415344253443534445344553446534475344853449534505345153452534535345453455534565345753458534595346053461534625346353464534655346653467534685346953470534715347253473534745347553476534775347853479534805348153482534835348453485534865348753488534895349053491534925349353494534955349653497534985349953500535015350253503535045350553506535075350853509535105351153512535135351453515535165351753518535195352053521535225352353524535255352653527535285352953530535315353253533535345353553536535375353853539535405354153542535435354453545535465354753548535495355053551535525355353554535555355653557535585355953560535615356253563535645356553566535675356853569535705357153572535735357453575535765357753578535795358053581535825358353584535855358653587535885358953590535915359253593535945359553596535975359853599536005360153602536035360453605536065360753608536095361053611536125361353614536155361653617536185361953620536215362253623536245362553626536275362853629536305363153632536335363453635536365363753638536395364053641536425364353644536455364653647536485364953650536515365253653536545365553656536575365853659536605366153662536635366453665536665366753668536695367053671536725367353674536755367653677536785367953680536815368253683536845368553686536875368853689536905369153692536935369453695536965369753698536995370053701537025370353704537055370653707537085370953710537115371253713537145371553716537175371853719537205372153722537235372453725537265372753728537295373053731537325373353734537355373653737537385373953740537415374253743537445374553746537475374853749537505375153752537535375453755537565375753758537595376053761537625376353764537655376653767537685376953770537715377253773537745377553776537775377853779537805378153782537835378453785537865378753788537895379053791537925379353794537955379653797537985379953800538015380253803538045380553806538075380853809538105381153812538135381453815538165381753818538195382053821538225382353824538255382653827538285382953830538315383253833538345383553836538375383853839538405384153842538435384453845538465384753848538495385053851538525385353854538555385653857538585385953860538615386253863538645386553866538675386853869538705387153872538735387453875538765387753878538795388053881538825388353884538855388653887538885388953890538915389253893538945389553896538975389853899539005390153902539035390453905539065390753908539095391053911539125391353914539155391653917539185391953920539215392253923539245392553926539275392853929539305393153932539335393453935539365393753938539395394053941539425394353944539455394653947539485394953950539515395253953539545395553956539575395853959539605396153962539635396453965539665396753968539695397053971539725397353974539755397653977539785397953980539815398253983539845398553986539875398853989539905399153992539935399453995539965399753998539995400054001540025400354004540055400654007540085400954010540115401254013540145401554016540175401854019540205402154022540235402454025540265402754028540295403054031540325403354034540355403654037540385403954040540415404254043540445404554046540475404854049540505405154052540535405454055540565405754058540595406054061540625406354064540655406654067540685406954070540715407254073540745407554076540775407854079540805408154082540835408454085540865408754088540895409054091540925409354094540955409654097540985409954100541015410254103541045410554106541075410854109541105411154112541135411454115541165411754118541195412054121541225412354124541255412654127541285412954130541315413254133541345413554136541375413854139541405414154142541435414454145541465414754148541495415054151541525415354154541555415654157541585415954160541615416254163541645416554166541675416854169541705417154172541735417454175541765417754178541795418054181541825418354184541855418654187541885418954190541915419254193541945419554196541975419854199542005420154202542035420454205542065420754208542095421054211542125421354214542155421654217542185421954220542215422254223542245422554226542275422854229542305423154232542335423454235542365423754238542395424054241542425424354244542455424654247542485424954250542515425254253542545425554256542575425854259542605426154262542635426454265542665426754268542695427054271542725427354274542755427654277542785427954280542815428254283542845428554286542875428854289542905429154292542935429454295542965429754298542995430054301543025430354304543055430654307543085430954310543115431254313543145431554316543175431854319543205432154322543235432454325543265432754328543295433054331543325433354334543355433654337543385433954340543415434254343543445434554346543475434854349543505435154352543535435454355543565435754358543595436054361543625436354364543655436654367543685436954370543715437254373543745437554376543775437854379543805438154382543835438454385543865438754388543895439054391543925439354394543955439654397543985439954400544015440254403544045440554406544075440854409544105441154412544135441454415544165441754418544195442054421544225442354424544255442654427544285442954430544315443254433544345443554436544375443854439544405444154442544435444454445544465444754448544495445054451544525445354454544555445654457544585445954460544615446254463544645446554466544675446854469544705447154472544735447454475544765447754478544795448054481544825448354484544855448654487544885448954490544915449254493544945449554496544975449854499545005450154502545035450454505545065450754508545095451054511545125451354514545155451654517545185451954520545215452254523545245452554526545275452854529545305453154532545335453454535545365453754538545395454054541545425454354544545455454654547545485454954550545515455254553545545455554556545575455854559545605456154562545635456454565545665456754568545695457054571545725457354574545755457654577545785457954580545815458254583545845458554586545875458854589545905459154592545935459454595545965459754598545995460054601546025460354604546055460654607546085460954610546115461254613546145461554616546175461854619546205462154622546235462454625546265462754628546295463054631546325463354634546355463654637546385463954640546415464254643546445464554646546475464854649546505465154652546535465454655546565465754658546595466054661546625466354664546655466654667546685466954670546715467254673546745467554676546775467854679546805468154682546835468454685546865468754688546895469054691546925469354694546955469654697546985469954700547015470254703547045470554706547075470854709547105471154712547135471454715547165471754718547195472054721547225472354724547255472654727547285472954730547315473254733547345473554736547375473854739547405474154742547435474454745547465474754748547495475054751547525475354754547555475654757547585475954760547615476254763547645476554766547675476854769547705477154772547735477454775547765477754778547795478054781547825478354784547855478654787547885478954790547915479254793547945479554796547975479854799548005480154802548035480454805548065480754808548095481054811548125481354814548155481654817548185481954820548215482254823548245482554826548275482854829548305483154832548335483454835548365483754838548395484054841548425484354844548455484654847548485484954850548515485254853548545485554856548575485854859548605486154862548635486454865548665486754868548695487054871548725487354874548755487654877548785487954880548815488254883548845488554886548875488854889548905489154892548935489454895548965489754898548995490054901549025490354904549055490654907549085490954910549115491254913549145491554916549175491854919549205492154922549235492454925549265492754928549295493054931549325493354934549355493654937549385493954940549415494254943549445494554946549475494854949549505495154952549535495454955549565495754958549595496054961549625496354964549655496654967549685496954970549715497254973549745497554976549775497854979549805498154982549835498454985549865498754988549895499054991549925499354994549955499654997549985499955000550015500255003550045500555006550075500855009550105501155012550135501455015550165501755018550195502055021550225502355024550255502655027550285502955030550315503255033550345503555036550375503855039550405504155042550435504455045550465504755048550495505055051550525505355054550555505655057550585505955060550615506255063550645506555066550675506855069550705507155072550735507455075550765507755078550795508055081550825508355084550855508655087550885508955090550915509255093550945509555096550975509855099551005510155102551035510455105551065510755108551095511055111551125511355114551155511655117551185511955120551215512255123551245512555126551275512855129551305513155132551335513455135551365513755138551395514055141551425514355144551455514655147551485514955150551515515255153551545515555156551575515855159551605516155162551635516455165551665516755168551695517055171551725517355174551755517655177551785517955180551815518255183551845518555186551875518855189551905519155192551935519455195551965519755198551995520055201552025520355204552055520655207552085520955210552115521255213552145521555216552175521855219552205522155222552235522455225552265522755228552295523055231552325523355234552355523655237552385523955240552415524255243552445524555246552475524855249552505525155252552535525455255552565525755258552595526055261552625526355264552655526655267552685526955270552715527255273552745527555276552775527855279552805528155282552835528455285552865528755288552895529055291552925529355294552955529655297552985529955300553015530255303553045530555306553075530855309553105531155312553135531455315553165531755318553195532055321553225532355324553255532655327553285532955330553315533255333553345533555336553375533855339553405534155342553435534455345553465534755348553495535055351553525535355354553555535655357553585535955360553615536255363553645536555366553675536855369553705537155372553735537455375553765537755378553795538055381553825538355384553855538655387553885538955390553915539255393553945539555396553975539855399554005540155402554035540455405554065540755408554095541055411554125541355414554155541655417554185541955420554215542255423554245542555426554275542855429554305543155432554335543455435554365543755438554395544055441554425544355444554455544655447554485544955450554515545255453554545545555456554575545855459554605546155462554635546455465554665546755468554695547055471554725547355474554755547655477554785547955480554815548255483554845548555486554875548855489554905549155492554935549455495554965549755498554995550055501555025550355504555055550655507555085550955510555115551255513555145551555516555175551855519555205552155522555235552455525555265552755528555295553055531555325553355534555355553655537555385553955540555415554255543555445554555546555475554855549555505555155552555535555455555555565555755558555595556055561555625556355564555655556655567555685556955570555715557255573555745557555576555775557855579555805558155582555835558455585555865558755588555895559055591555925559355594555955559655597555985559955600556015560255603556045560555606556075560855609556105561155612556135561455615556165561755618556195562055621556225562355624556255562655627556285562955630556315563255633556345563555636556375563855639556405564155642556435564455645556465564755648556495565055651556525565355654556555565655657556585565955660556615566255663556645566555666556675566855669556705567155672556735567455675556765567755678556795568055681556825568355684556855568655687556885568955690556915569255693556945569555696556975569855699557005570155702557035570455705557065570755708557095571055711557125571355714557155571655717557185571955720557215572255723557245572555726557275572855729557305573155732557335573455735557365573755738557395574055741557425574355744557455574655747557485574955750557515575255753557545575555756557575575855759557605576155762557635576455765557665576755768557695577055771557725577355774557755577655777557785577955780557815578255783557845578555786557875578855789557905579155792557935579455795557965579755798557995580055801558025580355804558055580655807558085580955810558115581255813558145581555816558175581855819558205582155822558235582455825558265582755828558295583055831558325583355834558355583655837558385583955840558415584255843558445584555846558475584855849558505585155852558535585455855558565585755858558595586055861558625586355864558655586655867558685586955870558715587255873558745587555876558775587855879558805588155882558835588455885558865588755888558895589055891558925589355894558955589655897558985589955900559015590255903559045590555906559075590855909559105591155912559135591455915559165591755918559195592055921559225592355924559255592655927559285592955930559315593255933559345593555936559375593855939559405594155942559435594455945559465594755948559495595055951559525595355954559555595655957559585595955960559615596255963559645596555966559675596855969559705597155972559735597455975559765597755978559795598055981559825598355984559855598655987559885598955990559915599255993559945599555996559975599855999560005600156002560035600456005560065600756008560095601056011560125601356014560155601656017560185601956020560215602256023560245602556026560275602856029560305603156032560335603456035560365603756038560395604056041560425604356044560455604656047560485604956050560515605256053560545605556056560575605856059560605606156062560635606456065560665606756068560695607056071560725607356074560755607656077560785607956080560815608256083560845608556086560875608856089560905609156092560935609456095560965609756098560995610056101561025610356104561055610656107561085610956110561115611256113561145611556116561175611856119561205612156122561235612456125561265612756128561295613056131561325613356134561355613656137561385613956140561415614256143561445614556146561475614856149561505615156152561535615456155561565615756158561595616056161561625616356164561655616656167561685616956170561715617256173561745617556176561775617856179561805618156182561835618456185561865618756188561895619056191561925619356194561955619656197561985619956200562015620256203562045620556206562075620856209562105621156212562135621456215562165621756218562195622056221562225622356224562255622656227562285622956230562315623256233562345623556236562375623856239562405624156242562435624456245562465624756248562495625056251562525625356254562555625656257562585625956260562615626256263562645626556266562675626856269562705627156272562735627456275562765627756278562795628056281562825628356284562855628656287562885628956290562915629256293562945629556296562975629856299563005630156302563035630456305563065630756308563095631056311563125631356314563155631656317563185631956320563215632256323563245632556326563275632856329563305633156332563335633456335563365633756338563395634056341563425634356344563455634656347563485634956350563515635256353563545635556356563575635856359563605636156362563635636456365563665636756368563695637056371563725637356374563755637656377563785637956380563815638256383563845638556386563875638856389563905639156392563935639456395563965639756398563995640056401564025640356404564055640656407564085640956410564115641256413564145641556416564175641856419564205642156422564235642456425564265642756428564295643056431564325643356434564355643656437564385643956440564415644256443564445644556446564475644856449564505645156452564535645456455564565645756458564595646056461564625646356464564655646656467564685646956470564715647256473564745647556476564775647856479564805648156482564835648456485564865648756488564895649056491564925649356494564955649656497564985649956500565015650256503565045650556506565075650856509565105651156512565135651456515565165651756518565195652056521565225652356524565255652656527565285652956530565315653256533565345653556536565375653856539565405654156542565435654456545565465654756548565495655056551565525655356554565555655656557565585655956560565615656256563565645656556566565675656856569565705657156572565735657456575565765657756578565795658056581565825658356584565855658656587565885658956590565915659256593565945659556596565975659856599566005660156602566035660456605566065660756608566095661056611566125661356614566155661656617566185661956620566215662256623566245662556626566275662856629566305663156632566335663456635566365663756638566395664056641566425664356644566455664656647566485664956650566515665256653566545665556656566575665856659566605666156662566635666456665566665666756668566695667056671566725667356674566755667656677566785667956680566815668256683566845668556686566875668856689566905669156692566935669456695566965669756698566995670056701567025670356704567055670656707567085670956710567115671256713567145671556716567175671856719567205672156722567235672456725567265672756728567295673056731567325673356734567355673656737567385673956740567415674256743567445674556746567475674856749567505675156752567535675456755567565675756758567595676056761567625676356764567655676656767567685676956770567715677256773567745677556776567775677856779567805678156782567835678456785567865678756788567895679056791567925679356794567955679656797567985679956800568015680256803568045680556806568075680856809568105681156812568135681456815568165681756818568195682056821568225682356824568255682656827568285682956830568315683256833568345683556836568375683856839568405684156842568435684456845568465684756848568495685056851568525685356854568555685656857568585685956860568615686256863568645686556866568675686856869568705687156872568735687456875568765687756878568795688056881568825688356884568855688656887568885688956890568915689256893568945689556896568975689856899569005690156902569035690456905569065690756908569095691056911569125691356914569155691656917569185691956920569215692256923569245692556926569275692856929569305693156932569335693456935569365693756938569395694056941569425694356944569455694656947569485694956950569515695256953569545695556956569575695856959569605696156962569635696456965569665696756968569695697056971569725697356974569755697656977569785697956980569815698256983569845698556986569875698856989569905699156992569935699456995569965699756998569995700057001570025700357004570055700657007570085700957010570115701257013570145701557016570175701857019570205702157022570235702457025570265702757028570295703057031570325703357034570355703657037570385703957040570415704257043570445704557046570475704857049570505705157052570535705457055570565705757058570595706057061570625706357064570655706657067570685706957070570715707257073570745707557076570775707857079570805708157082570835708457085570865708757088570895709057091570925709357094570955709657097570985709957100571015710257103571045710557106571075710857109571105711157112571135711457115571165711757118571195712057121571225712357124571255712657127571285712957130571315713257133571345713557136571375713857139571405714157142571435714457145571465714757148571495715057151571525715357154571555715657157571585715957160571615716257163571645716557166571675716857169571705717157172571735717457175571765717757178571795718057181571825718357184571855718657187571885718957190571915719257193571945719557196571975719857199572005720157202572035720457205572065720757208572095721057211572125721357214572155721657217572185721957220572215722257223572245722557226572275722857229572305723157232572335723457235572365723757238572395724057241572425724357244572455724657247572485724957250572515725257253572545725557256572575725857259572605726157262572635726457265572665726757268572695727057271572725727357274572755727657277572785727957280572815728257283572845728557286572875728857289572905729157292572935729457295572965729757298572995730057301573025730357304573055730657307573085730957310573115731257313573145731557316573175731857319573205732157322573235732457325573265732757328573295733057331573325733357334573355733657337573385733957340573415734257343573445734557346573475734857349573505735157352573535735457355573565735757358573595736057361573625736357364573655736657367573685736957370573715737257373573745737557376573775737857379573805738157382573835738457385573865738757388573895739057391573925739357394573955739657397573985739957400574015740257403574045740557406574075740857409574105741157412574135741457415574165741757418574195742057421574225742357424574255742657427574285742957430574315743257433574345743557436574375743857439574405744157442574435744457445574465744757448574495745057451574525745357454574555745657457574585745957460574615746257463574645746557466574675746857469574705747157472574735747457475574765747757478574795748057481574825748357484574855748657487574885748957490574915749257493574945749557496574975749857499575005750157502575035750457505575065750757508575095751057511575125751357514575155751657517575185751957520575215752257523575245752557526575275752857529575305753157532575335753457535575365753757538575395754057541575425754357544575455754657547575485754957550575515755257553575545755557556575575755857559575605756157562575635756457565575665756757568575695757057571575725757357574575755757657577575785757957580575815758257583575845758557586575875758857589575905759157592575935759457595575965759757598575995760057601576025760357604576055760657607576085760957610576115761257613576145761557616576175761857619576205762157622576235762457625576265762757628576295763057631576325763357634576355763657637576385763957640576415764257643576445764557646576475764857649576505765157652576535765457655576565765757658576595766057661576625766357664576655766657667576685766957670576715767257673576745767557676576775767857679576805768157682576835768457685576865768757688576895769057691576925769357694576955769657697576985769957700577015770257703577045770557706577075770857709577105771157712577135771457715577165771757718577195772057721577225772357724577255772657727577285772957730577315773257733577345773557736577375773857739577405774157742577435774457745577465774757748577495775057751577525775357754577555775657757577585775957760577615776257763577645776557766577675776857769577705777157772577735777457775577765777757778577795778057781577825778357784577855778657787577885778957790577915779257793577945779557796577975779857799578005780157802578035780457805578065780757808578095781057811578125781357814578155781657817578185781957820578215782257823578245782557826578275782857829578305783157832578335783457835578365783757838578395784057841578425784357844578455784657847578485784957850578515785257853578545785557856578575785857859578605786157862578635786457865578665786757868578695787057871578725787357874578755787657877578785787957880578815788257883578845788557886578875788857889578905789157892578935789457895578965789757898578995790057901579025790357904579055790657907579085790957910579115791257913579145791557916579175791857919579205792157922579235792457925579265792757928579295793057931579325793357934579355793657937579385793957940579415794257943579445794557946579475794857949579505795157952579535795457955579565795757958579595796057961579625796357964579655796657967579685796957970579715797257973579745797557976579775797857979579805798157982579835798457985579865798757988579895799057991579925799357994579955799657997579985799958000580015800258003580045800558006580075800858009580105801158012580135801458015580165801758018580195802058021580225802358024580255802658027580285802958030580315803258033580345803558036580375803858039580405804158042580435804458045580465804758048580495805058051580525805358054580555805658057580585805958060580615806258063580645806558066580675806858069580705807158072580735807458075580765807758078580795808058081580825808358084580855808658087580885808958090580915809258093580945809558096580975809858099581005810158102581035810458105581065810758108581095811058111581125811358114581155811658117581185811958120581215812258123581245812558126581275812858129581305813158132581335813458135581365813758138581395814058141581425814358144581455814658147581485814958150581515815258153581545815558156581575815858159581605816158162581635816458165581665816758168581695817058171581725817358174581755817658177581785817958180581815818258183581845818558186581875818858189581905819158192581935819458195581965819758198581995820058201582025820358204582055820658207582085820958210582115821258213582145821558216582175821858219582205822158222582235822458225582265822758228582295823058231582325823358234582355823658237582385823958240582415824258243582445824558246582475824858249582505825158252582535825458255582565825758258582595826058261582625826358264582655826658267582685826958270582715827258273582745827558276582775827858279582805828158282582835828458285582865828758288582895829058291582925829358294582955829658297582985829958300583015830258303583045830558306583075830858309583105831158312583135831458315583165831758318583195832058321583225832358324583255832658327583285832958330583315833258333583345833558336583375833858339583405834158342583435834458345583465834758348583495835058351583525835358354583555835658357583585835958360583615836258363583645836558366583675836858369583705837158372583735837458375583765837758378583795838058381583825838358384583855838658387583885838958390583915839258393583945839558396583975839858399584005840158402584035840458405584065840758408584095841058411584125841358414584155841658417584185841958420584215842258423584245842558426584275842858429584305843158432584335843458435584365843758438584395844058441584425844358444584455844658447584485844958450584515845258453584545845558456584575845858459584605846158462584635846458465584665846758468584695847058471584725847358474584755847658477584785847958480584815848258483584845848558486584875848858489584905849158492584935849458495584965849758498584995850058501585025850358504585055850658507585085850958510585115851258513585145851558516585175851858519585205852158522585235852458525585265852758528585295853058531585325853358534585355853658537585385853958540585415854258543585445854558546585475854858549585505855158552585535855458555585565855758558585595856058561585625856358564585655856658567585685856958570585715857258573585745857558576585775857858579585805858158582585835858458585585865858758588585895859058591585925859358594585955859658597585985859958600586015860258603586045860558606586075860858609586105861158612586135861458615586165861758618586195862058621586225862358624586255862658627586285862958630586315863258633586345863558636586375863858639586405864158642586435864458645586465864758648586495865058651586525865358654586555865658657586585865958660586615866258663586645866558666586675866858669586705867158672586735867458675586765867758678586795868058681586825868358684586855868658687586885868958690586915869258693586945869558696586975869858699587005870158702587035870458705587065870758708587095871058711587125871358714587155871658717587185871958720587215872258723587245872558726587275872858729587305873158732587335873458735587365873758738587395874058741587425874358744587455874658747587485874958750587515875258753587545875558756587575875858759587605876158762587635876458765587665876758768587695877058771587725877358774587755877658777587785877958780587815878258783587845878558786587875878858789587905879158792587935879458795587965879758798587995880058801588025880358804588055880658807588085880958810588115881258813588145881558816588175881858819588205882158822588235882458825588265882758828588295883058831588325883358834588355883658837588385883958840588415884258843588445884558846588475884858849588505885158852588535885458855588565885758858588595886058861588625886358864588655886658867588685886958870588715887258873588745887558876588775887858879588805888158882588835888458885588865888758888588895889058891588925889358894588955889658897588985889958900589015890258903589045890558906589075890858909589105891158912589135891458915589165891758918589195892058921589225892358924589255892658927589285892958930589315893258933589345893558936589375893858939589405894158942589435894458945589465894758948589495895058951589525895358954589555895658957589585895958960589615896258963589645896558966589675896858969589705897158972589735897458975589765897758978589795898058981589825898358984589855898658987589885898958990589915899258993589945899558996589975899858999590005900159002590035900459005590065900759008590095901059011590125901359014590155901659017590185901959020590215902259023590245902559026590275902859029590305903159032590335903459035590365903759038590395904059041590425904359044590455904659047590485904959050590515905259053590545905559056590575905859059590605906159062590635906459065590665906759068590695907059071590725907359074590755907659077590785907959080590815908259083590845908559086590875908859089590905909159092590935909459095590965909759098590995910059101591025910359104591055910659107591085910959110591115911259113591145911559116591175911859119591205912159122591235912459125591265912759128591295913059131591325913359134591355913659137591385913959140591415914259143591445914559146591475914859149591505915159152591535915459155591565915759158591595916059161591625916359164591655916659167591685916959170591715917259173591745917559176591775917859179591805918159182591835918459185591865918759188591895919059191591925919359194591955919659197591985919959200592015920259203592045920559206592075920859209592105921159212592135921459215592165921759218592195922059221592225922359224592255922659227592285922959230592315923259233592345923559236592375923859239592405924159242592435924459245592465924759248592495925059251592525925359254592555925659257592585925959260592615926259263592645926559266592675926859269592705927159272592735927459275592765927759278592795928059281592825928359284592855928659287592885928959290592915929259293592945929559296592975929859299593005930159302593035930459305593065930759308593095931059311593125931359314593155931659317593185931959320593215932259323593245932559326593275932859329593305933159332593335933459335593365933759338593395934059341593425934359344593455934659347593485934959350593515935259353593545935559356593575935859359593605936159362593635936459365593665936759368593695937059371593725937359374593755937659377593785937959380593815938259383593845938559386593875938859389593905939159392593935939459395593965939759398593995940059401594025940359404594055940659407594085940959410594115941259413594145941559416594175941859419594205942159422594235942459425594265942759428594295943059431594325943359434594355943659437594385943959440594415944259443594445944559446594475944859449594505945159452594535945459455594565945759458594595946059461594625946359464594655946659467594685946959470594715947259473594745947559476594775947859479594805948159482594835948459485594865948759488594895949059491594925949359494594955949659497594985949959500595015950259503595045950559506595075950859509595105951159512595135951459515595165951759518595195952059521595225952359524595255952659527595285952959530595315953259533595345953559536595375953859539595405954159542595435954459545595465954759548595495955059551595525955359554595555955659557595585955959560595615956259563595645956559566595675956859569595705957159572595735957459575595765957759578595795958059581595825958359584595855958659587595885958959590595915959259593595945959559596595975959859599596005960159602596035960459605596065960759608596095961059611596125961359614596155961659617596185961959620596215962259623596245962559626596275962859629596305963159632596335963459635596365963759638596395964059641596425964359644596455964659647596485964959650596515965259653596545965559656596575965859659596605966159662596635966459665596665966759668596695967059671596725967359674596755967659677596785967959680596815968259683596845968559686596875968859689596905969159692596935969459695596965969759698596995970059701597025970359704597055970659707597085970959710597115971259713597145971559716597175971859719597205972159722597235972459725597265972759728597295973059731597325973359734597355973659737597385973959740597415974259743597445974559746597475974859749597505975159752597535975459755597565975759758597595976059761597625976359764597655976659767597685976959770597715977259773597745977559776597775977859779597805978159782597835978459785597865978759788597895979059791597925979359794597955979659797597985979959800598015980259803598045980559806598075980859809598105981159812598135981459815598165981759818598195982059821598225982359824598255982659827598285982959830598315983259833598345983559836598375983859839598405984159842598435984459845598465984759848598495985059851598525985359854598555985659857598585985959860598615986259863598645986559866598675986859869598705987159872598735987459875598765987759878598795988059881598825988359884598855988659887598885988959890598915989259893598945989559896598975989859899599005990159902599035990459905599065990759908599095991059911599125991359914599155991659917599185991959920599215992259923599245992559926599275992859929599305993159932599335993459935599365993759938599395994059941599425994359944599455994659947599485994959950599515995259953599545995559956599575995859959599605996159962599635996459965599665996759968599695997059971599725997359974599755997659977599785997959980599815998259983599845998559986599875998859989599905999159992599935999459995599965999759998599996000060001600026000360004600056000660007600086000960010600116001260013600146001560016600176001860019600206002160022600236002460025600266002760028600296003060031600326003360034600356003660037600386003960040600416004260043600446004560046600476004860049600506005160052600536005460055600566005760058600596006060061600626006360064600656006660067600686006960070600716007260073600746007560076600776007860079600806008160082600836008460085600866008760088600896009060091600926009360094600956009660097600986009960100601016010260103601046010560106601076010860109601106011160112601136011460115601166011760118601196012060121601226012360124601256012660127601286012960130601316013260133601346013560136601376013860139601406014160142601436014460145601466014760148601496015060151601526015360154601556015660157601586015960160601616016260163601646016560166601676016860169601706017160172601736017460175601766017760178601796018060181601826018360184601856018660187601886018960190601916019260193601946019560196601976019860199602006020160202602036020460205602066020760208602096021060211602126021360214602156021660217602186021960220602216022260223602246022560226602276022860229602306023160232602336023460235602366023760238602396024060241602426024360244602456024660247602486024960250602516025260253602546025560256602576025860259602606026160262602636026460265602666026760268602696027060271602726027360274602756027660277602786027960280602816028260283602846028560286602876028860289602906029160292602936029460295602966029760298602996030060301603026030360304603056030660307603086030960310603116031260313603146031560316603176031860319603206032160322603236032460325603266032760328603296033060331603326033360334603356033660337603386033960340603416034260343603446034560346603476034860349603506035160352603536035460355603566035760358603596036060361603626036360364603656036660367603686036960370603716037260373603746037560376603776037860379603806038160382603836038460385603866038760388603896039060391603926039360394603956039660397603986039960400604016040260403604046040560406604076040860409604106041160412604136041460415604166041760418604196042060421604226042360424604256042660427604286042960430604316043260433604346043560436604376043860439604406044160442604436044460445604466044760448604496045060451604526045360454604556045660457604586045960460604616046260463604646046560466604676046860469604706047160472604736047460475604766047760478604796048060481604826048360484604856048660487604886048960490604916049260493604946049560496604976049860499605006050160502605036050460505605066050760508605096051060511605126051360514605156051660517605186051960520605216052260523605246052560526605276052860529605306053160532605336053460535605366053760538605396054060541605426054360544605456054660547605486054960550605516055260553605546055560556605576055860559605606056160562605636056460565605666056760568605696057060571605726057360574605756057660577605786057960580605816058260583605846058560586605876058860589605906059160592605936059460595605966059760598605996060060601606026060360604606056060660607606086060960610606116061260613606146061560616606176061860619606206062160622606236062460625606266062760628606296063060631606326063360634606356063660637606386063960640606416064260643606446064560646606476064860649606506065160652606536065460655606566065760658606596066060661606626066360664606656066660667606686066960670606716067260673606746067560676606776067860679606806068160682606836068460685606866068760688606896069060691606926069360694606956069660697606986069960700607016070260703607046070560706607076070860709607106071160712607136071460715607166071760718607196072060721607226072360724607256072660727607286072960730607316073260733607346073560736607376073860739607406074160742607436074460745607466074760748607496075060751607526075360754607556075660757607586075960760607616076260763607646076560766607676076860769607706077160772607736077460775607766077760778607796078060781607826078360784607856078660787607886078960790607916079260793607946079560796607976079860799608006080160802608036080460805608066080760808608096081060811608126081360814608156081660817608186081960820608216082260823608246082560826608276082860829608306083160832608336083460835608366083760838608396084060841608426084360844608456084660847608486084960850608516085260853608546085560856608576085860859608606086160862608636086460865608666086760868608696087060871608726087360874608756087660877608786087960880608816088260883608846088560886608876088860889608906089160892608936089460895608966089760898608996090060901609026090360904609056090660907609086090960910609116091260913609146091560916609176091860919609206092160922609236092460925609266092760928609296093060931609326093360934609356093660937609386093960940609416094260943609446094560946609476094860949609506095160952609536095460955609566095760958609596096060961609626096360964609656096660967609686096960970609716097260973609746097560976609776097860979609806098160982609836098460985609866098760988609896099060991609926099360994609956099660997609986099961000610016100261003610046100561006610076100861009610106101161012610136101461015610166101761018610196102061021610226102361024610256102661027610286102961030610316103261033610346103561036610376103861039610406104161042610436104461045610466104761048610496105061051610526105361054610556105661057610586105961060610616106261063610646106561066610676106861069610706107161072610736107461075610766107761078610796108061081610826108361084610856108661087610886108961090610916109261093610946109561096610976109861099611006110161102611036110461105611066110761108611096111061111611126111361114611156111661117611186111961120611216112261123611246112561126611276112861129611306113161132611336113461135611366113761138611396114061141611426114361144611456114661147611486114961150611516115261153611546115561156611576115861159611606116161162611636116461165611666116761168611696117061171611726117361174611756117661177611786117961180611816118261183611846118561186611876118861189611906119161192611936119461195611966119761198611996120061201612026120361204612056120661207612086120961210612116121261213612146121561216612176121861219612206122161222612236122461225612266122761228612296123061231612326123361234612356123661237612386123961240612416124261243612446124561246612476124861249612506125161252612536125461255612566125761258612596126061261612626126361264612656126661267612686126961270612716127261273612746127561276612776127861279612806128161282612836128461285612866128761288612896129061291612926129361294612956129661297612986129961300613016130261303613046130561306613076130861309613106131161312613136131461315613166131761318613196132061321613226132361324613256132661327613286132961330613316133261333613346133561336613376133861339613406134161342613436134461345613466134761348613496135061351613526135361354613556135661357613586135961360613616136261363613646136561366613676136861369613706137161372613736137461375613766137761378613796138061381613826138361384613856138661387613886138961390613916139261393613946139561396613976139861399614006140161402614036140461405614066140761408614096141061411614126141361414614156141661417614186141961420614216142261423614246142561426614276142861429614306143161432614336143461435614366143761438614396144061441614426144361444614456144661447614486144961450614516145261453614546145561456614576145861459614606146161462614636146461465614666146761468614696147061471614726147361474614756147661477614786147961480614816148261483614846148561486614876148861489614906149161492614936149461495614966149761498614996150061501615026150361504615056150661507615086150961510615116151261513615146151561516615176151861519615206152161522615236152461525615266152761528615296153061531615326153361534615356153661537615386153961540615416154261543615446154561546615476154861549615506155161552615536155461555615566155761558615596156061561615626156361564615656156661567615686156961570615716157261573615746157561576615776157861579615806158161582615836158461585615866158761588615896159061591615926159361594615956159661597615986159961600616016160261603616046160561606616076160861609616106161161612616136161461615616166161761618616196162061621616226162361624616256162661627616286162961630616316163261633616346163561636616376163861639616406164161642616436164461645616466164761648616496165061651616526165361654616556165661657616586165961660616616166261663616646166561666616676166861669616706167161672616736167461675616766167761678616796168061681616826168361684616856168661687616886168961690616916169261693616946169561696616976169861699617006170161702617036170461705617066170761708617096171061711617126171361714617156171661717617186171961720617216172261723617246172561726617276172861729617306173161732617336173461735617366173761738617396174061741617426174361744617456174661747617486174961750617516175261753617546175561756617576175861759617606176161762617636176461765617666176761768617696177061771617726177361774617756177661777617786177961780617816178261783617846178561786617876178861789617906179161792617936179461795617966179761798617996180061801618026180361804618056180661807618086180961810618116181261813618146181561816618176181861819618206182161822618236182461825618266182761828618296183061831618326183361834618356183661837618386183961840618416184261843618446184561846618476184861849618506185161852618536185461855618566185761858618596186061861618626186361864618656186661867618686186961870618716187261873618746187561876618776187861879618806188161882618836188461885618866188761888618896189061891618926189361894618956189661897618986189961900619016190261903619046190561906619076190861909619106191161912619136191461915619166191761918619196192061921619226192361924619256192661927619286192961930619316193261933619346193561936619376193861939619406194161942619436194461945619466194761948619496195061951619526195361954619556195661957619586195961960619616196261963619646196561966619676196861969619706197161972619736197461975619766197761978619796198061981619826198361984619856198661987619886198961990619916199261993619946199561996619976199861999620006200162002620036200462005620066200762008620096201062011620126201362014620156201662017620186201962020620216202262023620246202562026620276202862029620306203162032620336203462035620366203762038620396204062041620426204362044620456204662047620486204962050620516205262053620546205562056620576205862059620606206162062620636206462065620666206762068620696207062071620726207362074620756207662077620786207962080620816208262083620846208562086620876208862089620906209162092620936209462095620966209762098620996210062101621026210362104621056210662107621086210962110621116211262113621146211562116621176211862119621206212162122621236212462125621266212762128621296213062131621326213362134621356213662137621386213962140621416214262143621446214562146621476214862149621506215162152621536215462155621566215762158621596216062161621626216362164621656216662167621686216962170621716217262173621746217562176621776217862179621806218162182621836218462185621866218762188621896219062191621926219362194621956219662197621986219962200622016220262203622046220562206622076220862209622106221162212622136221462215622166221762218622196222062221622226222362224622256222662227622286222962230622316223262233622346223562236622376223862239622406224162242622436224462245622466224762248622496225062251622526225362254622556225662257622586225962260622616226262263622646226562266622676226862269622706227162272622736227462275622766227762278622796228062281622826228362284622856228662287622886228962290622916229262293622946229562296622976229862299623006230162302623036230462305623066230762308623096231062311623126231362314623156231662317623186231962320623216232262323623246232562326623276232862329623306233162332623336233462335623366233762338623396234062341623426234362344623456234662347623486234962350623516235262353623546235562356623576235862359623606236162362623636236462365623666236762368623696237062371623726237362374623756237662377623786237962380623816238262383623846238562386623876238862389623906239162392623936239462395623966239762398623996240062401624026240362404624056240662407624086240962410624116241262413624146241562416624176241862419624206242162422624236242462425624266242762428624296243062431624326243362434624356243662437624386243962440624416244262443624446244562446624476244862449624506245162452624536245462455624566245762458624596246062461624626246362464624656246662467624686246962470624716247262473624746247562476624776247862479624806248162482624836248462485624866248762488624896249062491624926249362494624956249662497624986249962500625016250262503625046250562506625076250862509625106251162512625136251462515625166251762518625196252062521625226252362524625256252662527625286252962530625316253262533625346253562536625376253862539625406254162542625436254462545625466254762548625496255062551625526255362554625556255662557625586255962560625616256262563625646256562566625676256862569625706257162572625736257462575625766257762578625796258062581625826258362584625856258662587625886258962590625916259262593625946259562596625976259862599626006260162602626036260462605626066260762608626096261062611626126261362614626156261662617626186261962620626216262262623626246262562626626276262862629626306263162632626336263462635626366263762638626396264062641626426264362644626456264662647626486264962650626516265262653626546265562656626576265862659626606266162662626636266462665626666266762668626696267062671626726267362674626756267662677626786267962680626816268262683626846268562686626876268862689626906269162692626936269462695626966269762698626996270062701627026270362704627056270662707627086270962710627116271262713627146271562716627176271862719627206272162722627236272462725627266272762728627296273062731627326273362734627356273662737627386273962740627416274262743627446274562746627476274862749627506275162752627536275462755627566275762758627596276062761627626276362764627656276662767627686276962770627716277262773627746277562776627776277862779627806278162782627836278462785627866278762788627896279062791627926279362794627956279662797627986279962800628016280262803628046280562806628076280862809628106281162812628136281462815628166281762818628196282062821628226282362824628256282662827628286282962830628316283262833628346283562836628376283862839628406284162842628436284462845628466284762848628496285062851628526285362854628556285662857628586285962860628616286262863628646286562866628676286862869628706287162872628736287462875628766287762878628796288062881628826288362884628856288662887628886288962890628916289262893628946289562896628976289862899629006290162902629036290462905629066290762908629096291062911629126291362914629156291662917629186291962920629216292262923629246292562926629276292862929629306293162932629336293462935629366293762938629396294062941629426294362944629456294662947629486294962950629516295262953629546295562956629576295862959629606296162962629636296462965629666296762968629696297062971629726297362974629756297662977629786297962980629816298262983629846298562986629876298862989629906299162992629936299462995629966299762998629996300063001630026300363004630056300663007630086300963010630116301263013630146301563016630176301863019630206302163022630236302463025630266302763028630296303063031630326303363034630356303663037630386303963040630416304263043630446304563046630476304863049630506305163052630536305463055630566305763058630596306063061630626306363064630656306663067630686306963070630716307263073630746307563076630776307863079630806308163082630836308463085630866308763088630896309063091630926309363094630956309663097630986309963100631016310263103631046310563106631076310863109631106311163112631136311463115631166311763118631196312063121631226312363124631256312663127631286312963130631316313263133631346313563136631376313863139631406314163142631436314463145631466314763148631496315063151631526315363154631556315663157631586315963160631616316263163631646316563166631676316863169631706317163172631736317463175631766317763178631796318063181631826318363184631856318663187631886318963190631916319263193631946319563196631976319863199632006320163202632036320463205632066320763208632096321063211632126321363214632156321663217632186321963220632216322263223632246322563226632276322863229632306323163232632336323463235632366323763238632396324063241632426324363244632456324663247632486324963250632516325263253632546325563256632576325863259632606326163262632636326463265632666326763268632696327063271632726327363274632756327663277632786327963280632816328263283632846328563286632876328863289632906329163292632936329463295632966329763298632996330063301633026330363304633056330663307633086330963310633116331263313633146331563316633176331863319633206332163322633236332463325633266332763328633296333063331633326333363334633356333663337633386333963340633416334263343633446334563346633476334863349633506335163352633536335463355633566335763358633596336063361633626336363364633656336663367633686336963370633716337263373633746337563376633776337863379633806338163382633836338463385633866338763388633896339063391633926339363394633956339663397633986339963400634016340263403634046340563406634076340863409634106341163412634136341463415634166341763418634196342063421634226342363424634256342663427634286342963430634316343263433634346343563436634376343863439634406344163442634436344463445634466344763448634496345063451634526345363454634556345663457634586345963460634616346263463634646346563466634676346863469634706347163472634736347463475634766347763478634796348063481634826348363484634856348663487634886348963490634916349263493634946349563496634976349863499635006350163502635036350463505635066350763508635096351063511635126351363514635156351663517635186351963520635216352263523635246352563526635276352863529635306353163532635336353463535635366353763538635396354063541635426354363544635456354663547635486354963550635516355263553635546355563556635576355863559635606356163562635636356463565635666356763568635696357063571635726357363574635756357663577635786357963580635816358263583635846358563586635876358863589635906359163592635936359463595635966359763598635996360063601636026360363604636056360663607636086360963610636116361263613636146361563616636176361863619636206362163622636236362463625636266362763628636296363063631636326363363634636356363663637636386363963640636416364263643636446364563646636476364863649636506365163652636536365463655636566365763658636596366063661636626366363664636656366663667636686366963670636716367263673636746367563676636776367863679636806368163682636836368463685636866368763688636896369063691636926369363694636956369663697636986369963700637016370263703637046370563706637076370863709637106371163712637136371463715637166371763718637196372063721637226372363724637256372663727637286372963730637316373263733637346373563736637376373863739637406374163742637436374463745637466374763748637496375063751637526375363754637556375663757637586375963760637616376263763637646376563766637676376863769637706377163772637736377463775637766377763778637796378063781637826378363784637856378663787637886378963790637916379263793637946379563796637976379863799638006380163802638036380463805638066380763808638096381063811638126381363814638156381663817638186381963820638216382263823638246382563826638276382863829638306383163832638336383463835638366383763838638396384063841638426384363844638456384663847638486384963850638516385263853638546385563856638576385863859638606386163862638636386463865638666386763868638696387063871638726387363874638756387663877638786387963880638816388263883638846388563886638876388863889638906389163892638936389463895638966389763898638996390063901639026390363904639056390663907639086390963910639116391263913639146391563916639176391863919639206392163922639236392463925639266392763928639296393063931639326393363934639356393663937639386393963940639416394263943639446394563946639476394863949639506395163952639536395463955639566395763958639596396063961639626396363964639656396663967639686396963970639716397263973639746397563976639776397863979639806398163982639836398463985639866398763988639896399063991639926399363994639956399663997639986399964000640016400264003640046400564006640076400864009640106401164012640136401464015640166401764018640196402064021640226402364024640256402664027640286402964030640316403264033640346403564036640376403864039640406404164042640436404464045640466404764048640496405064051640526405364054640556405664057640586405964060640616406264063640646406564066640676406864069640706407164072640736407464075640766407764078640796408064081640826408364084640856408664087640886408964090640916409264093640946409564096640976409864099641006410164102641036410464105641066410764108641096411064111641126411364114641156411664117641186411964120641216412264123641246412564126641276412864129641306413164132641336413464135641366413764138641396414064141641426414364144641456414664147641486414964150641516415264153641546415564156641576415864159641606416164162641636416464165641666416764168641696417064171641726417364174641756417664177641786417964180641816418264183641846418564186641876418864189641906419164192641936419464195641966419764198641996420064201642026420364204642056420664207642086420964210642116421264213642146421564216642176421864219642206422164222642236422464225642266422764228642296423064231642326423364234642356423664237642386423964240642416424264243642446424564246642476424864249642506425164252642536425464255642566425764258642596426064261642626426364264642656426664267642686426964270642716427264273642746427564276642776427864279642806428164282642836428464285642866428764288642896429064291642926429364294642956429664297642986429964300643016430264303643046430564306643076430864309643106431164312643136431464315643166431764318643196432064321643226432364324643256432664327643286432964330643316433264333643346433564336643376433864339643406434164342643436434464345643466434764348643496435064351643526435364354643556435664357643586435964360643616436264363643646436564366643676436864369643706437164372643736437464375643766437764378643796438064381643826438364384643856438664387643886438964390643916439264393643946439564396643976439864399644006440164402644036440464405644066440764408644096441064411644126441364414644156441664417644186441964420644216442264423644246442564426644276442864429644306443164432644336443464435644366443764438644396444064441644426444364444644456444664447644486444964450644516445264453644546445564456644576445864459644606446164462644636446464465644666446764468644696447064471644726447364474644756447664477644786447964480644816448264483644846448564486644876448864489644906449164492644936449464495644966449764498644996450064501645026450364504645056450664507645086450964510645116451264513645146451564516645176451864519645206452164522645236452464525645266452764528645296453064531645326453364534645356453664537645386453964540645416454264543645446454564546645476454864549645506455164552645536455464555645566455764558645596456064561645626456364564645656456664567645686456964570645716457264573645746457564576645776457864579645806458164582645836458464585645866458764588645896459064591645926459364594645956459664597645986459964600646016460264603646046460564606646076460864609646106461164612646136461464615646166461764618646196462064621646226462364624646256462664627646286462964630646316463264633646346463564636646376463864639646406464164642646436464464645646466464764648646496465064651646526465364654646556465664657646586465964660646616466264663646646466564666646676466864669646706467164672646736467464675646766467764678646796468064681646826468364684646856468664687646886468964690646916469264693646946469564696646976469864699647006470164702647036470464705647066470764708647096471064711647126471364714647156471664717647186471964720647216472264723647246472564726647276472864729647306473164732647336473464735647366473764738647396474064741647426474364744647456474664747647486474964750647516475264753647546475564756647576475864759647606476164762647636476464765647666476764768647696477064771647726477364774647756477664777647786477964780647816478264783647846478564786647876478864789647906479164792647936479464795647966479764798647996480064801648026480364804648056480664807648086480964810648116481264813648146481564816648176481864819648206482164822648236482464825648266482764828648296483064831648326483364834648356483664837648386483964840648416484264843648446484564846648476484864849648506485164852648536485464855648566485764858648596486064861648626486364864648656486664867648686486964870648716487264873648746487564876648776487864879648806488164882648836488464885648866488764888648896489064891648926489364894648956489664897648986489964900649016490264903649046490564906649076490864909649106491164912649136491464915649166491764918649196492064921649226492364924649256492664927649286492964930649316493264933649346493564936649376493864939649406494164942649436494464945649466494764948649496495064951649526495364954649556495664957649586495964960649616496264963649646496564966649676496864969649706497164972649736497464975649766497764978649796498064981649826498364984649856498664987649886498964990649916499264993649946499564996649976499864999650006500165002650036500465005650066500765008650096501065011650126501365014650156501665017650186501965020650216502265023650246502565026650276502865029650306503165032650336503465035650366503765038650396504065041650426504365044650456504665047650486504965050650516505265053650546505565056650576505865059650606506165062650636506465065650666506765068650696507065071650726507365074650756507665077650786507965080650816508265083650846508565086650876508865089650906509165092650936509465095650966509765098650996510065101651026510365104651056510665107651086510965110651116511265113651146511565116651176511865119651206512165122651236512465125651266512765128651296513065131651326513365134651356513665137651386513965140651416514265143651446514565146651476514865149651506515165152651536515465155651566515765158651596516065161651626516365164651656516665167651686516965170651716517265173651746517565176651776517865179651806518165182651836518465185651866518765188651896519065191651926519365194651956519665197651986519965200652016520265203652046520565206652076520865209652106521165212652136521465215652166521765218652196522065221652226522365224652256522665227652286522965230652316523265233652346523565236652376523865239652406524165242652436524465245652466524765248652496525065251652526525365254652556525665257652586525965260652616526265263652646526565266652676526865269652706527165272652736527465275652766527765278652796528065281652826528365284652856528665287652886528965290652916529265293652946529565296652976529865299653006530165302653036530465305653066530765308653096531065311653126531365314653156531665317653186531965320653216532265323653246532565326653276532865329653306533165332653336533465335653366533765338653396534065341653426534365344653456534665347653486534965350653516535265353653546535565356653576535865359653606536165362653636536465365653666536765368653696537065371653726537365374653756537665377653786537965380653816538265383653846538565386653876538865389653906539165392653936539465395653966539765398653996540065401654026540365404654056540665407654086540965410654116541265413654146541565416654176541865419654206542165422654236542465425654266542765428654296543065431654326543365434654356543665437654386543965440654416544265443654446544565446654476544865449654506545165452654536545465455654566545765458654596546065461654626546365464654656546665467654686546965470654716547265473654746547565476654776547865479654806548165482654836548465485654866548765488654896549065491654926549365494654956549665497654986549965500655016550265503655046550565506655076550865509655106551165512655136551465515655166551765518655196552065521655226552365524655256552665527655286552965530655316553265533655346553565536655376553865539655406554165542655436554465545655466554765548655496555065551655526555365554655556555665557655586555965560655616556265563655646556565566655676556865569655706557165572655736557465575655766557765578655796558065581655826558365584655856558665587655886558965590655916559265593655946559565596655976559865599656006560165602656036560465605656066560765608656096561065611656126561365614656156561665617656186561965620656216562265623656246562565626656276562865629656306563165632656336563465635656366563765638656396564065641656426564365644656456564665647656486564965650656516565265653656546565565656656576565865659656606566165662656636566465665656666566765668656696567065671656726567365674656756567665677656786567965680656816568265683656846568565686656876568865689656906569165692656936569465695656966569765698656996570065701657026570365704657056570665707657086570965710657116571265713657146571565716657176571865719657206572165722657236572465725657266572765728657296573065731657326573365734657356573665737657386573965740657416574265743657446574565746657476574865749657506575165752657536575465755657566575765758657596576065761657626576365764657656576665767657686576965770657716577265773657746577565776657776577865779657806578165782657836578465785657866578765788657896579065791657926579365794657956579665797657986579965800658016580265803658046580565806658076580865809658106581165812658136581465815658166581765818658196582065821658226582365824658256582665827658286582965830658316583265833658346583565836658376583865839658406584165842658436584465845658466584765848658496585065851658526585365854658556585665857658586585965860658616586265863658646586565866658676586865869658706587165872658736587465875658766587765878658796588065881658826588365884658856588665887658886588965890658916589265893658946589565896658976589865899659006590165902659036590465905659066590765908659096591065911659126591365914659156591665917659186591965920659216592265923659246592565926659276592865929659306593165932659336593465935659366593765938659396594065941659426594365944659456594665947659486594965950659516595265953659546595565956659576595865959659606596165962659636596465965659666596765968659696597065971659726597365974659756597665977659786597965980659816598265983659846598565986659876598865989659906599165992659936599465995659966599765998659996600066001660026600366004660056600666007660086600966010660116601266013660146601566016660176601866019660206602166022660236602466025660266602766028660296603066031660326603366034660356603666037660386603966040660416604266043660446604566046660476604866049660506605166052660536605466055660566605766058660596606066061660626606366064660656606666067660686606966070660716607266073660746607566076660776607866079660806608166082660836608466085660866608766088660896609066091660926609366094660956609666097660986609966100661016610266103661046610566106661076610866109661106611166112661136611466115661166611766118661196612066121661226612366124661256612666127661286612966130661316613266133661346613566136661376613866139661406614166142661436614466145661466614766148661496615066151661526615366154661556615666157661586615966160661616616266163661646616566166661676616866169661706617166172661736617466175661766617766178661796618066181661826618366184661856618666187661886618966190661916619266193661946619566196661976619866199662006620166202662036620466205662066620766208662096621066211662126621366214662156621666217662186621966220662216622266223662246622566226662276622866229662306623166232662336623466235662366623766238662396624066241662426624366244662456624666247662486624966250662516625266253662546625566256662576625866259662606626166262662636626466265662666626766268662696627066271662726627366274662756627666277662786627966280662816628266283662846628566286662876628866289662906629166292662936629466295662966629766298662996630066301663026630366304663056630666307663086630966310663116631266313663146631566316663176631866319663206632166322663236632466325663266632766328663296633066331663326633366334663356633666337663386633966340663416634266343663446634566346663476634866349663506635166352663536635466355663566635766358663596636066361663626636366364663656636666367663686636966370663716637266373663746637566376663776637866379663806638166382663836638466385663866638766388663896639066391663926639366394663956639666397663986639966400664016640266403664046640566406664076640866409664106641166412664136641466415664166641766418664196642066421664226642366424664256642666427664286642966430664316643266433664346643566436664376643866439664406644166442664436644466445664466644766448664496645066451664526645366454664556645666457664586645966460664616646266463664646646566466664676646866469664706647166472664736647466475664766647766478664796648066481664826648366484664856648666487664886648966490664916649266493664946649566496664976649866499665006650166502665036650466505665066650766508665096651066511665126651366514665156651666517665186651966520665216652266523665246652566526665276652866529665306653166532665336653466535665366653766538665396654066541665426654366544665456654666547665486654966550665516655266553665546655566556665576655866559665606656166562665636656466565665666656766568665696657066571665726657366574665756657666577665786657966580665816658266583665846658566586665876658866589665906659166592665936659466595665966659766598665996660066601666026660366604666056660666607666086660966610666116661266613666146661566616666176661866619666206662166622666236662466625666266662766628666296663066631666326663366634666356663666637666386663966640666416664266643666446664566646666476664866649666506665166652666536665466655666566665766658666596666066661666626666366664666656666666667666686666966670666716667266673666746667566676666776667866679666806668166682666836668466685666866668766688666896669066691666926669366694666956669666697666986669966700667016670266703667046670566706667076670866709667106671166712667136671466715667166671766718667196672066721667226672366724667256672666727667286672966730667316673266733667346673566736667376673866739667406674166742667436674466745667466674766748667496675066751667526675366754667556675666757667586675966760667616676266763667646676566766667676676866769667706677166772667736677466775667766677766778667796678066781667826678366784667856678666787667886678966790667916679266793667946679566796667976679866799668006680166802668036680466805668066680766808668096681066811668126681366814668156681666817668186681966820668216682266823668246682566826668276682866829668306683166832668336683466835668366683766838668396684066841668426684366844668456684666847668486684966850668516685266853668546685566856668576685866859668606686166862668636686466865668666686766868668696687066871668726687366874668756687666877668786687966880668816688266883668846688566886668876688866889668906689166892668936689466895668966689766898668996690066901669026690366904669056690666907669086690966910669116691266913669146691566916669176691866919669206692166922669236692466925669266692766928669296693066931669326693366934669356693666937669386693966940669416694266943669446694566946669476694866949669506695166952669536695466955669566695766958669596696066961669626696366964669656696666967669686696966970669716697266973669746697566976669776697866979669806698166982669836698466985669866698766988669896699066991669926699366994669956699666997669986699967000670016700267003670046700567006670076700867009670106701167012670136701467015670166701767018670196702067021670226702367024670256702667027670286702967030670316703267033670346703567036670376703867039670406704167042670436704467045670466704767048670496705067051670526705367054670556705667057670586705967060670616706267063670646706567066670676706867069670706707167072670736707467075670766707767078670796708067081670826708367084670856708667087670886708967090670916709267093670946709567096670976709867099671006710167102671036710467105671066710767108671096711067111671126711367114671156711667117671186711967120671216712267123671246712567126671276712867129671306713167132671336713467135671366713767138671396714067141671426714367144671456714667147671486714967150671516715267153671546715567156671576715867159671606716167162671636716467165671666716767168671696717067171671726717367174671756717667177671786717967180671816718267183671846718567186671876718867189671906719167192671936719467195671966719767198671996720067201672026720367204672056720667207672086720967210672116721267213672146721567216672176721867219672206722167222672236722467225672266722767228672296723067231672326723367234672356723667237672386723967240672416724267243672446724567246672476724867249672506725167252672536725467255672566725767258672596726067261672626726367264672656726667267672686726967270672716727267273672746727567276672776727867279672806728167282672836728467285672866728767288672896729067291672926729367294672956729667297672986729967300673016730267303673046730567306673076730867309673106731167312673136731467315673166731767318673196732067321673226732367324673256732667327673286732967330673316733267333673346733567336673376733867339673406734167342673436734467345673466734767348673496735067351673526735367354673556735667357673586735967360673616736267363673646736567366673676736867369673706737167372673736737467375673766737767378673796738067381673826738367384673856738667387673886738967390673916739267393673946739567396673976739867399674006740167402674036740467405674066740767408674096741067411674126741367414674156741667417674186741967420674216742267423674246742567426674276742867429674306743167432674336743467435674366743767438674396744067441674426744367444674456744667447674486744967450674516745267453674546745567456674576745867459674606746167462674636746467465674666746767468674696747067471674726747367474674756747667477674786747967480674816748267483674846748567486674876748867489674906749167492674936749467495674966749767498674996750067501675026750367504675056750667507675086750967510675116751267513675146751567516675176751867519675206752167522675236752467525675266752767528675296753067531675326753367534675356753667537675386753967540675416754267543675446754567546675476754867549675506755167552675536755467555675566755767558675596756067561675626756367564675656756667567675686756967570675716757267573675746757567576675776757867579675806758167582675836758467585675866758767588675896759067591675926759367594675956759667597675986759967600676016760267603676046760567606676076760867609676106761167612676136761467615676166761767618676196762067621676226762367624676256762667627676286762967630676316763267633676346763567636676376763867639676406764167642676436764467645676466764767648676496765067651676526765367654676556765667657676586765967660676616766267663676646766567666676676766867669676706767167672676736767467675676766767767678676796768067681676826768367684676856768667687676886768967690676916769267693676946769567696676976769867699677006770167702677036770467705677066770767708677096771067711677126771367714677156771667717677186771967720677216772267723677246772567726677276772867729677306773167732677336773467735677366773767738677396774067741677426774367744677456774667747677486774967750677516775267753677546775567756677576775867759677606776167762677636776467765677666776767768677696777067771677726777367774677756777667777677786777967780677816778267783677846778567786677876778867789677906779167792677936779467795677966779767798677996780067801678026780367804678056780667807678086780967810678116781267813678146781567816678176781867819678206782167822678236782467825678266782767828678296783067831678326783367834678356783667837678386783967840678416784267843678446784567846678476784867849678506785167852678536785467855678566785767858678596786067861678626786367864678656786667867678686786967870678716787267873678746787567876678776787867879678806788167882678836788467885678866788767888678896789067891678926789367894678956789667897678986789967900679016790267903679046790567906679076790867909679106791167912679136791467915679166791767918679196792067921679226792367924679256792667927679286792967930679316793267933679346793567936679376793867939679406794167942679436794467945679466794767948679496795067951679526795367954679556795667957679586795967960679616796267963679646796567966679676796867969679706797167972679736797467975679766797767978679796798067981679826798367984679856798667987679886798967990679916799267993679946799567996679976799867999680006800168002680036800468005680066800768008680096801068011680126801368014680156801668017680186801968020680216802268023680246802568026680276802868029680306803168032680336803468035680366803768038680396804068041680426804368044680456804668047680486804968050680516805268053680546805568056680576805868059680606806168062680636806468065680666806768068680696807068071680726807368074680756807668077680786807968080680816808268083680846808568086680876808868089680906809168092680936809468095680966809768098680996810068101681026810368104681056810668107681086810968110681116811268113681146811568116681176811868119681206812168122681236812468125681266812768128681296813068131681326813368134681356813668137681386813968140681416814268143681446814568146681476814868149681506815168152681536815468155681566815768158681596816068161681626816368164681656816668167681686816968170681716817268173681746817568176681776817868179681806818168182681836818468185681866818768188681896819068191681926819368194681956819668197681986819968200682016820268203682046820568206682076820868209682106821168212682136821468215682166821768218682196822068221682226822368224682256822668227682286822968230682316823268233682346823568236682376823868239682406824168242682436824468245682466824768248682496825068251682526825368254682556825668257682586825968260682616826268263682646826568266682676826868269682706827168272682736827468275682766827768278682796828068281682826828368284682856828668287682886828968290682916829268293682946829568296682976829868299683006830168302683036830468305683066830768308683096831068311683126831368314683156831668317683186831968320683216832268323683246832568326683276832868329683306833168332683336833468335683366833768338683396834068341683426834368344683456834668347683486834968350683516835268353683546835568356683576835868359683606836168362683636836468365683666836768368683696837068371683726837368374683756837668377683786837968380683816838268383683846838568386683876838868389683906839168392683936839468395683966839768398683996840068401684026840368404684056840668407684086840968410684116841268413684146841568416684176841868419684206842168422684236842468425684266842768428684296843068431684326843368434684356843668437684386843968440684416844268443684446844568446684476844868449684506845168452684536845468455684566845768458684596846068461684626846368464684656846668467684686846968470684716847268473684746847568476684776847868479684806848168482684836848468485684866848768488684896849068491684926849368494684956849668497684986849968500685016850268503685046850568506685076850868509685106851168512685136851468515685166851768518685196852068521685226852368524685256852668527685286852968530685316853268533685346853568536685376853868539685406854168542685436854468545685466854768548685496855068551685526855368554685556855668557685586855968560685616856268563685646856568566685676856868569685706857168572685736857468575685766857768578685796858068581685826858368584685856858668587685886858968590685916859268593685946859568596685976859868599686006860168602686036860468605686066860768608686096861068611686126861368614686156861668617686186861968620686216862268623686246862568626686276862868629686306863168632686336863468635686366863768638686396864068641686426864368644686456864668647686486864968650686516865268653686546865568656686576865868659686606866168662686636866468665686666866768668686696867068671686726867368674686756867668677686786867968680686816868268683686846868568686686876868868689686906869168692686936869468695686966869768698686996870068701687026870368704687056870668707687086870968710687116871268713687146871568716687176871868719687206872168722687236872468725687266872768728687296873068731687326873368734687356873668737687386873968740687416874268743687446874568746687476874868749687506875168752687536875468755687566875768758687596876068761687626876368764687656876668767687686876968770687716877268773687746877568776687776877868779687806878168782687836878468785687866878768788687896879068791687926879368794687956879668797687986879968800688016880268803688046880568806688076880868809688106881168812688136881468815688166881768818688196882068821688226882368824688256882668827688286882968830688316883268833688346883568836688376883868839688406884168842688436884468845688466884768848688496885068851688526885368854688556885668857688586885968860688616886268863688646886568866688676886868869688706887168872688736887468875688766887768878688796888068881688826888368884688856888668887688886888968890688916889268893688946889568896688976889868899689006890168902689036890468905689066890768908689096891068911689126891368914689156891668917689186891968920689216892268923689246892568926689276892868929689306893168932689336893468935689366893768938689396894068941689426894368944689456894668947689486894968950689516895268953689546895568956689576895868959689606896168962689636896468965689666896768968689696897068971689726897368974689756897668977689786897968980689816898268983689846898568986689876898868989689906899168992689936899468995689966899768998689996900069001690026900369004690056900669007690086900969010690116901269013690146901569016690176901869019690206902169022690236902469025690266902769028690296903069031690326903369034690356903669037690386903969040690416904269043690446904569046690476904869049690506905169052690536905469055690566905769058690596906069061690626906369064690656906669067690686906969070690716907269073690746907569076690776907869079690806908169082690836908469085690866908769088690896909069091690926909369094690956909669097690986909969100691016910269103691046910569106691076910869109691106911169112691136911469115691166911769118691196912069121691226912369124691256912669127691286912969130691316913269133691346913569136691376913869139691406914169142691436914469145691466914769148691496915069151691526915369154691556915669157691586915969160691616916269163691646916569166691676916869169691706917169172691736917469175691766917769178691796918069181691826918369184691856918669187691886918969190691916919269193691946919569196691976919869199692006920169202692036920469205692066920769208692096921069211692126921369214692156921669217692186921969220692216922269223692246922569226692276922869229692306923169232692336923469235692366923769238692396924069241692426924369244692456924669247692486924969250692516925269253692546925569256692576925869259692606926169262692636926469265692666926769268692696927069271692726927369274692756927669277692786927969280692816928269283692846928569286692876928869289692906929169292692936929469295692966929769298692996930069301693026930369304693056930669307693086930969310693116931269313693146931569316693176931869319693206932169322693236932469325693266932769328693296933069331693326933369334693356933669337693386933969340693416934269343693446934569346693476934869349693506935169352693536935469355693566935769358693596936069361693626936369364693656936669367693686936969370693716937269373693746937569376693776937869379693806938169382693836938469385693866938769388693896939069391693926939369394693956939669397693986939969400694016940269403694046940569406694076940869409694106941169412694136941469415694166941769418694196942069421694226942369424694256942669427694286942969430694316943269433694346943569436694376943869439694406944169442694436944469445694466944769448694496945069451694526945369454694556945669457694586945969460694616946269463694646946569466694676946869469694706947169472694736947469475694766947769478694796948069481694826948369484694856948669487694886948969490694916949269493694946949569496694976949869499695006950169502695036950469505695066950769508695096951069511695126951369514695156951669517695186951969520695216952269523695246952569526695276952869529695306953169532695336953469535695366953769538695396954069541695426954369544695456954669547695486954969550695516955269553695546955569556695576955869559695606956169562695636956469565695666956769568695696957069571695726957369574695756957669577695786957969580695816958269583695846958569586695876958869589695906959169592695936959469595695966959769598695996960069601696026960369604696056960669607696086960969610696116961269613696146961569616696176961869619696206962169622696236962469625696266962769628696296963069631696326963369634696356963669637696386963969640696416964269643696446964569646696476964869649696506965169652696536965469655696566965769658696596966069661696626966369664696656966669667696686966969670696716967269673696746967569676696776967869679696806968169682696836968469685696866968769688696896969069691696926969369694696956969669697696986969969700697016970269703697046970569706697076970869709697106971169712697136971469715697166971769718697196972069721697226972369724697256972669727697286972969730697316973269733697346973569736697376973869739697406974169742697436974469745697466974769748697496975069751697526975369754697556975669757697586975969760697616976269763697646976569766697676976869769697706977169772697736977469775697766977769778697796978069781697826978369784697856978669787697886978969790697916979269793697946979569796697976979869799698006980169802698036980469805698066980769808698096981069811698126981369814698156981669817698186981969820698216982269823698246982569826698276982869829698306983169832698336983469835698366983769838698396984069841698426984369844698456984669847698486984969850698516985269853698546985569856698576985869859698606986169862698636986469865698666986769868698696987069871698726987369874698756987669877698786987969880698816988269883698846988569886698876988869889698906989169892698936989469895698966989769898698996990069901699026990369904699056990669907699086990969910699116991269913699146991569916699176991869919699206992169922699236992469925699266992769928699296993069931699326993369934699356993669937699386993969940699416994269943699446994569946699476994869949699506995169952699536995469955699566995769958699596996069961699626996369964699656996669967699686996969970699716997269973699746997569976699776997869979699806998169982699836998469985699866998769988699896999069991699926999369994699956999669997699986999970000700017000270003700047000570006700077000870009700107001170012700137001470015700167001770018700197002070021700227002370024700257002670027700287002970030700317003270033700347003570036700377003870039700407004170042700437004470045700467004770048700497005070051700527005370054700557005670057700587005970060700617006270063700647006570066700677006870069700707007170072700737007470075700767007770078700797008070081700827008370084700857008670087700887008970090700917009270093700947009570096700977009870099701007010170102701037010470105701067010770108701097011070111701127011370114701157011670117701187011970120701217012270123701247012570126701277012870129701307013170132701337013470135701367013770138701397014070141701427014370144701457014670147701487014970150701517015270153701547015570156701577015870159701607016170162701637016470165701667016770168701697017070171701727017370174701757017670177701787017970180701817018270183701847018570186701877018870189701907019170192701937019470195701967019770198701997020070201702027020370204702057020670207702087020970210702117021270213702147021570216702177021870219702207022170222702237022470225702267022770228702297023070231702327023370234702357023670237702387023970240702417024270243702447024570246702477024870249702507025170252702537025470255702567025770258702597026070261702627026370264702657026670267702687026970270702717027270273702747027570276702777027870279702807028170282702837028470285702867028770288702897029070291702927029370294702957029670297702987029970300703017030270303703047030570306703077030870309703107031170312703137031470315703167031770318703197032070321703227032370324703257032670327703287032970330703317033270333703347033570336703377033870339703407034170342703437034470345703467034770348703497035070351703527035370354703557035670357703587035970360703617036270363703647036570366703677036870369703707037170372703737037470375703767037770378703797038070381703827038370384703857038670387703887038970390703917039270393703947039570396703977039870399704007040170402704037040470405704067040770408704097041070411704127041370414704157041670417704187041970420704217042270423704247042570426704277042870429704307043170432704337043470435704367043770438704397044070441704427044370444704457044670447704487044970450704517045270453704547045570456704577045870459704607046170462704637046470465704667046770468704697047070471704727047370474704757047670477704787047970480704817048270483704847048570486704877048870489704907049170492704937049470495704967049770498704997050070501705027050370504705057050670507705087050970510705117051270513705147051570516705177051870519705207052170522705237052470525705267052770528705297053070531705327053370534705357053670537705387053970540705417054270543705447054570546705477054870549705507055170552705537055470555705567055770558705597056070561705627056370564705657056670567705687056970570705717057270573705747057570576705777057870579705807058170582705837058470585705867058770588705897059070591705927059370594705957059670597705987059970600706017060270603706047060570606706077060870609706107061170612706137061470615706167061770618706197062070621706227062370624706257062670627706287062970630706317063270633706347063570636706377063870639706407064170642706437064470645706467064770648706497065070651706527065370654706557065670657706587065970660706617066270663706647066570666706677066870669706707067170672706737067470675706767067770678706797068070681706827068370684706857068670687706887068970690706917069270693706947069570696706977069870699707007070170702707037070470705707067070770708707097071070711707127071370714707157071670717707187071970720707217072270723707247072570726707277072870729707307073170732707337073470735707367073770738707397074070741707427074370744707457074670747707487074970750707517075270753707547075570756707577075870759707607076170762707637076470765707667076770768707697077070771707727077370774707757077670777707787077970780707817078270783707847078570786707877078870789707907079170792707937079470795707967079770798707997080070801708027080370804708057080670807708087080970810708117081270813708147081570816708177081870819708207082170822708237082470825708267082770828708297083070831708327083370834708357083670837708387083970840708417084270843708447084570846708477084870849708507085170852708537085470855708567085770858708597086070861708627086370864708657086670867708687086970870708717087270873708747087570876708777087870879708807088170882708837088470885708867088770888708897089070891708927089370894708957089670897708987089970900709017090270903709047090570906709077090870909709107091170912709137091470915709167091770918709197092070921709227092370924709257092670927709287092970930709317093270933709347093570936709377093870939709407094170942709437094470945709467094770948709497095070951709527095370954709557095670957709587095970960709617096270963709647096570966709677096870969709707097170972709737097470975709767097770978709797098070981709827098370984709857098670987709887098970990709917099270993709947099570996709977099870999710007100171002710037100471005710067100771008710097101071011710127101371014710157101671017710187101971020710217102271023710247102571026710277102871029710307103171032710337103471035710367103771038710397104071041710427104371044710457104671047710487104971050710517105271053710547105571056710577105871059710607106171062710637106471065710667106771068710697107071071710727107371074710757107671077710787107971080710817108271083710847108571086710877108871089710907109171092710937109471095710967109771098710997110071101711027110371104711057110671107711087110971110711117111271113711147111571116711177111871119711207112171122711237112471125711267112771128711297113071131711327113371134711357113671137711387113971140711417114271143711447114571146711477114871149711507115171152711537115471155711567115771158711597116071161711627116371164711657116671167711687116971170711717117271173711747117571176711777117871179711807118171182711837118471185711867118771188711897119071191711927119371194711957119671197711987119971200712017120271203712047120571206712077120871209712107121171212712137121471215712167121771218712197122071221712227122371224712257122671227712287122971230712317123271233712347123571236712377123871239712407124171242712437124471245712467124771248712497125071251712527125371254712557125671257712587125971260712617126271263712647126571266712677126871269712707127171272712737127471275712767127771278712797128071281712827128371284712857128671287712887128971290712917129271293712947129571296712977129871299713007130171302713037130471305713067130771308713097131071311713127131371314713157131671317713187131971320713217132271323713247132571326713277132871329713307133171332713337133471335713367133771338713397134071341713427134371344713457134671347713487134971350713517135271353713547135571356713577135871359713607136171362713637136471365713667136771368713697137071371713727137371374713757137671377713787137971380713817138271383713847138571386713877138871389713907139171392713937139471395713967139771398713997140071401714027140371404714057140671407714087140971410714117141271413714147141571416714177141871419714207142171422714237142471425714267142771428714297143071431714327143371434714357143671437714387143971440714417144271443714447144571446714477144871449714507145171452714537145471455714567145771458714597146071461714627146371464714657146671467714687146971470714717147271473714747147571476714777147871479714807148171482714837148471485714867148771488714897149071491714927149371494714957149671497714987149971500715017150271503715047150571506715077150871509715107151171512715137151471515715167151771518715197152071521715227152371524715257152671527715287152971530715317153271533715347153571536715377153871539715407154171542715437154471545715467154771548715497155071551715527155371554715557155671557715587155971560715617156271563715647156571566715677156871569715707157171572715737157471575715767157771578715797158071581715827158371584715857158671587715887158971590715917159271593715947159571596715977159871599716007160171602716037160471605716067160771608716097161071611716127161371614716157161671617716187161971620716217162271623716247162571626716277162871629716307163171632716337163471635716367163771638716397164071641716427164371644716457164671647716487164971650716517165271653716547165571656716577165871659716607166171662716637166471665716667166771668716697167071671716727167371674716757167671677716787167971680716817168271683716847168571686716877168871689716907169171692716937169471695716967169771698716997170071701717027170371704717057170671707717087170971710717117171271713717147171571716717177171871719717207172171722717237172471725717267172771728717297173071731717327173371734717357173671737717387173971740717417174271743717447174571746717477174871749717507175171752717537175471755717567175771758717597176071761717627176371764717657176671767717687176971770717717177271773717747177571776717777177871779717807178171782717837178471785717867178771788717897179071791717927179371794717957179671797717987179971800718017180271803718047180571806718077180871809718107181171812718137181471815718167181771818718197182071821718227182371824718257182671827718287182971830718317183271833718347183571836718377183871839718407184171842718437184471845718467184771848718497185071851718527185371854718557185671857718587185971860718617186271863718647186571866718677186871869718707187171872718737187471875718767187771878718797188071881718827188371884718857188671887718887188971890718917189271893718947189571896718977189871899719007190171902719037190471905719067190771908719097191071911719127191371914719157191671917719187191971920719217192271923719247192571926719277192871929719307193171932719337193471935719367193771938719397194071941719427194371944719457194671947719487194971950719517195271953719547195571956719577195871959719607196171962719637196471965719667196771968719697197071971719727197371974719757197671977719787197971980719817198271983719847198571986719877198871989719907199171992719937199471995719967199771998719997200072001720027200372004720057200672007720087200972010720117201272013720147201572016720177201872019720207202172022720237202472025720267202772028720297203072031720327203372034720357203672037720387203972040720417204272043720447204572046720477204872049720507205172052720537205472055720567205772058720597206072061720627206372064720657206672067720687206972070720717207272073720747207572076720777207872079720807208172082720837208472085720867208772088720897209072091720927209372094720957209672097720987209972100721017210272103721047210572106721077210872109721107211172112721137211472115721167211772118721197212072121721227212372124721257212672127721287212972130721317213272133721347213572136721377213872139721407214172142721437214472145721467214772148721497215072151721527215372154721557215672157721587215972160721617216272163721647216572166721677216872169721707217172172721737217472175721767217772178721797218072181721827218372184721857218672187721887218972190721917219272193721947219572196721977219872199722007220172202722037220472205722067220772208722097221072211722127221372214722157221672217722187221972220722217222272223722247222572226722277222872229722307223172232722337223472235722367223772238722397224072241722427224372244722457224672247722487224972250722517225272253722547225572256722577225872259722607226172262722637226472265722667226772268722697227072271722727227372274722757227672277722787227972280722817228272283722847228572286722877228872289722907229172292722937229472295722967229772298722997230072301723027230372304723057230672307723087230972310723117231272313723147231572316723177231872319723207232172322723237232472325723267232772328723297233072331723327233372334723357233672337723387233972340723417234272343723447234572346723477234872349723507235172352723537235472355723567235772358723597236072361723627236372364723657236672367723687236972370723717237272373723747237572376723777237872379723807238172382723837238472385723867238772388723897239072391723927239372394723957239672397723987239972400724017240272403724047240572406724077240872409724107241172412724137241472415724167241772418724197242072421724227242372424724257242672427724287242972430724317243272433724347243572436724377243872439724407244172442724437244472445724467244772448724497245072451724527245372454724557245672457724587245972460724617246272463724647246572466724677246872469724707247172472724737247472475724767247772478724797248072481724827248372484724857248672487724887248972490724917249272493724947249572496724977249872499725007250172502725037250472505725067250772508725097251072511725127251372514725157251672517725187251972520725217252272523725247252572526725277252872529725307253172532725337253472535725367253772538725397254072541725427254372544725457254672547725487254972550725517255272553725547255572556725577255872559725607256172562725637256472565725667256772568725697257072571725727257372574725757257672577725787257972580725817258272583725847258572586725877258872589725907259172592725937259472595725967259772598725997260072601726027260372604726057260672607726087260972610726117261272613726147261572616726177261872619726207262172622726237262472625726267262772628726297263072631726327263372634726357263672637726387263972640726417264272643726447264572646726477264872649726507265172652726537265472655726567265772658726597266072661726627266372664726657266672667726687266972670726717267272673726747267572676726777267872679726807268172682726837268472685726867268772688726897269072691726927269372694726957269672697726987269972700727017270272703727047270572706727077270872709727107271172712727137271472715727167271772718727197272072721727227272372724727257272672727727287272972730727317273272733727347273572736727377273872739727407274172742727437274472745727467274772748727497275072751727527275372754727557275672757727587275972760727617276272763727647276572766727677276872769727707277172772727737277472775727767277772778727797278072781727827278372784727857278672787727887278972790727917279272793727947279572796727977279872799728007280172802728037280472805728067280772808728097281072811728127281372814728157281672817728187281972820728217282272823728247282572826728277282872829728307283172832728337283472835728367283772838728397284072841728427284372844728457284672847728487284972850728517285272853728547285572856728577285872859728607286172862728637286472865728667286772868728697287072871728727287372874728757287672877728787287972880728817288272883728847288572886728877288872889728907289172892728937289472895728967289772898728997290072901729027290372904729057290672907729087290972910729117291272913729147291572916729177291872919729207292172922729237292472925729267292772928729297293072931729327293372934729357293672937729387293972940729417294272943729447294572946729477294872949729507295172952729537295472955729567295772958729597296072961729627296372964729657296672967729687296972970729717297272973729747297572976729777297872979729807298172982729837298472985729867298772988729897299072991729927299372994729957299672997729987299973000730017300273003730047300573006730077300873009730107301173012730137301473015730167301773018730197302073021730227302373024730257302673027730287302973030730317303273033730347303573036730377303873039730407304173042730437304473045730467304773048730497305073051730527305373054730557305673057730587305973060730617306273063730647306573066730677306873069730707307173072730737307473075730767307773078730797308073081730827308373084730857308673087730887308973090730917309273093730947309573096730977309873099731007310173102731037310473105731067310773108731097311073111731127311373114731157311673117731187311973120731217312273123731247312573126731277312873129731307313173132731337313473135731367313773138731397314073141731427314373144731457314673147731487314973150731517315273153731547315573156731577315873159731607316173162731637316473165731667316773168731697317073171731727317373174731757317673177731787317973180731817318273183731847318573186731877318873189731907319173192731937319473195731967319773198731997320073201732027320373204732057320673207732087320973210732117321273213732147321573216732177321873219732207322173222732237322473225732267322773228732297323073231732327323373234732357323673237732387323973240732417324273243732447324573246732477324873249732507325173252732537325473255732567325773258732597326073261732627326373264732657326673267732687326973270732717327273273732747327573276732777327873279732807328173282732837328473285732867328773288732897329073291732927329373294732957329673297732987329973300733017330273303733047330573306733077330873309733107331173312733137331473315733167331773318733197332073321733227332373324733257332673327733287332973330733317333273333733347333573336733377333873339733407334173342733437334473345733467334773348733497335073351733527335373354733557335673357733587335973360733617336273363733647336573366733677336873369733707337173372733737337473375733767337773378733797338073381733827338373384733857338673387733887338973390733917339273393733947339573396733977339873399734007340173402734037340473405734067340773408734097341073411734127341373414734157341673417734187341973420734217342273423734247342573426734277342873429734307343173432734337343473435734367343773438734397344073441734427344373444734457344673447734487344973450734517345273453734547345573456734577345873459734607346173462734637346473465734667346773468734697347073471734727347373474734757347673477734787347973480734817348273483734847348573486734877348873489734907349173492734937349473495734967349773498734997350073501735027350373504735057350673507735087350973510735117351273513735147351573516735177351873519735207352173522735237352473525735267352773528735297353073531735327353373534735357353673537735387353973540735417354273543735447354573546735477354873549735507355173552735537355473555735567355773558735597356073561735627356373564735657356673567735687356973570735717357273573735747357573576735777357873579735807358173582735837358473585735867358773588735897359073591735927359373594735957359673597735987359973600736017360273603736047360573606736077360873609736107361173612736137361473615736167361773618736197362073621736227362373624736257362673627736287362973630736317363273633736347363573636736377363873639736407364173642736437364473645736467364773648736497365073651736527365373654736557365673657736587365973660736617366273663736647366573666736677366873669736707367173672736737367473675736767367773678736797368073681736827368373684736857368673687736887368973690736917369273693736947369573696736977369873699737007370173702737037370473705737067370773708737097371073711737127371373714737157371673717737187371973720737217372273723737247372573726737277372873729737307373173732737337373473735737367373773738737397374073741737427374373744737457374673747737487374973750737517375273753737547375573756737577375873759737607376173762737637376473765737667376773768737697377073771737727377373774737757377673777737787377973780737817378273783737847378573786737877378873789737907379173792737937379473795737967379773798737997380073801738027380373804738057380673807738087380973810738117381273813738147381573816738177381873819738207382173822738237382473825738267382773828738297383073831738327383373834738357383673837738387383973840738417384273843738447384573846738477384873849738507385173852738537385473855738567385773858738597386073861738627386373864738657386673867738687386973870738717387273873738747387573876738777387873879738807388173882738837388473885738867388773888738897389073891738927389373894738957389673897738987389973900739017390273903739047390573906739077390873909739107391173912739137391473915739167391773918739197392073921739227392373924739257392673927739287392973930739317393273933739347393573936739377393873939739407394173942739437394473945739467394773948739497395073951739527395373954739557395673957739587395973960739617396273963739647396573966739677396873969739707397173972739737397473975739767397773978739797398073981739827398373984739857398673987739887398973990739917399273993739947399573996739977399873999740007400174002740037400474005740067400774008740097401074011740127401374014740157401674017740187401974020740217402274023740247402574026740277402874029740307403174032740337403474035740367403774038740397404074041740427404374044740457404674047740487404974050740517405274053740547405574056740577405874059740607406174062740637406474065740667406774068740697407074071740727407374074740757407674077740787407974080740817408274083740847408574086740877408874089740907409174092740937409474095740967409774098740997410074101741027410374104741057410674107741087410974110741117411274113741147411574116741177411874119741207412174122741237412474125741267412774128741297413074131741327413374134741357413674137741387413974140741417414274143741447414574146741477414874149741507415174152741537415474155741567415774158741597416074161741627416374164741657416674167741687416974170741717417274173741747417574176741777417874179741807418174182741837418474185741867418774188741897419074191741927419374194741957419674197741987419974200742017420274203742047420574206742077420874209742107421174212742137421474215742167421774218742197422074221742227422374224742257422674227742287422974230742317423274233742347423574236742377423874239742407424174242742437424474245742467424774248742497425074251742527425374254742557425674257742587425974260742617426274263742647426574266742677426874269742707427174272742737427474275742767427774278742797428074281742827428374284742857428674287742887428974290742917429274293742947429574296742977429874299743007430174302743037430474305743067430774308743097431074311743127431374314743157431674317743187431974320743217432274323743247432574326743277432874329743307433174332743337433474335743367433774338743397434074341743427434374344743457434674347743487434974350743517435274353743547435574356743577435874359743607436174362743637436474365743667436774368743697437074371743727437374374743757437674377743787437974380743817438274383743847438574386743877438874389743907439174392743937439474395743967439774398743997440074401744027440374404744057440674407744087440974410744117441274413744147441574416744177441874419744207442174422744237442474425744267442774428744297443074431744327443374434744357443674437744387443974440744417444274443744447444574446744477444874449744507445174452744537445474455744567445774458744597446074461744627446374464744657446674467744687446974470744717447274473744747447574476744777447874479744807448174482744837448474485744867448774488744897449074491744927449374494744957449674497744987449974500745017450274503745047450574506745077450874509745107451174512745137451474515745167451774518745197452074521745227452374524745257452674527745287452974530745317453274533745347453574536745377453874539745407454174542745437454474545745467454774548745497455074551745527455374554745557455674557745587455974560745617456274563745647456574566745677456874569745707457174572745737457474575745767457774578745797458074581745827458374584745857458674587745887458974590745917459274593745947459574596745977459874599746007460174602746037460474605746067460774608746097461074611746127461374614746157461674617746187461974620746217462274623746247462574626746277462874629746307463174632746337463474635746367463774638746397464074641746427464374644746457464674647746487464974650746517465274653746547465574656746577465874659746607466174662746637466474665746667466774668746697467074671746727467374674746757467674677746787467974680746817468274683746847468574686746877468874689746907469174692746937469474695746967469774698746997470074701747027470374704747057470674707747087470974710747117471274713747147471574716747177471874719747207472174722747237472474725747267472774728747297473074731747327473374734747357473674737747387473974740747417474274743747447474574746747477474874749747507475174752747537475474755747567475774758747597476074761747627476374764747657476674767747687476974770747717477274773747747477574776747777477874779747807478174782747837478474785747867478774788747897479074791747927479374794747957479674797747987479974800748017480274803748047480574806748077480874809748107481174812748137481474815748167481774818748197482074821748227482374824748257482674827748287482974830748317483274833748347483574836748377483874839748407484174842748437484474845748467484774848748497485074851748527485374854748557485674857748587485974860748617486274863748647486574866748677486874869748707487174872748737487474875748767487774878748797488074881748827488374884748857488674887748887488974890748917489274893748947489574896748977489874899749007490174902749037490474905749067490774908749097491074911749127491374914749157491674917749187491974920749217492274923749247492574926749277492874929749307493174932749337493474935749367493774938749397494074941749427494374944749457494674947749487494974950749517495274953749547495574956749577495874959749607496174962749637496474965749667496774968749697497074971749727497374974749757497674977749787497974980749817498274983749847498574986749877498874989749907499174992749937499474995749967499774998749997500075001750027500375004750057500675007750087500975010750117501275013750147501575016750177501875019750207502175022750237502475025750267502775028750297503075031750327503375034750357503675037750387503975040750417504275043750447504575046750477504875049750507505175052750537505475055750567505775058750597506075061750627506375064750657506675067750687506975070750717507275073750747507575076750777507875079750807508175082750837508475085750867508775088750897509075091750927509375094750957509675097750987509975100751017510275103751047510575106751077510875109751107511175112751137511475115751167511775118751197512075121751227512375124751257512675127751287512975130751317513275133751347513575136751377513875139751407514175142751437514475145751467514775148751497515075151751527515375154751557515675157751587515975160751617516275163751647516575166751677516875169751707517175172751737517475175751767517775178751797518075181751827518375184751857518675187751887518975190751917519275193751947519575196751977519875199752007520175202752037520475205752067520775208752097521075211752127521375214752157521675217752187521975220752217522275223752247522575226752277522875229752307523175232752337523475235752367523775238752397524075241752427524375244752457524675247752487524975250752517525275253752547525575256752577525875259752607526175262752637526475265752667526775268752697527075271752727527375274752757527675277752787527975280752817528275283752847528575286752877528875289752907529175292752937529475295752967529775298752997530075301753027530375304753057530675307753087530975310753117531275313753147531575316753177531875319753207532175322753237532475325753267532775328753297533075331753327533375334753357533675337753387533975340753417534275343753447534575346753477534875349753507535175352753537535475355753567535775358753597536075361753627536375364753657536675367753687536975370753717537275373753747537575376753777537875379753807538175382753837538475385753867538775388753897539075391753927539375394753957539675397753987539975400754017540275403754047540575406754077540875409754107541175412754137541475415754167541775418754197542075421754227542375424754257542675427754287542975430754317543275433754347543575436754377543875439754407544175442754437544475445754467544775448754497545075451754527545375454754557545675457754587545975460754617546275463754647546575466754677546875469754707547175472754737547475475754767547775478754797548075481754827548375484754857548675487754887548975490754917549275493754947549575496754977549875499755007550175502755037550475505755067550775508755097551075511755127551375514755157551675517755187551975520755217552275523755247552575526755277552875529755307553175532755337553475535755367553775538755397554075541755427554375544755457554675547755487554975550755517555275553755547555575556755577555875559755607556175562755637556475565755667556775568755697557075571755727557375574755757557675577755787557975580755817558275583755847558575586755877558875589755907559175592755937559475595755967559775598755997560075601756027560375604756057560675607756087560975610756117561275613756147561575616756177561875619756207562175622756237562475625756267562775628756297563075631756327563375634756357563675637756387563975640756417564275643756447564575646756477564875649756507565175652756537565475655756567565775658756597566075661756627566375664756657566675667756687566975670756717567275673756747567575676756777567875679756807568175682756837568475685756867568775688756897569075691756927569375694756957569675697756987569975700757017570275703757047570575706757077570875709757107571175712757137571475715757167571775718757197572075721757227572375724757257572675727757287572975730757317573275733757347573575736757377573875739757407574175742757437574475745757467574775748757497575075751757527575375754757557575675757757587575975760757617576275763757647576575766757677576875769757707577175772757737577475775757767577775778757797578075781757827578375784757857578675787757887578975790757917579275793757947579575796757977579875799758007580175802758037580475805758067580775808758097581075811758127581375814758157581675817758187581975820758217582275823758247582575826758277582875829758307583175832758337583475835758367583775838758397584075841758427584375844758457584675847758487584975850758517585275853758547585575856758577585875859758607586175862758637586475865758667586775868758697587075871758727587375874758757587675877758787587975880758817588275883758847588575886758877588875889758907589175892758937589475895758967589775898758997590075901759027590375904759057590675907759087590975910759117591275913759147591575916759177591875919759207592175922759237592475925759267592775928759297593075931759327593375934759357593675937759387593975940759417594275943759447594575946759477594875949759507595175952759537595475955759567595775958759597596075961759627596375964759657596675967759687596975970759717597275973759747597575976759777597875979759807598175982759837598475985759867598775988759897599075991759927599375994759957599675997759987599976000760017600276003760047600576006760077600876009760107601176012760137601476015760167601776018760197602076021760227602376024760257602676027760287602976030760317603276033760347603576036760377603876039760407604176042760437604476045760467604776048760497605076051760527605376054760557605676057760587605976060760617606276063760647606576066760677606876069760707607176072760737607476075760767607776078760797608076081760827608376084760857608676087760887608976090760917609276093760947609576096760977609876099761007610176102761037610476105761067610776108761097611076111761127611376114761157611676117761187611976120761217612276123761247612576126761277612876129761307613176132761337613476135761367613776138761397614076141761427614376144761457614676147761487614976150761517615276153761547615576156761577615876159761607616176162761637616476165761667616776168761697617076171761727617376174761757617676177761787617976180761817618276183761847618576186761877618876189761907619176192761937619476195761967619776198761997620076201762027620376204762057620676207762087620976210762117621276213762147621576216762177621876219762207622176222762237622476225762267622776228762297623076231762327623376234762357623676237762387623976240762417624276243762447624576246762477624876249762507625176252762537625476255762567625776258762597626076261762627626376264762657626676267762687626976270762717627276273762747627576276762777627876279762807628176282762837628476285762867628776288762897629076291762927629376294762957629676297762987629976300763017630276303763047630576306763077630876309763107631176312763137631476315763167631776318763197632076321763227632376324763257632676327763287632976330763317633276333763347633576336763377633876339763407634176342763437634476345763467634776348763497635076351763527635376354763557635676357763587635976360763617636276363763647636576366763677636876369763707637176372763737637476375763767637776378763797638076381763827638376384763857638676387763887638976390763917639276393763947639576396763977639876399764007640176402764037640476405764067640776408764097641076411764127641376414764157641676417764187641976420764217642276423764247642576426764277642876429764307643176432764337643476435764367643776438764397644076441764427644376444764457644676447764487644976450764517645276453764547645576456764577645876459764607646176462764637646476465764667646776468764697647076471764727647376474764757647676477764787647976480764817648276483764847648576486764877648876489764907649176492764937649476495764967649776498764997650076501765027650376504765057650676507765087650976510765117651276513765147651576516765177651876519765207652176522765237652476525765267652776528765297653076531765327653376534765357653676537765387653976540765417654276543765447654576546765477654876549765507655176552765537655476555765567655776558765597656076561765627656376564765657656676567765687656976570765717657276573765747657576576765777657876579765807658176582765837658476585765867658776588765897659076591765927659376594765957659676597765987659976600766017660276603766047660576606766077660876609766107661176612766137661476615766167661776618766197662076621766227662376624766257662676627766287662976630766317663276633766347663576636766377663876639766407664176642766437664476645766467664776648766497665076651766527665376654766557665676657766587665976660766617666276663766647666576666766677666876669766707667176672766737667476675766767667776678766797668076681766827668376684766857668676687766887668976690766917669276693766947669576696766977669876699767007670176702767037670476705767067670776708767097671076711767127671376714767157671676717767187671976720767217672276723767247672576726767277672876729767307673176732767337673476735767367673776738767397674076741767427674376744767457674676747767487674976750767517675276753767547675576756767577675876759767607676176762767637676476765767667676776768767697677076771767727677376774767757677676777767787677976780767817678276783767847678576786767877678876789767907679176792767937679476795767967679776798767997680076801768027680376804768057680676807768087680976810768117681276813768147681576816768177681876819768207682176822768237682476825768267682776828768297683076831768327683376834768357683676837768387683976840768417684276843768447684576846768477684876849768507685176852768537685476855768567685776858768597686076861768627686376864768657686676867768687686976870768717687276873768747687576876768777687876879768807688176882768837688476885768867688776888768897689076891768927689376894768957689676897768987689976900769017690276903769047690576906769077690876909769107691176912769137691476915769167691776918769197692076921769227692376924769257692676927769287692976930769317693276933769347693576936769377693876939769407694176942769437694476945769467694776948769497695076951769527695376954769557695676957769587695976960769617696276963769647696576966769677696876969769707697176972769737697476975769767697776978769797698076981769827698376984769857698676987769887698976990769917699276993769947699576996769977699876999770007700177002770037700477005770067700777008770097701077011770127701377014770157701677017770187701977020770217702277023770247702577026770277702877029770307703177032770337703477035770367703777038770397704077041770427704377044770457704677047770487704977050770517705277053770547705577056770577705877059770607706177062770637706477065770667706777068770697707077071770727707377074770757707677077770787707977080770817708277083770847708577086770877708877089770907709177092770937709477095770967709777098770997710077101771027710377104771057710677107771087710977110771117711277113771147711577116771177711877119771207712177122771237712477125771267712777128771297713077131771327713377134771357713677137771387713977140771417714277143771447714577146771477714877149771507715177152771537715477155771567715777158771597716077161771627716377164771657716677167771687716977170771717717277173771747717577176771777717877179771807718177182771837718477185771867718777188771897719077191771927719377194771957719677197771987719977200772017720277203772047720577206772077720877209772107721177212772137721477215772167721777218772197722077221772227722377224772257722677227772287722977230772317723277233772347723577236772377723877239772407724177242772437724477245772467724777248772497725077251772527725377254772557725677257772587725977260772617726277263772647726577266772677726877269772707727177272772737727477275772767727777278772797728077281772827728377284772857728677287772887728977290772917729277293772947729577296772977729877299773007730177302773037730477305773067730777308773097731077311773127731377314773157731677317773187731977320773217732277323773247732577326773277732877329773307733177332773337733477335773367733777338773397734077341773427734377344773457734677347773487734977350773517735277353773547735577356773577735877359773607736177362773637736477365773667736777368773697737077371773727737377374773757737677377773787737977380773817738277383773847738577386773877738877389773907739177392773937739477395773967739777398773997740077401774027740377404774057740677407774087740977410774117741277413774147741577416774177741877419774207742177422774237742477425774267742777428774297743077431774327743377434774357743677437774387743977440774417744277443774447744577446774477744877449774507745177452774537745477455774567745777458774597746077461774627746377464774657746677467774687746977470774717747277473774747747577476774777747877479774807748177482774837748477485774867748777488774897749077491774927749377494774957749677497774987749977500775017750277503775047750577506775077750877509775107751177512775137751477515775167751777518775197752077521775227752377524775257752677527775287752977530775317753277533775347753577536775377753877539775407754177542775437754477545775467754777548775497755077551775527755377554775557755677557775587755977560775617756277563775647756577566775677756877569775707757177572775737757477575775767757777578775797758077581775827758377584775857758677587775887758977590775917759277593775947759577596775977759877599776007760177602776037760477605776067760777608776097761077611776127761377614776157761677617776187761977620776217762277623776247762577626776277762877629776307763177632776337763477635776367763777638776397764077641776427764377644776457764677647776487764977650776517765277653776547765577656776577765877659776607766177662776637766477665776667766777668776697767077671776727767377674776757767677677776787767977680776817768277683776847768577686776877768877689776907769177692776937769477695776967769777698776997770077701777027770377704777057770677707777087770977710777117771277713777147771577716777177771877719777207772177722777237772477725777267772777728777297773077731777327773377734777357773677737777387773977740777417774277743777447774577746777477774877749777507775177752777537775477755777567775777758777597776077761777627776377764777657776677767777687776977770777717777277773777747777577776777777777877779777807778177782777837778477785777867778777788777897779077791777927779377794777957779677797777987779977800778017780277803778047780577806778077780877809778107781177812778137781477815778167781777818778197782077821778227782377824778257782677827778287782977830778317783277833778347783577836778377783877839778407784177842778437784477845778467784777848778497785077851778527785377854778557785677857778587785977860778617786277863778647786577866778677786877869778707787177872778737787477875778767787777878778797788077881778827788377884778857788677887778887788977890778917789277893778947789577896778977789877899779007790177902779037790477905779067790777908779097791077911779127791377914779157791677917779187791977920779217792277923779247792577926779277792877929779307793177932779337793477935779367793777938779397794077941779427794377944779457794677947779487794977950779517795277953779547795577956779577795877959779607796177962779637796477965779667796777968779697797077971779727797377974779757797677977779787797977980779817798277983779847798577986779877798877989779907799177992779937799477995779967799777998779997800078001780027800378004780057800678007780087800978010780117801278013780147801578016780177801878019780207802178022780237802478025780267802778028780297803078031780327803378034780357803678037780387803978040780417804278043780447804578046780477804878049780507805178052780537805478055780567805778058780597806078061780627806378064780657806678067780687806978070780717807278073780747807578076780777807878079780807808178082780837808478085780867808778088780897809078091780927809378094780957809678097780987809978100781017810278103781047810578106781077810878109781107811178112781137811478115781167811778118781197812078121781227812378124781257812678127781287812978130781317813278133781347813578136781377813878139781407814178142781437814478145781467814778148781497815078151781527815378154781557815678157781587815978160781617816278163781647816578166781677816878169781707817178172781737817478175781767817778178781797818078181781827818378184781857818678187781887818978190781917819278193781947819578196781977819878199782007820178202782037820478205782067820778208782097821078211782127821378214782157821678217782187821978220782217822278223782247822578226782277822878229782307823178232782337823478235782367823778238782397824078241782427824378244782457824678247782487824978250782517825278253782547825578256782577825878259782607826178262782637826478265782667826778268782697827078271782727827378274782757827678277782787827978280782817828278283782847828578286782877828878289782907829178292782937829478295782967829778298782997830078301783027830378304783057830678307783087830978310783117831278313783147831578316783177831878319783207832178322783237832478325783267832778328783297833078331783327833378334783357833678337783387833978340783417834278343783447834578346783477834878349783507835178352783537835478355783567835778358783597836078361783627836378364783657836678367783687836978370783717837278373783747837578376783777837878379783807838178382783837838478385783867838778388783897839078391783927839378394783957839678397783987839978400784017840278403784047840578406784077840878409784107841178412784137841478415784167841778418784197842078421784227842378424784257842678427784287842978430784317843278433784347843578436784377843878439784407844178442784437844478445784467844778448784497845078451784527845378454784557845678457784587845978460784617846278463784647846578466784677846878469784707847178472784737847478475784767847778478784797848078481784827848378484784857848678487784887848978490784917849278493784947849578496784977849878499785007850178502785037850478505785067850778508785097851078511785127851378514785157851678517785187851978520785217852278523785247852578526785277852878529785307853178532785337853478535785367853778538785397854078541785427854378544785457854678547785487854978550785517855278553785547855578556785577855878559785607856178562785637856478565785667856778568785697857078571785727857378574785757857678577785787857978580785817858278583785847858578586785877858878589785907859178592785937859478595785967859778598785997860078601786027860378604786057860678607786087860978610786117861278613786147861578616786177861878619786207862178622786237862478625786267862778628786297863078631786327863378634786357863678637786387863978640786417864278643786447864578646786477864878649786507865178652786537865478655786567865778658786597866078661786627866378664786657866678667786687866978670786717867278673786747867578676786777867878679786807868178682786837868478685786867868778688786897869078691786927869378694786957869678697786987869978700787017870278703787047870578706787077870878709787107871178712787137871478715787167871778718787197872078721787227872378724787257872678727787287872978730787317873278733787347873578736787377873878739787407874178742787437874478745787467874778748787497875078751787527875378754787557875678757787587875978760787617876278763787647876578766787677876878769787707877178772787737877478775787767877778778787797878078781787827878378784787857878678787787887878978790787917879278793787947879578796787977879878799788007880178802788037880478805788067880778808788097881078811788127881378814788157881678817788187881978820788217882278823788247882578826788277882878829788307883178832788337883478835788367883778838788397884078841788427884378844788457884678847788487884978850788517885278853788547885578856788577885878859788607886178862788637886478865788667886778868788697887078871788727887378874788757887678877788787887978880788817888278883788847888578886788877888878889788907889178892788937889478895788967889778898788997890078901789027890378904789057890678907789087890978910789117891278913789147891578916789177891878919789207892178922789237892478925789267892778928789297893078931789327893378934789357893678937789387893978940789417894278943789447894578946789477894878949789507895178952789537895478955789567895778958789597896078961789627896378964789657896678967789687896978970789717897278973789747897578976789777897878979789807898178982789837898478985789867898778988789897899078991789927899378994789957899678997789987899979000790017900279003790047900579006790077900879009790107901179012790137901479015790167901779018790197902079021790227902379024790257902679027790287902979030790317903279033790347903579036790377903879039790407904179042790437904479045790467904779048790497905079051790527905379054790557905679057790587905979060790617906279063790647906579066790677906879069790707907179072790737907479075790767907779078790797908079081790827908379084790857908679087790887908979090790917909279093790947909579096790977909879099791007910179102791037910479105791067910779108791097911079111791127911379114791157911679117791187911979120791217912279123791247912579126791277912879129791307913179132791337913479135791367913779138791397914079141791427914379144791457914679147791487914979150791517915279153791547915579156791577915879159791607916179162791637916479165791667916779168791697917079171791727917379174791757917679177791787917979180791817918279183791847918579186791877918879189791907919179192791937919479195791967919779198791997920079201792027920379204792057920679207792087920979210792117921279213792147921579216792177921879219792207922179222792237922479225792267922779228792297923079231792327923379234792357923679237792387923979240792417924279243792447924579246792477924879249792507925179252792537925479255792567925779258792597926079261792627926379264792657926679267792687926979270792717927279273792747927579276792777927879279792807928179282792837928479285792867928779288792897929079291792927929379294792957929679297792987929979300793017930279303793047930579306793077930879309793107931179312793137931479315793167931779318793197932079321793227932379324793257932679327793287932979330793317933279333793347933579336793377933879339793407934179342793437934479345793467934779348793497935079351793527935379354793557935679357793587935979360793617936279363793647936579366793677936879369793707937179372793737937479375793767937779378793797938079381793827938379384793857938679387793887938979390793917939279393793947939579396793977939879399794007940179402794037940479405794067940779408794097941079411794127941379414794157941679417794187941979420794217942279423794247942579426794277942879429794307943179432794337943479435794367943779438794397944079441794427944379444794457944679447794487944979450794517945279453794547945579456794577945879459794607946179462794637946479465794667946779468794697947079471794727947379474794757947679477794787947979480794817948279483794847948579486794877948879489794907949179492794937949479495794967949779498794997950079501795027950379504795057950679507795087950979510795117951279513795147951579516795177951879519795207952179522795237952479525795267952779528795297953079531795327953379534795357953679537795387953979540795417954279543795447954579546795477954879549795507955179552795537955479555795567955779558795597956079561795627956379564795657956679567795687956979570795717957279573795747957579576795777957879579795807958179582795837958479585795867958779588795897959079591795927959379594795957959679597795987959979600796017960279603796047960579606796077960879609796107961179612796137961479615796167961779618796197962079621796227962379624796257962679627796287962979630796317963279633796347963579636796377963879639796407964179642796437964479645796467964779648796497965079651796527965379654796557965679657796587965979660796617966279663796647966579666796677966879669796707967179672796737967479675796767967779678796797968079681796827968379684796857968679687796887968979690796917969279693796947969579696796977969879699797007970179702797037970479705797067970779708797097971079711797127971379714797157971679717797187971979720797217972279723797247972579726797277972879729797307973179732797337973479735797367973779738797397974079741797427974379744797457974679747797487974979750797517975279753797547975579756797577975879759797607976179762797637976479765797667976779768797697977079771797727977379774797757977679777797787977979780797817978279783797847978579786797877978879789797907979179792797937979479795797967979779798797997980079801798027980379804798057980679807798087980979810798117981279813798147981579816798177981879819798207982179822798237982479825798267982779828798297983079831798327983379834798357983679837798387983979840798417984279843798447984579846798477984879849798507985179852798537985479855798567985779858798597986079861798627986379864798657986679867798687986979870798717987279873798747987579876798777987879879798807988179882798837988479885798867988779888798897989079891798927989379894798957989679897798987989979900799017990279903799047990579906799077990879909799107991179912799137991479915799167991779918799197992079921799227992379924799257992679927799287992979930799317993279933799347993579936799377993879939799407994179942799437994479945799467994779948799497995079951799527995379954799557995679957799587995979960799617996279963799647996579966799677996879969799707997179972799737997479975799767997779978799797998079981799827998379984799857998679987799887998979990799917999279993799947999579996799977999879999800008000180002800038000480005800068000780008800098001080011800128001380014800158001680017800188001980020800218002280023800248002580026800278002880029800308003180032800338003480035800368003780038800398004080041800428004380044800458004680047800488004980050800518005280053800548005580056800578005880059800608006180062800638006480065800668006780068800698007080071800728007380074800758007680077800788007980080800818008280083800848008580086800878008880089800908009180092800938009480095800968009780098800998010080101801028010380104801058010680107801088010980110801118011280113801148011580116801178011880119801208012180122801238012480125801268012780128801298013080131801328013380134801358013680137801388013980140801418014280143801448014580146801478014880149801508015180152801538015480155801568015780158801598016080161801628016380164801658016680167801688016980170801718017280173801748017580176801778017880179801808018180182801838018480185801868018780188801898019080191801928019380194801958019680197801988019980200802018020280203802048020580206802078020880209802108021180212802138021480215802168021780218802198022080221802228022380224802258022680227802288022980230802318023280233802348023580236802378023880239802408024180242802438024480245802468024780248802498025080251802528025380254802558025680257802588025980260802618026280263802648026580266802678026880269802708027180272802738027480275802768027780278802798028080281802828028380284802858028680287802888028980290802918029280293802948029580296802978029880299803008030180302803038030480305803068030780308803098031080311803128031380314803158031680317803188031980320803218032280323803248032580326803278032880329803308033180332803338033480335803368033780338803398034080341803428034380344803458034680347803488034980350803518035280353803548035580356803578035880359803608036180362803638036480365803668036780368803698037080371803728037380374803758037680377803788037980380803818038280383803848038580386803878038880389803908039180392803938039480395803968039780398803998040080401804028040380404804058040680407804088040980410804118041280413804148041580416804178041880419804208042180422804238042480425804268042780428804298043080431804328043380434804358043680437804388043980440804418044280443804448044580446804478044880449804508045180452804538045480455804568045780458804598046080461804628046380464804658046680467804688046980470804718047280473804748047580476804778047880479804808048180482804838048480485804868048780488804898049080491804928049380494804958049680497804988049980500805018050280503805048050580506805078050880509805108051180512805138051480515805168051780518805198052080521805228052380524805258052680527805288052980530805318053280533805348053580536805378053880539805408054180542805438054480545805468054780548805498055080551805528055380554805558055680557805588055980560805618056280563805648056580566805678056880569805708057180572805738057480575805768057780578805798058080581805828058380584805858058680587805888058980590805918059280593805948059580596805978059880599806008060180602806038060480605806068060780608806098061080611806128061380614806158061680617806188061980620806218062280623806248062580626806278062880629806308063180632806338063480635806368063780638806398064080641806428064380644806458064680647806488064980650806518065280653806548065580656806578065880659806608066180662806638066480665806668066780668806698067080671806728067380674806758067680677806788067980680806818068280683806848068580686806878068880689806908069180692806938069480695806968069780698806998070080701807028070380704807058070680707807088070980710807118071280713807148071580716807178071880719807208072180722807238072480725807268072780728807298073080731807328073380734807358073680737807388073980740807418074280743807448074580746807478074880749807508075180752807538075480755807568075780758807598076080761807628076380764807658076680767807688076980770807718077280773807748077580776807778077880779807808078180782807838078480785807868078780788807898079080791807928079380794807958079680797807988079980800808018080280803808048080580806808078080880809808108081180812808138081480815808168081780818808198082080821808228082380824808258082680827808288082980830808318083280833808348083580836808378083880839808408084180842808438084480845808468084780848808498085080851808528085380854808558085680857808588085980860808618086280863808648086580866808678086880869808708087180872808738087480875808768087780878808798088080881808828088380884808858088680887808888088980890808918089280893808948089580896808978089880899809008090180902809038090480905809068090780908809098091080911809128091380914809158091680917809188091980920809218092280923809248092580926809278092880929809308093180932809338093480935809368093780938809398094080941809428094380944809458094680947809488094980950809518095280953809548095580956809578095880959809608096180962809638096480965809668096780968809698097080971809728097380974809758097680977809788097980980809818098280983809848098580986809878098880989809908099180992809938099480995809968099780998809998100081001810028100381004810058100681007810088100981010810118101281013810148101581016810178101881019810208102181022810238102481025810268102781028810298103081031810328103381034810358103681037810388103981040810418104281043810448104581046810478104881049810508105181052810538105481055810568105781058810598106081061810628106381064810658106681067810688106981070810718107281073810748107581076810778107881079810808108181082810838108481085810868108781088810898109081091810928109381094810958109681097810988109981100811018110281103811048110581106811078110881109811108111181112811138111481115811168111781118811198112081121811228112381124811258112681127811288112981130811318113281133811348113581136811378113881139811408114181142811438114481145811468114781148811498115081151811528115381154811558115681157811588115981160811618116281163811648116581166811678116881169811708117181172811738117481175811768117781178811798118081181811828118381184811858118681187811888118981190811918119281193811948119581196811978119881199812008120181202812038120481205812068120781208812098121081211812128121381214812158121681217812188121981220812218122281223812248122581226812278122881229812308123181232812338123481235812368123781238812398124081241812428124381244812458124681247812488124981250812518125281253812548125581256812578125881259812608126181262812638126481265812668126781268812698127081271812728127381274812758127681277812788127981280812818128281283812848128581286812878128881289812908129181292812938129481295812968129781298812998130081301813028130381304813058130681307813088130981310813118131281313813148131581316813178131881319813208132181322813238132481325813268132781328813298133081331813328133381334813358133681337813388133981340813418134281343813448134581346813478134881349813508135181352813538135481355813568135781358813598136081361813628136381364813658136681367813688136981370813718137281373813748137581376813778137881379813808138181382813838138481385813868138781388813898139081391813928139381394813958139681397813988139981400814018140281403814048140581406814078140881409814108141181412814138141481415814168141781418814198142081421814228142381424814258142681427814288142981430814318143281433814348143581436814378143881439814408144181442814438144481445814468144781448814498145081451814528145381454814558145681457814588145981460814618146281463814648146581466814678146881469814708147181472814738147481475814768147781478814798148081481814828148381484814858148681487814888148981490814918149281493814948149581496814978149881499815008150181502815038150481505815068150781508815098151081511815128151381514815158151681517815188151981520815218152281523815248152581526815278152881529815308153181532815338153481535815368153781538815398154081541815428154381544815458154681547815488154981550815518155281553815548155581556815578155881559815608156181562815638156481565815668156781568815698157081571815728157381574815758157681577815788157981580815818158281583815848158581586815878158881589815908159181592815938159481595815968159781598815998160081601816028160381604816058160681607816088160981610816118161281613816148161581616816178161881619816208162181622816238162481625816268162781628816298163081631816328163381634816358163681637816388163981640816418164281643816448164581646816478164881649816508165181652816538165481655816568165781658816598166081661816628166381664816658166681667816688166981670816718167281673816748167581676816778167881679816808168181682816838168481685816868168781688816898169081691816928169381694816958169681697816988169981700817018170281703817048170581706817078170881709817108171181712817138171481715817168171781718817198172081721817228172381724817258172681727817288172981730817318173281733817348173581736817378173881739817408174181742817438174481745817468174781748817498175081751817528175381754817558175681757817588175981760817618176281763817648176581766817678176881769817708177181772817738177481775817768177781778817798178081781817828178381784817858178681787817888178981790817918179281793817948179581796817978179881799818008180181802818038180481805818068180781808818098181081811818128181381814818158181681817818188181981820818218182281823818248182581826818278182881829818308183181832818338183481835818368183781838818398184081841818428184381844818458184681847818488184981850818518185281853818548185581856818578185881859818608186181862818638186481865818668186781868818698187081871818728187381874818758187681877818788187981880818818188281883818848188581886818878188881889818908189181892818938189481895818968189781898818998190081901819028190381904819058190681907819088190981910819118191281913819148191581916819178191881919819208192181922819238192481925819268192781928819298193081931819328193381934819358193681937819388193981940819418194281943819448194581946819478194881949819508195181952819538195481955819568195781958819598196081961819628196381964819658196681967819688196981970819718197281973819748197581976819778197881979819808198181982819838198481985819868198781988819898199081991819928199381994819958199681997819988199982000820018200282003820048200582006820078200882009820108201182012820138201482015820168201782018820198202082021820228202382024820258202682027820288202982030820318203282033820348203582036820378203882039820408204182042820438204482045820468204782048820498205082051820528205382054820558205682057820588205982060820618206282063820648206582066820678206882069820708207182072820738207482075820768207782078820798208082081820828208382084820858208682087820888208982090820918209282093820948209582096820978209882099821008210182102821038210482105821068210782108821098211082111821128211382114821158211682117821188211982120821218212282123821248212582126821278212882129821308213182132821338213482135821368213782138821398214082141821428214382144821458214682147821488214982150821518215282153821548215582156821578215882159821608216182162821638216482165821668216782168821698217082171821728217382174821758217682177821788217982180821818218282183821848218582186821878218882189821908219182192821938219482195821968219782198821998220082201822028220382204822058220682207822088220982210822118221282213822148221582216822178221882219822208222182222822238222482225822268222782228822298223082231822328223382234822358223682237822388223982240822418224282243822448224582246822478224882249822508225182252822538225482255822568225782258822598226082261822628226382264822658226682267822688226982270822718227282273822748227582276822778227882279822808228182282822838228482285822868228782288822898229082291822928229382294822958229682297822988229982300823018230282303823048230582306823078230882309823108231182312823138231482315823168231782318823198232082321823228232382324823258232682327823288232982330823318233282333823348233582336823378233882339823408234182342823438234482345823468234782348823498235082351823528235382354823558235682357823588235982360823618236282363823648236582366823678236882369823708237182372823738237482375823768237782378823798238082381823828238382384823858238682387823888238982390823918239282393823948239582396823978239882399824008240182402824038240482405824068240782408824098241082411824128241382414824158241682417824188241982420824218242282423824248242582426824278242882429824308243182432824338243482435824368243782438824398244082441824428244382444824458244682447824488244982450824518245282453824548245582456824578245882459824608246182462824638246482465824668246782468824698247082471824728247382474824758247682477824788247982480824818248282483824848248582486824878248882489824908249182492824938249482495824968249782498824998250082501825028250382504825058250682507825088250982510825118251282513825148251582516825178251882519825208252182522825238252482525825268252782528825298253082531825328253382534825358253682537825388253982540825418254282543825448254582546825478254882549825508255182552825538255482555825568255782558825598256082561825628256382564825658256682567825688256982570825718257282573825748257582576825778257882579825808258182582825838258482585825868258782588825898259082591825928259382594825958259682597825988259982600826018260282603826048260582606826078260882609826108261182612826138261482615826168261782618826198262082621826228262382624826258262682627826288262982630826318263282633826348263582636826378263882639826408264182642826438264482645826468264782648826498265082651826528265382654826558265682657826588265982660826618266282663826648266582666826678266882669826708267182672826738267482675826768267782678826798268082681826828268382684826858268682687826888268982690826918269282693826948269582696826978269882699827008270182702827038270482705827068270782708827098271082711827128271382714827158271682717827188271982720827218272282723827248272582726827278272882729827308273182732827338273482735827368273782738827398274082741827428274382744827458274682747827488274982750827518275282753827548275582756827578275882759827608276182762827638276482765827668276782768827698277082771827728277382774827758277682777827788277982780827818278282783827848278582786827878278882789827908279182792827938279482795827968279782798827998280082801828028280382804828058280682807828088280982810828118281282813828148281582816828178281882819828208282182822828238282482825828268282782828828298283082831828328283382834828358283682837828388283982840828418284282843828448284582846828478284882849828508285182852828538285482855828568285782858828598286082861828628286382864828658286682867828688286982870828718287282873828748287582876828778287882879828808288182882828838288482885828868288782888828898289082891828928289382894828958289682897828988289982900829018290282903829048290582906829078290882909829108291182912829138291482915829168291782918829198292082921829228292382924829258292682927829288292982930829318293282933829348293582936829378293882939829408294182942829438294482945829468294782948829498295082951829528295382954829558295682957829588295982960829618296282963829648296582966829678296882969829708297182972829738297482975829768297782978829798298082981829828298382984829858298682987829888298982990829918299282993829948299582996829978299882999830008300183002830038300483005830068300783008830098301083011830128301383014830158301683017830188301983020830218302283023830248302583026830278302883029830308303183032830338303483035830368303783038830398304083041830428304383044830458304683047830488304983050830518305283053830548305583056830578305883059830608306183062830638306483065830668306783068830698307083071830728307383074830758307683077830788307983080830818308283083830848308583086830878308883089830908309183092830938309483095830968309783098830998310083101831028310383104831058310683107831088310983110831118311283113831148311583116831178311883119831208312183122831238312483125831268312783128831298313083131831328313383134831358313683137831388313983140831418314283143831448314583146831478314883149831508315183152831538315483155831568315783158831598316083161831628316383164831658316683167831688316983170831718317283173831748317583176831778317883179831808318183182831838318483185831868318783188831898319083191831928319383194831958319683197831988319983200832018320283203832048320583206832078320883209832108321183212832138321483215832168321783218832198322083221832228322383224832258322683227832288322983230832318323283233832348323583236832378323883239832408324183242832438324483245832468324783248832498325083251832528325383254832558325683257832588325983260832618326283263832648326583266832678326883269832708327183272832738327483275832768327783278832798328083281832828328383284832858328683287832888328983290832918329283293832948329583296832978329883299833008330183302833038330483305833068330783308833098331083311833128331383314833158331683317833188331983320833218332283323833248332583326833278332883329833308333183332833338333483335833368333783338833398334083341833428334383344833458334683347833488334983350833518335283353833548335583356833578335883359833608336183362833638336483365833668336783368833698337083371833728337383374833758337683377833788337983380833818338283383833848338583386833878338883389833908339183392833938339483395833968339783398833998340083401834028340383404834058340683407834088340983410834118341283413834148341583416834178341883419834208342183422834238342483425834268342783428834298343083431834328343383434834358343683437834388343983440834418344283443834448344583446834478344883449834508345183452834538345483455834568345783458834598346083461834628346383464834658346683467834688346983470834718347283473834748347583476834778347883479834808348183482834838348483485834868348783488834898349083491834928349383494834958349683497834988349983500835018350283503835048350583506835078350883509835108351183512835138351483515835168351783518835198352083521835228352383524835258352683527835288352983530835318353283533835348353583536835378353883539835408354183542835438354483545835468354783548835498355083551835528355383554835558355683557835588355983560835618356283563835648356583566835678356883569835708357183572835738357483575835768357783578835798358083581835828358383584835858358683587835888358983590835918359283593835948359583596835978359883599836008360183602836038360483605836068360783608836098361083611836128361383614836158361683617836188361983620836218362283623836248362583626836278362883629836308363183632836338363483635836368363783638836398364083641836428364383644836458364683647836488364983650836518365283653836548365583656836578365883659836608366183662836638366483665836668366783668836698367083671836728367383674836758367683677836788367983680836818368283683836848368583686836878368883689836908369183692836938369483695836968369783698836998370083701837028370383704837058370683707837088370983710837118371283713837148371583716837178371883719837208372183722837238372483725837268372783728837298373083731837328373383734837358373683737837388373983740837418374283743837448374583746837478374883749837508375183752837538375483755837568375783758837598376083761837628376383764837658376683767837688376983770837718377283773837748377583776837778377883779837808378183782837838378483785837868378783788837898379083791837928379383794837958379683797837988379983800838018380283803838048380583806838078380883809838108381183812838138381483815838168381783818838198382083821838228382383824838258382683827838288382983830838318383283833838348383583836838378383883839838408384183842838438384483845838468384783848838498385083851838528385383854838558385683857838588385983860838618386283863838648386583866838678386883869838708387183872838738387483875838768387783878838798388083881838828388383884838858388683887838888388983890838918389283893838948389583896838978389883899839008390183902839038390483905839068390783908839098391083911839128391383914839158391683917839188391983920839218392283923839248392583926839278392883929839308393183932839338393483935839368393783938839398394083941839428394383944839458394683947839488394983950839518395283953839548395583956839578395883959839608396183962839638396483965839668396783968839698397083971839728397383974839758397683977839788397983980839818398283983839848398583986839878398883989839908399183992839938399483995839968399783998839998400084001840028400384004840058400684007840088400984010840118401284013840148401584016840178401884019840208402184022840238402484025840268402784028840298403084031840328403384034840358403684037840388403984040840418404284043840448404584046840478404884049840508405184052840538405484055840568405784058840598406084061840628406384064840658406684067840688406984070840718407284073840748407584076840778407884079840808408184082840838408484085840868408784088840898409084091840928409384094840958409684097840988409984100841018410284103841048410584106841078410884109841108411184112841138411484115841168411784118841198412084121841228412384124841258412684127841288412984130841318413284133841348413584136841378413884139841408414184142841438414484145841468414784148841498415084151841528415384154841558415684157841588415984160841618416284163841648416584166841678416884169841708417184172841738417484175841768417784178841798418084181841828418384184841858418684187841888418984190841918419284193841948419584196841978419884199842008420184202842038420484205842068420784208842098421084211842128421384214842158421684217842188421984220842218422284223842248422584226842278422884229842308423184232842338423484235842368423784238842398424084241842428424384244842458424684247842488424984250842518425284253842548425584256842578425884259842608426184262842638426484265842668426784268842698427084271842728427384274842758427684277842788427984280842818428284283842848428584286842878428884289842908429184292842938429484295842968429784298842998430084301843028430384304843058430684307843088430984310843118431284313843148431584316843178431884319843208432184322843238432484325843268432784328843298433084331843328433384334843358433684337843388433984340843418434284343843448434584346843478434884349843508435184352843538435484355843568435784358843598436084361843628436384364843658436684367843688436984370843718437284373843748437584376843778437884379843808438184382843838438484385843868438784388843898439084391843928439384394843958439684397843988439984400844018440284403844048440584406844078440884409844108441184412844138441484415844168441784418844198442084421844228442384424844258442684427844288442984430844318443284433844348443584436844378443884439844408444184442844438444484445844468444784448844498445084451844528445384454844558445684457844588445984460844618446284463844648446584466844678446884469844708447184472844738447484475844768447784478844798448084481844828448384484844858448684487844888448984490844918449284493844948449584496844978449884499845008450184502845038450484505845068450784508845098451084511845128451384514845158451684517845188451984520845218452284523845248452584526845278452884529845308453184532845338453484535845368453784538845398454084541845428454384544845458454684547845488454984550845518455284553845548455584556845578455884559845608456184562845638456484565845668456784568845698457084571845728457384574845758457684577845788457984580845818458284583845848458584586845878458884589845908459184592845938459484595845968459784598845998460084601846028460384604846058460684607846088460984610846118461284613846148461584616846178461884619846208462184622846238462484625846268462784628846298463084631846328463384634846358463684637846388463984640846418464284643846448464584646846478464884649846508465184652846538465484655846568465784658846598466084661846628466384664846658466684667846688466984670846718467284673846748467584676846778467884679846808468184682846838468484685846868468784688846898469084691846928469384694846958469684697846988469984700847018470284703847048470584706847078470884709847108471184712847138471484715847168471784718847198472084721847228472384724847258472684727847288472984730847318473284733847348473584736847378473884739847408474184742847438474484745847468474784748847498475084751847528475384754847558475684757847588475984760847618476284763847648476584766847678476884769847708477184772847738477484775847768477784778847798478084781847828478384784847858478684787847888478984790847918479284793847948479584796847978479884799848008480184802848038480484805848068480784808848098481084811848128481384814848158481684817848188481984820848218482284823848248482584826848278482884829848308483184832848338483484835848368483784838848398484084841848428484384844848458484684847848488484984850848518485284853848548485584856848578485884859848608486184862848638486484865848668486784868848698487084871848728487384874848758487684877848788487984880848818488284883848848488584886848878488884889848908489184892848938489484895848968489784898848998490084901849028490384904849058490684907849088490984910849118491284913849148491584916849178491884919849208492184922849238492484925849268492784928849298493084931849328493384934849358493684937849388493984940849418494284943849448494584946849478494884949849508495184952849538495484955849568495784958849598496084961849628496384964849658496684967849688496984970849718497284973849748497584976849778497884979849808498184982849838498484985849868498784988849898499084991849928499384994849958499684997849988499985000850018500285003850048500585006850078500885009850108501185012850138501485015850168501785018850198502085021850228502385024850258502685027850288502985030850318503285033850348503585036850378503885039850408504185042850438504485045850468504785048850498505085051850528505385054850558505685057850588505985060850618506285063850648506585066850678506885069850708507185072850738507485075850768507785078850798508085081850828508385084850858508685087850888508985090850918509285093850948509585096850978509885099851008510185102851038510485105851068510785108851098511085111851128511385114851158511685117851188511985120851218512285123851248512585126851278512885129851308513185132851338513485135851368513785138851398514085141851428514385144851458514685147851488514985150851518515285153851548515585156851578515885159851608516185162851638516485165851668516785168851698517085171851728517385174851758517685177851788517985180851818518285183851848518585186851878518885189851908519185192851938519485195851968519785198851998520085201852028520385204852058520685207852088520985210852118521285213852148521585216852178521885219852208522185222852238522485225852268522785228852298523085231852328523385234852358523685237852388523985240852418524285243852448524585246852478524885249852508525185252852538525485255852568525785258852598526085261852628526385264852658526685267852688526985270852718527285273852748527585276852778527885279852808528185282852838528485285852868528785288852898529085291852928529385294852958529685297852988529985300853018530285303853048530585306853078530885309853108531185312853138531485315853168531785318853198532085321853228532385324853258532685327853288532985330853318533285333853348533585336853378533885339853408534185342853438534485345853468534785348853498535085351853528535385354853558535685357853588535985360853618536285363853648536585366853678536885369853708537185372853738537485375853768537785378853798538085381853828538385384853858538685387853888538985390853918539285393853948539585396853978539885399854008540185402854038540485405854068540785408854098541085411854128541385414854158541685417854188541985420854218542285423854248542585426854278542885429854308543185432854338543485435854368543785438854398544085441854428544385444854458544685447854488544985450854518545285453854548545585456854578545885459854608546185462854638546485465854668546785468854698547085471854728547385474854758547685477854788547985480854818548285483854848548585486854878548885489854908549185492854938549485495854968549785498854998550085501855028550385504855058550685507855088550985510855118551285513855148551585516855178551885519855208552185522855238552485525855268552785528855298553085531855328553385534855358553685537855388553985540855418554285543855448554585546855478554885549855508555185552855538555485555855568555785558855598556085561855628556385564855658556685567855688556985570855718557285573855748557585576855778557885579855808558185582855838558485585855868558785588855898559085591855928559385594855958559685597855988559985600856018560285603856048560585606856078560885609856108561185612856138561485615856168561785618856198562085621856228562385624856258562685627856288562985630856318563285633856348563585636856378563885639856408564185642856438564485645856468564785648856498565085651856528565385654856558565685657856588565985660856618566285663856648566585666856678566885669856708567185672856738567485675856768567785678856798568085681856828568385684856858568685687856888568985690856918569285693856948569585696856978569885699857008570185702857038570485705857068570785708857098571085711857128571385714857158571685717857188571985720857218572285723857248572585726857278572885729857308573185732857338573485735857368573785738857398574085741857428574385744857458574685747857488574985750857518575285753857548575585756857578575885759857608576185762857638576485765857668576785768857698577085771857728577385774857758577685777857788577985780857818578285783857848578585786857878578885789857908579185792857938579485795857968579785798857998580085801858028580385804858058580685807858088580985810858118581285813858148581585816858178581885819858208582185822858238582485825858268582785828858298583085831858328583385834858358583685837858388583985840858418584285843858448584585846858478584885849858508585185852858538585485855858568585785858858598586085861858628586385864858658586685867858688586985870858718587285873858748587585876858778587885879858808588185882858838588485885858868588785888858898589085891858928589385894858958589685897858988589985900859018590285903859048590585906859078590885909859108591185912859138591485915859168591785918859198592085921859228592385924859258592685927859288592985930859318593285933859348593585936859378593885939859408594185942859438594485945859468594785948859498595085951859528595385954859558595685957859588595985960859618596285963859648596585966859678596885969859708597185972859738597485975859768597785978859798598085981859828598385984859858598685987859888598985990859918599285993859948599585996859978599885999860008600186002860038600486005860068600786008860098601086011860128601386014860158601686017860188601986020860218602286023860248602586026860278602886029860308603186032860338603486035860368603786038860398604086041860428604386044860458604686047860488604986050860518605286053860548605586056860578605886059860608606186062860638606486065860668606786068860698607086071860728607386074860758607686077860788607986080860818608286083860848608586086860878608886089860908609186092860938609486095860968609786098860998610086101861028610386104861058610686107861088610986110861118611286113861148611586116861178611886119861208612186122861238612486125861268612786128861298613086131861328613386134861358613686137861388613986140861418614286143861448614586146861478614886149861508615186152861538615486155861568615786158861598616086161861628616386164861658616686167861688616986170861718617286173861748617586176861778617886179861808618186182861838618486185861868618786188861898619086191861928619386194861958619686197861988619986200862018620286203862048620586206862078620886209862108621186212862138621486215862168621786218862198622086221862228622386224862258622686227862288622986230862318623286233862348623586236862378623886239862408624186242862438624486245862468624786248862498625086251862528625386254862558625686257862588625986260862618626286263862648626586266862678626886269862708627186272862738627486275862768627786278862798628086281862828628386284862858628686287862888628986290862918629286293862948629586296862978629886299863008630186302863038630486305863068630786308863098631086311863128631386314863158631686317863188631986320863218632286323863248632586326863278632886329863308633186332863338633486335863368633786338863398634086341863428634386344863458634686347863488634986350863518635286353863548635586356863578635886359863608636186362863638636486365863668636786368863698637086371863728637386374863758637686377863788637986380863818638286383863848638586386863878638886389863908639186392863938639486395863968639786398863998640086401864028640386404864058640686407864088640986410864118641286413864148641586416864178641886419864208642186422864238642486425864268642786428864298643086431864328643386434864358643686437864388643986440864418644286443864448644586446864478644886449864508645186452864538645486455864568645786458864598646086461864628646386464864658646686467864688646986470864718647286473864748647586476864778647886479864808648186482864838648486485864868648786488864898649086491864928649386494864958649686497864988649986500865018650286503865048650586506865078650886509865108651186512865138651486515865168651786518865198652086521865228652386524865258652686527865288652986530865318653286533865348653586536865378653886539865408654186542865438654486545865468654786548865498655086551865528655386554865558655686557865588655986560865618656286563865648656586566865678656886569865708657186572865738657486575865768657786578865798658086581865828658386584865858658686587865888658986590865918659286593865948659586596865978659886599866008660186602866038660486605866068660786608866098661086611866128661386614866158661686617866188661986620866218662286623866248662586626866278662886629866308663186632866338663486635866368663786638866398664086641866428664386644866458664686647866488664986650866518665286653866548665586656866578665886659866608666186662866638666486665866668666786668866698667086671866728667386674866758667686677866788667986680866818668286683866848668586686866878668886689866908669186692866938669486695866968669786698866998670086701867028670386704867058670686707867088670986710867118671286713867148671586716867178671886719867208672186722867238672486725867268672786728867298673086731867328673386734867358673686737867388673986740867418674286743867448674586746867478674886749867508675186752867538675486755867568675786758867598676086761867628676386764867658676686767867688676986770867718677286773867748677586776867778677886779867808678186782867838678486785867868678786788867898679086791867928679386794867958679686797867988679986800868018680286803868048680586806868078680886809868108681186812868138681486815868168681786818868198682086821868228682386824868258682686827868288682986830868318683286833868348683586836868378683886839868408684186842868438684486845868468684786848868498685086851868528685386854868558685686857868588685986860868618686286863868648686586866868678686886869868708687186872868738687486875868768687786878868798688086881868828688386884868858688686887868888688986890868918689286893868948689586896868978689886899869008690186902869038690486905869068690786908869098691086911869128691386914869158691686917869188691986920869218692286923869248692586926869278692886929869308693186932869338693486935869368693786938869398694086941869428694386944869458694686947869488694986950869518695286953869548695586956869578695886959869608696186962869638696486965869668696786968869698697086971869728697386974869758697686977869788697986980869818698286983869848698586986869878698886989869908699186992869938699486995869968699786998869998700087001870028700387004870058700687007870088700987010870118701287013870148701587016870178701887019870208702187022870238702487025870268702787028870298703087031870328703387034870358703687037870388703987040870418704287043870448704587046870478704887049870508705187052870538705487055870568705787058870598706087061870628706387064870658706687067870688706987070870718707287073870748707587076870778707887079870808708187082870838708487085870868708787088870898709087091870928709387094870958709687097870988709987100871018710287103871048710587106871078710887109871108711187112871138711487115871168711787118871198712087121871228712387124871258712687127871288712987130871318713287133871348713587136871378713887139871408714187142871438714487145871468714787148871498715087151871528715387154871558715687157871588715987160871618716287163871648716587166871678716887169871708717187172871738717487175871768717787178871798718087181871828718387184871858718687187871888718987190871918719287193871948719587196871978719887199872008720187202872038720487205872068720787208872098721087211872128721387214872158721687217872188721987220872218722287223872248722587226872278722887229872308723187232872338723487235872368723787238872398724087241872428724387244872458724687247872488724987250872518725287253872548725587256872578725887259872608726187262872638726487265872668726787268872698727087271872728727387274872758727687277872788727987280872818728287283872848728587286872878728887289872908729187292872938729487295872968729787298872998730087301873028730387304873058730687307873088730987310873118731287313873148731587316873178731887319873208732187322873238732487325873268732787328873298733087331873328733387334873358733687337873388733987340873418734287343873448734587346873478734887349873508735187352873538735487355873568735787358873598736087361873628736387364873658736687367873688736987370873718737287373873748737587376873778737887379873808738187382873838738487385873868738787388873898739087391873928739387394873958739687397873988739987400874018740287403874048740587406874078740887409874108741187412874138741487415874168741787418874198742087421874228742387424874258742687427874288742987430874318743287433874348743587436874378743887439874408744187442874438744487445874468744787448874498745087451874528745387454874558745687457874588745987460874618746287463874648746587466874678746887469874708747187472874738747487475874768747787478874798748087481874828748387484874858748687487874888748987490874918749287493874948749587496874978749887499875008750187502875038750487505875068750787508875098751087511875128751387514875158751687517875188751987520875218752287523875248752587526875278752887529875308753187532875338753487535875368753787538875398754087541875428754387544875458754687547875488754987550875518755287553875548755587556875578755887559875608756187562875638756487565875668756787568875698757087571875728757387574875758757687577875788757987580875818758287583875848758587586875878758887589875908759187592875938759487595875968759787598875998760087601876028760387604876058760687607876088760987610876118761287613876148761587616876178761887619876208762187622876238762487625876268762787628876298763087631876328763387634876358763687637876388763987640876418764287643876448764587646876478764887649876508765187652876538765487655876568765787658876598766087661876628766387664876658766687667876688766987670876718767287673876748767587676876778767887679876808768187682876838768487685876868768787688876898769087691876928769387694876958769687697876988769987700877018770287703877048770587706877078770887709877108771187712877138771487715877168771787718877198772087721877228772387724877258772687727877288772987730877318773287733877348773587736877378773887739877408774187742877438774487745877468774787748877498775087751877528775387754877558775687757877588775987760877618776287763877648776587766877678776887769877708777187772877738777487775877768777787778877798778087781877828778387784877858778687787877888778987790877918779287793877948779587796877978779887799878008780187802878038780487805878068780787808878098781087811878128781387814878158781687817878188781987820878218782287823878248782587826878278782887829878308783187832878338783487835878368783787838878398784087841878428784387844878458784687847878488784987850878518785287853878548785587856878578785887859878608786187862878638786487865878668786787868878698787087871878728787387874878758787687877878788787987880878818788287883878848788587886878878788887889878908789187892878938789487895878968789787898878998790087901879028790387904879058790687907879088790987910879118791287913879148791587916879178791887919879208792187922879238792487925879268792787928879298793087931879328793387934879358793687937879388793987940879418794287943879448794587946879478794887949879508795187952879538795487955879568795787958879598796087961879628796387964879658796687967879688796987970879718797287973879748797587976879778797887979879808798187982879838798487985879868798787988879898799087991879928799387994879958799687997879988799988000880018800288003880048800588006880078800888009880108801188012880138801488015880168801788018880198802088021880228802388024880258802688027880288802988030880318803288033880348803588036880378803888039880408804188042880438804488045880468804788048880498805088051880528805388054880558805688057880588805988060880618806288063880648806588066880678806888069880708807188072880738807488075880768807788078880798808088081880828808388084880858808688087880888808988090880918809288093880948809588096880978809888099881008810188102881038810488105881068810788108881098811088111881128811388114881158811688117881188811988120881218812288123881248812588126881278812888129881308813188132881338813488135881368813788138881398814088141881428814388144881458814688147881488814988150881518815288153881548815588156881578815888159881608816188162881638816488165881668816788168881698817088171881728817388174881758817688177881788817988180881818818288183881848818588186881878818888189881908819188192881938819488195881968819788198881998820088201882028820388204882058820688207882088820988210882118821288213882148821588216882178821888219882208822188222882238822488225882268822788228882298823088231882328823388234882358823688237882388823988240882418824288243882448824588246882478824888249882508825188252882538825488255882568825788258882598826088261882628826388264882658826688267882688826988270882718827288273882748827588276882778827888279882808828188282882838828488285882868828788288882898829088291882928829388294882958829688297882988829988300883018830288303883048830588306883078830888309883108831188312883138831488315883168831788318883198832088321883228832388324883258832688327883288832988330883318833288333883348833588336883378833888339883408834188342883438834488345883468834788348883498835088351883528835388354883558835688357883588835988360883618836288363883648836588366883678836888369883708837188372883738837488375883768837788378883798838088381883828838388384883858838688387883888838988390883918839288393883948839588396883978839888399884008840188402884038840488405884068840788408884098841088411884128841388414884158841688417884188841988420884218842288423884248842588426884278842888429884308843188432884338843488435884368843788438884398844088441884428844388444884458844688447884488844988450884518845288453884548845588456884578845888459884608846188462884638846488465884668846788468884698847088471884728847388474884758847688477884788847988480884818848288483884848848588486884878848888489884908849188492884938849488495884968849788498884998850088501885028850388504885058850688507885088850988510885118851288513885148851588516885178851888519885208852188522885238852488525885268852788528885298853088531885328853388534885358853688537885388853988540885418854288543885448854588546885478854888549885508855188552885538855488555885568855788558885598856088561885628856388564885658856688567885688856988570885718857288573885748857588576885778857888579885808858188582885838858488585885868858788588885898859088591885928859388594885958859688597885988859988600886018860288603886048860588606886078860888609886108861188612886138861488615886168861788618886198862088621886228862388624886258862688627886288862988630886318863288633886348863588636886378863888639886408864188642886438864488645886468864788648886498865088651886528865388654886558865688657886588865988660886618866288663886648866588666886678866888669886708867188672886738867488675886768867788678886798868088681886828868388684886858868688687886888868988690886918869288693886948869588696886978869888699887008870188702887038870488705887068870788708887098871088711887128871388714887158871688717887188871988720887218872288723887248872588726887278872888729887308873188732887338873488735887368873788738887398874088741887428874388744887458874688747887488874988750887518875288753887548875588756887578875888759887608876188762887638876488765887668876788768887698877088771887728877388774887758877688777887788877988780887818878288783887848878588786887878878888789887908879188792887938879488795887968879788798887998880088801888028880388804888058880688807
  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. * @param updateOnlyBuffersList True to only update the uniformBuffersList array
  27256. */
  27257. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>, updateOnlyBuffersList?: boolean): void;
  27258. /**
  27259. * Prepares the uniforms and samplers list to be used in the effect
  27260. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  27261. * @param samplersList The sampler list
  27262. * @param defines The defines helping in the list generation
  27263. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  27264. */
  27265. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  27266. /**
  27267. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  27268. * @param defines The defines to update while falling back
  27269. * @param fallbacks The authorized effect fallbacks
  27270. * @param maxSimultaneousLights The maximum number of lights allowed
  27271. * @param rank the current rank of the Effect
  27272. * @returns The newly affected rank
  27273. */
  27274. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  27275. private static _TmpMorphInfluencers;
  27276. /**
  27277. * Prepares the list of attributes required for morph targets according to the effect defines.
  27278. * @param attribs The current list of supported attribs
  27279. * @param mesh The mesh to prepare the morph targets attributes for
  27280. * @param influencers The number of influencers
  27281. */
  27282. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  27283. /**
  27284. * Prepares the list of attributes required for morph targets according to the effect defines.
  27285. * @param attribs The current list of supported attribs
  27286. * @param mesh The mesh to prepare the morph targets attributes for
  27287. * @param defines The current Defines of the effect
  27288. */
  27289. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  27290. /**
  27291. * Prepares the list of attributes required for bones according to the effect defines.
  27292. * @param attribs The current list of supported attribs
  27293. * @param mesh The mesh to prepare the bones attributes for
  27294. * @param defines The current Defines of the effect
  27295. * @param fallbacks The current efffect fallback strategy
  27296. */
  27297. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  27298. /**
  27299. * Check and prepare the list of attributes required for instances according to the effect defines.
  27300. * @param attribs The current list of supported attribs
  27301. * @param defines The current MaterialDefines of the effect
  27302. */
  27303. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  27304. /**
  27305. * Add the list of attributes required for instances to the attribs array.
  27306. * @param attribs The current list of supported attribs
  27307. */
  27308. static PushAttributesForInstances(attribs: string[]): void;
  27309. /**
  27310. * Binds the light information to the effect.
  27311. * @param light The light containing the generator
  27312. * @param effect The effect we are binding the data to
  27313. * @param lightIndex The light index in the effect used to render
  27314. */
  27315. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  27316. /**
  27317. * Binds the lights information from the scene to the effect for the given mesh.
  27318. * @param light Light to bind
  27319. * @param lightIndex Light index
  27320. * @param scene The scene where the light belongs to
  27321. * @param effect The effect we are binding the data to
  27322. * @param useSpecular Defines if specular is supported
  27323. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  27324. */
  27325. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  27326. /**
  27327. * Binds the lights information from the scene to the effect for the given mesh.
  27328. * @param scene The scene the lights belongs to
  27329. * @param mesh The mesh we are binding the information to render
  27330. * @param effect The effect we are binding the data to
  27331. * @param defines The generated defines for the effect
  27332. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  27333. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  27334. */
  27335. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  27336. private static _tempFogColor;
  27337. /**
  27338. * Binds the fog information from the scene to the effect for the given mesh.
  27339. * @param scene The scene the lights belongs to
  27340. * @param mesh The mesh we are binding the information to render
  27341. * @param effect The effect we are binding the data to
  27342. * @param linearSpace Defines if the fog effect is applied in linear space
  27343. */
  27344. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  27345. /**
  27346. * Binds the bones information from the mesh to the effect.
  27347. * @param mesh The mesh we are binding the information to render
  27348. * @param effect The effect we are binding the data to
  27349. * @param prePassConfiguration Configuration for the prepass, in case prepass is activated
  27350. */
  27351. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect, prePassConfiguration?: PrePassConfiguration): void;
  27352. private static _CopyBonesTransformationMatrices;
  27353. /**
  27354. * Binds the morph targets information from the mesh to the effect.
  27355. * @param abstractMesh The mesh we are binding the information to render
  27356. * @param effect The effect we are binding the data to
  27357. */
  27358. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  27359. /**
  27360. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  27361. * @param defines The generated defines used in the effect
  27362. * @param effect The effect we are binding the data to
  27363. * @param scene The scene we are willing to render with logarithmic scale for
  27364. */
  27365. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  27366. /**
  27367. * Binds the clip plane information from the scene to the effect.
  27368. * @param scene The scene the clip plane information are extracted from
  27369. * @param effect The effect we are binding the data to
  27370. */
  27371. static BindClipPlane(effect: Effect, scene: Scene): void;
  27372. }
  27373. }
  27374. declare module BABYLON {
  27375. /** @hidden */
  27376. export var bayerDitherFunctions: {
  27377. name: string;
  27378. shader: string;
  27379. };
  27380. }
  27381. declare module BABYLON {
  27382. /** @hidden */
  27383. export var shadowMapFragmentDeclaration: {
  27384. name: string;
  27385. shader: string;
  27386. };
  27387. }
  27388. declare module BABYLON {
  27389. /** @hidden */
  27390. export var shadowMapFragment: {
  27391. name: string;
  27392. shader: string;
  27393. };
  27394. }
  27395. declare module BABYLON {
  27396. /** @hidden */
  27397. export var shadowMapPixelShader: {
  27398. name: string;
  27399. shader: string;
  27400. };
  27401. }
  27402. declare module BABYLON {
  27403. /** @hidden */
  27404. export var shadowMapVertexDeclaration: {
  27405. name: string;
  27406. shader: string;
  27407. };
  27408. }
  27409. declare module BABYLON {
  27410. /** @hidden */
  27411. export var shadowMapVertexNormalBias: {
  27412. name: string;
  27413. shader: string;
  27414. };
  27415. }
  27416. declare module BABYLON {
  27417. /** @hidden */
  27418. export var shadowMapVertexMetric: {
  27419. name: string;
  27420. shader: string;
  27421. };
  27422. }
  27423. declare module BABYLON {
  27424. /** @hidden */
  27425. export var shadowMapVertexShader: {
  27426. name: string;
  27427. shader: string;
  27428. };
  27429. }
  27430. declare module BABYLON {
  27431. /** @hidden */
  27432. export var depthBoxBlurPixelShader: {
  27433. name: string;
  27434. shader: string;
  27435. };
  27436. }
  27437. declare module BABYLON {
  27438. /** @hidden */
  27439. export var shadowMapFragmentSoftTransparentShadow: {
  27440. name: string;
  27441. shader: string;
  27442. };
  27443. }
  27444. declare module BABYLON {
  27445. /**
  27446. * Creates an instance based on a source mesh.
  27447. */
  27448. export class InstancedMesh extends AbstractMesh {
  27449. private _sourceMesh;
  27450. private _currentLOD;
  27451. /** @hidden */
  27452. _indexInSourceMeshInstanceArray: number;
  27453. constructor(name: string, source: Mesh);
  27454. /**
  27455. * Returns the string "InstancedMesh".
  27456. */
  27457. getClassName(): string;
  27458. /** Gets the list of lights affecting that mesh */
  27459. get lightSources(): Light[];
  27460. _resyncLightSources(): void;
  27461. _resyncLightSource(light: Light): void;
  27462. _removeLightSource(light: Light, dispose: boolean): void;
  27463. /**
  27464. * If the source mesh receives shadows
  27465. */
  27466. get receiveShadows(): boolean;
  27467. /**
  27468. * The material of the source mesh
  27469. */
  27470. get material(): Nullable<Material>;
  27471. /**
  27472. * Visibility of the source mesh
  27473. */
  27474. get visibility(): number;
  27475. /**
  27476. * Skeleton of the source mesh
  27477. */
  27478. get skeleton(): Nullable<Skeleton>;
  27479. /**
  27480. * Rendering ground id of the source mesh
  27481. */
  27482. get renderingGroupId(): number;
  27483. set renderingGroupId(value: number);
  27484. /**
  27485. * Returns the total number of vertices (integer).
  27486. */
  27487. getTotalVertices(): number;
  27488. /**
  27489. * Returns a positive integer : the total number of indices in this mesh geometry.
  27490. * @returns the numner of indices or zero if the mesh has no geometry.
  27491. */
  27492. getTotalIndices(): number;
  27493. /**
  27494. * The source mesh of the instance
  27495. */
  27496. get sourceMesh(): Mesh;
  27497. /**
  27498. * Creates a new InstancedMesh object from the mesh model.
  27499. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  27500. * @param name defines the name of the new instance
  27501. * @returns a new InstancedMesh
  27502. */
  27503. createInstance(name: string): InstancedMesh;
  27504. /**
  27505. * Is this node ready to be used/rendered
  27506. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  27507. * @return {boolean} is it ready
  27508. */
  27509. isReady(completeCheck?: boolean): boolean;
  27510. /**
  27511. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  27512. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  27513. * @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.
  27514. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  27515. */
  27516. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  27517. /**
  27518. * Sets the vertex data of the mesh geometry for the requested `kind`.
  27519. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  27520. * The `data` are either a numeric array either a Float32Array.
  27521. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  27522. * 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).
  27523. * Note that a new underlying VertexBuffer object is created each call.
  27524. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  27525. *
  27526. * Possible `kind` values :
  27527. * - VertexBuffer.PositionKind
  27528. * - VertexBuffer.UVKind
  27529. * - VertexBuffer.UV2Kind
  27530. * - VertexBuffer.UV3Kind
  27531. * - VertexBuffer.UV4Kind
  27532. * - VertexBuffer.UV5Kind
  27533. * - VertexBuffer.UV6Kind
  27534. * - VertexBuffer.ColorKind
  27535. * - VertexBuffer.MatricesIndicesKind
  27536. * - VertexBuffer.MatricesIndicesExtraKind
  27537. * - VertexBuffer.MatricesWeightsKind
  27538. * - VertexBuffer.MatricesWeightsExtraKind
  27539. *
  27540. * Returns the Mesh.
  27541. */
  27542. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  27543. /**
  27544. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  27545. * If the mesh has no geometry, it is simply returned as it is.
  27546. * The `data` are either a numeric array either a Float32Array.
  27547. * No new underlying VertexBuffer object is created.
  27548. * 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.
  27549. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  27550. *
  27551. * Possible `kind` values :
  27552. * - VertexBuffer.PositionKind
  27553. * - VertexBuffer.UVKind
  27554. * - VertexBuffer.UV2Kind
  27555. * - VertexBuffer.UV3Kind
  27556. * - VertexBuffer.UV4Kind
  27557. * - VertexBuffer.UV5Kind
  27558. * - VertexBuffer.UV6Kind
  27559. * - VertexBuffer.ColorKind
  27560. * - VertexBuffer.MatricesIndicesKind
  27561. * - VertexBuffer.MatricesIndicesExtraKind
  27562. * - VertexBuffer.MatricesWeightsKind
  27563. * - VertexBuffer.MatricesWeightsExtraKind
  27564. *
  27565. * Returns the Mesh.
  27566. */
  27567. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  27568. /**
  27569. * Sets the mesh indices.
  27570. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  27571. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  27572. * This method creates a new index buffer each call.
  27573. * Returns the Mesh.
  27574. */
  27575. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  27576. /**
  27577. * Boolean : True if the mesh owns the requested kind of data.
  27578. */
  27579. isVerticesDataPresent(kind: string): boolean;
  27580. /**
  27581. * Returns an array of indices (IndicesArray).
  27582. */
  27583. getIndices(): Nullable<IndicesArray>;
  27584. get _positions(): Nullable<Vector3[]>;
  27585. /**
  27586. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  27587. * This means the mesh underlying bounding box and sphere are recomputed.
  27588. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  27589. * @returns the current mesh
  27590. */
  27591. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  27592. /** @hidden */
  27593. _preActivate(): InstancedMesh;
  27594. /** @hidden */
  27595. _activate(renderId: number, intermediateRendering: boolean): boolean;
  27596. /** @hidden */
  27597. _postActivate(): void;
  27598. getWorldMatrix(): Matrix;
  27599. get isAnInstance(): boolean;
  27600. /**
  27601. * Returns the current associated LOD AbstractMesh.
  27602. */
  27603. getLOD(camera: Camera): AbstractMesh;
  27604. /** @hidden */
  27605. _preActivateForIntermediateRendering(renderId: number): Mesh;
  27606. /** @hidden */
  27607. _syncSubMeshes(): InstancedMesh;
  27608. /** @hidden */
  27609. _generatePointsArray(): boolean;
  27610. /** @hidden */
  27611. _updateBoundingInfo(): AbstractMesh;
  27612. /**
  27613. * Creates a new InstancedMesh from the current mesh.
  27614. * - name (string) : the cloned mesh name
  27615. * - newParent (optional Node) : the optional Node to parent the clone to.
  27616. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  27617. *
  27618. * Returns the clone.
  27619. */
  27620. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  27621. /**
  27622. * Disposes the InstancedMesh.
  27623. * Returns nothing.
  27624. */
  27625. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  27626. }
  27627. interface Mesh {
  27628. /**
  27629. * Register a custom buffer that will be instanced
  27630. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  27631. * @param kind defines the buffer kind
  27632. * @param stride defines the stride in floats
  27633. */
  27634. registerInstancedBuffer(kind: string, stride: number): void;
  27635. /**
  27636. * true to use the edge renderer for all instances of this mesh
  27637. */
  27638. edgesShareWithInstances: boolean;
  27639. /** @hidden */
  27640. _userInstancedBuffersStorage: {
  27641. data: {
  27642. [key: string]: Float32Array;
  27643. };
  27644. sizes: {
  27645. [key: string]: number;
  27646. };
  27647. vertexBuffers: {
  27648. [key: string]: Nullable<VertexBuffer>;
  27649. };
  27650. strides: {
  27651. [key: string]: number;
  27652. };
  27653. };
  27654. }
  27655. interface AbstractMesh {
  27656. /**
  27657. * Object used to store instanced buffers defined by user
  27658. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  27659. */
  27660. instancedBuffers: {
  27661. [key: string]: any;
  27662. };
  27663. }
  27664. }
  27665. declare module BABYLON {
  27666. /**
  27667. * Defines the options associated with the creation of a shader material.
  27668. */
  27669. export interface IShaderMaterialOptions {
  27670. /**
  27671. * Does the material work in alpha blend mode
  27672. */
  27673. needAlphaBlending: boolean;
  27674. /**
  27675. * Does the material work in alpha test mode
  27676. */
  27677. needAlphaTesting: boolean;
  27678. /**
  27679. * The list of attribute names used in the shader
  27680. */
  27681. attributes: string[];
  27682. /**
  27683. * The list of unifrom names used in the shader
  27684. */
  27685. uniforms: string[];
  27686. /**
  27687. * The list of UBO names used in the shader
  27688. */
  27689. uniformBuffers: string[];
  27690. /**
  27691. * The list of sampler names used in the shader
  27692. */
  27693. samplers: string[];
  27694. /**
  27695. * The list of defines used in the shader
  27696. */
  27697. defines: string[];
  27698. }
  27699. /**
  27700. * 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.
  27701. *
  27702. * This returned material effects how the mesh will look based on the code in the shaders.
  27703. *
  27704. * @see https://doc.babylonjs.com/how_to/shader_material
  27705. */
  27706. export class ShaderMaterial extends Material {
  27707. private _shaderPath;
  27708. private _options;
  27709. private _textures;
  27710. private _textureArrays;
  27711. private _floats;
  27712. private _ints;
  27713. private _floatsArrays;
  27714. private _colors3;
  27715. private _colors3Arrays;
  27716. private _colors4;
  27717. private _colors4Arrays;
  27718. private _vectors2;
  27719. private _vectors3;
  27720. private _vectors4;
  27721. private _matrices;
  27722. private _matrixArrays;
  27723. private _matrices3x3;
  27724. private _matrices2x2;
  27725. private _vectors2Arrays;
  27726. private _vectors3Arrays;
  27727. private _vectors4Arrays;
  27728. private _cachedWorldViewMatrix;
  27729. private _cachedWorldViewProjectionMatrix;
  27730. private _renderId;
  27731. private _multiview;
  27732. private _cachedDefines;
  27733. /** Define the Url to load snippets */
  27734. static SnippetUrl: string;
  27735. /** Snippet ID if the material was created from the snippet server */
  27736. snippetId: string;
  27737. /**
  27738. * Instantiate a new shader material.
  27739. * 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.
  27740. * This returned material effects how the mesh will look based on the code in the shaders.
  27741. * @see https://doc.babylonjs.com/how_to/shader_material
  27742. * @param name Define the name of the material in the scene
  27743. * @param scene Define the scene the material belongs to
  27744. * @param shaderPath Defines the route to the shader code in one of three ways:
  27745. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  27746. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  27747. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  27748. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  27749. * @param options Define the options used to create the shader
  27750. */
  27751. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  27752. /**
  27753. * Gets the shader path used to define the shader code
  27754. * It can be modified to trigger a new compilation
  27755. */
  27756. get shaderPath(): any;
  27757. /**
  27758. * Sets the shader path used to define the shader code
  27759. * It can be modified to trigger a new compilation
  27760. */
  27761. set shaderPath(shaderPath: any);
  27762. /**
  27763. * Gets the options used to compile the shader.
  27764. * They can be modified to trigger a new compilation
  27765. */
  27766. get options(): IShaderMaterialOptions;
  27767. /**
  27768. * Gets the current class name of the material e.g. "ShaderMaterial"
  27769. * Mainly use in serialization.
  27770. * @returns the class name
  27771. */
  27772. getClassName(): string;
  27773. /**
  27774. * Specifies if the material will require alpha blending
  27775. * @returns a boolean specifying if alpha blending is needed
  27776. */
  27777. needAlphaBlending(): boolean;
  27778. /**
  27779. * Specifies if this material should be rendered in alpha test mode
  27780. * @returns a boolean specifying if an alpha test is needed.
  27781. */
  27782. needAlphaTesting(): boolean;
  27783. private _checkUniform;
  27784. /**
  27785. * Set a texture in the shader.
  27786. * @param name Define the name of the uniform samplers as defined in the shader
  27787. * @param texture Define the texture to bind to this sampler
  27788. * @return the material itself allowing "fluent" like uniform updates
  27789. */
  27790. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  27791. /**
  27792. * Set a texture array in the shader.
  27793. * @param name Define the name of the uniform sampler array as defined in the shader
  27794. * @param textures Define the list of textures to bind to this sampler
  27795. * @return the material itself allowing "fluent" like uniform updates
  27796. */
  27797. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  27798. /**
  27799. * Set a float in the shader.
  27800. * @param name Define the name of the uniform as defined in the shader
  27801. * @param value Define the value to give to the uniform
  27802. * @return the material itself allowing "fluent" like uniform updates
  27803. */
  27804. setFloat(name: string, value: number): ShaderMaterial;
  27805. /**
  27806. * Set a int in the shader.
  27807. * @param name Define the name of the uniform as defined in the shader
  27808. * @param value Define the value to give to the uniform
  27809. * @return the material itself allowing "fluent" like uniform updates
  27810. */
  27811. setInt(name: string, value: number): ShaderMaterial;
  27812. /**
  27813. * Set an array of floats in the shader.
  27814. * @param name Define the name of the uniform as defined in the shader
  27815. * @param value Define the value to give to the uniform
  27816. * @return the material itself allowing "fluent" like uniform updates
  27817. */
  27818. setFloats(name: string, value: number[]): ShaderMaterial;
  27819. /**
  27820. * Set a vec3 in the shader from a Color3.
  27821. * @param name Define the name of the uniform as defined in the shader
  27822. * @param value Define the value to give to the uniform
  27823. * @return the material itself allowing "fluent" like uniform updates
  27824. */
  27825. setColor3(name: string, value: Color3): ShaderMaterial;
  27826. /**
  27827. * Set a vec3 array in the shader from a Color3 array.
  27828. * @param name Define the name of the uniform as defined in the shader
  27829. * @param value Define the value to give to the uniform
  27830. * @return the material itself allowing "fluent" like uniform updates
  27831. */
  27832. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  27833. /**
  27834. * Set a vec4 in the shader from a Color4.
  27835. * @param name Define the name of the uniform as defined in the shader
  27836. * @param value Define the value to give to the uniform
  27837. * @return the material itself allowing "fluent" like uniform updates
  27838. */
  27839. setColor4(name: string, value: Color4): ShaderMaterial;
  27840. /**
  27841. * Set a vec4 array in the shader from a Color4 array.
  27842. * @param name Define the name of the uniform as defined in the shader
  27843. * @param value Define the value to give to the uniform
  27844. * @return the material itself allowing "fluent" like uniform updates
  27845. */
  27846. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  27847. /**
  27848. * Set a vec2 in the shader from a Vector2.
  27849. * @param name Define the name of the uniform as defined in the shader
  27850. * @param value Define the value to give to the uniform
  27851. * @return the material itself allowing "fluent" like uniform updates
  27852. */
  27853. setVector2(name: string, value: Vector2): ShaderMaterial;
  27854. /**
  27855. * Set a vec3 in the shader from a Vector3.
  27856. * @param name Define the name of the uniform as defined in the shader
  27857. * @param value Define the value to give to the uniform
  27858. * @return the material itself allowing "fluent" like uniform updates
  27859. */
  27860. setVector3(name: string, value: Vector3): ShaderMaterial;
  27861. /**
  27862. * Set a vec4 in the shader from a Vector4.
  27863. * @param name Define the name of the uniform as defined in the shader
  27864. * @param value Define the value to give to the uniform
  27865. * @return the material itself allowing "fluent" like uniform updates
  27866. */
  27867. setVector4(name: string, value: Vector4): ShaderMaterial;
  27868. /**
  27869. * Set a mat4 in the shader from a Matrix.
  27870. * @param name Define the name of the uniform as defined in the shader
  27871. * @param value Define the value to give to the uniform
  27872. * @return the material itself allowing "fluent" like uniform updates
  27873. */
  27874. setMatrix(name: string, value: Matrix): ShaderMaterial;
  27875. /**
  27876. * Set a float32Array in the shader from a matrix array.
  27877. * @param name Define the name of the uniform as defined in the shader
  27878. * @param value Define the value to give to the uniform
  27879. * @return the material itself allowing "fluent" like uniform updates
  27880. */
  27881. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  27882. /**
  27883. * Set a mat3 in the shader from a Float32Array.
  27884. * @param name Define the name of the uniform as defined in the shader
  27885. * @param value Define the value to give to the uniform
  27886. * @return the material itself allowing "fluent" like uniform updates
  27887. */
  27888. setMatrix3x3(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  27889. /**
  27890. * Set a mat2 in the shader from a Float32Array.
  27891. * @param name Define the name of the uniform as defined in the shader
  27892. * @param value Define the value to give to the uniform
  27893. * @return the material itself allowing "fluent" like uniform updates
  27894. */
  27895. setMatrix2x2(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  27896. /**
  27897. * Set a vec2 array in the shader from a number array.
  27898. * @param name Define the name of the uniform as defined in the shader
  27899. * @param value Define the value to give to the uniform
  27900. * @return the material itself allowing "fluent" like uniform updates
  27901. */
  27902. setArray2(name: string, value: number[]): ShaderMaterial;
  27903. /**
  27904. * Set a vec3 array in the shader from a number array.
  27905. * @param name Define the name of the uniform as defined in the shader
  27906. * @param value Define the value to give to the uniform
  27907. * @return the material itself allowing "fluent" like uniform updates
  27908. */
  27909. setArray3(name: string, value: number[]): ShaderMaterial;
  27910. /**
  27911. * Set a vec4 array in the shader from a number array.
  27912. * @param name Define the name of the uniform as defined in the shader
  27913. * @param value Define the value to give to the uniform
  27914. * @return the material itself allowing "fluent" like uniform updates
  27915. */
  27916. setArray4(name: string, value: number[]): ShaderMaterial;
  27917. private _checkCache;
  27918. /**
  27919. * Specifies that the submesh is ready to be used
  27920. * @param mesh defines the mesh to check
  27921. * @param subMesh defines which submesh to check
  27922. * @param useInstances specifies that instances should be used
  27923. * @returns a boolean indicating that the submesh is ready or not
  27924. */
  27925. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  27926. /**
  27927. * Checks if the material is ready to render the requested mesh
  27928. * @param mesh Define the mesh to render
  27929. * @param useInstances Define whether or not the material is used with instances
  27930. * @returns true if ready, otherwise false
  27931. */
  27932. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  27933. /**
  27934. * Binds the world matrix to the material
  27935. * @param world defines the world transformation matrix
  27936. * @param effectOverride - If provided, use this effect instead of internal effect
  27937. */
  27938. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  27939. /**
  27940. * Binds the submesh to this material by preparing the effect and shader to draw
  27941. * @param world defines the world transformation matrix
  27942. * @param mesh defines the mesh containing the submesh
  27943. * @param subMesh defines the submesh to bind the material to
  27944. */
  27945. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  27946. /**
  27947. * Binds the material to the mesh
  27948. * @param world defines the world transformation matrix
  27949. * @param mesh defines the mesh to bind the material to
  27950. * @param effectOverride - If provided, use this effect instead of internal effect
  27951. */
  27952. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  27953. protected _afterBind(mesh?: Mesh): void;
  27954. /**
  27955. * Gets the active textures from the material
  27956. * @returns an array of textures
  27957. */
  27958. getActiveTextures(): BaseTexture[];
  27959. /**
  27960. * Specifies if the material uses a texture
  27961. * @param texture defines the texture to check against the material
  27962. * @returns a boolean specifying if the material uses the texture
  27963. */
  27964. hasTexture(texture: BaseTexture): boolean;
  27965. /**
  27966. * Makes a duplicate of the material, and gives it a new name
  27967. * @param name defines the new name for the duplicated material
  27968. * @returns the cloned material
  27969. */
  27970. clone(name: string): ShaderMaterial;
  27971. /**
  27972. * Disposes the material
  27973. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  27974. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  27975. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  27976. */
  27977. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  27978. /**
  27979. * Serializes this material in a JSON representation
  27980. * @returns the serialized material object
  27981. */
  27982. serialize(): any;
  27983. /**
  27984. * Creates a shader material from parsed shader material data
  27985. * @param source defines the JSON represnetation of the material
  27986. * @param scene defines the hosting scene
  27987. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  27988. * @returns a new material
  27989. */
  27990. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  27991. /**
  27992. * Creates a new ShaderMaterial from a snippet saved in a remote file
  27993. * @param name defines the name of the ShaderMaterial to create (can be null or empty to use the one from the json data)
  27994. * @param url defines the url to load from
  27995. * @param scene defines the hosting scene
  27996. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  27997. * @returns a promise that will resolve to the new ShaderMaterial
  27998. */
  27999. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  28000. /**
  28001. * Creates a ShaderMaterial from a snippet saved by the Inspector
  28002. * @param snippetId defines the snippet to load
  28003. * @param scene defines the hosting scene
  28004. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  28005. * @returns a promise that will resolve to the new ShaderMaterial
  28006. */
  28007. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  28008. }
  28009. }
  28010. declare module BABYLON {
  28011. /** @hidden */
  28012. export var colorPixelShader: {
  28013. name: string;
  28014. shader: string;
  28015. };
  28016. }
  28017. declare module BABYLON {
  28018. /** @hidden */
  28019. export var colorVertexShader: {
  28020. name: string;
  28021. shader: string;
  28022. };
  28023. }
  28024. declare module BABYLON {
  28025. /**
  28026. * Line mesh
  28027. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  28028. */
  28029. export class LinesMesh extends Mesh {
  28030. /**
  28031. * If vertex color should be applied to the mesh
  28032. */
  28033. readonly useVertexColor?: boolean | undefined;
  28034. /**
  28035. * If vertex alpha should be applied to the mesh
  28036. */
  28037. readonly useVertexAlpha?: boolean | undefined;
  28038. /**
  28039. * Color of the line (Default: White)
  28040. */
  28041. color: Color3;
  28042. /**
  28043. * Alpha of the line (Default: 1)
  28044. */
  28045. alpha: number;
  28046. /**
  28047. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  28048. * This margin is expressed in world space coordinates, so its value may vary.
  28049. * Default value is 0.1
  28050. */
  28051. intersectionThreshold: number;
  28052. private _colorShader;
  28053. private color4;
  28054. /**
  28055. * Creates a new LinesMesh
  28056. * @param name defines the name
  28057. * @param scene defines the hosting scene
  28058. * @param parent defines the parent mesh if any
  28059. * @param source defines the optional source LinesMesh used to clone data from
  28060. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  28061. * When false, achieved by calling a clone(), also passing False.
  28062. * This will make creation of children, recursive.
  28063. * @param useVertexColor defines if this LinesMesh supports vertex color
  28064. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  28065. */
  28066. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  28067. /**
  28068. * If vertex color should be applied to the mesh
  28069. */
  28070. useVertexColor?: boolean | undefined,
  28071. /**
  28072. * If vertex alpha should be applied to the mesh
  28073. */
  28074. useVertexAlpha?: boolean | undefined);
  28075. private _addClipPlaneDefine;
  28076. private _removeClipPlaneDefine;
  28077. isReady(): boolean;
  28078. /**
  28079. * Returns the string "LineMesh"
  28080. */
  28081. getClassName(): string;
  28082. /**
  28083. * @hidden
  28084. */
  28085. get material(): Material;
  28086. /**
  28087. * @hidden
  28088. */
  28089. set material(value: Material);
  28090. /**
  28091. * @hidden
  28092. */
  28093. get checkCollisions(): boolean;
  28094. /** @hidden */
  28095. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  28096. /** @hidden */
  28097. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  28098. /**
  28099. * Disposes of the line mesh
  28100. * @param doNotRecurse If children should be disposed
  28101. */
  28102. dispose(doNotRecurse?: boolean): void;
  28103. /**
  28104. * Returns a new LineMesh object cloned from the current one.
  28105. */
  28106. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  28107. /**
  28108. * Creates a new InstancedLinesMesh object from the mesh model.
  28109. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  28110. * @param name defines the name of the new instance
  28111. * @returns a new InstancedLinesMesh
  28112. */
  28113. createInstance(name: string): InstancedLinesMesh;
  28114. }
  28115. /**
  28116. * Creates an instance based on a source LinesMesh
  28117. */
  28118. export class InstancedLinesMesh extends InstancedMesh {
  28119. /**
  28120. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  28121. * This margin is expressed in world space coordinates, so its value may vary.
  28122. * Initilized with the intersectionThreshold value of the source LinesMesh
  28123. */
  28124. intersectionThreshold: number;
  28125. constructor(name: string, source: LinesMesh);
  28126. /**
  28127. * Returns the string "InstancedLinesMesh".
  28128. */
  28129. getClassName(): string;
  28130. }
  28131. }
  28132. declare module BABYLON {
  28133. /** @hidden */
  28134. export var linePixelShader: {
  28135. name: string;
  28136. shader: string;
  28137. };
  28138. }
  28139. declare module BABYLON {
  28140. /** @hidden */
  28141. export var lineVertexShader: {
  28142. name: string;
  28143. shader: string;
  28144. };
  28145. }
  28146. declare module BABYLON {
  28147. interface Scene {
  28148. /** @hidden */
  28149. _edgeRenderLineShader: Nullable<ShaderMaterial>;
  28150. }
  28151. interface AbstractMesh {
  28152. /**
  28153. * Gets the edgesRenderer associated with the mesh
  28154. */
  28155. edgesRenderer: Nullable<EdgesRenderer>;
  28156. }
  28157. interface LinesMesh {
  28158. /**
  28159. * Enables the edge rendering mode on the mesh.
  28160. * This mode makes the mesh edges visible
  28161. * @param epsilon defines the maximal distance between two angles to detect a face
  28162. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  28163. * @returns the currentAbstractMesh
  28164. * @see https://www.babylonjs-playground.com/#19O9TU#0
  28165. */
  28166. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  28167. }
  28168. interface InstancedLinesMesh {
  28169. /**
  28170. * Enables the edge rendering mode on the mesh.
  28171. * This mode makes the mesh edges visible
  28172. * @param epsilon defines the maximal distance between two angles to detect a face
  28173. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  28174. * @returns the current InstancedLinesMesh
  28175. * @see https://www.babylonjs-playground.com/#19O9TU#0
  28176. */
  28177. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  28178. }
  28179. /**
  28180. * Defines the minimum contract an Edges renderer should follow.
  28181. */
  28182. export interface IEdgesRenderer extends IDisposable {
  28183. /**
  28184. * Gets or sets a boolean indicating if the edgesRenderer is active
  28185. */
  28186. isEnabled: boolean;
  28187. /**
  28188. * Renders the edges of the attached mesh,
  28189. */
  28190. render(): void;
  28191. /**
  28192. * Checks wether or not the edges renderer is ready to render.
  28193. * @return true if ready, otherwise false.
  28194. */
  28195. isReady(): boolean;
  28196. /**
  28197. * List of instances to render in case the source mesh has instances
  28198. */
  28199. customInstances: SmartArray<Matrix>;
  28200. }
  28201. /**
  28202. * Defines the additional options of the edges renderer
  28203. */
  28204. export interface IEdgesRendererOptions {
  28205. /**
  28206. * Gets or sets a boolean indicating that the alternate edge finder algorithm must be used
  28207. * If not defined, the default value is true
  28208. */
  28209. useAlternateEdgeFinder?: boolean;
  28210. /**
  28211. * Gets or sets a boolean indicating that the vertex merger fast processing must be used.
  28212. * If not defined, the default value is true.
  28213. * 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)
  28214. * This option is used only if useAlternateEdgeFinder = true
  28215. */
  28216. useFastVertexMerger?: boolean;
  28217. /**
  28218. * During edges processing, the vertices are merged if they are close enough: epsilonVertexMerge is the limit whithin which vertices are considered to be equal.
  28219. * The default value is 1e-6
  28220. * This option is used only if useAlternateEdgeFinder = true
  28221. */
  28222. epsilonVertexMerge?: number;
  28223. /**
  28224. * 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
  28225. * 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.
  28226. * This option is used only if useAlternateEdgeFinder = true
  28227. */
  28228. applyTessellation?: boolean;
  28229. /**
  28230. * 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
  28231. * The default value is 1e-6
  28232. * This option is used only if useAlternateEdgeFinder = true
  28233. */
  28234. epsilonVertexAligned?: number;
  28235. }
  28236. /**
  28237. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  28238. */
  28239. export class EdgesRenderer implements IEdgesRenderer {
  28240. /**
  28241. * Define the size of the edges with an orthographic camera
  28242. */
  28243. edgesWidthScalerForOrthographic: number;
  28244. /**
  28245. * Define the size of the edges with a perspective camera
  28246. */
  28247. edgesWidthScalerForPerspective: number;
  28248. protected _source: AbstractMesh;
  28249. protected _linesPositions: number[];
  28250. protected _linesNormals: number[];
  28251. protected _linesIndices: number[];
  28252. protected _epsilon: number;
  28253. protected _indicesCount: number;
  28254. protected _lineShader: ShaderMaterial;
  28255. protected _ib: DataBuffer;
  28256. protected _buffers: {
  28257. [key: string]: Nullable<VertexBuffer>;
  28258. };
  28259. protected _buffersForInstances: {
  28260. [key: string]: Nullable<VertexBuffer>;
  28261. };
  28262. protected _checkVerticesInsteadOfIndices: boolean;
  28263. protected _options: Nullable<IEdgesRendererOptions>;
  28264. private _meshRebuildObserver;
  28265. private _meshDisposeObserver;
  28266. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  28267. isEnabled: boolean;
  28268. /** Gets the vertices generated by the edge renderer */
  28269. get linesPositions(): Immutable<Array<number>>;
  28270. /** Gets the normals generated by the edge renderer */
  28271. get linesNormals(): Immutable<Array<number>>;
  28272. /** Gets the indices generated by the edge renderer */
  28273. get linesIndices(): Immutable<Array<number>>;
  28274. /**
  28275. * List of instances to render in case the source mesh has instances
  28276. */
  28277. customInstances: SmartArray<Matrix>;
  28278. private static GetShader;
  28279. /**
  28280. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  28281. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  28282. * @param source Mesh used to create edges
  28283. * @param epsilon sum of angles in adjacency to check for edge
  28284. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices. Note that this parameter is not used if options.useAlternateEdgeFinder = true
  28285. * @param generateEdgesLines - should generate Lines or only prepare resources.
  28286. * @param options The options to apply when generating the edges
  28287. */
  28288. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean, options?: IEdgesRendererOptions);
  28289. protected _prepareRessources(): void;
  28290. /** @hidden */
  28291. _rebuild(): void;
  28292. /**
  28293. * Releases the required resources for the edges renderer
  28294. */
  28295. dispose(): void;
  28296. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  28297. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  28298. /**
  28299. * Checks if the pair of p0 and p1 is en edge
  28300. * @param faceIndex
  28301. * @param edge
  28302. * @param faceNormals
  28303. * @param p0
  28304. * @param p1
  28305. * @private
  28306. */
  28307. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  28308. /**
  28309. * push line into the position, normal and index buffer
  28310. * @protected
  28311. */
  28312. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  28313. /**
  28314. * See https://playground.babylonjs.com/#R3JR6V#1 for a visual display of the algorithm
  28315. */
  28316. private _tessellateTriangle;
  28317. private _generateEdgesLinesAlternate;
  28318. /**
  28319. * Generates lines edges from adjacencjes
  28320. * @private
  28321. */
  28322. _generateEdgesLines(): void;
  28323. /**
  28324. * Checks wether or not the edges renderer is ready to render.
  28325. * @return true if ready, otherwise false.
  28326. */
  28327. isReady(): boolean;
  28328. /**
  28329. * Renders the edges of the attached mesh,
  28330. */
  28331. render(): void;
  28332. }
  28333. /**
  28334. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  28335. */
  28336. export class LineEdgesRenderer extends EdgesRenderer {
  28337. /**
  28338. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  28339. * @param source LineMesh used to generate edges
  28340. * @param epsilon not important (specified angle for edge detection)
  28341. * @param checkVerticesInsteadOfIndices not important for LineMesh
  28342. */
  28343. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  28344. /**
  28345. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  28346. */
  28347. _generateEdgesLines(): void;
  28348. }
  28349. }
  28350. declare module BABYLON {
  28351. /**
  28352. * This represents the object necessary to create a rendering group.
  28353. * This is exclusively used and created by the rendering manager.
  28354. * To modify the behavior, you use the available helpers in your scene or meshes.
  28355. * @hidden
  28356. */
  28357. export class RenderingGroup {
  28358. index: number;
  28359. private static _zeroVector;
  28360. private _scene;
  28361. private _opaqueSubMeshes;
  28362. private _transparentSubMeshes;
  28363. private _alphaTestSubMeshes;
  28364. private _depthOnlySubMeshes;
  28365. private _particleSystems;
  28366. private _spriteManagers;
  28367. private _opaqueSortCompareFn;
  28368. private _alphaTestSortCompareFn;
  28369. private _transparentSortCompareFn;
  28370. private _renderOpaque;
  28371. private _renderAlphaTest;
  28372. private _renderTransparent;
  28373. /** @hidden */
  28374. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  28375. onBeforeTransparentRendering: () => void;
  28376. /**
  28377. * Set the opaque sort comparison function.
  28378. * If null the sub meshes will be render in the order they were created
  28379. */
  28380. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  28381. /**
  28382. * Set the alpha test sort comparison function.
  28383. * If null the sub meshes will be render in the order they were created
  28384. */
  28385. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  28386. /**
  28387. * Set the transparent sort comparison function.
  28388. * If null the sub meshes will be render in the order they were created
  28389. */
  28390. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  28391. /**
  28392. * Creates a new rendering group.
  28393. * @param index The rendering group index
  28394. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  28395. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  28396. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  28397. */
  28398. 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>);
  28399. /**
  28400. * Render all the sub meshes contained in the group.
  28401. * @param customRenderFunction Used to override the default render behaviour of the group.
  28402. * @returns true if rendered some submeshes.
  28403. */
  28404. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  28405. /**
  28406. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  28407. * @param subMeshes The submeshes to render
  28408. */
  28409. private renderOpaqueSorted;
  28410. /**
  28411. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  28412. * @param subMeshes The submeshes to render
  28413. */
  28414. private renderAlphaTestSorted;
  28415. /**
  28416. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  28417. * @param subMeshes The submeshes to render
  28418. */
  28419. private renderTransparentSorted;
  28420. /**
  28421. * Renders the submeshes in a specified order.
  28422. * @param subMeshes The submeshes to sort before render
  28423. * @param sortCompareFn The comparison function use to sort
  28424. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  28425. * @param transparent Specifies to activate blending if true
  28426. */
  28427. private static renderSorted;
  28428. /**
  28429. * Renders the submeshes in the order they were dispatched (no sort applied).
  28430. * @param subMeshes The submeshes to render
  28431. */
  28432. private static renderUnsorted;
  28433. /**
  28434. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  28435. * are rendered back to front if in the same alpha index.
  28436. *
  28437. * @param a The first submesh
  28438. * @param b The second submesh
  28439. * @returns The result of the comparison
  28440. */
  28441. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  28442. /**
  28443. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  28444. * are rendered back to front.
  28445. *
  28446. * @param a The first submesh
  28447. * @param b The second submesh
  28448. * @returns The result of the comparison
  28449. */
  28450. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  28451. /**
  28452. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  28453. * are rendered front to back (prevent overdraw).
  28454. *
  28455. * @param a The first submesh
  28456. * @param b The second submesh
  28457. * @returns The result of the comparison
  28458. */
  28459. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  28460. /**
  28461. * Resets the different lists of submeshes to prepare a new frame.
  28462. */
  28463. prepare(): void;
  28464. dispose(): void;
  28465. /**
  28466. * Inserts the submesh in its correct queue depending on its material.
  28467. * @param subMesh The submesh to dispatch
  28468. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  28469. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  28470. */
  28471. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  28472. dispatchSprites(spriteManager: ISpriteManager): void;
  28473. dispatchParticles(particleSystem: IParticleSystem): void;
  28474. private _renderParticles;
  28475. private _renderSprites;
  28476. }
  28477. }
  28478. declare module BABYLON {
  28479. /**
  28480. * Interface describing the different options available in the rendering manager
  28481. * regarding Auto Clear between groups.
  28482. */
  28483. export interface IRenderingManagerAutoClearSetup {
  28484. /**
  28485. * Defines whether or not autoclear is enable.
  28486. */
  28487. autoClear: boolean;
  28488. /**
  28489. * Defines whether or not to autoclear the depth buffer.
  28490. */
  28491. depth: boolean;
  28492. /**
  28493. * Defines whether or not to autoclear the stencil buffer.
  28494. */
  28495. stencil: boolean;
  28496. }
  28497. /**
  28498. * This class is used by the onRenderingGroupObservable
  28499. */
  28500. export class RenderingGroupInfo {
  28501. /**
  28502. * The Scene that being rendered
  28503. */
  28504. scene: Scene;
  28505. /**
  28506. * The camera currently used for the rendering pass
  28507. */
  28508. camera: Nullable<Camera>;
  28509. /**
  28510. * The ID of the renderingGroup being processed
  28511. */
  28512. renderingGroupId: number;
  28513. }
  28514. /**
  28515. * This is the manager responsible of all the rendering for meshes sprites and particles.
  28516. * It is enable to manage the different groups as well as the different necessary sort functions.
  28517. * This should not be used directly aside of the few static configurations
  28518. */
  28519. export class RenderingManager {
  28520. /**
  28521. * The max id used for rendering groups (not included)
  28522. */
  28523. static MAX_RENDERINGGROUPS: number;
  28524. /**
  28525. * The min id used for rendering groups (included)
  28526. */
  28527. static MIN_RENDERINGGROUPS: number;
  28528. /**
  28529. * Used to globally prevent autoclearing scenes.
  28530. */
  28531. static AUTOCLEAR: boolean;
  28532. /**
  28533. * @hidden
  28534. */
  28535. _useSceneAutoClearSetup: boolean;
  28536. private _scene;
  28537. private _renderingGroups;
  28538. private _depthStencilBufferAlreadyCleaned;
  28539. private _autoClearDepthStencil;
  28540. private _customOpaqueSortCompareFn;
  28541. private _customAlphaTestSortCompareFn;
  28542. private _customTransparentSortCompareFn;
  28543. private _renderingGroupInfo;
  28544. /**
  28545. * Instantiates a new rendering group for a particular scene
  28546. * @param scene Defines the scene the groups belongs to
  28547. */
  28548. constructor(scene: Scene);
  28549. private _clearDepthStencilBuffer;
  28550. /**
  28551. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  28552. * @hidden
  28553. */
  28554. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  28555. /**
  28556. * Resets the different information of the group to prepare a new frame
  28557. * @hidden
  28558. */
  28559. reset(): void;
  28560. /**
  28561. * Dispose and release the group and its associated resources.
  28562. * @hidden
  28563. */
  28564. dispose(): void;
  28565. /**
  28566. * Clear the info related to rendering groups preventing retention points during dispose.
  28567. */
  28568. freeRenderingGroups(): void;
  28569. private _prepareRenderingGroup;
  28570. /**
  28571. * Add a sprite manager to the rendering manager in order to render it this frame.
  28572. * @param spriteManager Define the sprite manager to render
  28573. */
  28574. dispatchSprites(spriteManager: ISpriteManager): void;
  28575. /**
  28576. * Add a particle system to the rendering manager in order to render it this frame.
  28577. * @param particleSystem Define the particle system to render
  28578. */
  28579. dispatchParticles(particleSystem: IParticleSystem): void;
  28580. /**
  28581. * Add a submesh to the manager in order to render it this frame
  28582. * @param subMesh The submesh to dispatch
  28583. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  28584. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  28585. */
  28586. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  28587. /**
  28588. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  28589. * This allowed control for front to back rendering or reversly depending of the special needs.
  28590. *
  28591. * @param renderingGroupId The rendering group id corresponding to its index
  28592. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  28593. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  28594. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  28595. */
  28596. 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;
  28597. /**
  28598. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  28599. *
  28600. * @param renderingGroupId The rendering group id corresponding to its index
  28601. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  28602. * @param depth Automatically clears depth between groups if true and autoClear is true.
  28603. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  28604. */
  28605. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  28606. /**
  28607. * Gets the current auto clear configuration for one rendering group of the rendering
  28608. * manager.
  28609. * @param index the rendering group index to get the information for
  28610. * @returns The auto clear setup for the requested rendering group
  28611. */
  28612. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  28613. }
  28614. }
  28615. declare module BABYLON {
  28616. /**
  28617. * Defines the options associated with the creation of a custom shader for a shadow generator.
  28618. */
  28619. export interface ICustomShaderOptions {
  28620. /**
  28621. * Gets or sets the custom shader name to use
  28622. */
  28623. shaderName: string;
  28624. /**
  28625. * The list of attribute names used in the shader
  28626. */
  28627. attributes?: string[];
  28628. /**
  28629. * The list of unifrom names used in the shader
  28630. */
  28631. uniforms?: string[];
  28632. /**
  28633. * The list of sampler names used in the shader
  28634. */
  28635. samplers?: string[];
  28636. /**
  28637. * The list of defines used in the shader
  28638. */
  28639. defines?: string[];
  28640. }
  28641. /**
  28642. * Interface to implement to create a shadow generator compatible with BJS.
  28643. */
  28644. export interface IShadowGenerator {
  28645. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  28646. id: string;
  28647. /**
  28648. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  28649. * @returns The render target texture if present otherwise, null
  28650. */
  28651. getShadowMap(): Nullable<RenderTargetTexture>;
  28652. /**
  28653. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  28654. * @param subMesh The submesh we want to render in the shadow map
  28655. * @param useInstances Defines wether will draw in the map using instances
  28656. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  28657. * @returns true if ready otherwise, false
  28658. */
  28659. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  28660. /**
  28661. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  28662. * @param defines Defines of the material we want to update
  28663. * @param lightIndex Index of the light in the enabled light list of the material
  28664. */
  28665. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  28666. /**
  28667. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  28668. * defined in the generator but impacting the effect).
  28669. * It implies the unifroms available on the materials are the standard BJS ones.
  28670. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  28671. * @param effect The effect we are binfing the information for
  28672. */
  28673. bindShadowLight(lightIndex: string, effect: Effect): void;
  28674. /**
  28675. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  28676. * (eq to shadow prjection matrix * light transform matrix)
  28677. * @returns The transform matrix used to create the shadow map
  28678. */
  28679. getTransformMatrix(): Matrix;
  28680. /**
  28681. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  28682. * Cube and 2D textures for instance.
  28683. */
  28684. recreateShadowMap(): void;
  28685. /**
  28686. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  28687. * @param onCompiled Callback triggered at the and of the effects compilation
  28688. * @param options Sets of optional options forcing the compilation with different modes
  28689. */
  28690. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  28691. useInstances: boolean;
  28692. }>): void;
  28693. /**
  28694. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  28695. * @param options Sets of optional options forcing the compilation with different modes
  28696. * @returns A promise that resolves when the compilation completes
  28697. */
  28698. forceCompilationAsync(options?: Partial<{
  28699. useInstances: boolean;
  28700. }>): Promise<void>;
  28701. /**
  28702. * Serializes the shadow generator setup to a json object.
  28703. * @returns The serialized JSON object
  28704. */
  28705. serialize(): any;
  28706. /**
  28707. * Disposes the Shadow map and related Textures and effects.
  28708. */
  28709. dispose(): void;
  28710. }
  28711. /**
  28712. * Default implementation IShadowGenerator.
  28713. * This is the main object responsible of generating shadows in the framework.
  28714. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  28715. */
  28716. export class ShadowGenerator implements IShadowGenerator {
  28717. /**
  28718. * Name of the shadow generator class
  28719. */
  28720. static CLASSNAME: string;
  28721. /**
  28722. * Shadow generator mode None: no filtering applied.
  28723. */
  28724. static readonly FILTER_NONE: number;
  28725. /**
  28726. * Shadow generator mode ESM: Exponential Shadow Mapping.
  28727. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  28728. */
  28729. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  28730. /**
  28731. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  28732. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  28733. */
  28734. static readonly FILTER_POISSONSAMPLING: number;
  28735. /**
  28736. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  28737. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  28738. */
  28739. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  28740. /**
  28741. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  28742. * edge artifacts on steep falloff.
  28743. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  28744. */
  28745. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  28746. /**
  28747. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  28748. * edge artifacts on steep falloff.
  28749. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  28750. */
  28751. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  28752. /**
  28753. * Shadow generator mode PCF: Percentage Closer Filtering
  28754. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  28755. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  28756. */
  28757. static readonly FILTER_PCF: number;
  28758. /**
  28759. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  28760. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  28761. * Contact Hardening
  28762. */
  28763. static readonly FILTER_PCSS: number;
  28764. /**
  28765. * Reserved for PCF and PCSS
  28766. * Highest Quality.
  28767. *
  28768. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  28769. *
  28770. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  28771. */
  28772. static readonly QUALITY_HIGH: number;
  28773. /**
  28774. * Reserved for PCF and PCSS
  28775. * Good tradeoff for quality/perf cross devices
  28776. *
  28777. * Execute PCF on a 3*3 kernel.
  28778. *
  28779. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  28780. */
  28781. static readonly QUALITY_MEDIUM: number;
  28782. /**
  28783. * Reserved for PCF and PCSS
  28784. * The lowest quality but the fastest.
  28785. *
  28786. * Execute PCF on a 1*1 kernel.
  28787. *
  28788. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  28789. */
  28790. static readonly QUALITY_LOW: number;
  28791. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  28792. id: string;
  28793. /** Gets or sets the custom shader name to use */
  28794. customShaderOptions: ICustomShaderOptions;
  28795. /** Gets or sets a custom function to allow/disallow rendering a sub mesh in the shadow map */
  28796. customAllowRendering: (subMesh: SubMesh) => boolean;
  28797. /**
  28798. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  28799. */
  28800. onBeforeShadowMapRenderObservable: Observable<Effect>;
  28801. /**
  28802. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  28803. */
  28804. onAfterShadowMapRenderObservable: Observable<Effect>;
  28805. /**
  28806. * Observable triggered before a mesh is rendered in the shadow map.
  28807. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  28808. */
  28809. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  28810. /**
  28811. * Observable triggered after a mesh is rendered in the shadow map.
  28812. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  28813. */
  28814. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  28815. protected _bias: number;
  28816. /**
  28817. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  28818. */
  28819. get bias(): number;
  28820. /**
  28821. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  28822. */
  28823. set bias(bias: number);
  28824. protected _normalBias: number;
  28825. /**
  28826. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  28827. */
  28828. get normalBias(): number;
  28829. /**
  28830. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  28831. */
  28832. set normalBias(normalBias: number);
  28833. protected _blurBoxOffset: number;
  28834. /**
  28835. * Gets the blur box offset: offset applied during the blur pass.
  28836. * Only useful if useKernelBlur = false
  28837. */
  28838. get blurBoxOffset(): number;
  28839. /**
  28840. * Sets the blur box offset: offset applied during the blur pass.
  28841. * Only useful if useKernelBlur = false
  28842. */
  28843. set blurBoxOffset(value: number);
  28844. protected _blurScale: number;
  28845. /**
  28846. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  28847. * 2 means half of the size.
  28848. */
  28849. get blurScale(): number;
  28850. /**
  28851. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  28852. * 2 means half of the size.
  28853. */
  28854. set blurScale(value: number);
  28855. protected _blurKernel: number;
  28856. /**
  28857. * Gets the blur kernel: kernel size of the blur pass.
  28858. * Only useful if useKernelBlur = true
  28859. */
  28860. get blurKernel(): number;
  28861. /**
  28862. * Sets the blur kernel: kernel size of the blur pass.
  28863. * Only useful if useKernelBlur = true
  28864. */
  28865. set blurKernel(value: number);
  28866. protected _useKernelBlur: boolean;
  28867. /**
  28868. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  28869. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  28870. */
  28871. get useKernelBlur(): boolean;
  28872. /**
  28873. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  28874. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  28875. */
  28876. set useKernelBlur(value: boolean);
  28877. protected _depthScale: number;
  28878. /**
  28879. * Gets the depth scale used in ESM mode.
  28880. */
  28881. get depthScale(): number;
  28882. /**
  28883. * Sets the depth scale used in ESM mode.
  28884. * This can override the scale stored on the light.
  28885. */
  28886. set depthScale(value: number);
  28887. protected _validateFilter(filter: number): number;
  28888. protected _filter: number;
  28889. /**
  28890. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  28891. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  28892. */
  28893. get filter(): number;
  28894. /**
  28895. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  28896. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  28897. */
  28898. set filter(value: number);
  28899. /**
  28900. * Gets if the current filter is set to Poisson Sampling.
  28901. */
  28902. get usePoissonSampling(): boolean;
  28903. /**
  28904. * Sets the current filter to Poisson Sampling.
  28905. */
  28906. set usePoissonSampling(value: boolean);
  28907. /**
  28908. * Gets if the current filter is set to ESM.
  28909. */
  28910. get useExponentialShadowMap(): boolean;
  28911. /**
  28912. * Sets the current filter is to ESM.
  28913. */
  28914. set useExponentialShadowMap(value: boolean);
  28915. /**
  28916. * Gets if the current filter is set to filtered ESM.
  28917. */
  28918. get useBlurExponentialShadowMap(): boolean;
  28919. /**
  28920. * Gets if the current filter is set to filtered ESM.
  28921. */
  28922. set useBlurExponentialShadowMap(value: boolean);
  28923. /**
  28924. * Gets if the current filter is set to "close ESM" (using the inverse of the
  28925. * exponential to prevent steep falloff artifacts).
  28926. */
  28927. get useCloseExponentialShadowMap(): boolean;
  28928. /**
  28929. * Sets the current filter to "close ESM" (using the inverse of the
  28930. * exponential to prevent steep falloff artifacts).
  28931. */
  28932. set useCloseExponentialShadowMap(value: boolean);
  28933. /**
  28934. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  28935. * exponential to prevent steep falloff artifacts).
  28936. */
  28937. get useBlurCloseExponentialShadowMap(): boolean;
  28938. /**
  28939. * Sets the current filter to filtered "close ESM" (using the inverse of the
  28940. * exponential to prevent steep falloff artifacts).
  28941. */
  28942. set useBlurCloseExponentialShadowMap(value: boolean);
  28943. /**
  28944. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  28945. */
  28946. get usePercentageCloserFiltering(): boolean;
  28947. /**
  28948. * Sets the current filter to "PCF" (percentage closer filtering).
  28949. */
  28950. set usePercentageCloserFiltering(value: boolean);
  28951. protected _filteringQuality: number;
  28952. /**
  28953. * Gets the PCF or PCSS Quality.
  28954. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  28955. */
  28956. get filteringQuality(): number;
  28957. /**
  28958. * Sets the PCF or PCSS Quality.
  28959. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  28960. */
  28961. set filteringQuality(filteringQuality: number);
  28962. /**
  28963. * Gets if the current filter is set to "PCSS" (contact hardening).
  28964. */
  28965. get useContactHardeningShadow(): boolean;
  28966. /**
  28967. * Sets the current filter to "PCSS" (contact hardening).
  28968. */
  28969. set useContactHardeningShadow(value: boolean);
  28970. protected _contactHardeningLightSizeUVRatio: number;
  28971. /**
  28972. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  28973. * Using a ratio helps keeping shape stability independently of the map size.
  28974. *
  28975. * It does not account for the light projection as it was having too much
  28976. * instability during the light setup or during light position changes.
  28977. *
  28978. * Only valid if useContactHardeningShadow is true.
  28979. */
  28980. get contactHardeningLightSizeUVRatio(): number;
  28981. /**
  28982. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  28983. * Using a ratio helps keeping shape stability independently of the map size.
  28984. *
  28985. * It does not account for the light projection as it was having too much
  28986. * instability during the light setup or during light position changes.
  28987. *
  28988. * Only valid if useContactHardeningShadow is true.
  28989. */
  28990. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  28991. protected _darkness: number;
  28992. /** Gets or sets the actual darkness of a shadow */
  28993. get darkness(): number;
  28994. set darkness(value: number);
  28995. /**
  28996. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  28997. * 0 means strongest and 1 would means no shadow.
  28998. * @returns the darkness.
  28999. */
  29000. getDarkness(): number;
  29001. /**
  29002. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  29003. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  29004. * @returns the shadow generator allowing fluent coding.
  29005. */
  29006. setDarkness(darkness: number): ShadowGenerator;
  29007. protected _transparencyShadow: boolean;
  29008. /** Gets or sets the ability to have transparent shadow */
  29009. get transparencyShadow(): boolean;
  29010. set transparencyShadow(value: boolean);
  29011. /**
  29012. * Sets the ability to have transparent shadow (boolean).
  29013. * @param transparent True if transparent else False
  29014. * @returns the shadow generator allowing fluent coding
  29015. */
  29016. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  29017. /**
  29018. * Enables or disables shadows with varying strength based on the transparency
  29019. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  29020. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  29021. * mesh.visibility * alphaTexture.a
  29022. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  29023. */
  29024. enableSoftTransparentShadow: boolean;
  29025. protected _shadowMap: Nullable<RenderTargetTexture>;
  29026. protected _shadowMap2: Nullable<RenderTargetTexture>;
  29027. /**
  29028. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  29029. * @returns The render target texture if present otherwise, null
  29030. */
  29031. getShadowMap(): Nullable<RenderTargetTexture>;
  29032. /**
  29033. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  29034. * @returns The render target texture if the shadow map is present otherwise, null
  29035. */
  29036. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  29037. /**
  29038. * Gets the class name of that object
  29039. * @returns "ShadowGenerator"
  29040. */
  29041. getClassName(): string;
  29042. /**
  29043. * Helper function to add a mesh and its descendants to the list of shadow casters.
  29044. * @param mesh Mesh to add
  29045. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  29046. * @returns the Shadow Generator itself
  29047. */
  29048. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  29049. /**
  29050. * Helper function to remove a mesh and its descendants from the list of shadow casters
  29051. * @param mesh Mesh to remove
  29052. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  29053. * @returns the Shadow Generator itself
  29054. */
  29055. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  29056. /**
  29057. * Controls the extent to which the shadows fade out at the edge of the frustum
  29058. */
  29059. frustumEdgeFalloff: number;
  29060. protected _light: IShadowLight;
  29061. /**
  29062. * Returns the associated light object.
  29063. * @returns the light generating the shadow
  29064. */
  29065. getLight(): IShadowLight;
  29066. /**
  29067. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  29068. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  29069. * It might on the other hand introduce peter panning.
  29070. */
  29071. forceBackFacesOnly: boolean;
  29072. protected _scene: Scene;
  29073. protected _lightDirection: Vector3;
  29074. protected _effect: Effect;
  29075. protected _viewMatrix: Matrix;
  29076. protected _projectionMatrix: Matrix;
  29077. protected _transformMatrix: Matrix;
  29078. protected _cachedPosition: Vector3;
  29079. protected _cachedDirection: Vector3;
  29080. protected _cachedDefines: string;
  29081. protected _currentRenderID: number;
  29082. protected _boxBlurPostprocess: Nullable<PostProcess>;
  29083. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  29084. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  29085. protected _blurPostProcesses: PostProcess[];
  29086. protected _mapSize: number;
  29087. protected _currentFaceIndex: number;
  29088. protected _currentFaceIndexCache: number;
  29089. protected _textureType: number;
  29090. protected _defaultTextureMatrix: Matrix;
  29091. protected _storedUniqueId: Nullable<number>;
  29092. /** @hidden */
  29093. static _SceneComponentInitialization: (scene: Scene) => void;
  29094. /**
  29095. * Gets or sets the size of the texture what stores the shadows
  29096. */
  29097. get mapSize(): number;
  29098. set mapSize(size: number);
  29099. /**
  29100. * Creates a ShadowGenerator object.
  29101. * A ShadowGenerator is the required tool to use the shadows.
  29102. * Each light casting shadows needs to use its own ShadowGenerator.
  29103. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  29104. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  29105. * @param light The light object generating the shadows.
  29106. * @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.
  29107. */
  29108. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  29109. protected _initializeGenerator(): void;
  29110. protected _createTargetRenderTexture(): void;
  29111. protected _initializeShadowMap(): void;
  29112. protected _initializeBlurRTTAndPostProcesses(): void;
  29113. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  29114. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  29115. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  29116. protected _applyFilterValues(): void;
  29117. /**
  29118. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  29119. * @param onCompiled Callback triggered at the and of the effects compilation
  29120. * @param options Sets of optional options forcing the compilation with different modes
  29121. */
  29122. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  29123. useInstances: boolean;
  29124. }>): void;
  29125. /**
  29126. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  29127. * @param options Sets of optional options forcing the compilation with different modes
  29128. * @returns A promise that resolves when the compilation completes
  29129. */
  29130. forceCompilationAsync(options?: Partial<{
  29131. useInstances: boolean;
  29132. }>): Promise<void>;
  29133. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  29134. private _prepareShadowDefines;
  29135. /**
  29136. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  29137. * @param subMesh The submesh we want to render in the shadow map
  29138. * @param useInstances Defines wether will draw in the map using instances
  29139. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  29140. * @returns true if ready otherwise, false
  29141. */
  29142. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  29143. /**
  29144. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  29145. * @param defines Defines of the material we want to update
  29146. * @param lightIndex Index of the light in the enabled light list of the material
  29147. */
  29148. prepareDefines(defines: any, lightIndex: number): void;
  29149. /**
  29150. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  29151. * defined in the generator but impacting the effect).
  29152. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  29153. * @param effect The effect we are binfing the information for
  29154. */
  29155. bindShadowLight(lightIndex: string, effect: Effect): void;
  29156. /**
  29157. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  29158. * (eq to shadow prjection matrix * light transform matrix)
  29159. * @returns The transform matrix used to create the shadow map
  29160. */
  29161. getTransformMatrix(): Matrix;
  29162. /**
  29163. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  29164. * Cube and 2D textures for instance.
  29165. */
  29166. recreateShadowMap(): void;
  29167. protected _disposeBlurPostProcesses(): void;
  29168. protected _disposeRTTandPostProcesses(): void;
  29169. /**
  29170. * Disposes the ShadowGenerator.
  29171. * Returns nothing.
  29172. */
  29173. dispose(): void;
  29174. /**
  29175. * Serializes the shadow generator setup to a json object.
  29176. * @returns The serialized JSON object
  29177. */
  29178. serialize(): any;
  29179. /**
  29180. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  29181. * @param parsedShadowGenerator The JSON object to parse
  29182. * @param scene The scene to create the shadow map for
  29183. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  29184. * @returns The parsed shadow generator
  29185. */
  29186. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  29187. }
  29188. }
  29189. declare module BABYLON {
  29190. /**
  29191. * Options to be used when creating a shadow depth material
  29192. */
  29193. export interface IIOptionShadowDepthMaterial {
  29194. /** Variables in the vertex shader code that need to have their names remapped.
  29195. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  29196. * "var_name" should be either: worldPos or vNormalW
  29197. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  29198. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  29199. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  29200. */
  29201. remappedVariables?: string[];
  29202. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  29203. standalone?: boolean;
  29204. }
  29205. /**
  29206. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  29207. */
  29208. export class ShadowDepthWrapper {
  29209. private _scene;
  29210. private _options?;
  29211. private _baseMaterial;
  29212. private _onEffectCreatedObserver;
  29213. private _subMeshToEffect;
  29214. private _subMeshToDepthEffect;
  29215. private _meshes;
  29216. /** @hidden */
  29217. _matriceNames: any;
  29218. /** Gets the standalone status of the wrapper */
  29219. get standalone(): boolean;
  29220. /** Gets the base material the wrapper is built upon */
  29221. get baseMaterial(): Material;
  29222. /**
  29223. * Instantiate a new shadow depth wrapper.
  29224. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  29225. * generate the shadow depth map. For more information, please refer to the documentation:
  29226. * https://doc.babylonjs.com/babylon101/shadows
  29227. * @param baseMaterial Material to wrap
  29228. * @param scene Define the scene the material belongs to
  29229. * @param options Options used to create the wrapper
  29230. */
  29231. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  29232. /**
  29233. * Gets the effect to use to generate the depth map
  29234. * @param subMesh subMesh to get the effect for
  29235. * @param shadowGenerator shadow generator to get the effect for
  29236. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  29237. */
  29238. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  29239. /**
  29240. * Specifies that the submesh is ready to be used for depth rendering
  29241. * @param subMesh submesh to check
  29242. * @param defines the list of defines to take into account when checking the effect
  29243. * @param shadowGenerator combined with subMesh, it defines the effect to check
  29244. * @param useInstances specifies that instances should be used
  29245. * @returns a boolean indicating that the submesh is ready or not
  29246. */
  29247. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  29248. /**
  29249. * Disposes the resources
  29250. */
  29251. dispose(): void;
  29252. private _makeEffect;
  29253. }
  29254. }
  29255. declare module BABYLON {
  29256. /**
  29257. * Options for compiling materials.
  29258. */
  29259. export interface IMaterialCompilationOptions {
  29260. /**
  29261. * Defines whether clip planes are enabled.
  29262. */
  29263. clipPlane: boolean;
  29264. /**
  29265. * Defines whether instances are enabled.
  29266. */
  29267. useInstances: boolean;
  29268. }
  29269. /**
  29270. * Options passed when calling customShaderNameResolve
  29271. */
  29272. export interface ICustomShaderNameResolveOptions {
  29273. /**
  29274. * 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
  29275. */
  29276. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  29277. }
  29278. /**
  29279. * Base class for the main features of a material in Babylon.js
  29280. */
  29281. export class Material implements IAnimatable {
  29282. /**
  29283. * Returns the triangle fill mode
  29284. */
  29285. static readonly TriangleFillMode: number;
  29286. /**
  29287. * Returns the wireframe mode
  29288. */
  29289. static readonly WireFrameFillMode: number;
  29290. /**
  29291. * Returns the point fill mode
  29292. */
  29293. static readonly PointFillMode: number;
  29294. /**
  29295. * Returns the point list draw mode
  29296. */
  29297. static readonly PointListDrawMode: number;
  29298. /**
  29299. * Returns the line list draw mode
  29300. */
  29301. static readonly LineListDrawMode: number;
  29302. /**
  29303. * Returns the line loop draw mode
  29304. */
  29305. static readonly LineLoopDrawMode: number;
  29306. /**
  29307. * Returns the line strip draw mode
  29308. */
  29309. static readonly LineStripDrawMode: number;
  29310. /**
  29311. * Returns the triangle strip draw mode
  29312. */
  29313. static readonly TriangleStripDrawMode: number;
  29314. /**
  29315. * Returns the triangle fan draw mode
  29316. */
  29317. static readonly TriangleFanDrawMode: number;
  29318. /**
  29319. * Stores the clock-wise side orientation
  29320. */
  29321. static readonly ClockWiseSideOrientation: number;
  29322. /**
  29323. * Stores the counter clock-wise side orientation
  29324. */
  29325. static readonly CounterClockWiseSideOrientation: number;
  29326. /**
  29327. * The dirty texture flag value
  29328. */
  29329. static readonly TextureDirtyFlag: number;
  29330. /**
  29331. * The dirty light flag value
  29332. */
  29333. static readonly LightDirtyFlag: number;
  29334. /**
  29335. * The dirty fresnel flag value
  29336. */
  29337. static readonly FresnelDirtyFlag: number;
  29338. /**
  29339. * The dirty attribute flag value
  29340. */
  29341. static readonly AttributesDirtyFlag: number;
  29342. /**
  29343. * The dirty misc flag value
  29344. */
  29345. static readonly MiscDirtyFlag: number;
  29346. /**
  29347. * The dirty prepass flag value
  29348. */
  29349. static readonly PrePassDirtyFlag: number;
  29350. /**
  29351. * The all dirty flag value
  29352. */
  29353. static readonly AllDirtyFlag: number;
  29354. /**
  29355. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  29356. */
  29357. static readonly MATERIAL_OPAQUE: number;
  29358. /**
  29359. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  29360. */
  29361. static readonly MATERIAL_ALPHATEST: number;
  29362. /**
  29363. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  29364. */
  29365. static readonly MATERIAL_ALPHABLEND: number;
  29366. /**
  29367. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  29368. * They are also discarded below the alpha cutoff threshold to improve performances.
  29369. */
  29370. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  29371. /**
  29372. * The Whiteout method is used to blend normals.
  29373. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  29374. */
  29375. static readonly MATERIAL_NORMALBLENDMETHOD_WHITEOUT: number;
  29376. /**
  29377. * The Reoriented Normal Mapping method is used to blend normals.
  29378. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  29379. */
  29380. static readonly MATERIAL_NORMALBLENDMETHOD_RNM: number;
  29381. /**
  29382. * Custom callback helping to override the default shader used in the material.
  29383. */
  29384. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  29385. /**
  29386. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  29387. */
  29388. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  29389. /**
  29390. * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
  29391. * This means that the material can keep using a previous shader while a new one is being compiled.
  29392. * This is mostly used when shader parallel compilation is supported (true by default)
  29393. */
  29394. allowShaderHotSwapping: boolean;
  29395. /**
  29396. * The ID of the material
  29397. */
  29398. id: string;
  29399. /**
  29400. * Gets or sets the unique id of the material
  29401. */
  29402. uniqueId: number;
  29403. /**
  29404. * The name of the material
  29405. */
  29406. name: string;
  29407. /**
  29408. * Gets or sets user defined metadata
  29409. */
  29410. metadata: any;
  29411. /**
  29412. * For internal use only. Please do not use.
  29413. */
  29414. reservedDataStore: any;
  29415. /**
  29416. * Specifies if the ready state should be checked on each call
  29417. */
  29418. checkReadyOnEveryCall: boolean;
  29419. /**
  29420. * Specifies if the ready state should be checked once
  29421. */
  29422. checkReadyOnlyOnce: boolean;
  29423. /**
  29424. * The state of the material
  29425. */
  29426. state: string;
  29427. /**
  29428. * If the material can be rendered to several textures with MRT extension
  29429. */
  29430. get canRenderToMRT(): boolean;
  29431. /**
  29432. * The alpha value of the material
  29433. */
  29434. protected _alpha: number;
  29435. /**
  29436. * List of inspectable custom properties (used by the Inspector)
  29437. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  29438. */
  29439. inspectableCustomProperties: IInspectable[];
  29440. /**
  29441. * Sets the alpha value of the material
  29442. */
  29443. set alpha(value: number);
  29444. /**
  29445. * Gets the alpha value of the material
  29446. */
  29447. get alpha(): number;
  29448. /**
  29449. * Specifies if back face culling is enabled
  29450. */
  29451. protected _backFaceCulling: boolean;
  29452. /**
  29453. * Sets the back-face culling state
  29454. */
  29455. set backFaceCulling(value: boolean);
  29456. /**
  29457. * Gets the back-face culling state
  29458. */
  29459. get backFaceCulling(): boolean;
  29460. /**
  29461. * Stores the value for side orientation
  29462. */
  29463. sideOrientation: number;
  29464. /**
  29465. * Callback triggered when the material is compiled
  29466. */
  29467. onCompiled: Nullable<(effect: Effect) => void>;
  29468. /**
  29469. * Callback triggered when an error occurs
  29470. */
  29471. onError: Nullable<(effect: Effect, errors: string) => void>;
  29472. /**
  29473. * Callback triggered to get the render target textures
  29474. */
  29475. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  29476. /**
  29477. * Gets a boolean indicating that current material needs to register RTT
  29478. */
  29479. get hasRenderTargetTextures(): boolean;
  29480. /**
  29481. * Specifies if the material should be serialized
  29482. */
  29483. doNotSerialize: boolean;
  29484. /**
  29485. * @hidden
  29486. */
  29487. _storeEffectOnSubMeshes: boolean;
  29488. /**
  29489. * Stores the animations for the material
  29490. */
  29491. animations: Nullable<Array<Animation>>;
  29492. /**
  29493. * An event triggered when the material is disposed
  29494. */
  29495. onDisposeObservable: Observable<Material>;
  29496. /**
  29497. * An observer which watches for dispose events
  29498. */
  29499. private _onDisposeObserver;
  29500. private _onUnBindObservable;
  29501. /**
  29502. * Called during a dispose event
  29503. */
  29504. set onDispose(callback: () => void);
  29505. private _onBindObservable;
  29506. /**
  29507. * An event triggered when the material is bound
  29508. */
  29509. get onBindObservable(): Observable<AbstractMesh>;
  29510. /**
  29511. * An observer which watches for bind events
  29512. */
  29513. private _onBindObserver;
  29514. /**
  29515. * Called during a bind event
  29516. */
  29517. set onBind(callback: (Mesh: AbstractMesh) => void);
  29518. /**
  29519. * An event triggered when the material is unbound
  29520. */
  29521. get onUnBindObservable(): Observable<Material>;
  29522. protected _onEffectCreatedObservable: Nullable<Observable<{
  29523. effect: Effect;
  29524. subMesh: Nullable<SubMesh>;
  29525. }>>;
  29526. /**
  29527. * An event triggered when the effect is (re)created
  29528. */
  29529. get onEffectCreatedObservable(): Observable<{
  29530. effect: Effect;
  29531. subMesh: Nullable<SubMesh>;
  29532. }>;
  29533. /**
  29534. * Stores the value of the alpha mode
  29535. */
  29536. private _alphaMode;
  29537. /**
  29538. * Sets the value of the alpha mode.
  29539. *
  29540. * | Value | Type | Description |
  29541. * | --- | --- | --- |
  29542. * | 0 | ALPHA_DISABLE | |
  29543. * | 1 | ALPHA_ADD | |
  29544. * | 2 | ALPHA_COMBINE | |
  29545. * | 3 | ALPHA_SUBTRACT | |
  29546. * | 4 | ALPHA_MULTIPLY | |
  29547. * | 5 | ALPHA_MAXIMIZED | |
  29548. * | 6 | ALPHA_ONEONE | |
  29549. * | 7 | ALPHA_PREMULTIPLIED | |
  29550. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  29551. * | 9 | ALPHA_INTERPOLATE | |
  29552. * | 10 | ALPHA_SCREENMODE | |
  29553. *
  29554. */
  29555. set alphaMode(value: number);
  29556. /**
  29557. * Gets the value of the alpha mode
  29558. */
  29559. get alphaMode(): number;
  29560. /**
  29561. * Stores the state of the need depth pre-pass value
  29562. */
  29563. private _needDepthPrePass;
  29564. /**
  29565. * Sets the need depth pre-pass value
  29566. */
  29567. set needDepthPrePass(value: boolean);
  29568. /**
  29569. * Gets the depth pre-pass value
  29570. */
  29571. get needDepthPrePass(): boolean;
  29572. /**
  29573. * Specifies if depth writing should be disabled
  29574. */
  29575. disableDepthWrite: boolean;
  29576. /**
  29577. * Specifies if color writing should be disabled
  29578. */
  29579. disableColorWrite: boolean;
  29580. /**
  29581. * Specifies if depth writing should be forced
  29582. */
  29583. forceDepthWrite: boolean;
  29584. /**
  29585. * Specifies the depth function that should be used. 0 means the default engine function
  29586. */
  29587. depthFunction: number;
  29588. /**
  29589. * Specifies if there should be a separate pass for culling
  29590. */
  29591. separateCullingPass: boolean;
  29592. /**
  29593. * Stores the state specifing if fog should be enabled
  29594. */
  29595. private _fogEnabled;
  29596. /**
  29597. * Sets the state for enabling fog
  29598. */
  29599. set fogEnabled(value: boolean);
  29600. /**
  29601. * Gets the value of the fog enabled state
  29602. */
  29603. get fogEnabled(): boolean;
  29604. /**
  29605. * Stores the size of points
  29606. */
  29607. pointSize: number;
  29608. /**
  29609. * Stores the z offset value
  29610. */
  29611. zOffset: number;
  29612. get wireframe(): boolean;
  29613. /**
  29614. * Sets the state of wireframe mode
  29615. */
  29616. set wireframe(value: boolean);
  29617. /**
  29618. * Gets the value specifying if point clouds are enabled
  29619. */
  29620. get pointsCloud(): boolean;
  29621. /**
  29622. * Sets the state of point cloud mode
  29623. */
  29624. set pointsCloud(value: boolean);
  29625. /**
  29626. * Gets the material fill mode
  29627. */
  29628. get fillMode(): number;
  29629. /**
  29630. * Sets the material fill mode
  29631. */
  29632. set fillMode(value: number);
  29633. /**
  29634. * @hidden
  29635. * Stores the effects for the material
  29636. */
  29637. _effect: Nullable<Effect>;
  29638. /**
  29639. * Specifies if uniform buffers should be used
  29640. */
  29641. private _useUBO;
  29642. /**
  29643. * Stores a reference to the scene
  29644. */
  29645. private _scene;
  29646. /**
  29647. * Stores the fill mode state
  29648. */
  29649. private _fillMode;
  29650. /**
  29651. * Specifies if the depth write state should be cached
  29652. */
  29653. private _cachedDepthWriteState;
  29654. /**
  29655. * Specifies if the color write state should be cached
  29656. */
  29657. private _cachedColorWriteState;
  29658. /**
  29659. * Specifies if the depth function state should be cached
  29660. */
  29661. private _cachedDepthFunctionState;
  29662. /**
  29663. * Stores the uniform buffer
  29664. */
  29665. protected _uniformBuffer: UniformBuffer;
  29666. /** @hidden */
  29667. _indexInSceneMaterialArray: number;
  29668. /** @hidden */
  29669. meshMap: Nullable<{
  29670. [id: string]: AbstractMesh | undefined;
  29671. }>;
  29672. /**
  29673. * Creates a material instance
  29674. * @param name defines the name of the material
  29675. * @param scene defines the scene to reference
  29676. * @param doNotAdd specifies if the material should be added to the scene
  29677. */
  29678. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  29679. /**
  29680. * Returns a string representation of the current material
  29681. * @param fullDetails defines a boolean indicating which levels of logging is desired
  29682. * @returns a string with material information
  29683. */
  29684. toString(fullDetails?: boolean): string;
  29685. /**
  29686. * Gets the class name of the material
  29687. * @returns a string with the class name of the material
  29688. */
  29689. getClassName(): string;
  29690. /**
  29691. * Specifies if updates for the material been locked
  29692. */
  29693. get isFrozen(): boolean;
  29694. /**
  29695. * Locks updates for the material
  29696. */
  29697. freeze(): void;
  29698. /**
  29699. * Unlocks updates for the material
  29700. */
  29701. unfreeze(): void;
  29702. /**
  29703. * Specifies if the material is ready to be used
  29704. * @param mesh defines the mesh to check
  29705. * @param useInstances specifies if instances should be used
  29706. * @returns a boolean indicating if the material is ready to be used
  29707. */
  29708. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  29709. /**
  29710. * Specifies that the submesh is ready to be used
  29711. * @param mesh defines the mesh to check
  29712. * @param subMesh defines which submesh to check
  29713. * @param useInstances specifies that instances should be used
  29714. * @returns a boolean indicating that the submesh is ready or not
  29715. */
  29716. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  29717. /**
  29718. * Returns the material effect
  29719. * @returns the effect associated with the material
  29720. */
  29721. getEffect(): Nullable<Effect>;
  29722. /**
  29723. * Returns the current scene
  29724. * @returns a Scene
  29725. */
  29726. getScene(): Scene;
  29727. /**
  29728. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  29729. */
  29730. protected _forceAlphaTest: boolean;
  29731. /**
  29732. * The transparency mode of the material.
  29733. */
  29734. protected _transparencyMode: Nullable<number>;
  29735. /**
  29736. * Gets the current transparency mode.
  29737. */
  29738. get transparencyMode(): Nullable<number>;
  29739. /**
  29740. * Sets the transparency mode of the material.
  29741. *
  29742. * | Value | Type | Description |
  29743. * | ----- | ----------------------------------- | ----------- |
  29744. * | 0 | OPAQUE | |
  29745. * | 1 | ALPHATEST | |
  29746. * | 2 | ALPHABLEND | |
  29747. * | 3 | ALPHATESTANDBLEND | |
  29748. *
  29749. */
  29750. set transparencyMode(value: Nullable<number>);
  29751. /**
  29752. * Returns true if alpha blending should be disabled.
  29753. */
  29754. protected get _disableAlphaBlending(): boolean;
  29755. /**
  29756. * Specifies whether or not this material should be rendered in alpha blend mode.
  29757. * @returns a boolean specifying if alpha blending is needed
  29758. */
  29759. needAlphaBlending(): boolean;
  29760. /**
  29761. * Specifies if the mesh will require alpha blending
  29762. * @param mesh defines the mesh to check
  29763. * @returns a boolean specifying if alpha blending is needed for the mesh
  29764. */
  29765. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  29766. /**
  29767. * Specifies whether or not this material should be rendered in alpha test mode.
  29768. * @returns a boolean specifying if an alpha test is needed.
  29769. */
  29770. needAlphaTesting(): boolean;
  29771. /**
  29772. * Specifies if material alpha testing should be turned on for the mesh
  29773. * @param mesh defines the mesh to check
  29774. */
  29775. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  29776. /**
  29777. * Gets the texture used for the alpha test
  29778. * @returns the texture to use for alpha testing
  29779. */
  29780. getAlphaTestTexture(): Nullable<BaseTexture>;
  29781. /**
  29782. * Marks the material to indicate that it needs to be re-calculated
  29783. */
  29784. markDirty(): void;
  29785. /** @hidden */
  29786. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  29787. /**
  29788. * Binds the material to the mesh
  29789. * @param world defines the world transformation matrix
  29790. * @param mesh defines the mesh to bind the material to
  29791. */
  29792. bind(world: Matrix, mesh?: Mesh): void;
  29793. /**
  29794. * Binds the submesh to the material
  29795. * @param world defines the world transformation matrix
  29796. * @param mesh defines the mesh containing the submesh
  29797. * @param subMesh defines the submesh to bind the material to
  29798. */
  29799. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  29800. /**
  29801. * Binds the world matrix to the material
  29802. * @param world defines the world transformation matrix
  29803. */
  29804. bindOnlyWorldMatrix(world: Matrix): void;
  29805. /**
  29806. * Binds the scene's uniform buffer to the effect.
  29807. * @param effect defines the effect to bind to the scene uniform buffer
  29808. * @param sceneUbo defines the uniform buffer storing scene data
  29809. */
  29810. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  29811. /**
  29812. * Binds the view matrix to the effect
  29813. * @param effect defines the effect to bind the view matrix to
  29814. */
  29815. bindView(effect: Effect): void;
  29816. /**
  29817. * Binds the view projection matrix to the effect
  29818. * @param effect defines the effect to bind the view projection matrix to
  29819. */
  29820. bindViewProjection(effect: Effect): void;
  29821. /**
  29822. * Processes to execute after binding the material to a mesh
  29823. * @param mesh defines the rendered mesh
  29824. */
  29825. protected _afterBind(mesh?: Mesh): void;
  29826. /**
  29827. * Unbinds the material from the mesh
  29828. */
  29829. unbind(): void;
  29830. /**
  29831. * Gets the active textures from the material
  29832. * @returns an array of textures
  29833. */
  29834. getActiveTextures(): BaseTexture[];
  29835. /**
  29836. * Specifies if the material uses a texture
  29837. * @param texture defines the texture to check against the material
  29838. * @returns a boolean specifying if the material uses the texture
  29839. */
  29840. hasTexture(texture: BaseTexture): boolean;
  29841. /**
  29842. * Makes a duplicate of the material, and gives it a new name
  29843. * @param name defines the new name for the duplicated material
  29844. * @returns the cloned material
  29845. */
  29846. clone(name: string): Nullable<Material>;
  29847. /**
  29848. * Gets the meshes bound to the material
  29849. * @returns an array of meshes bound to the material
  29850. */
  29851. getBindedMeshes(): AbstractMesh[];
  29852. /**
  29853. * Force shader compilation
  29854. * @param mesh defines the mesh associated with this material
  29855. * @param onCompiled defines a function to execute once the material is compiled
  29856. * @param options defines the options to configure the compilation
  29857. * @param onError defines a function to execute if the material fails compiling
  29858. */
  29859. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  29860. /**
  29861. * Force shader compilation
  29862. * @param mesh defines the mesh that will use this material
  29863. * @param options defines additional options for compiling the shaders
  29864. * @returns a promise that resolves when the compilation completes
  29865. */
  29866. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  29867. private static readonly _AllDirtyCallBack;
  29868. private static readonly _ImageProcessingDirtyCallBack;
  29869. private static readonly _TextureDirtyCallBack;
  29870. private static readonly _FresnelDirtyCallBack;
  29871. private static readonly _MiscDirtyCallBack;
  29872. private static readonly _PrePassDirtyCallBack;
  29873. private static readonly _LightsDirtyCallBack;
  29874. private static readonly _AttributeDirtyCallBack;
  29875. private static _FresnelAndMiscDirtyCallBack;
  29876. private static _TextureAndMiscDirtyCallBack;
  29877. private static readonly _DirtyCallbackArray;
  29878. private static readonly _RunDirtyCallBacks;
  29879. /**
  29880. * Marks a define in the material to indicate that it needs to be re-computed
  29881. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  29882. */
  29883. markAsDirty(flag: number): void;
  29884. /**
  29885. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  29886. * @param func defines a function which checks material defines against the submeshes
  29887. */
  29888. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  29889. /**
  29890. * Indicates that the scene should check if the rendering now needs a prepass
  29891. */
  29892. protected _markScenePrePassDirty(): void;
  29893. /**
  29894. * Indicates that we need to re-calculated for all submeshes
  29895. */
  29896. protected _markAllSubMeshesAsAllDirty(): void;
  29897. /**
  29898. * Indicates that image processing needs to be re-calculated for all submeshes
  29899. */
  29900. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  29901. /**
  29902. * Indicates that textures need to be re-calculated for all submeshes
  29903. */
  29904. protected _markAllSubMeshesAsTexturesDirty(): void;
  29905. /**
  29906. * Indicates that fresnel needs to be re-calculated for all submeshes
  29907. */
  29908. protected _markAllSubMeshesAsFresnelDirty(): void;
  29909. /**
  29910. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  29911. */
  29912. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  29913. /**
  29914. * Indicates that lights need to be re-calculated for all submeshes
  29915. */
  29916. protected _markAllSubMeshesAsLightsDirty(): void;
  29917. /**
  29918. * Indicates that attributes need to be re-calculated for all submeshes
  29919. */
  29920. protected _markAllSubMeshesAsAttributesDirty(): void;
  29921. /**
  29922. * Indicates that misc needs to be re-calculated for all submeshes
  29923. */
  29924. protected _markAllSubMeshesAsMiscDirty(): void;
  29925. /**
  29926. * Indicates that prepass needs to be re-calculated for all submeshes
  29927. */
  29928. protected _markAllSubMeshesAsPrePassDirty(): void;
  29929. /**
  29930. * Indicates that textures and misc need to be re-calculated for all submeshes
  29931. */
  29932. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  29933. /**
  29934. * Sets the required values to the prepass renderer.
  29935. * @param prePassRenderer defines the prepass renderer to setup.
  29936. * @returns true if the pre pass is needed.
  29937. */
  29938. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  29939. /**
  29940. * Disposes the material
  29941. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  29942. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  29943. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  29944. */
  29945. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  29946. /** @hidden */
  29947. private releaseVertexArrayObject;
  29948. /**
  29949. * Serializes this material
  29950. * @returns the serialized material object
  29951. */
  29952. serialize(): any;
  29953. /**
  29954. * Creates a material from parsed material data
  29955. * @param parsedMaterial defines parsed material data
  29956. * @param scene defines the hosting scene
  29957. * @param rootUrl defines the root URL to use to load textures
  29958. * @returns a new material
  29959. */
  29960. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  29961. }
  29962. }
  29963. declare module BABYLON {
  29964. /**
  29965. * A multi-material is used to apply different materials to different parts of the same object without the need of
  29966. * separate meshes. This can be use to improve performances.
  29967. * @see https://doc.babylonjs.com/how_to/multi_materials
  29968. */
  29969. export class MultiMaterial extends Material {
  29970. private _subMaterials;
  29971. /**
  29972. * Gets or Sets the list of Materials used within the multi material.
  29973. * They need to be ordered according to the submeshes order in the associated mesh
  29974. */
  29975. get subMaterials(): Nullable<Material>[];
  29976. set subMaterials(value: Nullable<Material>[]);
  29977. /**
  29978. * Function used to align with Node.getChildren()
  29979. * @returns the list of Materials used within the multi material
  29980. */
  29981. getChildren(): Nullable<Material>[];
  29982. /**
  29983. * Instantiates a new Multi Material
  29984. * A multi-material is used to apply different materials to different parts of the same object without the need of
  29985. * separate meshes. This can be use to improve performances.
  29986. * @see https://doc.babylonjs.com/how_to/multi_materials
  29987. * @param name Define the name in the scene
  29988. * @param scene Define the scene the material belongs to
  29989. */
  29990. constructor(name: string, scene: Scene);
  29991. private _hookArray;
  29992. /**
  29993. * Get one of the submaterial by its index in the submaterials array
  29994. * @param index The index to look the sub material at
  29995. * @returns The Material if the index has been defined
  29996. */
  29997. getSubMaterial(index: number): Nullable<Material>;
  29998. /**
  29999. * Get the list of active textures for the whole sub materials list.
  30000. * @returns All the textures that will be used during the rendering
  30001. */
  30002. getActiveTextures(): BaseTexture[];
  30003. /**
  30004. * Specifies if any sub-materials of this multi-material use a given texture.
  30005. * @param texture Defines the texture to check against this multi-material's sub-materials.
  30006. * @returns A boolean specifying if any sub-material of this multi-material uses the texture.
  30007. */
  30008. hasTexture(texture: BaseTexture): boolean;
  30009. /**
  30010. * Gets the current class name of the material e.g. "MultiMaterial"
  30011. * Mainly use in serialization.
  30012. * @returns the class name
  30013. */
  30014. getClassName(): string;
  30015. /**
  30016. * Checks if the material is ready to render the requested sub mesh
  30017. * @param mesh Define the mesh the submesh belongs to
  30018. * @param subMesh Define the sub mesh to look readyness for
  30019. * @param useInstances Define whether or not the material is used with instances
  30020. * @returns true if ready, otherwise false
  30021. */
  30022. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  30023. /**
  30024. * Clones the current material and its related sub materials
  30025. * @param name Define the name of the newly cloned material
  30026. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  30027. * @returns the cloned material
  30028. */
  30029. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  30030. /**
  30031. * Serializes the materials into a JSON representation.
  30032. * @returns the JSON representation
  30033. */
  30034. serialize(): any;
  30035. /**
  30036. * Dispose the material and release its associated resources
  30037. * @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)
  30038. * @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)
  30039. * @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)
  30040. */
  30041. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  30042. /**
  30043. * Creates a MultiMaterial from parsed MultiMaterial data.
  30044. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  30045. * @param scene defines the hosting scene
  30046. * @returns a new MultiMaterial
  30047. */
  30048. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  30049. }
  30050. }
  30051. declare module BABYLON {
  30052. /**
  30053. * Defines a subdivision inside a mesh
  30054. */
  30055. export class SubMesh implements ICullable {
  30056. /** the material index to use */
  30057. materialIndex: number;
  30058. /** vertex index start */
  30059. verticesStart: number;
  30060. /** vertices count */
  30061. verticesCount: number;
  30062. /** index start */
  30063. indexStart: number;
  30064. /** indices count */
  30065. indexCount: number;
  30066. /** @hidden */
  30067. _materialDefines: Nullable<MaterialDefines>;
  30068. /** @hidden */
  30069. _materialEffect: Nullable<Effect>;
  30070. /** @hidden */
  30071. _effectOverride: Nullable<Effect>;
  30072. /**
  30073. * Gets material defines used by the effect associated to the sub mesh
  30074. */
  30075. get materialDefines(): Nullable<MaterialDefines>;
  30076. /**
  30077. * Sets material defines used by the effect associated to the sub mesh
  30078. */
  30079. set materialDefines(defines: Nullable<MaterialDefines>);
  30080. /**
  30081. * Gets associated effect
  30082. */
  30083. get effect(): Nullable<Effect>;
  30084. /**
  30085. * Sets associated effect (effect used to render this submesh)
  30086. * @param effect defines the effect to associate with
  30087. * @param defines defines the set of defines used to compile this effect
  30088. */
  30089. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  30090. /** @hidden */
  30091. _linesIndexCount: number;
  30092. private _mesh;
  30093. private _renderingMesh;
  30094. private _boundingInfo;
  30095. private _linesIndexBuffer;
  30096. /** @hidden */
  30097. _lastColliderWorldVertices: Nullable<Vector3[]>;
  30098. /** @hidden */
  30099. _trianglePlanes: Plane[];
  30100. /** @hidden */
  30101. _lastColliderTransformMatrix: Nullable<Matrix>;
  30102. /** @hidden */
  30103. _renderId: number;
  30104. /** @hidden */
  30105. _alphaIndex: number;
  30106. /** @hidden */
  30107. _distanceToCamera: number;
  30108. /** @hidden */
  30109. _id: number;
  30110. private _currentMaterial;
  30111. /**
  30112. * Add a new submesh to a mesh
  30113. * @param materialIndex defines the material index to use
  30114. * @param verticesStart defines vertex index start
  30115. * @param verticesCount defines vertices count
  30116. * @param indexStart defines index start
  30117. * @param indexCount defines indices count
  30118. * @param mesh defines the parent mesh
  30119. * @param renderingMesh defines an optional rendering mesh
  30120. * @param createBoundingBox defines if bounding box should be created for this submesh
  30121. * @returns the new submesh
  30122. */
  30123. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  30124. /**
  30125. * Creates a new submesh
  30126. * @param materialIndex defines the material index to use
  30127. * @param verticesStart defines vertex index start
  30128. * @param verticesCount defines vertices count
  30129. * @param indexStart defines index start
  30130. * @param indexCount defines indices count
  30131. * @param mesh defines the parent mesh
  30132. * @param renderingMesh defines an optional rendering mesh
  30133. * @param createBoundingBox defines if bounding box should be created for this submesh
  30134. * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)
  30135. */
  30136. constructor(
  30137. /** the material index to use */
  30138. materialIndex: number,
  30139. /** vertex index start */
  30140. verticesStart: number,
  30141. /** vertices count */
  30142. verticesCount: number,
  30143. /** index start */
  30144. indexStart: number,
  30145. /** indices count */
  30146. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean, addToMesh?: boolean);
  30147. /**
  30148. * Returns true if this submesh covers the entire parent mesh
  30149. * @ignorenaming
  30150. */
  30151. get IsGlobal(): boolean;
  30152. /**
  30153. * Returns the submesh BoudingInfo object
  30154. * @returns current bounding info (or mesh's one if the submesh is global)
  30155. */
  30156. getBoundingInfo(): BoundingInfo;
  30157. /**
  30158. * Sets the submesh BoundingInfo
  30159. * @param boundingInfo defines the new bounding info to use
  30160. * @returns the SubMesh
  30161. */
  30162. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  30163. /**
  30164. * Returns the mesh of the current submesh
  30165. * @return the parent mesh
  30166. */
  30167. getMesh(): AbstractMesh;
  30168. /**
  30169. * Returns the rendering mesh of the submesh
  30170. * @returns the rendering mesh (could be different from parent mesh)
  30171. */
  30172. getRenderingMesh(): Mesh;
  30173. /**
  30174. * Returns the replacement mesh of the submesh
  30175. * @returns the replacement mesh (could be different from parent mesh)
  30176. */
  30177. getReplacementMesh(): Nullable<AbstractMesh>;
  30178. /**
  30179. * Returns the effective mesh of the submesh
  30180. * @returns the effective mesh (could be different from parent mesh)
  30181. */
  30182. getEffectiveMesh(): AbstractMesh;
  30183. /**
  30184. * Returns the submesh material
  30185. * @returns null or the current material
  30186. */
  30187. getMaterial(): Nullable<Material>;
  30188. private _IsMultiMaterial;
  30189. /**
  30190. * Sets a new updated BoundingInfo object to the submesh
  30191. * @param data defines an optional position array to use to determine the bounding info
  30192. * @returns the SubMesh
  30193. */
  30194. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  30195. /** @hidden */
  30196. _checkCollision(collider: Collider): boolean;
  30197. /**
  30198. * Updates the submesh BoundingInfo
  30199. * @param world defines the world matrix to use to update the bounding info
  30200. * @returns the submesh
  30201. */
  30202. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  30203. /**
  30204. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  30205. * @param frustumPlanes defines the frustum planes
  30206. * @returns true if the submesh is intersecting with the frustum
  30207. */
  30208. isInFrustum(frustumPlanes: Plane[]): boolean;
  30209. /**
  30210. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  30211. * @param frustumPlanes defines the frustum planes
  30212. * @returns true if the submesh is inside the frustum
  30213. */
  30214. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  30215. /**
  30216. * Renders the submesh
  30217. * @param enableAlphaMode defines if alpha needs to be used
  30218. * @returns the submesh
  30219. */
  30220. render(enableAlphaMode: boolean): SubMesh;
  30221. /**
  30222. * @hidden
  30223. */
  30224. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  30225. /**
  30226. * Checks if the submesh intersects with a ray
  30227. * @param ray defines the ray to test
  30228. * @returns true is the passed ray intersects the submesh bounding box
  30229. */
  30230. canIntersects(ray: Ray): boolean;
  30231. /**
  30232. * Intersects current submesh with a ray
  30233. * @param ray defines the ray to test
  30234. * @param positions defines mesh's positions array
  30235. * @param indices defines mesh's indices array
  30236. * @param fastCheck defines if the first intersection will be used (and not the closest)
  30237. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  30238. * @returns intersection info or null if no intersection
  30239. */
  30240. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  30241. /** @hidden */
  30242. private _intersectLines;
  30243. /** @hidden */
  30244. private _intersectUnIndexedLines;
  30245. /** @hidden */
  30246. private _intersectTriangles;
  30247. /** @hidden */
  30248. private _intersectUnIndexedTriangles;
  30249. /** @hidden */
  30250. _rebuild(): void;
  30251. /**
  30252. * Creates a new submesh from the passed mesh
  30253. * @param newMesh defines the new hosting mesh
  30254. * @param newRenderingMesh defines an optional rendering mesh
  30255. * @returns the new submesh
  30256. */
  30257. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  30258. /**
  30259. * Release associated resources
  30260. */
  30261. dispose(): void;
  30262. /**
  30263. * Gets the class name
  30264. * @returns the string "SubMesh".
  30265. */
  30266. getClassName(): string;
  30267. /**
  30268. * Creates a new submesh from indices data
  30269. * @param materialIndex the index of the main mesh material
  30270. * @param startIndex the index where to start the copy in the mesh indices array
  30271. * @param indexCount the number of indices to copy then from the startIndex
  30272. * @param mesh the main mesh to create the submesh from
  30273. * @param renderingMesh the optional rendering mesh
  30274. * @returns a new submesh
  30275. */
  30276. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  30277. }
  30278. }
  30279. declare module BABYLON {
  30280. /**
  30281. * Class used to represent data loading progression
  30282. */
  30283. export class SceneLoaderFlags {
  30284. private static _ForceFullSceneLoadingForIncremental;
  30285. private static _ShowLoadingScreen;
  30286. private static _CleanBoneMatrixWeights;
  30287. private static _loggingLevel;
  30288. /**
  30289. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  30290. */
  30291. static get ForceFullSceneLoadingForIncremental(): boolean;
  30292. static set ForceFullSceneLoadingForIncremental(value: boolean);
  30293. /**
  30294. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  30295. */
  30296. static get ShowLoadingScreen(): boolean;
  30297. static set ShowLoadingScreen(value: boolean);
  30298. /**
  30299. * Defines the current logging level (while loading the scene)
  30300. * @ignorenaming
  30301. */
  30302. static get loggingLevel(): number;
  30303. static set loggingLevel(value: number);
  30304. /**
  30305. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  30306. */
  30307. static get CleanBoneMatrixWeights(): boolean;
  30308. static set CleanBoneMatrixWeights(value: boolean);
  30309. }
  30310. }
  30311. declare module BABYLON {
  30312. /**
  30313. * Class used to store geometry data (vertex buffers + index buffer)
  30314. */
  30315. export class Geometry implements IGetSetVerticesData {
  30316. /**
  30317. * Gets or sets the ID of the geometry
  30318. */
  30319. id: string;
  30320. /**
  30321. * Gets or sets the unique ID of the geometry
  30322. */
  30323. uniqueId: number;
  30324. /**
  30325. * Gets the delay loading state of the geometry (none by default which means not delayed)
  30326. */
  30327. delayLoadState: number;
  30328. /**
  30329. * Gets the file containing the data to load when running in delay load state
  30330. */
  30331. delayLoadingFile: Nullable<string>;
  30332. /**
  30333. * Callback called when the geometry is updated
  30334. */
  30335. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  30336. private _scene;
  30337. private _engine;
  30338. private _meshes;
  30339. private _totalVertices;
  30340. /** @hidden */
  30341. _indices: IndicesArray;
  30342. /** @hidden */
  30343. _vertexBuffers: {
  30344. [key: string]: VertexBuffer;
  30345. };
  30346. private _isDisposed;
  30347. private _extend;
  30348. private _boundingBias;
  30349. /** @hidden */
  30350. _delayInfo: Array<string>;
  30351. private _indexBuffer;
  30352. private _indexBufferIsUpdatable;
  30353. /** @hidden */
  30354. _boundingInfo: Nullable<BoundingInfo>;
  30355. /** @hidden */
  30356. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  30357. /** @hidden */
  30358. _softwareSkinningFrameId: number;
  30359. private _vertexArrayObjects;
  30360. private _updatable;
  30361. /** @hidden */
  30362. _positions: Nullable<Vector3[]>;
  30363. private _positionsCache;
  30364. /**
  30365. * 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
  30366. */
  30367. get boundingBias(): Vector2;
  30368. /**
  30369. * 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
  30370. */
  30371. set boundingBias(value: Vector2);
  30372. /**
  30373. * Static function used to attach a new empty geometry to a mesh
  30374. * @param mesh defines the mesh to attach the geometry to
  30375. * @returns the new Geometry
  30376. */
  30377. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  30378. /** Get the list of meshes using this geometry */
  30379. get meshes(): Mesh[];
  30380. /**
  30381. * 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
  30382. * and won't be computed based on the vertex positions (which is what we get when useBoundingInfoFromGeometry = false)
  30383. */
  30384. useBoundingInfoFromGeometry: boolean;
  30385. /**
  30386. * Creates a new geometry
  30387. * @param id defines the unique ID
  30388. * @param scene defines the hosting scene
  30389. * @param vertexData defines the VertexData used to get geometry data
  30390. * @param updatable defines if geometry must be updatable (false by default)
  30391. * @param mesh defines the mesh that will be associated with the geometry
  30392. */
  30393. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  30394. /**
  30395. * Gets the current extend of the geometry
  30396. */
  30397. get extend(): {
  30398. minimum: Vector3;
  30399. maximum: Vector3;
  30400. };
  30401. /**
  30402. * Gets the hosting scene
  30403. * @returns the hosting Scene
  30404. */
  30405. getScene(): Scene;
  30406. /**
  30407. * Gets the hosting engine
  30408. * @returns the hosting Engine
  30409. */
  30410. getEngine(): Engine;
  30411. /**
  30412. * Defines if the geometry is ready to use
  30413. * @returns true if the geometry is ready to be used
  30414. */
  30415. isReady(): boolean;
  30416. /**
  30417. * Gets a value indicating that the geometry should not be serialized
  30418. */
  30419. get doNotSerialize(): boolean;
  30420. /** @hidden */
  30421. _rebuild(): void;
  30422. /**
  30423. * Affects all geometry data in one call
  30424. * @param vertexData defines the geometry data
  30425. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  30426. */
  30427. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  30428. /**
  30429. * Set specific vertex data
  30430. * @param kind defines the data kind (Position, normal, etc...)
  30431. * @param data defines the vertex data to use
  30432. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  30433. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  30434. */
  30435. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  30436. /**
  30437. * Removes a specific vertex data
  30438. * @param kind defines the data kind (Position, normal, etc...)
  30439. */
  30440. removeVerticesData(kind: string): void;
  30441. /**
  30442. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  30443. * @param buffer defines the vertex buffer to use
  30444. * @param totalVertices defines the total number of vertices for position kind (could be null)
  30445. */
  30446. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  30447. /**
  30448. * Update a specific vertex buffer
  30449. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  30450. * It will do nothing if the buffer is not updatable
  30451. * @param kind defines the data kind (Position, normal, etc...)
  30452. * @param data defines the data to use
  30453. * @param offset defines the offset in the target buffer where to store the data
  30454. * @param useBytes set to true if the offset is in bytes
  30455. */
  30456. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  30457. /**
  30458. * Update a specific vertex buffer
  30459. * This function will create a new buffer if the current one is not updatable
  30460. * @param kind defines the data kind (Position, normal, etc...)
  30461. * @param data defines the data to use
  30462. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  30463. */
  30464. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  30465. private _updateBoundingInfo;
  30466. /** @hidden */
  30467. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  30468. /**
  30469. * Gets total number of vertices
  30470. * @returns the total number of vertices
  30471. */
  30472. getTotalVertices(): number;
  30473. /**
  30474. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  30475. * @param kind defines the data kind (Position, normal, etc...)
  30476. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  30477. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  30478. * @returns a float array containing vertex data
  30479. */
  30480. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  30481. /**
  30482. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  30483. * @param kind defines the data kind (Position, normal, etc...)
  30484. * @returns true if the vertex buffer with the specified kind is updatable
  30485. */
  30486. isVertexBufferUpdatable(kind: string): boolean;
  30487. /**
  30488. * Gets a specific vertex buffer
  30489. * @param kind defines the data kind (Position, normal, etc...)
  30490. * @returns a VertexBuffer
  30491. */
  30492. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  30493. /**
  30494. * Returns all vertex buffers
  30495. * @return an object holding all vertex buffers indexed by kind
  30496. */
  30497. getVertexBuffers(): Nullable<{
  30498. [key: string]: VertexBuffer;
  30499. }>;
  30500. /**
  30501. * Gets a boolean indicating if specific vertex buffer is present
  30502. * @param kind defines the data kind (Position, normal, etc...)
  30503. * @returns true if data is present
  30504. */
  30505. isVerticesDataPresent(kind: string): boolean;
  30506. /**
  30507. * Gets a list of all attached data kinds (Position, normal, etc...)
  30508. * @returns a list of string containing all kinds
  30509. */
  30510. getVerticesDataKinds(): string[];
  30511. /**
  30512. * Update index buffer
  30513. * @param indices defines the indices to store in the index buffer
  30514. * @param offset defines the offset in the target buffer where to store the data
  30515. * @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)
  30516. */
  30517. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  30518. /**
  30519. * Creates a new index buffer
  30520. * @param indices defines the indices to store in the index buffer
  30521. * @param totalVertices defines the total number of vertices (could be null)
  30522. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  30523. */
  30524. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  30525. /**
  30526. * Return the total number of indices
  30527. * @returns the total number of indices
  30528. */
  30529. getTotalIndices(): number;
  30530. /**
  30531. * Gets the index buffer array
  30532. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  30533. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  30534. * @returns the index buffer array
  30535. */
  30536. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  30537. /**
  30538. * Gets the index buffer
  30539. * @return the index buffer
  30540. */
  30541. getIndexBuffer(): Nullable<DataBuffer>;
  30542. /** @hidden */
  30543. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  30544. /**
  30545. * Release the associated resources for a specific mesh
  30546. * @param mesh defines the source mesh
  30547. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  30548. */
  30549. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  30550. /**
  30551. * Apply current geometry to a given mesh
  30552. * @param mesh defines the mesh to apply geometry to
  30553. */
  30554. applyToMesh(mesh: Mesh): void;
  30555. private _updateExtend;
  30556. private _applyToMesh;
  30557. private notifyUpdate;
  30558. /**
  30559. * Load the geometry if it was flagged as delay loaded
  30560. * @param scene defines the hosting scene
  30561. * @param onLoaded defines a callback called when the geometry is loaded
  30562. */
  30563. load(scene: Scene, onLoaded?: () => void): void;
  30564. private _queueLoad;
  30565. /**
  30566. * Invert the geometry to move from a right handed system to a left handed one.
  30567. */
  30568. toLeftHanded(): void;
  30569. /** @hidden */
  30570. _resetPointsArrayCache(): void;
  30571. /** @hidden */
  30572. _generatePointsArray(): boolean;
  30573. /**
  30574. * Gets a value indicating if the geometry is disposed
  30575. * @returns true if the geometry was disposed
  30576. */
  30577. isDisposed(): boolean;
  30578. private _disposeVertexArrayObjects;
  30579. /**
  30580. * Free all associated resources
  30581. */
  30582. dispose(): void;
  30583. /**
  30584. * Clone the current geometry into a new geometry
  30585. * @param id defines the unique ID of the new geometry
  30586. * @returns a new geometry object
  30587. */
  30588. copy(id: string): Geometry;
  30589. /**
  30590. * Serialize the current geometry info (and not the vertices data) into a JSON object
  30591. * @return a JSON representation of the current geometry data (without the vertices data)
  30592. */
  30593. serialize(): any;
  30594. private toNumberArray;
  30595. /**
  30596. * Serialize all vertices data into a JSON oject
  30597. * @returns a JSON representation of the current geometry data
  30598. */
  30599. serializeVerticeData(): any;
  30600. /**
  30601. * Extracts a clone of a mesh geometry
  30602. * @param mesh defines the source mesh
  30603. * @param id defines the unique ID of the new geometry object
  30604. * @returns the new geometry object
  30605. */
  30606. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  30607. /**
  30608. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  30609. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  30610. * Be aware Math.random() could cause collisions, but:
  30611. * "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"
  30612. * @returns a string containing a new GUID
  30613. */
  30614. static RandomId(): string;
  30615. /** @hidden */
  30616. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  30617. private static _CleanMatricesWeights;
  30618. /**
  30619. * Create a new geometry from persisted data (Using .babylon file format)
  30620. * @param parsedVertexData defines the persisted data
  30621. * @param scene defines the hosting scene
  30622. * @param rootUrl defines the root url to use to load assets (like delayed data)
  30623. * @returns the new geometry object
  30624. */
  30625. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  30626. }
  30627. }
  30628. declare module BABYLON {
  30629. /**
  30630. * Defines a target to use with MorphTargetManager
  30631. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  30632. */
  30633. export class MorphTarget implements IAnimatable {
  30634. /** defines the name of the target */
  30635. name: string;
  30636. /**
  30637. * Gets or sets the list of animations
  30638. */
  30639. animations: Animation[];
  30640. private _scene;
  30641. private _positions;
  30642. private _normals;
  30643. private _tangents;
  30644. private _uvs;
  30645. private _influence;
  30646. private _uniqueId;
  30647. /**
  30648. * Observable raised when the influence changes
  30649. */
  30650. onInfluenceChanged: Observable<boolean>;
  30651. /** @hidden */
  30652. _onDataLayoutChanged: Observable<void>;
  30653. /**
  30654. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  30655. */
  30656. get influence(): number;
  30657. set influence(influence: number);
  30658. /**
  30659. * Gets or sets the id of the morph Target
  30660. */
  30661. id: string;
  30662. private _animationPropertiesOverride;
  30663. /**
  30664. * Gets or sets the animation properties override
  30665. */
  30666. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  30667. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  30668. /**
  30669. * Creates a new MorphTarget
  30670. * @param name defines the name of the target
  30671. * @param influence defines the influence to use
  30672. * @param scene defines the scene the morphtarget belongs to
  30673. */
  30674. constructor(
  30675. /** defines the name of the target */
  30676. name: string, influence?: number, scene?: Nullable<Scene>);
  30677. /**
  30678. * Gets the unique ID of this manager
  30679. */
  30680. get uniqueId(): number;
  30681. /**
  30682. * Gets a boolean defining if the target contains position data
  30683. */
  30684. get hasPositions(): boolean;
  30685. /**
  30686. * Gets a boolean defining if the target contains normal data
  30687. */
  30688. get hasNormals(): boolean;
  30689. /**
  30690. * Gets a boolean defining if the target contains tangent data
  30691. */
  30692. get hasTangents(): boolean;
  30693. /**
  30694. * Gets a boolean defining if the target contains texture coordinates data
  30695. */
  30696. get hasUVs(): boolean;
  30697. /**
  30698. * Affects position data to this target
  30699. * @param data defines the position data to use
  30700. */
  30701. setPositions(data: Nullable<FloatArray>): void;
  30702. /**
  30703. * Gets the position data stored in this target
  30704. * @returns a FloatArray containing the position data (or null if not present)
  30705. */
  30706. getPositions(): Nullable<FloatArray>;
  30707. /**
  30708. * Affects normal data to this target
  30709. * @param data defines the normal data to use
  30710. */
  30711. setNormals(data: Nullable<FloatArray>): void;
  30712. /**
  30713. * Gets the normal data stored in this target
  30714. * @returns a FloatArray containing the normal data (or null if not present)
  30715. */
  30716. getNormals(): Nullable<FloatArray>;
  30717. /**
  30718. * Affects tangent data to this target
  30719. * @param data defines the tangent data to use
  30720. */
  30721. setTangents(data: Nullable<FloatArray>): void;
  30722. /**
  30723. * Gets the tangent data stored in this target
  30724. * @returns a FloatArray containing the tangent data (or null if not present)
  30725. */
  30726. getTangents(): Nullable<FloatArray>;
  30727. /**
  30728. * Affects texture coordinates data to this target
  30729. * @param data defines the texture coordinates data to use
  30730. */
  30731. setUVs(data: Nullable<FloatArray>): void;
  30732. /**
  30733. * Gets the texture coordinates data stored in this target
  30734. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  30735. */
  30736. getUVs(): Nullable<FloatArray>;
  30737. /**
  30738. * Clone the current target
  30739. * @returns a new MorphTarget
  30740. */
  30741. clone(): MorphTarget;
  30742. /**
  30743. * Serializes the current target into a Serialization object
  30744. * @returns the serialized object
  30745. */
  30746. serialize(): any;
  30747. /**
  30748. * Returns the string "MorphTarget"
  30749. * @returns "MorphTarget"
  30750. */
  30751. getClassName(): string;
  30752. /**
  30753. * Creates a new target from serialized data
  30754. * @param serializationObject defines the serialized data to use
  30755. * @returns a new MorphTarget
  30756. */
  30757. static Parse(serializationObject: any): MorphTarget;
  30758. /**
  30759. * Creates a MorphTarget from mesh data
  30760. * @param mesh defines the source mesh
  30761. * @param name defines the name to use for the new target
  30762. * @param influence defines the influence to attach to the target
  30763. * @returns a new MorphTarget
  30764. */
  30765. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  30766. }
  30767. }
  30768. declare module BABYLON {
  30769. /**
  30770. * This class is used to deform meshes using morphing between different targets
  30771. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  30772. */
  30773. export class MorphTargetManager {
  30774. private _targets;
  30775. private _targetInfluenceChangedObservers;
  30776. private _targetDataLayoutChangedObservers;
  30777. private _activeTargets;
  30778. private _scene;
  30779. private _influences;
  30780. private _supportsNormals;
  30781. private _supportsTangents;
  30782. private _supportsUVs;
  30783. private _vertexCount;
  30784. private _uniqueId;
  30785. private _tempInfluences;
  30786. /**
  30787. * Gets or sets a boolean indicating if normals must be morphed
  30788. */
  30789. enableNormalMorphing: boolean;
  30790. /**
  30791. * Gets or sets a boolean indicating if tangents must be morphed
  30792. */
  30793. enableTangentMorphing: boolean;
  30794. /**
  30795. * Gets or sets a boolean indicating if UV must be morphed
  30796. */
  30797. enableUVMorphing: boolean;
  30798. /**
  30799. * Creates a new MorphTargetManager
  30800. * @param scene defines the current scene
  30801. */
  30802. constructor(scene?: Nullable<Scene>);
  30803. /**
  30804. * Gets the unique ID of this manager
  30805. */
  30806. get uniqueId(): number;
  30807. /**
  30808. * Gets the number of vertices handled by this manager
  30809. */
  30810. get vertexCount(): number;
  30811. /**
  30812. * Gets a boolean indicating if this manager supports morphing of normals
  30813. */
  30814. get supportsNormals(): boolean;
  30815. /**
  30816. * Gets a boolean indicating if this manager supports morphing of tangents
  30817. */
  30818. get supportsTangents(): boolean;
  30819. /**
  30820. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  30821. */
  30822. get supportsUVs(): boolean;
  30823. /**
  30824. * Gets the number of targets stored in this manager
  30825. */
  30826. get numTargets(): number;
  30827. /**
  30828. * Gets the number of influencers (ie. the number of targets with influences > 0)
  30829. */
  30830. get numInfluencers(): number;
  30831. /**
  30832. * Gets the list of influences (one per target)
  30833. */
  30834. get influences(): Float32Array;
  30835. /**
  30836. * Gets the active target at specified index. An active target is a target with an influence > 0
  30837. * @param index defines the index to check
  30838. * @returns the requested target
  30839. */
  30840. getActiveTarget(index: number): MorphTarget;
  30841. /**
  30842. * Gets the target at specified index
  30843. * @param index defines the index to check
  30844. * @returns the requested target
  30845. */
  30846. getTarget(index: number): MorphTarget;
  30847. /**
  30848. * Add a new target to this manager
  30849. * @param target defines the target to add
  30850. */
  30851. addTarget(target: MorphTarget): void;
  30852. /**
  30853. * Removes a target from the manager
  30854. * @param target defines the target to remove
  30855. */
  30856. removeTarget(target: MorphTarget): void;
  30857. /**
  30858. * Clone the current manager
  30859. * @returns a new MorphTargetManager
  30860. */
  30861. clone(): MorphTargetManager;
  30862. /**
  30863. * Serializes the current manager into a Serialization object
  30864. * @returns the serialized object
  30865. */
  30866. serialize(): any;
  30867. private _syncActiveTargets;
  30868. /**
  30869. * Syncrhonize the targets with all the meshes using this morph target manager
  30870. */
  30871. synchronize(): void;
  30872. /**
  30873. * Creates a new MorphTargetManager from serialized data
  30874. * @param serializationObject defines the serialized data
  30875. * @param scene defines the hosting scene
  30876. * @returns the new MorphTargetManager
  30877. */
  30878. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  30879. }
  30880. }
  30881. declare module BABYLON {
  30882. /**
  30883. * Class used to represent a specific level of detail of a mesh
  30884. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  30885. */
  30886. export class MeshLODLevel {
  30887. /** Defines the distance where this level should start being displayed */
  30888. distance: number;
  30889. /** Defines the mesh to use to render this level */
  30890. mesh: Nullable<Mesh>;
  30891. /**
  30892. * Creates a new LOD level
  30893. * @param distance defines the distance where this level should star being displayed
  30894. * @param mesh defines the mesh to use to render this level
  30895. */
  30896. constructor(
  30897. /** Defines the distance where this level should start being displayed */
  30898. distance: number,
  30899. /** Defines the mesh to use to render this level */
  30900. mesh: Nullable<Mesh>);
  30901. }
  30902. }
  30903. declare module BABYLON {
  30904. /**
  30905. * Helper class used to generate a canvas to manipulate images
  30906. */
  30907. export class CanvasGenerator {
  30908. /**
  30909. * Create a new canvas (or offscreen canvas depending on the context)
  30910. * @param width defines the expected width
  30911. * @param height defines the expected height
  30912. * @return a new canvas or offscreen canvas
  30913. */
  30914. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  30915. }
  30916. }
  30917. declare module BABYLON {
  30918. /**
  30919. * Mesh representing the gorund
  30920. */
  30921. export class GroundMesh extends Mesh {
  30922. /** If octree should be generated */
  30923. generateOctree: boolean;
  30924. private _heightQuads;
  30925. /** @hidden */
  30926. _subdivisionsX: number;
  30927. /** @hidden */
  30928. _subdivisionsY: number;
  30929. /** @hidden */
  30930. _width: number;
  30931. /** @hidden */
  30932. _height: number;
  30933. /** @hidden */
  30934. _minX: number;
  30935. /** @hidden */
  30936. _maxX: number;
  30937. /** @hidden */
  30938. _minZ: number;
  30939. /** @hidden */
  30940. _maxZ: number;
  30941. constructor(name: string, scene: Scene);
  30942. /**
  30943. * "GroundMesh"
  30944. * @returns "GroundMesh"
  30945. */
  30946. getClassName(): string;
  30947. /**
  30948. * The minimum of x and y subdivisions
  30949. */
  30950. get subdivisions(): number;
  30951. /**
  30952. * X subdivisions
  30953. */
  30954. get subdivisionsX(): number;
  30955. /**
  30956. * Y subdivisions
  30957. */
  30958. get subdivisionsY(): number;
  30959. /**
  30960. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  30961. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  30962. * @param chunksCount the number of subdivisions for x and y
  30963. * @param octreeBlocksSize (Default: 32)
  30964. */
  30965. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  30966. /**
  30967. * Returns a height (y) value in the Worl system :
  30968. * the ground altitude at the coordinates (x, z) expressed in the World system.
  30969. * @param x x coordinate
  30970. * @param z z coordinate
  30971. * @returns the ground y position if (x, z) are outside the ground surface.
  30972. */
  30973. getHeightAtCoordinates(x: number, z: number): number;
  30974. /**
  30975. * Returns a normalized vector (Vector3) orthogonal to the ground
  30976. * at the ground coordinates (x, z) expressed in the World system.
  30977. * @param x x coordinate
  30978. * @param z z coordinate
  30979. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  30980. */
  30981. getNormalAtCoordinates(x: number, z: number): Vector3;
  30982. /**
  30983. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  30984. * at the ground coordinates (x, z) expressed in the World system.
  30985. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  30986. * @param x x coordinate
  30987. * @param z z coordinate
  30988. * @param ref vector to store the result
  30989. * @returns the GroundMesh.
  30990. */
  30991. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  30992. /**
  30993. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  30994. * if the ground has been updated.
  30995. * This can be used in the render loop.
  30996. * @returns the GroundMesh.
  30997. */
  30998. updateCoordinateHeights(): GroundMesh;
  30999. private _getFacetAt;
  31000. private _initHeightQuads;
  31001. private _computeHeightQuads;
  31002. /**
  31003. * Serializes this ground mesh
  31004. * @param serializationObject object to write serialization to
  31005. */
  31006. serialize(serializationObject: any): void;
  31007. /**
  31008. * Parses a serialized ground mesh
  31009. * @param parsedMesh the serialized mesh
  31010. * @param scene the scene to create the ground mesh in
  31011. * @returns the created ground mesh
  31012. */
  31013. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  31014. }
  31015. }
  31016. declare module BABYLON {
  31017. /**
  31018. * Interface for Physics-Joint data
  31019. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31020. */
  31021. export interface PhysicsJointData {
  31022. /**
  31023. * The main pivot of the joint
  31024. */
  31025. mainPivot?: Vector3;
  31026. /**
  31027. * The connected pivot of the joint
  31028. */
  31029. connectedPivot?: Vector3;
  31030. /**
  31031. * The main axis of the joint
  31032. */
  31033. mainAxis?: Vector3;
  31034. /**
  31035. * The connected axis of the joint
  31036. */
  31037. connectedAxis?: Vector3;
  31038. /**
  31039. * The collision of the joint
  31040. */
  31041. collision?: boolean;
  31042. /**
  31043. * Native Oimo/Cannon/Energy data
  31044. */
  31045. nativeParams?: any;
  31046. }
  31047. /**
  31048. * This is a holder class for the physics joint created by the physics plugin
  31049. * It holds a set of functions to control the underlying joint
  31050. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31051. */
  31052. export class PhysicsJoint {
  31053. /**
  31054. * The type of the physics joint
  31055. */
  31056. type: number;
  31057. /**
  31058. * The data for the physics joint
  31059. */
  31060. jointData: PhysicsJointData;
  31061. private _physicsJoint;
  31062. protected _physicsPlugin: IPhysicsEnginePlugin;
  31063. /**
  31064. * Initializes the physics joint
  31065. * @param type The type of the physics joint
  31066. * @param jointData The data for the physics joint
  31067. */
  31068. constructor(
  31069. /**
  31070. * The type of the physics joint
  31071. */
  31072. type: number,
  31073. /**
  31074. * The data for the physics joint
  31075. */
  31076. jointData: PhysicsJointData);
  31077. /**
  31078. * Gets the physics joint
  31079. */
  31080. get physicsJoint(): any;
  31081. /**
  31082. * Sets the physics joint
  31083. */
  31084. set physicsJoint(newJoint: any);
  31085. /**
  31086. * Sets the physics plugin
  31087. */
  31088. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  31089. /**
  31090. * Execute a function that is physics-plugin specific.
  31091. * @param {Function} func the function that will be executed.
  31092. * It accepts two parameters: the physics world and the physics joint
  31093. */
  31094. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  31095. /**
  31096. * Distance-Joint type
  31097. */
  31098. static DistanceJoint: number;
  31099. /**
  31100. * Hinge-Joint type
  31101. */
  31102. static HingeJoint: number;
  31103. /**
  31104. * Ball-and-Socket joint type
  31105. */
  31106. static BallAndSocketJoint: number;
  31107. /**
  31108. * Wheel-Joint type
  31109. */
  31110. static WheelJoint: number;
  31111. /**
  31112. * Slider-Joint type
  31113. */
  31114. static SliderJoint: number;
  31115. /**
  31116. * Prismatic-Joint type
  31117. */
  31118. static PrismaticJoint: number;
  31119. /**
  31120. * Universal-Joint type
  31121. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  31122. */
  31123. static UniversalJoint: number;
  31124. /**
  31125. * Hinge-Joint 2 type
  31126. */
  31127. static Hinge2Joint: number;
  31128. /**
  31129. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  31130. */
  31131. static PointToPointJoint: number;
  31132. /**
  31133. * Spring-Joint type
  31134. */
  31135. static SpringJoint: number;
  31136. /**
  31137. * Lock-Joint type
  31138. */
  31139. static LockJoint: number;
  31140. }
  31141. /**
  31142. * A class representing a physics distance joint
  31143. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31144. */
  31145. export class DistanceJoint extends PhysicsJoint {
  31146. /**
  31147. *
  31148. * @param jointData The data for the Distance-Joint
  31149. */
  31150. constructor(jointData: DistanceJointData);
  31151. /**
  31152. * Update the predefined distance.
  31153. * @param maxDistance The maximum preferred distance
  31154. * @param minDistance The minimum preferred distance
  31155. */
  31156. updateDistance(maxDistance: number, minDistance?: number): void;
  31157. }
  31158. /**
  31159. * Represents a Motor-Enabled Joint
  31160. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31161. */
  31162. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  31163. /**
  31164. * Initializes the Motor-Enabled Joint
  31165. * @param type The type of the joint
  31166. * @param jointData The physica joint data for the joint
  31167. */
  31168. constructor(type: number, jointData: PhysicsJointData);
  31169. /**
  31170. * Set the motor values.
  31171. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31172. * @param force the force to apply
  31173. * @param maxForce max force for this motor.
  31174. */
  31175. setMotor(force?: number, maxForce?: number): void;
  31176. /**
  31177. * Set the motor's limits.
  31178. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31179. * @param upperLimit The upper limit of the motor
  31180. * @param lowerLimit The lower limit of the motor
  31181. */
  31182. setLimit(upperLimit: number, lowerLimit?: number): void;
  31183. }
  31184. /**
  31185. * This class represents a single physics Hinge-Joint
  31186. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31187. */
  31188. export class HingeJoint extends MotorEnabledJoint {
  31189. /**
  31190. * Initializes the Hinge-Joint
  31191. * @param jointData The joint data for the Hinge-Joint
  31192. */
  31193. constructor(jointData: PhysicsJointData);
  31194. /**
  31195. * Set the motor values.
  31196. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31197. * @param {number} force the force to apply
  31198. * @param {number} maxForce max force for this motor.
  31199. */
  31200. setMotor(force?: number, maxForce?: number): void;
  31201. /**
  31202. * Set the motor's limits.
  31203. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31204. * @param upperLimit The upper limit of the motor
  31205. * @param lowerLimit The lower limit of the motor
  31206. */
  31207. setLimit(upperLimit: number, lowerLimit?: number): void;
  31208. }
  31209. /**
  31210. * This class represents a dual hinge physics joint (same as wheel joint)
  31211. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31212. */
  31213. export class Hinge2Joint extends MotorEnabledJoint {
  31214. /**
  31215. * Initializes the Hinge2-Joint
  31216. * @param jointData The joint data for the Hinge2-Joint
  31217. */
  31218. constructor(jointData: PhysicsJointData);
  31219. /**
  31220. * Set the motor values.
  31221. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31222. * @param {number} targetSpeed the speed the motor is to reach
  31223. * @param {number} maxForce max force for this motor.
  31224. * @param {motorIndex} the motor's index, 0 or 1.
  31225. */
  31226. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  31227. /**
  31228. * Set the motor limits.
  31229. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31230. * @param {number} upperLimit the upper limit
  31231. * @param {number} lowerLimit lower limit
  31232. * @param {motorIndex} the motor's index, 0 or 1.
  31233. */
  31234. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  31235. }
  31236. /**
  31237. * Interface for a motor enabled joint
  31238. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31239. */
  31240. export interface IMotorEnabledJoint {
  31241. /**
  31242. * Physics joint
  31243. */
  31244. physicsJoint: any;
  31245. /**
  31246. * Sets the motor of the motor-enabled joint
  31247. * @param force The force of the motor
  31248. * @param maxForce The maximum force of the motor
  31249. * @param motorIndex The index of the motor
  31250. */
  31251. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  31252. /**
  31253. * Sets the limit of the motor
  31254. * @param upperLimit The upper limit of the motor
  31255. * @param lowerLimit The lower limit of the motor
  31256. * @param motorIndex The index of the motor
  31257. */
  31258. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  31259. }
  31260. /**
  31261. * Joint data for a Distance-Joint
  31262. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31263. */
  31264. export interface DistanceJointData extends PhysicsJointData {
  31265. /**
  31266. * Max distance the 2 joint objects can be apart
  31267. */
  31268. maxDistance: number;
  31269. }
  31270. /**
  31271. * Joint data from a spring joint
  31272. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31273. */
  31274. export interface SpringJointData extends PhysicsJointData {
  31275. /**
  31276. * Length of the spring
  31277. */
  31278. length: number;
  31279. /**
  31280. * Stiffness of the spring
  31281. */
  31282. stiffness: number;
  31283. /**
  31284. * Damping of the spring
  31285. */
  31286. damping: number;
  31287. /** this callback will be called when applying the force to the impostors. */
  31288. forceApplicationCallback: () => void;
  31289. }
  31290. }
  31291. declare module BABYLON {
  31292. /**
  31293. * Holds the data for the raycast result
  31294. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31295. */
  31296. export class PhysicsRaycastResult {
  31297. private _hasHit;
  31298. private _hitDistance;
  31299. private _hitNormalWorld;
  31300. private _hitPointWorld;
  31301. private _rayFromWorld;
  31302. private _rayToWorld;
  31303. /**
  31304. * Gets if there was a hit
  31305. */
  31306. get hasHit(): boolean;
  31307. /**
  31308. * Gets the distance from the hit
  31309. */
  31310. get hitDistance(): number;
  31311. /**
  31312. * Gets the hit normal/direction in the world
  31313. */
  31314. get hitNormalWorld(): Vector3;
  31315. /**
  31316. * Gets the hit point in the world
  31317. */
  31318. get hitPointWorld(): Vector3;
  31319. /**
  31320. * Gets the ray "start point" of the ray in the world
  31321. */
  31322. get rayFromWorld(): Vector3;
  31323. /**
  31324. * Gets the ray "end point" of the ray in the world
  31325. */
  31326. get rayToWorld(): Vector3;
  31327. /**
  31328. * Sets the hit data (normal & point in world space)
  31329. * @param hitNormalWorld defines the normal in world space
  31330. * @param hitPointWorld defines the point in world space
  31331. */
  31332. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  31333. /**
  31334. * Sets the distance from the start point to the hit point
  31335. * @param distance
  31336. */
  31337. setHitDistance(distance: number): void;
  31338. /**
  31339. * Calculates the distance manually
  31340. */
  31341. calculateHitDistance(): void;
  31342. /**
  31343. * Resets all the values to default
  31344. * @param from The from point on world space
  31345. * @param to The to point on world space
  31346. */
  31347. reset(from?: Vector3, to?: Vector3): void;
  31348. }
  31349. /**
  31350. * Interface for the size containing width and height
  31351. */
  31352. interface IXYZ {
  31353. /**
  31354. * X
  31355. */
  31356. x: number;
  31357. /**
  31358. * Y
  31359. */
  31360. y: number;
  31361. /**
  31362. * Z
  31363. */
  31364. z: number;
  31365. }
  31366. }
  31367. declare module BABYLON {
  31368. /**
  31369. * Interface used to describe a physics joint
  31370. */
  31371. export interface PhysicsImpostorJoint {
  31372. /** Defines the main impostor to which the joint is linked */
  31373. mainImpostor: PhysicsImpostor;
  31374. /** Defines the impostor that is connected to the main impostor using this joint */
  31375. connectedImpostor: PhysicsImpostor;
  31376. /** Defines the joint itself */
  31377. joint: PhysicsJoint;
  31378. }
  31379. /** @hidden */
  31380. export interface IPhysicsEnginePlugin {
  31381. world: any;
  31382. name: string;
  31383. setGravity(gravity: Vector3): void;
  31384. setTimeStep(timeStep: number): void;
  31385. getTimeStep(): number;
  31386. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  31387. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  31388. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  31389. generatePhysicsBody(impostor: PhysicsImpostor): void;
  31390. removePhysicsBody(impostor: PhysicsImpostor): void;
  31391. generateJoint(joint: PhysicsImpostorJoint): void;
  31392. removeJoint(joint: PhysicsImpostorJoint): void;
  31393. isSupported(): boolean;
  31394. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  31395. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  31396. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  31397. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  31398. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  31399. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  31400. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  31401. getBodyMass(impostor: PhysicsImpostor): number;
  31402. getBodyFriction(impostor: PhysicsImpostor): number;
  31403. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  31404. getBodyRestitution(impostor: PhysicsImpostor): number;
  31405. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  31406. getBodyPressure?(impostor: PhysicsImpostor): number;
  31407. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  31408. getBodyStiffness?(impostor: PhysicsImpostor): number;
  31409. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  31410. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  31411. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  31412. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  31413. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  31414. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  31415. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  31416. sleepBody(impostor: PhysicsImpostor): void;
  31417. wakeUpBody(impostor: PhysicsImpostor): void;
  31418. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  31419. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  31420. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  31421. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  31422. getRadius(impostor: PhysicsImpostor): number;
  31423. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  31424. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  31425. dispose(): void;
  31426. }
  31427. /**
  31428. * Interface used to define a physics engine
  31429. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31430. */
  31431. export interface IPhysicsEngine {
  31432. /**
  31433. * Gets the gravity vector used by the simulation
  31434. */
  31435. gravity: Vector3;
  31436. /**
  31437. * Sets the gravity vector used by the simulation
  31438. * @param gravity defines the gravity vector to use
  31439. */
  31440. setGravity(gravity: Vector3): void;
  31441. /**
  31442. * Set the time step of the physics engine.
  31443. * Default is 1/60.
  31444. * To slow it down, enter 1/600 for example.
  31445. * To speed it up, 1/30
  31446. * @param newTimeStep the new timestep to apply to this world.
  31447. */
  31448. setTimeStep(newTimeStep: number): void;
  31449. /**
  31450. * Get the time step of the physics engine.
  31451. * @returns the current time step
  31452. */
  31453. getTimeStep(): number;
  31454. /**
  31455. * Set the sub time step of the physics engine.
  31456. * Default is 0 meaning there is no sub steps
  31457. * To increase physics resolution precision, set a small value (like 1 ms)
  31458. * @param subTimeStep defines the new sub timestep used for physics resolution.
  31459. */
  31460. setSubTimeStep(subTimeStep: number): void;
  31461. /**
  31462. * Get the sub time step of the physics engine.
  31463. * @returns the current sub time step
  31464. */
  31465. getSubTimeStep(): number;
  31466. /**
  31467. * Release all resources
  31468. */
  31469. dispose(): void;
  31470. /**
  31471. * Gets the name of the current physics plugin
  31472. * @returns the name of the plugin
  31473. */
  31474. getPhysicsPluginName(): string;
  31475. /**
  31476. * Adding a new impostor for the impostor tracking.
  31477. * This will be done by the impostor itself.
  31478. * @param impostor the impostor to add
  31479. */
  31480. addImpostor(impostor: PhysicsImpostor): void;
  31481. /**
  31482. * Remove an impostor from the engine.
  31483. * This impostor and its mesh will not longer be updated by the physics engine.
  31484. * @param impostor the impostor to remove
  31485. */
  31486. removeImpostor(impostor: PhysicsImpostor): void;
  31487. /**
  31488. * Add a joint to the physics engine
  31489. * @param mainImpostor defines the main impostor to which the joint is added.
  31490. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  31491. * @param joint defines the joint that will connect both impostors.
  31492. */
  31493. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  31494. /**
  31495. * Removes a joint from the simulation
  31496. * @param mainImpostor defines the impostor used with the joint
  31497. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  31498. * @param joint defines the joint to remove
  31499. */
  31500. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  31501. /**
  31502. * Gets the current plugin used to run the simulation
  31503. * @returns current plugin
  31504. */
  31505. getPhysicsPlugin(): IPhysicsEnginePlugin;
  31506. /**
  31507. * Gets the list of physic impostors
  31508. * @returns an array of PhysicsImpostor
  31509. */
  31510. getImpostors(): Array<PhysicsImpostor>;
  31511. /**
  31512. * Gets the impostor for a physics enabled object
  31513. * @param object defines the object impersonated by the impostor
  31514. * @returns the PhysicsImpostor or null if not found
  31515. */
  31516. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  31517. /**
  31518. * Gets the impostor for a physics body object
  31519. * @param body defines physics body used by the impostor
  31520. * @returns the PhysicsImpostor or null if not found
  31521. */
  31522. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  31523. /**
  31524. * Does a raycast in the physics world
  31525. * @param from when should the ray start?
  31526. * @param to when should the ray end?
  31527. * @returns PhysicsRaycastResult
  31528. */
  31529. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  31530. /**
  31531. * Called by the scene. No need to call it.
  31532. * @param delta defines the timespam between frames
  31533. */
  31534. _step(delta: number): void;
  31535. }
  31536. }
  31537. declare module BABYLON {
  31538. /**
  31539. * The interface for the physics imposter parameters
  31540. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31541. */
  31542. export interface PhysicsImpostorParameters {
  31543. /**
  31544. * The mass of the physics imposter
  31545. */
  31546. mass: number;
  31547. /**
  31548. * The friction of the physics imposter
  31549. */
  31550. friction?: number;
  31551. /**
  31552. * The coefficient of restitution of the physics imposter
  31553. */
  31554. restitution?: number;
  31555. /**
  31556. * The native options of the physics imposter
  31557. */
  31558. nativeOptions?: any;
  31559. /**
  31560. * Specifies if the parent should be ignored
  31561. */
  31562. ignoreParent?: boolean;
  31563. /**
  31564. * Specifies if bi-directional transformations should be disabled
  31565. */
  31566. disableBidirectionalTransformation?: boolean;
  31567. /**
  31568. * The pressure inside the physics imposter, soft object only
  31569. */
  31570. pressure?: number;
  31571. /**
  31572. * The stiffness the physics imposter, soft object only
  31573. */
  31574. stiffness?: number;
  31575. /**
  31576. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  31577. */
  31578. velocityIterations?: number;
  31579. /**
  31580. * The number of iterations used in maintaining consistent vertex positions, soft object only
  31581. */
  31582. positionIterations?: number;
  31583. /**
  31584. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  31585. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  31586. * Add to fix multiple points
  31587. */
  31588. fixedPoints?: number;
  31589. /**
  31590. * The collision margin around a soft object
  31591. */
  31592. margin?: number;
  31593. /**
  31594. * The collision margin around a soft object
  31595. */
  31596. damping?: number;
  31597. /**
  31598. * The path for a rope based on an extrusion
  31599. */
  31600. path?: any;
  31601. /**
  31602. * The shape of an extrusion used for a rope based on an extrusion
  31603. */
  31604. shape?: any;
  31605. }
  31606. /**
  31607. * Interface for a physics-enabled object
  31608. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31609. */
  31610. export interface IPhysicsEnabledObject {
  31611. /**
  31612. * The position of the physics-enabled object
  31613. */
  31614. position: Vector3;
  31615. /**
  31616. * The rotation of the physics-enabled object
  31617. */
  31618. rotationQuaternion: Nullable<Quaternion>;
  31619. /**
  31620. * The scale of the physics-enabled object
  31621. */
  31622. scaling: Vector3;
  31623. /**
  31624. * The rotation of the physics-enabled object
  31625. */
  31626. rotation?: Vector3;
  31627. /**
  31628. * The parent of the physics-enabled object
  31629. */
  31630. parent?: any;
  31631. /**
  31632. * The bounding info of the physics-enabled object
  31633. * @returns The bounding info of the physics-enabled object
  31634. */
  31635. getBoundingInfo(): BoundingInfo;
  31636. /**
  31637. * Computes the world matrix
  31638. * @param force Specifies if the world matrix should be computed by force
  31639. * @returns A world matrix
  31640. */
  31641. computeWorldMatrix(force: boolean): Matrix;
  31642. /**
  31643. * Gets the world matrix
  31644. * @returns A world matrix
  31645. */
  31646. getWorldMatrix?(): Matrix;
  31647. /**
  31648. * Gets the child meshes
  31649. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  31650. * @returns An array of abstract meshes
  31651. */
  31652. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  31653. /**
  31654. * Gets the vertex data
  31655. * @param kind The type of vertex data
  31656. * @returns A nullable array of numbers, or a float32 array
  31657. */
  31658. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  31659. /**
  31660. * Gets the indices from the mesh
  31661. * @returns A nullable array of index arrays
  31662. */
  31663. getIndices?(): Nullable<IndicesArray>;
  31664. /**
  31665. * Gets the scene from the mesh
  31666. * @returns the indices array or null
  31667. */
  31668. getScene?(): Scene;
  31669. /**
  31670. * Gets the absolute position from the mesh
  31671. * @returns the absolute position
  31672. */
  31673. getAbsolutePosition(): Vector3;
  31674. /**
  31675. * Gets the absolute pivot point from the mesh
  31676. * @returns the absolute pivot point
  31677. */
  31678. getAbsolutePivotPoint(): Vector3;
  31679. /**
  31680. * Rotates the mesh
  31681. * @param axis The axis of rotation
  31682. * @param amount The amount of rotation
  31683. * @param space The space of the rotation
  31684. * @returns The rotation transform node
  31685. */
  31686. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  31687. /**
  31688. * Translates the mesh
  31689. * @param axis The axis of translation
  31690. * @param distance The distance of translation
  31691. * @param space The space of the translation
  31692. * @returns The transform node
  31693. */
  31694. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  31695. /**
  31696. * Sets the absolute position of the mesh
  31697. * @param absolutePosition The absolute position of the mesh
  31698. * @returns The transform node
  31699. */
  31700. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  31701. /**
  31702. * Gets the class name of the mesh
  31703. * @returns The class name
  31704. */
  31705. getClassName(): string;
  31706. }
  31707. /**
  31708. * Represents a physics imposter
  31709. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31710. */
  31711. export class PhysicsImpostor {
  31712. /**
  31713. * The physics-enabled object used as the physics imposter
  31714. */
  31715. object: IPhysicsEnabledObject;
  31716. /**
  31717. * The type of the physics imposter
  31718. */
  31719. type: number;
  31720. private _options;
  31721. private _scene?;
  31722. /**
  31723. * The default object size of the imposter
  31724. */
  31725. static DEFAULT_OBJECT_SIZE: Vector3;
  31726. /**
  31727. * The identity quaternion of the imposter
  31728. */
  31729. static IDENTITY_QUATERNION: Quaternion;
  31730. /** @hidden */
  31731. _pluginData: any;
  31732. private _physicsEngine;
  31733. private _physicsBody;
  31734. private _bodyUpdateRequired;
  31735. private _onBeforePhysicsStepCallbacks;
  31736. private _onAfterPhysicsStepCallbacks;
  31737. /** @hidden */
  31738. _onPhysicsCollideCallbacks: Array<{
  31739. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor, point: Nullable<Vector3>) => void;
  31740. otherImpostors: Array<PhysicsImpostor>;
  31741. }>;
  31742. private _deltaPosition;
  31743. private _deltaRotation;
  31744. private _deltaRotationConjugated;
  31745. /** @hidden */
  31746. _isFromLine: boolean;
  31747. private _parent;
  31748. private _isDisposed;
  31749. private static _tmpVecs;
  31750. private static _tmpQuat;
  31751. /**
  31752. * Specifies if the physics imposter is disposed
  31753. */
  31754. get isDisposed(): boolean;
  31755. /**
  31756. * Gets the mass of the physics imposter
  31757. */
  31758. get mass(): number;
  31759. set mass(value: number);
  31760. /**
  31761. * Gets the coefficient of friction
  31762. */
  31763. get friction(): number;
  31764. /**
  31765. * Sets the coefficient of friction
  31766. */
  31767. set friction(value: number);
  31768. /**
  31769. * Gets the coefficient of restitution
  31770. */
  31771. get restitution(): number;
  31772. /**
  31773. * Sets the coefficient of restitution
  31774. */
  31775. set restitution(value: number);
  31776. /**
  31777. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  31778. */
  31779. get pressure(): number;
  31780. /**
  31781. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  31782. */
  31783. set pressure(value: number);
  31784. /**
  31785. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  31786. */
  31787. get stiffness(): number;
  31788. /**
  31789. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  31790. */
  31791. set stiffness(value: number);
  31792. /**
  31793. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  31794. */
  31795. get velocityIterations(): number;
  31796. /**
  31797. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  31798. */
  31799. set velocityIterations(value: number);
  31800. /**
  31801. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  31802. */
  31803. get positionIterations(): number;
  31804. /**
  31805. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  31806. */
  31807. set positionIterations(value: number);
  31808. /**
  31809. * The unique id of the physics imposter
  31810. * set by the physics engine when adding this impostor to the array
  31811. */
  31812. uniqueId: number;
  31813. /**
  31814. * @hidden
  31815. */
  31816. soft: boolean;
  31817. /**
  31818. * @hidden
  31819. */
  31820. segments: number;
  31821. private _joints;
  31822. /**
  31823. * Initializes the physics imposter
  31824. * @param object The physics-enabled object used as the physics imposter
  31825. * @param type The type of the physics imposter
  31826. * @param _options The options for the physics imposter
  31827. * @param _scene The Babylon scene
  31828. */
  31829. constructor(
  31830. /**
  31831. * The physics-enabled object used as the physics imposter
  31832. */
  31833. object: IPhysicsEnabledObject,
  31834. /**
  31835. * The type of the physics imposter
  31836. */
  31837. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  31838. /**
  31839. * This function will completly initialize this impostor.
  31840. * It will create a new body - but only if this mesh has no parent.
  31841. * If it has, this impostor will not be used other than to define the impostor
  31842. * of the child mesh.
  31843. * @hidden
  31844. */
  31845. _init(): void;
  31846. private _getPhysicsParent;
  31847. /**
  31848. * Should a new body be generated.
  31849. * @returns boolean specifying if body initialization is required
  31850. */
  31851. isBodyInitRequired(): boolean;
  31852. /**
  31853. * Sets the updated scaling
  31854. * @param updated Specifies if the scaling is updated
  31855. */
  31856. setScalingUpdated(): void;
  31857. /**
  31858. * Force a regeneration of this or the parent's impostor's body.
  31859. * Use under cautious - This will remove all joints already implemented.
  31860. */
  31861. forceUpdate(): void;
  31862. /**
  31863. * Gets the body that holds this impostor. Either its own, or its parent.
  31864. */
  31865. get physicsBody(): any;
  31866. /**
  31867. * Get the parent of the physics imposter
  31868. * @returns Physics imposter or null
  31869. */
  31870. get parent(): Nullable<PhysicsImpostor>;
  31871. /**
  31872. * Sets the parent of the physics imposter
  31873. */
  31874. set parent(value: Nullable<PhysicsImpostor>);
  31875. /**
  31876. * Set the physics body. Used mainly by the physics engine/plugin
  31877. */
  31878. set physicsBody(physicsBody: any);
  31879. /**
  31880. * Resets the update flags
  31881. */
  31882. resetUpdateFlags(): void;
  31883. /**
  31884. * Gets the object extend size
  31885. * @returns the object extend size
  31886. */
  31887. getObjectExtendSize(): Vector3;
  31888. /**
  31889. * Gets the object center
  31890. * @returns The object center
  31891. */
  31892. getObjectCenter(): Vector3;
  31893. /**
  31894. * Get a specific parameter from the options parameters
  31895. * @param paramName The object parameter name
  31896. * @returns The object parameter
  31897. */
  31898. getParam(paramName: string): any;
  31899. /**
  31900. * Sets a specific parameter in the options given to the physics plugin
  31901. * @param paramName The parameter name
  31902. * @param value The value of the parameter
  31903. */
  31904. setParam(paramName: string, value: number): void;
  31905. /**
  31906. * Specifically change the body's mass option. Won't recreate the physics body object
  31907. * @param mass The mass of the physics imposter
  31908. */
  31909. setMass(mass: number): void;
  31910. /**
  31911. * Gets the linear velocity
  31912. * @returns linear velocity or null
  31913. */
  31914. getLinearVelocity(): Nullable<Vector3>;
  31915. /**
  31916. * Sets the linear velocity
  31917. * @param velocity linear velocity or null
  31918. */
  31919. setLinearVelocity(velocity: Nullable<Vector3>): void;
  31920. /**
  31921. * Gets the angular velocity
  31922. * @returns angular velocity or null
  31923. */
  31924. getAngularVelocity(): Nullable<Vector3>;
  31925. /**
  31926. * Sets the angular velocity
  31927. * @param velocity The velocity or null
  31928. */
  31929. setAngularVelocity(velocity: Nullable<Vector3>): void;
  31930. /**
  31931. * Execute a function with the physics plugin native code
  31932. * Provide a function the will have two variables - the world object and the physics body object
  31933. * @param func The function to execute with the physics plugin native code
  31934. */
  31935. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  31936. /**
  31937. * Register a function that will be executed before the physics world is stepping forward
  31938. * @param func The function to execute before the physics world is stepped forward
  31939. */
  31940. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  31941. /**
  31942. * Unregister a function that will be executed before the physics world is stepping forward
  31943. * @param func The function to execute before the physics world is stepped forward
  31944. */
  31945. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  31946. /**
  31947. * Register a function that will be executed after the physics step
  31948. * @param func The function to execute after physics step
  31949. */
  31950. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  31951. /**
  31952. * Unregisters a function that will be executed after the physics step
  31953. * @param func The function to execute after physics step
  31954. */
  31955. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  31956. /**
  31957. * register a function that will be executed when this impostor collides against a different body
  31958. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  31959. * @param func Callback that is executed on collision
  31960. */
  31961. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  31962. /**
  31963. * Unregisters the physics imposter on contact
  31964. * @param collideAgainst The physics object to collide against
  31965. * @param func Callback to execute on collision
  31966. */
  31967. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  31968. private _tmpQuat;
  31969. private _tmpQuat2;
  31970. /**
  31971. * Get the parent rotation
  31972. * @returns The parent rotation
  31973. */
  31974. getParentsRotation(): Quaternion;
  31975. /**
  31976. * this function is executed by the physics engine.
  31977. */
  31978. beforeStep: () => void;
  31979. /**
  31980. * this function is executed by the physics engine
  31981. */
  31982. afterStep: () => void;
  31983. /**
  31984. * Legacy collision detection event support
  31985. */
  31986. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  31987. /**
  31988. * event and body object due to cannon's event-based architecture.
  31989. */
  31990. onCollide: (e: {
  31991. body: any;
  31992. point: Nullable<Vector3>;
  31993. }) => void;
  31994. /**
  31995. * Apply a force
  31996. * @param force The force to apply
  31997. * @param contactPoint The contact point for the force
  31998. * @returns The physics imposter
  31999. */
  32000. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  32001. /**
  32002. * Apply an impulse
  32003. * @param force The impulse force
  32004. * @param contactPoint The contact point for the impulse force
  32005. * @returns The physics imposter
  32006. */
  32007. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  32008. /**
  32009. * A help function to create a joint
  32010. * @param otherImpostor A physics imposter used to create a joint
  32011. * @param jointType The type of joint
  32012. * @param jointData The data for the joint
  32013. * @returns The physics imposter
  32014. */
  32015. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  32016. /**
  32017. * Add a joint to this impostor with a different impostor
  32018. * @param otherImpostor A physics imposter used to add a joint
  32019. * @param joint The joint to add
  32020. * @returns The physics imposter
  32021. */
  32022. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  32023. /**
  32024. * Add an anchor to a cloth impostor
  32025. * @param otherImpostor rigid impostor to anchor to
  32026. * @param width ratio across width from 0 to 1
  32027. * @param height ratio up height from 0 to 1
  32028. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  32029. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  32030. * @returns impostor the soft imposter
  32031. */
  32032. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  32033. /**
  32034. * Add a hook to a rope impostor
  32035. * @param otherImpostor rigid impostor to anchor to
  32036. * @param length ratio across rope from 0 to 1
  32037. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  32038. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  32039. * @returns impostor the rope imposter
  32040. */
  32041. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  32042. /**
  32043. * Will keep this body still, in a sleep mode.
  32044. * @returns the physics imposter
  32045. */
  32046. sleep(): PhysicsImpostor;
  32047. /**
  32048. * Wake the body up.
  32049. * @returns The physics imposter
  32050. */
  32051. wakeUp(): PhysicsImpostor;
  32052. /**
  32053. * Clones the physics imposter
  32054. * @param newObject The physics imposter clones to this physics-enabled object
  32055. * @returns A nullable physics imposter
  32056. */
  32057. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  32058. /**
  32059. * Disposes the physics imposter
  32060. */
  32061. dispose(): void;
  32062. /**
  32063. * Sets the delta position
  32064. * @param position The delta position amount
  32065. */
  32066. setDeltaPosition(position: Vector3): void;
  32067. /**
  32068. * Sets the delta rotation
  32069. * @param rotation The delta rotation amount
  32070. */
  32071. setDeltaRotation(rotation: Quaternion): void;
  32072. /**
  32073. * Gets the box size of the physics imposter and stores the result in the input parameter
  32074. * @param result Stores the box size
  32075. * @returns The physics imposter
  32076. */
  32077. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  32078. /**
  32079. * Gets the radius of the physics imposter
  32080. * @returns Radius of the physics imposter
  32081. */
  32082. getRadius(): number;
  32083. /**
  32084. * Sync a bone with this impostor
  32085. * @param bone The bone to sync to the impostor.
  32086. * @param boneMesh The mesh that the bone is influencing.
  32087. * @param jointPivot The pivot of the joint / bone in local space.
  32088. * @param distToJoint Optional distance from the impostor to the joint.
  32089. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  32090. */
  32091. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  32092. /**
  32093. * Sync impostor to a bone
  32094. * @param bone The bone that the impostor will be synced to.
  32095. * @param boneMesh The mesh that the bone is influencing.
  32096. * @param jointPivot The pivot of the joint / bone in local space.
  32097. * @param distToJoint Optional distance from the impostor to the joint.
  32098. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  32099. * @param boneAxis Optional vector3 axis the bone is aligned with
  32100. */
  32101. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  32102. /**
  32103. * No-Imposter type
  32104. */
  32105. static NoImpostor: number;
  32106. /**
  32107. * Sphere-Imposter type
  32108. */
  32109. static SphereImpostor: number;
  32110. /**
  32111. * Box-Imposter type
  32112. */
  32113. static BoxImpostor: number;
  32114. /**
  32115. * Plane-Imposter type
  32116. */
  32117. static PlaneImpostor: number;
  32118. /**
  32119. * Mesh-imposter type
  32120. */
  32121. static MeshImpostor: number;
  32122. /**
  32123. * Capsule-Impostor type (Ammo.js plugin only)
  32124. */
  32125. static CapsuleImpostor: number;
  32126. /**
  32127. * Cylinder-Imposter type
  32128. */
  32129. static CylinderImpostor: number;
  32130. /**
  32131. * Particle-Imposter type
  32132. */
  32133. static ParticleImpostor: number;
  32134. /**
  32135. * Heightmap-Imposter type
  32136. */
  32137. static HeightmapImpostor: number;
  32138. /**
  32139. * ConvexHull-Impostor type (Ammo.js plugin only)
  32140. */
  32141. static ConvexHullImpostor: number;
  32142. /**
  32143. * Custom-Imposter type (Ammo.js plugin only)
  32144. */
  32145. static CustomImpostor: number;
  32146. /**
  32147. * Rope-Imposter type
  32148. */
  32149. static RopeImpostor: number;
  32150. /**
  32151. * Cloth-Imposter type
  32152. */
  32153. static ClothImpostor: number;
  32154. /**
  32155. * Softbody-Imposter type
  32156. */
  32157. static SoftbodyImpostor: number;
  32158. }
  32159. }
  32160. declare module BABYLON {
  32161. /**
  32162. * @hidden
  32163. **/
  32164. export class _CreationDataStorage {
  32165. closePath?: boolean;
  32166. closeArray?: boolean;
  32167. idx: number[];
  32168. dashSize: number;
  32169. gapSize: number;
  32170. path3D: Path3D;
  32171. pathArray: Vector3[][];
  32172. arc: number;
  32173. radius: number;
  32174. cap: number;
  32175. tessellation: number;
  32176. }
  32177. /**
  32178. * @hidden
  32179. **/
  32180. class _InstanceDataStorage {
  32181. visibleInstances: any;
  32182. batchCache: _InstancesBatch;
  32183. instancesBufferSize: number;
  32184. instancesBuffer: Nullable<Buffer>;
  32185. instancesData: Float32Array;
  32186. overridenInstanceCount: number;
  32187. isFrozen: boolean;
  32188. previousBatch: Nullable<_InstancesBatch>;
  32189. hardwareInstancedRendering: boolean;
  32190. sideOrientation: number;
  32191. manualUpdate: boolean;
  32192. previousRenderId: number;
  32193. }
  32194. /**
  32195. * @hidden
  32196. **/
  32197. export class _InstancesBatch {
  32198. mustReturn: boolean;
  32199. visibleInstances: Nullable<InstancedMesh[]>[];
  32200. renderSelf: boolean[];
  32201. hardwareInstancedRendering: boolean[];
  32202. }
  32203. /**
  32204. * @hidden
  32205. **/
  32206. class _ThinInstanceDataStorage {
  32207. instancesCount: number;
  32208. matrixBuffer: Nullable<Buffer>;
  32209. matrixBufferSize: number;
  32210. matrixData: Nullable<Float32Array>;
  32211. boundingVectors: Array<Vector3>;
  32212. worldMatrices: Nullable<Matrix[]>;
  32213. }
  32214. /**
  32215. * Class used to represent renderable models
  32216. */
  32217. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  32218. /**
  32219. * Mesh side orientation : usually the external or front surface
  32220. */
  32221. static readonly FRONTSIDE: number;
  32222. /**
  32223. * Mesh side orientation : usually the internal or back surface
  32224. */
  32225. static readonly BACKSIDE: number;
  32226. /**
  32227. * Mesh side orientation : both internal and external or front and back surfaces
  32228. */
  32229. static readonly DOUBLESIDE: number;
  32230. /**
  32231. * Mesh side orientation : by default, `FRONTSIDE`
  32232. */
  32233. static readonly DEFAULTSIDE: number;
  32234. /**
  32235. * Mesh cap setting : no cap
  32236. */
  32237. static readonly NO_CAP: number;
  32238. /**
  32239. * Mesh cap setting : one cap at the beginning of the mesh
  32240. */
  32241. static readonly CAP_START: number;
  32242. /**
  32243. * Mesh cap setting : one cap at the end of the mesh
  32244. */
  32245. static readonly CAP_END: number;
  32246. /**
  32247. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  32248. */
  32249. static readonly CAP_ALL: number;
  32250. /**
  32251. * Mesh pattern setting : no flip or rotate
  32252. */
  32253. static readonly NO_FLIP: number;
  32254. /**
  32255. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  32256. */
  32257. static readonly FLIP_TILE: number;
  32258. /**
  32259. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  32260. */
  32261. static readonly ROTATE_TILE: number;
  32262. /**
  32263. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  32264. */
  32265. static readonly FLIP_ROW: number;
  32266. /**
  32267. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  32268. */
  32269. static readonly ROTATE_ROW: number;
  32270. /**
  32271. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  32272. */
  32273. static readonly FLIP_N_ROTATE_TILE: number;
  32274. /**
  32275. * Mesh pattern setting : rotate pattern and rotate
  32276. */
  32277. static readonly FLIP_N_ROTATE_ROW: number;
  32278. /**
  32279. * Mesh tile positioning : part tiles same on left/right or top/bottom
  32280. */
  32281. static readonly CENTER: number;
  32282. /**
  32283. * Mesh tile positioning : part tiles on left
  32284. */
  32285. static readonly LEFT: number;
  32286. /**
  32287. * Mesh tile positioning : part tiles on right
  32288. */
  32289. static readonly RIGHT: number;
  32290. /**
  32291. * Mesh tile positioning : part tiles on top
  32292. */
  32293. static readonly TOP: number;
  32294. /**
  32295. * Mesh tile positioning : part tiles on bottom
  32296. */
  32297. static readonly BOTTOM: number;
  32298. /**
  32299. * Gets the default side orientation.
  32300. * @param orientation the orientation to value to attempt to get
  32301. * @returns the default orientation
  32302. * @hidden
  32303. */
  32304. static _GetDefaultSideOrientation(orientation?: number): number;
  32305. private _internalMeshDataInfo;
  32306. get computeBonesUsingShaders(): boolean;
  32307. set computeBonesUsingShaders(value: boolean);
  32308. /**
  32309. * An event triggered before rendering the mesh
  32310. */
  32311. get onBeforeRenderObservable(): Observable<Mesh>;
  32312. /**
  32313. * An event triggered before binding the mesh
  32314. */
  32315. get onBeforeBindObservable(): Observable<Mesh>;
  32316. /**
  32317. * An event triggered after rendering the mesh
  32318. */
  32319. get onAfterRenderObservable(): Observable<Mesh>;
  32320. /**
  32321. * An event triggered before drawing the mesh
  32322. */
  32323. get onBeforeDrawObservable(): Observable<Mesh>;
  32324. private _onBeforeDrawObserver;
  32325. /**
  32326. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  32327. */
  32328. set onBeforeDraw(callback: () => void);
  32329. get hasInstances(): boolean;
  32330. get hasThinInstances(): boolean;
  32331. /**
  32332. * Gets the delay loading state of the mesh (when delay loading is turned on)
  32333. * @see https://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  32334. */
  32335. delayLoadState: number;
  32336. /**
  32337. * Gets the list of instances created from this mesh
  32338. * it is not supposed to be modified manually.
  32339. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  32340. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  32341. */
  32342. instances: InstancedMesh[];
  32343. /**
  32344. * Gets the file containing delay loading data for this mesh
  32345. */
  32346. delayLoadingFile: string;
  32347. /** @hidden */
  32348. _binaryInfo: any;
  32349. /**
  32350. * User defined function used to change how LOD level selection is done
  32351. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  32352. */
  32353. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  32354. /**
  32355. * Gets or sets the morph target manager
  32356. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  32357. */
  32358. get morphTargetManager(): Nullable<MorphTargetManager>;
  32359. set morphTargetManager(value: Nullable<MorphTargetManager>);
  32360. /** @hidden */
  32361. _creationDataStorage: Nullable<_CreationDataStorage>;
  32362. /** @hidden */
  32363. _geometry: Nullable<Geometry>;
  32364. /** @hidden */
  32365. _delayInfo: Array<string>;
  32366. /** @hidden */
  32367. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  32368. /** @hidden */
  32369. _instanceDataStorage: _InstanceDataStorage;
  32370. /** @hidden */
  32371. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  32372. private _effectiveMaterial;
  32373. /** @hidden */
  32374. _shouldGenerateFlatShading: boolean;
  32375. /** @hidden */
  32376. _originalBuilderSideOrientation: number;
  32377. /**
  32378. * Use this property to change the original side orientation defined at construction time
  32379. */
  32380. overrideMaterialSideOrientation: Nullable<number>;
  32381. /**
  32382. * Gets the source mesh (the one used to clone this one from)
  32383. */
  32384. get source(): Nullable<Mesh>;
  32385. /**
  32386. * Gets the list of clones of this mesh
  32387. * The scene must have been constructed with useClonedMeshMap=true for this to work!
  32388. * Note that useClonedMeshMap=true is the default setting
  32389. */
  32390. get cloneMeshMap(): Nullable<{
  32391. [id: string]: Mesh | undefined;
  32392. }>;
  32393. /**
  32394. * Gets or sets a boolean indicating that this mesh does not use index buffer
  32395. */
  32396. get isUnIndexed(): boolean;
  32397. set isUnIndexed(value: boolean);
  32398. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  32399. get worldMatrixInstancedBuffer(): Float32Array;
  32400. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  32401. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  32402. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  32403. /**
  32404. * @constructor
  32405. * @param name The value used by scene.getMeshByName() to do a lookup.
  32406. * @param scene The scene to add this mesh to.
  32407. * @param parent The parent of this mesh, if it has one
  32408. * @param source An optional Mesh from which geometry is shared, cloned.
  32409. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  32410. * When false, achieved by calling a clone(), also passing False.
  32411. * This will make creation of children, recursive.
  32412. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  32413. */
  32414. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  32415. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  32416. doNotInstantiate: boolean;
  32417. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  32418. /**
  32419. * Gets the class name
  32420. * @returns the string "Mesh".
  32421. */
  32422. getClassName(): string;
  32423. /** @hidden */
  32424. get _isMesh(): boolean;
  32425. /**
  32426. * Returns a description of this mesh
  32427. * @param fullDetails define if full details about this mesh must be used
  32428. * @returns a descriptive string representing this mesh
  32429. */
  32430. toString(fullDetails?: boolean): string;
  32431. /** @hidden */
  32432. _unBindEffect(): void;
  32433. /**
  32434. * Gets a boolean indicating if this mesh has LOD
  32435. */
  32436. get hasLODLevels(): boolean;
  32437. /**
  32438. * Gets the list of MeshLODLevel associated with the current mesh
  32439. * @returns an array of MeshLODLevel
  32440. */
  32441. getLODLevels(): MeshLODLevel[];
  32442. private _sortLODLevels;
  32443. /**
  32444. * Add a mesh as LOD level triggered at the given distance.
  32445. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  32446. * @param distance The distance from the center of the object to show this level
  32447. * @param mesh The mesh to be added as LOD level (can be null)
  32448. * @return This mesh (for chaining)
  32449. */
  32450. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  32451. /**
  32452. * Returns the LOD level mesh at the passed distance or null if not found.
  32453. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  32454. * @param distance The distance from the center of the object to show this level
  32455. * @returns a Mesh or `null`
  32456. */
  32457. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  32458. /**
  32459. * Remove a mesh from the LOD array
  32460. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  32461. * @param mesh defines the mesh to be removed
  32462. * @return This mesh (for chaining)
  32463. */
  32464. removeLODLevel(mesh: Mesh): Mesh;
  32465. /**
  32466. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  32467. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  32468. * @param camera defines the camera to use to compute distance
  32469. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  32470. * @return This mesh (for chaining)
  32471. */
  32472. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  32473. /**
  32474. * Gets the mesh internal Geometry object
  32475. */
  32476. get geometry(): Nullable<Geometry>;
  32477. /**
  32478. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  32479. * @returns the total number of vertices
  32480. */
  32481. getTotalVertices(): number;
  32482. /**
  32483. * Returns the content of an associated vertex buffer
  32484. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  32485. * - VertexBuffer.PositionKind
  32486. * - VertexBuffer.UVKind
  32487. * - VertexBuffer.UV2Kind
  32488. * - VertexBuffer.UV3Kind
  32489. * - VertexBuffer.UV4Kind
  32490. * - VertexBuffer.UV5Kind
  32491. * - VertexBuffer.UV6Kind
  32492. * - VertexBuffer.ColorKind
  32493. * - VertexBuffer.MatricesIndicesKind
  32494. * - VertexBuffer.MatricesIndicesExtraKind
  32495. * - VertexBuffer.MatricesWeightsKind
  32496. * - VertexBuffer.MatricesWeightsExtraKind
  32497. * @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
  32498. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  32499. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  32500. */
  32501. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  32502. /**
  32503. * Returns the mesh VertexBuffer object from the requested `kind`
  32504. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  32505. * - VertexBuffer.PositionKind
  32506. * - VertexBuffer.NormalKind
  32507. * - VertexBuffer.UVKind
  32508. * - VertexBuffer.UV2Kind
  32509. * - VertexBuffer.UV3Kind
  32510. * - VertexBuffer.UV4Kind
  32511. * - VertexBuffer.UV5Kind
  32512. * - VertexBuffer.UV6Kind
  32513. * - VertexBuffer.ColorKind
  32514. * - VertexBuffer.MatricesIndicesKind
  32515. * - VertexBuffer.MatricesIndicesExtraKind
  32516. * - VertexBuffer.MatricesWeightsKind
  32517. * - VertexBuffer.MatricesWeightsExtraKind
  32518. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  32519. */
  32520. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  32521. /**
  32522. * Tests if a specific vertex buffer is associated with this mesh
  32523. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  32524. * - VertexBuffer.PositionKind
  32525. * - VertexBuffer.NormalKind
  32526. * - VertexBuffer.UVKind
  32527. * - VertexBuffer.UV2Kind
  32528. * - VertexBuffer.UV3Kind
  32529. * - VertexBuffer.UV4Kind
  32530. * - VertexBuffer.UV5Kind
  32531. * - VertexBuffer.UV6Kind
  32532. * - VertexBuffer.ColorKind
  32533. * - VertexBuffer.MatricesIndicesKind
  32534. * - VertexBuffer.MatricesIndicesExtraKind
  32535. * - VertexBuffer.MatricesWeightsKind
  32536. * - VertexBuffer.MatricesWeightsExtraKind
  32537. * @returns a boolean
  32538. */
  32539. isVerticesDataPresent(kind: string): boolean;
  32540. /**
  32541. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  32542. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  32543. * - VertexBuffer.PositionKind
  32544. * - VertexBuffer.UVKind
  32545. * - VertexBuffer.UV2Kind
  32546. * - VertexBuffer.UV3Kind
  32547. * - VertexBuffer.UV4Kind
  32548. * - VertexBuffer.UV5Kind
  32549. * - VertexBuffer.UV6Kind
  32550. * - VertexBuffer.ColorKind
  32551. * - VertexBuffer.MatricesIndicesKind
  32552. * - VertexBuffer.MatricesIndicesExtraKind
  32553. * - VertexBuffer.MatricesWeightsKind
  32554. * - VertexBuffer.MatricesWeightsExtraKind
  32555. * @returns a boolean
  32556. */
  32557. isVertexBufferUpdatable(kind: string): boolean;
  32558. /**
  32559. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  32560. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  32561. * - VertexBuffer.PositionKind
  32562. * - VertexBuffer.NormalKind
  32563. * - VertexBuffer.UVKind
  32564. * - VertexBuffer.UV2Kind
  32565. * - VertexBuffer.UV3Kind
  32566. * - VertexBuffer.UV4Kind
  32567. * - VertexBuffer.UV5Kind
  32568. * - VertexBuffer.UV6Kind
  32569. * - VertexBuffer.ColorKind
  32570. * - VertexBuffer.MatricesIndicesKind
  32571. * - VertexBuffer.MatricesIndicesExtraKind
  32572. * - VertexBuffer.MatricesWeightsKind
  32573. * - VertexBuffer.MatricesWeightsExtraKind
  32574. * @returns an array of strings
  32575. */
  32576. getVerticesDataKinds(): string[];
  32577. /**
  32578. * Returns a positive integer : the total number of indices in this mesh geometry.
  32579. * @returns the numner of indices or zero if the mesh has no geometry.
  32580. */
  32581. getTotalIndices(): number;
  32582. /**
  32583. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  32584. * @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.
  32585. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  32586. * @returns the indices array or an empty array if the mesh has no geometry
  32587. */
  32588. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  32589. get isBlocked(): boolean;
  32590. /**
  32591. * Determine if the current mesh is ready to be rendered
  32592. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  32593. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  32594. * @returns true if all associated assets are ready (material, textures, shaders)
  32595. */
  32596. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  32597. /**
  32598. * 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.
  32599. */
  32600. get areNormalsFrozen(): boolean;
  32601. /**
  32602. * 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.
  32603. * @returns the current mesh
  32604. */
  32605. freezeNormals(): Mesh;
  32606. /**
  32607. * 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
  32608. * @returns the current mesh
  32609. */
  32610. unfreezeNormals(): Mesh;
  32611. /**
  32612. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  32613. */
  32614. set overridenInstanceCount(count: number);
  32615. /** @hidden */
  32616. _preActivate(): Mesh;
  32617. /** @hidden */
  32618. _preActivateForIntermediateRendering(renderId: number): Mesh;
  32619. /** @hidden */
  32620. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  32621. protected _afterComputeWorldMatrix(): void;
  32622. /** @hidden */
  32623. _postActivate(): void;
  32624. /**
  32625. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  32626. * This means the mesh underlying bounding box and sphere are recomputed.
  32627. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  32628. * @returns the current mesh
  32629. */
  32630. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  32631. /** @hidden */
  32632. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  32633. /**
  32634. * This function will subdivide the mesh into multiple submeshes
  32635. * @param count defines the expected number of submeshes
  32636. */
  32637. subdivide(count: number): void;
  32638. /**
  32639. * Copy a FloatArray into a specific associated vertex buffer
  32640. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  32641. * - VertexBuffer.PositionKind
  32642. * - VertexBuffer.UVKind
  32643. * - VertexBuffer.UV2Kind
  32644. * - VertexBuffer.UV3Kind
  32645. * - VertexBuffer.UV4Kind
  32646. * - VertexBuffer.UV5Kind
  32647. * - VertexBuffer.UV6Kind
  32648. * - VertexBuffer.ColorKind
  32649. * - VertexBuffer.MatricesIndicesKind
  32650. * - VertexBuffer.MatricesIndicesExtraKind
  32651. * - VertexBuffer.MatricesWeightsKind
  32652. * - VertexBuffer.MatricesWeightsExtraKind
  32653. * @param data defines the data source
  32654. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  32655. * @param stride defines the data stride size (can be null)
  32656. * @returns the current mesh
  32657. */
  32658. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  32659. /**
  32660. * Delete a vertex buffer associated with this mesh
  32661. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  32662. * - VertexBuffer.PositionKind
  32663. * - VertexBuffer.UVKind
  32664. * - VertexBuffer.UV2Kind
  32665. * - VertexBuffer.UV3Kind
  32666. * - VertexBuffer.UV4Kind
  32667. * - VertexBuffer.UV5Kind
  32668. * - VertexBuffer.UV6Kind
  32669. * - VertexBuffer.ColorKind
  32670. * - VertexBuffer.MatricesIndicesKind
  32671. * - VertexBuffer.MatricesIndicesExtraKind
  32672. * - VertexBuffer.MatricesWeightsKind
  32673. * - VertexBuffer.MatricesWeightsExtraKind
  32674. */
  32675. removeVerticesData(kind: string): void;
  32676. /**
  32677. * Flags an associated vertex buffer as updatable
  32678. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  32679. * - VertexBuffer.PositionKind
  32680. * - VertexBuffer.UVKind
  32681. * - VertexBuffer.UV2Kind
  32682. * - VertexBuffer.UV3Kind
  32683. * - VertexBuffer.UV4Kind
  32684. * - VertexBuffer.UV5Kind
  32685. * - VertexBuffer.UV6Kind
  32686. * - VertexBuffer.ColorKind
  32687. * - VertexBuffer.MatricesIndicesKind
  32688. * - VertexBuffer.MatricesIndicesExtraKind
  32689. * - VertexBuffer.MatricesWeightsKind
  32690. * - VertexBuffer.MatricesWeightsExtraKind
  32691. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  32692. */
  32693. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  32694. /**
  32695. * Sets the mesh global Vertex Buffer
  32696. * @param buffer defines the buffer to use
  32697. * @returns the current mesh
  32698. */
  32699. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  32700. /**
  32701. * Update a specific associated vertex buffer
  32702. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  32703. * - VertexBuffer.PositionKind
  32704. * - VertexBuffer.UVKind
  32705. * - VertexBuffer.UV2Kind
  32706. * - VertexBuffer.UV3Kind
  32707. * - VertexBuffer.UV4Kind
  32708. * - VertexBuffer.UV5Kind
  32709. * - VertexBuffer.UV6Kind
  32710. * - VertexBuffer.ColorKind
  32711. * - VertexBuffer.MatricesIndicesKind
  32712. * - VertexBuffer.MatricesIndicesExtraKind
  32713. * - VertexBuffer.MatricesWeightsKind
  32714. * - VertexBuffer.MatricesWeightsExtraKind
  32715. * @param data defines the data source
  32716. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  32717. * @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)
  32718. * @returns the current mesh
  32719. */
  32720. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  32721. /**
  32722. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  32723. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  32724. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  32725. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  32726. * @returns the current mesh
  32727. */
  32728. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  32729. /**
  32730. * Creates a un-shared specific occurence of the geometry for the mesh.
  32731. * @returns the current mesh
  32732. */
  32733. makeGeometryUnique(): Mesh;
  32734. /**
  32735. * Set the index buffer of this mesh
  32736. * @param indices defines the source data
  32737. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  32738. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  32739. * @returns the current mesh
  32740. */
  32741. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  32742. /**
  32743. * Update the current index buffer
  32744. * @param indices defines the source data
  32745. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  32746. * @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)
  32747. * @returns the current mesh
  32748. */
  32749. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  32750. /**
  32751. * Invert the geometry to move from a right handed system to a left handed one.
  32752. * @returns the current mesh
  32753. */
  32754. toLeftHanded(): Mesh;
  32755. /** @hidden */
  32756. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  32757. /** @hidden */
  32758. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  32759. /**
  32760. * Registers for this mesh a javascript function called just before the rendering process
  32761. * @param func defines the function to call before rendering this mesh
  32762. * @returns the current mesh
  32763. */
  32764. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  32765. /**
  32766. * Disposes a previously registered javascript function called before the rendering
  32767. * @param func defines the function to remove
  32768. * @returns the current mesh
  32769. */
  32770. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  32771. /**
  32772. * Registers for this mesh a javascript function called just after the rendering is complete
  32773. * @param func defines the function to call after rendering this mesh
  32774. * @returns the current mesh
  32775. */
  32776. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  32777. /**
  32778. * Disposes a previously registered javascript function called after the rendering.
  32779. * @param func defines the function to remove
  32780. * @returns the current mesh
  32781. */
  32782. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  32783. /** @hidden */
  32784. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  32785. /** @hidden */
  32786. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  32787. /** @hidden */
  32788. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  32789. /** @hidden */
  32790. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  32791. /** @hidden */
  32792. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  32793. /** @hidden */
  32794. _rebuild(): void;
  32795. /** @hidden */
  32796. _freeze(): void;
  32797. /** @hidden */
  32798. _unFreeze(): void;
  32799. /**
  32800. * 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
  32801. * @param subMesh defines the subMesh to render
  32802. * @param enableAlphaMode defines if alpha mode can be changed
  32803. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  32804. * @returns the current mesh
  32805. */
  32806. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  32807. private _onBeforeDraw;
  32808. /**
  32809. * Renormalize the mesh and patch it up if there are no weights
  32810. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  32811. * However in the case of zero weights then we set just a single influence to 1.
  32812. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  32813. */
  32814. cleanMatrixWeights(): void;
  32815. private normalizeSkinFourWeights;
  32816. private normalizeSkinWeightsAndExtra;
  32817. /**
  32818. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  32819. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  32820. * the user know there was an issue with importing the mesh
  32821. * @returns a validation object with skinned, valid and report string
  32822. */
  32823. validateSkinning(): {
  32824. skinned: boolean;
  32825. valid: boolean;
  32826. report: string;
  32827. };
  32828. /** @hidden */
  32829. _checkDelayState(): Mesh;
  32830. private _queueLoad;
  32831. /**
  32832. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  32833. * A mesh is in the frustum if its bounding box intersects the frustum
  32834. * @param frustumPlanes defines the frustum to test
  32835. * @returns true if the mesh is in the frustum planes
  32836. */
  32837. isInFrustum(frustumPlanes: Plane[]): boolean;
  32838. /**
  32839. * Sets the mesh material by the material or multiMaterial `id` property
  32840. * @param id is a string identifying the material or the multiMaterial
  32841. * @returns the current mesh
  32842. */
  32843. setMaterialByID(id: string): Mesh;
  32844. /**
  32845. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  32846. * @returns an array of IAnimatable
  32847. */
  32848. getAnimatables(): IAnimatable[];
  32849. /**
  32850. * Modifies the mesh geometry according to the passed transformation matrix.
  32851. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  32852. * The mesh normals are modified using the same transformation.
  32853. * Note that, under the hood, this method sets a new VertexBuffer each call.
  32854. * @param transform defines the transform matrix to use
  32855. * @see https://doc.babylonjs.com/resources/baking_transformations
  32856. * @returns the current mesh
  32857. */
  32858. bakeTransformIntoVertices(transform: Matrix): Mesh;
  32859. /**
  32860. * Modifies the mesh geometry according to its own current World Matrix.
  32861. * The mesh World Matrix is then reset.
  32862. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  32863. * Note that, under the hood, this method sets a new VertexBuffer each call.
  32864. * @see https://doc.babylonjs.com/resources/baking_transformations
  32865. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  32866. * @returns the current mesh
  32867. */
  32868. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  32869. /** @hidden */
  32870. get _positions(): Nullable<Vector3[]>;
  32871. /** @hidden */
  32872. _resetPointsArrayCache(): Mesh;
  32873. /** @hidden */
  32874. _generatePointsArray(): boolean;
  32875. /**
  32876. * Returns a new Mesh object generated from the current mesh properties.
  32877. * This method must not get confused with createInstance()
  32878. * @param name is a string, the name given to the new mesh
  32879. * @param newParent can be any Node object (default `null`)
  32880. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  32881. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  32882. * @returns a new mesh
  32883. */
  32884. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  32885. /**
  32886. * Releases resources associated with this mesh.
  32887. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  32888. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  32889. */
  32890. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  32891. /** @hidden */
  32892. _disposeInstanceSpecificData(): void;
  32893. /** @hidden */
  32894. _disposeThinInstanceSpecificData(): void;
  32895. /**
  32896. * Modifies the mesh geometry according to a displacement map.
  32897. * 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.
  32898. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  32899. * @param url is a string, the URL from the image file is to be downloaded.
  32900. * @param minHeight is the lower limit of the displacement.
  32901. * @param maxHeight is the upper limit of the displacement.
  32902. * @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.
  32903. * @param uvOffset is an optional vector2 used to offset UV.
  32904. * @param uvScale is an optional vector2 used to scale UV.
  32905. * @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.
  32906. * @returns the Mesh.
  32907. */
  32908. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  32909. /**
  32910. * Modifies the mesh geometry according to a displacementMap buffer.
  32911. * 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.
  32912. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  32913. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  32914. * @param heightMapWidth is the width of the buffer image.
  32915. * @param heightMapHeight is the height of the buffer image.
  32916. * @param minHeight is the lower limit of the displacement.
  32917. * @param maxHeight is the upper limit of the displacement.
  32918. * @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.
  32919. * @param uvOffset is an optional vector2 used to offset UV.
  32920. * @param uvScale is an optional vector2 used to scale UV.
  32921. * @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.
  32922. * @returns the Mesh.
  32923. */
  32924. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  32925. /**
  32926. * Modify the mesh to get a flat shading rendering.
  32927. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  32928. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  32929. * @returns current mesh
  32930. */
  32931. convertToFlatShadedMesh(): Mesh;
  32932. /**
  32933. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  32934. * In other words, more vertices, no more indices and a single bigger VBO.
  32935. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  32936. * @returns current mesh
  32937. */
  32938. convertToUnIndexedMesh(): Mesh;
  32939. /**
  32940. * Inverses facet orientations.
  32941. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  32942. * @param flipNormals will also inverts the normals
  32943. * @returns current mesh
  32944. */
  32945. flipFaces(flipNormals?: boolean): Mesh;
  32946. /**
  32947. * Increase the number of facets and hence vertices in a mesh
  32948. * Vertex normals are interpolated from existing vertex normals
  32949. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  32950. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  32951. */
  32952. increaseVertices(numberPerEdge: number): void;
  32953. /**
  32954. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  32955. * This will undo any application of covertToFlatShadedMesh
  32956. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  32957. */
  32958. forceSharedVertices(): void;
  32959. /** @hidden */
  32960. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  32961. /** @hidden */
  32962. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  32963. /**
  32964. * Creates a new InstancedMesh object from the mesh model.
  32965. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  32966. * @param name defines the name of the new instance
  32967. * @returns a new InstancedMesh
  32968. */
  32969. createInstance(name: string): InstancedMesh;
  32970. /**
  32971. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  32972. * After this call, all the mesh instances have the same submeshes than the current mesh.
  32973. * @returns the current mesh
  32974. */
  32975. synchronizeInstances(): Mesh;
  32976. /**
  32977. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  32978. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  32979. * This should be used together with the simplification to avoid disappearing triangles.
  32980. * @param successCallback an optional success callback to be called after the optimization finished.
  32981. * @returns the current mesh
  32982. */
  32983. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  32984. /**
  32985. * Serialize current mesh
  32986. * @param serializationObject defines the object which will receive the serialization data
  32987. */
  32988. serialize(serializationObject: any): void;
  32989. /** @hidden */
  32990. _syncGeometryWithMorphTargetManager(): void;
  32991. /** @hidden */
  32992. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  32993. /**
  32994. * Returns a new Mesh object parsed from the source provided.
  32995. * @param parsedMesh is the source
  32996. * @param scene defines the hosting scene
  32997. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  32998. * @returns a new Mesh
  32999. */
  33000. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  33001. /**
  33002. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  33003. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  33004. * @param name defines the name of the mesh to create
  33005. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  33006. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  33007. * @param closePath creates a seam between the first and the last points of each path of the path array
  33008. * @param offset is taken in account only if the `pathArray` is containing a single path
  33009. * @param scene defines the hosting scene
  33010. * @param updatable defines if the mesh must be flagged as updatable
  33011. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33012. * @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)
  33013. * @returns a new Mesh
  33014. */
  33015. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  33016. /**
  33017. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  33018. * @param name defines the name of the mesh to create
  33019. * @param radius sets the radius size (float) of the polygon (default 0.5)
  33020. * @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
  33021. * @param scene defines the hosting scene
  33022. * @param updatable defines if the mesh must be flagged as updatable
  33023. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33024. * @returns a new Mesh
  33025. */
  33026. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  33027. /**
  33028. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  33029. * @param name defines the name of the mesh to create
  33030. * @param size sets the size (float) of each box side (default 1)
  33031. * @param scene defines the hosting scene
  33032. * @param updatable defines if the mesh must be flagged as updatable
  33033. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33034. * @returns a new Mesh
  33035. */
  33036. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  33037. /**
  33038. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  33039. * @param name defines the name of the mesh to create
  33040. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  33041. * @param diameter sets the diameter size (float) of the sphere (default 1)
  33042. * @param scene defines the hosting scene
  33043. * @param updatable defines if the mesh must be flagged as updatable
  33044. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33045. * @returns a new Mesh
  33046. */
  33047. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  33048. /**
  33049. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  33050. * @param name defines the name of the mesh to create
  33051. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  33052. * @param diameter sets the diameter size (float) of the sphere (default 1)
  33053. * @param scene defines the hosting scene
  33054. * @returns a new Mesh
  33055. */
  33056. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  33057. /**
  33058. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  33059. * @param name defines the name of the mesh to create
  33060. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  33061. * @param diameterTop set the top cap diameter (floats, default 1)
  33062. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  33063. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  33064. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  33065. * @param scene defines the hosting scene
  33066. * @param updatable defines if the mesh must be flagged as updatable
  33067. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33068. * @returns a new Mesh
  33069. */
  33070. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  33071. /**
  33072. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  33073. * @param name defines the name of the mesh to create
  33074. * @param diameter sets the diameter size (float) of the torus (default 1)
  33075. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  33076. * @param tessellation sets the number of torus sides (postive integer, default 16)
  33077. * @param scene defines the hosting scene
  33078. * @param updatable defines if the mesh must be flagged as updatable
  33079. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33080. * @returns a new Mesh
  33081. */
  33082. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  33083. /**
  33084. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  33085. * @param name defines the name of the mesh to create
  33086. * @param radius sets the global radius size (float) of the torus knot (default 2)
  33087. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  33088. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  33089. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  33090. * @param p the number of windings on X axis (positive integers, default 2)
  33091. * @param q the number of windings on Y axis (positive integers, default 3)
  33092. * @param scene defines the hosting scene
  33093. * @param updatable defines if the mesh must be flagged as updatable
  33094. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33095. * @returns a new Mesh
  33096. */
  33097. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  33098. /**
  33099. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  33100. * @param name defines the name of the mesh to create
  33101. * @param points is an array successive Vector3
  33102. * @param scene defines the hosting scene
  33103. * @param updatable defines if the mesh must be flagged as updatable
  33104. * @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).
  33105. * @returns a new Mesh
  33106. */
  33107. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  33108. /**
  33109. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  33110. * @param name defines the name of the mesh to create
  33111. * @param points is an array successive Vector3
  33112. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  33113. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  33114. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  33115. * @param scene defines the hosting scene
  33116. * @param updatable defines if the mesh must be flagged as updatable
  33117. * @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)
  33118. * @returns a new Mesh
  33119. */
  33120. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  33121. /**
  33122. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  33123. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  33124. * 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.
  33125. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  33126. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  33127. * Remember you can only change the shape positions, not their number when updating a polygon.
  33128. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  33129. * @param name defines the name of the mesh to create
  33130. * @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
  33131. * @param scene defines the hosting scene
  33132. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  33133. * @param updatable defines if the mesh must be flagged as updatable
  33134. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33135. * @param earcutInjection can be used to inject your own earcut reference
  33136. * @returns a new Mesh
  33137. */
  33138. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  33139. /**
  33140. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  33141. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  33142. * @param name defines the name of the mesh to create
  33143. * @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
  33144. * @param depth defines the height of extrusion
  33145. * @param scene defines the hosting scene
  33146. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  33147. * @param updatable defines if the mesh must be flagged as updatable
  33148. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33149. * @param earcutInjection can be used to inject your own earcut reference
  33150. * @returns a new Mesh
  33151. */
  33152. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  33153. /**
  33154. * Creates an extruded shape mesh.
  33155. * 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
  33156. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  33157. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  33158. * @param name defines the name of the mesh to create
  33159. * @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
  33160. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  33161. * @param scale is the value to scale the shape
  33162. * @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
  33163. * @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
  33164. * @param scene defines the hosting scene
  33165. * @param updatable defines if the mesh must be flagged as updatable
  33166. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33167. * @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)
  33168. * @returns a new Mesh
  33169. */
  33170. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  33171. /**
  33172. * Creates an custom extruded shape mesh.
  33173. * The custom extrusion is a parametric shape.
  33174. * It has no predefined shape. Its final shape will depend on the input parameters.
  33175. * Please consider using the same method from the MeshBuilder class instead
  33176. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  33177. * @param name defines the name of the mesh to create
  33178. * @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
  33179. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  33180. * @param scaleFunction is a custom Javascript function called on each path point
  33181. * @param rotationFunction is a custom Javascript function called on each path point
  33182. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  33183. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  33184. * @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
  33185. * @param scene defines the hosting scene
  33186. * @param updatable defines if the mesh must be flagged as updatable
  33187. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33188. * @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)
  33189. * @returns a new Mesh
  33190. */
  33191. 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;
  33192. /**
  33193. * Creates lathe mesh.
  33194. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  33195. * Please consider using the same method from the MeshBuilder class instead
  33196. * @param name defines the name of the mesh to create
  33197. * @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
  33198. * @param radius is the radius value of the lathe
  33199. * @param tessellation is the side number of the lathe.
  33200. * @param scene defines the hosting scene
  33201. * @param updatable defines if the mesh must be flagged as updatable
  33202. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33203. * @returns a new Mesh
  33204. */
  33205. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  33206. /**
  33207. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  33208. * @param name defines the name of the mesh to create
  33209. * @param size sets the size (float) of both sides of the plane at once (default 1)
  33210. * @param scene defines the hosting scene
  33211. * @param updatable defines if the mesh must be flagged as updatable
  33212. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33213. * @returns a new Mesh
  33214. */
  33215. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  33216. /**
  33217. * Creates a ground mesh.
  33218. * Please consider using the same method from the MeshBuilder class instead
  33219. * @param name defines the name of the mesh to create
  33220. * @param width set the width of the ground
  33221. * @param height set the height of the ground
  33222. * @param subdivisions sets the number of subdivisions per side
  33223. * @param scene defines the hosting scene
  33224. * @param updatable defines if the mesh must be flagged as updatable
  33225. * @returns a new Mesh
  33226. */
  33227. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  33228. /**
  33229. * Creates a tiled ground mesh.
  33230. * Please consider using the same method from the MeshBuilder class instead
  33231. * @param name defines the name of the mesh to create
  33232. * @param xmin set the ground minimum X coordinate
  33233. * @param zmin set the ground minimum Y coordinate
  33234. * @param xmax set the ground maximum X coordinate
  33235. * @param zmax set the ground maximum Z coordinate
  33236. * @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
  33237. * @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
  33238. * @param scene defines the hosting scene
  33239. * @param updatable defines if the mesh must be flagged as updatable
  33240. * @returns a new Mesh
  33241. */
  33242. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  33243. w: number;
  33244. h: number;
  33245. }, precision: {
  33246. w: number;
  33247. h: number;
  33248. }, scene: Scene, updatable?: boolean): Mesh;
  33249. /**
  33250. * Creates a ground mesh from a height map.
  33251. * Please consider using the same method from the MeshBuilder class instead
  33252. * @see https://doc.babylonjs.com/babylon101/height_map
  33253. * @param name defines the name of the mesh to create
  33254. * @param url sets the URL of the height map image resource
  33255. * @param width set the ground width size
  33256. * @param height set the ground height size
  33257. * @param subdivisions sets the number of subdivision per side
  33258. * @param minHeight is the minimum altitude on the ground
  33259. * @param maxHeight is the maximum altitude on the ground
  33260. * @param scene defines the hosting scene
  33261. * @param updatable defines if the mesh must be flagged as updatable
  33262. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  33263. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  33264. * @returns a new Mesh
  33265. */
  33266. 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;
  33267. /**
  33268. * Creates a tube mesh.
  33269. * The tube is a parametric shape.
  33270. * It has no predefined shape. Its final shape will depend on the input parameters.
  33271. * Please consider using the same method from the MeshBuilder class instead
  33272. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  33273. * @param name defines the name of the mesh to create
  33274. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  33275. * @param radius sets the tube radius size
  33276. * @param tessellation is the number of sides on the tubular surface
  33277. * @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
  33278. * @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
  33279. * @param scene defines the hosting scene
  33280. * @param updatable defines if the mesh must be flagged as updatable
  33281. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33282. * @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)
  33283. * @returns a new Mesh
  33284. */
  33285. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  33286. (i: number, distance: number): number;
  33287. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  33288. /**
  33289. * Creates a polyhedron mesh.
  33290. * Please consider using the same method from the MeshBuilder class instead.
  33291. * * 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
  33292. * * The parameter `size` (positive float, default 1) sets the polygon size
  33293. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  33294. * * 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`
  33295. * * 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
  33296. * * 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)`)
  33297. * * 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
  33298. * * 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
  33299. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  33300. * * 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
  33301. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  33302. * @param name defines the name of the mesh to create
  33303. * @param options defines the options used to create the mesh
  33304. * @param scene defines the hosting scene
  33305. * @returns a new Mesh
  33306. */
  33307. static CreatePolyhedron(name: string, options: {
  33308. type?: number;
  33309. size?: number;
  33310. sizeX?: number;
  33311. sizeY?: number;
  33312. sizeZ?: number;
  33313. custom?: any;
  33314. faceUV?: Vector4[];
  33315. faceColors?: Color4[];
  33316. updatable?: boolean;
  33317. sideOrientation?: number;
  33318. }, scene: Scene): Mesh;
  33319. /**
  33320. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  33321. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  33322. * * 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`)
  33323. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  33324. * * 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
  33325. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  33326. * * 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
  33327. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  33328. * @param name defines the name of the mesh
  33329. * @param options defines the options used to create the mesh
  33330. * @param scene defines the hosting scene
  33331. * @returns a new Mesh
  33332. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  33333. */
  33334. static CreateIcoSphere(name: string, options: {
  33335. radius?: number;
  33336. flat?: boolean;
  33337. subdivisions?: number;
  33338. sideOrientation?: number;
  33339. updatable?: boolean;
  33340. }, scene: Scene): Mesh;
  33341. /**
  33342. * Creates a decal mesh.
  33343. * Please consider using the same method from the MeshBuilder class instead.
  33344. * A decal is a mesh usually applied as a model onto the surface of another mesh
  33345. * @param name defines the name of the mesh
  33346. * @param sourceMesh defines the mesh receiving the decal
  33347. * @param position sets the position of the decal in world coordinates
  33348. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  33349. * @param size sets the decal scaling
  33350. * @param angle sets the angle to rotate the decal
  33351. * @returns a new Mesh
  33352. */
  33353. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  33354. /** Creates a Capsule Mesh
  33355. * @param name defines the name of the mesh.
  33356. * @param options the constructors options used to shape the mesh.
  33357. * @param scene defines the scene the mesh is scoped to.
  33358. * @returns the capsule mesh
  33359. * @see https://doc.babylonjs.com/how_to/capsule_shape
  33360. */
  33361. static CreateCapsule(name: string, options: ICreateCapsuleOptions, scene: Scene): Mesh;
  33362. /**
  33363. * Prepare internal position array for software CPU skinning
  33364. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  33365. */
  33366. setPositionsForCPUSkinning(): Float32Array;
  33367. /**
  33368. * Prepare internal normal array for software CPU skinning
  33369. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  33370. */
  33371. setNormalsForCPUSkinning(): Float32Array;
  33372. /**
  33373. * Updates the vertex buffer by applying transformation from the bones
  33374. * @param skeleton defines the skeleton to apply to current mesh
  33375. * @returns the current mesh
  33376. */
  33377. applySkeleton(skeleton: Skeleton): Mesh;
  33378. /**
  33379. * 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
  33380. * @param meshes defines the list of meshes to scan
  33381. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  33382. */
  33383. static MinMax(meshes: AbstractMesh[]): {
  33384. min: Vector3;
  33385. max: Vector3;
  33386. };
  33387. /**
  33388. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  33389. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  33390. * @returns a vector3
  33391. */
  33392. static Center(meshesOrMinMaxVector: {
  33393. min: Vector3;
  33394. max: Vector3;
  33395. } | AbstractMesh[]): Vector3;
  33396. /**
  33397. * Merge the array of meshes into a single mesh for performance reasons.
  33398. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  33399. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  33400. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  33401. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  33402. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  33403. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  33404. * @returns a new mesh
  33405. */
  33406. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  33407. /** @hidden */
  33408. addInstance(instance: InstancedMesh): void;
  33409. /** @hidden */
  33410. removeInstance(instance: InstancedMesh): void;
  33411. }
  33412. }
  33413. declare module BABYLON {
  33414. /**
  33415. * The options Interface for creating a Capsule Mesh
  33416. */
  33417. export interface ICreateCapsuleOptions {
  33418. /** The Orientation of the capsule. Default : Vector3.Up() */
  33419. orientation?: Vector3;
  33420. /** Number of sub segments on the tube section of the capsule running parallel to orientation. */
  33421. subdivisions: number;
  33422. /** Number of cylindrical segments on the capsule. */
  33423. tessellation: number;
  33424. /** Height or Length of the capsule. */
  33425. height: number;
  33426. /** Radius of the capsule. */
  33427. radius: number;
  33428. /** Number of sub segments on the cap sections of the capsule running parallel to orientation. */
  33429. capSubdivisions: number;
  33430. /** Overwrite for the top radius. */
  33431. radiusTop?: number;
  33432. /** Overwrite for the bottom radius. */
  33433. radiusBottom?: number;
  33434. /** Overwrite for the top capSubdivisions. */
  33435. topCapSubdivisions?: number;
  33436. /** Overwrite for the bottom capSubdivisions. */
  33437. bottomCapSubdivisions?: number;
  33438. }
  33439. /**
  33440. * Class containing static functions to help procedurally build meshes
  33441. */
  33442. export class CapsuleBuilder {
  33443. /**
  33444. * Creates a capsule or a pill mesh
  33445. * @param name defines the name of the mesh
  33446. * @param options The constructors options.
  33447. * @param scene The scene the mesh is scoped to.
  33448. * @returns Capsule Mesh
  33449. */
  33450. static CreateCapsule(name: string, options: ICreateCapsuleOptions | undefined, scene: any): Mesh;
  33451. }
  33452. }
  33453. declare module BABYLON {
  33454. /**
  33455. * Define an interface for all classes that will get and set the data on vertices
  33456. */
  33457. export interface IGetSetVerticesData {
  33458. /**
  33459. * Gets a boolean indicating if specific vertex data is present
  33460. * @param kind defines the vertex data kind to use
  33461. * @returns true is data kind is present
  33462. */
  33463. isVerticesDataPresent(kind: string): boolean;
  33464. /**
  33465. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  33466. * @param kind defines the data kind (Position, normal, etc...)
  33467. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  33468. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  33469. * @returns a float array containing vertex data
  33470. */
  33471. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  33472. /**
  33473. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  33474. * @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.
  33475. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  33476. * @returns the indices array or an empty array if the mesh has no geometry
  33477. */
  33478. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  33479. /**
  33480. * Set specific vertex data
  33481. * @param kind defines the data kind (Position, normal, etc...)
  33482. * @param data defines the vertex data to use
  33483. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  33484. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  33485. */
  33486. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  33487. /**
  33488. * Update a specific associated vertex buffer
  33489. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  33490. * - VertexBuffer.PositionKind
  33491. * - VertexBuffer.UVKind
  33492. * - VertexBuffer.UV2Kind
  33493. * - VertexBuffer.UV3Kind
  33494. * - VertexBuffer.UV4Kind
  33495. * - VertexBuffer.UV5Kind
  33496. * - VertexBuffer.UV6Kind
  33497. * - VertexBuffer.ColorKind
  33498. * - VertexBuffer.MatricesIndicesKind
  33499. * - VertexBuffer.MatricesIndicesExtraKind
  33500. * - VertexBuffer.MatricesWeightsKind
  33501. * - VertexBuffer.MatricesWeightsExtraKind
  33502. * @param data defines the data source
  33503. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  33504. * @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)
  33505. */
  33506. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  33507. /**
  33508. * Creates a new index buffer
  33509. * @param indices defines the indices to store in the index buffer
  33510. * @param totalVertices defines the total number of vertices (could be null)
  33511. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  33512. */
  33513. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  33514. }
  33515. /**
  33516. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  33517. */
  33518. export class VertexData {
  33519. /**
  33520. * Mesh side orientation : usually the external or front surface
  33521. */
  33522. static readonly FRONTSIDE: number;
  33523. /**
  33524. * Mesh side orientation : usually the internal or back surface
  33525. */
  33526. static readonly BACKSIDE: number;
  33527. /**
  33528. * Mesh side orientation : both internal and external or front and back surfaces
  33529. */
  33530. static readonly DOUBLESIDE: number;
  33531. /**
  33532. * Mesh side orientation : by default, `FRONTSIDE`
  33533. */
  33534. static readonly DEFAULTSIDE: number;
  33535. /**
  33536. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  33537. */
  33538. positions: Nullable<FloatArray>;
  33539. /**
  33540. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  33541. */
  33542. normals: Nullable<FloatArray>;
  33543. /**
  33544. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  33545. */
  33546. tangents: Nullable<FloatArray>;
  33547. /**
  33548. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  33549. */
  33550. uvs: Nullable<FloatArray>;
  33551. /**
  33552. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  33553. */
  33554. uvs2: Nullable<FloatArray>;
  33555. /**
  33556. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  33557. */
  33558. uvs3: Nullable<FloatArray>;
  33559. /**
  33560. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  33561. */
  33562. uvs4: Nullable<FloatArray>;
  33563. /**
  33564. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  33565. */
  33566. uvs5: Nullable<FloatArray>;
  33567. /**
  33568. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  33569. */
  33570. uvs6: Nullable<FloatArray>;
  33571. /**
  33572. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  33573. */
  33574. colors: Nullable<FloatArray>;
  33575. /**
  33576. * 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).
  33577. */
  33578. matricesIndices: Nullable<FloatArray>;
  33579. /**
  33580. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  33581. */
  33582. matricesWeights: Nullable<FloatArray>;
  33583. /**
  33584. * An array extending the number of possible indices
  33585. */
  33586. matricesIndicesExtra: Nullable<FloatArray>;
  33587. /**
  33588. * An array extending the number of possible weights when the number of indices is extended
  33589. */
  33590. matricesWeightsExtra: Nullable<FloatArray>;
  33591. /**
  33592. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  33593. */
  33594. indices: Nullable<IndicesArray>;
  33595. /**
  33596. * Uses the passed data array to set the set the values for the specified kind of data
  33597. * @param data a linear array of floating numbers
  33598. * @param kind the type of data that is being set, eg positions, colors etc
  33599. */
  33600. set(data: FloatArray, kind: string): void;
  33601. /**
  33602. * Associates the vertexData to the passed Mesh.
  33603. * Sets it as updatable or not (default `false`)
  33604. * @param mesh the mesh the vertexData is applied to
  33605. * @param updatable when used and having the value true allows new data to update the vertexData
  33606. * @returns the VertexData
  33607. */
  33608. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  33609. /**
  33610. * Associates the vertexData to the passed Geometry.
  33611. * Sets it as updatable or not (default `false`)
  33612. * @param geometry the geometry the vertexData is applied to
  33613. * @param updatable when used and having the value true allows new data to update the vertexData
  33614. * @returns VertexData
  33615. */
  33616. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  33617. /**
  33618. * Updates the associated mesh
  33619. * @param mesh the mesh to be updated
  33620. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  33621. * @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
  33622. * @returns VertexData
  33623. */
  33624. updateMesh(mesh: Mesh): VertexData;
  33625. /**
  33626. * Updates the associated geometry
  33627. * @param geometry the geometry to be updated
  33628. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  33629. * @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
  33630. * @returns VertexData.
  33631. */
  33632. updateGeometry(geometry: Geometry): VertexData;
  33633. private _applyTo;
  33634. private _update;
  33635. /**
  33636. * Transforms each position and each normal of the vertexData according to the passed Matrix
  33637. * @param matrix the transforming matrix
  33638. * @returns the VertexData
  33639. */
  33640. transform(matrix: Matrix): VertexData;
  33641. /**
  33642. * Merges the passed VertexData into the current one
  33643. * @param other the VertexData to be merged into the current one
  33644. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  33645. * @returns the modified VertexData
  33646. */
  33647. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  33648. private _mergeElement;
  33649. private _validate;
  33650. /**
  33651. * Serializes the VertexData
  33652. * @returns a serialized object
  33653. */
  33654. serialize(): any;
  33655. /**
  33656. * Extracts the vertexData from a mesh
  33657. * @param mesh the mesh from which to extract the VertexData
  33658. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  33659. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  33660. * @returns the object VertexData associated to the passed mesh
  33661. */
  33662. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  33663. /**
  33664. * Extracts the vertexData from the geometry
  33665. * @param geometry the geometry from which to extract the VertexData
  33666. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  33667. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  33668. * @returns the object VertexData associated to the passed mesh
  33669. */
  33670. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  33671. private static _ExtractFrom;
  33672. /**
  33673. * Creates the VertexData for a Ribbon
  33674. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  33675. * * pathArray array of paths, each of which an array of successive Vector3
  33676. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  33677. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  33678. * * 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
  33679. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  33680. * * 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)
  33681. * * 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)
  33682. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  33683. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  33684. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  33685. * @returns the VertexData of the ribbon
  33686. */
  33687. static CreateRibbon(options: {
  33688. pathArray: Vector3[][];
  33689. closeArray?: boolean;
  33690. closePath?: boolean;
  33691. offset?: number;
  33692. sideOrientation?: number;
  33693. frontUVs?: Vector4;
  33694. backUVs?: Vector4;
  33695. invertUV?: boolean;
  33696. uvs?: Vector2[];
  33697. colors?: Color4[];
  33698. }): VertexData;
  33699. /**
  33700. * Creates the VertexData for a box
  33701. * @param options an object used to set the following optional parameters for the box, required but can be empty
  33702. * * size sets the width, height and depth of the box to the value of size, optional default 1
  33703. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  33704. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  33705. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  33706. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  33707. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  33708. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  33709. * * 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)
  33710. * * 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)
  33711. * @returns the VertexData of the box
  33712. */
  33713. static CreateBox(options: {
  33714. size?: number;
  33715. width?: number;
  33716. height?: number;
  33717. depth?: number;
  33718. faceUV?: Vector4[];
  33719. faceColors?: Color4[];
  33720. sideOrientation?: number;
  33721. frontUVs?: Vector4;
  33722. backUVs?: Vector4;
  33723. }): VertexData;
  33724. /**
  33725. * Creates the VertexData for a tiled box
  33726. * @param options an object used to set the following optional parameters for the box, required but can be empty
  33727. * * faceTiles sets the pattern, tile size and number of tiles for a face
  33728. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  33729. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  33730. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  33731. * @returns the VertexData of the box
  33732. */
  33733. static CreateTiledBox(options: {
  33734. pattern?: number;
  33735. width?: number;
  33736. height?: number;
  33737. depth?: number;
  33738. tileSize?: number;
  33739. tileWidth?: number;
  33740. tileHeight?: number;
  33741. alignHorizontal?: number;
  33742. alignVertical?: number;
  33743. faceUV?: Vector4[];
  33744. faceColors?: Color4[];
  33745. sideOrientation?: number;
  33746. }): VertexData;
  33747. /**
  33748. * Creates the VertexData for a tiled plane
  33749. * @param options an object used to set the following optional parameters for the box, required but can be empty
  33750. * * pattern a limited pattern arrangement depending on the number
  33751. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  33752. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  33753. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  33754. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  33755. * * 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)
  33756. * * 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)
  33757. * @returns the VertexData of the tiled plane
  33758. */
  33759. static CreateTiledPlane(options: {
  33760. pattern?: number;
  33761. tileSize?: number;
  33762. tileWidth?: number;
  33763. tileHeight?: number;
  33764. size?: number;
  33765. width?: number;
  33766. height?: number;
  33767. alignHorizontal?: number;
  33768. alignVertical?: number;
  33769. sideOrientation?: number;
  33770. frontUVs?: Vector4;
  33771. backUVs?: Vector4;
  33772. }): VertexData;
  33773. /**
  33774. * Creates the VertexData for an ellipsoid, defaults to a sphere
  33775. * @param options an object used to set the following optional parameters for the box, required but can be empty
  33776. * * segments sets the number of horizontal strips optional, default 32
  33777. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  33778. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  33779. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  33780. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  33781. * * 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
  33782. * * 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
  33783. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  33784. * * 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)
  33785. * * 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)
  33786. * @returns the VertexData of the ellipsoid
  33787. */
  33788. static CreateSphere(options: {
  33789. segments?: number;
  33790. diameter?: number;
  33791. diameterX?: number;
  33792. diameterY?: number;
  33793. diameterZ?: number;
  33794. arc?: number;
  33795. slice?: number;
  33796. sideOrientation?: number;
  33797. frontUVs?: Vector4;
  33798. backUVs?: Vector4;
  33799. }): VertexData;
  33800. /**
  33801. * Creates the VertexData for a cylinder, cone or prism
  33802. * @param options an object used to set the following optional parameters for the box, required but can be empty
  33803. * * height sets the height (y direction) of the cylinder, optional, default 2
  33804. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  33805. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  33806. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  33807. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  33808. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  33809. * * 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
  33810. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  33811. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  33812. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  33813. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  33814. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  33815. * * 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)
  33816. * * 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)
  33817. * @returns the VertexData of the cylinder, cone or prism
  33818. */
  33819. static CreateCylinder(options: {
  33820. height?: number;
  33821. diameterTop?: number;
  33822. diameterBottom?: number;
  33823. diameter?: number;
  33824. tessellation?: number;
  33825. subdivisions?: number;
  33826. arc?: number;
  33827. faceColors?: Color4[];
  33828. faceUV?: Vector4[];
  33829. hasRings?: boolean;
  33830. enclose?: boolean;
  33831. sideOrientation?: number;
  33832. frontUVs?: Vector4;
  33833. backUVs?: Vector4;
  33834. }): VertexData;
  33835. /**
  33836. * Creates the VertexData for a torus
  33837. * @param options an object used to set the following optional parameters for the box, required but can be empty
  33838. * * diameter the diameter of the torus, optional default 1
  33839. * * thickness the diameter of the tube forming the torus, optional default 0.5
  33840. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  33841. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  33842. * * 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)
  33843. * * 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)
  33844. * @returns the VertexData of the torus
  33845. */
  33846. static CreateTorus(options: {
  33847. diameter?: number;
  33848. thickness?: number;
  33849. tessellation?: number;
  33850. sideOrientation?: number;
  33851. frontUVs?: Vector4;
  33852. backUVs?: Vector4;
  33853. }): VertexData;
  33854. /**
  33855. * Creates the VertexData of the LineSystem
  33856. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  33857. * - lines an array of lines, each line being an array of successive Vector3
  33858. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  33859. * @returns the VertexData of the LineSystem
  33860. */
  33861. static CreateLineSystem(options: {
  33862. lines: Vector3[][];
  33863. colors?: Nullable<Color4[][]>;
  33864. }): VertexData;
  33865. /**
  33866. * Create the VertexData for a DashedLines
  33867. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  33868. * - points an array successive Vector3
  33869. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  33870. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  33871. * - dashNb the intended total number of dashes, optional, default 200
  33872. * @returns the VertexData for the DashedLines
  33873. */
  33874. static CreateDashedLines(options: {
  33875. points: Vector3[];
  33876. dashSize?: number;
  33877. gapSize?: number;
  33878. dashNb?: number;
  33879. }): VertexData;
  33880. /**
  33881. * Creates the VertexData for a Ground
  33882. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  33883. * - width the width (x direction) of the ground, optional, default 1
  33884. * - height the height (z direction) of the ground, optional, default 1
  33885. * - subdivisions the number of subdivisions per side, optional, default 1
  33886. * @returns the VertexData of the Ground
  33887. */
  33888. static CreateGround(options: {
  33889. width?: number;
  33890. height?: number;
  33891. subdivisions?: number;
  33892. subdivisionsX?: number;
  33893. subdivisionsY?: number;
  33894. }): VertexData;
  33895. /**
  33896. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  33897. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  33898. * * xmin the ground minimum X coordinate, optional, default -1
  33899. * * zmin the ground minimum Z coordinate, optional, default -1
  33900. * * xmax the ground maximum X coordinate, optional, default 1
  33901. * * zmax the ground maximum Z coordinate, optional, default 1
  33902. * * 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}
  33903. * * 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}
  33904. * @returns the VertexData of the TiledGround
  33905. */
  33906. static CreateTiledGround(options: {
  33907. xmin: number;
  33908. zmin: number;
  33909. xmax: number;
  33910. zmax: number;
  33911. subdivisions?: {
  33912. w: number;
  33913. h: number;
  33914. };
  33915. precision?: {
  33916. w: number;
  33917. h: number;
  33918. };
  33919. }): VertexData;
  33920. /**
  33921. * Creates the VertexData of the Ground designed from a heightmap
  33922. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  33923. * * width the width (x direction) of the ground
  33924. * * height the height (z direction) of the ground
  33925. * * subdivisions the number of subdivisions per side
  33926. * * minHeight the minimum altitude on the ground, optional, default 0
  33927. * * maxHeight the maximum altitude on the ground, optional default 1
  33928. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  33929. * * buffer the array holding the image color data
  33930. * * bufferWidth the width of image
  33931. * * bufferHeight the height of image
  33932. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  33933. * @returns the VertexData of the Ground designed from a heightmap
  33934. */
  33935. static CreateGroundFromHeightMap(options: {
  33936. width: number;
  33937. height: number;
  33938. subdivisions: number;
  33939. minHeight: number;
  33940. maxHeight: number;
  33941. colorFilter: Color3;
  33942. buffer: Uint8Array;
  33943. bufferWidth: number;
  33944. bufferHeight: number;
  33945. alphaFilter: number;
  33946. }): VertexData;
  33947. /**
  33948. * Creates the VertexData for a Plane
  33949. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  33950. * * size sets the width and height of the plane to the value of size, optional default 1
  33951. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  33952. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  33953. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  33954. * * 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)
  33955. * * 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)
  33956. * @returns the VertexData of the box
  33957. */
  33958. static CreatePlane(options: {
  33959. size?: number;
  33960. width?: number;
  33961. height?: number;
  33962. sideOrientation?: number;
  33963. frontUVs?: Vector4;
  33964. backUVs?: Vector4;
  33965. }): VertexData;
  33966. /**
  33967. * Creates the VertexData of the Disc or regular Polygon
  33968. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  33969. * * radius the radius of the disc, optional default 0.5
  33970. * * tessellation the number of polygon sides, optional, default 64
  33971. * * 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
  33972. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  33973. * * 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)
  33974. * * 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)
  33975. * @returns the VertexData of the box
  33976. */
  33977. static CreateDisc(options: {
  33978. radius?: number;
  33979. tessellation?: number;
  33980. arc?: number;
  33981. sideOrientation?: number;
  33982. frontUVs?: Vector4;
  33983. backUVs?: Vector4;
  33984. }): VertexData;
  33985. /**
  33986. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  33987. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  33988. * @param polygon a mesh built from polygonTriangulation.build()
  33989. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  33990. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  33991. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  33992. * @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)
  33993. * @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)
  33994. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  33995. * @returns the VertexData of the Polygon
  33996. */
  33997. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  33998. /**
  33999. * Creates the VertexData of the IcoSphere
  34000. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  34001. * * radius the radius of the IcoSphere, optional default 1
  34002. * * radiusX allows stretching in the x direction, optional, default radius
  34003. * * radiusY allows stretching in the y direction, optional, default radius
  34004. * * radiusZ allows stretching in the z direction, optional, default radius
  34005. * * flat when true creates a flat shaded mesh, optional, default true
  34006. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  34007. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34008. * * 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)
  34009. * * 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)
  34010. * @returns the VertexData of the IcoSphere
  34011. */
  34012. static CreateIcoSphere(options: {
  34013. radius?: number;
  34014. radiusX?: number;
  34015. radiusY?: number;
  34016. radiusZ?: number;
  34017. flat?: boolean;
  34018. subdivisions?: number;
  34019. sideOrientation?: number;
  34020. frontUVs?: Vector4;
  34021. backUVs?: Vector4;
  34022. }): VertexData;
  34023. /**
  34024. * Creates the VertexData for a Polyhedron
  34025. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  34026. * * type provided types are:
  34027. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  34028. * * 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)
  34029. * * size the size of the IcoSphere, optional default 1
  34030. * * sizeX allows stretching in the x direction, optional, default size
  34031. * * sizeY allows stretching in the y direction, optional, default size
  34032. * * sizeZ allows stretching in the z direction, optional, default size
  34033. * * 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
  34034. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  34035. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  34036. * * flat when true creates a flat shaded mesh, optional, default true
  34037. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  34038. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34039. * * 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)
  34040. * * 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)
  34041. * @returns the VertexData of the Polyhedron
  34042. */
  34043. static CreatePolyhedron(options: {
  34044. type?: number;
  34045. size?: number;
  34046. sizeX?: number;
  34047. sizeY?: number;
  34048. sizeZ?: number;
  34049. custom?: any;
  34050. faceUV?: Vector4[];
  34051. faceColors?: Color4[];
  34052. flat?: boolean;
  34053. sideOrientation?: number;
  34054. frontUVs?: Vector4;
  34055. backUVs?: Vector4;
  34056. }): VertexData;
  34057. /**
  34058. * Creates the VertexData for a Capsule, inspired from https://github.com/maximeq/three-js-capsule-geometry/blob/master/src/CapsuleBufferGeometry.js
  34059. * @param options an object used to set the following optional parameters for the capsule, required but can be empty
  34060. * @returns the VertexData of the Capsule
  34061. */
  34062. static CreateCapsule(options?: ICreateCapsuleOptions): VertexData;
  34063. /**
  34064. * Creates the VertexData for a TorusKnot
  34065. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  34066. * * radius the radius of the torus knot, optional, default 2
  34067. * * tube the thickness of the tube, optional, default 0.5
  34068. * * radialSegments the number of sides on each tube segments, optional, default 32
  34069. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  34070. * * p the number of windings around the z axis, optional, default 2
  34071. * * q the number of windings around the x axis, optional, default 3
  34072. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34073. * * 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)
  34074. * * 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)
  34075. * @returns the VertexData of the Torus Knot
  34076. */
  34077. static CreateTorusKnot(options: {
  34078. radius?: number;
  34079. tube?: number;
  34080. radialSegments?: number;
  34081. tubularSegments?: number;
  34082. p?: number;
  34083. q?: number;
  34084. sideOrientation?: number;
  34085. frontUVs?: Vector4;
  34086. backUVs?: Vector4;
  34087. }): VertexData;
  34088. /**
  34089. * Compute normals for given positions and indices
  34090. * @param positions an array of vertex positions, [...., x, y, z, ......]
  34091. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  34092. * @param normals an array of vertex normals, [...., x, y, z, ......]
  34093. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  34094. * * facetNormals : optional array of facet normals (vector3)
  34095. * * facetPositions : optional array of facet positions (vector3)
  34096. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  34097. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  34098. * * bInfo : optional bounding info, required for facetPartitioning computation
  34099. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  34100. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  34101. * * useRightHandedSystem: optional boolean to for right handed system computation
  34102. * * depthSort : optional boolean to enable the facet depth sort computation
  34103. * * distanceTo : optional Vector3 to compute the facet depth from this location
  34104. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  34105. */
  34106. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  34107. facetNormals?: any;
  34108. facetPositions?: any;
  34109. facetPartitioning?: any;
  34110. ratio?: number;
  34111. bInfo?: any;
  34112. bbSize?: Vector3;
  34113. subDiv?: any;
  34114. useRightHandedSystem?: boolean;
  34115. depthSort?: boolean;
  34116. distanceTo?: Vector3;
  34117. depthSortedFacets?: any;
  34118. }): void;
  34119. /** @hidden */
  34120. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  34121. /**
  34122. * Applies VertexData created from the imported parameters to the geometry
  34123. * @param parsedVertexData the parsed data from an imported file
  34124. * @param geometry the geometry to apply the VertexData to
  34125. */
  34126. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  34127. }
  34128. }
  34129. declare module BABYLON {
  34130. /**
  34131. * Class containing static functions to help procedurally build meshes
  34132. */
  34133. export class DiscBuilder {
  34134. /**
  34135. * Creates a plane polygonal mesh. By default, this is a disc
  34136. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  34137. * * 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
  34138. * * 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
  34139. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  34140. * * 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
  34141. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  34142. * @param name defines the name of the mesh
  34143. * @param options defines the options used to create the mesh
  34144. * @param scene defines the hosting scene
  34145. * @returns the plane polygonal mesh
  34146. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  34147. */
  34148. static CreateDisc(name: string, options: {
  34149. radius?: number;
  34150. tessellation?: number;
  34151. arc?: number;
  34152. updatable?: boolean;
  34153. sideOrientation?: number;
  34154. frontUVs?: Vector4;
  34155. backUVs?: Vector4;
  34156. }, scene?: Nullable<Scene>): Mesh;
  34157. }
  34158. }
  34159. declare module BABYLON {
  34160. /**
  34161. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  34162. *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.
  34163. * The SPS is also a particle system. It provides some methods to manage the particles.
  34164. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  34165. *
  34166. * Full documentation here : https://doc.babylonjs.com/how_to/Solid_Particle_System
  34167. */
  34168. export class SolidParticleSystem implements IDisposable {
  34169. /**
  34170. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  34171. * Example : var p = SPS.particles[i];
  34172. */
  34173. particles: SolidParticle[];
  34174. /**
  34175. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  34176. */
  34177. nbParticles: number;
  34178. /**
  34179. * If the particles must ever face the camera (default false). Useful for planar particles.
  34180. */
  34181. billboard: boolean;
  34182. /**
  34183. * Recompute normals when adding a shape
  34184. */
  34185. recomputeNormals: boolean;
  34186. /**
  34187. * This a counter ofr your own usage. It's not set by any SPS functions.
  34188. */
  34189. counter: number;
  34190. /**
  34191. * The SPS name. This name is also given to the underlying mesh.
  34192. */
  34193. name: string;
  34194. /**
  34195. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  34196. */
  34197. mesh: Mesh;
  34198. /**
  34199. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  34200. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  34201. */
  34202. vars: any;
  34203. /**
  34204. * This array is populated when the SPS is set as 'pickable'.
  34205. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  34206. * Each element of this array is an object `{idx: int, faceId: int}`.
  34207. * `idx` is the picked particle index in the `SPS.particles` array
  34208. * `faceId` is the picked face index counted within this particle.
  34209. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  34210. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  34211. * Use the method SPS.pickedParticle(pickingInfo) instead.
  34212. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  34213. */
  34214. pickedParticles: {
  34215. idx: number;
  34216. faceId: number;
  34217. }[];
  34218. /**
  34219. * This array is populated when the SPS is set as 'pickable'
  34220. * Each key of this array is a submesh index.
  34221. * Each element of this array is a second array defined like this :
  34222. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  34223. * Each element of this second array is an object `{idx: int, faceId: int}`.
  34224. * `idx` is the picked particle index in the `SPS.particles` array
  34225. * `faceId` is the picked face index counted within this particle.
  34226. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  34227. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  34228. */
  34229. pickedBySubMesh: {
  34230. idx: number;
  34231. faceId: number;
  34232. }[][];
  34233. /**
  34234. * This array is populated when `enableDepthSort` is set to true.
  34235. * Each element of this array is an instance of the class DepthSortedParticle.
  34236. */
  34237. depthSortedParticles: DepthSortedParticle[];
  34238. /**
  34239. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  34240. * @hidden
  34241. */
  34242. _bSphereOnly: boolean;
  34243. /**
  34244. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  34245. * @hidden
  34246. */
  34247. _bSphereRadiusFactor: number;
  34248. private _scene;
  34249. private _positions;
  34250. private _indices;
  34251. private _normals;
  34252. private _colors;
  34253. private _uvs;
  34254. private _indices32;
  34255. private _positions32;
  34256. private _normals32;
  34257. private _fixedNormal32;
  34258. private _colors32;
  34259. private _uvs32;
  34260. private _index;
  34261. private _updatable;
  34262. private _pickable;
  34263. private _isVisibilityBoxLocked;
  34264. private _alwaysVisible;
  34265. private _depthSort;
  34266. private _expandable;
  34267. private _shapeCounter;
  34268. private _copy;
  34269. private _color;
  34270. private _computeParticleColor;
  34271. private _computeParticleTexture;
  34272. private _computeParticleRotation;
  34273. private _computeParticleVertex;
  34274. private _computeBoundingBox;
  34275. private _depthSortParticles;
  34276. private _camera;
  34277. private _mustUnrotateFixedNormals;
  34278. private _particlesIntersect;
  34279. private _needs32Bits;
  34280. private _isNotBuilt;
  34281. private _lastParticleId;
  34282. private _idxOfId;
  34283. private _multimaterialEnabled;
  34284. private _useModelMaterial;
  34285. private _indicesByMaterial;
  34286. private _materialIndexes;
  34287. private _depthSortFunction;
  34288. private _materialSortFunction;
  34289. private _materials;
  34290. private _multimaterial;
  34291. private _materialIndexesById;
  34292. private _defaultMaterial;
  34293. private _autoUpdateSubMeshes;
  34294. private _tmpVertex;
  34295. /**
  34296. * Creates a SPS (Solid Particle System) object.
  34297. * @param name (String) is the SPS name, this will be the underlying mesh name.
  34298. * @param scene (Scene) is the scene in which the SPS is added.
  34299. * @param options defines the options of the sps e.g.
  34300. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  34301. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  34302. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  34303. * * 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.
  34304. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  34305. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  34306. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  34307. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  34308. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  34309. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  34310. */
  34311. constructor(name: string, scene: Scene, options?: {
  34312. updatable?: boolean;
  34313. isPickable?: boolean;
  34314. enableDepthSort?: boolean;
  34315. particleIntersection?: boolean;
  34316. boundingSphereOnly?: boolean;
  34317. bSphereRadiusFactor?: number;
  34318. expandable?: boolean;
  34319. useModelMaterial?: boolean;
  34320. enableMultiMaterial?: boolean;
  34321. });
  34322. /**
  34323. * Builds the SPS underlying mesh. Returns a standard Mesh.
  34324. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  34325. * @returns the created mesh
  34326. */
  34327. buildMesh(): Mesh;
  34328. /**
  34329. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  34330. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  34331. * Thus the particles generated from `digest()` have their property `position` set yet.
  34332. * @param mesh ( Mesh ) is the mesh to be digested
  34333. * @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
  34334. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  34335. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  34336. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  34337. * @returns the current SPS
  34338. */
  34339. digest(mesh: Mesh, options?: {
  34340. facetNb?: number;
  34341. number?: number;
  34342. delta?: number;
  34343. storage?: [];
  34344. }): SolidParticleSystem;
  34345. /**
  34346. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  34347. * @hidden
  34348. */
  34349. private _unrotateFixedNormals;
  34350. /**
  34351. * Resets the temporary working copy particle
  34352. * @hidden
  34353. */
  34354. private _resetCopy;
  34355. /**
  34356. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  34357. * @param p the current index in the positions array to be updated
  34358. * @param ind the current index in the indices array
  34359. * @param shape a Vector3 array, the shape geometry
  34360. * @param positions the positions array to be updated
  34361. * @param meshInd the shape indices array
  34362. * @param indices the indices array to be updated
  34363. * @param meshUV the shape uv array
  34364. * @param uvs the uv array to be updated
  34365. * @param meshCol the shape color array
  34366. * @param colors the color array to be updated
  34367. * @param meshNor the shape normals array
  34368. * @param normals the normals array to be updated
  34369. * @param idx the particle index
  34370. * @param idxInShape the particle index in its shape
  34371. * @param options the addShape() method passed options
  34372. * @model the particle model
  34373. * @hidden
  34374. */
  34375. private _meshBuilder;
  34376. /**
  34377. * Returns a shape Vector3 array from positions float array
  34378. * @param positions float array
  34379. * @returns a vector3 array
  34380. * @hidden
  34381. */
  34382. private _posToShape;
  34383. /**
  34384. * Returns a shapeUV array from a float uvs (array deep copy)
  34385. * @param uvs as a float array
  34386. * @returns a shapeUV array
  34387. * @hidden
  34388. */
  34389. private _uvsToShapeUV;
  34390. /**
  34391. * Adds a new particle object in the particles array
  34392. * @param idx particle index in particles array
  34393. * @param id particle id
  34394. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  34395. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  34396. * @param model particle ModelShape object
  34397. * @param shapeId model shape identifier
  34398. * @param idxInShape index of the particle in the current model
  34399. * @param bInfo model bounding info object
  34400. * @param storage target storage array, if any
  34401. * @hidden
  34402. */
  34403. private _addParticle;
  34404. /**
  34405. * Adds some particles to the SPS from the model shape. Returns the shape id.
  34406. * Please read the doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  34407. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  34408. * @param nb (positive integer) the number of particles to be created from this model
  34409. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  34410. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  34411. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  34412. * @returns the number of shapes in the system
  34413. */
  34414. addShape(mesh: Mesh, nb: number, options?: {
  34415. positionFunction?: any;
  34416. vertexFunction?: any;
  34417. storage?: [];
  34418. }): number;
  34419. /**
  34420. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  34421. * @hidden
  34422. */
  34423. private _rebuildParticle;
  34424. /**
  34425. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  34426. * @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.
  34427. * @returns the SPS.
  34428. */
  34429. rebuildMesh(reset?: boolean): SolidParticleSystem;
  34430. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  34431. * Returns an array with the removed particles.
  34432. * 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.
  34433. * The SPS can't be empty so at least one particle needs to remain in place.
  34434. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  34435. * @param start index of the first particle to remove
  34436. * @param end index of the last particle to remove (included)
  34437. * @returns an array populated with the removed particles
  34438. */
  34439. removeParticles(start: number, end: number): SolidParticle[];
  34440. /**
  34441. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  34442. * @param solidParticleArray an array populated with Solid Particles objects
  34443. * @returns the SPS
  34444. */
  34445. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  34446. /**
  34447. * Creates a new particle and modifies the SPS mesh geometry :
  34448. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  34449. * - calls _addParticle() to populate the particle array
  34450. * factorized code from addShape() and insertParticlesFromArray()
  34451. * @param idx particle index in the particles array
  34452. * @param i particle index in its shape
  34453. * @param modelShape particle ModelShape object
  34454. * @param shape shape vertex array
  34455. * @param meshInd shape indices array
  34456. * @param meshUV shape uv array
  34457. * @param meshCol shape color array
  34458. * @param meshNor shape normals array
  34459. * @param bbInfo shape bounding info
  34460. * @param storage target particle storage
  34461. * @options addShape() passed options
  34462. * @hidden
  34463. */
  34464. private _insertNewParticle;
  34465. /**
  34466. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  34467. * This method calls `updateParticle()` for each particle of the SPS.
  34468. * For an animated SPS, it is usually called within the render loop.
  34469. * 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.
  34470. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  34471. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  34472. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  34473. * @returns the SPS.
  34474. */
  34475. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  34476. /**
  34477. * Disposes the SPS.
  34478. */
  34479. dispose(): void;
  34480. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  34481. * idx is the particle index in the SPS
  34482. * faceId is the picked face index counted within this particle.
  34483. * Returns null if the pickInfo can't identify a picked particle.
  34484. * @param pickingInfo (PickingInfo object)
  34485. * @returns {idx: number, faceId: number} or null
  34486. */
  34487. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  34488. idx: number;
  34489. faceId: number;
  34490. }>;
  34491. /**
  34492. * Returns a SolidParticle object from its identifier : particle.id
  34493. * @param id (integer) the particle Id
  34494. * @returns the searched particle or null if not found in the SPS.
  34495. */
  34496. getParticleById(id: number): Nullable<SolidParticle>;
  34497. /**
  34498. * Returns a new array populated with the particles having the passed shapeId.
  34499. * @param shapeId (integer) the shape identifier
  34500. * @returns a new solid particle array
  34501. */
  34502. getParticlesByShapeId(shapeId: number): SolidParticle[];
  34503. /**
  34504. * Populates the passed array "ref" with the particles having the passed shapeId.
  34505. * @param shapeId the shape identifier
  34506. * @returns the SPS
  34507. * @param ref
  34508. */
  34509. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  34510. /**
  34511. * Computes the required SubMeshes according the materials assigned to the particles.
  34512. * @returns the solid particle system.
  34513. * Does nothing if called before the SPS mesh is built.
  34514. */
  34515. computeSubMeshes(): SolidParticleSystem;
  34516. /**
  34517. * Sorts the solid particles by material when MultiMaterial is enabled.
  34518. * Updates the indices32 array.
  34519. * Updates the indicesByMaterial array.
  34520. * Updates the mesh indices array.
  34521. * @returns the SPS
  34522. * @hidden
  34523. */
  34524. private _sortParticlesByMaterial;
  34525. /**
  34526. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  34527. * @hidden
  34528. */
  34529. private _setMaterialIndexesById;
  34530. /**
  34531. * Returns an array with unique values of Materials from the passed array
  34532. * @param array the material array to be checked and filtered
  34533. * @hidden
  34534. */
  34535. private _filterUniqueMaterialId;
  34536. /**
  34537. * Sets a new Standard Material as _defaultMaterial if not already set.
  34538. * @hidden
  34539. */
  34540. private _setDefaultMaterial;
  34541. /**
  34542. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  34543. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  34544. * @returns the SPS.
  34545. */
  34546. refreshVisibleSize(): SolidParticleSystem;
  34547. /**
  34548. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  34549. * @param size the size (float) of the visibility box
  34550. * note : this doesn't lock the SPS mesh bounding box.
  34551. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  34552. */
  34553. setVisibilityBox(size: number): void;
  34554. /**
  34555. * Gets whether the SPS as always visible or not
  34556. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  34557. */
  34558. get isAlwaysVisible(): boolean;
  34559. /**
  34560. * Sets the SPS as always visible or not
  34561. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  34562. */
  34563. set isAlwaysVisible(val: boolean);
  34564. /**
  34565. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  34566. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  34567. */
  34568. set isVisibilityBoxLocked(val: boolean);
  34569. /**
  34570. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  34571. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  34572. */
  34573. get isVisibilityBoxLocked(): boolean;
  34574. /**
  34575. * Tells to `setParticles()` to compute the particle rotations or not.
  34576. * Default value : true. The SPS is faster when it's set to false.
  34577. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  34578. */
  34579. set computeParticleRotation(val: boolean);
  34580. /**
  34581. * Tells to `setParticles()` to compute the particle colors or not.
  34582. * Default value : true. The SPS is faster when it's set to false.
  34583. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  34584. */
  34585. set computeParticleColor(val: boolean);
  34586. set computeParticleTexture(val: boolean);
  34587. /**
  34588. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  34589. * Default value : false. The SPS is faster when it's set to false.
  34590. * Note : the particle custom vertex positions aren't stored values.
  34591. */
  34592. set computeParticleVertex(val: boolean);
  34593. /**
  34594. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  34595. */
  34596. set computeBoundingBox(val: boolean);
  34597. /**
  34598. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  34599. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  34600. * Default : `true`
  34601. */
  34602. set depthSortParticles(val: boolean);
  34603. /**
  34604. * Gets if `setParticles()` computes the particle rotations or not.
  34605. * Default value : true. The SPS is faster when it's set to false.
  34606. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  34607. */
  34608. get computeParticleRotation(): boolean;
  34609. /**
  34610. * Gets if `setParticles()` computes the particle colors or not.
  34611. * Default value : true. The SPS is faster when it's set to false.
  34612. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  34613. */
  34614. get computeParticleColor(): boolean;
  34615. /**
  34616. * Gets if `setParticles()` computes the particle textures or not.
  34617. * Default value : true. The SPS is faster when it's set to false.
  34618. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  34619. */
  34620. get computeParticleTexture(): boolean;
  34621. /**
  34622. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  34623. * Default value : false. The SPS is faster when it's set to false.
  34624. * Note : the particle custom vertex positions aren't stored values.
  34625. */
  34626. get computeParticleVertex(): boolean;
  34627. /**
  34628. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  34629. */
  34630. get computeBoundingBox(): boolean;
  34631. /**
  34632. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  34633. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  34634. * Default : `true`
  34635. */
  34636. get depthSortParticles(): boolean;
  34637. /**
  34638. * Gets if the SPS is created as expandable at construction time.
  34639. * Default : `false`
  34640. */
  34641. get expandable(): boolean;
  34642. /**
  34643. * Gets if the SPS supports the Multi Materials
  34644. */
  34645. get multimaterialEnabled(): boolean;
  34646. /**
  34647. * Gets if the SPS uses the model materials for its own multimaterial.
  34648. */
  34649. get useModelMaterial(): boolean;
  34650. /**
  34651. * The SPS used material array.
  34652. */
  34653. get materials(): Material[];
  34654. /**
  34655. * Sets the SPS MultiMaterial from the passed materials.
  34656. * Note : the passed array is internally copied and not used then by reference.
  34657. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  34658. */
  34659. setMultiMaterial(materials: Material[]): void;
  34660. /**
  34661. * The SPS computed multimaterial object
  34662. */
  34663. get multimaterial(): MultiMaterial;
  34664. set multimaterial(mm: MultiMaterial);
  34665. /**
  34666. * If the subMeshes must be updated on the next call to setParticles()
  34667. */
  34668. get autoUpdateSubMeshes(): boolean;
  34669. set autoUpdateSubMeshes(val: boolean);
  34670. /**
  34671. * This function does nothing. It may be overwritten to set all the particle first values.
  34672. * The SPS doesn't call this function, you may have to call it by your own.
  34673. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  34674. */
  34675. initParticles(): void;
  34676. /**
  34677. * This function does nothing. It may be overwritten to recycle a particle.
  34678. * The SPS doesn't call this function, you may have to call it by your own.
  34679. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  34680. * @param particle The particle to recycle
  34681. * @returns the recycled particle
  34682. */
  34683. recycleParticle(particle: SolidParticle): SolidParticle;
  34684. /**
  34685. * Updates a particle : this function should be overwritten by the user.
  34686. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  34687. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  34688. * @example : just set a particle position or velocity and recycle conditions
  34689. * @param particle The particle to update
  34690. * @returns the updated particle
  34691. */
  34692. updateParticle(particle: SolidParticle): SolidParticle;
  34693. /**
  34694. * Updates a vertex of a particle : it can be overwritten by the user.
  34695. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  34696. * @param particle the current particle
  34697. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  34698. * @param pt the index of the current vertex in the particle shape
  34699. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  34700. * @example : just set a vertex particle position or color
  34701. * @returns the sps
  34702. */
  34703. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  34704. /**
  34705. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  34706. * This does nothing and may be overwritten by the user.
  34707. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  34708. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  34709. * @param update the boolean update value actually passed to setParticles()
  34710. */
  34711. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  34712. /**
  34713. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  34714. * This will be passed three parameters.
  34715. * This does nothing and may be overwritten by the user.
  34716. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  34717. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  34718. * @param update the boolean update value actually passed to setParticles()
  34719. */
  34720. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  34721. }
  34722. }
  34723. declare module BABYLON {
  34724. /**
  34725. * Represents one particle of a solid particle system.
  34726. */
  34727. export class SolidParticle {
  34728. /**
  34729. * particle global index
  34730. */
  34731. idx: number;
  34732. /**
  34733. * particle identifier
  34734. */
  34735. id: number;
  34736. /**
  34737. * The color of the particle
  34738. */
  34739. color: Nullable<Color4>;
  34740. /**
  34741. * The world space position of the particle.
  34742. */
  34743. position: Vector3;
  34744. /**
  34745. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  34746. */
  34747. rotation: Vector3;
  34748. /**
  34749. * The world space rotation quaternion of the particle.
  34750. */
  34751. rotationQuaternion: Nullable<Quaternion>;
  34752. /**
  34753. * The scaling of the particle.
  34754. */
  34755. scaling: Vector3;
  34756. /**
  34757. * The uvs of the particle.
  34758. */
  34759. uvs: Vector4;
  34760. /**
  34761. * The current speed of the particle.
  34762. */
  34763. velocity: Vector3;
  34764. /**
  34765. * The pivot point in the particle local space.
  34766. */
  34767. pivot: Vector3;
  34768. /**
  34769. * Must the particle be translated from its pivot point in its local space ?
  34770. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  34771. * Default : false
  34772. */
  34773. translateFromPivot: boolean;
  34774. /**
  34775. * Is the particle active or not ?
  34776. */
  34777. alive: boolean;
  34778. /**
  34779. * Is the particle visible or not ?
  34780. */
  34781. isVisible: boolean;
  34782. /**
  34783. * Index of this particle in the global "positions" array (Internal use)
  34784. * @hidden
  34785. */
  34786. _pos: number;
  34787. /**
  34788. * @hidden Index of this particle in the global "indices" array (Internal use)
  34789. */
  34790. _ind: number;
  34791. /**
  34792. * @hidden ModelShape of this particle (Internal use)
  34793. */
  34794. _model: ModelShape;
  34795. /**
  34796. * ModelShape id of this particle
  34797. */
  34798. shapeId: number;
  34799. /**
  34800. * Index of the particle in its shape id
  34801. */
  34802. idxInShape: number;
  34803. /**
  34804. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  34805. */
  34806. _modelBoundingInfo: BoundingInfo;
  34807. /**
  34808. * @hidden Particle BoundingInfo object (Internal use)
  34809. */
  34810. _boundingInfo: BoundingInfo;
  34811. /**
  34812. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  34813. */
  34814. _sps: SolidParticleSystem;
  34815. /**
  34816. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  34817. */
  34818. _stillInvisible: boolean;
  34819. /**
  34820. * @hidden Last computed particle rotation matrix
  34821. */
  34822. _rotationMatrix: number[];
  34823. /**
  34824. * Parent particle Id, if any.
  34825. * Default null.
  34826. */
  34827. parentId: Nullable<number>;
  34828. /**
  34829. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  34830. */
  34831. materialIndex: Nullable<number>;
  34832. /**
  34833. * Custom object or properties.
  34834. */
  34835. props: Nullable<any>;
  34836. /**
  34837. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  34838. * The possible values are :
  34839. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  34840. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  34841. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  34842. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  34843. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  34844. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  34845. * */
  34846. cullingStrategy: number;
  34847. /**
  34848. * @hidden Internal global position in the SPS.
  34849. */
  34850. _globalPosition: Vector3;
  34851. /**
  34852. * Creates a Solid Particle object.
  34853. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  34854. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  34855. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  34856. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  34857. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  34858. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  34859. * @param shapeId (integer) is the model shape identifier in the SPS.
  34860. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  34861. * @param sps defines the sps it is associated to
  34862. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  34863. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  34864. */
  34865. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  34866. /**
  34867. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  34868. * @param target the particle target
  34869. * @returns the current particle
  34870. */
  34871. copyToRef(target: SolidParticle): SolidParticle;
  34872. /**
  34873. * Legacy support, changed scale to scaling
  34874. */
  34875. get scale(): Vector3;
  34876. /**
  34877. * Legacy support, changed scale to scaling
  34878. */
  34879. set scale(scale: Vector3);
  34880. /**
  34881. * Legacy support, changed quaternion to rotationQuaternion
  34882. */
  34883. get quaternion(): Nullable<Quaternion>;
  34884. /**
  34885. * Legacy support, changed quaternion to rotationQuaternion
  34886. */
  34887. set quaternion(q: Nullable<Quaternion>);
  34888. /**
  34889. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  34890. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  34891. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  34892. * @returns true if it intersects
  34893. */
  34894. intersectsMesh(target: Mesh | SolidParticle): boolean;
  34895. /**
  34896. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  34897. * A particle is in the frustum if its bounding box intersects the frustum
  34898. * @param frustumPlanes defines the frustum to test
  34899. * @returns true if the particle is in the frustum planes
  34900. */
  34901. isInFrustum(frustumPlanes: Plane[]): boolean;
  34902. /**
  34903. * get the rotation matrix of the particle
  34904. * @hidden
  34905. */
  34906. getRotationMatrix(m: Matrix): void;
  34907. }
  34908. /**
  34909. * Represents the shape of the model used by one particle of a solid particle system.
  34910. * SPS internal tool, don't use it manually.
  34911. */
  34912. export class ModelShape {
  34913. /**
  34914. * The shape id
  34915. * @hidden
  34916. */
  34917. shapeID: number;
  34918. /**
  34919. * flat array of model positions (internal use)
  34920. * @hidden
  34921. */
  34922. _shape: Vector3[];
  34923. /**
  34924. * flat array of model UVs (internal use)
  34925. * @hidden
  34926. */
  34927. _shapeUV: number[];
  34928. /**
  34929. * color array of the model
  34930. * @hidden
  34931. */
  34932. _shapeColors: number[];
  34933. /**
  34934. * indices array of the model
  34935. * @hidden
  34936. */
  34937. _indices: number[];
  34938. /**
  34939. * normals array of the model
  34940. * @hidden
  34941. */
  34942. _normals: number[];
  34943. /**
  34944. * length of the shape in the model indices array (internal use)
  34945. * @hidden
  34946. */
  34947. _indicesLength: number;
  34948. /**
  34949. * Custom position function (internal use)
  34950. * @hidden
  34951. */
  34952. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  34953. /**
  34954. * Custom vertex function (internal use)
  34955. * @hidden
  34956. */
  34957. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  34958. /**
  34959. * Model material (internal use)
  34960. * @hidden
  34961. */
  34962. _material: Nullable<Material>;
  34963. /**
  34964. * 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.
  34965. * SPS internal tool, don't use it manually.
  34966. * @hidden
  34967. */
  34968. 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>);
  34969. }
  34970. /**
  34971. * Represents a Depth Sorted Particle in the solid particle system.
  34972. * @hidden
  34973. */
  34974. export class DepthSortedParticle {
  34975. /**
  34976. * Particle index
  34977. */
  34978. idx: number;
  34979. /**
  34980. * Index of the particle in the "indices" array
  34981. */
  34982. ind: number;
  34983. /**
  34984. * Length of the particle shape in the "indices" array
  34985. */
  34986. indicesLength: number;
  34987. /**
  34988. * Squared distance from the particle to the camera
  34989. */
  34990. sqDistance: number;
  34991. /**
  34992. * Material index when used with MultiMaterials
  34993. */
  34994. materialIndex: number;
  34995. /**
  34996. * Creates a new sorted particle
  34997. * @param materialIndex
  34998. */
  34999. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  35000. }
  35001. /**
  35002. * Represents a solid particle vertex
  35003. */
  35004. export class SolidParticleVertex {
  35005. /**
  35006. * Vertex position
  35007. */
  35008. position: Vector3;
  35009. /**
  35010. * Vertex color
  35011. */
  35012. color: Color4;
  35013. /**
  35014. * Vertex UV
  35015. */
  35016. uv: Vector2;
  35017. /**
  35018. * Creates a new solid particle vertex
  35019. */
  35020. constructor();
  35021. /** Vertex x coordinate */
  35022. get x(): number;
  35023. set x(val: number);
  35024. /** Vertex y coordinate */
  35025. get y(): number;
  35026. set y(val: number);
  35027. /** Vertex z coordinate */
  35028. get z(): number;
  35029. set z(val: number);
  35030. }
  35031. }
  35032. declare module BABYLON {
  35033. /**
  35034. * @hidden
  35035. */
  35036. export class _MeshCollisionData {
  35037. _checkCollisions: boolean;
  35038. _collisionMask: number;
  35039. _collisionGroup: number;
  35040. _surroundingMeshes: Nullable<AbstractMesh[]>;
  35041. _collider: Nullable<Collider>;
  35042. _oldPositionForCollisions: Vector3;
  35043. _diffPositionForCollisions: Vector3;
  35044. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  35045. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  35046. _collisionResponse: boolean;
  35047. }
  35048. }
  35049. declare module BABYLON {
  35050. /** @hidden */
  35051. class _FacetDataStorage {
  35052. facetPositions: Vector3[];
  35053. facetNormals: Vector3[];
  35054. facetPartitioning: number[][];
  35055. facetNb: number;
  35056. partitioningSubdivisions: number;
  35057. partitioningBBoxRatio: number;
  35058. facetDataEnabled: boolean;
  35059. facetParameters: any;
  35060. bbSize: Vector3;
  35061. subDiv: {
  35062. max: number;
  35063. X: number;
  35064. Y: number;
  35065. Z: number;
  35066. };
  35067. facetDepthSort: boolean;
  35068. facetDepthSortEnabled: boolean;
  35069. depthSortedIndices: IndicesArray;
  35070. depthSortedFacets: {
  35071. ind: number;
  35072. sqDistance: number;
  35073. }[];
  35074. facetDepthSortFunction: (f1: {
  35075. ind: number;
  35076. sqDistance: number;
  35077. }, f2: {
  35078. ind: number;
  35079. sqDistance: number;
  35080. }) => number;
  35081. facetDepthSortFrom: Vector3;
  35082. facetDepthSortOrigin: Vector3;
  35083. invertedMatrix: Matrix;
  35084. }
  35085. /**
  35086. * @hidden
  35087. **/
  35088. class _InternalAbstractMeshDataInfo {
  35089. _hasVertexAlpha: boolean;
  35090. _useVertexColors: boolean;
  35091. _numBoneInfluencers: number;
  35092. _applyFog: boolean;
  35093. _receiveShadows: boolean;
  35094. _facetData: _FacetDataStorage;
  35095. _visibility: number;
  35096. _skeleton: Nullable<Skeleton>;
  35097. _layerMask: number;
  35098. _computeBonesUsingShaders: boolean;
  35099. _isActive: boolean;
  35100. _onlyForInstances: boolean;
  35101. _isActiveIntermediate: boolean;
  35102. _onlyForInstancesIntermediate: boolean;
  35103. _actAsRegularMesh: boolean;
  35104. _currentLOD: Nullable<AbstractMesh>;
  35105. _currentLODIsUpToDate: boolean;
  35106. }
  35107. /**
  35108. * Class used to store all common mesh properties
  35109. */
  35110. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  35111. /** No occlusion */
  35112. static OCCLUSION_TYPE_NONE: number;
  35113. /** Occlusion set to optimisitic */
  35114. static OCCLUSION_TYPE_OPTIMISTIC: number;
  35115. /** Occlusion set to strict */
  35116. static OCCLUSION_TYPE_STRICT: number;
  35117. /** Use an accurante occlusion algorithm */
  35118. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  35119. /** Use a conservative occlusion algorithm */
  35120. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  35121. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  35122. * Test order :
  35123. * Is the bounding sphere outside the frustum ?
  35124. * If not, are the bounding box vertices outside the frustum ?
  35125. * It not, then the cullable object is in the frustum.
  35126. */
  35127. static readonly CULLINGSTRATEGY_STANDARD: number;
  35128. /** Culling strategy : Bounding Sphere Only.
  35129. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  35130. * It's also less accurate than the standard because some not visible objects can still be selected.
  35131. * Test : is the bounding sphere outside the frustum ?
  35132. * If not, then the cullable object is in the frustum.
  35133. */
  35134. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  35135. /** Culling strategy : Optimistic Inclusion.
  35136. * This in an inclusion test first, then the standard exclusion test.
  35137. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  35138. * 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.
  35139. * Anyway, it's as accurate as the standard strategy.
  35140. * Test :
  35141. * Is the cullable object bounding sphere center in the frustum ?
  35142. * If not, apply the default culling strategy.
  35143. */
  35144. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  35145. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  35146. * This in an inclusion test first, then the bounding sphere only exclusion test.
  35147. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  35148. * 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.
  35149. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  35150. * Test :
  35151. * Is the cullable object bounding sphere center in the frustum ?
  35152. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  35153. */
  35154. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  35155. /**
  35156. * No billboard
  35157. */
  35158. static get BILLBOARDMODE_NONE(): number;
  35159. /** Billboard on X axis */
  35160. static get BILLBOARDMODE_X(): number;
  35161. /** Billboard on Y axis */
  35162. static get BILLBOARDMODE_Y(): number;
  35163. /** Billboard on Z axis */
  35164. static get BILLBOARDMODE_Z(): number;
  35165. /** Billboard on all axes */
  35166. static get BILLBOARDMODE_ALL(): number;
  35167. /** Billboard on using position instead of orientation */
  35168. static get BILLBOARDMODE_USE_POSITION(): number;
  35169. /** @hidden */
  35170. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  35171. /**
  35172. * The culling strategy to use to check whether the mesh must be rendered or not.
  35173. * This value can be changed at any time and will be used on the next render mesh selection.
  35174. * The possible values are :
  35175. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  35176. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  35177. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  35178. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  35179. * Please read each static variable documentation to get details about the culling process.
  35180. * */
  35181. cullingStrategy: number;
  35182. /**
  35183. * Gets the number of facets in the mesh
  35184. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  35185. */
  35186. get facetNb(): number;
  35187. /**
  35188. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  35189. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  35190. */
  35191. get partitioningSubdivisions(): number;
  35192. set partitioningSubdivisions(nb: number);
  35193. /**
  35194. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  35195. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  35196. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  35197. */
  35198. get partitioningBBoxRatio(): number;
  35199. set partitioningBBoxRatio(ratio: number);
  35200. /**
  35201. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  35202. * Works only for updatable meshes.
  35203. * Doesn't work with multi-materials
  35204. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  35205. */
  35206. get mustDepthSortFacets(): boolean;
  35207. set mustDepthSortFacets(sort: boolean);
  35208. /**
  35209. * The location (Vector3) where the facet depth sort must be computed from.
  35210. * By default, the active camera position.
  35211. * Used only when facet depth sort is enabled
  35212. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  35213. */
  35214. get facetDepthSortFrom(): Vector3;
  35215. set facetDepthSortFrom(location: Vector3);
  35216. /**
  35217. * gets a boolean indicating if facetData is enabled
  35218. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  35219. */
  35220. get isFacetDataEnabled(): boolean;
  35221. /** @hidden */
  35222. _updateNonUniformScalingState(value: boolean): boolean;
  35223. /**
  35224. * An event triggered when this mesh collides with another one
  35225. */
  35226. onCollideObservable: Observable<AbstractMesh>;
  35227. /** Set a function to call when this mesh collides with another one */
  35228. set onCollide(callback: () => void);
  35229. /**
  35230. * An event triggered when the collision's position changes
  35231. */
  35232. onCollisionPositionChangeObservable: Observable<Vector3>;
  35233. /** Set a function to call when the collision's position changes */
  35234. set onCollisionPositionChange(callback: () => void);
  35235. /**
  35236. * An event triggered when material is changed
  35237. */
  35238. onMaterialChangedObservable: Observable<AbstractMesh>;
  35239. /**
  35240. * Gets or sets the orientation for POV movement & rotation
  35241. */
  35242. definedFacingForward: boolean;
  35243. /** @hidden */
  35244. _occlusionQuery: Nullable<WebGLQuery>;
  35245. /** @hidden */
  35246. _renderingGroup: Nullable<RenderingGroup>;
  35247. /**
  35248. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  35249. */
  35250. get visibility(): number;
  35251. /**
  35252. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  35253. */
  35254. set visibility(value: number);
  35255. /** Gets or sets the alpha index used to sort transparent meshes
  35256. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  35257. */
  35258. alphaIndex: number;
  35259. /**
  35260. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  35261. */
  35262. isVisible: boolean;
  35263. /**
  35264. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  35265. */
  35266. isPickable: boolean;
  35267. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  35268. showSubMeshesBoundingBox: boolean;
  35269. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  35270. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  35271. */
  35272. isBlocker: boolean;
  35273. /**
  35274. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  35275. */
  35276. enablePointerMoveEvents: boolean;
  35277. private _renderingGroupId;
  35278. /**
  35279. * Specifies the rendering group id for this mesh (0 by default)
  35280. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  35281. */
  35282. get renderingGroupId(): number;
  35283. set renderingGroupId(value: number);
  35284. private _material;
  35285. /** Gets or sets current material */
  35286. get material(): Nullable<Material>;
  35287. set material(value: Nullable<Material>);
  35288. /**
  35289. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  35290. * @see https://doc.babylonjs.com/babylon101/shadows
  35291. */
  35292. get receiveShadows(): boolean;
  35293. set receiveShadows(value: boolean);
  35294. /** Defines color to use when rendering outline */
  35295. outlineColor: Color3;
  35296. /** Define width to use when rendering outline */
  35297. outlineWidth: number;
  35298. /** Defines color to use when rendering overlay */
  35299. overlayColor: Color3;
  35300. /** Defines alpha to use when rendering overlay */
  35301. overlayAlpha: number;
  35302. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  35303. get hasVertexAlpha(): boolean;
  35304. set hasVertexAlpha(value: boolean);
  35305. /** 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) */
  35306. get useVertexColors(): boolean;
  35307. set useVertexColors(value: boolean);
  35308. /**
  35309. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  35310. */
  35311. get computeBonesUsingShaders(): boolean;
  35312. set computeBonesUsingShaders(value: boolean);
  35313. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  35314. get numBoneInfluencers(): number;
  35315. set numBoneInfluencers(value: number);
  35316. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  35317. get applyFog(): boolean;
  35318. set applyFog(value: boolean);
  35319. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  35320. useOctreeForRenderingSelection: boolean;
  35321. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  35322. useOctreeForPicking: boolean;
  35323. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  35324. useOctreeForCollisions: boolean;
  35325. /**
  35326. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  35327. * @see https://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  35328. */
  35329. get layerMask(): number;
  35330. set layerMask(value: number);
  35331. /**
  35332. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  35333. */
  35334. alwaysSelectAsActiveMesh: boolean;
  35335. /**
  35336. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  35337. */
  35338. doNotSyncBoundingInfo: boolean;
  35339. /**
  35340. * Gets or sets the current action manager
  35341. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  35342. */
  35343. actionManager: Nullable<AbstractActionManager>;
  35344. private _meshCollisionData;
  35345. /**
  35346. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  35347. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  35348. */
  35349. ellipsoid: Vector3;
  35350. /**
  35351. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  35352. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  35353. */
  35354. ellipsoidOffset: Vector3;
  35355. /**
  35356. * Gets or sets a collision mask used to mask collisions (default is -1).
  35357. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  35358. */
  35359. get collisionMask(): number;
  35360. set collisionMask(mask: number);
  35361. /**
  35362. * Gets or sets a collision response flag (default is true).
  35363. * when collisionResponse is false, events are still triggered but colliding entity has no response
  35364. * This helps creating trigger volume when user wants collision feedback events but not position/velocity
  35365. * to respond to the collision.
  35366. */
  35367. get collisionResponse(): boolean;
  35368. set collisionResponse(response: boolean);
  35369. /**
  35370. * Gets or sets the current collision group mask (-1 by default).
  35371. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  35372. */
  35373. get collisionGroup(): number;
  35374. set collisionGroup(mask: number);
  35375. /**
  35376. * Gets or sets current surrounding meshes (null by default).
  35377. *
  35378. * By default collision detection is tested against every mesh in the scene.
  35379. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  35380. * meshes will be tested for the collision.
  35381. *
  35382. * Note: if set to an empty array no collision will happen when this mesh is moved.
  35383. */
  35384. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  35385. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  35386. /**
  35387. * Defines edge width used when edgesRenderer is enabled
  35388. * @see https://www.babylonjs-playground.com/#10OJSG#13
  35389. */
  35390. edgesWidth: number;
  35391. /**
  35392. * Defines edge color used when edgesRenderer is enabled
  35393. * @see https://www.babylonjs-playground.com/#10OJSG#13
  35394. */
  35395. edgesColor: Color4;
  35396. /** @hidden */
  35397. _edgesRenderer: Nullable<IEdgesRenderer>;
  35398. /** @hidden */
  35399. _masterMesh: Nullable<AbstractMesh>;
  35400. /** @hidden */
  35401. _boundingInfo: Nullable<BoundingInfo>;
  35402. /** @hidden */
  35403. _renderId: number;
  35404. /**
  35405. * Gets or sets the list of subMeshes
  35406. * @see https://doc.babylonjs.com/how_to/multi_materials
  35407. */
  35408. subMeshes: SubMesh[];
  35409. /** @hidden */
  35410. _intersectionsInProgress: AbstractMesh[];
  35411. /** @hidden */
  35412. _unIndexed: boolean;
  35413. /** @hidden */
  35414. _lightSources: Light[];
  35415. /** Gets the list of lights affecting that mesh */
  35416. get lightSources(): Light[];
  35417. /** @hidden */
  35418. get _positions(): Nullable<Vector3[]>;
  35419. /** @hidden */
  35420. _waitingData: {
  35421. lods: Nullable<any>;
  35422. actions: Nullable<any>;
  35423. freezeWorldMatrix: Nullable<boolean>;
  35424. };
  35425. /** @hidden */
  35426. _bonesTransformMatrices: Nullable<Float32Array>;
  35427. /** @hidden */
  35428. _transformMatrixTexture: Nullable<RawTexture>;
  35429. /**
  35430. * Gets or sets a skeleton to apply skining transformations
  35431. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  35432. */
  35433. set skeleton(value: Nullable<Skeleton>);
  35434. get skeleton(): Nullable<Skeleton>;
  35435. /**
  35436. * An event triggered when the mesh is rebuilt.
  35437. */
  35438. onRebuildObservable: Observable<AbstractMesh>;
  35439. /**
  35440. * Creates a new AbstractMesh
  35441. * @param name defines the name of the mesh
  35442. * @param scene defines the hosting scene
  35443. */
  35444. constructor(name: string, scene?: Nullable<Scene>);
  35445. /**
  35446. * Returns the string "AbstractMesh"
  35447. * @returns "AbstractMesh"
  35448. */
  35449. getClassName(): string;
  35450. /**
  35451. * Gets a string representation of the current mesh
  35452. * @param fullDetails defines a boolean indicating if full details must be included
  35453. * @returns a string representation of the current mesh
  35454. */
  35455. toString(fullDetails?: boolean): string;
  35456. /**
  35457. * @hidden
  35458. */
  35459. protected _getEffectiveParent(): Nullable<Node>;
  35460. /** @hidden */
  35461. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  35462. /** @hidden */
  35463. _rebuild(): void;
  35464. /** @hidden */
  35465. _resyncLightSources(): void;
  35466. /** @hidden */
  35467. _resyncLightSource(light: Light): void;
  35468. /** @hidden */
  35469. _unBindEffect(): void;
  35470. /** @hidden */
  35471. _removeLightSource(light: Light, dispose: boolean): void;
  35472. private _markSubMeshesAsDirty;
  35473. /** @hidden */
  35474. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  35475. /** @hidden */
  35476. _markSubMeshesAsAttributesDirty(): void;
  35477. /** @hidden */
  35478. _markSubMeshesAsMiscDirty(): void;
  35479. /**
  35480. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  35481. */
  35482. get scaling(): Vector3;
  35483. set scaling(newScaling: Vector3);
  35484. /**
  35485. * Returns true if the mesh is blocked. Implemented by child classes
  35486. */
  35487. get isBlocked(): boolean;
  35488. /**
  35489. * Returns the mesh itself by default. Implemented by child classes
  35490. * @param camera defines the camera to use to pick the right LOD level
  35491. * @returns the currentAbstractMesh
  35492. */
  35493. getLOD(camera: Camera): Nullable<AbstractMesh>;
  35494. /**
  35495. * Returns 0 by default. Implemented by child classes
  35496. * @returns an integer
  35497. */
  35498. getTotalVertices(): number;
  35499. /**
  35500. * Returns a positive integer : the total number of indices in this mesh geometry.
  35501. * @returns the numner of indices or zero if the mesh has no geometry.
  35502. */
  35503. getTotalIndices(): number;
  35504. /**
  35505. * Returns null by default. Implemented by child classes
  35506. * @returns null
  35507. */
  35508. getIndices(): Nullable<IndicesArray>;
  35509. /**
  35510. * Returns the array of the requested vertex data kind. Implemented by child classes
  35511. * @param kind defines the vertex data kind to use
  35512. * @returns null
  35513. */
  35514. getVerticesData(kind: string): Nullable<FloatArray>;
  35515. /**
  35516. * Sets the vertex data of the mesh geometry for the requested `kind`.
  35517. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  35518. * Note that a new underlying VertexBuffer object is created each call.
  35519. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  35520. * @param kind defines vertex data kind:
  35521. * * VertexBuffer.PositionKind
  35522. * * VertexBuffer.UVKind
  35523. * * VertexBuffer.UV2Kind
  35524. * * VertexBuffer.UV3Kind
  35525. * * VertexBuffer.UV4Kind
  35526. * * VertexBuffer.UV5Kind
  35527. * * VertexBuffer.UV6Kind
  35528. * * VertexBuffer.ColorKind
  35529. * * VertexBuffer.MatricesIndicesKind
  35530. * * VertexBuffer.MatricesIndicesExtraKind
  35531. * * VertexBuffer.MatricesWeightsKind
  35532. * * VertexBuffer.MatricesWeightsExtraKind
  35533. * @param data defines the data source
  35534. * @param updatable defines if the data must be flagged as updatable (or static)
  35535. * @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
  35536. * @returns the current mesh
  35537. */
  35538. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  35539. /**
  35540. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  35541. * If the mesh has no geometry, it is simply returned as it is.
  35542. * @param kind defines vertex data kind:
  35543. * * VertexBuffer.PositionKind
  35544. * * VertexBuffer.UVKind
  35545. * * VertexBuffer.UV2Kind
  35546. * * VertexBuffer.UV3Kind
  35547. * * VertexBuffer.UV4Kind
  35548. * * VertexBuffer.UV5Kind
  35549. * * VertexBuffer.UV6Kind
  35550. * * VertexBuffer.ColorKind
  35551. * * VertexBuffer.MatricesIndicesKind
  35552. * * VertexBuffer.MatricesIndicesExtraKind
  35553. * * VertexBuffer.MatricesWeightsKind
  35554. * * VertexBuffer.MatricesWeightsExtraKind
  35555. * @param data defines the data source
  35556. * @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
  35557. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  35558. * @returns the current mesh
  35559. */
  35560. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  35561. /**
  35562. * Sets the mesh indices,
  35563. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  35564. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  35565. * @param totalVertices Defines the total number of vertices
  35566. * @returns the current mesh
  35567. */
  35568. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  35569. /**
  35570. * Gets a boolean indicating if specific vertex data is present
  35571. * @param kind defines the vertex data kind to use
  35572. * @returns true is data kind is present
  35573. */
  35574. isVerticesDataPresent(kind: string): boolean;
  35575. /**
  35576. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  35577. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  35578. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  35579. * @returns a BoundingInfo
  35580. */
  35581. getBoundingInfo(): BoundingInfo;
  35582. /**
  35583. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  35584. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  35585. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  35586. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  35587. * @returns the current mesh
  35588. */
  35589. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  35590. /**
  35591. * Overwrite the current bounding info
  35592. * @param boundingInfo defines the new bounding info
  35593. * @returns the current mesh
  35594. */
  35595. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  35596. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  35597. get useBones(): boolean;
  35598. /** @hidden */
  35599. _preActivate(): void;
  35600. /** @hidden */
  35601. _preActivateForIntermediateRendering(renderId: number): void;
  35602. /** @hidden */
  35603. _activate(renderId: number, intermediateRendering: boolean): boolean;
  35604. /** @hidden */
  35605. _postActivate(): void;
  35606. /** @hidden */
  35607. _freeze(): void;
  35608. /** @hidden */
  35609. _unFreeze(): void;
  35610. /**
  35611. * Gets the current world matrix
  35612. * @returns a Matrix
  35613. */
  35614. getWorldMatrix(): Matrix;
  35615. /** @hidden */
  35616. _getWorldMatrixDeterminant(): number;
  35617. /**
  35618. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  35619. */
  35620. get isAnInstance(): boolean;
  35621. /**
  35622. * Gets a boolean indicating if this mesh has instances
  35623. */
  35624. get hasInstances(): boolean;
  35625. /**
  35626. * Gets a boolean indicating if this mesh has thin instances
  35627. */
  35628. get hasThinInstances(): boolean;
  35629. /**
  35630. * Perform relative position change from the point of view of behind the front of the mesh.
  35631. * This is performed taking into account the meshes current rotation, so you do not have to care.
  35632. * Supports definition of mesh facing forward or backward
  35633. * @param amountRight defines the distance on the right axis
  35634. * @param amountUp defines the distance on the up axis
  35635. * @param amountForward defines the distance on the forward axis
  35636. * @returns the current mesh
  35637. */
  35638. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  35639. /**
  35640. * Calculate relative position change from the point of view of behind the front of the mesh.
  35641. * This is performed taking into account the meshes current rotation, so you do not have to care.
  35642. * Supports definition of mesh facing forward or backward
  35643. * @param amountRight defines the distance on the right axis
  35644. * @param amountUp defines the distance on the up axis
  35645. * @param amountForward defines the distance on the forward axis
  35646. * @returns the new displacement vector
  35647. */
  35648. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  35649. /**
  35650. * Perform relative rotation change from the point of view of behind the front of the mesh.
  35651. * Supports definition of mesh facing forward or backward
  35652. * @param flipBack defines the flip
  35653. * @param twirlClockwise defines the twirl
  35654. * @param tiltRight defines the tilt
  35655. * @returns the current mesh
  35656. */
  35657. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  35658. /**
  35659. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  35660. * Supports definition of mesh facing forward or backward.
  35661. * @param flipBack defines the flip
  35662. * @param twirlClockwise defines the twirl
  35663. * @param tiltRight defines the tilt
  35664. * @returns the new rotation vector
  35665. */
  35666. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  35667. /**
  35668. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  35669. * This means the mesh underlying bounding box and sphere are recomputed.
  35670. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  35671. * @returns the current mesh
  35672. */
  35673. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  35674. /** @hidden */
  35675. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  35676. /** @hidden */
  35677. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  35678. /** @hidden */
  35679. _updateBoundingInfo(): AbstractMesh;
  35680. /** @hidden */
  35681. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  35682. /** @hidden */
  35683. protected _afterComputeWorldMatrix(): void;
  35684. /** @hidden */
  35685. get _effectiveMesh(): AbstractMesh;
  35686. /**
  35687. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  35688. * A mesh is in the frustum if its bounding box intersects the frustum
  35689. * @param frustumPlanes defines the frustum to test
  35690. * @returns true if the mesh is in the frustum planes
  35691. */
  35692. isInFrustum(frustumPlanes: Plane[]): boolean;
  35693. /**
  35694. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  35695. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  35696. * @param frustumPlanes defines the frustum to test
  35697. * @returns true if the mesh is completely in the frustum planes
  35698. */
  35699. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  35700. /**
  35701. * True if the mesh intersects another mesh or a SolidParticle object
  35702. * @param mesh defines a target mesh or SolidParticle to test
  35703. * @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)
  35704. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  35705. * @returns true if there is an intersection
  35706. */
  35707. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  35708. /**
  35709. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  35710. * @param point defines the point to test
  35711. * @returns true if there is an intersection
  35712. */
  35713. intersectsPoint(point: Vector3): boolean;
  35714. /**
  35715. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  35716. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  35717. */
  35718. get checkCollisions(): boolean;
  35719. set checkCollisions(collisionEnabled: boolean);
  35720. /**
  35721. * Gets Collider object used to compute collisions (not physics)
  35722. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  35723. */
  35724. get collider(): Nullable<Collider>;
  35725. /**
  35726. * Move the mesh using collision engine
  35727. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  35728. * @param displacement defines the requested displacement vector
  35729. * @returns the current mesh
  35730. */
  35731. moveWithCollisions(displacement: Vector3): AbstractMesh;
  35732. private _onCollisionPositionChange;
  35733. /** @hidden */
  35734. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  35735. /** @hidden */
  35736. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  35737. /** @hidden */
  35738. _checkCollision(collider: Collider): AbstractMesh;
  35739. /** @hidden */
  35740. _generatePointsArray(): boolean;
  35741. /**
  35742. * Checks if the passed Ray intersects with the mesh
  35743. * @param ray defines the ray to use
  35744. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  35745. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35746. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  35747. * @param worldToUse defines the world matrix to use to get the world coordinate of the intersection point
  35748. * @param skipBoundingInfo a boolean indicating if we should skip the bounding info check
  35749. * @returns the picking info
  35750. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  35751. */
  35752. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean, worldToUse?: Matrix, skipBoundingInfo?: boolean): PickingInfo;
  35753. /**
  35754. * Clones the current mesh
  35755. * @param name defines the mesh name
  35756. * @param newParent defines the new mesh parent
  35757. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  35758. * @returns the new mesh
  35759. */
  35760. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  35761. /**
  35762. * Disposes all the submeshes of the current meshnp
  35763. * @returns the current mesh
  35764. */
  35765. releaseSubMeshes(): AbstractMesh;
  35766. /**
  35767. * Releases resources associated with this abstract mesh.
  35768. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  35769. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  35770. */
  35771. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  35772. /**
  35773. * Adds the passed mesh as a child to the current mesh
  35774. * @param mesh defines the child mesh
  35775. * @returns the current mesh
  35776. */
  35777. addChild(mesh: AbstractMesh): AbstractMesh;
  35778. /**
  35779. * Removes the passed mesh from the current mesh children list
  35780. * @param mesh defines the child mesh
  35781. * @returns the current mesh
  35782. */
  35783. removeChild(mesh: AbstractMesh): AbstractMesh;
  35784. /** @hidden */
  35785. private _initFacetData;
  35786. /**
  35787. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  35788. * This method can be called within the render loop.
  35789. * 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
  35790. * @returns the current mesh
  35791. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35792. */
  35793. updateFacetData(): AbstractMesh;
  35794. /**
  35795. * Returns the facetLocalNormals array.
  35796. * The normals are expressed in the mesh local spac
  35797. * @returns an array of Vector3
  35798. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35799. */
  35800. getFacetLocalNormals(): Vector3[];
  35801. /**
  35802. * Returns the facetLocalPositions array.
  35803. * The facet positions are expressed in the mesh local space
  35804. * @returns an array of Vector3
  35805. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35806. */
  35807. getFacetLocalPositions(): Vector3[];
  35808. /**
  35809. * Returns the facetLocalPartioning array
  35810. * @returns an array of array of numbers
  35811. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35812. */
  35813. getFacetLocalPartitioning(): number[][];
  35814. /**
  35815. * Returns the i-th facet position in the world system.
  35816. * This method allocates a new Vector3 per call
  35817. * @param i defines the facet index
  35818. * @returns a new Vector3
  35819. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35820. */
  35821. getFacetPosition(i: number): Vector3;
  35822. /**
  35823. * Sets the reference Vector3 with the i-th facet position in the world system
  35824. * @param i defines the facet index
  35825. * @param ref defines the target vector
  35826. * @returns the current mesh
  35827. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35828. */
  35829. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  35830. /**
  35831. * Returns the i-th facet normal in the world system.
  35832. * This method allocates a new Vector3 per call
  35833. * @param i defines the facet index
  35834. * @returns a new Vector3
  35835. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35836. */
  35837. getFacetNormal(i: number): Vector3;
  35838. /**
  35839. * Sets the reference Vector3 with the i-th facet normal in the world system
  35840. * @param i defines the facet index
  35841. * @param ref defines the target vector
  35842. * @returns the current mesh
  35843. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35844. */
  35845. getFacetNormalToRef(i: number, ref: Vector3): this;
  35846. /**
  35847. * 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)
  35848. * @param x defines x coordinate
  35849. * @param y defines y coordinate
  35850. * @param z defines z coordinate
  35851. * @returns the array of facet indexes
  35852. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35853. */
  35854. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  35855. /**
  35856. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  35857. * @param projected sets as the (x,y,z) world projection on the facet
  35858. * @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
  35859. * @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
  35860. * @param x defines x coordinate
  35861. * @param y defines y coordinate
  35862. * @param z defines z coordinate
  35863. * @returns the face index if found (or null instead)
  35864. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35865. */
  35866. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  35867. /**
  35868. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  35869. * @param projected sets as the (x,y,z) local projection on the facet
  35870. * @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
  35871. * @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
  35872. * @param x defines x coordinate
  35873. * @param y defines y coordinate
  35874. * @param z defines z coordinate
  35875. * @returns the face index if found (or null instead)
  35876. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35877. */
  35878. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  35879. /**
  35880. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  35881. * @returns the parameters
  35882. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35883. */
  35884. getFacetDataParameters(): any;
  35885. /**
  35886. * Disables the feature FacetData and frees the related memory
  35887. * @returns the current mesh
  35888. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35889. */
  35890. disableFacetData(): AbstractMesh;
  35891. /**
  35892. * Updates the AbstractMesh indices array
  35893. * @param indices defines the data source
  35894. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  35895. * @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)
  35896. * @returns the current mesh
  35897. */
  35898. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  35899. /**
  35900. * Creates new normals data for the mesh
  35901. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  35902. * @returns the current mesh
  35903. */
  35904. createNormals(updatable: boolean): AbstractMesh;
  35905. /**
  35906. * Align the mesh with a normal
  35907. * @param normal defines the normal to use
  35908. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  35909. * @returns the current mesh
  35910. */
  35911. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  35912. /** @hidden */
  35913. _checkOcclusionQuery(): boolean;
  35914. /**
  35915. * Disables the mesh edge rendering mode
  35916. * @returns the currentAbstractMesh
  35917. */
  35918. disableEdgesRendering(): AbstractMesh;
  35919. /**
  35920. * Enables the edge rendering mode on the mesh.
  35921. * This mode makes the mesh edges visible
  35922. * @param epsilon defines the maximal distance between two angles to detect a face
  35923. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  35924. * @param options options to the edge renderer
  35925. * @returns the currentAbstractMesh
  35926. * @see https://www.babylonjs-playground.com/#19O9TU#0
  35927. */
  35928. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean, options?: IEdgesRendererOptions): AbstractMesh;
  35929. /**
  35930. * This function returns all of the particle systems in the scene that use the mesh as an emitter.
  35931. * @returns an array of particle systems in the scene that use the mesh as an emitter
  35932. */
  35933. getConnectedParticleSystems(): IParticleSystem[];
  35934. }
  35935. }
  35936. declare module BABYLON {
  35937. /**
  35938. * Interface used to define ActionEvent
  35939. */
  35940. export interface IActionEvent {
  35941. /** The mesh or sprite that triggered the action */
  35942. source: any;
  35943. /** The X mouse cursor position at the time of the event */
  35944. pointerX: number;
  35945. /** The Y mouse cursor position at the time of the event */
  35946. pointerY: number;
  35947. /** The mesh that is currently pointed at (can be null) */
  35948. meshUnderPointer: Nullable<AbstractMesh>;
  35949. /** the original (browser) event that triggered the ActionEvent */
  35950. sourceEvent?: any;
  35951. /** additional data for the event */
  35952. additionalData?: any;
  35953. }
  35954. /**
  35955. * ActionEvent is the event being sent when an action is triggered.
  35956. */
  35957. export class ActionEvent implements IActionEvent {
  35958. /** The mesh or sprite that triggered the action */
  35959. source: any;
  35960. /** The X mouse cursor position at the time of the event */
  35961. pointerX: number;
  35962. /** The Y mouse cursor position at the time of the event */
  35963. pointerY: number;
  35964. /** The mesh that is currently pointed at (can be null) */
  35965. meshUnderPointer: Nullable<AbstractMesh>;
  35966. /** the original (browser) event that triggered the ActionEvent */
  35967. sourceEvent?: any;
  35968. /** additional data for the event */
  35969. additionalData?: any;
  35970. /**
  35971. * Creates a new ActionEvent
  35972. * @param source The mesh or sprite that triggered the action
  35973. * @param pointerX The X mouse cursor position at the time of the event
  35974. * @param pointerY The Y mouse cursor position at the time of the event
  35975. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  35976. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  35977. * @param additionalData additional data for the event
  35978. */
  35979. constructor(
  35980. /** The mesh or sprite that triggered the action */
  35981. source: any,
  35982. /** The X mouse cursor position at the time of the event */
  35983. pointerX: number,
  35984. /** The Y mouse cursor position at the time of the event */
  35985. pointerY: number,
  35986. /** The mesh that is currently pointed at (can be null) */
  35987. meshUnderPointer: Nullable<AbstractMesh>,
  35988. /** the original (browser) event that triggered the ActionEvent */
  35989. sourceEvent?: any,
  35990. /** additional data for the event */
  35991. additionalData?: any);
  35992. /**
  35993. * Helper function to auto-create an ActionEvent from a source mesh.
  35994. * @param source The source mesh that triggered the event
  35995. * @param evt The original (browser) event
  35996. * @param additionalData additional data for the event
  35997. * @returns the new ActionEvent
  35998. */
  35999. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  36000. /**
  36001. * Helper function to auto-create an ActionEvent from a source sprite
  36002. * @param source The source sprite that triggered the event
  36003. * @param scene Scene associated with the sprite
  36004. * @param evt The original (browser) event
  36005. * @param additionalData additional data for the event
  36006. * @returns the new ActionEvent
  36007. */
  36008. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  36009. /**
  36010. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  36011. * @param scene the scene where the event occurred
  36012. * @param evt The original (browser) event
  36013. * @returns the new ActionEvent
  36014. */
  36015. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  36016. /**
  36017. * Helper function to auto-create an ActionEvent from a primitive
  36018. * @param prim defines the target primitive
  36019. * @param pointerPos defines the pointer position
  36020. * @param evt The original (browser) event
  36021. * @param additionalData additional data for the event
  36022. * @returns the new ActionEvent
  36023. */
  36024. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  36025. }
  36026. }
  36027. declare module BABYLON {
  36028. /**
  36029. * Abstract class used to decouple action Manager from scene and meshes.
  36030. * Do not instantiate.
  36031. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  36032. */
  36033. export abstract class AbstractActionManager implements IDisposable {
  36034. /** Gets the list of active triggers */
  36035. static Triggers: {
  36036. [key: string]: number;
  36037. };
  36038. /** Gets the cursor to use when hovering items */
  36039. hoverCursor: string;
  36040. /** Gets the list of actions */
  36041. actions: IAction[];
  36042. /**
  36043. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  36044. */
  36045. isRecursive: boolean;
  36046. /**
  36047. * Releases all associated resources
  36048. */
  36049. abstract dispose(): void;
  36050. /**
  36051. * Does this action manager has pointer triggers
  36052. */
  36053. abstract get hasPointerTriggers(): boolean;
  36054. /**
  36055. * Does this action manager has pick triggers
  36056. */
  36057. abstract get hasPickTriggers(): boolean;
  36058. /**
  36059. * Process a specific trigger
  36060. * @param trigger defines the trigger to process
  36061. * @param evt defines the event details to be processed
  36062. */
  36063. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  36064. /**
  36065. * Does this action manager handles actions of any of the given triggers
  36066. * @param triggers defines the triggers to be tested
  36067. * @return a boolean indicating whether one (or more) of the triggers is handled
  36068. */
  36069. abstract hasSpecificTriggers(triggers: number[]): boolean;
  36070. /**
  36071. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  36072. * speed.
  36073. * @param triggerA defines the trigger to be tested
  36074. * @param triggerB defines the trigger to be tested
  36075. * @return a boolean indicating whether one (or more) of the triggers is handled
  36076. */
  36077. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  36078. /**
  36079. * Does this action manager handles actions of a given trigger
  36080. * @param trigger defines the trigger to be tested
  36081. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  36082. * @return whether the trigger is handled
  36083. */
  36084. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  36085. /**
  36086. * Serialize this manager to a JSON object
  36087. * @param name defines the property name to store this manager
  36088. * @returns a JSON representation of this manager
  36089. */
  36090. abstract serialize(name: string): any;
  36091. /**
  36092. * Registers an action to this action manager
  36093. * @param action defines the action to be registered
  36094. * @return the action amended (prepared) after registration
  36095. */
  36096. abstract registerAction(action: IAction): Nullable<IAction>;
  36097. /**
  36098. * Unregisters an action to this action manager
  36099. * @param action defines the action to be unregistered
  36100. * @return a boolean indicating whether the action has been unregistered
  36101. */
  36102. abstract unregisterAction(action: IAction): Boolean;
  36103. /**
  36104. * Does exist one action manager with at least one trigger
  36105. **/
  36106. static get HasTriggers(): boolean;
  36107. /**
  36108. * Does exist one action manager with at least one pick trigger
  36109. **/
  36110. static get HasPickTriggers(): boolean;
  36111. /**
  36112. * Does exist one action manager that handles actions of a given trigger
  36113. * @param trigger defines the trigger to be tested
  36114. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  36115. **/
  36116. static HasSpecificTrigger(trigger: number): boolean;
  36117. }
  36118. }
  36119. declare module BABYLON {
  36120. /**
  36121. * Defines how a node can be built from a string name.
  36122. */
  36123. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  36124. /**
  36125. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  36126. */
  36127. export class Node implements IBehaviorAware<Node> {
  36128. /** @hidden */
  36129. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  36130. private static _NodeConstructors;
  36131. /**
  36132. * Add a new node constructor
  36133. * @param type defines the type name of the node to construct
  36134. * @param constructorFunc defines the constructor function
  36135. */
  36136. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  36137. /**
  36138. * Returns a node constructor based on type name
  36139. * @param type defines the type name
  36140. * @param name defines the new node name
  36141. * @param scene defines the hosting scene
  36142. * @param options defines optional options to transmit to constructors
  36143. * @returns the new constructor or null
  36144. */
  36145. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  36146. /**
  36147. * Gets or sets the name of the node
  36148. */
  36149. name: string;
  36150. /**
  36151. * Gets or sets the id of the node
  36152. */
  36153. id: string;
  36154. /**
  36155. * Gets or sets the unique id of the node
  36156. */
  36157. uniqueId: number;
  36158. /**
  36159. * Gets or sets a string used to store user defined state for the node
  36160. */
  36161. state: string;
  36162. /**
  36163. * Gets or sets an object used to store user defined information for the node
  36164. */
  36165. metadata: any;
  36166. /**
  36167. * For internal use only. Please do not use.
  36168. */
  36169. reservedDataStore: any;
  36170. /**
  36171. * List of inspectable custom properties (used by the Inspector)
  36172. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  36173. */
  36174. inspectableCustomProperties: IInspectable[];
  36175. private _doNotSerialize;
  36176. /**
  36177. * Gets or sets a boolean used to define if the node must be serialized
  36178. */
  36179. get doNotSerialize(): boolean;
  36180. set doNotSerialize(value: boolean);
  36181. /** @hidden */
  36182. _isDisposed: boolean;
  36183. /**
  36184. * Gets a list of Animations associated with the node
  36185. */
  36186. animations: Animation[];
  36187. protected _ranges: {
  36188. [name: string]: Nullable<AnimationRange>;
  36189. };
  36190. /**
  36191. * Callback raised when the node is ready to be used
  36192. */
  36193. onReady: Nullable<(node: Node) => void>;
  36194. private _isEnabled;
  36195. private _isParentEnabled;
  36196. private _isReady;
  36197. /** @hidden */
  36198. _currentRenderId: number;
  36199. private _parentUpdateId;
  36200. /** @hidden */
  36201. _childUpdateId: number;
  36202. /** @hidden */
  36203. _waitingParentId: Nullable<string>;
  36204. /** @hidden */
  36205. _scene: Scene;
  36206. /** @hidden */
  36207. _cache: any;
  36208. private _parentNode;
  36209. private _children;
  36210. /** @hidden */
  36211. _worldMatrix: Matrix;
  36212. /** @hidden */
  36213. _worldMatrixDeterminant: number;
  36214. /** @hidden */
  36215. _worldMatrixDeterminantIsDirty: boolean;
  36216. /** @hidden */
  36217. private _sceneRootNodesIndex;
  36218. /**
  36219. * Gets a boolean indicating if the node has been disposed
  36220. * @returns true if the node was disposed
  36221. */
  36222. isDisposed(): boolean;
  36223. /**
  36224. * Gets or sets the parent of the node (without keeping the current position in the scene)
  36225. * @see https://doc.babylonjs.com/how_to/parenting
  36226. */
  36227. set parent(parent: Nullable<Node>);
  36228. get parent(): Nullable<Node>;
  36229. /** @hidden */
  36230. _addToSceneRootNodes(): void;
  36231. /** @hidden */
  36232. _removeFromSceneRootNodes(): void;
  36233. private _animationPropertiesOverride;
  36234. /**
  36235. * Gets or sets the animation properties override
  36236. */
  36237. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  36238. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  36239. /**
  36240. * Gets a string identifying the name of the class
  36241. * @returns "Node" string
  36242. */
  36243. getClassName(): string;
  36244. /** @hidden */
  36245. readonly _isNode: boolean;
  36246. /**
  36247. * An event triggered when the mesh is disposed
  36248. */
  36249. onDisposeObservable: Observable<Node>;
  36250. private _onDisposeObserver;
  36251. /**
  36252. * Sets a callback that will be raised when the node will be disposed
  36253. */
  36254. set onDispose(callback: () => void);
  36255. /**
  36256. * Creates a new Node
  36257. * @param name the name and id to be given to this node
  36258. * @param scene the scene this node will be added to
  36259. */
  36260. constructor(name: string, scene?: Nullable<Scene>);
  36261. /**
  36262. * Gets the scene of the node
  36263. * @returns a scene
  36264. */
  36265. getScene(): Scene;
  36266. /**
  36267. * Gets the engine of the node
  36268. * @returns a Engine
  36269. */
  36270. getEngine(): Engine;
  36271. private _behaviors;
  36272. /**
  36273. * Attach a behavior to the node
  36274. * @see https://doc.babylonjs.com/features/behaviour
  36275. * @param behavior defines the behavior to attach
  36276. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  36277. * @returns the current Node
  36278. */
  36279. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  36280. /**
  36281. * Remove an attached behavior
  36282. * @see https://doc.babylonjs.com/features/behaviour
  36283. * @param behavior defines the behavior to attach
  36284. * @returns the current Node
  36285. */
  36286. removeBehavior(behavior: Behavior<Node>): Node;
  36287. /**
  36288. * Gets the list of attached behaviors
  36289. * @see https://doc.babylonjs.com/features/behaviour
  36290. */
  36291. get behaviors(): Behavior<Node>[];
  36292. /**
  36293. * Gets an attached behavior by name
  36294. * @param name defines the name of the behavior to look for
  36295. * @see https://doc.babylonjs.com/features/behaviour
  36296. * @returns null if behavior was not found else the requested behavior
  36297. */
  36298. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  36299. /**
  36300. * Returns the latest update of the World matrix
  36301. * @returns a Matrix
  36302. */
  36303. getWorldMatrix(): Matrix;
  36304. /** @hidden */
  36305. _getWorldMatrixDeterminant(): number;
  36306. /**
  36307. * Returns directly the latest state of the mesh World matrix.
  36308. * A Matrix is returned.
  36309. */
  36310. get worldMatrixFromCache(): Matrix;
  36311. /** @hidden */
  36312. _initCache(): void;
  36313. /** @hidden */
  36314. updateCache(force?: boolean): void;
  36315. /** @hidden */
  36316. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  36317. /** @hidden */
  36318. _updateCache(ignoreParentClass?: boolean): void;
  36319. /** @hidden */
  36320. _isSynchronized(): boolean;
  36321. /** @hidden */
  36322. _markSyncedWithParent(): void;
  36323. /** @hidden */
  36324. isSynchronizedWithParent(): boolean;
  36325. /** @hidden */
  36326. isSynchronized(): boolean;
  36327. /**
  36328. * Is this node ready to be used/rendered
  36329. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  36330. * @return true if the node is ready
  36331. */
  36332. isReady(completeCheck?: boolean): boolean;
  36333. /**
  36334. * Is this node enabled?
  36335. * 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
  36336. * @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
  36337. * @return whether this node (and its parent) is enabled
  36338. */
  36339. isEnabled(checkAncestors?: boolean): boolean;
  36340. /** @hidden */
  36341. protected _syncParentEnabledState(): void;
  36342. /**
  36343. * Set the enabled state of this node
  36344. * @param value defines the new enabled state
  36345. */
  36346. setEnabled(value: boolean): void;
  36347. /**
  36348. * Is this node a descendant of the given node?
  36349. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  36350. * @param ancestor defines the parent node to inspect
  36351. * @returns a boolean indicating if this node is a descendant of the given node
  36352. */
  36353. isDescendantOf(ancestor: Node): boolean;
  36354. /** @hidden */
  36355. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  36356. /**
  36357. * Will return all nodes that have this node as ascendant
  36358. * @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
  36359. * @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
  36360. * @return all children nodes of all types
  36361. */
  36362. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  36363. /**
  36364. * Get all child-meshes of this node
  36365. * @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)
  36366. * @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
  36367. * @returns an array of AbstractMesh
  36368. */
  36369. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  36370. /**
  36371. * Get all direct children of this node
  36372. * @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
  36373. * @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)
  36374. * @returns an array of Node
  36375. */
  36376. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  36377. /** @hidden */
  36378. _setReady(state: boolean): void;
  36379. /**
  36380. * Get an animation by name
  36381. * @param name defines the name of the animation to look for
  36382. * @returns null if not found else the requested animation
  36383. */
  36384. getAnimationByName(name: string): Nullable<Animation>;
  36385. /**
  36386. * Creates an animation range for this node
  36387. * @param name defines the name of the range
  36388. * @param from defines the starting key
  36389. * @param to defines the end key
  36390. */
  36391. createAnimationRange(name: string, from: number, to: number): void;
  36392. /**
  36393. * Delete a specific animation range
  36394. * @param name defines the name of the range to delete
  36395. * @param deleteFrames defines if animation frames from the range must be deleted as well
  36396. */
  36397. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  36398. /**
  36399. * Get an animation range by name
  36400. * @param name defines the name of the animation range to look for
  36401. * @returns null if not found else the requested animation range
  36402. */
  36403. getAnimationRange(name: string): Nullable<AnimationRange>;
  36404. /**
  36405. * Gets the list of all animation ranges defined on this node
  36406. * @returns an array
  36407. */
  36408. getAnimationRanges(): Nullable<AnimationRange>[];
  36409. /**
  36410. * Will start the animation sequence
  36411. * @param name defines the range frames for animation sequence
  36412. * @param loop defines if the animation should loop (false by default)
  36413. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  36414. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  36415. * @returns the object created for this animation. If range does not exist, it will return null
  36416. */
  36417. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  36418. /**
  36419. * Serialize animation ranges into a JSON compatible object
  36420. * @returns serialization object
  36421. */
  36422. serializeAnimationRanges(): any;
  36423. /**
  36424. * Computes the world matrix of the node
  36425. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  36426. * @returns the world matrix
  36427. */
  36428. computeWorldMatrix(force?: boolean): Matrix;
  36429. /**
  36430. * Releases resources associated with this node.
  36431. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  36432. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  36433. */
  36434. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  36435. /**
  36436. * Parse animation range data from a serialization object and store them into a given node
  36437. * @param node defines where to store the animation ranges
  36438. * @param parsedNode defines the serialization object to read data from
  36439. * @param scene defines the hosting scene
  36440. */
  36441. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  36442. /**
  36443. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  36444. * @param includeDescendants Include bounding info from descendants as well (true by default)
  36445. * @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
  36446. * @returns the new bounding vectors
  36447. */
  36448. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  36449. min: Vector3;
  36450. max: Vector3;
  36451. };
  36452. }
  36453. }
  36454. declare module BABYLON {
  36455. /**
  36456. * @hidden
  36457. */
  36458. export class _IAnimationState {
  36459. key: number;
  36460. repeatCount: number;
  36461. workValue?: any;
  36462. loopMode?: number;
  36463. offsetValue?: any;
  36464. highLimitValue?: any;
  36465. }
  36466. /**
  36467. * Class used to store any kind of animation
  36468. */
  36469. export class Animation {
  36470. /**Name of the animation */
  36471. name: string;
  36472. /**Property to animate */
  36473. targetProperty: string;
  36474. /**The frames per second of the animation */
  36475. framePerSecond: number;
  36476. /**The data type of the animation */
  36477. dataType: number;
  36478. /**The loop mode of the animation */
  36479. loopMode?: number | undefined;
  36480. /**Specifies if blending should be enabled */
  36481. enableBlending?: boolean | undefined;
  36482. /**
  36483. * Use matrix interpolation instead of using direct key value when animating matrices
  36484. */
  36485. static AllowMatricesInterpolation: boolean;
  36486. /**
  36487. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  36488. */
  36489. static AllowMatrixDecomposeForInterpolation: boolean;
  36490. /** Define the Url to load snippets */
  36491. static SnippetUrl: string;
  36492. /** Snippet ID if the animation was created from the snippet server */
  36493. snippetId: string;
  36494. /**
  36495. * Stores the key frames of the animation
  36496. */
  36497. private _keys;
  36498. /**
  36499. * Stores the easing function of the animation
  36500. */
  36501. private _easingFunction;
  36502. /**
  36503. * @hidden Internal use only
  36504. */
  36505. _runtimeAnimations: RuntimeAnimation[];
  36506. /**
  36507. * The set of event that will be linked to this animation
  36508. */
  36509. private _events;
  36510. /**
  36511. * Stores an array of target property paths
  36512. */
  36513. targetPropertyPath: string[];
  36514. /**
  36515. * Stores the blending speed of the animation
  36516. */
  36517. blendingSpeed: number;
  36518. /**
  36519. * Stores the animation ranges for the animation
  36520. */
  36521. private _ranges;
  36522. /**
  36523. * @hidden Internal use
  36524. */
  36525. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  36526. /**
  36527. * Sets up an animation
  36528. * @param property The property to animate
  36529. * @param animationType The animation type to apply
  36530. * @param framePerSecond The frames per second of the animation
  36531. * @param easingFunction The easing function used in the animation
  36532. * @returns The created animation
  36533. */
  36534. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  36535. /**
  36536. * Create and start an animation on a node
  36537. * @param name defines the name of the global animation that will be run on all nodes
  36538. * @param node defines the root node where the animation will take place
  36539. * @param targetProperty defines property to animate
  36540. * @param framePerSecond defines the number of frame per second yo use
  36541. * @param totalFrame defines the number of frames in total
  36542. * @param from defines the initial value
  36543. * @param to defines the final value
  36544. * @param loopMode defines which loop mode you want to use (off by default)
  36545. * @param easingFunction defines the easing function to use (linear by default)
  36546. * @param onAnimationEnd defines the callback to call when animation end
  36547. * @returns the animatable created for this animation
  36548. */
  36549. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  36550. /**
  36551. * Create and start an animation on a node and its descendants
  36552. * @param name defines the name of the global animation that will be run on all nodes
  36553. * @param node defines the root node where the animation will take place
  36554. * @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
  36555. * @param targetProperty defines property to animate
  36556. * @param framePerSecond defines the number of frame per second to use
  36557. * @param totalFrame defines the number of frames in total
  36558. * @param from defines the initial value
  36559. * @param to defines the final value
  36560. * @param loopMode defines which loop mode you want to use (off by default)
  36561. * @param easingFunction defines the easing function to use (linear by default)
  36562. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  36563. * @returns the list of animatables created for all nodes
  36564. * @example https://www.babylonjs-playground.com/#MH0VLI
  36565. */
  36566. 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[]>;
  36567. /**
  36568. * Creates a new animation, merges it with the existing animations and starts it
  36569. * @param name Name of the animation
  36570. * @param node Node which contains the scene that begins the animations
  36571. * @param targetProperty Specifies which property to animate
  36572. * @param framePerSecond The frames per second of the animation
  36573. * @param totalFrame The total number of frames
  36574. * @param from The frame at the beginning of the animation
  36575. * @param to The frame at the end of the animation
  36576. * @param loopMode Specifies the loop mode of the animation
  36577. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  36578. * @param onAnimationEnd Callback to run once the animation is complete
  36579. * @returns Nullable animation
  36580. */
  36581. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  36582. /**
  36583. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  36584. * @param sourceAnimation defines the Animation containing keyframes to convert
  36585. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  36586. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  36587. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  36588. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  36589. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  36590. */
  36591. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  36592. /**
  36593. * Transition property of an host to the target Value
  36594. * @param property The property to transition
  36595. * @param targetValue The target Value of the property
  36596. * @param host The object where the property to animate belongs
  36597. * @param scene Scene used to run the animation
  36598. * @param frameRate Framerate (in frame/s) to use
  36599. * @param transition The transition type we want to use
  36600. * @param duration The duration of the animation, in milliseconds
  36601. * @param onAnimationEnd Callback trigger at the end of the animation
  36602. * @returns Nullable animation
  36603. */
  36604. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  36605. /**
  36606. * Return the array of runtime animations currently using this animation
  36607. */
  36608. get runtimeAnimations(): RuntimeAnimation[];
  36609. /**
  36610. * Specifies if any of the runtime animations are currently running
  36611. */
  36612. get hasRunningRuntimeAnimations(): boolean;
  36613. /**
  36614. * Initializes the animation
  36615. * @param name Name of the animation
  36616. * @param targetProperty Property to animate
  36617. * @param framePerSecond The frames per second of the animation
  36618. * @param dataType The data type of the animation
  36619. * @param loopMode The loop mode of the animation
  36620. * @param enableBlending Specifies if blending should be enabled
  36621. */
  36622. constructor(
  36623. /**Name of the animation */
  36624. name: string,
  36625. /**Property to animate */
  36626. targetProperty: string,
  36627. /**The frames per second of the animation */
  36628. framePerSecond: number,
  36629. /**The data type of the animation */
  36630. dataType: number,
  36631. /**The loop mode of the animation */
  36632. loopMode?: number | undefined,
  36633. /**Specifies if blending should be enabled */
  36634. enableBlending?: boolean | undefined);
  36635. /**
  36636. * Converts the animation to a string
  36637. * @param fullDetails support for multiple levels of logging within scene loading
  36638. * @returns String form of the animation
  36639. */
  36640. toString(fullDetails?: boolean): string;
  36641. /**
  36642. * Add an event to this animation
  36643. * @param event Event to add
  36644. */
  36645. addEvent(event: AnimationEvent): void;
  36646. /**
  36647. * Remove all events found at the given frame
  36648. * @param frame The frame to remove events from
  36649. */
  36650. removeEvents(frame: number): void;
  36651. /**
  36652. * Retrieves all the events from the animation
  36653. * @returns Events from the animation
  36654. */
  36655. getEvents(): AnimationEvent[];
  36656. /**
  36657. * Creates an animation range
  36658. * @param name Name of the animation range
  36659. * @param from Starting frame of the animation range
  36660. * @param to Ending frame of the animation
  36661. */
  36662. createRange(name: string, from: number, to: number): void;
  36663. /**
  36664. * Deletes an animation range by name
  36665. * @param name Name of the animation range to delete
  36666. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  36667. */
  36668. deleteRange(name: string, deleteFrames?: boolean): void;
  36669. /**
  36670. * Gets the animation range by name, or null if not defined
  36671. * @param name Name of the animation range
  36672. * @returns Nullable animation range
  36673. */
  36674. getRange(name: string): Nullable<AnimationRange>;
  36675. /**
  36676. * Gets the key frames from the animation
  36677. * @returns The key frames of the animation
  36678. */
  36679. getKeys(): Array<IAnimationKey>;
  36680. /**
  36681. * Gets the highest frame rate of the animation
  36682. * @returns Highest frame rate of the animation
  36683. */
  36684. getHighestFrame(): number;
  36685. /**
  36686. * Gets the easing function of the animation
  36687. * @returns Easing function of the animation
  36688. */
  36689. getEasingFunction(): IEasingFunction;
  36690. /**
  36691. * Sets the easing function of the animation
  36692. * @param easingFunction A custom mathematical formula for animation
  36693. */
  36694. setEasingFunction(easingFunction: EasingFunction): void;
  36695. /**
  36696. * Interpolates a scalar linearly
  36697. * @param startValue Start value of the animation curve
  36698. * @param endValue End value of the animation curve
  36699. * @param gradient Scalar amount to interpolate
  36700. * @returns Interpolated scalar value
  36701. */
  36702. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  36703. /**
  36704. * Interpolates a scalar cubically
  36705. * @param startValue Start value of the animation curve
  36706. * @param outTangent End tangent of the animation
  36707. * @param endValue End value of the animation curve
  36708. * @param inTangent Start tangent of the animation curve
  36709. * @param gradient Scalar amount to interpolate
  36710. * @returns Interpolated scalar value
  36711. */
  36712. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  36713. /**
  36714. * Interpolates a quaternion using a spherical linear interpolation
  36715. * @param startValue Start value of the animation curve
  36716. * @param endValue End value of the animation curve
  36717. * @param gradient Scalar amount to interpolate
  36718. * @returns Interpolated quaternion value
  36719. */
  36720. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  36721. /**
  36722. * Interpolates a quaternion cubically
  36723. * @param startValue Start value of the animation curve
  36724. * @param outTangent End tangent of the animation curve
  36725. * @param endValue End value of the animation curve
  36726. * @param inTangent Start tangent of the animation curve
  36727. * @param gradient Scalar amount to interpolate
  36728. * @returns Interpolated quaternion value
  36729. */
  36730. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  36731. /**
  36732. * Interpolates a Vector3 linearl
  36733. * @param startValue Start value of the animation curve
  36734. * @param endValue End value of the animation curve
  36735. * @param gradient Scalar amount to interpolate
  36736. * @returns Interpolated scalar value
  36737. */
  36738. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  36739. /**
  36740. * Interpolates a Vector3 cubically
  36741. * @param startValue Start value of the animation curve
  36742. * @param outTangent End tangent of the animation
  36743. * @param endValue End value of the animation curve
  36744. * @param inTangent Start tangent of the animation curve
  36745. * @param gradient Scalar amount to interpolate
  36746. * @returns InterpolatedVector3 value
  36747. */
  36748. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  36749. /**
  36750. * Interpolates a Vector2 linearly
  36751. * @param startValue Start value of the animation curve
  36752. * @param endValue End value of the animation curve
  36753. * @param gradient Scalar amount to interpolate
  36754. * @returns Interpolated Vector2 value
  36755. */
  36756. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  36757. /**
  36758. * Interpolates a Vector2 cubically
  36759. * @param startValue Start value of the animation curve
  36760. * @param outTangent End tangent of the animation
  36761. * @param endValue End value of the animation curve
  36762. * @param inTangent Start tangent of the animation curve
  36763. * @param gradient Scalar amount to interpolate
  36764. * @returns Interpolated Vector2 value
  36765. */
  36766. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  36767. /**
  36768. * Interpolates a size linearly
  36769. * @param startValue Start value of the animation curve
  36770. * @param endValue End value of the animation curve
  36771. * @param gradient Scalar amount to interpolate
  36772. * @returns Interpolated Size value
  36773. */
  36774. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  36775. /**
  36776. * Interpolates a Color3 linearly
  36777. * @param startValue Start value of the animation curve
  36778. * @param endValue End value of the animation curve
  36779. * @param gradient Scalar amount to interpolate
  36780. * @returns Interpolated Color3 value
  36781. */
  36782. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  36783. /**
  36784. * Interpolates a Color4 linearly
  36785. * @param startValue Start value of the animation curve
  36786. * @param endValue End value of the animation curve
  36787. * @param gradient Scalar amount to interpolate
  36788. * @returns Interpolated Color3 value
  36789. */
  36790. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  36791. /**
  36792. * @hidden Internal use only
  36793. */
  36794. _getKeyValue(value: any): any;
  36795. /**
  36796. * @hidden Internal use only
  36797. */
  36798. _interpolate(currentFrame: number, state: _IAnimationState): any;
  36799. /**
  36800. * Defines the function to use to interpolate matrices
  36801. * @param startValue defines the start matrix
  36802. * @param endValue defines the end matrix
  36803. * @param gradient defines the gradient between both matrices
  36804. * @param result defines an optional target matrix where to store the interpolation
  36805. * @returns the interpolated matrix
  36806. */
  36807. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  36808. /**
  36809. * Makes a copy of the animation
  36810. * @returns Cloned animation
  36811. */
  36812. clone(): Animation;
  36813. /**
  36814. * Sets the key frames of the animation
  36815. * @param values The animation key frames to set
  36816. */
  36817. setKeys(values: Array<IAnimationKey>): void;
  36818. /**
  36819. * Serializes the animation to an object
  36820. * @returns Serialized object
  36821. */
  36822. serialize(): any;
  36823. /**
  36824. * Float animation type
  36825. */
  36826. static readonly ANIMATIONTYPE_FLOAT: number;
  36827. /**
  36828. * Vector3 animation type
  36829. */
  36830. static readonly ANIMATIONTYPE_VECTOR3: number;
  36831. /**
  36832. * Quaternion animation type
  36833. */
  36834. static readonly ANIMATIONTYPE_QUATERNION: number;
  36835. /**
  36836. * Matrix animation type
  36837. */
  36838. static readonly ANIMATIONTYPE_MATRIX: number;
  36839. /**
  36840. * Color3 animation type
  36841. */
  36842. static readonly ANIMATIONTYPE_COLOR3: number;
  36843. /**
  36844. * Color3 animation type
  36845. */
  36846. static readonly ANIMATIONTYPE_COLOR4: number;
  36847. /**
  36848. * Vector2 animation type
  36849. */
  36850. static readonly ANIMATIONTYPE_VECTOR2: number;
  36851. /**
  36852. * Size animation type
  36853. */
  36854. static readonly ANIMATIONTYPE_SIZE: number;
  36855. /**
  36856. * Relative Loop Mode
  36857. */
  36858. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  36859. /**
  36860. * Cycle Loop Mode
  36861. */
  36862. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  36863. /**
  36864. * Constant Loop Mode
  36865. */
  36866. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  36867. /** @hidden */
  36868. static _UniversalLerp(left: any, right: any, amount: number): any;
  36869. /**
  36870. * Parses an animation object and creates an animation
  36871. * @param parsedAnimation Parsed animation object
  36872. * @returns Animation object
  36873. */
  36874. static Parse(parsedAnimation: any): Animation;
  36875. /**
  36876. * Appends the serialized animations from the source animations
  36877. * @param source Source containing the animations
  36878. * @param destination Target to store the animations
  36879. */
  36880. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  36881. /**
  36882. * Creates a new animation or an array of animations from a snippet saved in a remote file
  36883. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  36884. * @param url defines the url to load from
  36885. * @returns a promise that will resolve to the new animation or an array of animations
  36886. */
  36887. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  36888. /**
  36889. * Creates an animation or an array of animations from a snippet saved by the Inspector
  36890. * @param snippetId defines the snippet to load
  36891. * @returns a promise that will resolve to the new animation or a new array of animations
  36892. */
  36893. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  36894. }
  36895. }
  36896. declare module BABYLON {
  36897. /**
  36898. * Interface containing an array of animations
  36899. */
  36900. export interface IAnimatable {
  36901. /**
  36902. * Array of animations
  36903. */
  36904. animations: Nullable<Array<Animation>>;
  36905. }
  36906. }
  36907. declare module BABYLON {
  36908. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  36909. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36910. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36911. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36912. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36913. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36914. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36915. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36916. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36917. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36918. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36919. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36920. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36921. /**
  36922. * Decorator used to define property that can be serialized as reference to a camera
  36923. * @param sourceName defines the name of the property to decorate
  36924. */
  36925. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36926. /**
  36927. * Class used to help serialization objects
  36928. */
  36929. export class SerializationHelper {
  36930. /** @hidden */
  36931. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  36932. /** @hidden */
  36933. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  36934. /** @hidden */
  36935. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  36936. /** @hidden */
  36937. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  36938. /**
  36939. * Appends the serialized animations from the source animations
  36940. * @param source Source containing the animations
  36941. * @param destination Target to store the animations
  36942. */
  36943. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  36944. /**
  36945. * Static function used to serialized a specific entity
  36946. * @param entity defines the entity to serialize
  36947. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  36948. * @returns a JSON compatible object representing the serialization of the entity
  36949. */
  36950. static Serialize<T>(entity: T, serializationObject?: any): any;
  36951. /**
  36952. * Creates a new entity from a serialization data object
  36953. * @param creationFunction defines a function used to instanciated the new entity
  36954. * @param source defines the source serialization data
  36955. * @param scene defines the hosting scene
  36956. * @param rootUrl defines the root url for resources
  36957. * @returns a new entity
  36958. */
  36959. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  36960. /**
  36961. * Clones an object
  36962. * @param creationFunction defines the function used to instanciate the new object
  36963. * @param source defines the source object
  36964. * @returns the cloned object
  36965. */
  36966. static Clone<T>(creationFunction: () => T, source: T): T;
  36967. /**
  36968. * Instanciates a new object based on a source one (some data will be shared between both object)
  36969. * @param creationFunction defines the function used to instanciate the new object
  36970. * @param source defines the source object
  36971. * @returns the new object
  36972. */
  36973. static Instanciate<T>(creationFunction: () => T, source: T): T;
  36974. }
  36975. }
  36976. declare module BABYLON {
  36977. /**
  36978. * This is the base class of all the camera used in the application.
  36979. * @see https://doc.babylonjs.com/features/cameras
  36980. */
  36981. export class Camera extends Node {
  36982. /** @hidden */
  36983. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  36984. /**
  36985. * This is the default projection mode used by the cameras.
  36986. * It helps recreating a feeling of perspective and better appreciate depth.
  36987. * This is the best way to simulate real life cameras.
  36988. */
  36989. static readonly PERSPECTIVE_CAMERA: number;
  36990. /**
  36991. * This helps creating camera with an orthographic mode.
  36992. * 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.
  36993. */
  36994. static readonly ORTHOGRAPHIC_CAMERA: number;
  36995. /**
  36996. * This is the default FOV mode for perspective cameras.
  36997. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  36998. */
  36999. static readonly FOVMODE_VERTICAL_FIXED: number;
  37000. /**
  37001. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  37002. */
  37003. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  37004. /**
  37005. * This specifies ther is no need for a camera rig.
  37006. * Basically only one eye is rendered corresponding to the camera.
  37007. */
  37008. static readonly RIG_MODE_NONE: number;
  37009. /**
  37010. * Simulates a camera Rig with one blue eye and one red eye.
  37011. * This can be use with 3d blue and red glasses.
  37012. */
  37013. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  37014. /**
  37015. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  37016. */
  37017. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  37018. /**
  37019. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  37020. */
  37021. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  37022. /**
  37023. * Defines that both eyes of the camera will be rendered over under each other.
  37024. */
  37025. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  37026. /**
  37027. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  37028. */
  37029. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  37030. /**
  37031. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  37032. */
  37033. static readonly RIG_MODE_VR: number;
  37034. /**
  37035. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  37036. */
  37037. static readonly RIG_MODE_WEBVR: number;
  37038. /**
  37039. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  37040. */
  37041. static readonly RIG_MODE_CUSTOM: number;
  37042. /**
  37043. * Defines if by default attaching controls should prevent the default javascript event to continue.
  37044. */
  37045. static ForceAttachControlToAlwaysPreventDefault: boolean;
  37046. /**
  37047. * Define the input manager associated with the camera.
  37048. */
  37049. inputs: CameraInputsManager<Camera>;
  37050. /** @hidden */
  37051. _position: Vector3;
  37052. /**
  37053. * Define the current local position of the camera in the scene
  37054. */
  37055. get position(): Vector3;
  37056. set position(newPosition: Vector3);
  37057. protected _upVector: Vector3;
  37058. /**
  37059. * The vector the camera should consider as up.
  37060. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  37061. */
  37062. set upVector(vec: Vector3);
  37063. get upVector(): Vector3;
  37064. /**
  37065. * Define the current limit on the left side for an orthographic camera
  37066. * In scene unit
  37067. */
  37068. orthoLeft: Nullable<number>;
  37069. /**
  37070. * Define the current limit on the right side for an orthographic camera
  37071. * In scene unit
  37072. */
  37073. orthoRight: Nullable<number>;
  37074. /**
  37075. * Define the current limit on the bottom side for an orthographic camera
  37076. * In scene unit
  37077. */
  37078. orthoBottom: Nullable<number>;
  37079. /**
  37080. * Define the current limit on the top side for an orthographic camera
  37081. * In scene unit
  37082. */
  37083. orthoTop: Nullable<number>;
  37084. /**
  37085. * Field Of View is set in Radians. (default is 0.8)
  37086. */
  37087. fov: number;
  37088. /**
  37089. * Define the minimum distance the camera can see from.
  37090. * This is important to note that the depth buffer are not infinite and the closer it starts
  37091. * the more your scene might encounter depth fighting issue.
  37092. */
  37093. minZ: number;
  37094. /**
  37095. * Define the maximum distance the camera can see to.
  37096. * This is important to note that the depth buffer are not infinite and the further it end
  37097. * the more your scene might encounter depth fighting issue.
  37098. */
  37099. maxZ: number;
  37100. /**
  37101. * Define the default inertia of the camera.
  37102. * This helps giving a smooth feeling to the camera movement.
  37103. */
  37104. inertia: number;
  37105. /**
  37106. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  37107. */
  37108. mode: number;
  37109. /**
  37110. * Define whether the camera is intermediate.
  37111. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  37112. */
  37113. isIntermediate: boolean;
  37114. /**
  37115. * Define the viewport of the camera.
  37116. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  37117. */
  37118. viewport: Viewport;
  37119. /**
  37120. * Restricts the camera to viewing objects with the same layerMask.
  37121. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  37122. */
  37123. layerMask: number;
  37124. /**
  37125. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  37126. */
  37127. fovMode: number;
  37128. /**
  37129. * Rig mode of the camera.
  37130. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  37131. * This is normally controlled byt the camera themselves as internal use.
  37132. */
  37133. cameraRigMode: number;
  37134. /**
  37135. * Defines the distance between both "eyes" in case of a RIG
  37136. */
  37137. interaxialDistance: number;
  37138. /**
  37139. * Defines if stereoscopic rendering is done side by side or over under.
  37140. */
  37141. isStereoscopicSideBySide: boolean;
  37142. /**
  37143. * 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
  37144. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  37145. * else in the scene. (Eg. security camera)
  37146. *
  37147. * 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)
  37148. */
  37149. customRenderTargets: RenderTargetTexture[];
  37150. /**
  37151. * When set, the camera will render to this render target instead of the default canvas
  37152. *
  37153. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  37154. */
  37155. outputRenderTarget: Nullable<RenderTargetTexture>;
  37156. /**
  37157. * Observable triggered when the camera view matrix has changed.
  37158. */
  37159. onViewMatrixChangedObservable: Observable<Camera>;
  37160. /**
  37161. * Observable triggered when the camera Projection matrix has changed.
  37162. */
  37163. onProjectionMatrixChangedObservable: Observable<Camera>;
  37164. /**
  37165. * Observable triggered when the inputs have been processed.
  37166. */
  37167. onAfterCheckInputsObservable: Observable<Camera>;
  37168. /**
  37169. * Observable triggered when reset has been called and applied to the camera.
  37170. */
  37171. onRestoreStateObservable: Observable<Camera>;
  37172. /**
  37173. * Is this camera a part of a rig system?
  37174. */
  37175. isRigCamera: boolean;
  37176. /**
  37177. * If isRigCamera set to true this will be set with the parent camera.
  37178. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  37179. */
  37180. rigParent?: Camera;
  37181. /** @hidden */
  37182. _cameraRigParams: any;
  37183. /** @hidden */
  37184. _rigCameras: Camera[];
  37185. /** @hidden */
  37186. _rigPostProcess: Nullable<PostProcess>;
  37187. protected _webvrViewMatrix: Matrix;
  37188. /** @hidden */
  37189. _skipRendering: boolean;
  37190. /** @hidden */
  37191. _projectionMatrix: Matrix;
  37192. /** @hidden */
  37193. _postProcesses: Nullable<PostProcess>[];
  37194. /** @hidden */
  37195. _activeMeshes: SmartArray<AbstractMesh>;
  37196. protected _globalPosition: Vector3;
  37197. /** @hidden */
  37198. _computedViewMatrix: Matrix;
  37199. private _doNotComputeProjectionMatrix;
  37200. private _transformMatrix;
  37201. private _frustumPlanes;
  37202. private _refreshFrustumPlanes;
  37203. private _storedFov;
  37204. private _stateStored;
  37205. /**
  37206. * Instantiates a new camera object.
  37207. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  37208. * @see https://doc.babylonjs.com/features/cameras
  37209. * @param name Defines the name of the camera in the scene
  37210. * @param position Defines the position of the camera
  37211. * @param scene Defines the scene the camera belongs too
  37212. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  37213. */
  37214. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  37215. /**
  37216. * Store current camera state (fov, position, etc..)
  37217. * @returns the camera
  37218. */
  37219. storeState(): Camera;
  37220. /**
  37221. * Restores the camera state values if it has been stored. You must call storeState() first
  37222. */
  37223. protected _restoreStateValues(): boolean;
  37224. /**
  37225. * Restored camera state. You must call storeState() first.
  37226. * @returns true if restored and false otherwise
  37227. */
  37228. restoreState(): boolean;
  37229. /**
  37230. * Gets the class name of the camera.
  37231. * @returns the class name
  37232. */
  37233. getClassName(): string;
  37234. /** @hidden */
  37235. readonly _isCamera: boolean;
  37236. /**
  37237. * Gets a string representation of the camera useful for debug purpose.
  37238. * @param fullDetails Defines that a more verboe level of logging is required
  37239. * @returns the string representation
  37240. */
  37241. toString(fullDetails?: boolean): string;
  37242. /**
  37243. * Gets the current world space position of the camera.
  37244. */
  37245. get globalPosition(): Vector3;
  37246. /**
  37247. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  37248. * @returns the active meshe list
  37249. */
  37250. getActiveMeshes(): SmartArray<AbstractMesh>;
  37251. /**
  37252. * Check whether a mesh is part of the current active mesh list of the camera
  37253. * @param mesh Defines the mesh to check
  37254. * @returns true if active, false otherwise
  37255. */
  37256. isActiveMesh(mesh: Mesh): boolean;
  37257. /**
  37258. * Is this camera ready to be used/rendered
  37259. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  37260. * @return true if the camera is ready
  37261. */
  37262. isReady(completeCheck?: boolean): boolean;
  37263. /** @hidden */
  37264. _initCache(): void;
  37265. /** @hidden */
  37266. _updateCache(ignoreParentClass?: boolean): void;
  37267. /** @hidden */
  37268. _isSynchronized(): boolean;
  37269. /** @hidden */
  37270. _isSynchronizedViewMatrix(): boolean;
  37271. /** @hidden */
  37272. _isSynchronizedProjectionMatrix(): boolean;
  37273. /**
  37274. * Attach the input controls to a specific dom element to get the input from.
  37275. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37276. */
  37277. attachControl(noPreventDefault?: boolean): void;
  37278. /**
  37279. * Attach the input controls to a specific dom element to get the input from.
  37280. * @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
  37281. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37282. * BACK COMPAT SIGNATURE ONLY.
  37283. */
  37284. attachControl(ignored: any, noPreventDefault?: boolean): void;
  37285. /**
  37286. * Detach the current controls from the specified dom element.
  37287. */
  37288. detachControl(): void;
  37289. /**
  37290. * Detach the current controls from the specified dom element.
  37291. * @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
  37292. */
  37293. detachControl(ignored: any): void;
  37294. /**
  37295. * Update the camera state according to the different inputs gathered during the frame.
  37296. */
  37297. update(): void;
  37298. /** @hidden */
  37299. _checkInputs(): void;
  37300. /** @hidden */
  37301. get rigCameras(): Camera[];
  37302. /**
  37303. * Gets the post process used by the rig cameras
  37304. */
  37305. get rigPostProcess(): Nullable<PostProcess>;
  37306. /**
  37307. * Internal, gets the first post proces.
  37308. * @returns the first post process to be run on this camera.
  37309. */
  37310. _getFirstPostProcess(): Nullable<PostProcess>;
  37311. private _cascadePostProcessesToRigCams;
  37312. /**
  37313. * Attach a post process to the camera.
  37314. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  37315. * @param postProcess The post process to attach to the camera
  37316. * @param insertAt The position of the post process in case several of them are in use in the scene
  37317. * @returns the position the post process has been inserted at
  37318. */
  37319. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  37320. /**
  37321. * Detach a post process to the camera.
  37322. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  37323. * @param postProcess The post process to detach from the camera
  37324. */
  37325. detachPostProcess(postProcess: PostProcess): void;
  37326. /**
  37327. * Gets the current world matrix of the camera
  37328. */
  37329. getWorldMatrix(): Matrix;
  37330. /** @hidden */
  37331. _getViewMatrix(): Matrix;
  37332. /**
  37333. * Gets the current view matrix of the camera.
  37334. * @param force forces the camera to recompute the matrix without looking at the cached state
  37335. * @returns the view matrix
  37336. */
  37337. getViewMatrix(force?: boolean): Matrix;
  37338. /**
  37339. * Freeze the projection matrix.
  37340. * It will prevent the cache check of the camera projection compute and can speed up perf
  37341. * if no parameter of the camera are meant to change
  37342. * @param projection Defines manually a projection if necessary
  37343. */
  37344. freezeProjectionMatrix(projection?: Matrix): void;
  37345. /**
  37346. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  37347. */
  37348. unfreezeProjectionMatrix(): void;
  37349. /**
  37350. * Gets the current projection matrix of the camera.
  37351. * @param force forces the camera to recompute the matrix without looking at the cached state
  37352. * @returns the projection matrix
  37353. */
  37354. getProjectionMatrix(force?: boolean): Matrix;
  37355. /**
  37356. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  37357. * @returns a Matrix
  37358. */
  37359. getTransformationMatrix(): Matrix;
  37360. private _updateFrustumPlanes;
  37361. /**
  37362. * Checks if a cullable object (mesh...) is in the camera frustum
  37363. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  37364. * @param target The object to check
  37365. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  37366. * @returns true if the object is in frustum otherwise false
  37367. */
  37368. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  37369. /**
  37370. * Checks if a cullable object (mesh...) is in the camera frustum
  37371. * Unlike isInFrustum this cheks the full bounding box
  37372. * @param target The object to check
  37373. * @returns true if the object is in frustum otherwise false
  37374. */
  37375. isCompletelyInFrustum(target: ICullable): boolean;
  37376. /**
  37377. * Gets a ray in the forward direction from the camera.
  37378. * @param length Defines the length of the ray to create
  37379. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  37380. * @param origin Defines the start point of the ray which defaults to the camera position
  37381. * @returns the forward ray
  37382. */
  37383. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  37384. /**
  37385. * Gets a ray in the forward direction from the camera.
  37386. * @param refRay the ray to (re)use when setting the values
  37387. * @param length Defines the length of the ray to create
  37388. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  37389. * @param origin Defines the start point of the ray which defaults to the camera position
  37390. * @returns the forward ray
  37391. */
  37392. getForwardRayToRef(refRay: Ray, length?: number, transform?: Matrix, origin?: Vector3): Ray;
  37393. /**
  37394. * Releases resources associated with this node.
  37395. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  37396. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  37397. */
  37398. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  37399. /** @hidden */
  37400. _isLeftCamera: boolean;
  37401. /**
  37402. * Gets the left camera of a rig setup in case of Rigged Camera
  37403. */
  37404. get isLeftCamera(): boolean;
  37405. /** @hidden */
  37406. _isRightCamera: boolean;
  37407. /**
  37408. * Gets the right camera of a rig setup in case of Rigged Camera
  37409. */
  37410. get isRightCamera(): boolean;
  37411. /**
  37412. * Gets the left camera of a rig setup in case of Rigged Camera
  37413. */
  37414. get leftCamera(): Nullable<FreeCamera>;
  37415. /**
  37416. * Gets the right camera of a rig setup in case of Rigged Camera
  37417. */
  37418. get rightCamera(): Nullable<FreeCamera>;
  37419. /**
  37420. * Gets the left camera target of a rig setup in case of Rigged Camera
  37421. * @returns the target position
  37422. */
  37423. getLeftTarget(): Nullable<Vector3>;
  37424. /**
  37425. * Gets the right camera target of a rig setup in case of Rigged Camera
  37426. * @returns the target position
  37427. */
  37428. getRightTarget(): Nullable<Vector3>;
  37429. /**
  37430. * @hidden
  37431. */
  37432. setCameraRigMode(mode: number, rigParams: any): void;
  37433. /** @hidden */
  37434. static _setStereoscopicRigMode(camera: Camera): void;
  37435. /** @hidden */
  37436. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  37437. /** @hidden */
  37438. static _setVRRigMode(camera: Camera, rigParams: any): void;
  37439. /** @hidden */
  37440. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  37441. /** @hidden */
  37442. _getVRProjectionMatrix(): Matrix;
  37443. protected _updateCameraRotationMatrix(): void;
  37444. protected _updateWebVRCameraRotationMatrix(): void;
  37445. /**
  37446. * This function MUST be overwritten by the different WebVR cameras available.
  37447. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  37448. * @hidden
  37449. */
  37450. _getWebVRProjectionMatrix(): Matrix;
  37451. /**
  37452. * This function MUST be overwritten by the different WebVR cameras available.
  37453. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  37454. * @hidden
  37455. */
  37456. _getWebVRViewMatrix(): Matrix;
  37457. /** @hidden */
  37458. setCameraRigParameter(name: string, value: any): void;
  37459. /**
  37460. * needs to be overridden by children so sub has required properties to be copied
  37461. * @hidden
  37462. */
  37463. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  37464. /**
  37465. * May need to be overridden by children
  37466. * @hidden
  37467. */
  37468. _updateRigCameras(): void;
  37469. /** @hidden */
  37470. _setupInputs(): void;
  37471. /**
  37472. * Serialiaze the camera setup to a json represention
  37473. * @returns the JSON representation
  37474. */
  37475. serialize(): any;
  37476. /**
  37477. * Clones the current camera.
  37478. * @param name The cloned camera name
  37479. * @returns the cloned camera
  37480. */
  37481. clone(name: string): Camera;
  37482. /**
  37483. * Gets the direction of the camera relative to a given local axis.
  37484. * @param localAxis Defines the reference axis to provide a relative direction.
  37485. * @return the direction
  37486. */
  37487. getDirection(localAxis: Vector3): Vector3;
  37488. /**
  37489. * Returns the current camera absolute rotation
  37490. */
  37491. get absoluteRotation(): Quaternion;
  37492. /**
  37493. * Gets the direction of the camera relative to a given local axis into a passed vector.
  37494. * @param localAxis Defines the reference axis to provide a relative direction.
  37495. * @param result Defines the vector to store the result in
  37496. */
  37497. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  37498. /**
  37499. * Gets a camera constructor for a given camera type
  37500. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  37501. * @param name The name of the camera the result will be able to instantiate
  37502. * @param scene The scene the result will construct the camera in
  37503. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  37504. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  37505. * @returns a factory method to construc the camera
  37506. */
  37507. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  37508. /**
  37509. * Compute the world matrix of the camera.
  37510. * @returns the camera world matrix
  37511. */
  37512. computeWorldMatrix(): Matrix;
  37513. /**
  37514. * Parse a JSON and creates the camera from the parsed information
  37515. * @param parsedCamera The JSON to parse
  37516. * @param scene The scene to instantiate the camera in
  37517. * @returns the newly constructed camera
  37518. */
  37519. static Parse(parsedCamera: any, scene: Scene): Camera;
  37520. }
  37521. }
  37522. declare module BABYLON {
  37523. /**
  37524. * PostProcessManager is used to manage one or more post processes or post process pipelines
  37525. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  37526. */
  37527. export class PostProcessManager {
  37528. private _scene;
  37529. private _indexBuffer;
  37530. private _vertexBuffers;
  37531. /**
  37532. * Creates a new instance PostProcess
  37533. * @param scene The scene that the post process is associated with.
  37534. */
  37535. constructor(scene: Scene);
  37536. private _prepareBuffers;
  37537. private _buildIndexBuffer;
  37538. /**
  37539. * Rebuilds the vertex buffers of the manager.
  37540. * @hidden
  37541. */
  37542. _rebuild(): void;
  37543. /**
  37544. * Prepares a frame to be run through a post process.
  37545. * @param sourceTexture The input texture to the post procesess. (default: null)
  37546. * @param postProcesses An array of post processes to be run. (default: null)
  37547. * @returns True if the post processes were able to be run.
  37548. * @hidden
  37549. */
  37550. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  37551. /**
  37552. * Manually render a set of post processes to a texture.
  37553. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  37554. * @param postProcesses An array of post processes to be run.
  37555. * @param targetTexture The target texture to render to.
  37556. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  37557. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  37558. * @param lodLevel defines which lod of the texture to render to
  37559. * @param doNotBindFrambuffer If set to true, assumes that the framebuffer has been bound previously
  37560. */
  37561. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number, doNotBindFrambuffer?: boolean): void;
  37562. /**
  37563. * Finalize the result of the output of the postprocesses.
  37564. * @param doNotPresent If true the result will not be displayed to the screen.
  37565. * @param targetTexture The target texture to render to.
  37566. * @param faceIndex The index of the face to bind the target texture to.
  37567. * @param postProcesses The array of post processes to render.
  37568. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  37569. * @hidden
  37570. */
  37571. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  37572. /**
  37573. * Disposes of the post process manager.
  37574. */
  37575. dispose(): void;
  37576. }
  37577. }
  37578. declare module BABYLON {
  37579. /**
  37580. * This Helps creating a texture that will be created from a camera in your scene.
  37581. * It is basically a dynamic texture that could be used to create special effects for instance.
  37582. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  37583. */
  37584. export class RenderTargetTexture extends Texture {
  37585. /**
  37586. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  37587. */
  37588. static readonly REFRESHRATE_RENDER_ONCE: number;
  37589. /**
  37590. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  37591. */
  37592. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  37593. /**
  37594. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  37595. * the central point of your effect and can save a lot of performances.
  37596. */
  37597. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  37598. /**
  37599. * Use this predicate to dynamically define the list of mesh you want to render.
  37600. * If set, the renderList property will be overwritten.
  37601. */
  37602. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  37603. private _renderList;
  37604. /**
  37605. * Use this list to define the list of mesh you want to render.
  37606. */
  37607. get renderList(): Nullable<Array<AbstractMesh>>;
  37608. set renderList(value: Nullable<Array<AbstractMesh>>);
  37609. /**
  37610. * Use this function to overload the renderList array at rendering time.
  37611. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  37612. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  37613. * the cube (if the RTT is a cube, else layerOrFace=0).
  37614. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  37615. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  37616. * hold dummy elements!
  37617. */
  37618. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  37619. private _hookArray;
  37620. /**
  37621. * Define if particles should be rendered in your texture.
  37622. */
  37623. renderParticles: boolean;
  37624. /**
  37625. * Define if sprites should be rendered in your texture.
  37626. */
  37627. renderSprites: boolean;
  37628. /**
  37629. * Define the camera used to render the texture.
  37630. */
  37631. activeCamera: Nullable<Camera>;
  37632. /**
  37633. * Override the mesh isReady function with your own one.
  37634. */
  37635. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  37636. /**
  37637. * Override the render function of the texture with your own one.
  37638. */
  37639. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  37640. /**
  37641. * Define if camera post processes should be use while rendering the texture.
  37642. */
  37643. useCameraPostProcesses: boolean;
  37644. /**
  37645. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  37646. */
  37647. ignoreCameraViewport: boolean;
  37648. private _postProcessManager;
  37649. private _postProcesses;
  37650. private _resizeObserver;
  37651. /**
  37652. * An event triggered when the texture is unbind.
  37653. */
  37654. onBeforeBindObservable: Observable<RenderTargetTexture>;
  37655. /**
  37656. * An event triggered when the texture is unbind.
  37657. */
  37658. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  37659. private _onAfterUnbindObserver;
  37660. /**
  37661. * Set a after unbind callback in the texture.
  37662. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  37663. */
  37664. set onAfterUnbind(callback: () => void);
  37665. /**
  37666. * An event triggered before rendering the texture
  37667. */
  37668. onBeforeRenderObservable: Observable<number>;
  37669. private _onBeforeRenderObserver;
  37670. /**
  37671. * Set a before render callback in the texture.
  37672. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  37673. */
  37674. set onBeforeRender(callback: (faceIndex: number) => void);
  37675. /**
  37676. * An event triggered after rendering the texture
  37677. */
  37678. onAfterRenderObservable: Observable<number>;
  37679. private _onAfterRenderObserver;
  37680. /**
  37681. * Set a after render callback in the texture.
  37682. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  37683. */
  37684. set onAfterRender(callback: (faceIndex: number) => void);
  37685. /**
  37686. * An event triggered after the texture clear
  37687. */
  37688. onClearObservable: Observable<Engine>;
  37689. private _onClearObserver;
  37690. /**
  37691. * Set a clear callback in the texture.
  37692. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  37693. */
  37694. set onClear(callback: (Engine: Engine) => void);
  37695. /**
  37696. * An event triggered when the texture is resized.
  37697. */
  37698. onResizeObservable: Observable<RenderTargetTexture>;
  37699. /**
  37700. * Define the clear color of the Render Target if it should be different from the scene.
  37701. */
  37702. clearColor: Color4;
  37703. protected _size: number | {
  37704. width: number;
  37705. height: number;
  37706. layers?: number;
  37707. };
  37708. protected _initialSizeParameter: number | {
  37709. width: number;
  37710. height: number;
  37711. } | {
  37712. ratio: number;
  37713. };
  37714. protected _sizeRatio: Nullable<number>;
  37715. /** @hidden */
  37716. _generateMipMaps: boolean;
  37717. protected _renderingManager: RenderingManager;
  37718. /** @hidden */
  37719. _waitingRenderList?: string[];
  37720. protected _doNotChangeAspectRatio: boolean;
  37721. protected _currentRefreshId: number;
  37722. protected _refreshRate: number;
  37723. protected _textureMatrix: Matrix;
  37724. protected _samples: number;
  37725. protected _renderTargetOptions: RenderTargetCreationOptions;
  37726. /**
  37727. * Gets render target creation options that were used.
  37728. */
  37729. get renderTargetOptions(): RenderTargetCreationOptions;
  37730. protected _onRatioRescale(): void;
  37731. /**
  37732. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  37733. * It must define where the camera used to render the texture is set
  37734. */
  37735. boundingBoxPosition: Vector3;
  37736. private _boundingBoxSize;
  37737. /**
  37738. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  37739. * When defined, the cubemap will switch to local mode
  37740. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  37741. * @example https://www.babylonjs-playground.com/#RNASML
  37742. */
  37743. set boundingBoxSize(value: Vector3);
  37744. get boundingBoxSize(): Vector3;
  37745. /**
  37746. * In case the RTT has been created with a depth texture, get the associated
  37747. * depth texture.
  37748. * Otherwise, return null.
  37749. */
  37750. get depthStencilTexture(): Nullable<InternalTexture>;
  37751. /**
  37752. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  37753. * or used a shadow, depth texture...
  37754. * @param name The friendly name of the texture
  37755. * @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)
  37756. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  37757. * @param generateMipMaps True if mip maps need to be generated after render.
  37758. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  37759. * @param type The type of the buffer in the RTT (int, half float, float...)
  37760. * @param isCube True if a cube texture needs to be created
  37761. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  37762. * @param generateDepthBuffer True to generate a depth buffer
  37763. * @param generateStencilBuffer True to generate a stencil buffer
  37764. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  37765. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  37766. * @param delayAllocation if the texture allocation should be delayed (default: false)
  37767. */
  37768. constructor(name: string, size: number | {
  37769. width: number;
  37770. height: number;
  37771. layers?: number;
  37772. } | {
  37773. ratio: number;
  37774. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  37775. /**
  37776. * Creates a depth stencil texture.
  37777. * This is only available in WebGL 2 or with the depth texture extension available.
  37778. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  37779. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  37780. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  37781. */
  37782. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  37783. private _processSizeParameter;
  37784. /**
  37785. * Define the number of samples to use in case of MSAA.
  37786. * It defaults to one meaning no MSAA has been enabled.
  37787. */
  37788. get samples(): number;
  37789. set samples(value: number);
  37790. /**
  37791. * Resets the refresh counter of the texture and start bak from scratch.
  37792. * Could be useful to regenerate the texture if it is setup to render only once.
  37793. */
  37794. resetRefreshCounter(): void;
  37795. /**
  37796. * Define the refresh rate of the texture or the rendering frequency.
  37797. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  37798. */
  37799. get refreshRate(): number;
  37800. set refreshRate(value: number);
  37801. /**
  37802. * Adds a post process to the render target rendering passes.
  37803. * @param postProcess define the post process to add
  37804. */
  37805. addPostProcess(postProcess: PostProcess): void;
  37806. /**
  37807. * Clear all the post processes attached to the render target
  37808. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  37809. */
  37810. clearPostProcesses(dispose?: boolean): void;
  37811. /**
  37812. * Remove one of the post process from the list of attached post processes to the texture
  37813. * @param postProcess define the post process to remove from the list
  37814. */
  37815. removePostProcess(postProcess: PostProcess): void;
  37816. /** @hidden */
  37817. _shouldRender(): boolean;
  37818. /**
  37819. * Gets the actual render size of the texture.
  37820. * @returns the width of the render size
  37821. */
  37822. getRenderSize(): number;
  37823. /**
  37824. * Gets the actual render width of the texture.
  37825. * @returns the width of the render size
  37826. */
  37827. getRenderWidth(): number;
  37828. /**
  37829. * Gets the actual render height of the texture.
  37830. * @returns the height of the render size
  37831. */
  37832. getRenderHeight(): number;
  37833. /**
  37834. * Gets the actual number of layers of the texture.
  37835. * @returns the number of layers
  37836. */
  37837. getRenderLayers(): number;
  37838. /**
  37839. * Get if the texture can be rescaled or not.
  37840. */
  37841. get canRescale(): boolean;
  37842. /**
  37843. * Resize the texture using a ratio.
  37844. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  37845. */
  37846. scale(ratio: number): void;
  37847. /**
  37848. * Get the texture reflection matrix used to rotate/transform the reflection.
  37849. * @returns the reflection matrix
  37850. */
  37851. getReflectionTextureMatrix(): Matrix;
  37852. /**
  37853. * Resize the texture to a new desired size.
  37854. * Be carrefull as it will recreate all the data in the new texture.
  37855. * @param size Define the new size. It can be:
  37856. * - a number for squared texture,
  37857. * - an object containing { width: number, height: number }
  37858. * - or an object containing a ratio { ratio: number }
  37859. */
  37860. resize(size: number | {
  37861. width: number;
  37862. height: number;
  37863. } | {
  37864. ratio: number;
  37865. }): void;
  37866. private _defaultRenderListPrepared;
  37867. /**
  37868. * Renders all the objects from the render list into the texture.
  37869. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  37870. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  37871. */
  37872. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  37873. private _bestReflectionRenderTargetDimension;
  37874. private _prepareRenderingManager;
  37875. /**
  37876. * @hidden
  37877. * @param faceIndex face index to bind to if this is a cubetexture
  37878. * @param layer defines the index of the texture to bind in the array
  37879. */
  37880. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  37881. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  37882. private renderToTarget;
  37883. /**
  37884. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  37885. * This allowed control for front to back rendering or reversly depending of the special needs.
  37886. *
  37887. * @param renderingGroupId The rendering group id corresponding to its index
  37888. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  37889. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  37890. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  37891. */
  37892. 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;
  37893. /**
  37894. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  37895. *
  37896. * @param renderingGroupId The rendering group id corresponding to its index
  37897. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  37898. */
  37899. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  37900. /**
  37901. * Clones the texture.
  37902. * @returns the cloned texture
  37903. */
  37904. clone(): RenderTargetTexture;
  37905. /**
  37906. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  37907. * @returns The JSON representation of the texture
  37908. */
  37909. serialize(): any;
  37910. /**
  37911. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  37912. */
  37913. disposeFramebufferObjects(): void;
  37914. /**
  37915. * Dispose the texture and release its associated resources.
  37916. */
  37917. dispose(): void;
  37918. /** @hidden */
  37919. _rebuild(): void;
  37920. /**
  37921. * Clear the info related to rendering groups preventing retention point in material dispose.
  37922. */
  37923. freeRenderingGroups(): void;
  37924. /**
  37925. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  37926. * @returns the view count
  37927. */
  37928. getViewCount(): number;
  37929. }
  37930. }
  37931. declare module BABYLON {
  37932. /**
  37933. * Options to be used when creating an effect.
  37934. */
  37935. export interface IEffectCreationOptions {
  37936. /**
  37937. * Atrributes that will be used in the shader.
  37938. */
  37939. attributes: string[];
  37940. /**
  37941. * Uniform varible names that will be set in the shader.
  37942. */
  37943. uniformsNames: string[];
  37944. /**
  37945. * Uniform buffer variable names that will be set in the shader.
  37946. */
  37947. uniformBuffersNames: string[];
  37948. /**
  37949. * Sampler texture variable names that will be set in the shader.
  37950. */
  37951. samplers: string[];
  37952. /**
  37953. * Define statements that will be set in the shader.
  37954. */
  37955. defines: any;
  37956. /**
  37957. * Possible fallbacks for this effect to improve performance when needed.
  37958. */
  37959. fallbacks: Nullable<IEffectFallbacks>;
  37960. /**
  37961. * Callback that will be called when the shader is compiled.
  37962. */
  37963. onCompiled: Nullable<(effect: Effect) => void>;
  37964. /**
  37965. * Callback that will be called if an error occurs during shader compilation.
  37966. */
  37967. onError: Nullable<(effect: Effect, errors: string) => void>;
  37968. /**
  37969. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  37970. */
  37971. indexParameters?: any;
  37972. /**
  37973. * Max number of lights that can be used in the shader.
  37974. */
  37975. maxSimultaneousLights?: number;
  37976. /**
  37977. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  37978. */
  37979. transformFeedbackVaryings?: Nullable<string[]>;
  37980. /**
  37981. * 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
  37982. */
  37983. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  37984. /**
  37985. * Is this effect rendering to several color attachments ?
  37986. */
  37987. multiTarget?: boolean;
  37988. }
  37989. /**
  37990. * Effect containing vertex and fragment shader that can be executed on an object.
  37991. */
  37992. export class Effect implements IDisposable {
  37993. /**
  37994. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  37995. */
  37996. static ShadersRepository: string;
  37997. /**
  37998. * Enable logging of the shader code when a compilation error occurs
  37999. */
  38000. static LogShaderCodeOnCompilationError: boolean;
  38001. /**
  38002. * Name of the effect.
  38003. */
  38004. name: any;
  38005. /**
  38006. * String container all the define statements that should be set on the shader.
  38007. */
  38008. defines: string;
  38009. /**
  38010. * Callback that will be called when the shader is compiled.
  38011. */
  38012. onCompiled: Nullable<(effect: Effect) => void>;
  38013. /**
  38014. * Callback that will be called if an error occurs during shader compilation.
  38015. */
  38016. onError: Nullable<(effect: Effect, errors: string) => void>;
  38017. /**
  38018. * Callback that will be called when effect is bound.
  38019. */
  38020. onBind: Nullable<(effect: Effect) => void>;
  38021. /**
  38022. * Unique ID of the effect.
  38023. */
  38024. uniqueId: number;
  38025. /**
  38026. * Observable that will be called when the shader is compiled.
  38027. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  38028. */
  38029. onCompileObservable: Observable<Effect>;
  38030. /**
  38031. * Observable that will be called if an error occurs during shader compilation.
  38032. */
  38033. onErrorObservable: Observable<Effect>;
  38034. /** @hidden */
  38035. _onBindObservable: Nullable<Observable<Effect>>;
  38036. /**
  38037. * @hidden
  38038. * Specifies if the effect was previously ready
  38039. */
  38040. _wasPreviouslyReady: boolean;
  38041. /**
  38042. * Observable that will be called when effect is bound.
  38043. */
  38044. get onBindObservable(): Observable<Effect>;
  38045. /** @hidden */
  38046. _bonesComputationForcedToCPU: boolean;
  38047. /** @hidden */
  38048. _multiTarget: boolean;
  38049. private static _uniqueIdSeed;
  38050. private _engine;
  38051. private _uniformBuffersNames;
  38052. private _uniformBuffersNamesList;
  38053. private _uniformsNames;
  38054. private _samplerList;
  38055. private _samplers;
  38056. private _isReady;
  38057. private _compilationError;
  38058. private _allFallbacksProcessed;
  38059. private _attributesNames;
  38060. private _attributes;
  38061. private _attributeLocationByName;
  38062. private _uniforms;
  38063. /**
  38064. * Key for the effect.
  38065. * @hidden
  38066. */
  38067. _key: string;
  38068. private _indexParameters;
  38069. private _fallbacks;
  38070. private _vertexSourceCode;
  38071. private _fragmentSourceCode;
  38072. private _vertexSourceCodeOverride;
  38073. private _fragmentSourceCodeOverride;
  38074. private _transformFeedbackVaryings;
  38075. private _rawVertexSourceCode;
  38076. private _rawFragmentSourceCode;
  38077. /**
  38078. * Compiled shader to webGL program.
  38079. * @hidden
  38080. */
  38081. _pipelineContext: Nullable<IPipelineContext>;
  38082. private _valueCache;
  38083. private static _baseCache;
  38084. /**
  38085. * Instantiates an effect.
  38086. * An effect can be used to create/manage/execute vertex and fragment shaders.
  38087. * @param baseName Name of the effect.
  38088. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  38089. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  38090. * @param samplers List of sampler variables that will be passed to the shader.
  38091. * @param engine Engine to be used to render the effect
  38092. * @param defines Define statements to be added to the shader.
  38093. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  38094. * @param onCompiled Callback that will be called when the shader is compiled.
  38095. * @param onError Callback that will be called if an error occurs during shader compilation.
  38096. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  38097. */
  38098. 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);
  38099. private _useFinalCode;
  38100. /**
  38101. * Unique key for this effect
  38102. */
  38103. get key(): string;
  38104. /**
  38105. * If the effect has been compiled and prepared.
  38106. * @returns if the effect is compiled and prepared.
  38107. */
  38108. isReady(): boolean;
  38109. private _isReadyInternal;
  38110. /**
  38111. * The engine the effect was initialized with.
  38112. * @returns the engine.
  38113. */
  38114. getEngine(): Engine;
  38115. /**
  38116. * The pipeline context for this effect
  38117. * @returns the associated pipeline context
  38118. */
  38119. getPipelineContext(): Nullable<IPipelineContext>;
  38120. /**
  38121. * The set of names of attribute variables for the shader.
  38122. * @returns An array of attribute names.
  38123. */
  38124. getAttributesNames(): string[];
  38125. /**
  38126. * Returns the attribute at the given index.
  38127. * @param index The index of the attribute.
  38128. * @returns The location of the attribute.
  38129. */
  38130. getAttributeLocation(index: number): number;
  38131. /**
  38132. * Returns the attribute based on the name of the variable.
  38133. * @param name of the attribute to look up.
  38134. * @returns the attribute location.
  38135. */
  38136. getAttributeLocationByName(name: string): number;
  38137. /**
  38138. * The number of attributes.
  38139. * @returns the numnber of attributes.
  38140. */
  38141. getAttributesCount(): number;
  38142. /**
  38143. * Gets the index of a uniform variable.
  38144. * @param uniformName of the uniform to look up.
  38145. * @returns the index.
  38146. */
  38147. getUniformIndex(uniformName: string): number;
  38148. /**
  38149. * Returns the attribute based on the name of the variable.
  38150. * @param uniformName of the uniform to look up.
  38151. * @returns the location of the uniform.
  38152. */
  38153. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  38154. /**
  38155. * Returns an array of sampler variable names
  38156. * @returns The array of sampler variable names.
  38157. */
  38158. getSamplers(): string[];
  38159. /**
  38160. * Returns an array of uniform variable names
  38161. * @returns The array of uniform variable names.
  38162. */
  38163. getUniformNames(): string[];
  38164. /**
  38165. * Returns an array of uniform buffer variable names
  38166. * @returns The array of uniform buffer variable names.
  38167. */
  38168. getUniformBuffersNames(): string[];
  38169. /**
  38170. * Returns the index parameters used to create the effect
  38171. * @returns The index parameters object
  38172. */
  38173. getIndexParameters(): any;
  38174. /**
  38175. * The error from the last compilation.
  38176. * @returns the error string.
  38177. */
  38178. getCompilationError(): string;
  38179. /**
  38180. * Gets a boolean indicating that all fallbacks were used during compilation
  38181. * @returns true if all fallbacks were used
  38182. */
  38183. allFallbacksProcessed(): boolean;
  38184. /**
  38185. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  38186. * @param func The callback to be used.
  38187. */
  38188. executeWhenCompiled(func: (effect: Effect) => void): void;
  38189. private _checkIsReady;
  38190. private _loadShader;
  38191. /**
  38192. * Gets the vertex shader source code of this effect
  38193. */
  38194. get vertexSourceCode(): string;
  38195. /**
  38196. * Gets the fragment shader source code of this effect
  38197. */
  38198. get fragmentSourceCode(): string;
  38199. /**
  38200. * Gets the vertex shader source code before it has been processed by the preprocessor
  38201. */
  38202. get rawVertexSourceCode(): string;
  38203. /**
  38204. * Gets the fragment shader source code before it has been processed by the preprocessor
  38205. */
  38206. get rawFragmentSourceCode(): string;
  38207. /**
  38208. * Recompiles the webGL program
  38209. * @param vertexSourceCode The source code for the vertex shader.
  38210. * @param fragmentSourceCode The source code for the fragment shader.
  38211. * @param onCompiled Callback called when completed.
  38212. * @param onError Callback called on error.
  38213. * @hidden
  38214. */
  38215. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  38216. /**
  38217. * Prepares the effect
  38218. * @hidden
  38219. */
  38220. _prepareEffect(): void;
  38221. private _getShaderCodeAndErrorLine;
  38222. private _processCompilationErrors;
  38223. /**
  38224. * Checks if the effect is supported. (Must be called after compilation)
  38225. */
  38226. get isSupported(): boolean;
  38227. /**
  38228. * Binds a texture to the engine to be used as output of the shader.
  38229. * @param channel Name of the output variable.
  38230. * @param texture Texture to bind.
  38231. * @hidden
  38232. */
  38233. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  38234. /**
  38235. * Sets a texture on the engine to be used in the shader.
  38236. * @param channel Name of the sampler variable.
  38237. * @param texture Texture to set.
  38238. */
  38239. setTexture(channel: string, texture: Nullable<ThinTexture>): void;
  38240. /**
  38241. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  38242. * @param channel Name of the sampler variable.
  38243. * @param texture Texture to set.
  38244. */
  38245. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  38246. /**
  38247. * Sets an array of textures on the engine to be used in the shader.
  38248. * @param channel Name of the variable.
  38249. * @param textures Textures to set.
  38250. */
  38251. setTextureArray(channel: string, textures: ThinTexture[]): void;
  38252. /**
  38253. * 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)
  38254. * @param channel Name of the sampler variable.
  38255. * @param postProcess Post process to get the input texture from.
  38256. */
  38257. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  38258. /**
  38259. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  38260. * 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)
  38261. * @param channel Name of the sampler variable.
  38262. * @param postProcess Post process to get the output texture from.
  38263. */
  38264. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  38265. /** @hidden */
  38266. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  38267. /** @hidden */
  38268. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  38269. /** @hidden */
  38270. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  38271. /** @hidden */
  38272. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  38273. /**
  38274. * Binds a buffer to a uniform.
  38275. * @param buffer Buffer to bind.
  38276. * @param name Name of the uniform variable to bind to.
  38277. */
  38278. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  38279. /**
  38280. * Binds block to a uniform.
  38281. * @param blockName Name of the block to bind.
  38282. * @param index Index to bind.
  38283. */
  38284. bindUniformBlock(blockName: string, index: number): void;
  38285. /**
  38286. * Sets an interger value on a uniform variable.
  38287. * @param uniformName Name of the variable.
  38288. * @param value Value to be set.
  38289. * @returns this effect.
  38290. */
  38291. setInt(uniformName: string, value: number): Effect;
  38292. /**
  38293. * Sets an int array on a uniform variable.
  38294. * @param uniformName Name of the variable.
  38295. * @param array array to be set.
  38296. * @returns this effect.
  38297. */
  38298. setIntArray(uniformName: string, array: Int32Array): Effect;
  38299. /**
  38300. * 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)
  38301. * @param uniformName Name of the variable.
  38302. * @param array array to be set.
  38303. * @returns this effect.
  38304. */
  38305. setIntArray2(uniformName: string, array: Int32Array): Effect;
  38306. /**
  38307. * 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)
  38308. * @param uniformName Name of the variable.
  38309. * @param array array to be set.
  38310. * @returns this effect.
  38311. */
  38312. setIntArray3(uniformName: string, array: Int32Array): Effect;
  38313. /**
  38314. * 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)
  38315. * @param uniformName Name of the variable.
  38316. * @param array array to be set.
  38317. * @returns this effect.
  38318. */
  38319. setIntArray4(uniformName: string, array: Int32Array): Effect;
  38320. /**
  38321. * Sets an float array on a uniform variable.
  38322. * @param uniformName Name of the variable.
  38323. * @param array array to be set.
  38324. * @returns this effect.
  38325. */
  38326. setFloatArray(uniformName: string, array: Float32Array): Effect;
  38327. /**
  38328. * 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)
  38329. * @param uniformName Name of the variable.
  38330. * @param array array to be set.
  38331. * @returns this effect.
  38332. */
  38333. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  38334. /**
  38335. * 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)
  38336. * @param uniformName Name of the variable.
  38337. * @param array array to be set.
  38338. * @returns this effect.
  38339. */
  38340. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  38341. /**
  38342. * 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)
  38343. * @param uniformName Name of the variable.
  38344. * @param array array to be set.
  38345. * @returns this effect.
  38346. */
  38347. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  38348. /**
  38349. * Sets an array on a uniform variable.
  38350. * @param uniformName Name of the variable.
  38351. * @param array array to be set.
  38352. * @returns this effect.
  38353. */
  38354. setArray(uniformName: string, array: number[]): Effect;
  38355. /**
  38356. * 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)
  38357. * @param uniformName Name of the variable.
  38358. * @param array array to be set.
  38359. * @returns this effect.
  38360. */
  38361. setArray2(uniformName: string, array: number[]): Effect;
  38362. /**
  38363. * 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)
  38364. * @param uniformName Name of the variable.
  38365. * @param array array to be set.
  38366. * @returns this effect.
  38367. */
  38368. setArray3(uniformName: string, array: number[]): Effect;
  38369. /**
  38370. * 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)
  38371. * @param uniformName Name of the variable.
  38372. * @param array array to be set.
  38373. * @returns this effect.
  38374. */
  38375. setArray4(uniformName: string, array: number[]): Effect;
  38376. /**
  38377. * Sets matrices on a uniform variable.
  38378. * @param uniformName Name of the variable.
  38379. * @param matrices matrices to be set.
  38380. * @returns this effect.
  38381. */
  38382. setMatrices(uniformName: string, matrices: Float32Array | Array<number>): Effect;
  38383. /**
  38384. * Sets matrix on a uniform variable.
  38385. * @param uniformName Name of the variable.
  38386. * @param matrix matrix to be set.
  38387. * @returns this effect.
  38388. */
  38389. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  38390. /**
  38391. * 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)
  38392. * @param uniformName Name of the variable.
  38393. * @param matrix matrix to be set.
  38394. * @returns this effect.
  38395. */
  38396. setMatrix3x3(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  38397. /**
  38398. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  38399. * @param uniformName Name of the variable.
  38400. * @param matrix matrix to be set.
  38401. * @returns this effect.
  38402. */
  38403. setMatrix2x2(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  38404. /**
  38405. * Sets a float on a uniform variable.
  38406. * @param uniformName Name of the variable.
  38407. * @param value value to be set.
  38408. * @returns this effect.
  38409. */
  38410. setFloat(uniformName: string, value: number): Effect;
  38411. /**
  38412. * Sets a boolean on a uniform variable.
  38413. * @param uniformName Name of the variable.
  38414. * @param bool value to be set.
  38415. * @returns this effect.
  38416. */
  38417. setBool(uniformName: string, bool: boolean): Effect;
  38418. /**
  38419. * Sets a Vector2 on a uniform variable.
  38420. * @param uniformName Name of the variable.
  38421. * @param vector2 vector2 to be set.
  38422. * @returns this effect.
  38423. */
  38424. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  38425. /**
  38426. * Sets a float2 on a uniform variable.
  38427. * @param uniformName Name of the variable.
  38428. * @param x First float in float2.
  38429. * @param y Second float in float2.
  38430. * @returns this effect.
  38431. */
  38432. setFloat2(uniformName: string, x: number, y: number): Effect;
  38433. /**
  38434. * Sets a Vector3 on a uniform variable.
  38435. * @param uniformName Name of the variable.
  38436. * @param vector3 Value to be set.
  38437. * @returns this effect.
  38438. */
  38439. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  38440. /**
  38441. * Sets a float3 on a uniform variable.
  38442. * @param uniformName Name of the variable.
  38443. * @param x First float in float3.
  38444. * @param y Second float in float3.
  38445. * @param z Third float in float3.
  38446. * @returns this effect.
  38447. */
  38448. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  38449. /**
  38450. * Sets a Vector4 on a uniform variable.
  38451. * @param uniformName Name of the variable.
  38452. * @param vector4 Value to be set.
  38453. * @returns this effect.
  38454. */
  38455. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  38456. /**
  38457. * Sets a float4 on a uniform variable.
  38458. * @param uniformName Name of the variable.
  38459. * @param x First float in float4.
  38460. * @param y Second float in float4.
  38461. * @param z Third float in float4.
  38462. * @param w Fourth float in float4.
  38463. * @returns this effect.
  38464. */
  38465. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  38466. /**
  38467. * Sets a Color3 on a uniform variable.
  38468. * @param uniformName Name of the variable.
  38469. * @param color3 Value to be set.
  38470. * @returns this effect.
  38471. */
  38472. setColor3(uniformName: string, color3: IColor3Like): Effect;
  38473. /**
  38474. * Sets a Color4 on a uniform variable.
  38475. * @param uniformName Name of the variable.
  38476. * @param color3 Value to be set.
  38477. * @param alpha Alpha value to be set.
  38478. * @returns this effect.
  38479. */
  38480. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  38481. /**
  38482. * Sets a Color4 on a uniform variable
  38483. * @param uniformName defines the name of the variable
  38484. * @param color4 defines the value to be set
  38485. * @returns this effect.
  38486. */
  38487. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  38488. /** Release all associated resources */
  38489. dispose(): void;
  38490. /**
  38491. * This function will add a new shader to the shader store
  38492. * @param name the name of the shader
  38493. * @param pixelShader optional pixel shader content
  38494. * @param vertexShader optional vertex shader content
  38495. */
  38496. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  38497. /**
  38498. * Store of each shader (The can be looked up using effect.key)
  38499. */
  38500. static ShadersStore: {
  38501. [key: string]: string;
  38502. };
  38503. /**
  38504. * Store of each included file for a shader (The can be looked up using effect.key)
  38505. */
  38506. static IncludesShadersStore: {
  38507. [key: string]: string;
  38508. };
  38509. /**
  38510. * Resets the cache of effects.
  38511. */
  38512. static ResetCache(): void;
  38513. }
  38514. }
  38515. declare module BABYLON {
  38516. /**
  38517. * Interface used to describe the capabilities of the engine relatively to the current browser
  38518. */
  38519. export interface EngineCapabilities {
  38520. /** Maximum textures units per fragment shader */
  38521. maxTexturesImageUnits: number;
  38522. /** Maximum texture units per vertex shader */
  38523. maxVertexTextureImageUnits: number;
  38524. /** Maximum textures units in the entire pipeline */
  38525. maxCombinedTexturesImageUnits: number;
  38526. /** Maximum texture size */
  38527. maxTextureSize: number;
  38528. /** Maximum texture samples */
  38529. maxSamples?: number;
  38530. /** Maximum cube texture size */
  38531. maxCubemapTextureSize: number;
  38532. /** Maximum render texture size */
  38533. maxRenderTextureSize: number;
  38534. /** Maximum number of vertex attributes */
  38535. maxVertexAttribs: number;
  38536. /** Maximum number of varyings */
  38537. maxVaryingVectors: number;
  38538. /** Maximum number of uniforms per vertex shader */
  38539. maxVertexUniformVectors: number;
  38540. /** Maximum number of uniforms per fragment shader */
  38541. maxFragmentUniformVectors: number;
  38542. /** Defines if standard derivates (dx/dy) are supported */
  38543. standardDerivatives: boolean;
  38544. /** Defines if s3tc texture compression is supported */
  38545. s3tc?: WEBGL_compressed_texture_s3tc;
  38546. /** Defines if pvrtc texture compression is supported */
  38547. pvrtc: any;
  38548. /** Defines if etc1 texture compression is supported */
  38549. etc1: any;
  38550. /** Defines if etc2 texture compression is supported */
  38551. etc2: any;
  38552. /** Defines if astc texture compression is supported */
  38553. astc: any;
  38554. /** Defines if bptc texture compression is supported */
  38555. bptc: any;
  38556. /** Defines if float textures are supported */
  38557. textureFloat: boolean;
  38558. /** Defines if vertex array objects are supported */
  38559. vertexArrayObject: boolean;
  38560. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  38561. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  38562. /** Gets the maximum level of anisotropy supported */
  38563. maxAnisotropy: number;
  38564. /** Defines if instancing is supported */
  38565. instancedArrays: boolean;
  38566. /** Defines if 32 bits indices are supported */
  38567. uintIndices: boolean;
  38568. /** Defines if high precision shaders are supported */
  38569. highPrecisionShaderSupported: boolean;
  38570. /** Defines if depth reading in the fragment shader is supported */
  38571. fragmentDepthSupported: boolean;
  38572. /** Defines if float texture linear filtering is supported*/
  38573. textureFloatLinearFiltering: boolean;
  38574. /** Defines if rendering to float textures is supported */
  38575. textureFloatRender: boolean;
  38576. /** Defines if half float textures are supported*/
  38577. textureHalfFloat: boolean;
  38578. /** Defines if half float texture linear filtering is supported*/
  38579. textureHalfFloatLinearFiltering: boolean;
  38580. /** Defines if rendering to half float textures is supported */
  38581. textureHalfFloatRender: boolean;
  38582. /** Defines if textureLOD shader command is supported */
  38583. textureLOD: boolean;
  38584. /** Defines if draw buffers extension is supported */
  38585. drawBuffersExtension: boolean;
  38586. /** Defines if depth textures are supported */
  38587. depthTextureExtension: boolean;
  38588. /** Defines if float color buffer are supported */
  38589. colorBufferFloat: boolean;
  38590. /** Gets disjoint timer query extension (null if not supported) */
  38591. timerQuery?: EXT_disjoint_timer_query;
  38592. /** Defines if timestamp can be used with timer query */
  38593. canUseTimestampForTimerQuery: boolean;
  38594. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  38595. multiview?: any;
  38596. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  38597. oculusMultiview?: any;
  38598. /** Function used to let the system compiles shaders in background */
  38599. parallelShaderCompile?: {
  38600. COMPLETION_STATUS_KHR: number;
  38601. };
  38602. /** Max number of texture samples for MSAA */
  38603. maxMSAASamples: number;
  38604. /** Defines if the blend min max extension is supported */
  38605. blendMinMax: boolean;
  38606. }
  38607. }
  38608. declare module BABYLON {
  38609. /**
  38610. * @hidden
  38611. **/
  38612. export class DepthCullingState {
  38613. private _isDepthTestDirty;
  38614. private _isDepthMaskDirty;
  38615. private _isDepthFuncDirty;
  38616. private _isCullFaceDirty;
  38617. private _isCullDirty;
  38618. private _isZOffsetDirty;
  38619. private _isFrontFaceDirty;
  38620. private _depthTest;
  38621. private _depthMask;
  38622. private _depthFunc;
  38623. private _cull;
  38624. private _cullFace;
  38625. private _zOffset;
  38626. private _frontFace;
  38627. /**
  38628. * Initializes the state.
  38629. */
  38630. constructor();
  38631. get isDirty(): boolean;
  38632. get zOffset(): number;
  38633. set zOffset(value: number);
  38634. get cullFace(): Nullable<number>;
  38635. set cullFace(value: Nullable<number>);
  38636. get cull(): Nullable<boolean>;
  38637. set cull(value: Nullable<boolean>);
  38638. get depthFunc(): Nullable<number>;
  38639. set depthFunc(value: Nullable<number>);
  38640. get depthMask(): boolean;
  38641. set depthMask(value: boolean);
  38642. get depthTest(): boolean;
  38643. set depthTest(value: boolean);
  38644. get frontFace(): Nullable<number>;
  38645. set frontFace(value: Nullable<number>);
  38646. reset(): void;
  38647. apply(gl: WebGLRenderingContext): void;
  38648. }
  38649. }
  38650. declare module BABYLON {
  38651. /**
  38652. * @hidden
  38653. **/
  38654. export class StencilState {
  38655. /** 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 */
  38656. static readonly ALWAYS: number;
  38657. /** Passed to stencilOperation to specify that stencil value must be kept */
  38658. static readonly KEEP: number;
  38659. /** Passed to stencilOperation to specify that stencil value must be replaced */
  38660. static readonly REPLACE: number;
  38661. private _isStencilTestDirty;
  38662. private _isStencilMaskDirty;
  38663. private _isStencilFuncDirty;
  38664. private _isStencilOpDirty;
  38665. private _stencilTest;
  38666. private _stencilMask;
  38667. private _stencilFunc;
  38668. private _stencilFuncRef;
  38669. private _stencilFuncMask;
  38670. private _stencilOpStencilFail;
  38671. private _stencilOpDepthFail;
  38672. private _stencilOpStencilDepthPass;
  38673. get isDirty(): boolean;
  38674. get stencilFunc(): number;
  38675. set stencilFunc(value: number);
  38676. get stencilFuncRef(): number;
  38677. set stencilFuncRef(value: number);
  38678. get stencilFuncMask(): number;
  38679. set stencilFuncMask(value: number);
  38680. get stencilOpStencilFail(): number;
  38681. set stencilOpStencilFail(value: number);
  38682. get stencilOpDepthFail(): number;
  38683. set stencilOpDepthFail(value: number);
  38684. get stencilOpStencilDepthPass(): number;
  38685. set stencilOpStencilDepthPass(value: number);
  38686. get stencilMask(): number;
  38687. set stencilMask(value: number);
  38688. get stencilTest(): boolean;
  38689. set stencilTest(value: boolean);
  38690. constructor();
  38691. reset(): void;
  38692. apply(gl: WebGLRenderingContext): void;
  38693. }
  38694. }
  38695. declare module BABYLON {
  38696. /**
  38697. * @hidden
  38698. **/
  38699. export class AlphaState {
  38700. private _isAlphaBlendDirty;
  38701. private _isBlendFunctionParametersDirty;
  38702. private _isBlendEquationParametersDirty;
  38703. private _isBlendConstantsDirty;
  38704. private _alphaBlend;
  38705. private _blendFunctionParameters;
  38706. private _blendEquationParameters;
  38707. private _blendConstants;
  38708. /**
  38709. * Initializes the state.
  38710. */
  38711. constructor();
  38712. get isDirty(): boolean;
  38713. get alphaBlend(): boolean;
  38714. set alphaBlend(value: boolean);
  38715. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  38716. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  38717. setAlphaEquationParameters(rgb: number, alpha: number): void;
  38718. reset(): void;
  38719. apply(gl: WebGLRenderingContext): void;
  38720. }
  38721. }
  38722. declare module BABYLON {
  38723. /** @hidden */
  38724. export class WebGLShaderProcessor implements IShaderProcessor {
  38725. postProcessor(code: string, defines: string[], isFragment: boolean, engine: ThinEngine): string;
  38726. }
  38727. }
  38728. declare module BABYLON {
  38729. /** @hidden */
  38730. export class WebGL2ShaderProcessor implements IShaderProcessor {
  38731. attributeProcessor(attribute: string): string;
  38732. varyingProcessor(varying: string, isFragment: boolean): string;
  38733. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  38734. }
  38735. }
  38736. declare module BABYLON {
  38737. /**
  38738. * Interface for attribute information associated with buffer instanciation
  38739. */
  38740. export interface InstancingAttributeInfo {
  38741. /**
  38742. * Name of the GLSL attribute
  38743. * if attribute index is not specified, this is used to retrieve the index from the effect
  38744. */
  38745. attributeName: string;
  38746. /**
  38747. * Index/offset of the attribute in the vertex shader
  38748. * if not specified, this will be computes from the name.
  38749. */
  38750. index?: number;
  38751. /**
  38752. * size of the attribute, 1, 2, 3 or 4
  38753. */
  38754. attributeSize: number;
  38755. /**
  38756. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  38757. */
  38758. offset: number;
  38759. /**
  38760. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  38761. * default to 1
  38762. */
  38763. divisor?: number;
  38764. /**
  38765. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  38766. * default is FLOAT
  38767. */
  38768. attributeType?: number;
  38769. /**
  38770. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  38771. */
  38772. normalized?: boolean;
  38773. }
  38774. }
  38775. declare module BABYLON {
  38776. interface ThinEngine {
  38777. /**
  38778. * Update a video texture
  38779. * @param texture defines the texture to update
  38780. * @param video defines the video element to use
  38781. * @param invertY defines if data must be stored with Y axis inverted
  38782. */
  38783. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  38784. }
  38785. }
  38786. declare module BABYLON {
  38787. interface ThinEngine {
  38788. /**
  38789. * Creates a dynamic texture
  38790. * @param width defines the width of the texture
  38791. * @param height defines the height of the texture
  38792. * @param generateMipMaps defines if the engine should generate the mip levels
  38793. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  38794. * @returns the dynamic texture inside an InternalTexture
  38795. */
  38796. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  38797. /**
  38798. * Update the content of a dynamic texture
  38799. * @param texture defines the texture to update
  38800. * @param source defines the source containing the data
  38801. * @param invertY defines if data must be stored with Y axis inverted
  38802. * @param premulAlpha defines if alpha is stored as premultiplied
  38803. * @param format defines the format of the data
  38804. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  38805. */
  38806. updateDynamicTexture(texture: Nullable<InternalTexture>, source: ImageBitmap | ImageData | HTMLImageElement | HTMLCanvasElement | HTMLVideoElement | OffscreenCanvas, invertY?: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  38807. }
  38808. }
  38809. declare module BABYLON {
  38810. /**
  38811. * Settings for finer control over video usage
  38812. */
  38813. export interface VideoTextureSettings {
  38814. /**
  38815. * Applies `autoplay` to video, if specified
  38816. */
  38817. autoPlay?: boolean;
  38818. /**
  38819. * Applies `muted` to video, if specified
  38820. */
  38821. muted?: boolean;
  38822. /**
  38823. * Applies `loop` to video, if specified
  38824. */
  38825. loop?: boolean;
  38826. /**
  38827. * Automatically updates internal texture from video at every frame in the render loop
  38828. */
  38829. autoUpdateTexture: boolean;
  38830. /**
  38831. * Image src displayed during the video loading or until the user interacts with the video.
  38832. */
  38833. poster?: string;
  38834. }
  38835. /**
  38836. * If you want to display a video in your scene, this is the special texture for that.
  38837. * This special texture works similar to other textures, with the exception of a few parameters.
  38838. * @see https://doc.babylonjs.com/how_to/video_texture
  38839. */
  38840. export class VideoTexture extends Texture {
  38841. /**
  38842. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  38843. */
  38844. readonly autoUpdateTexture: boolean;
  38845. /**
  38846. * The video instance used by the texture internally
  38847. */
  38848. readonly video: HTMLVideoElement;
  38849. private _onUserActionRequestedObservable;
  38850. /**
  38851. * Event triggerd when a dom action is required by the user to play the video.
  38852. * This happens due to recent changes in browser policies preventing video to auto start.
  38853. */
  38854. get onUserActionRequestedObservable(): Observable<Texture>;
  38855. private _generateMipMaps;
  38856. private _stillImageCaptured;
  38857. private _displayingPosterTexture;
  38858. private _settings;
  38859. private _createInternalTextureOnEvent;
  38860. private _frameId;
  38861. private _currentSrc;
  38862. /**
  38863. * Creates a video texture.
  38864. * If you want to display a video in your scene, this is the special texture for that.
  38865. * This special texture works similar to other textures, with the exception of a few parameters.
  38866. * @see https://doc.babylonjs.com/how_to/video_texture
  38867. * @param name optional name, will detect from video source, if not defined
  38868. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  38869. * @param scene is obviously the current scene.
  38870. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  38871. * @param invertY is false by default but can be used to invert video on Y axis
  38872. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  38873. * @param settings allows finer control over video usage
  38874. */
  38875. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  38876. private _getName;
  38877. private _getVideo;
  38878. private _createInternalTexture;
  38879. private reset;
  38880. /**
  38881. * @hidden Internal method to initiate `update`.
  38882. */
  38883. _rebuild(): void;
  38884. /**
  38885. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  38886. */
  38887. update(): void;
  38888. /**
  38889. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  38890. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  38891. */
  38892. updateTexture(isVisible: boolean): void;
  38893. protected _updateInternalTexture: () => void;
  38894. /**
  38895. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  38896. * @param url New url.
  38897. */
  38898. updateURL(url: string): void;
  38899. /**
  38900. * Clones the texture.
  38901. * @returns the cloned texture
  38902. */
  38903. clone(): VideoTexture;
  38904. /**
  38905. * Dispose the texture and release its associated resources.
  38906. */
  38907. dispose(): void;
  38908. /**
  38909. * Creates a video texture straight from a stream.
  38910. * @param scene Define the scene the texture should be created in
  38911. * @param stream Define the stream the texture should be created from
  38912. * @returns The created video texture as a promise
  38913. */
  38914. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  38915. /**
  38916. * Creates a video texture straight from your WebCam video feed.
  38917. * @param scene Define the scene the texture should be created in
  38918. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  38919. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  38920. * @returns The created video texture as a promise
  38921. */
  38922. static CreateFromWebCamAsync(scene: Scene, constraints: {
  38923. minWidth: number;
  38924. maxWidth: number;
  38925. minHeight: number;
  38926. maxHeight: number;
  38927. deviceId: string;
  38928. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  38929. /**
  38930. * Creates a video texture straight from your WebCam video feed.
  38931. * @param scene Define the scene the texture should be created in
  38932. * @param onReady Define a callback to triggered once the texture will be ready
  38933. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  38934. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  38935. */
  38936. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  38937. minWidth: number;
  38938. maxWidth: number;
  38939. minHeight: number;
  38940. maxHeight: number;
  38941. deviceId: string;
  38942. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  38943. }
  38944. }
  38945. declare module BABYLON {
  38946. /**
  38947. * Defines the interface used by objects working like Scene
  38948. * @hidden
  38949. */
  38950. export interface ISceneLike {
  38951. _addPendingData(data: any): void;
  38952. _removePendingData(data: any): void;
  38953. offlineProvider: IOfflineProvider;
  38954. }
  38955. /**
  38956. * Information about the current host
  38957. */
  38958. export interface HostInformation {
  38959. /**
  38960. * Defines if the current host is a mobile
  38961. */
  38962. isMobile: boolean;
  38963. }
  38964. /** Interface defining initialization parameters for Engine class */
  38965. export interface EngineOptions extends WebGLContextAttributes {
  38966. /**
  38967. * Defines if the engine should no exceed a specified device ratio
  38968. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  38969. */
  38970. limitDeviceRatio?: number;
  38971. /**
  38972. * Defines if webvr should be enabled automatically
  38973. * @see https://doc.babylonjs.com/how_to/webvr_camera
  38974. */
  38975. autoEnableWebVR?: boolean;
  38976. /**
  38977. * Defines if webgl2 should be turned off even if supported
  38978. * @see https://doc.babylonjs.com/features/webgl2
  38979. */
  38980. disableWebGL2Support?: boolean;
  38981. /**
  38982. * Defines if webaudio should be initialized as well
  38983. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  38984. */
  38985. audioEngine?: boolean;
  38986. /**
  38987. * Defines if animations should run using a deterministic lock step
  38988. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  38989. */
  38990. deterministicLockstep?: boolean;
  38991. /** Defines the maximum steps to use with deterministic lock step mode */
  38992. lockstepMaxSteps?: number;
  38993. /** Defines the seconds between each deterministic lock step */
  38994. timeStep?: number;
  38995. /**
  38996. * Defines that engine should ignore context lost events
  38997. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  38998. */
  38999. doNotHandleContextLost?: boolean;
  39000. /**
  39001. * Defines that engine should ignore modifying touch action attribute and style
  39002. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  39003. */
  39004. doNotHandleTouchAction?: boolean;
  39005. /**
  39006. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  39007. */
  39008. useHighPrecisionFloats?: boolean;
  39009. /**
  39010. * Make the canvas XR Compatible for XR sessions
  39011. */
  39012. xrCompatible?: boolean;
  39013. /**
  39014. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  39015. */
  39016. useHighPrecisionMatrix?: boolean;
  39017. /**
  39018. * Will prevent the system from falling back to software implementation if a hardware device cannot be created
  39019. */
  39020. failIfMajorPerformanceCaveat?: boolean;
  39021. }
  39022. /**
  39023. * The base engine class (root of all engines)
  39024. */
  39025. export class ThinEngine {
  39026. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  39027. static ExceptionList: ({
  39028. key: string;
  39029. capture: string;
  39030. captureConstraint: number;
  39031. targets: string[];
  39032. } | {
  39033. key: string;
  39034. capture: null;
  39035. captureConstraint: null;
  39036. targets: string[];
  39037. })[];
  39038. /** @hidden */
  39039. static _TextureLoaders: IInternalTextureLoader[];
  39040. /**
  39041. * Returns the current npm package of the sdk
  39042. */
  39043. static get NpmPackage(): string;
  39044. /**
  39045. * Returns the current version of the framework
  39046. */
  39047. static get Version(): string;
  39048. /**
  39049. * Returns a string describing the current engine
  39050. */
  39051. get description(): string;
  39052. /**
  39053. * Gets or sets the epsilon value used by collision engine
  39054. */
  39055. static CollisionsEpsilon: number;
  39056. /**
  39057. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  39058. */
  39059. static get ShadersRepository(): string;
  39060. static set ShadersRepository(value: string);
  39061. /** @hidden */
  39062. _shaderProcessor: IShaderProcessor;
  39063. /**
  39064. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  39065. */
  39066. forcePOTTextures: boolean;
  39067. /**
  39068. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  39069. */
  39070. isFullscreen: boolean;
  39071. /**
  39072. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  39073. */
  39074. cullBackFaces: boolean;
  39075. /**
  39076. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  39077. */
  39078. renderEvenInBackground: boolean;
  39079. /**
  39080. * Gets or sets a boolean indicating that cache can be kept between frames
  39081. */
  39082. preventCacheWipeBetweenFrames: boolean;
  39083. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  39084. validateShaderPrograms: boolean;
  39085. /**
  39086. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  39087. * This can provide greater z depth for distant objects.
  39088. */
  39089. useReverseDepthBuffer: boolean;
  39090. /**
  39091. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  39092. */
  39093. disableUniformBuffers: boolean;
  39094. /** @hidden */
  39095. _uniformBuffers: UniformBuffer[];
  39096. /**
  39097. * Gets a boolean indicating that the engine supports uniform buffers
  39098. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  39099. */
  39100. get supportsUniformBuffers(): boolean;
  39101. /** @hidden */
  39102. _gl: WebGLRenderingContext;
  39103. /** @hidden */
  39104. _webGLVersion: number;
  39105. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  39106. protected _windowIsBackground: boolean;
  39107. protected _creationOptions: EngineOptions;
  39108. protected _highPrecisionShadersAllowed: boolean;
  39109. /** @hidden */
  39110. get _shouldUseHighPrecisionShader(): boolean;
  39111. /**
  39112. * Gets a boolean indicating that only power of 2 textures are supported
  39113. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  39114. */
  39115. get needPOTTextures(): boolean;
  39116. /** @hidden */
  39117. _badOS: boolean;
  39118. /** @hidden */
  39119. _badDesktopOS: boolean;
  39120. private _hardwareScalingLevel;
  39121. /** @hidden */
  39122. _caps: EngineCapabilities;
  39123. private _isStencilEnable;
  39124. private _glVersion;
  39125. private _glRenderer;
  39126. private _glVendor;
  39127. /** @hidden */
  39128. _videoTextureSupported: boolean;
  39129. protected _renderingQueueLaunched: boolean;
  39130. protected _activeRenderLoops: (() => void)[];
  39131. /**
  39132. * Observable signaled when a context lost event is raised
  39133. */
  39134. onContextLostObservable: Observable<ThinEngine>;
  39135. /**
  39136. * Observable signaled when a context restored event is raised
  39137. */
  39138. onContextRestoredObservable: Observable<ThinEngine>;
  39139. private _onContextLost;
  39140. private _onContextRestored;
  39141. protected _contextWasLost: boolean;
  39142. /** @hidden */
  39143. _doNotHandleContextLost: boolean;
  39144. /**
  39145. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  39146. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  39147. */
  39148. get doNotHandleContextLost(): boolean;
  39149. set doNotHandleContextLost(value: boolean);
  39150. /**
  39151. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  39152. */
  39153. disableVertexArrayObjects: boolean;
  39154. /** @hidden */
  39155. protected _colorWrite: boolean;
  39156. /** @hidden */
  39157. protected _colorWriteChanged: boolean;
  39158. /** @hidden */
  39159. protected _depthCullingState: DepthCullingState;
  39160. /** @hidden */
  39161. protected _stencilState: StencilState;
  39162. /** @hidden */
  39163. _alphaState: AlphaState;
  39164. /** @hidden */
  39165. _alphaMode: number;
  39166. /** @hidden */
  39167. _alphaEquation: number;
  39168. /** @hidden */
  39169. _internalTexturesCache: InternalTexture[];
  39170. /** @hidden */
  39171. protected _activeChannel: number;
  39172. private _currentTextureChannel;
  39173. /** @hidden */
  39174. protected _boundTexturesCache: {
  39175. [key: string]: Nullable<InternalTexture>;
  39176. };
  39177. /** @hidden */
  39178. protected _currentEffect: Nullable<Effect>;
  39179. /** @hidden */
  39180. protected _currentProgram: Nullable<WebGLProgram>;
  39181. private _compiledEffects;
  39182. private _vertexAttribArraysEnabled;
  39183. /** @hidden */
  39184. protected _cachedViewport: Nullable<IViewportLike>;
  39185. private _cachedVertexArrayObject;
  39186. /** @hidden */
  39187. protected _cachedVertexBuffers: any;
  39188. /** @hidden */
  39189. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  39190. /** @hidden */
  39191. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  39192. /** @hidden */
  39193. _currentRenderTarget: Nullable<InternalTexture>;
  39194. private _uintIndicesCurrentlySet;
  39195. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  39196. /** @hidden */
  39197. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  39198. /** @hidden */
  39199. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  39200. private _currentBufferPointers;
  39201. private _currentInstanceLocations;
  39202. private _currentInstanceBuffers;
  39203. private _textureUnits;
  39204. /** @hidden */
  39205. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  39206. /** @hidden */
  39207. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  39208. /** @hidden */
  39209. _boundRenderFunction: any;
  39210. private _vaoRecordInProgress;
  39211. private _mustWipeVertexAttributes;
  39212. private _emptyTexture;
  39213. private _emptyCubeTexture;
  39214. private _emptyTexture3D;
  39215. private _emptyTexture2DArray;
  39216. /** @hidden */
  39217. _frameHandler: number;
  39218. private _nextFreeTextureSlots;
  39219. private _maxSimultaneousTextures;
  39220. private _activeRequests;
  39221. /** @hidden */
  39222. _transformTextureUrl: Nullable<(url: string) => string>;
  39223. /**
  39224. * Gets information about the current host
  39225. */
  39226. hostInformation: HostInformation;
  39227. protected get _supportsHardwareTextureRescaling(): boolean;
  39228. private _framebufferDimensionsObject;
  39229. /**
  39230. * sets the object from which width and height will be taken from when getting render width and height
  39231. * Will fallback to the gl object
  39232. * @param dimensions the framebuffer width and height that will be used.
  39233. */
  39234. set framebufferDimensionsObject(dimensions: Nullable<{
  39235. framebufferWidth: number;
  39236. framebufferHeight: number;
  39237. }>);
  39238. /**
  39239. * Gets the current viewport
  39240. */
  39241. get currentViewport(): Nullable<IViewportLike>;
  39242. /**
  39243. * Gets the default empty texture
  39244. */
  39245. get emptyTexture(): InternalTexture;
  39246. /**
  39247. * Gets the default empty 3D texture
  39248. */
  39249. get emptyTexture3D(): InternalTexture;
  39250. /**
  39251. * Gets the default empty 2D array texture
  39252. */
  39253. get emptyTexture2DArray(): InternalTexture;
  39254. /**
  39255. * Gets the default empty cube texture
  39256. */
  39257. get emptyCubeTexture(): InternalTexture;
  39258. /**
  39259. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  39260. */
  39261. readonly premultipliedAlpha: boolean;
  39262. /**
  39263. * Observable event triggered before each texture is initialized
  39264. */
  39265. onBeforeTextureInitObservable: Observable<Texture>;
  39266. /**
  39267. * Creates a new engine
  39268. * @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
  39269. * @param antialias defines enable antialiasing (default: false)
  39270. * @param options defines further options to be sent to the getContext() function
  39271. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  39272. */
  39273. constructor(canvasOrContext: Nullable<HTMLCanvasElement | OffscreenCanvas | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  39274. private _rebuildInternalTextures;
  39275. private _rebuildEffects;
  39276. /**
  39277. * Gets a boolean indicating if all created effects are ready
  39278. * @returns true if all effects are ready
  39279. */
  39280. areAllEffectsReady(): boolean;
  39281. protected _rebuildBuffers(): void;
  39282. protected _initGLContext(): void;
  39283. /**
  39284. * Gets version of the current webGL context
  39285. */
  39286. get webGLVersion(): number;
  39287. /**
  39288. * Gets a string identifying the name of the class
  39289. * @returns "Engine" string
  39290. */
  39291. getClassName(): string;
  39292. /**
  39293. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  39294. */
  39295. get isStencilEnable(): boolean;
  39296. /** @hidden */
  39297. _prepareWorkingCanvas(): void;
  39298. /**
  39299. * Reset the texture cache to empty state
  39300. */
  39301. resetTextureCache(): void;
  39302. /**
  39303. * Gets an object containing information about the current webGL context
  39304. * @returns an object containing the vender, the renderer and the version of the current webGL context
  39305. */
  39306. getGlInfo(): {
  39307. vendor: string;
  39308. renderer: string;
  39309. version: string;
  39310. };
  39311. /**
  39312. * Defines the hardware scaling level.
  39313. * By default the hardware scaling level is computed from the window device ratio.
  39314. * 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.
  39315. * @param level defines the level to use
  39316. */
  39317. setHardwareScalingLevel(level: number): void;
  39318. /**
  39319. * Gets the current hardware scaling level.
  39320. * By default the hardware scaling level is computed from the window device ratio.
  39321. * 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.
  39322. * @returns a number indicating the current hardware scaling level
  39323. */
  39324. getHardwareScalingLevel(): number;
  39325. /**
  39326. * Gets the list of loaded textures
  39327. * @returns an array containing all loaded textures
  39328. */
  39329. getLoadedTexturesCache(): InternalTexture[];
  39330. /**
  39331. * Gets the object containing all engine capabilities
  39332. * @returns the EngineCapabilities object
  39333. */
  39334. getCaps(): EngineCapabilities;
  39335. /**
  39336. * stop executing a render loop function and remove it from the execution array
  39337. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  39338. */
  39339. stopRenderLoop(renderFunction?: () => void): void;
  39340. /** @hidden */
  39341. _renderLoop(): void;
  39342. /**
  39343. * Gets the HTML canvas attached with the current webGL context
  39344. * @returns a HTML canvas
  39345. */
  39346. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  39347. /**
  39348. * Gets host window
  39349. * @returns the host window object
  39350. */
  39351. getHostWindow(): Nullable<Window>;
  39352. /**
  39353. * Gets the current render width
  39354. * @param useScreen defines if screen size must be used (or the current render target if any)
  39355. * @returns a number defining the current render width
  39356. */
  39357. getRenderWidth(useScreen?: boolean): number;
  39358. /**
  39359. * Gets the current render height
  39360. * @param useScreen defines if screen size must be used (or the current render target if any)
  39361. * @returns a number defining the current render height
  39362. */
  39363. getRenderHeight(useScreen?: boolean): number;
  39364. /**
  39365. * Can be used to override the current requestAnimationFrame requester.
  39366. * @hidden
  39367. */
  39368. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  39369. /**
  39370. * Register and execute a render loop. The engine can have more than one render function
  39371. * @param renderFunction defines the function to continuously execute
  39372. */
  39373. runRenderLoop(renderFunction: () => void): void;
  39374. /**
  39375. * Clear the current render buffer or the current render target (if any is set up)
  39376. * @param color defines the color to use
  39377. * @param backBuffer defines if the back buffer must be cleared
  39378. * @param depth defines if the depth buffer must be cleared
  39379. * @param stencil defines if the stencil buffer must be cleared
  39380. */
  39381. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  39382. private _viewportCached;
  39383. /** @hidden */
  39384. _viewport(x: number, y: number, width: number, height: number): void;
  39385. /**
  39386. * Set the WebGL's viewport
  39387. * @param viewport defines the viewport element to be used
  39388. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  39389. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  39390. */
  39391. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  39392. /**
  39393. * Begin a new frame
  39394. */
  39395. beginFrame(): void;
  39396. /**
  39397. * Enf the current frame
  39398. */
  39399. endFrame(): void;
  39400. /**
  39401. * Resize the view according to the canvas' size
  39402. */
  39403. resize(): void;
  39404. /**
  39405. * Force a specific size of the canvas
  39406. * @param width defines the new canvas' width
  39407. * @param height defines the new canvas' height
  39408. * @returns true if the size was changed
  39409. */
  39410. setSize(width: number, height: number): boolean;
  39411. /**
  39412. * Binds the frame buffer to the specified texture.
  39413. * @param texture The texture to render to or null for the default canvas
  39414. * @param faceIndex The face of the texture to render to in case of cube texture
  39415. * @param requiredWidth The width of the target to render to
  39416. * @param requiredHeight The height of the target to render to
  39417. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  39418. * @param lodLevel defines the lod level to bind to the frame buffer
  39419. * @param layer defines the 2d array index to bind to frame buffer to
  39420. */
  39421. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  39422. /** @hidden */
  39423. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  39424. /**
  39425. * Unbind the current render target texture from the webGL context
  39426. * @param texture defines the render target texture to unbind
  39427. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  39428. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  39429. */
  39430. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  39431. /**
  39432. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  39433. */
  39434. flushFramebuffer(): void;
  39435. /**
  39436. * Unbind the current render target and bind the default framebuffer
  39437. */
  39438. restoreDefaultFramebuffer(): void;
  39439. /** @hidden */
  39440. protected _resetVertexBufferBinding(): void;
  39441. /**
  39442. * Creates a vertex buffer
  39443. * @param data the data for the vertex buffer
  39444. * @returns the new WebGL static buffer
  39445. */
  39446. createVertexBuffer(data: DataArray): DataBuffer;
  39447. private _createVertexBuffer;
  39448. /**
  39449. * Creates a dynamic vertex buffer
  39450. * @param data the data for the dynamic vertex buffer
  39451. * @returns the new WebGL dynamic buffer
  39452. */
  39453. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  39454. protected _resetIndexBufferBinding(): void;
  39455. /**
  39456. * Creates a new index buffer
  39457. * @param indices defines the content of the index buffer
  39458. * @param updatable defines if the index buffer must be updatable
  39459. * @returns a new webGL buffer
  39460. */
  39461. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  39462. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  39463. /**
  39464. * Bind a webGL buffer to the webGL context
  39465. * @param buffer defines the buffer to bind
  39466. */
  39467. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  39468. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  39469. private bindBuffer;
  39470. /**
  39471. * update the bound buffer with the given data
  39472. * @param data defines the data to update
  39473. */
  39474. updateArrayBuffer(data: Float32Array): void;
  39475. private _vertexAttribPointer;
  39476. /** @hidden */
  39477. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  39478. private _bindVertexBuffersAttributes;
  39479. /**
  39480. * Records a vertex array object
  39481. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  39482. * @param vertexBuffers defines the list of vertex buffers to store
  39483. * @param indexBuffer defines the index buffer to store
  39484. * @param effect defines the effect to store
  39485. * @returns the new vertex array object
  39486. */
  39487. recordVertexArrayObject(vertexBuffers: {
  39488. [key: string]: VertexBuffer;
  39489. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  39490. /**
  39491. * Bind a specific vertex array object
  39492. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  39493. * @param vertexArrayObject defines the vertex array object to bind
  39494. * @param indexBuffer defines the index buffer to bind
  39495. */
  39496. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  39497. /**
  39498. * Bind webGl buffers directly to the webGL context
  39499. * @param vertexBuffer defines the vertex buffer to bind
  39500. * @param indexBuffer defines the index buffer to bind
  39501. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  39502. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  39503. * @param effect defines the effect associated with the vertex buffer
  39504. */
  39505. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  39506. private _unbindVertexArrayObject;
  39507. /**
  39508. * Bind a list of vertex buffers to the webGL context
  39509. * @param vertexBuffers defines the list of vertex buffers to bind
  39510. * @param indexBuffer defines the index buffer to bind
  39511. * @param effect defines the effect associated with the vertex buffers
  39512. */
  39513. bindBuffers(vertexBuffers: {
  39514. [key: string]: Nullable<VertexBuffer>;
  39515. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  39516. /**
  39517. * Unbind all instance attributes
  39518. */
  39519. unbindInstanceAttributes(): void;
  39520. /**
  39521. * Release and free the memory of a vertex array object
  39522. * @param vao defines the vertex array object to delete
  39523. */
  39524. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  39525. /** @hidden */
  39526. _releaseBuffer(buffer: DataBuffer): boolean;
  39527. protected _deleteBuffer(buffer: DataBuffer): void;
  39528. /**
  39529. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  39530. * @param instancesBuffer defines the webGL buffer to update and bind
  39531. * @param data defines the data to store in the buffer
  39532. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  39533. */
  39534. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  39535. /**
  39536. * Bind the content of a webGL buffer used with instantiation
  39537. * @param instancesBuffer defines the webGL buffer to bind
  39538. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  39539. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  39540. */
  39541. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  39542. /**
  39543. * Disable the instance attribute corresponding to the name in parameter
  39544. * @param name defines the name of the attribute to disable
  39545. */
  39546. disableInstanceAttributeByName(name: string): void;
  39547. /**
  39548. * Disable the instance attribute corresponding to the location in parameter
  39549. * @param attributeLocation defines the attribute location of the attribute to disable
  39550. */
  39551. disableInstanceAttribute(attributeLocation: number): void;
  39552. /**
  39553. * Disable the attribute corresponding to the location in parameter
  39554. * @param attributeLocation defines the attribute location of the attribute to disable
  39555. */
  39556. disableAttributeByIndex(attributeLocation: number): void;
  39557. /**
  39558. * Send a draw order
  39559. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  39560. * @param indexStart defines the starting index
  39561. * @param indexCount defines the number of index to draw
  39562. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  39563. */
  39564. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  39565. /**
  39566. * Draw a list of points
  39567. * @param verticesStart defines the index of first vertex to draw
  39568. * @param verticesCount defines the count of vertices to draw
  39569. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  39570. */
  39571. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  39572. /**
  39573. * Draw a list of unindexed primitives
  39574. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  39575. * @param verticesStart defines the index of first vertex to draw
  39576. * @param verticesCount defines the count of vertices to draw
  39577. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  39578. */
  39579. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  39580. /**
  39581. * Draw a list of indexed primitives
  39582. * @param fillMode defines the primitive to use
  39583. * @param indexStart defines the starting index
  39584. * @param indexCount defines the number of index to draw
  39585. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  39586. */
  39587. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  39588. /**
  39589. * Draw a list of unindexed primitives
  39590. * @param fillMode defines the primitive to use
  39591. * @param verticesStart defines the index of first vertex to draw
  39592. * @param verticesCount defines the count of vertices to draw
  39593. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  39594. */
  39595. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  39596. private _drawMode;
  39597. /** @hidden */
  39598. protected _reportDrawCall(): void;
  39599. /** @hidden */
  39600. _releaseEffect(effect: Effect): void;
  39601. /** @hidden */
  39602. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  39603. /**
  39604. * Create a new effect (used to store vertex/fragment shaders)
  39605. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  39606. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  39607. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  39608. * @param samplers defines an array of string used to represent textures
  39609. * @param defines defines the string containing the defines to use to compile the shaders
  39610. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  39611. * @param onCompiled defines a function to call when the effect creation is successful
  39612. * @param onError defines a function to call when the effect creation has failed
  39613. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  39614. * @returns the new Effect
  39615. */
  39616. 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;
  39617. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  39618. private _compileShader;
  39619. private _compileRawShader;
  39620. /** @hidden */
  39621. _getShaderSource(shader: WebGLShader): Nullable<string>;
  39622. /**
  39623. * Directly creates a webGL program
  39624. * @param pipelineContext defines the pipeline context to attach to
  39625. * @param vertexCode defines the vertex shader code to use
  39626. * @param fragmentCode defines the fragment shader code to use
  39627. * @param context defines the webGL context to use (if not set, the current one will be used)
  39628. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  39629. * @returns the new webGL program
  39630. */
  39631. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  39632. /**
  39633. * Creates a webGL program
  39634. * @param pipelineContext defines the pipeline context to attach to
  39635. * @param vertexCode defines the vertex shader code to use
  39636. * @param fragmentCode defines the fragment shader code to use
  39637. * @param defines defines the string containing the defines to use to compile the shaders
  39638. * @param context defines the webGL context to use (if not set, the current one will be used)
  39639. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  39640. * @returns the new webGL program
  39641. */
  39642. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  39643. /**
  39644. * Creates a new pipeline context
  39645. * @returns the new pipeline
  39646. */
  39647. createPipelineContext(): IPipelineContext;
  39648. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  39649. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  39650. /** @hidden */
  39651. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  39652. /** @hidden */
  39653. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  39654. /** @hidden */
  39655. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  39656. /**
  39657. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  39658. * @param pipelineContext defines the pipeline context to use
  39659. * @param uniformsNames defines the list of uniform names
  39660. * @returns an array of webGL uniform locations
  39661. */
  39662. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  39663. /**
  39664. * Gets the lsit of active attributes for a given webGL program
  39665. * @param pipelineContext defines the pipeline context to use
  39666. * @param attributesNames defines the list of attribute names to get
  39667. * @returns an array of indices indicating the offset of each attribute
  39668. */
  39669. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  39670. /**
  39671. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  39672. * @param effect defines the effect to activate
  39673. */
  39674. enableEffect(effect: Nullable<Effect>): void;
  39675. /**
  39676. * Set the value of an uniform to a number (int)
  39677. * @param uniform defines the webGL uniform location where to store the value
  39678. * @param value defines the int number to store
  39679. * @returns true if the value was set
  39680. */
  39681. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  39682. /**
  39683. * Set the value of an uniform to an array of int32
  39684. * @param uniform defines the webGL uniform location where to store the value
  39685. * @param array defines the array of int32 to store
  39686. * @returns true if the value was set
  39687. */
  39688. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  39689. /**
  39690. * Set the value of an uniform to an array of int32 (stored as vec2)
  39691. * @param uniform defines the webGL uniform location where to store the value
  39692. * @param array defines the array of int32 to store
  39693. * @returns true if the value was set
  39694. */
  39695. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  39696. /**
  39697. * Set the value of an uniform to an array of int32 (stored as vec3)
  39698. * @param uniform defines the webGL uniform location where to store the value
  39699. * @param array defines the array of int32 to store
  39700. * @returns true if the value was set
  39701. */
  39702. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  39703. /**
  39704. * Set the value of an uniform to an array of int32 (stored as vec4)
  39705. * @param uniform defines the webGL uniform location where to store the value
  39706. * @param array defines the array of int32 to store
  39707. * @returns true if the value was set
  39708. */
  39709. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  39710. /**
  39711. * Set the value of an uniform to an array of number
  39712. * @param uniform defines the webGL uniform location where to store the value
  39713. * @param array defines the array of number to store
  39714. * @returns true if the value was set
  39715. */
  39716. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  39717. /**
  39718. * Set the value of an uniform to an array of number (stored as vec2)
  39719. * @param uniform defines the webGL uniform location where to store the value
  39720. * @param array defines the array of number to store
  39721. * @returns true if the value was set
  39722. */
  39723. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  39724. /**
  39725. * Set the value of an uniform to an array of number (stored as vec3)
  39726. * @param uniform defines the webGL uniform location where to store the value
  39727. * @param array defines the array of number to store
  39728. * @returns true if the value was set
  39729. */
  39730. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  39731. /**
  39732. * Set the value of an uniform to an array of number (stored as vec4)
  39733. * @param uniform defines the webGL uniform location where to store the value
  39734. * @param array defines the array of number to store
  39735. * @returns true if the value was set
  39736. */
  39737. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  39738. /**
  39739. * Set the value of an uniform to an array of float32 (stored as matrices)
  39740. * @param uniform defines the webGL uniform location where to store the value
  39741. * @param matrices defines the array of float32 to store
  39742. * @returns true if the value was set
  39743. */
  39744. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): boolean;
  39745. /**
  39746. * Set the value of an uniform to a matrix (3x3)
  39747. * @param uniform defines the webGL uniform location where to store the value
  39748. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  39749. * @returns true if the value was set
  39750. */
  39751. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  39752. /**
  39753. * Set the value of an uniform to a matrix (2x2)
  39754. * @param uniform defines the webGL uniform location where to store the value
  39755. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  39756. * @returns true if the value was set
  39757. */
  39758. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  39759. /**
  39760. * Set the value of an uniform to a number (float)
  39761. * @param uniform defines the webGL uniform location where to store the value
  39762. * @param value defines the float number to store
  39763. * @returns true if the value was transfered
  39764. */
  39765. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  39766. /**
  39767. * Set the value of an uniform to a vec2
  39768. * @param uniform defines the webGL uniform location where to store the value
  39769. * @param x defines the 1st component of the value
  39770. * @param y defines the 2nd component of the value
  39771. * @returns true if the value was set
  39772. */
  39773. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): boolean;
  39774. /**
  39775. * Set the value of an uniform to a vec3
  39776. * @param uniform defines the webGL uniform location where to store the value
  39777. * @param x defines the 1st component of the value
  39778. * @param y defines the 2nd component of the value
  39779. * @param z defines the 3rd component of the value
  39780. * @returns true if the value was set
  39781. */
  39782. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): boolean;
  39783. /**
  39784. * Set the value of an uniform to a vec4
  39785. * @param uniform defines the webGL uniform location where to store the value
  39786. * @param x defines the 1st component of the value
  39787. * @param y defines the 2nd component of the value
  39788. * @param z defines the 3rd component of the value
  39789. * @param w defines the 4th component of the value
  39790. * @returns true if the value was set
  39791. */
  39792. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): boolean;
  39793. /**
  39794. * Apply all cached states (depth, culling, stencil and alpha)
  39795. */
  39796. applyStates(): void;
  39797. /**
  39798. * Enable or disable color writing
  39799. * @param enable defines the state to set
  39800. */
  39801. setColorWrite(enable: boolean): void;
  39802. /**
  39803. * Gets a boolean indicating if color writing is enabled
  39804. * @returns the current color writing state
  39805. */
  39806. getColorWrite(): boolean;
  39807. /**
  39808. * Gets the depth culling state manager
  39809. */
  39810. get depthCullingState(): DepthCullingState;
  39811. /**
  39812. * Gets the alpha state manager
  39813. */
  39814. get alphaState(): AlphaState;
  39815. /**
  39816. * Gets the stencil state manager
  39817. */
  39818. get stencilState(): StencilState;
  39819. /**
  39820. * Clears the list of texture accessible through engine.
  39821. * This can help preventing texture load conflict due to name collision.
  39822. */
  39823. clearInternalTexturesCache(): void;
  39824. /**
  39825. * Force the entire cache to be cleared
  39826. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  39827. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  39828. */
  39829. wipeCaches(bruteForce?: boolean): void;
  39830. /** @hidden */
  39831. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  39832. min: number;
  39833. mag: number;
  39834. };
  39835. /** @hidden */
  39836. _createTexture(): WebGLTexture;
  39837. /**
  39838. * Usually called from Texture.ts.
  39839. * Passed information to create a WebGLTexture
  39840. * @param url defines a value which contains one of the following:
  39841. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  39842. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  39843. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  39844. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  39845. * @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)
  39846. * @param scene needed for loading to the correct scene
  39847. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  39848. * @param onLoad optional callback to be called upon successful completion
  39849. * @param onError optional callback to be called upon failure
  39850. * @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
  39851. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  39852. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  39853. * @param forcedExtension defines the extension to use to pick the right loader
  39854. * @param mimeType defines an optional mime type
  39855. * @param loaderOptions options to be passed to the loader
  39856. * @returns a InternalTexture for assignment back into BABYLON.Texture
  39857. */
  39858. 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;
  39859. /**
  39860. * Loads an image as an HTMLImageElement.
  39861. * @param input url string, ArrayBuffer, or Blob to load
  39862. * @param onLoad callback called when the image successfully loads
  39863. * @param onError callback called when the image fails to load
  39864. * @param offlineProvider offline provider for caching
  39865. * @param mimeType optional mime type
  39866. * @returns the HTMLImageElement of the loaded image
  39867. * @hidden
  39868. */
  39869. 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>;
  39870. /**
  39871. * @hidden
  39872. */
  39873. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  39874. private _unpackFlipYCached;
  39875. /**
  39876. * In case you are sharing the context with other applications, it might
  39877. * be interested to not cache the unpack flip y state to ensure a consistent
  39878. * value would be set.
  39879. */
  39880. enableUnpackFlipYCached: boolean;
  39881. /** @hidden */
  39882. _unpackFlipY(value: boolean): void;
  39883. /** @hidden */
  39884. _getUnpackAlignement(): number;
  39885. private _getTextureTarget;
  39886. /**
  39887. * Update the sampling mode of a given texture
  39888. * @param samplingMode defines the required sampling mode
  39889. * @param texture defines the texture to update
  39890. * @param generateMipMaps defines whether to generate mipmaps for the texture
  39891. */
  39892. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  39893. /**
  39894. * Update the sampling mode of a given texture
  39895. * @param texture defines the texture to update
  39896. * @param wrapU defines the texture wrap mode of the u coordinates
  39897. * @param wrapV defines the texture wrap mode of the v coordinates
  39898. * @param wrapR defines the texture wrap mode of the r coordinates
  39899. */
  39900. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  39901. /** @hidden */
  39902. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  39903. width: number;
  39904. height: number;
  39905. layers?: number;
  39906. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  39907. /** @hidden */
  39908. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  39909. /** @hidden */
  39910. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  39911. /**
  39912. * Update a portion of an internal texture
  39913. * @param texture defines the texture to update
  39914. * @param imageData defines the data to store into the texture
  39915. * @param xOffset defines the x coordinates of the update rectangle
  39916. * @param yOffset defines the y coordinates of the update rectangle
  39917. * @param width defines the width of the update rectangle
  39918. * @param height defines the height of the update rectangle
  39919. * @param faceIndex defines the face index if texture is a cube (0 by default)
  39920. * @param lod defines the lod level to update (0 by default)
  39921. */
  39922. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  39923. /** @hidden */
  39924. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  39925. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  39926. private _prepareWebGLTexture;
  39927. /** @hidden */
  39928. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  39929. private _getDepthStencilBuffer;
  39930. /** @hidden */
  39931. _releaseFramebufferObjects(texture: InternalTexture): void;
  39932. /** @hidden */
  39933. _releaseTexture(texture: InternalTexture): void;
  39934. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  39935. protected _setProgram(program: WebGLProgram): void;
  39936. protected _boundUniforms: {
  39937. [key: number]: WebGLUniformLocation;
  39938. };
  39939. /**
  39940. * Binds an effect to the webGL context
  39941. * @param effect defines the effect to bind
  39942. */
  39943. bindSamplers(effect: Effect): void;
  39944. private _activateCurrentTexture;
  39945. /** @hidden */
  39946. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  39947. /** @hidden */
  39948. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  39949. /**
  39950. * Unbind all textures from the webGL context
  39951. */
  39952. unbindAllTextures(): void;
  39953. /**
  39954. * Sets a texture to the according uniform.
  39955. * @param channel The texture channel
  39956. * @param uniform The uniform to set
  39957. * @param texture The texture to apply
  39958. */
  39959. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<ThinTexture>): void;
  39960. private _bindSamplerUniformToChannel;
  39961. private _getTextureWrapMode;
  39962. protected _setTexture(channel: number, texture: Nullable<ThinTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  39963. /**
  39964. * Sets an array of texture to the webGL context
  39965. * @param channel defines the channel where the texture array must be set
  39966. * @param uniform defines the associated uniform location
  39967. * @param textures defines the array of textures to bind
  39968. */
  39969. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: ThinTexture[]): void;
  39970. /** @hidden */
  39971. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  39972. private _setTextureParameterFloat;
  39973. private _setTextureParameterInteger;
  39974. /**
  39975. * Unbind all vertex attributes from the webGL context
  39976. */
  39977. unbindAllAttributes(): void;
  39978. /**
  39979. * 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
  39980. */
  39981. releaseEffects(): void;
  39982. /**
  39983. * Dispose and release all associated resources
  39984. */
  39985. dispose(): void;
  39986. /**
  39987. * Attach a new callback raised when context lost event is fired
  39988. * @param callback defines the callback to call
  39989. */
  39990. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  39991. /**
  39992. * Attach a new callback raised when context restored event is fired
  39993. * @param callback defines the callback to call
  39994. */
  39995. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  39996. /**
  39997. * Get the current error code of the webGL context
  39998. * @returns the error code
  39999. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  40000. */
  40001. getError(): number;
  40002. private _canRenderToFloatFramebuffer;
  40003. private _canRenderToHalfFloatFramebuffer;
  40004. private _canRenderToFramebuffer;
  40005. /** @hidden */
  40006. _getWebGLTextureType(type: number): number;
  40007. /** @hidden */
  40008. _getInternalFormat(format: number): number;
  40009. /** @hidden */
  40010. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  40011. /** @hidden */
  40012. _getRGBAMultiSampleBufferFormat(type: number): number;
  40013. /** @hidden */
  40014. _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;
  40015. /**
  40016. * Loads a file from a url
  40017. * @param url url to load
  40018. * @param onSuccess callback called when the file successfully loads
  40019. * @param onProgress callback called while file is loading (if the server supports this mode)
  40020. * @param offlineProvider defines the offline provider for caching
  40021. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  40022. * @param onError callback called when the file fails to load
  40023. * @returns a file request object
  40024. * @hidden
  40025. */
  40026. 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;
  40027. /**
  40028. * Reads pixels from the current frame buffer. Please note that this function can be slow
  40029. * @param x defines the x coordinate of the rectangle where pixels must be read
  40030. * @param y defines the y coordinate of the rectangle where pixels must be read
  40031. * @param width defines the width of the rectangle where pixels must be read
  40032. * @param height defines the height of the rectangle where pixels must be read
  40033. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  40034. * @returns a Uint8Array containing RGBA colors
  40035. */
  40036. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  40037. private static _IsSupported;
  40038. private static _HasMajorPerformanceCaveat;
  40039. /**
  40040. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  40041. */
  40042. static get IsSupported(): boolean;
  40043. /**
  40044. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  40045. * @returns true if the engine can be created
  40046. * @ignorenaming
  40047. */
  40048. static isSupported(): boolean;
  40049. /**
  40050. * 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)
  40051. */
  40052. static get HasMajorPerformanceCaveat(): boolean;
  40053. /**
  40054. * Find the next highest power of two.
  40055. * @param x Number to start search from.
  40056. * @return Next highest power of two.
  40057. */
  40058. static CeilingPOT(x: number): number;
  40059. /**
  40060. * Find the next lowest power of two.
  40061. * @param x Number to start search from.
  40062. * @return Next lowest power of two.
  40063. */
  40064. static FloorPOT(x: number): number;
  40065. /**
  40066. * Find the nearest power of two.
  40067. * @param x Number to start search from.
  40068. * @return Next nearest power of two.
  40069. */
  40070. static NearestPOT(x: number): number;
  40071. /**
  40072. * Get the closest exponent of two
  40073. * @param value defines the value to approximate
  40074. * @param max defines the maximum value to return
  40075. * @param mode defines how to define the closest value
  40076. * @returns closest exponent of two of the given value
  40077. */
  40078. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  40079. /**
  40080. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  40081. * @param func - the function to be called
  40082. * @param requester - the object that will request the next frame. Falls back to window.
  40083. * @returns frame number
  40084. */
  40085. static QueueNewFrame(func: () => void, requester?: any): number;
  40086. /**
  40087. * Gets host document
  40088. * @returns the host document object
  40089. */
  40090. getHostDocument(): Nullable<Document>;
  40091. }
  40092. }
  40093. declare module BABYLON {
  40094. /**
  40095. * Defines the source of the internal texture
  40096. */
  40097. export enum InternalTextureSource {
  40098. /**
  40099. * The source of the texture data is unknown
  40100. */
  40101. Unknown = 0,
  40102. /**
  40103. * Texture data comes from an URL
  40104. */
  40105. Url = 1,
  40106. /**
  40107. * Texture data is only used for temporary storage
  40108. */
  40109. Temp = 2,
  40110. /**
  40111. * Texture data comes from raw data (ArrayBuffer)
  40112. */
  40113. Raw = 3,
  40114. /**
  40115. * Texture content is dynamic (video or dynamic texture)
  40116. */
  40117. Dynamic = 4,
  40118. /**
  40119. * Texture content is generated by rendering to it
  40120. */
  40121. RenderTarget = 5,
  40122. /**
  40123. * Texture content is part of a multi render target process
  40124. */
  40125. MultiRenderTarget = 6,
  40126. /**
  40127. * Texture data comes from a cube data file
  40128. */
  40129. Cube = 7,
  40130. /**
  40131. * Texture data comes from a raw cube data
  40132. */
  40133. CubeRaw = 8,
  40134. /**
  40135. * Texture data come from a prefiltered cube data file
  40136. */
  40137. CubePrefiltered = 9,
  40138. /**
  40139. * Texture content is raw 3D data
  40140. */
  40141. Raw3D = 10,
  40142. /**
  40143. * Texture content is raw 2D array data
  40144. */
  40145. Raw2DArray = 11,
  40146. /**
  40147. * Texture content is a depth texture
  40148. */
  40149. Depth = 12,
  40150. /**
  40151. * Texture data comes from a raw cube data encoded with RGBD
  40152. */
  40153. CubeRawRGBD = 13
  40154. }
  40155. /**
  40156. * Class used to store data associated with WebGL texture data for the engine
  40157. * This class should not be used directly
  40158. */
  40159. export class InternalTexture {
  40160. /** @hidden */
  40161. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  40162. /**
  40163. * Defines if the texture is ready
  40164. */
  40165. isReady: boolean;
  40166. /**
  40167. * Defines if the texture is a cube texture
  40168. */
  40169. isCube: boolean;
  40170. /**
  40171. * Defines if the texture contains 3D data
  40172. */
  40173. is3D: boolean;
  40174. /**
  40175. * Defines if the texture contains 2D array data
  40176. */
  40177. is2DArray: boolean;
  40178. /**
  40179. * Defines if the texture contains multiview data
  40180. */
  40181. isMultiview: boolean;
  40182. /**
  40183. * Gets the URL used to load this texture
  40184. */
  40185. url: string;
  40186. /** @hidden */
  40187. _originalUrl: string;
  40188. /**
  40189. * Gets the sampling mode of the texture
  40190. */
  40191. samplingMode: number;
  40192. /**
  40193. * Gets a boolean indicating if the texture needs mipmaps generation
  40194. */
  40195. generateMipMaps: boolean;
  40196. /**
  40197. * Gets the number of samples used by the texture (WebGL2+ only)
  40198. */
  40199. samples: number;
  40200. /**
  40201. * Gets the type of the texture (int, float...)
  40202. */
  40203. type: number;
  40204. /**
  40205. * Gets the format of the texture (RGB, RGBA...)
  40206. */
  40207. format: number;
  40208. /**
  40209. * Observable called when the texture is loaded
  40210. */
  40211. onLoadedObservable: Observable<InternalTexture>;
  40212. /**
  40213. * Gets the width of the texture
  40214. */
  40215. width: number;
  40216. /**
  40217. * Gets the height of the texture
  40218. */
  40219. height: number;
  40220. /**
  40221. * Gets the depth of the texture
  40222. */
  40223. depth: number;
  40224. /**
  40225. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  40226. */
  40227. baseWidth: number;
  40228. /**
  40229. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  40230. */
  40231. baseHeight: number;
  40232. /**
  40233. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  40234. */
  40235. baseDepth: number;
  40236. /**
  40237. * Gets a boolean indicating if the texture is inverted on Y axis
  40238. */
  40239. invertY: boolean;
  40240. /** @hidden */
  40241. _invertVScale: boolean;
  40242. /** @hidden */
  40243. _associatedChannel: number;
  40244. /** @hidden */
  40245. _source: InternalTextureSource;
  40246. /** @hidden */
  40247. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  40248. /** @hidden */
  40249. _bufferView: Nullable<ArrayBufferView>;
  40250. /** @hidden */
  40251. _bufferViewArray: Nullable<ArrayBufferView[]>;
  40252. /** @hidden */
  40253. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  40254. /** @hidden */
  40255. _size: number;
  40256. /** @hidden */
  40257. _extension: string;
  40258. /** @hidden */
  40259. _files: Nullable<string[]>;
  40260. /** @hidden */
  40261. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  40262. /** @hidden */
  40263. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  40264. /** @hidden */
  40265. _framebuffer: Nullable<WebGLFramebuffer>;
  40266. /** @hidden */
  40267. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  40268. /** @hidden */
  40269. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  40270. /** @hidden */
  40271. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  40272. /** @hidden */
  40273. _attachments: Nullable<number[]>;
  40274. /** @hidden */
  40275. _textureArray: Nullable<InternalTexture[]>;
  40276. /** @hidden */
  40277. _cachedCoordinatesMode: Nullable<number>;
  40278. /** @hidden */
  40279. _cachedWrapU: Nullable<number>;
  40280. /** @hidden */
  40281. _cachedWrapV: Nullable<number>;
  40282. /** @hidden */
  40283. _cachedWrapR: Nullable<number>;
  40284. /** @hidden */
  40285. _cachedAnisotropicFilteringLevel: Nullable<number>;
  40286. /** @hidden */
  40287. _isDisabled: boolean;
  40288. /** @hidden */
  40289. _compression: Nullable<string>;
  40290. /** @hidden */
  40291. _generateStencilBuffer: boolean;
  40292. /** @hidden */
  40293. _generateDepthBuffer: boolean;
  40294. /** @hidden */
  40295. _comparisonFunction: number;
  40296. /** @hidden */
  40297. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  40298. /** @hidden */
  40299. _lodGenerationScale: number;
  40300. /** @hidden */
  40301. _lodGenerationOffset: number;
  40302. /** @hidden */
  40303. _depthStencilTexture: Nullable<InternalTexture>;
  40304. /** @hidden */
  40305. _colorTextureArray: Nullable<WebGLTexture>;
  40306. /** @hidden */
  40307. _depthStencilTextureArray: Nullable<WebGLTexture>;
  40308. /** @hidden */
  40309. _lodTextureHigh: Nullable<BaseTexture>;
  40310. /** @hidden */
  40311. _lodTextureMid: Nullable<BaseTexture>;
  40312. /** @hidden */
  40313. _lodTextureLow: Nullable<BaseTexture>;
  40314. /** @hidden */
  40315. _isRGBD: boolean;
  40316. /** @hidden */
  40317. _linearSpecularLOD: boolean;
  40318. /** @hidden */
  40319. _irradianceTexture: Nullable<BaseTexture>;
  40320. /** @hidden */
  40321. _webGLTexture: Nullable<WebGLTexture>;
  40322. /** @hidden */
  40323. _references: number;
  40324. /** @hidden */
  40325. _gammaSpace: Nullable<boolean>;
  40326. private _engine;
  40327. /**
  40328. * Gets the Engine the texture belongs to.
  40329. * @returns The babylon engine
  40330. */
  40331. getEngine(): ThinEngine;
  40332. /**
  40333. * Gets the data source type of the texture
  40334. */
  40335. get source(): InternalTextureSource;
  40336. /**
  40337. * Creates a new InternalTexture
  40338. * @param engine defines the engine to use
  40339. * @param source defines the type of data that will be used
  40340. * @param delayAllocation if the texture allocation should be delayed (default: false)
  40341. */
  40342. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  40343. /**
  40344. * Increments the number of references (ie. the number of Texture that point to it)
  40345. */
  40346. incrementReferences(): void;
  40347. /**
  40348. * Change the size of the texture (not the size of the content)
  40349. * @param width defines the new width
  40350. * @param height defines the new height
  40351. * @param depth defines the new depth (1 by default)
  40352. */
  40353. updateSize(width: int, height: int, depth?: int): void;
  40354. /** @hidden */
  40355. _rebuild(): void;
  40356. /** @hidden */
  40357. _swapAndDie(target: InternalTexture): void;
  40358. /**
  40359. * Dispose the current allocated resources
  40360. */
  40361. dispose(): void;
  40362. }
  40363. }
  40364. declare module BABYLON {
  40365. /**
  40366. * Interface used to present a loading screen while loading a scene
  40367. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  40368. */
  40369. export interface ILoadingScreen {
  40370. /**
  40371. * Function called to display the loading screen
  40372. */
  40373. displayLoadingUI: () => void;
  40374. /**
  40375. * Function called to hide the loading screen
  40376. */
  40377. hideLoadingUI: () => void;
  40378. /**
  40379. * Gets or sets the color to use for the background
  40380. */
  40381. loadingUIBackgroundColor: string;
  40382. /**
  40383. * Gets or sets the text to display while loading
  40384. */
  40385. loadingUIText: string;
  40386. }
  40387. /**
  40388. * Class used for the default loading screen
  40389. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  40390. */
  40391. export class DefaultLoadingScreen implements ILoadingScreen {
  40392. private _renderingCanvas;
  40393. private _loadingText;
  40394. private _loadingDivBackgroundColor;
  40395. private _loadingDiv;
  40396. private _loadingTextDiv;
  40397. /** Gets or sets the logo url to use for the default loading screen */
  40398. static DefaultLogoUrl: string;
  40399. /** Gets or sets the spinner url to use for the default loading screen */
  40400. static DefaultSpinnerUrl: string;
  40401. /**
  40402. * Creates a new default loading screen
  40403. * @param _renderingCanvas defines the canvas used to render the scene
  40404. * @param _loadingText defines the default text to display
  40405. * @param _loadingDivBackgroundColor defines the default background color
  40406. */
  40407. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  40408. /**
  40409. * Function called to display the loading screen
  40410. */
  40411. displayLoadingUI(): void;
  40412. /**
  40413. * Function called to hide the loading screen
  40414. */
  40415. hideLoadingUI(): void;
  40416. /**
  40417. * Gets or sets the text to display while loading
  40418. */
  40419. set loadingUIText(text: string);
  40420. get loadingUIText(): string;
  40421. /**
  40422. * Gets or sets the color to use for the background
  40423. */
  40424. get loadingUIBackgroundColor(): string;
  40425. set loadingUIBackgroundColor(color: string);
  40426. private _resizeLoadingUI;
  40427. }
  40428. }
  40429. declare module BABYLON {
  40430. /**
  40431. * Interface for any object that can request an animation frame
  40432. */
  40433. export interface ICustomAnimationFrameRequester {
  40434. /**
  40435. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  40436. */
  40437. renderFunction?: Function;
  40438. /**
  40439. * Called to request the next frame to render to
  40440. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  40441. */
  40442. requestAnimationFrame: Function;
  40443. /**
  40444. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  40445. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  40446. */
  40447. requestID?: number;
  40448. }
  40449. }
  40450. declare module BABYLON {
  40451. /**
  40452. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  40453. */
  40454. export class PerformanceMonitor {
  40455. private _enabled;
  40456. private _rollingFrameTime;
  40457. private _lastFrameTimeMs;
  40458. /**
  40459. * constructor
  40460. * @param frameSampleSize The number of samples required to saturate the sliding window
  40461. */
  40462. constructor(frameSampleSize?: number);
  40463. /**
  40464. * Samples current frame
  40465. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  40466. */
  40467. sampleFrame(timeMs?: number): void;
  40468. /**
  40469. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  40470. */
  40471. get averageFrameTime(): number;
  40472. /**
  40473. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  40474. */
  40475. get averageFrameTimeVariance(): number;
  40476. /**
  40477. * Returns the frame time of the most recent frame
  40478. */
  40479. get instantaneousFrameTime(): number;
  40480. /**
  40481. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  40482. */
  40483. get averageFPS(): number;
  40484. /**
  40485. * Returns the average framerate in frames per second using the most recent frame time
  40486. */
  40487. get instantaneousFPS(): number;
  40488. /**
  40489. * Returns true if enough samples have been taken to completely fill the sliding window
  40490. */
  40491. get isSaturated(): boolean;
  40492. /**
  40493. * Enables contributions to the sliding window sample set
  40494. */
  40495. enable(): void;
  40496. /**
  40497. * Disables contributions to the sliding window sample set
  40498. * Samples will not be interpolated over the disabled period
  40499. */
  40500. disable(): void;
  40501. /**
  40502. * Returns true if sampling is enabled
  40503. */
  40504. get isEnabled(): boolean;
  40505. /**
  40506. * Resets performance monitor
  40507. */
  40508. reset(): void;
  40509. }
  40510. /**
  40511. * RollingAverage
  40512. *
  40513. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  40514. */
  40515. export class RollingAverage {
  40516. /**
  40517. * Current average
  40518. */
  40519. average: number;
  40520. /**
  40521. * Current variance
  40522. */
  40523. variance: number;
  40524. protected _samples: Array<number>;
  40525. protected _sampleCount: number;
  40526. protected _pos: number;
  40527. protected _m2: number;
  40528. /**
  40529. * constructor
  40530. * @param length The number of samples required to saturate the sliding window
  40531. */
  40532. constructor(length: number);
  40533. /**
  40534. * Adds a sample to the sample set
  40535. * @param v The sample value
  40536. */
  40537. add(v: number): void;
  40538. /**
  40539. * Returns previously added values or null if outside of history or outside the sliding window domain
  40540. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  40541. * @return Value previously recorded with add() or null if outside of range
  40542. */
  40543. history(i: number): number;
  40544. /**
  40545. * Returns true if enough samples have been taken to completely fill the sliding window
  40546. * @return true if sample-set saturated
  40547. */
  40548. isSaturated(): boolean;
  40549. /**
  40550. * Resets the rolling average (equivalent to 0 samples taken so far)
  40551. */
  40552. reset(): void;
  40553. /**
  40554. * Wraps a value around the sample range boundaries
  40555. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  40556. * @return Wrapped position in sample range
  40557. */
  40558. protected _wrapPosition(i: number): number;
  40559. }
  40560. }
  40561. declare module BABYLON {
  40562. /**
  40563. * This class is used to track a performance counter which is number based.
  40564. * The user has access to many properties which give statistics of different nature.
  40565. *
  40566. * The implementer can track two kinds of Performance Counter: time and count.
  40567. * 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.
  40568. * 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.
  40569. */
  40570. export class PerfCounter {
  40571. /**
  40572. * Gets or sets a global boolean to turn on and off all the counters
  40573. */
  40574. static Enabled: boolean;
  40575. /**
  40576. * Returns the smallest value ever
  40577. */
  40578. get min(): number;
  40579. /**
  40580. * Returns the biggest value ever
  40581. */
  40582. get max(): number;
  40583. /**
  40584. * Returns the average value since the performance counter is running
  40585. */
  40586. get average(): number;
  40587. /**
  40588. * Returns the average value of the last second the counter was monitored
  40589. */
  40590. get lastSecAverage(): number;
  40591. /**
  40592. * Returns the current value
  40593. */
  40594. get current(): number;
  40595. /**
  40596. * Gets the accumulated total
  40597. */
  40598. get total(): number;
  40599. /**
  40600. * Gets the total value count
  40601. */
  40602. get count(): number;
  40603. /**
  40604. * Creates a new counter
  40605. */
  40606. constructor();
  40607. /**
  40608. * Call this method to start monitoring a new frame.
  40609. * 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.
  40610. */
  40611. fetchNewFrame(): void;
  40612. /**
  40613. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  40614. * @param newCount the count value to add to the monitored count
  40615. * @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.
  40616. */
  40617. addCount(newCount: number, fetchResult: boolean): void;
  40618. /**
  40619. * Start monitoring this performance counter
  40620. */
  40621. beginMonitoring(): void;
  40622. /**
  40623. * Compute the time lapsed since the previous beginMonitoring() call.
  40624. * @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
  40625. */
  40626. endMonitoring(newFrame?: boolean): void;
  40627. private _fetchResult;
  40628. private _startMonitoringTime;
  40629. private _min;
  40630. private _max;
  40631. private _average;
  40632. private _current;
  40633. private _totalValueCount;
  40634. private _totalAccumulated;
  40635. private _lastSecAverage;
  40636. private _lastSecAccumulated;
  40637. private _lastSecTime;
  40638. private _lastSecValueCount;
  40639. }
  40640. }
  40641. declare module BABYLON {
  40642. interface ThinEngine {
  40643. /** @hidden */
  40644. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  40645. }
  40646. }
  40647. declare module BABYLON {
  40648. /**
  40649. * Class used to work with sound analyzer using fast fourier transform (FFT)
  40650. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  40651. */
  40652. export class Analyser {
  40653. /**
  40654. * Gets or sets the smoothing
  40655. * @ignorenaming
  40656. */
  40657. SMOOTHING: number;
  40658. /**
  40659. * Gets or sets the FFT table size
  40660. * @ignorenaming
  40661. */
  40662. FFT_SIZE: number;
  40663. /**
  40664. * Gets or sets the bar graph amplitude
  40665. * @ignorenaming
  40666. */
  40667. BARGRAPHAMPLITUDE: number;
  40668. /**
  40669. * Gets or sets the position of the debug canvas
  40670. * @ignorenaming
  40671. */
  40672. DEBUGCANVASPOS: {
  40673. x: number;
  40674. y: number;
  40675. };
  40676. /**
  40677. * Gets or sets the debug canvas size
  40678. * @ignorenaming
  40679. */
  40680. DEBUGCANVASSIZE: {
  40681. width: number;
  40682. height: number;
  40683. };
  40684. private _byteFreqs;
  40685. private _byteTime;
  40686. private _floatFreqs;
  40687. private _webAudioAnalyser;
  40688. private _debugCanvas;
  40689. private _debugCanvasContext;
  40690. private _scene;
  40691. private _registerFunc;
  40692. private _audioEngine;
  40693. /**
  40694. * Creates a new analyser
  40695. * @param scene defines hosting scene
  40696. */
  40697. constructor(scene: Scene);
  40698. /**
  40699. * Get the number of data values you will have to play with for the visualization
  40700. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  40701. * @returns a number
  40702. */
  40703. getFrequencyBinCount(): number;
  40704. /**
  40705. * Gets the current frequency data as a byte array
  40706. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  40707. * @returns a Uint8Array
  40708. */
  40709. getByteFrequencyData(): Uint8Array;
  40710. /**
  40711. * Gets the current waveform as a byte array
  40712. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  40713. * @returns a Uint8Array
  40714. */
  40715. getByteTimeDomainData(): Uint8Array;
  40716. /**
  40717. * Gets the current frequency data as a float array
  40718. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  40719. * @returns a Float32Array
  40720. */
  40721. getFloatFrequencyData(): Float32Array;
  40722. /**
  40723. * Renders the debug canvas
  40724. */
  40725. drawDebugCanvas(): void;
  40726. /**
  40727. * Stops rendering the debug canvas and removes it
  40728. */
  40729. stopDebugCanvas(): void;
  40730. /**
  40731. * Connects two audio nodes
  40732. * @param inputAudioNode defines first node to connect
  40733. * @param outputAudioNode defines second node to connect
  40734. */
  40735. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  40736. /**
  40737. * Releases all associated resources
  40738. */
  40739. dispose(): void;
  40740. }
  40741. }
  40742. declare module BABYLON {
  40743. /**
  40744. * This represents an audio engine and it is responsible
  40745. * to play, synchronize and analyse sounds throughout the application.
  40746. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  40747. */
  40748. export interface IAudioEngine extends IDisposable {
  40749. /**
  40750. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  40751. */
  40752. readonly canUseWebAudio: boolean;
  40753. /**
  40754. * Gets the current AudioContext if available.
  40755. */
  40756. readonly audioContext: Nullable<AudioContext>;
  40757. /**
  40758. * The master gain node defines the global audio volume of your audio engine.
  40759. */
  40760. readonly masterGain: GainNode;
  40761. /**
  40762. * Gets whether or not mp3 are supported by your browser.
  40763. */
  40764. readonly isMP3supported: boolean;
  40765. /**
  40766. * Gets whether or not ogg are supported by your browser.
  40767. */
  40768. readonly isOGGsupported: boolean;
  40769. /**
  40770. * Defines if Babylon should emit a warning if WebAudio is not supported.
  40771. * @ignoreNaming
  40772. */
  40773. WarnedWebAudioUnsupported: boolean;
  40774. /**
  40775. * Defines if the audio engine relies on a custom unlocked button.
  40776. * In this case, the embedded button will not be displayed.
  40777. */
  40778. useCustomUnlockedButton: boolean;
  40779. /**
  40780. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  40781. */
  40782. readonly unlocked: boolean;
  40783. /**
  40784. * Event raised when audio has been unlocked on the browser.
  40785. */
  40786. onAudioUnlockedObservable: Observable<IAudioEngine>;
  40787. /**
  40788. * Event raised when audio has been locked on the browser.
  40789. */
  40790. onAudioLockedObservable: Observable<IAudioEngine>;
  40791. /**
  40792. * Flags the audio engine in Locked state.
  40793. * This happens due to new browser policies preventing audio to autoplay.
  40794. */
  40795. lock(): void;
  40796. /**
  40797. * Unlocks the audio engine once a user action has been done on the dom.
  40798. * This is helpful to resume play once browser policies have been satisfied.
  40799. */
  40800. unlock(): void;
  40801. /**
  40802. * Gets the global volume sets on the master gain.
  40803. * @returns the global volume if set or -1 otherwise
  40804. */
  40805. getGlobalVolume(): number;
  40806. /**
  40807. * Sets the global volume of your experience (sets on the master gain).
  40808. * @param newVolume Defines the new global volume of the application
  40809. */
  40810. setGlobalVolume(newVolume: number): void;
  40811. /**
  40812. * Connect the audio engine to an audio analyser allowing some amazing
  40813. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  40814. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  40815. * @param analyser The analyser to connect to the engine
  40816. */
  40817. connectToAnalyser(analyser: Analyser): void;
  40818. }
  40819. }
  40820. declare module BABYLON {
  40821. /**
  40822. * Defines the interface used by display changed events
  40823. */
  40824. export interface IDisplayChangedEventArgs {
  40825. /** Gets the vrDisplay object (if any) */
  40826. vrDisplay: Nullable<any>;
  40827. /** Gets a boolean indicating if webVR is supported */
  40828. vrSupported: boolean;
  40829. }
  40830. /**
  40831. * Defines the interface used by objects containing a viewport (like a camera)
  40832. */
  40833. interface IViewportOwnerLike {
  40834. /**
  40835. * Gets or sets the viewport
  40836. */
  40837. viewport: IViewportLike;
  40838. }
  40839. /**
  40840. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  40841. */
  40842. export class Engine extends ThinEngine {
  40843. /** Defines that alpha blending is disabled */
  40844. static readonly ALPHA_DISABLE: number;
  40845. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  40846. static readonly ALPHA_ADD: number;
  40847. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  40848. static readonly ALPHA_COMBINE: number;
  40849. /** Defines that alpha blending to DEST - SRC * DEST */
  40850. static readonly ALPHA_SUBTRACT: number;
  40851. /** Defines that alpha blending to SRC * DEST */
  40852. static readonly ALPHA_MULTIPLY: number;
  40853. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  40854. static readonly ALPHA_MAXIMIZED: number;
  40855. /** Defines that alpha blending to SRC + DEST */
  40856. static readonly ALPHA_ONEONE: number;
  40857. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  40858. static readonly ALPHA_PREMULTIPLIED: number;
  40859. /**
  40860. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  40861. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  40862. */
  40863. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  40864. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  40865. static readonly ALPHA_INTERPOLATE: number;
  40866. /**
  40867. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  40868. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  40869. */
  40870. static readonly ALPHA_SCREENMODE: number;
  40871. /** Defines that the ressource is not delayed*/
  40872. static readonly DELAYLOADSTATE_NONE: number;
  40873. /** Defines that the ressource was successfully delay loaded */
  40874. static readonly DELAYLOADSTATE_LOADED: number;
  40875. /** Defines that the ressource is currently delay loading */
  40876. static readonly DELAYLOADSTATE_LOADING: number;
  40877. /** Defines that the ressource is delayed and has not started loading */
  40878. static readonly DELAYLOADSTATE_NOTLOADED: number;
  40879. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  40880. static readonly NEVER: number;
  40881. /** 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 */
  40882. static readonly ALWAYS: number;
  40883. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  40884. static readonly LESS: number;
  40885. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  40886. static readonly EQUAL: number;
  40887. /** 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 */
  40888. static readonly LEQUAL: number;
  40889. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  40890. static readonly GREATER: number;
  40891. /** 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 */
  40892. static readonly GEQUAL: number;
  40893. /** 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 */
  40894. static readonly NOTEQUAL: number;
  40895. /** Passed to stencilOperation to specify that stencil value must be kept */
  40896. static readonly KEEP: number;
  40897. /** Passed to stencilOperation to specify that stencil value must be replaced */
  40898. static readonly REPLACE: number;
  40899. /** Passed to stencilOperation to specify that stencil value must be incremented */
  40900. static readonly INCR: number;
  40901. /** Passed to stencilOperation to specify that stencil value must be decremented */
  40902. static readonly DECR: number;
  40903. /** Passed to stencilOperation to specify that stencil value must be inverted */
  40904. static readonly INVERT: number;
  40905. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  40906. static readonly INCR_WRAP: number;
  40907. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  40908. static readonly DECR_WRAP: number;
  40909. /** Texture is not repeating outside of 0..1 UVs */
  40910. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  40911. /** Texture is repeating outside of 0..1 UVs */
  40912. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  40913. /** Texture is repeating and mirrored */
  40914. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  40915. /** ALPHA */
  40916. static readonly TEXTUREFORMAT_ALPHA: number;
  40917. /** LUMINANCE */
  40918. static readonly TEXTUREFORMAT_LUMINANCE: number;
  40919. /** LUMINANCE_ALPHA */
  40920. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  40921. /** RGB */
  40922. static readonly TEXTUREFORMAT_RGB: number;
  40923. /** RGBA */
  40924. static readonly TEXTUREFORMAT_RGBA: number;
  40925. /** RED */
  40926. static readonly TEXTUREFORMAT_RED: number;
  40927. /** RED (2nd reference) */
  40928. static readonly TEXTUREFORMAT_R: number;
  40929. /** RG */
  40930. static readonly TEXTUREFORMAT_RG: number;
  40931. /** RED_INTEGER */
  40932. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  40933. /** RED_INTEGER (2nd reference) */
  40934. static readonly TEXTUREFORMAT_R_INTEGER: number;
  40935. /** RG_INTEGER */
  40936. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  40937. /** RGB_INTEGER */
  40938. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  40939. /** RGBA_INTEGER */
  40940. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  40941. /** UNSIGNED_BYTE */
  40942. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  40943. /** UNSIGNED_BYTE (2nd reference) */
  40944. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  40945. /** FLOAT */
  40946. static readonly TEXTURETYPE_FLOAT: number;
  40947. /** HALF_FLOAT */
  40948. static readonly TEXTURETYPE_HALF_FLOAT: number;
  40949. /** BYTE */
  40950. static readonly TEXTURETYPE_BYTE: number;
  40951. /** SHORT */
  40952. static readonly TEXTURETYPE_SHORT: number;
  40953. /** UNSIGNED_SHORT */
  40954. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  40955. /** INT */
  40956. static readonly TEXTURETYPE_INT: number;
  40957. /** UNSIGNED_INT */
  40958. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  40959. /** UNSIGNED_SHORT_4_4_4_4 */
  40960. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  40961. /** UNSIGNED_SHORT_5_5_5_1 */
  40962. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  40963. /** UNSIGNED_SHORT_5_6_5 */
  40964. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  40965. /** UNSIGNED_INT_2_10_10_10_REV */
  40966. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  40967. /** UNSIGNED_INT_24_8 */
  40968. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  40969. /** UNSIGNED_INT_10F_11F_11F_REV */
  40970. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  40971. /** UNSIGNED_INT_5_9_9_9_REV */
  40972. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  40973. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  40974. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  40975. /** nearest is mag = nearest and min = nearest and mip = linear */
  40976. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  40977. /** Bilinear is mag = linear and min = linear and mip = nearest */
  40978. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  40979. /** Trilinear is mag = linear and min = linear and mip = linear */
  40980. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  40981. /** nearest is mag = nearest and min = nearest and mip = linear */
  40982. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  40983. /** Bilinear is mag = linear and min = linear and mip = nearest */
  40984. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  40985. /** Trilinear is mag = linear and min = linear and mip = linear */
  40986. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  40987. /** mag = nearest and min = nearest and mip = nearest */
  40988. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  40989. /** mag = nearest and min = linear and mip = nearest */
  40990. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  40991. /** mag = nearest and min = linear and mip = linear */
  40992. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  40993. /** mag = nearest and min = linear and mip = none */
  40994. static readonly TEXTURE_NEAREST_LINEAR: number;
  40995. /** mag = nearest and min = nearest and mip = none */
  40996. static readonly TEXTURE_NEAREST_NEAREST: number;
  40997. /** mag = linear and min = nearest and mip = nearest */
  40998. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  40999. /** mag = linear and min = nearest and mip = linear */
  41000. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  41001. /** mag = linear and min = linear and mip = none */
  41002. static readonly TEXTURE_LINEAR_LINEAR: number;
  41003. /** mag = linear and min = nearest and mip = none */
  41004. static readonly TEXTURE_LINEAR_NEAREST: number;
  41005. /** Explicit coordinates mode */
  41006. static readonly TEXTURE_EXPLICIT_MODE: number;
  41007. /** Spherical coordinates mode */
  41008. static readonly TEXTURE_SPHERICAL_MODE: number;
  41009. /** Planar coordinates mode */
  41010. static readonly TEXTURE_PLANAR_MODE: number;
  41011. /** Cubic coordinates mode */
  41012. static readonly TEXTURE_CUBIC_MODE: number;
  41013. /** Projection coordinates mode */
  41014. static readonly TEXTURE_PROJECTION_MODE: number;
  41015. /** Skybox coordinates mode */
  41016. static readonly TEXTURE_SKYBOX_MODE: number;
  41017. /** Inverse Cubic coordinates mode */
  41018. static readonly TEXTURE_INVCUBIC_MODE: number;
  41019. /** Equirectangular coordinates mode */
  41020. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  41021. /** Equirectangular Fixed coordinates mode */
  41022. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  41023. /** Equirectangular Fixed Mirrored coordinates mode */
  41024. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  41025. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  41026. static readonly SCALEMODE_FLOOR: number;
  41027. /** Defines that texture rescaling will look for the nearest power of 2 size */
  41028. static readonly SCALEMODE_NEAREST: number;
  41029. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  41030. static readonly SCALEMODE_CEILING: number;
  41031. /**
  41032. * Returns the current npm package of the sdk
  41033. */
  41034. static get NpmPackage(): string;
  41035. /**
  41036. * Returns the current version of the framework
  41037. */
  41038. static get Version(): string;
  41039. /** Gets the list of created engines */
  41040. static get Instances(): Engine[];
  41041. /**
  41042. * Gets the latest created engine
  41043. */
  41044. static get LastCreatedEngine(): Nullable<Engine>;
  41045. /**
  41046. * Gets the latest created scene
  41047. */
  41048. static get LastCreatedScene(): Nullable<Scene>;
  41049. /**
  41050. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  41051. * @param flag defines which part of the materials must be marked as dirty
  41052. * @param predicate defines a predicate used to filter which materials should be affected
  41053. */
  41054. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  41055. /**
  41056. * Method called to create the default loading screen.
  41057. * This can be overriden in your own app.
  41058. * @param canvas The rendering canvas element
  41059. * @returns The loading screen
  41060. */
  41061. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  41062. /**
  41063. * Method called to create the default rescale post process on each engine.
  41064. */
  41065. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  41066. /**
  41067. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  41068. **/
  41069. enableOfflineSupport: boolean;
  41070. /**
  41071. * 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)
  41072. **/
  41073. disableManifestCheck: boolean;
  41074. /**
  41075. * Gets the list of created scenes
  41076. */
  41077. scenes: Scene[];
  41078. /**
  41079. * Event raised when a new scene is created
  41080. */
  41081. onNewSceneAddedObservable: Observable<Scene>;
  41082. /**
  41083. * Gets the list of created postprocesses
  41084. */
  41085. postProcesses: PostProcess[];
  41086. /**
  41087. * Gets a boolean indicating if the pointer is currently locked
  41088. */
  41089. isPointerLock: boolean;
  41090. /**
  41091. * Observable event triggered each time the rendering canvas is resized
  41092. */
  41093. onResizeObservable: Observable<Engine>;
  41094. /**
  41095. * Observable event triggered each time the canvas loses focus
  41096. */
  41097. onCanvasBlurObservable: Observable<Engine>;
  41098. /**
  41099. * Observable event triggered each time the canvas gains focus
  41100. */
  41101. onCanvasFocusObservable: Observable<Engine>;
  41102. /**
  41103. * Observable event triggered each time the canvas receives pointerout event
  41104. */
  41105. onCanvasPointerOutObservable: Observable<PointerEvent>;
  41106. /**
  41107. * Observable raised when the engine begins a new frame
  41108. */
  41109. onBeginFrameObservable: Observable<Engine>;
  41110. /**
  41111. * If set, will be used to request the next animation frame for the render loop
  41112. */
  41113. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  41114. /**
  41115. * Observable raised when the engine ends the current frame
  41116. */
  41117. onEndFrameObservable: Observable<Engine>;
  41118. /**
  41119. * Observable raised when the engine is about to compile a shader
  41120. */
  41121. onBeforeShaderCompilationObservable: Observable<Engine>;
  41122. /**
  41123. * Observable raised when the engine has jsut compiled a shader
  41124. */
  41125. onAfterShaderCompilationObservable: Observable<Engine>;
  41126. /**
  41127. * Gets the audio engine
  41128. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  41129. * @ignorenaming
  41130. */
  41131. static audioEngine: IAudioEngine;
  41132. /**
  41133. * Default AudioEngine factory responsible of creating the Audio Engine.
  41134. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  41135. */
  41136. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  41137. /**
  41138. * Default offline support factory responsible of creating a tool used to store data locally.
  41139. * By default, this will create a Database object if the workload has been embedded.
  41140. */
  41141. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  41142. private _loadingScreen;
  41143. private _pointerLockRequested;
  41144. private _rescalePostProcess;
  41145. private _deterministicLockstep;
  41146. private _lockstepMaxSteps;
  41147. private _timeStep;
  41148. protected get _supportsHardwareTextureRescaling(): boolean;
  41149. private _fps;
  41150. private _deltaTime;
  41151. /** @hidden */
  41152. _drawCalls: PerfCounter;
  41153. /** 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 */
  41154. canvasTabIndex: number;
  41155. /**
  41156. * Turn this value on if you want to pause FPS computation when in background
  41157. */
  41158. disablePerformanceMonitorInBackground: boolean;
  41159. private _performanceMonitor;
  41160. /**
  41161. * Gets the performance monitor attached to this engine
  41162. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  41163. */
  41164. get performanceMonitor(): PerformanceMonitor;
  41165. private _onFocus;
  41166. private _onBlur;
  41167. private _onCanvasPointerOut;
  41168. private _onCanvasBlur;
  41169. private _onCanvasFocus;
  41170. private _onFullscreenChange;
  41171. private _onPointerLockChange;
  41172. /**
  41173. * Gets the HTML element used to attach event listeners
  41174. * @returns a HTML element
  41175. */
  41176. getInputElement(): Nullable<HTMLElement>;
  41177. /**
  41178. * Creates a new engine
  41179. * @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
  41180. * @param antialias defines enable antialiasing (default: false)
  41181. * @param options defines further options to be sent to the getContext() function
  41182. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  41183. */
  41184. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  41185. /**
  41186. * Gets current aspect ratio
  41187. * @param viewportOwner defines the camera to use to get the aspect ratio
  41188. * @param useScreen defines if screen size must be used (or the current render target if any)
  41189. * @returns a number defining the aspect ratio
  41190. */
  41191. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  41192. /**
  41193. * Gets current screen aspect ratio
  41194. * @returns a number defining the aspect ratio
  41195. */
  41196. getScreenAspectRatio(): number;
  41197. /**
  41198. * Gets the client rect of the HTML canvas attached with the current webGL context
  41199. * @returns a client rectanglee
  41200. */
  41201. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  41202. /**
  41203. * Gets the client rect of the HTML element used for events
  41204. * @returns a client rectanglee
  41205. */
  41206. getInputElementClientRect(): Nullable<ClientRect>;
  41207. /**
  41208. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  41209. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41210. * @returns true if engine is in deterministic lock step mode
  41211. */
  41212. isDeterministicLockStep(): boolean;
  41213. /**
  41214. * Gets the max steps when engine is running in deterministic lock step
  41215. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41216. * @returns the max steps
  41217. */
  41218. getLockstepMaxSteps(): number;
  41219. /**
  41220. * Returns the time in ms between steps when using deterministic lock step.
  41221. * @returns time step in (ms)
  41222. */
  41223. getTimeStep(): number;
  41224. /**
  41225. * Force the mipmap generation for the given render target texture
  41226. * @param texture defines the render target texture to use
  41227. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  41228. */
  41229. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  41230. /** States */
  41231. /**
  41232. * Set various states to the webGL context
  41233. * @param culling defines backface culling state
  41234. * @param zOffset defines the value to apply to zOffset (0 by default)
  41235. * @param force defines if states must be applied even if cache is up to date
  41236. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  41237. */
  41238. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  41239. /**
  41240. * Set the z offset to apply to current rendering
  41241. * @param value defines the offset to apply
  41242. */
  41243. setZOffset(value: number): void;
  41244. /**
  41245. * Gets the current value of the zOffset
  41246. * @returns the current zOffset state
  41247. */
  41248. getZOffset(): number;
  41249. /**
  41250. * Enable or disable depth buffering
  41251. * @param enable defines the state to set
  41252. */
  41253. setDepthBuffer(enable: boolean): void;
  41254. /**
  41255. * Gets a boolean indicating if depth writing is enabled
  41256. * @returns the current depth writing state
  41257. */
  41258. getDepthWrite(): boolean;
  41259. /**
  41260. * Enable or disable depth writing
  41261. * @param enable defines the state to set
  41262. */
  41263. setDepthWrite(enable: boolean): void;
  41264. /**
  41265. * Gets a boolean indicating if stencil buffer is enabled
  41266. * @returns the current stencil buffer state
  41267. */
  41268. getStencilBuffer(): boolean;
  41269. /**
  41270. * Enable or disable the stencil buffer
  41271. * @param enable defines if the stencil buffer must be enabled or disabled
  41272. */
  41273. setStencilBuffer(enable: boolean): void;
  41274. /**
  41275. * Gets the current stencil mask
  41276. * @returns a number defining the new stencil mask to use
  41277. */
  41278. getStencilMask(): number;
  41279. /**
  41280. * Sets the current stencil mask
  41281. * @param mask defines the new stencil mask to use
  41282. */
  41283. setStencilMask(mask: number): void;
  41284. /**
  41285. * Gets the current stencil function
  41286. * @returns a number defining the stencil function to use
  41287. */
  41288. getStencilFunction(): number;
  41289. /**
  41290. * Gets the current stencil reference value
  41291. * @returns a number defining the stencil reference value to use
  41292. */
  41293. getStencilFunctionReference(): number;
  41294. /**
  41295. * Gets the current stencil mask
  41296. * @returns a number defining the stencil mask to use
  41297. */
  41298. getStencilFunctionMask(): number;
  41299. /**
  41300. * Sets the current stencil function
  41301. * @param stencilFunc defines the new stencil function to use
  41302. */
  41303. setStencilFunction(stencilFunc: number): void;
  41304. /**
  41305. * Sets the current stencil reference
  41306. * @param reference defines the new stencil reference to use
  41307. */
  41308. setStencilFunctionReference(reference: number): void;
  41309. /**
  41310. * Sets the current stencil mask
  41311. * @param mask defines the new stencil mask to use
  41312. */
  41313. setStencilFunctionMask(mask: number): void;
  41314. /**
  41315. * Gets the current stencil operation when stencil fails
  41316. * @returns a number defining stencil operation to use when stencil fails
  41317. */
  41318. getStencilOperationFail(): number;
  41319. /**
  41320. * Gets the current stencil operation when depth fails
  41321. * @returns a number defining stencil operation to use when depth fails
  41322. */
  41323. getStencilOperationDepthFail(): number;
  41324. /**
  41325. * Gets the current stencil operation when stencil passes
  41326. * @returns a number defining stencil operation to use when stencil passes
  41327. */
  41328. getStencilOperationPass(): number;
  41329. /**
  41330. * Sets the stencil operation to use when stencil fails
  41331. * @param operation defines the stencil operation to use when stencil fails
  41332. */
  41333. setStencilOperationFail(operation: number): void;
  41334. /**
  41335. * Sets the stencil operation to use when depth fails
  41336. * @param operation defines the stencil operation to use when depth fails
  41337. */
  41338. setStencilOperationDepthFail(operation: number): void;
  41339. /**
  41340. * Sets the stencil operation to use when stencil passes
  41341. * @param operation defines the stencil operation to use when stencil passes
  41342. */
  41343. setStencilOperationPass(operation: number): void;
  41344. /**
  41345. * Sets a boolean indicating if the dithering state is enabled or disabled
  41346. * @param value defines the dithering state
  41347. */
  41348. setDitheringState(value: boolean): void;
  41349. /**
  41350. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  41351. * @param value defines the rasterizer state
  41352. */
  41353. setRasterizerState(value: boolean): void;
  41354. /**
  41355. * Gets the current depth function
  41356. * @returns a number defining the depth function
  41357. */
  41358. getDepthFunction(): Nullable<number>;
  41359. /**
  41360. * Sets the current depth function
  41361. * @param depthFunc defines the function to use
  41362. */
  41363. setDepthFunction(depthFunc: number): void;
  41364. /**
  41365. * Sets the current depth function to GREATER
  41366. */
  41367. setDepthFunctionToGreater(): void;
  41368. /**
  41369. * Sets the current depth function to GEQUAL
  41370. */
  41371. setDepthFunctionToGreaterOrEqual(): void;
  41372. /**
  41373. * Sets the current depth function to LESS
  41374. */
  41375. setDepthFunctionToLess(): void;
  41376. /**
  41377. * Sets the current depth function to LEQUAL
  41378. */
  41379. setDepthFunctionToLessOrEqual(): void;
  41380. private _cachedStencilBuffer;
  41381. private _cachedStencilFunction;
  41382. private _cachedStencilMask;
  41383. private _cachedStencilOperationPass;
  41384. private _cachedStencilOperationFail;
  41385. private _cachedStencilOperationDepthFail;
  41386. private _cachedStencilReference;
  41387. /**
  41388. * Caches the the state of the stencil buffer
  41389. */
  41390. cacheStencilState(): void;
  41391. /**
  41392. * Restores the state of the stencil buffer
  41393. */
  41394. restoreStencilState(): void;
  41395. /**
  41396. * Directly set the WebGL Viewport
  41397. * @param x defines the x coordinate of the viewport (in screen space)
  41398. * @param y defines the y coordinate of the viewport (in screen space)
  41399. * @param width defines the width of the viewport (in screen space)
  41400. * @param height defines the height of the viewport (in screen space)
  41401. * @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
  41402. */
  41403. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  41404. /**
  41405. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  41406. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  41407. * @param y defines the y-coordinate of the corner of the clear rectangle
  41408. * @param width defines the width of the clear rectangle
  41409. * @param height defines the height of the clear rectangle
  41410. * @param clearColor defines the clear color
  41411. */
  41412. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  41413. /**
  41414. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  41415. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  41416. * @param y defines the y-coordinate of the corner of the clear rectangle
  41417. * @param width defines the width of the clear rectangle
  41418. * @param height defines the height of the clear rectangle
  41419. */
  41420. enableScissor(x: number, y: number, width: number, height: number): void;
  41421. /**
  41422. * Disable previously set scissor test rectangle
  41423. */
  41424. disableScissor(): void;
  41425. protected _reportDrawCall(): void;
  41426. /**
  41427. * Initializes a webVR display and starts listening to display change events
  41428. * The onVRDisplayChangedObservable will be notified upon these changes
  41429. * @returns The onVRDisplayChangedObservable
  41430. */
  41431. initWebVR(): Observable<IDisplayChangedEventArgs>;
  41432. /** @hidden */
  41433. _prepareVRComponent(): void;
  41434. /** @hidden */
  41435. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  41436. /** @hidden */
  41437. _submitVRFrame(): void;
  41438. /**
  41439. * Call this function to leave webVR mode
  41440. * Will do nothing if webVR is not supported or if there is no webVR device
  41441. * @see https://doc.babylonjs.com/how_to/webvr_camera
  41442. */
  41443. disableVR(): void;
  41444. /**
  41445. * Gets a boolean indicating that the system is in VR mode and is presenting
  41446. * @returns true if VR mode is engaged
  41447. */
  41448. isVRPresenting(): boolean;
  41449. /** @hidden */
  41450. _requestVRFrame(): void;
  41451. /** @hidden */
  41452. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  41453. /**
  41454. * Gets the source code of the vertex shader associated with a specific webGL program
  41455. * @param program defines the program to use
  41456. * @returns a string containing the source code of the vertex shader associated with the program
  41457. */
  41458. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  41459. /**
  41460. * Gets the source code of the fragment shader associated with a specific webGL program
  41461. * @param program defines the program to use
  41462. * @returns a string containing the source code of the fragment shader associated with the program
  41463. */
  41464. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  41465. /**
  41466. * Sets a depth stencil texture from a render target to the according uniform.
  41467. * @param channel The texture channel
  41468. * @param uniform The uniform to set
  41469. * @param texture The render target texture containing the depth stencil texture to apply
  41470. */
  41471. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  41472. /**
  41473. * Sets a texture to the webGL context from a postprocess
  41474. * @param channel defines the channel to use
  41475. * @param postProcess defines the source postprocess
  41476. */
  41477. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  41478. /**
  41479. * Binds the output of the passed in post process to the texture channel specified
  41480. * @param channel The channel the texture should be bound to
  41481. * @param postProcess The post process which's output should be bound
  41482. */
  41483. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  41484. protected _rebuildBuffers(): void;
  41485. /** @hidden */
  41486. _renderFrame(): void;
  41487. _renderLoop(): void;
  41488. /** @hidden */
  41489. _renderViews(): boolean;
  41490. /**
  41491. * Toggle full screen mode
  41492. * @param requestPointerLock defines if a pointer lock should be requested from the user
  41493. */
  41494. switchFullscreen(requestPointerLock: boolean): void;
  41495. /**
  41496. * Enters full screen mode
  41497. * @param requestPointerLock defines if a pointer lock should be requested from the user
  41498. */
  41499. enterFullscreen(requestPointerLock: boolean): void;
  41500. /**
  41501. * Exits full screen mode
  41502. */
  41503. exitFullscreen(): void;
  41504. /**
  41505. * Enters Pointerlock mode
  41506. */
  41507. enterPointerlock(): void;
  41508. /**
  41509. * Exits Pointerlock mode
  41510. */
  41511. exitPointerlock(): void;
  41512. /**
  41513. * Begin a new frame
  41514. */
  41515. beginFrame(): void;
  41516. /**
  41517. * Enf the current frame
  41518. */
  41519. endFrame(): void;
  41520. resize(): void;
  41521. /**
  41522. * Force a specific size of the canvas
  41523. * @param width defines the new canvas' width
  41524. * @param height defines the new canvas' height
  41525. * @returns true if the size was changed
  41526. */
  41527. setSize(width: number, height: number): boolean;
  41528. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  41529. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  41530. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  41531. _releaseTexture(texture: InternalTexture): void;
  41532. /**
  41533. * @hidden
  41534. * Rescales a texture
  41535. * @param source input texutre
  41536. * @param destination destination texture
  41537. * @param scene scene to use to render the resize
  41538. * @param internalFormat format to use when resizing
  41539. * @param onComplete callback to be called when resize has completed
  41540. */
  41541. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  41542. /**
  41543. * Gets the current framerate
  41544. * @returns a number representing the framerate
  41545. */
  41546. getFps(): number;
  41547. /**
  41548. * Gets the time spent between current and previous frame
  41549. * @returns a number representing the delta time in ms
  41550. */
  41551. getDeltaTime(): number;
  41552. private _measureFps;
  41553. /** @hidden */
  41554. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  41555. /**
  41556. * Updates the sample count of a render target texture
  41557. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  41558. * @param texture defines the texture to update
  41559. * @param samples defines the sample count to set
  41560. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  41561. */
  41562. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  41563. /**
  41564. * Updates a depth texture Comparison Mode and Function.
  41565. * If the comparison Function is equal to 0, the mode will be set to none.
  41566. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  41567. * @param texture The texture to set the comparison function for
  41568. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  41569. */
  41570. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  41571. /**
  41572. * Creates a webGL buffer to use with instanciation
  41573. * @param capacity defines the size of the buffer
  41574. * @returns the webGL buffer
  41575. */
  41576. createInstancesBuffer(capacity: number): DataBuffer;
  41577. /**
  41578. * Delete a webGL buffer used with instanciation
  41579. * @param buffer defines the webGL buffer to delete
  41580. */
  41581. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  41582. private _clientWaitAsync;
  41583. /** @hidden */
  41584. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  41585. dispose(): void;
  41586. private _disableTouchAction;
  41587. /**
  41588. * Display the loading screen
  41589. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41590. */
  41591. displayLoadingUI(): void;
  41592. /**
  41593. * Hide the loading screen
  41594. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41595. */
  41596. hideLoadingUI(): void;
  41597. /**
  41598. * Gets the current loading screen object
  41599. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41600. */
  41601. get loadingScreen(): ILoadingScreen;
  41602. /**
  41603. * Sets the current loading screen object
  41604. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41605. */
  41606. set loadingScreen(loadingScreen: ILoadingScreen);
  41607. /**
  41608. * Sets the current loading screen text
  41609. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41610. */
  41611. set loadingUIText(text: string);
  41612. /**
  41613. * Sets the current loading screen background color
  41614. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41615. */
  41616. set loadingUIBackgroundColor(color: string);
  41617. /** Pointerlock and fullscreen */
  41618. /**
  41619. * Ask the browser to promote the current element to pointerlock mode
  41620. * @param element defines the DOM element to promote
  41621. */
  41622. static _RequestPointerlock(element: HTMLElement): void;
  41623. /**
  41624. * Asks the browser to exit pointerlock mode
  41625. */
  41626. static _ExitPointerlock(): void;
  41627. /**
  41628. * Ask the browser to promote the current element to fullscreen rendering mode
  41629. * @param element defines the DOM element to promote
  41630. */
  41631. static _RequestFullscreen(element: HTMLElement): void;
  41632. /**
  41633. * Asks the browser to exit fullscreen mode
  41634. */
  41635. static _ExitFullscreen(): void;
  41636. }
  41637. }
  41638. declare module BABYLON {
  41639. /**
  41640. * The engine store class is responsible to hold all the instances of Engine and Scene created
  41641. * during the life time of the application.
  41642. */
  41643. export class EngineStore {
  41644. /** Gets the list of created engines */
  41645. static Instances: Engine[];
  41646. /** @hidden */
  41647. static _LastCreatedScene: Nullable<Scene>;
  41648. /**
  41649. * Gets the latest created engine
  41650. */
  41651. static get LastCreatedEngine(): Nullable<Engine>;
  41652. /**
  41653. * Gets the latest created scene
  41654. */
  41655. static get LastCreatedScene(): Nullable<Scene>;
  41656. /**
  41657. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  41658. * @ignorenaming
  41659. */
  41660. static UseFallbackTexture: boolean;
  41661. /**
  41662. * Texture content used if a texture cannot loaded
  41663. * @ignorenaming
  41664. */
  41665. static FallbackTexture: string;
  41666. }
  41667. }
  41668. declare module BABYLON {
  41669. /**
  41670. * Helper class that provides a small promise polyfill
  41671. */
  41672. export class PromisePolyfill {
  41673. /**
  41674. * Static function used to check if the polyfill is required
  41675. * If this is the case then the function will inject the polyfill to window.Promise
  41676. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  41677. */
  41678. static Apply(force?: boolean): void;
  41679. }
  41680. }
  41681. declare module BABYLON {
  41682. /**
  41683. * Interface for screenshot methods with describe argument called `size` as object with options
  41684. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  41685. */
  41686. export interface IScreenshotSize {
  41687. /**
  41688. * number in pixels for canvas height
  41689. */
  41690. height?: number;
  41691. /**
  41692. * multiplier allowing render at a higher or lower resolution
  41693. * If value is defined then height and width will be ignored and taken from camera
  41694. */
  41695. precision?: number;
  41696. /**
  41697. * number in pixels for canvas width
  41698. */
  41699. width?: number;
  41700. }
  41701. }
  41702. declare module BABYLON {
  41703. interface IColor4Like {
  41704. r: float;
  41705. g: float;
  41706. b: float;
  41707. a: float;
  41708. }
  41709. /**
  41710. * Class containing a set of static utilities functions
  41711. */
  41712. export class Tools {
  41713. /**
  41714. * Gets or sets the base URL to use to load assets
  41715. */
  41716. static get BaseUrl(): string;
  41717. static set BaseUrl(value: string);
  41718. /**
  41719. * Enable/Disable Custom HTTP Request Headers globally.
  41720. * default = false
  41721. * @see CustomRequestHeaders
  41722. */
  41723. static UseCustomRequestHeaders: boolean;
  41724. /**
  41725. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  41726. * i.e. when loading files, where the server/service expects an Authorization header
  41727. */
  41728. static CustomRequestHeaders: {
  41729. [key: string]: string;
  41730. };
  41731. /**
  41732. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  41733. */
  41734. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  41735. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  41736. /**
  41737. * Default behaviour for cors in the application.
  41738. * It can be a string if the expected behavior is identical in the entire app.
  41739. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  41740. */
  41741. static get CorsBehavior(): string | ((url: string | string[]) => string);
  41742. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  41743. /**
  41744. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  41745. * @ignorenaming
  41746. */
  41747. static get UseFallbackTexture(): boolean;
  41748. static set UseFallbackTexture(value: boolean);
  41749. /**
  41750. * Use this object to register external classes like custom textures or material
  41751. * to allow the laoders to instantiate them
  41752. */
  41753. static get RegisteredExternalClasses(): {
  41754. [key: string]: Object;
  41755. };
  41756. static set RegisteredExternalClasses(classes: {
  41757. [key: string]: Object;
  41758. });
  41759. /**
  41760. * Texture content used if a texture cannot loaded
  41761. * @ignorenaming
  41762. */
  41763. static get fallbackTexture(): string;
  41764. static set fallbackTexture(value: string);
  41765. /**
  41766. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  41767. * @param u defines the coordinate on X axis
  41768. * @param v defines the coordinate on Y axis
  41769. * @param width defines the width of the source data
  41770. * @param height defines the height of the source data
  41771. * @param pixels defines the source byte array
  41772. * @param color defines the output color
  41773. */
  41774. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  41775. /**
  41776. * Interpolates between a and b via alpha
  41777. * @param a The lower value (returned when alpha = 0)
  41778. * @param b The upper value (returned when alpha = 1)
  41779. * @param alpha The interpolation-factor
  41780. * @return The mixed value
  41781. */
  41782. static Mix(a: number, b: number, alpha: number): number;
  41783. /**
  41784. * Tries to instantiate a new object from a given class name
  41785. * @param className defines the class name to instantiate
  41786. * @returns the new object or null if the system was not able to do the instantiation
  41787. */
  41788. static Instantiate(className: string): any;
  41789. /**
  41790. * Provides a slice function that will work even on IE
  41791. * @param data defines the array to slice
  41792. * @param start defines the start of the data (optional)
  41793. * @param end defines the end of the data (optional)
  41794. * @returns the new sliced array
  41795. */
  41796. static Slice<T>(data: T, start?: number, end?: number): T;
  41797. /**
  41798. * Provides a slice function that will work even on IE
  41799. * The difference between this and Slice is that this will force-convert to array
  41800. * @param data defines the array to slice
  41801. * @param start defines the start of the data (optional)
  41802. * @param end defines the end of the data (optional)
  41803. * @returns the new sliced array
  41804. */
  41805. static SliceToArray<T, P>(data: T, start?: number, end?: number): Array<P>;
  41806. /**
  41807. * Polyfill for setImmediate
  41808. * @param action defines the action to execute after the current execution block
  41809. */
  41810. static SetImmediate(action: () => void): void;
  41811. /**
  41812. * Function indicating if a number is an exponent of 2
  41813. * @param value defines the value to test
  41814. * @returns true if the value is an exponent of 2
  41815. */
  41816. static IsExponentOfTwo(value: number): boolean;
  41817. private static _tmpFloatArray;
  41818. /**
  41819. * Returns the nearest 32-bit single precision float representation of a Number
  41820. * @param value A Number. If the parameter is of a different type, it will get converted
  41821. * to a number or to NaN if it cannot be converted
  41822. * @returns number
  41823. */
  41824. static FloatRound(value: number): number;
  41825. /**
  41826. * Extracts the filename from a path
  41827. * @param path defines the path to use
  41828. * @returns the filename
  41829. */
  41830. static GetFilename(path: string): string;
  41831. /**
  41832. * Extracts the "folder" part of a path (everything before the filename).
  41833. * @param uri The URI to extract the info from
  41834. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  41835. * @returns The "folder" part of the path
  41836. */
  41837. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  41838. /**
  41839. * Extracts text content from a DOM element hierarchy
  41840. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  41841. */
  41842. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  41843. /**
  41844. * Convert an angle in radians to degrees
  41845. * @param angle defines the angle to convert
  41846. * @returns the angle in degrees
  41847. */
  41848. static ToDegrees(angle: number): number;
  41849. /**
  41850. * Convert an angle in degrees to radians
  41851. * @param angle defines the angle to convert
  41852. * @returns the angle in radians
  41853. */
  41854. static ToRadians(angle: number): number;
  41855. /**
  41856. * Returns an array if obj is not an array
  41857. * @param obj defines the object to evaluate as an array
  41858. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  41859. * @returns either obj directly if obj is an array or a new array containing obj
  41860. */
  41861. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  41862. /**
  41863. * Gets the pointer prefix to use
  41864. * @param engine defines the engine we are finding the prefix for
  41865. * @returns "pointer" if touch is enabled. Else returns "mouse"
  41866. */
  41867. static GetPointerPrefix(engine: Engine): string;
  41868. /**
  41869. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  41870. * @param url define the url we are trying
  41871. * @param element define the dom element where to configure the cors policy
  41872. */
  41873. static SetCorsBehavior(url: string | string[], element: {
  41874. crossOrigin: string | null;
  41875. }): void;
  41876. /**
  41877. * Removes unwanted characters from an url
  41878. * @param url defines the url to clean
  41879. * @returns the cleaned url
  41880. */
  41881. static CleanUrl(url: string): string;
  41882. /**
  41883. * Gets or sets a function used to pre-process url before using them to load assets
  41884. */
  41885. static get PreprocessUrl(): (url: string) => string;
  41886. static set PreprocessUrl(processor: (url: string) => string);
  41887. /**
  41888. * Loads an image as an HTMLImageElement.
  41889. * @param input url string, ArrayBuffer, or Blob to load
  41890. * @param onLoad callback called when the image successfully loads
  41891. * @param onError callback called when the image fails to load
  41892. * @param offlineProvider offline provider for caching
  41893. * @param mimeType optional mime type
  41894. * @returns the HTMLImageElement of the loaded image
  41895. */
  41896. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  41897. /**
  41898. * Loads a file from a url
  41899. * @param url url string, ArrayBuffer, or Blob to load
  41900. * @param onSuccess callback called when the file successfully loads
  41901. * @param onProgress callback called while file is loading (if the server supports this mode)
  41902. * @param offlineProvider defines the offline provider for caching
  41903. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  41904. * @param onError callback called when the file fails to load
  41905. * @returns a file request object
  41906. */
  41907. 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;
  41908. /**
  41909. * Loads a file from a url
  41910. * @param url the file url to load
  41911. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  41912. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  41913. */
  41914. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  41915. /**
  41916. * Load a script (identified by an url). When the url returns, the
  41917. * content of this file is added into a new script element, attached to the DOM (body element)
  41918. * @param scriptUrl defines the url of the script to laod
  41919. * @param onSuccess defines the callback called when the script is loaded
  41920. * @param onError defines the callback to call if an error occurs
  41921. * @param scriptId defines the id of the script element
  41922. */
  41923. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  41924. /**
  41925. * Load an asynchronous script (identified by an url). When the url returns, the
  41926. * content of this file is added into a new script element, attached to the DOM (body element)
  41927. * @param scriptUrl defines the url of the script to laod
  41928. * @param scriptId defines the id of the script element
  41929. * @returns a promise request object
  41930. */
  41931. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  41932. /**
  41933. * Loads a file from a blob
  41934. * @param fileToLoad defines the blob to use
  41935. * @param callback defines the callback to call when data is loaded
  41936. * @param progressCallback defines the callback to call during loading process
  41937. * @returns a file request object
  41938. */
  41939. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  41940. /**
  41941. * Reads a file from a File object
  41942. * @param file defines the file to load
  41943. * @param onSuccess defines the callback to call when data is loaded
  41944. * @param onProgress defines the callback to call during loading process
  41945. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  41946. * @param onError defines the callback to call when an error occurs
  41947. * @returns a file request object
  41948. */
  41949. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  41950. /**
  41951. * Creates a data url from a given string content
  41952. * @param content defines the content to convert
  41953. * @returns the new data url link
  41954. */
  41955. static FileAsURL(content: string): string;
  41956. /**
  41957. * Format the given number to a specific decimal format
  41958. * @param value defines the number to format
  41959. * @param decimals defines the number of decimals to use
  41960. * @returns the formatted string
  41961. */
  41962. static Format(value: number, decimals?: number): string;
  41963. /**
  41964. * Tries to copy an object by duplicating every property
  41965. * @param source defines the source object
  41966. * @param destination defines the target object
  41967. * @param doNotCopyList defines a list of properties to avoid
  41968. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  41969. */
  41970. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  41971. /**
  41972. * Gets a boolean indicating if the given object has no own property
  41973. * @param obj defines the object to test
  41974. * @returns true if object has no own property
  41975. */
  41976. static IsEmpty(obj: any): boolean;
  41977. /**
  41978. * Function used to register events at window level
  41979. * @param windowElement defines the Window object to use
  41980. * @param events defines the events to register
  41981. */
  41982. static RegisterTopRootEvents(windowElement: Window, events: {
  41983. name: string;
  41984. handler: Nullable<(e: FocusEvent) => any>;
  41985. }[]): void;
  41986. /**
  41987. * Function used to unregister events from window level
  41988. * @param windowElement defines the Window object to use
  41989. * @param events defines the events to unregister
  41990. */
  41991. static UnregisterTopRootEvents(windowElement: Window, events: {
  41992. name: string;
  41993. handler: Nullable<(e: FocusEvent) => any>;
  41994. }[]): void;
  41995. /**
  41996. * @ignore
  41997. */
  41998. static _ScreenshotCanvas: HTMLCanvasElement;
  41999. /**
  42000. * Dumps the current bound framebuffer
  42001. * @param width defines the rendering width
  42002. * @param height defines the rendering height
  42003. * @param engine defines the hosting engine
  42004. * @param successCallback defines the callback triggered once the data are available
  42005. * @param mimeType defines the mime type of the result
  42006. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  42007. */
  42008. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  42009. /**
  42010. * Converts the canvas data to blob.
  42011. * This acts as a polyfill for browsers not supporting the to blob function.
  42012. * @param canvas Defines the canvas to extract the data from
  42013. * @param successCallback Defines the callback triggered once the data are available
  42014. * @param mimeType Defines the mime type of the result
  42015. */
  42016. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  42017. /**
  42018. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  42019. * @param successCallback defines the callback triggered once the data are available
  42020. * @param mimeType defines the mime type of the result
  42021. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  42022. */
  42023. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  42024. /**
  42025. * Downloads a blob in the browser
  42026. * @param blob defines the blob to download
  42027. * @param fileName defines the name of the downloaded file
  42028. */
  42029. static Download(blob: Blob, fileName: string): void;
  42030. /**
  42031. * Will return the right value of the noPreventDefault variable
  42032. * Needed to keep backwards compatibility to the old API.
  42033. *
  42034. * @param args arguments passed to the attachControl function
  42035. * @returns the correct value for noPreventDefault
  42036. */
  42037. static BackCompatCameraNoPreventDefault(args: IArguments): boolean;
  42038. /**
  42039. * Captures a screenshot of the current rendering
  42040. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  42041. * @param engine defines the rendering engine
  42042. * @param camera defines the source camera
  42043. * @param size This parameter can be set to a single number or to an object with the
  42044. * following (optional) properties: precision, width, height. If a single number is passed,
  42045. * it will be used for both width and height. If an object is passed, the screenshot size
  42046. * will be derived from the parameters. The precision property is a multiplier allowing
  42047. * rendering at a higher or lower resolution
  42048. * @param successCallback defines the callback receives a single parameter which contains the
  42049. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  42050. * src parameter of an <img> to display it
  42051. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  42052. * Check your browser for supported MIME types
  42053. */
  42054. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  42055. /**
  42056. * Captures a screenshot of the current rendering
  42057. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  42058. * @param engine defines the rendering engine
  42059. * @param camera defines the source camera
  42060. * @param size This parameter can be set to a single number or to an object with the
  42061. * following (optional) properties: precision, width, height. If a single number is passed,
  42062. * it will be used for both width and height. If an object is passed, the screenshot size
  42063. * will be derived from the parameters. The precision property is a multiplier allowing
  42064. * rendering at a higher or lower resolution
  42065. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  42066. * Check your browser for supported MIME types
  42067. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  42068. * to the src parameter of an <img> to display it
  42069. */
  42070. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  42071. /**
  42072. * Generates an image screenshot from the specified camera.
  42073. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  42074. * @param engine The engine to use for rendering
  42075. * @param camera The camera to use for rendering
  42076. * @param size This parameter can be set to a single number or to an object with the
  42077. * following (optional) properties: precision, width, height. If a single number is passed,
  42078. * it will be used for both width and height. If an object is passed, the screenshot size
  42079. * will be derived from the parameters. The precision property is a multiplier allowing
  42080. * rendering at a higher or lower resolution
  42081. * @param successCallback The callback receives a single parameter which contains the
  42082. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  42083. * src parameter of an <img> to display it
  42084. * @param mimeType The MIME type of the screenshot image (default: image/png).
  42085. * Check your browser for supported MIME types
  42086. * @param samples Texture samples (default: 1)
  42087. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  42088. * @param fileName A name for for the downloaded file.
  42089. */
  42090. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  42091. /**
  42092. * Generates an image screenshot from the specified camera.
  42093. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  42094. * @param engine The engine to use for rendering
  42095. * @param camera The camera to use for rendering
  42096. * @param size This parameter can be set to a single number or to an object with the
  42097. * following (optional) properties: precision, width, height. If a single number is passed,
  42098. * it will be used for both width and height. If an object is passed, the screenshot size
  42099. * will be derived from the parameters. The precision property is a multiplier allowing
  42100. * rendering at a higher or lower resolution
  42101. * @param mimeType The MIME type of the screenshot image (default: image/png).
  42102. * Check your browser for supported MIME types
  42103. * @param samples Texture samples (default: 1)
  42104. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  42105. * @param fileName A name for for the downloaded file.
  42106. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  42107. * to the src parameter of an <img> to display it
  42108. */
  42109. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  42110. /**
  42111. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  42112. * Be aware Math.random() could cause collisions, but:
  42113. * "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"
  42114. * @returns a pseudo random id
  42115. */
  42116. static RandomId(): string;
  42117. /**
  42118. * Test if the given uri is a base64 string
  42119. * @param uri The uri to test
  42120. * @return True if the uri is a base64 string or false otherwise
  42121. */
  42122. static IsBase64(uri: string): boolean;
  42123. /**
  42124. * Decode the given base64 uri.
  42125. * @param uri The uri to decode
  42126. * @return The decoded base64 data.
  42127. */
  42128. static DecodeBase64(uri: string): ArrayBuffer;
  42129. /**
  42130. * Gets the absolute url.
  42131. * @param url the input url
  42132. * @return the absolute url
  42133. */
  42134. static GetAbsoluteUrl(url: string): string;
  42135. /**
  42136. * No log
  42137. */
  42138. static readonly NoneLogLevel: number;
  42139. /**
  42140. * Only message logs
  42141. */
  42142. static readonly MessageLogLevel: number;
  42143. /**
  42144. * Only warning logs
  42145. */
  42146. static readonly WarningLogLevel: number;
  42147. /**
  42148. * Only error logs
  42149. */
  42150. static readonly ErrorLogLevel: number;
  42151. /**
  42152. * All logs
  42153. */
  42154. static readonly AllLogLevel: number;
  42155. /**
  42156. * Gets a value indicating the number of loading errors
  42157. * @ignorenaming
  42158. */
  42159. static get errorsCount(): number;
  42160. /**
  42161. * Callback called when a new log is added
  42162. */
  42163. static OnNewCacheEntry: (entry: string) => void;
  42164. /**
  42165. * Log a message to the console
  42166. * @param message defines the message to log
  42167. */
  42168. static Log(message: string): void;
  42169. /**
  42170. * Write a warning message to the console
  42171. * @param message defines the message to log
  42172. */
  42173. static Warn(message: string): void;
  42174. /**
  42175. * Write an error message to the console
  42176. * @param message defines the message to log
  42177. */
  42178. static Error(message: string): void;
  42179. /**
  42180. * Gets current log cache (list of logs)
  42181. */
  42182. static get LogCache(): string;
  42183. /**
  42184. * Clears the log cache
  42185. */
  42186. static ClearLogCache(): void;
  42187. /**
  42188. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  42189. */
  42190. static set LogLevels(level: number);
  42191. /**
  42192. * Checks if the window object exists
  42193. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  42194. */
  42195. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  42196. /**
  42197. * No performance log
  42198. */
  42199. static readonly PerformanceNoneLogLevel: number;
  42200. /**
  42201. * Use user marks to log performance
  42202. */
  42203. static readonly PerformanceUserMarkLogLevel: number;
  42204. /**
  42205. * Log performance to the console
  42206. */
  42207. static readonly PerformanceConsoleLogLevel: number;
  42208. private static _performance;
  42209. /**
  42210. * Sets the current performance log level
  42211. */
  42212. static set PerformanceLogLevel(level: number);
  42213. private static _StartPerformanceCounterDisabled;
  42214. private static _EndPerformanceCounterDisabled;
  42215. private static _StartUserMark;
  42216. private static _EndUserMark;
  42217. private static _StartPerformanceConsole;
  42218. private static _EndPerformanceConsole;
  42219. /**
  42220. * Starts a performance counter
  42221. */
  42222. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  42223. /**
  42224. * Ends a specific performance coutner
  42225. */
  42226. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  42227. /**
  42228. * Gets either window.performance.now() if supported or Date.now() else
  42229. */
  42230. static get Now(): number;
  42231. /**
  42232. * This method will return the name of the class used to create the instance of the given object.
  42233. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  42234. * @param object the object to get the class name from
  42235. * @param isType defines if the object is actually a type
  42236. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  42237. */
  42238. static GetClassName(object: any, isType?: boolean): string;
  42239. /**
  42240. * Gets the first element of an array satisfying a given predicate
  42241. * @param array defines the array to browse
  42242. * @param predicate defines the predicate to use
  42243. * @returns null if not found or the element
  42244. */
  42245. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  42246. /**
  42247. * This method will return the name of the full name of the class, including its owning module (if any).
  42248. * 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).
  42249. * @param object the object to get the class name from
  42250. * @param isType defines if the object is actually a type
  42251. * @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.
  42252. * @ignorenaming
  42253. */
  42254. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  42255. /**
  42256. * Returns a promise that resolves after the given amount of time.
  42257. * @param delay Number of milliseconds to delay
  42258. * @returns Promise that resolves after the given amount of time
  42259. */
  42260. static DelayAsync(delay: number): Promise<void>;
  42261. /**
  42262. * Utility function to detect if the current user agent is Safari
  42263. * @returns whether or not the current user agent is safari
  42264. */
  42265. static IsSafari(): boolean;
  42266. }
  42267. /**
  42268. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  42269. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  42270. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  42271. * @param name The name of the class, case should be preserved
  42272. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  42273. */
  42274. export function className(name: string, module?: string): (target: Object) => void;
  42275. /**
  42276. * An implementation of a loop for asynchronous functions.
  42277. */
  42278. export class AsyncLoop {
  42279. /**
  42280. * Defines the number of iterations for the loop
  42281. */
  42282. iterations: number;
  42283. /**
  42284. * Defines the current index of the loop.
  42285. */
  42286. index: number;
  42287. private _done;
  42288. private _fn;
  42289. private _successCallback;
  42290. /**
  42291. * Constructor.
  42292. * @param iterations the number of iterations.
  42293. * @param func the function to run each iteration
  42294. * @param successCallback the callback that will be called upon succesful execution
  42295. * @param offset starting offset.
  42296. */
  42297. constructor(
  42298. /**
  42299. * Defines the number of iterations for the loop
  42300. */
  42301. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  42302. /**
  42303. * Execute the next iteration. Must be called after the last iteration was finished.
  42304. */
  42305. executeNext(): void;
  42306. /**
  42307. * Break the loop and run the success callback.
  42308. */
  42309. breakLoop(): void;
  42310. /**
  42311. * Create and run an async loop.
  42312. * @param iterations the number of iterations.
  42313. * @param fn the function to run each iteration
  42314. * @param successCallback the callback that will be called upon succesful execution
  42315. * @param offset starting offset.
  42316. * @returns the created async loop object
  42317. */
  42318. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  42319. /**
  42320. * A for-loop that will run a given number of iterations synchronous and the rest async.
  42321. * @param iterations total number of iterations
  42322. * @param syncedIterations number of synchronous iterations in each async iteration.
  42323. * @param fn the function to call each iteration.
  42324. * @param callback a success call back that will be called when iterating stops.
  42325. * @param breakFunction a break condition (optional)
  42326. * @param timeout timeout settings for the setTimeout function. default - 0.
  42327. * @returns the created async loop object
  42328. */
  42329. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  42330. }
  42331. }
  42332. declare module BABYLON {
  42333. /**
  42334. * This class implement a typical dictionary using a string as key and the generic type T as value.
  42335. * The underlying implementation relies on an associative array to ensure the best performances.
  42336. * The value can be anything including 'null' but except 'undefined'
  42337. */
  42338. export class StringDictionary<T> {
  42339. /**
  42340. * This will clear this dictionary and copy the content from the 'source' one.
  42341. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  42342. * @param source the dictionary to take the content from and copy to this dictionary
  42343. */
  42344. copyFrom(source: StringDictionary<T>): void;
  42345. /**
  42346. * Get a value based from its key
  42347. * @param key the given key to get the matching value from
  42348. * @return the value if found, otherwise undefined is returned
  42349. */
  42350. get(key: string): T | undefined;
  42351. /**
  42352. * Get a value from its key or add it if it doesn't exist.
  42353. * This method will ensure you that a given key/data will be present in the dictionary.
  42354. * @param key the given key to get the matching value from
  42355. * @param factory the factory that will create the value if the key is not present in the dictionary.
  42356. * The factory will only be invoked if there's no data for the given key.
  42357. * @return the value corresponding to the key.
  42358. */
  42359. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  42360. /**
  42361. * Get a value from its key if present in the dictionary otherwise add it
  42362. * @param key the key to get the value from
  42363. * @param val if there's no such key/value pair in the dictionary add it with this value
  42364. * @return the value corresponding to the key
  42365. */
  42366. getOrAdd(key: string, val: T): T;
  42367. /**
  42368. * Check if there's a given key in the dictionary
  42369. * @param key the key to check for
  42370. * @return true if the key is present, false otherwise
  42371. */
  42372. contains(key: string): boolean;
  42373. /**
  42374. * Add a new key and its corresponding value
  42375. * @param key the key to add
  42376. * @param value the value corresponding to the key
  42377. * @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
  42378. */
  42379. add(key: string, value: T): boolean;
  42380. /**
  42381. * Update a specific value associated to a key
  42382. * @param key defines the key to use
  42383. * @param value defines the value to store
  42384. * @returns true if the value was updated (or false if the key was not found)
  42385. */
  42386. set(key: string, value: T): boolean;
  42387. /**
  42388. * Get the element of the given key and remove it from the dictionary
  42389. * @param key defines the key to search
  42390. * @returns the value associated with the key or null if not found
  42391. */
  42392. getAndRemove(key: string): Nullable<T>;
  42393. /**
  42394. * Remove a key/value from the dictionary.
  42395. * @param key the key to remove
  42396. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  42397. */
  42398. remove(key: string): boolean;
  42399. /**
  42400. * Clear the whole content of the dictionary
  42401. */
  42402. clear(): void;
  42403. /**
  42404. * Gets the current count
  42405. */
  42406. get count(): number;
  42407. /**
  42408. * Execute a callback on each key/val of the dictionary.
  42409. * Note that you can remove any element in this dictionary in the callback implementation
  42410. * @param callback the callback to execute on a given key/value pair
  42411. */
  42412. forEach(callback: (key: string, val: T) => void): void;
  42413. /**
  42414. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  42415. * If the callback returns null or undefined the method will iterate to the next key/value pair
  42416. * Note that you can remove any element in this dictionary in the callback implementation
  42417. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  42418. * @returns the first item
  42419. */
  42420. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  42421. private _count;
  42422. private _data;
  42423. }
  42424. }
  42425. declare module BABYLON {
  42426. /** @hidden */
  42427. export interface ICollisionCoordinator {
  42428. createCollider(): Collider;
  42429. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  42430. init(scene: Scene): void;
  42431. }
  42432. /** @hidden */
  42433. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  42434. private _scene;
  42435. private _scaledPosition;
  42436. private _scaledVelocity;
  42437. private _finalPosition;
  42438. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  42439. createCollider(): Collider;
  42440. init(scene: Scene): void;
  42441. private _collideWithWorld;
  42442. }
  42443. }
  42444. declare module BABYLON {
  42445. /**
  42446. * Class used to manage all inputs for the scene.
  42447. */
  42448. export class InputManager {
  42449. /** The distance in pixel that you have to move to prevent some events */
  42450. static DragMovementThreshold: number;
  42451. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  42452. static LongPressDelay: number;
  42453. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  42454. static DoubleClickDelay: number;
  42455. /** If you need to check double click without raising a single click at first click, enable this flag */
  42456. static ExclusiveDoubleClickMode: boolean;
  42457. /** 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. */
  42458. private _alreadyAttached;
  42459. private _alreadyAttachedTo;
  42460. private _wheelEventName;
  42461. private _onPointerMove;
  42462. private _onPointerDown;
  42463. private _onPointerUp;
  42464. private _initClickEvent;
  42465. private _initActionManager;
  42466. private _delayedSimpleClick;
  42467. private _delayedSimpleClickTimeout;
  42468. private _previousDelayedSimpleClickTimeout;
  42469. private _meshPickProceed;
  42470. private _previousButtonPressed;
  42471. private _currentPickResult;
  42472. private _previousPickResult;
  42473. private _totalPointersPressed;
  42474. private _doubleClickOccured;
  42475. private _pointerOverMesh;
  42476. private _pickedDownMesh;
  42477. private _pickedUpMesh;
  42478. private _pointerX;
  42479. private _pointerY;
  42480. private _unTranslatedPointerX;
  42481. private _unTranslatedPointerY;
  42482. private _startingPointerPosition;
  42483. private _previousStartingPointerPosition;
  42484. private _startingPointerTime;
  42485. private _previousStartingPointerTime;
  42486. private _pointerCaptures;
  42487. private _meshUnderPointerId;
  42488. private _onKeyDown;
  42489. private _onKeyUp;
  42490. private _keyboardIsAttached;
  42491. private _onCanvasFocusObserver;
  42492. private _onCanvasBlurObserver;
  42493. private _scene;
  42494. /**
  42495. * Creates a new InputManager
  42496. * @param scene defines the hosting scene
  42497. */
  42498. constructor(scene: Scene);
  42499. /**
  42500. * Gets the mesh that is currently under the pointer
  42501. */
  42502. get meshUnderPointer(): Nullable<AbstractMesh>;
  42503. /**
  42504. * When using more than one pointer (for example in XR) you can get the mesh under the specific pointer
  42505. * @param pointerId the pointer id to use
  42506. * @returns The mesh under this pointer id or null if not found
  42507. */
  42508. getMeshUnderPointerByPointerId(pointerId: number): Nullable<AbstractMesh>;
  42509. /**
  42510. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  42511. */
  42512. get unTranslatedPointer(): Vector2;
  42513. /**
  42514. * Gets or sets the current on-screen X position of the pointer
  42515. */
  42516. get pointerX(): number;
  42517. set pointerX(value: number);
  42518. /**
  42519. * Gets or sets the current on-screen Y position of the pointer
  42520. */
  42521. get pointerY(): number;
  42522. set pointerY(value: number);
  42523. private _updatePointerPosition;
  42524. private _processPointerMove;
  42525. private _setRayOnPointerInfo;
  42526. private _checkPrePointerObservable;
  42527. /**
  42528. * Use this method to simulate a pointer move on a mesh
  42529. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  42530. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  42531. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  42532. */
  42533. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  42534. /**
  42535. * Use this method to simulate a pointer down on a mesh
  42536. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  42537. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  42538. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  42539. */
  42540. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  42541. private _processPointerDown;
  42542. /** @hidden */
  42543. _isPointerSwiping(): boolean;
  42544. /**
  42545. * Use this method to simulate a pointer up on a mesh
  42546. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  42547. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  42548. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  42549. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  42550. */
  42551. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  42552. private _processPointerUp;
  42553. /**
  42554. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  42555. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  42556. * @returns true if the pointer was captured
  42557. */
  42558. isPointerCaptured(pointerId?: number): boolean;
  42559. /**
  42560. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  42561. * @param attachUp defines if you want to attach events to pointerup
  42562. * @param attachDown defines if you want to attach events to pointerdown
  42563. * @param attachMove defines if you want to attach events to pointermove
  42564. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  42565. */
  42566. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  42567. /**
  42568. * Detaches all event handlers
  42569. */
  42570. detachControl(): void;
  42571. /**
  42572. * Force the value of meshUnderPointer
  42573. * @param mesh defines the mesh to use
  42574. * @param pointerId optional pointer id when using more than one pointer. Defaults to 0
  42575. */
  42576. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  42577. /**
  42578. * Gets the mesh under the pointer
  42579. * @returns a Mesh or null if no mesh is under the pointer
  42580. */
  42581. getPointerOverMesh(): Nullable<AbstractMesh>;
  42582. }
  42583. }
  42584. declare module BABYLON {
  42585. /**
  42586. * This class defines the direct association between an animation and a target
  42587. */
  42588. export class TargetedAnimation {
  42589. /**
  42590. * Animation to perform
  42591. */
  42592. animation: Animation;
  42593. /**
  42594. * Target to animate
  42595. */
  42596. target: any;
  42597. /**
  42598. * Returns the string "TargetedAnimation"
  42599. * @returns "TargetedAnimation"
  42600. */
  42601. getClassName(): string;
  42602. /**
  42603. * Serialize the object
  42604. * @returns the JSON object representing the current entity
  42605. */
  42606. serialize(): any;
  42607. }
  42608. /**
  42609. * Use this class to create coordinated animations on multiple targets
  42610. */
  42611. export class AnimationGroup implements IDisposable {
  42612. /** The name of the animation group */
  42613. name: string;
  42614. private _scene;
  42615. private _targetedAnimations;
  42616. private _animatables;
  42617. private _from;
  42618. private _to;
  42619. private _isStarted;
  42620. private _isPaused;
  42621. private _speedRatio;
  42622. private _loopAnimation;
  42623. private _isAdditive;
  42624. /**
  42625. * Gets or sets the unique id of the node
  42626. */
  42627. uniqueId: number;
  42628. /**
  42629. * This observable will notify when one animation have ended
  42630. */
  42631. onAnimationEndObservable: Observable<TargetedAnimation>;
  42632. /**
  42633. * Observer raised when one animation loops
  42634. */
  42635. onAnimationLoopObservable: Observable<TargetedAnimation>;
  42636. /**
  42637. * Observer raised when all animations have looped
  42638. */
  42639. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  42640. /**
  42641. * This observable will notify when all animations have ended.
  42642. */
  42643. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  42644. /**
  42645. * This observable will notify when all animations have paused.
  42646. */
  42647. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  42648. /**
  42649. * This observable will notify when all animations are playing.
  42650. */
  42651. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  42652. /**
  42653. * Gets the first frame
  42654. */
  42655. get from(): number;
  42656. /**
  42657. * Gets the last frame
  42658. */
  42659. get to(): number;
  42660. /**
  42661. * Define if the animations are started
  42662. */
  42663. get isStarted(): boolean;
  42664. /**
  42665. * Gets a value indicating that the current group is playing
  42666. */
  42667. get isPlaying(): boolean;
  42668. /**
  42669. * Gets or sets the speed ratio to use for all animations
  42670. */
  42671. get speedRatio(): number;
  42672. /**
  42673. * Gets or sets the speed ratio to use for all animations
  42674. */
  42675. set speedRatio(value: number);
  42676. /**
  42677. * Gets or sets if all animations should loop or not
  42678. */
  42679. get loopAnimation(): boolean;
  42680. set loopAnimation(value: boolean);
  42681. /**
  42682. * Gets or sets if all animations should be evaluated additively
  42683. */
  42684. get isAdditive(): boolean;
  42685. set isAdditive(value: boolean);
  42686. /**
  42687. * Gets the targeted animations for this animation group
  42688. */
  42689. get targetedAnimations(): Array<TargetedAnimation>;
  42690. /**
  42691. * returning the list of animatables controlled by this animation group.
  42692. */
  42693. get animatables(): Array<Animatable>;
  42694. /**
  42695. * Gets the list of target animations
  42696. */
  42697. get children(): TargetedAnimation[];
  42698. /**
  42699. * Instantiates a new Animation Group.
  42700. * This helps managing several animations at once.
  42701. * @see https://doc.babylonjs.com/how_to/group
  42702. * @param name Defines the name of the group
  42703. * @param scene Defines the scene the group belongs to
  42704. */
  42705. constructor(
  42706. /** The name of the animation group */
  42707. name: string, scene?: Nullable<Scene>);
  42708. /**
  42709. * Add an animation (with its target) in the group
  42710. * @param animation defines the animation we want to add
  42711. * @param target defines the target of the animation
  42712. * @returns the TargetedAnimation object
  42713. */
  42714. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  42715. /**
  42716. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  42717. * It can add constant keys at begin or end
  42718. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  42719. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  42720. * @returns the animation group
  42721. */
  42722. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  42723. private _animationLoopCount;
  42724. private _animationLoopFlags;
  42725. private _processLoop;
  42726. /**
  42727. * Start all animations on given targets
  42728. * @param loop defines if animations must loop
  42729. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  42730. * @param from defines the from key (optional)
  42731. * @param to defines the to key (optional)
  42732. * @param isAdditive defines the additive state for the resulting animatables (optional)
  42733. * @returns the current animation group
  42734. */
  42735. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  42736. /**
  42737. * Pause all animations
  42738. * @returns the animation group
  42739. */
  42740. pause(): AnimationGroup;
  42741. /**
  42742. * Play all animations to initial state
  42743. * This function will start() the animations if they were not started or will restart() them if they were paused
  42744. * @param loop defines if animations must loop
  42745. * @returns the animation group
  42746. */
  42747. play(loop?: boolean): AnimationGroup;
  42748. /**
  42749. * Reset all animations to initial state
  42750. * @returns the animation group
  42751. */
  42752. reset(): AnimationGroup;
  42753. /**
  42754. * Restart animations from key 0
  42755. * @returns the animation group
  42756. */
  42757. restart(): AnimationGroup;
  42758. /**
  42759. * Stop all animations
  42760. * @returns the animation group
  42761. */
  42762. stop(): AnimationGroup;
  42763. /**
  42764. * Set animation weight for all animatables
  42765. * @param weight defines the weight to use
  42766. * @return the animationGroup
  42767. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  42768. */
  42769. setWeightForAllAnimatables(weight: number): AnimationGroup;
  42770. /**
  42771. * Synchronize and normalize all animatables with a source animatable
  42772. * @param root defines the root animatable to synchronize with
  42773. * @return the animationGroup
  42774. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  42775. */
  42776. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  42777. /**
  42778. * Goes to a specific frame in this animation group
  42779. * @param frame the frame number to go to
  42780. * @return the animationGroup
  42781. */
  42782. goToFrame(frame: number): AnimationGroup;
  42783. /**
  42784. * Dispose all associated resources
  42785. */
  42786. dispose(): void;
  42787. private _checkAnimationGroupEnded;
  42788. /**
  42789. * Clone the current animation group and returns a copy
  42790. * @param newName defines the name of the new group
  42791. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  42792. * @returns the new aniamtion group
  42793. */
  42794. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  42795. /**
  42796. * Serializes the animationGroup to an object
  42797. * @returns Serialized object
  42798. */
  42799. serialize(): any;
  42800. /**
  42801. * Returns a new AnimationGroup object parsed from the source provided.
  42802. * @param parsedAnimationGroup defines the source
  42803. * @param scene defines the scene that will receive the animationGroup
  42804. * @returns a new AnimationGroup
  42805. */
  42806. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  42807. /**
  42808. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  42809. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  42810. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  42811. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  42812. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  42813. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  42814. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  42815. */
  42816. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  42817. /**
  42818. * Returns the string "AnimationGroup"
  42819. * @returns "AnimationGroup"
  42820. */
  42821. getClassName(): string;
  42822. /**
  42823. * Creates a detailled string about the object
  42824. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  42825. * @returns a string representing the object
  42826. */
  42827. toString(fullDetails?: boolean): string;
  42828. }
  42829. }
  42830. declare module BABYLON {
  42831. /**
  42832. * Define an interface for all classes that will hold resources
  42833. */
  42834. export interface IDisposable {
  42835. /**
  42836. * Releases all held resources
  42837. */
  42838. dispose(): void;
  42839. }
  42840. /** Interface defining initialization parameters for Scene class */
  42841. export interface SceneOptions {
  42842. /**
  42843. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  42844. * It will improve performance when the number of geometries becomes important.
  42845. */
  42846. useGeometryUniqueIdsMap?: boolean;
  42847. /**
  42848. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  42849. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  42850. */
  42851. useMaterialMeshMap?: boolean;
  42852. /**
  42853. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  42854. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  42855. */
  42856. useClonedMeshMap?: boolean;
  42857. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  42858. virtual?: boolean;
  42859. }
  42860. /**
  42861. * Represents a scene to be rendered by the engine.
  42862. * @see https://doc.babylonjs.com/features/scene
  42863. */
  42864. export class Scene extends AbstractScene implements IAnimatable, IClipPlanesHolder {
  42865. /** The fog is deactivated */
  42866. static readonly FOGMODE_NONE: number;
  42867. /** The fog density is following an exponential function */
  42868. static readonly FOGMODE_EXP: number;
  42869. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  42870. static readonly FOGMODE_EXP2: number;
  42871. /** The fog density is following a linear function. */
  42872. static readonly FOGMODE_LINEAR: number;
  42873. /**
  42874. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  42875. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42876. */
  42877. static MinDeltaTime: number;
  42878. /**
  42879. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  42880. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42881. */
  42882. static MaxDeltaTime: number;
  42883. /**
  42884. * Factory used to create the default material.
  42885. * @param name The name of the material to create
  42886. * @param scene The scene to create the material for
  42887. * @returns The default material
  42888. */
  42889. static DefaultMaterialFactory(scene: Scene): Material;
  42890. /**
  42891. * Factory used to create the a collision coordinator.
  42892. * @returns The collision coordinator
  42893. */
  42894. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  42895. /** @hidden */
  42896. _inputManager: InputManager;
  42897. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  42898. cameraToUseForPointers: Nullable<Camera>;
  42899. /** @hidden */
  42900. readonly _isScene: boolean;
  42901. /** @hidden */
  42902. _blockEntityCollection: boolean;
  42903. /**
  42904. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  42905. */
  42906. autoClear: boolean;
  42907. /**
  42908. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  42909. */
  42910. autoClearDepthAndStencil: boolean;
  42911. /**
  42912. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  42913. */
  42914. clearColor: Color4;
  42915. /**
  42916. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  42917. */
  42918. ambientColor: Color3;
  42919. /**
  42920. * This is use to store the default BRDF lookup for PBR materials in your scene.
  42921. * It should only be one of the following (if not the default embedded one):
  42922. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  42923. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  42924. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  42925. * The material properties need to be setup according to the type of texture in use.
  42926. */
  42927. environmentBRDFTexture: BaseTexture;
  42928. /**
  42929. * Texture used in all pbr material as the reflection texture.
  42930. * As in the majority of the scene they are the same (exception for multi room and so on),
  42931. * this is easier to reference from here than from all the materials.
  42932. */
  42933. get environmentTexture(): Nullable<BaseTexture>;
  42934. /**
  42935. * Texture used in all pbr material as the reflection texture.
  42936. * As in the majority of the scene they are the same (exception for multi room and so on),
  42937. * this is easier to set here than in all the materials.
  42938. */
  42939. set environmentTexture(value: Nullable<BaseTexture>);
  42940. /** @hidden */
  42941. protected _environmentIntensity: number;
  42942. /**
  42943. * Intensity of the environment in all pbr material.
  42944. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  42945. * As in the majority of the scene they are the same (exception for multi room and so on),
  42946. * this is easier to reference from here than from all the materials.
  42947. */
  42948. get environmentIntensity(): number;
  42949. /**
  42950. * Intensity of the environment in all pbr material.
  42951. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  42952. * As in the majority of the scene they are the same (exception for multi room and so on),
  42953. * this is easier to set here than in all the materials.
  42954. */
  42955. set environmentIntensity(value: number);
  42956. /** @hidden */
  42957. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  42958. /**
  42959. * Default image processing configuration used either in the rendering
  42960. * Forward main pass or through the imageProcessingPostProcess if present.
  42961. * As in the majority of the scene they are the same (exception for multi camera),
  42962. * this is easier to reference from here than from all the materials and post process.
  42963. *
  42964. * No setter as we it is a shared configuration, you can set the values instead.
  42965. */
  42966. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  42967. private _forceWireframe;
  42968. /**
  42969. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  42970. */
  42971. set forceWireframe(value: boolean);
  42972. get forceWireframe(): boolean;
  42973. private _skipFrustumClipping;
  42974. /**
  42975. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  42976. */
  42977. set skipFrustumClipping(value: boolean);
  42978. get skipFrustumClipping(): boolean;
  42979. private _forcePointsCloud;
  42980. /**
  42981. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  42982. */
  42983. set forcePointsCloud(value: boolean);
  42984. get forcePointsCloud(): boolean;
  42985. /**
  42986. * Gets or sets the active clipplane 1
  42987. */
  42988. clipPlane: Nullable<Plane>;
  42989. /**
  42990. * Gets or sets the active clipplane 2
  42991. */
  42992. clipPlane2: Nullable<Plane>;
  42993. /**
  42994. * Gets or sets the active clipplane 3
  42995. */
  42996. clipPlane3: Nullable<Plane>;
  42997. /**
  42998. * Gets or sets the active clipplane 4
  42999. */
  43000. clipPlane4: Nullable<Plane>;
  43001. /**
  43002. * Gets or sets the active clipplane 5
  43003. */
  43004. clipPlane5: Nullable<Plane>;
  43005. /**
  43006. * Gets or sets the active clipplane 6
  43007. */
  43008. clipPlane6: Nullable<Plane>;
  43009. /**
  43010. * Gets or sets a boolean indicating if animations are enabled
  43011. */
  43012. animationsEnabled: boolean;
  43013. private _animationPropertiesOverride;
  43014. /**
  43015. * Gets or sets the animation properties override
  43016. */
  43017. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  43018. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  43019. /**
  43020. * Gets or sets a boolean indicating if a constant deltatime has to be used
  43021. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  43022. */
  43023. useConstantAnimationDeltaTime: boolean;
  43024. /**
  43025. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  43026. * Please note that it requires to run a ray cast through the scene on every frame
  43027. */
  43028. constantlyUpdateMeshUnderPointer: boolean;
  43029. /**
  43030. * Defines the HTML cursor to use when hovering over interactive elements
  43031. */
  43032. hoverCursor: string;
  43033. /**
  43034. * Defines the HTML default cursor to use (empty by default)
  43035. */
  43036. defaultCursor: string;
  43037. /**
  43038. * Defines whether cursors are handled by the scene.
  43039. */
  43040. doNotHandleCursors: boolean;
  43041. /**
  43042. * This is used to call preventDefault() on pointer down
  43043. * in order to block unwanted artifacts like system double clicks
  43044. */
  43045. preventDefaultOnPointerDown: boolean;
  43046. /**
  43047. * This is used to call preventDefault() on pointer up
  43048. * in order to block unwanted artifacts like system double clicks
  43049. */
  43050. preventDefaultOnPointerUp: boolean;
  43051. /**
  43052. * Gets or sets user defined metadata
  43053. */
  43054. metadata: any;
  43055. /**
  43056. * For internal use only. Please do not use.
  43057. */
  43058. reservedDataStore: any;
  43059. /**
  43060. * Gets the name of the plugin used to load this scene (null by default)
  43061. */
  43062. loadingPluginName: string;
  43063. /**
  43064. * Use this array to add regular expressions used to disable offline support for specific urls
  43065. */
  43066. disableOfflineSupportExceptionRules: RegExp[];
  43067. /**
  43068. * An event triggered when the scene is disposed.
  43069. */
  43070. onDisposeObservable: Observable<Scene>;
  43071. private _onDisposeObserver;
  43072. /** Sets a function to be executed when this scene is disposed. */
  43073. set onDispose(callback: () => void);
  43074. /**
  43075. * An event triggered before rendering the scene (right after animations and physics)
  43076. */
  43077. onBeforeRenderObservable: Observable<Scene>;
  43078. private _onBeforeRenderObserver;
  43079. /** Sets a function to be executed before rendering this scene */
  43080. set beforeRender(callback: Nullable<() => void>);
  43081. /**
  43082. * An event triggered after rendering the scene
  43083. */
  43084. onAfterRenderObservable: Observable<Scene>;
  43085. /**
  43086. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  43087. */
  43088. onAfterRenderCameraObservable: Observable<Camera>;
  43089. private _onAfterRenderObserver;
  43090. /** Sets a function to be executed after rendering this scene */
  43091. set afterRender(callback: Nullable<() => void>);
  43092. /**
  43093. * An event triggered before animating the scene
  43094. */
  43095. onBeforeAnimationsObservable: Observable<Scene>;
  43096. /**
  43097. * An event triggered after animations processing
  43098. */
  43099. onAfterAnimationsObservable: Observable<Scene>;
  43100. /**
  43101. * An event triggered before draw calls are ready to be sent
  43102. */
  43103. onBeforeDrawPhaseObservable: Observable<Scene>;
  43104. /**
  43105. * An event triggered after draw calls have been sent
  43106. */
  43107. onAfterDrawPhaseObservable: Observable<Scene>;
  43108. /**
  43109. * An event triggered when the scene is ready
  43110. */
  43111. onReadyObservable: Observable<Scene>;
  43112. /**
  43113. * An event triggered before rendering a camera
  43114. */
  43115. onBeforeCameraRenderObservable: Observable<Camera>;
  43116. private _onBeforeCameraRenderObserver;
  43117. /** Sets a function to be executed before rendering a camera*/
  43118. set beforeCameraRender(callback: () => void);
  43119. /**
  43120. * An event triggered after rendering a camera
  43121. */
  43122. onAfterCameraRenderObservable: Observable<Camera>;
  43123. private _onAfterCameraRenderObserver;
  43124. /** Sets a function to be executed after rendering a camera*/
  43125. set afterCameraRender(callback: () => void);
  43126. /**
  43127. * An event triggered when active meshes evaluation is about to start
  43128. */
  43129. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  43130. /**
  43131. * An event triggered when active meshes evaluation is done
  43132. */
  43133. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  43134. /**
  43135. * An event triggered when particles rendering is about to start
  43136. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  43137. */
  43138. onBeforeParticlesRenderingObservable: Observable<Scene>;
  43139. /**
  43140. * An event triggered when particles rendering is done
  43141. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  43142. */
  43143. onAfterParticlesRenderingObservable: Observable<Scene>;
  43144. /**
  43145. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  43146. */
  43147. onDataLoadedObservable: Observable<Scene>;
  43148. /**
  43149. * An event triggered when a camera is created
  43150. */
  43151. onNewCameraAddedObservable: Observable<Camera>;
  43152. /**
  43153. * An event triggered when a camera is removed
  43154. */
  43155. onCameraRemovedObservable: Observable<Camera>;
  43156. /**
  43157. * An event triggered when a light is created
  43158. */
  43159. onNewLightAddedObservable: Observable<Light>;
  43160. /**
  43161. * An event triggered when a light is removed
  43162. */
  43163. onLightRemovedObservable: Observable<Light>;
  43164. /**
  43165. * An event triggered when a geometry is created
  43166. */
  43167. onNewGeometryAddedObservable: Observable<Geometry>;
  43168. /**
  43169. * An event triggered when a geometry is removed
  43170. */
  43171. onGeometryRemovedObservable: Observable<Geometry>;
  43172. /**
  43173. * An event triggered when a transform node is created
  43174. */
  43175. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  43176. /**
  43177. * An event triggered when a transform node is removed
  43178. */
  43179. onTransformNodeRemovedObservable: Observable<TransformNode>;
  43180. /**
  43181. * An event triggered when a mesh is created
  43182. */
  43183. onNewMeshAddedObservable: Observable<AbstractMesh>;
  43184. /**
  43185. * An event triggered when a mesh is removed
  43186. */
  43187. onMeshRemovedObservable: Observable<AbstractMesh>;
  43188. /**
  43189. * An event triggered when a skeleton is created
  43190. */
  43191. onNewSkeletonAddedObservable: Observable<Skeleton>;
  43192. /**
  43193. * An event triggered when a skeleton is removed
  43194. */
  43195. onSkeletonRemovedObservable: Observable<Skeleton>;
  43196. /**
  43197. * An event triggered when a material is created
  43198. */
  43199. onNewMaterialAddedObservable: Observable<Material>;
  43200. /**
  43201. * An event triggered when a multi material is created
  43202. */
  43203. onNewMultiMaterialAddedObservable: Observable<MultiMaterial>;
  43204. /**
  43205. * An event triggered when a material is removed
  43206. */
  43207. onMaterialRemovedObservable: Observable<Material>;
  43208. /**
  43209. * An event triggered when a multi material is removed
  43210. */
  43211. onMultiMaterialRemovedObservable: Observable<MultiMaterial>;
  43212. /**
  43213. * An event triggered when a texture is created
  43214. */
  43215. onNewTextureAddedObservable: Observable<BaseTexture>;
  43216. /**
  43217. * An event triggered when a texture is removed
  43218. */
  43219. onTextureRemovedObservable: Observable<BaseTexture>;
  43220. /**
  43221. * An event triggered when render targets are about to be rendered
  43222. * Can happen multiple times per frame.
  43223. */
  43224. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  43225. /**
  43226. * An event triggered when render targets were rendered.
  43227. * Can happen multiple times per frame.
  43228. */
  43229. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  43230. /**
  43231. * An event triggered before calculating deterministic simulation step
  43232. */
  43233. onBeforeStepObservable: Observable<Scene>;
  43234. /**
  43235. * An event triggered after calculating deterministic simulation step
  43236. */
  43237. onAfterStepObservable: Observable<Scene>;
  43238. /**
  43239. * An event triggered when the activeCamera property is updated
  43240. */
  43241. onActiveCameraChanged: Observable<Scene>;
  43242. /**
  43243. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  43244. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  43245. * 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)
  43246. */
  43247. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  43248. /**
  43249. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  43250. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  43251. * 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)
  43252. */
  43253. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  43254. /**
  43255. * This Observable will when a mesh has been imported into the scene.
  43256. */
  43257. onMeshImportedObservable: Observable<AbstractMesh>;
  43258. /**
  43259. * This Observable will when an animation file has been imported into the scene.
  43260. */
  43261. onAnimationFileImportedObservable: Observable<Scene>;
  43262. /**
  43263. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  43264. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  43265. */
  43266. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  43267. /** @hidden */
  43268. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  43269. /**
  43270. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  43271. */
  43272. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  43273. /**
  43274. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  43275. */
  43276. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  43277. /**
  43278. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  43279. */
  43280. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  43281. /** Callback called when a pointer move is detected */
  43282. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  43283. /** Callback called when a pointer down is detected */
  43284. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  43285. /** Callback called when a pointer up is detected */
  43286. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  43287. /** Callback called when a pointer pick is detected */
  43288. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  43289. /**
  43290. * 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).
  43291. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  43292. */
  43293. onPrePointerObservable: Observable<PointerInfoPre>;
  43294. /**
  43295. * Observable event triggered each time an input event is received from the rendering canvas
  43296. */
  43297. onPointerObservable: Observable<PointerInfo>;
  43298. /**
  43299. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  43300. */
  43301. get unTranslatedPointer(): Vector2;
  43302. /**
  43303. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  43304. */
  43305. static get DragMovementThreshold(): number;
  43306. static set DragMovementThreshold(value: number);
  43307. /**
  43308. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  43309. */
  43310. static get LongPressDelay(): number;
  43311. static set LongPressDelay(value: number);
  43312. /**
  43313. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  43314. */
  43315. static get DoubleClickDelay(): number;
  43316. static set DoubleClickDelay(value: number);
  43317. /** If you need to check double click without raising a single click at first click, enable this flag */
  43318. static get ExclusiveDoubleClickMode(): boolean;
  43319. static set ExclusiveDoubleClickMode(value: boolean);
  43320. /** @hidden */
  43321. _mirroredCameraPosition: Nullable<Vector3>;
  43322. /**
  43323. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  43324. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  43325. */
  43326. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  43327. /**
  43328. * Observable event triggered each time an keyboard event is received from the hosting window
  43329. */
  43330. onKeyboardObservable: Observable<KeyboardInfo>;
  43331. private _useRightHandedSystem;
  43332. /**
  43333. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  43334. */
  43335. set useRightHandedSystem(value: boolean);
  43336. get useRightHandedSystem(): boolean;
  43337. private _timeAccumulator;
  43338. private _currentStepId;
  43339. private _currentInternalStep;
  43340. /**
  43341. * Sets the step Id used by deterministic lock step
  43342. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43343. * @param newStepId defines the step Id
  43344. */
  43345. setStepId(newStepId: number): void;
  43346. /**
  43347. * Gets the step Id used by deterministic lock step
  43348. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43349. * @returns the step Id
  43350. */
  43351. getStepId(): number;
  43352. /**
  43353. * Gets the internal step used by deterministic lock step
  43354. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43355. * @returns the internal step
  43356. */
  43357. getInternalStep(): number;
  43358. private _fogEnabled;
  43359. /**
  43360. * Gets or sets a boolean indicating if fog is enabled on this scene
  43361. * @see https://doc.babylonjs.com/babylon101/environment#fog
  43362. * (Default is true)
  43363. */
  43364. set fogEnabled(value: boolean);
  43365. get fogEnabled(): boolean;
  43366. private _fogMode;
  43367. /**
  43368. * Gets or sets the fog mode to use
  43369. * @see https://doc.babylonjs.com/babylon101/environment#fog
  43370. * | mode | value |
  43371. * | --- | --- |
  43372. * | FOGMODE_NONE | 0 |
  43373. * | FOGMODE_EXP | 1 |
  43374. * | FOGMODE_EXP2 | 2 |
  43375. * | FOGMODE_LINEAR | 3 |
  43376. */
  43377. set fogMode(value: number);
  43378. get fogMode(): number;
  43379. /**
  43380. * Gets or sets the fog color to use
  43381. * @see https://doc.babylonjs.com/babylon101/environment#fog
  43382. * (Default is Color3(0.2, 0.2, 0.3))
  43383. */
  43384. fogColor: Color3;
  43385. /**
  43386. * Gets or sets the fog density to use
  43387. * @see https://doc.babylonjs.com/babylon101/environment#fog
  43388. * (Default is 0.1)
  43389. */
  43390. fogDensity: number;
  43391. /**
  43392. * Gets or sets the fog start distance to use
  43393. * @see https://doc.babylonjs.com/babylon101/environment#fog
  43394. * (Default is 0)
  43395. */
  43396. fogStart: number;
  43397. /**
  43398. * Gets or sets the fog end distance to use
  43399. * @see https://doc.babylonjs.com/babylon101/environment#fog
  43400. * (Default is 1000)
  43401. */
  43402. fogEnd: number;
  43403. /**
  43404. * Flag indicating that the frame buffer binding is handled by another component
  43405. */
  43406. prePass: boolean;
  43407. private _shadowsEnabled;
  43408. /**
  43409. * Gets or sets a boolean indicating if shadows are enabled on this scene
  43410. */
  43411. set shadowsEnabled(value: boolean);
  43412. get shadowsEnabled(): boolean;
  43413. private _lightsEnabled;
  43414. /**
  43415. * Gets or sets a boolean indicating if lights are enabled on this scene
  43416. */
  43417. set lightsEnabled(value: boolean);
  43418. get lightsEnabled(): boolean;
  43419. /** All of the active cameras added to this scene. */
  43420. activeCameras: Camera[];
  43421. /** @hidden */
  43422. _activeCamera: Nullable<Camera>;
  43423. /** Gets or sets the current active camera */
  43424. get activeCamera(): Nullable<Camera>;
  43425. set activeCamera(value: Nullable<Camera>);
  43426. private _defaultMaterial;
  43427. /** The default material used on meshes when no material is affected */
  43428. get defaultMaterial(): Material;
  43429. /** The default material used on meshes when no material is affected */
  43430. set defaultMaterial(value: Material);
  43431. private _texturesEnabled;
  43432. /**
  43433. * Gets or sets a boolean indicating if textures are enabled on this scene
  43434. */
  43435. set texturesEnabled(value: boolean);
  43436. get texturesEnabled(): boolean;
  43437. /**
  43438. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  43439. */
  43440. physicsEnabled: boolean;
  43441. /**
  43442. * Gets or sets a boolean indicating if particles are enabled on this scene
  43443. */
  43444. particlesEnabled: boolean;
  43445. /**
  43446. * Gets or sets a boolean indicating if sprites are enabled on this scene
  43447. */
  43448. spritesEnabled: boolean;
  43449. private _skeletonsEnabled;
  43450. /**
  43451. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  43452. */
  43453. set skeletonsEnabled(value: boolean);
  43454. get skeletonsEnabled(): boolean;
  43455. /**
  43456. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  43457. */
  43458. lensFlaresEnabled: boolean;
  43459. /**
  43460. * Gets or sets a boolean indicating if collisions are enabled on this scene
  43461. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  43462. */
  43463. collisionsEnabled: boolean;
  43464. private _collisionCoordinator;
  43465. /** @hidden */
  43466. get collisionCoordinator(): ICollisionCoordinator;
  43467. /**
  43468. * Defines the gravity applied to this scene (used only for collisions)
  43469. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  43470. */
  43471. gravity: Vector3;
  43472. /**
  43473. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  43474. */
  43475. postProcessesEnabled: boolean;
  43476. /**
  43477. * Gets the current postprocess manager
  43478. */
  43479. postProcessManager: PostProcessManager;
  43480. /**
  43481. * Gets or sets a boolean indicating if render targets are enabled on this scene
  43482. */
  43483. renderTargetsEnabled: boolean;
  43484. /**
  43485. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  43486. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  43487. */
  43488. dumpNextRenderTargets: boolean;
  43489. /**
  43490. * The list of user defined render targets added to the scene
  43491. */
  43492. customRenderTargets: RenderTargetTexture[];
  43493. /**
  43494. * Defines if texture loading must be delayed
  43495. * If true, textures will only be loaded when they need to be rendered
  43496. */
  43497. useDelayedTextureLoading: boolean;
  43498. /**
  43499. * Gets the list of meshes imported to the scene through SceneLoader
  43500. */
  43501. importedMeshesFiles: String[];
  43502. /**
  43503. * Gets or sets a boolean indicating if probes are enabled on this scene
  43504. */
  43505. probesEnabled: boolean;
  43506. /**
  43507. * Gets or sets the current offline provider to use to store scene data
  43508. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  43509. */
  43510. offlineProvider: IOfflineProvider;
  43511. /**
  43512. * Gets or sets the action manager associated with the scene
  43513. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  43514. */
  43515. actionManager: AbstractActionManager;
  43516. private _meshesForIntersections;
  43517. /**
  43518. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  43519. */
  43520. proceduralTexturesEnabled: boolean;
  43521. private _engine;
  43522. private _totalVertices;
  43523. /** @hidden */
  43524. _activeIndices: PerfCounter;
  43525. /** @hidden */
  43526. _activeParticles: PerfCounter;
  43527. /** @hidden */
  43528. _activeBones: PerfCounter;
  43529. private _animationRatio;
  43530. /** @hidden */
  43531. _animationTimeLast: number;
  43532. /** @hidden */
  43533. _animationTime: number;
  43534. /**
  43535. * Gets or sets a general scale for animation speed
  43536. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  43537. */
  43538. animationTimeScale: number;
  43539. /** @hidden */
  43540. _cachedMaterial: Nullable<Material>;
  43541. /** @hidden */
  43542. _cachedEffect: Nullable<Effect>;
  43543. /** @hidden */
  43544. _cachedVisibility: Nullable<number>;
  43545. private _renderId;
  43546. private _frameId;
  43547. private _executeWhenReadyTimeoutId;
  43548. private _intermediateRendering;
  43549. private _viewUpdateFlag;
  43550. private _projectionUpdateFlag;
  43551. /** @hidden */
  43552. _toBeDisposed: Nullable<IDisposable>[];
  43553. private _activeRequests;
  43554. /** @hidden */
  43555. _pendingData: any[];
  43556. private _isDisposed;
  43557. /**
  43558. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  43559. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  43560. */
  43561. dispatchAllSubMeshesOfActiveMeshes: boolean;
  43562. private _activeMeshes;
  43563. private _processedMaterials;
  43564. private _renderTargets;
  43565. /** @hidden */
  43566. _activeParticleSystems: SmartArray<IParticleSystem>;
  43567. private _activeSkeletons;
  43568. private _softwareSkinnedMeshes;
  43569. private _renderingManager;
  43570. /** @hidden */
  43571. _activeAnimatables: Animatable[];
  43572. private _transformMatrix;
  43573. private _sceneUbo;
  43574. /** @hidden */
  43575. _viewMatrix: Matrix;
  43576. private _projectionMatrix;
  43577. /** @hidden */
  43578. _forcedViewPosition: Nullable<Vector3>;
  43579. /** @hidden */
  43580. _frustumPlanes: Plane[];
  43581. /**
  43582. * Gets the list of frustum planes (built from the active camera)
  43583. */
  43584. get frustumPlanes(): Plane[];
  43585. /**
  43586. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  43587. * This is useful if there are more lights that the maximum simulteanous authorized
  43588. */
  43589. requireLightSorting: boolean;
  43590. /** @hidden */
  43591. readonly useMaterialMeshMap: boolean;
  43592. /** @hidden */
  43593. readonly useClonedMeshMap: boolean;
  43594. private _externalData;
  43595. private _uid;
  43596. /**
  43597. * @hidden
  43598. * Backing store of defined scene components.
  43599. */
  43600. _components: ISceneComponent[];
  43601. /**
  43602. * @hidden
  43603. * Backing store of defined scene components.
  43604. */
  43605. _serializableComponents: ISceneSerializableComponent[];
  43606. /**
  43607. * List of components to register on the next registration step.
  43608. */
  43609. private _transientComponents;
  43610. /**
  43611. * Registers the transient components if needed.
  43612. */
  43613. private _registerTransientComponents;
  43614. /**
  43615. * @hidden
  43616. * Add a component to the scene.
  43617. * Note that the ccomponent could be registered on th next frame if this is called after
  43618. * the register component stage.
  43619. * @param component Defines the component to add to the scene
  43620. */
  43621. _addComponent(component: ISceneComponent): void;
  43622. /**
  43623. * @hidden
  43624. * Gets a component from the scene.
  43625. * @param name defines the name of the component to retrieve
  43626. * @returns the component or null if not present
  43627. */
  43628. _getComponent(name: string): Nullable<ISceneComponent>;
  43629. /**
  43630. * @hidden
  43631. * Defines the actions happening before camera updates.
  43632. */
  43633. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  43634. /**
  43635. * @hidden
  43636. * Defines the actions happening before clear the canvas.
  43637. */
  43638. _beforeClearStage: Stage<SimpleStageAction>;
  43639. /**
  43640. * @hidden
  43641. * Defines the actions when collecting render targets for the frame.
  43642. */
  43643. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  43644. /**
  43645. * @hidden
  43646. * Defines the actions happening for one camera in the frame.
  43647. */
  43648. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  43649. /**
  43650. * @hidden
  43651. * Defines the actions happening during the per mesh ready checks.
  43652. */
  43653. _isReadyForMeshStage: Stage<MeshStageAction>;
  43654. /**
  43655. * @hidden
  43656. * Defines the actions happening before evaluate active mesh checks.
  43657. */
  43658. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  43659. /**
  43660. * @hidden
  43661. * Defines the actions happening during the evaluate sub mesh checks.
  43662. */
  43663. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  43664. /**
  43665. * @hidden
  43666. * Defines the actions happening during the active mesh stage.
  43667. */
  43668. _preActiveMeshStage: Stage<PreActiveMeshStageAction>;
  43669. /**
  43670. * @hidden
  43671. * Defines the actions happening during the per camera render target step.
  43672. */
  43673. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  43674. /**
  43675. * @hidden
  43676. * Defines the actions happening just before the active camera is drawing.
  43677. */
  43678. _beforeCameraDrawStage: Stage<CameraStageAction>;
  43679. /**
  43680. * @hidden
  43681. * Defines the actions happening just before a render target is drawing.
  43682. */
  43683. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  43684. /**
  43685. * @hidden
  43686. * Defines the actions happening just before a rendering group is drawing.
  43687. */
  43688. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  43689. /**
  43690. * @hidden
  43691. * Defines the actions happening just before a mesh is drawing.
  43692. */
  43693. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  43694. /**
  43695. * @hidden
  43696. * Defines the actions happening just after a mesh has been drawn.
  43697. */
  43698. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  43699. /**
  43700. * @hidden
  43701. * Defines the actions happening just after a rendering group has been drawn.
  43702. */
  43703. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  43704. /**
  43705. * @hidden
  43706. * Defines the actions happening just after the active camera has been drawn.
  43707. */
  43708. _afterCameraDrawStage: Stage<CameraStageAction>;
  43709. /**
  43710. * @hidden
  43711. * Defines the actions happening just after a render target has been drawn.
  43712. */
  43713. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  43714. /**
  43715. * @hidden
  43716. * Defines the actions happening just after rendering all cameras and computing intersections.
  43717. */
  43718. _afterRenderStage: Stage<SimpleStageAction>;
  43719. /**
  43720. * @hidden
  43721. * Defines the actions happening when a pointer move event happens.
  43722. */
  43723. _pointerMoveStage: Stage<PointerMoveStageAction>;
  43724. /**
  43725. * @hidden
  43726. * Defines the actions happening when a pointer down event happens.
  43727. */
  43728. _pointerDownStage: Stage<PointerUpDownStageAction>;
  43729. /**
  43730. * @hidden
  43731. * Defines the actions happening when a pointer up event happens.
  43732. */
  43733. _pointerUpStage: Stage<PointerUpDownStageAction>;
  43734. /**
  43735. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  43736. */
  43737. private geometriesByUniqueId;
  43738. /**
  43739. * Creates a new Scene
  43740. * @param engine defines the engine to use to render this scene
  43741. * @param options defines the scene options
  43742. */
  43743. constructor(engine: Engine, options?: SceneOptions);
  43744. /**
  43745. * Gets a string identifying the name of the class
  43746. * @returns "Scene" string
  43747. */
  43748. getClassName(): string;
  43749. private _defaultMeshCandidates;
  43750. /**
  43751. * @hidden
  43752. */
  43753. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  43754. private _defaultSubMeshCandidates;
  43755. /**
  43756. * @hidden
  43757. */
  43758. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  43759. /**
  43760. * Sets the default candidate providers for the scene.
  43761. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  43762. * and getCollidingSubMeshCandidates to their default function
  43763. */
  43764. setDefaultCandidateProviders(): void;
  43765. /**
  43766. * Gets the mesh that is currently under the pointer
  43767. */
  43768. get meshUnderPointer(): Nullable<AbstractMesh>;
  43769. /**
  43770. * Gets or sets the current on-screen X position of the pointer
  43771. */
  43772. get pointerX(): number;
  43773. set pointerX(value: number);
  43774. /**
  43775. * Gets or sets the current on-screen Y position of the pointer
  43776. */
  43777. get pointerY(): number;
  43778. set pointerY(value: number);
  43779. /**
  43780. * Gets the cached material (ie. the latest rendered one)
  43781. * @returns the cached material
  43782. */
  43783. getCachedMaterial(): Nullable<Material>;
  43784. /**
  43785. * Gets the cached effect (ie. the latest rendered one)
  43786. * @returns the cached effect
  43787. */
  43788. getCachedEffect(): Nullable<Effect>;
  43789. /**
  43790. * Gets the cached visibility state (ie. the latest rendered one)
  43791. * @returns the cached visibility state
  43792. */
  43793. getCachedVisibility(): Nullable<number>;
  43794. /**
  43795. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  43796. * @param material defines the current material
  43797. * @param effect defines the current effect
  43798. * @param visibility defines the current visibility state
  43799. * @returns true if one parameter is not cached
  43800. */
  43801. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  43802. /**
  43803. * Gets the engine associated with the scene
  43804. * @returns an Engine
  43805. */
  43806. getEngine(): Engine;
  43807. /**
  43808. * Gets the total number of vertices rendered per frame
  43809. * @returns the total number of vertices rendered per frame
  43810. */
  43811. getTotalVertices(): number;
  43812. /**
  43813. * Gets the performance counter for total vertices
  43814. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  43815. */
  43816. get totalVerticesPerfCounter(): PerfCounter;
  43817. /**
  43818. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  43819. * @returns the total number of active indices rendered per frame
  43820. */
  43821. getActiveIndices(): number;
  43822. /**
  43823. * Gets the performance counter for active indices
  43824. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  43825. */
  43826. get totalActiveIndicesPerfCounter(): PerfCounter;
  43827. /**
  43828. * Gets the total number of active particles rendered per frame
  43829. * @returns the total number of active particles rendered per frame
  43830. */
  43831. getActiveParticles(): number;
  43832. /**
  43833. * Gets the performance counter for active particles
  43834. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  43835. */
  43836. get activeParticlesPerfCounter(): PerfCounter;
  43837. /**
  43838. * Gets the total number of active bones rendered per frame
  43839. * @returns the total number of active bones rendered per frame
  43840. */
  43841. getActiveBones(): number;
  43842. /**
  43843. * Gets the performance counter for active bones
  43844. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  43845. */
  43846. get activeBonesPerfCounter(): PerfCounter;
  43847. /**
  43848. * Gets the array of active meshes
  43849. * @returns an array of AbstractMesh
  43850. */
  43851. getActiveMeshes(): SmartArray<AbstractMesh>;
  43852. /**
  43853. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  43854. * @returns a number
  43855. */
  43856. getAnimationRatio(): number;
  43857. /**
  43858. * Gets an unique Id for the current render phase
  43859. * @returns a number
  43860. */
  43861. getRenderId(): number;
  43862. /**
  43863. * Gets an unique Id for the current frame
  43864. * @returns a number
  43865. */
  43866. getFrameId(): number;
  43867. /** Call this function if you want to manually increment the render Id*/
  43868. incrementRenderId(): void;
  43869. private _createUbo;
  43870. /**
  43871. * Use this method to simulate a pointer move on a mesh
  43872. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  43873. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  43874. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  43875. * @returns the current scene
  43876. */
  43877. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  43878. /**
  43879. * Use this method to simulate a pointer down on a mesh
  43880. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  43881. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  43882. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  43883. * @returns the current scene
  43884. */
  43885. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  43886. /**
  43887. * Use this method to simulate a pointer up on a mesh
  43888. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  43889. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  43890. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  43891. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  43892. * @returns the current scene
  43893. */
  43894. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  43895. /**
  43896. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  43897. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  43898. * @returns true if the pointer was captured
  43899. */
  43900. isPointerCaptured(pointerId?: number): boolean;
  43901. /**
  43902. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  43903. * @param attachUp defines if you want to attach events to pointerup
  43904. * @param attachDown defines if you want to attach events to pointerdown
  43905. * @param attachMove defines if you want to attach events to pointermove
  43906. */
  43907. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  43908. /** Detaches all event handlers*/
  43909. detachControl(): void;
  43910. /**
  43911. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  43912. * Delay loaded resources are not taking in account
  43913. * @return true if all required resources are ready
  43914. */
  43915. isReady(): boolean;
  43916. /** Resets all cached information relative to material (including effect and visibility) */
  43917. resetCachedMaterial(): void;
  43918. /**
  43919. * Registers a function to be called before every frame render
  43920. * @param func defines the function to register
  43921. */
  43922. registerBeforeRender(func: () => void): void;
  43923. /**
  43924. * Unregisters a function called before every frame render
  43925. * @param func defines the function to unregister
  43926. */
  43927. unregisterBeforeRender(func: () => void): void;
  43928. /**
  43929. * Registers a function to be called after every frame render
  43930. * @param func defines the function to register
  43931. */
  43932. registerAfterRender(func: () => void): void;
  43933. /**
  43934. * Unregisters a function called after every frame render
  43935. * @param func defines the function to unregister
  43936. */
  43937. unregisterAfterRender(func: () => void): void;
  43938. private _executeOnceBeforeRender;
  43939. /**
  43940. * The provided function will run before render once and will be disposed afterwards.
  43941. * A timeout delay can be provided so that the function will be executed in N ms.
  43942. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  43943. * @param func The function to be executed.
  43944. * @param timeout optional delay in ms
  43945. */
  43946. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  43947. /** @hidden */
  43948. _addPendingData(data: any): void;
  43949. /** @hidden */
  43950. _removePendingData(data: any): void;
  43951. /**
  43952. * Returns the number of items waiting to be loaded
  43953. * @returns the number of items waiting to be loaded
  43954. */
  43955. getWaitingItemsCount(): number;
  43956. /**
  43957. * Returns a boolean indicating if the scene is still loading data
  43958. */
  43959. get isLoading(): boolean;
  43960. /**
  43961. * Registers a function to be executed when the scene is ready
  43962. * @param {Function} func - the function to be executed
  43963. */
  43964. executeWhenReady(func: () => void): void;
  43965. /**
  43966. * Returns a promise that resolves when the scene is ready
  43967. * @returns A promise that resolves when the scene is ready
  43968. */
  43969. whenReadyAsync(): Promise<void>;
  43970. /** @hidden */
  43971. _checkIsReady(): void;
  43972. /**
  43973. * Gets all animatable attached to the scene
  43974. */
  43975. get animatables(): Animatable[];
  43976. /**
  43977. * Resets the last animation time frame.
  43978. * Useful to override when animations start running when loading a scene for the first time.
  43979. */
  43980. resetLastAnimationTimeFrame(): void;
  43981. /**
  43982. * Gets the current view matrix
  43983. * @returns a Matrix
  43984. */
  43985. getViewMatrix(): Matrix;
  43986. /**
  43987. * Gets the current projection matrix
  43988. * @returns a Matrix
  43989. */
  43990. getProjectionMatrix(): Matrix;
  43991. /**
  43992. * Gets the current transform matrix
  43993. * @returns a Matrix made of View * Projection
  43994. */
  43995. getTransformMatrix(): Matrix;
  43996. /**
  43997. * Sets the current transform matrix
  43998. * @param viewL defines the View matrix to use
  43999. * @param projectionL defines the Projection matrix to use
  44000. * @param viewR defines the right View matrix to use (if provided)
  44001. * @param projectionR defines the right Projection matrix to use (if provided)
  44002. */
  44003. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  44004. /**
  44005. * Gets the uniform buffer used to store scene data
  44006. * @returns a UniformBuffer
  44007. */
  44008. getSceneUniformBuffer(): UniformBuffer;
  44009. /**
  44010. * Gets an unique (relatively to the current scene) Id
  44011. * @returns an unique number for the scene
  44012. */
  44013. getUniqueId(): number;
  44014. /**
  44015. * Add a mesh to the list of scene's meshes
  44016. * @param newMesh defines the mesh to add
  44017. * @param recursive if all child meshes should also be added to the scene
  44018. */
  44019. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  44020. /**
  44021. * Remove a mesh for the list of scene's meshes
  44022. * @param toRemove defines the mesh to remove
  44023. * @param recursive if all child meshes should also be removed from the scene
  44024. * @returns the index where the mesh was in the mesh list
  44025. */
  44026. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  44027. /**
  44028. * Add a transform node to the list of scene's transform nodes
  44029. * @param newTransformNode defines the transform node to add
  44030. */
  44031. addTransformNode(newTransformNode: TransformNode): void;
  44032. /**
  44033. * Remove a transform node for the list of scene's transform nodes
  44034. * @param toRemove defines the transform node to remove
  44035. * @returns the index where the transform node was in the transform node list
  44036. */
  44037. removeTransformNode(toRemove: TransformNode): number;
  44038. /**
  44039. * Remove a skeleton for the list of scene's skeletons
  44040. * @param toRemove defines the skeleton to remove
  44041. * @returns the index where the skeleton was in the skeleton list
  44042. */
  44043. removeSkeleton(toRemove: Skeleton): number;
  44044. /**
  44045. * Remove a morph target for the list of scene's morph targets
  44046. * @param toRemove defines the morph target to remove
  44047. * @returns the index where the morph target was in the morph target list
  44048. */
  44049. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  44050. /**
  44051. * Remove a light for the list of scene's lights
  44052. * @param toRemove defines the light to remove
  44053. * @returns the index where the light was in the light list
  44054. */
  44055. removeLight(toRemove: Light): number;
  44056. /**
  44057. * Remove a camera for the list of scene's cameras
  44058. * @param toRemove defines the camera to remove
  44059. * @returns the index where the camera was in the camera list
  44060. */
  44061. removeCamera(toRemove: Camera): number;
  44062. /**
  44063. * Remove a particle system for the list of scene's particle systems
  44064. * @param toRemove defines the particle system to remove
  44065. * @returns the index where the particle system was in the particle system list
  44066. */
  44067. removeParticleSystem(toRemove: IParticleSystem): number;
  44068. /**
  44069. * Remove a animation for the list of scene's animations
  44070. * @param toRemove defines the animation to remove
  44071. * @returns the index where the animation was in the animation list
  44072. */
  44073. removeAnimation(toRemove: Animation): number;
  44074. /**
  44075. * Will stop the animation of the given target
  44076. * @param target - the target
  44077. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  44078. * @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)
  44079. */
  44080. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  44081. /**
  44082. * Removes the given animation group from this scene.
  44083. * @param toRemove The animation group to remove
  44084. * @returns The index of the removed animation group
  44085. */
  44086. removeAnimationGroup(toRemove: AnimationGroup): number;
  44087. /**
  44088. * Removes the given multi-material from this scene.
  44089. * @param toRemove The multi-material to remove
  44090. * @returns The index of the removed multi-material
  44091. */
  44092. removeMultiMaterial(toRemove: MultiMaterial): number;
  44093. /**
  44094. * Removes the given material from this scene.
  44095. * @param toRemove The material to remove
  44096. * @returns The index of the removed material
  44097. */
  44098. removeMaterial(toRemove: Material): number;
  44099. /**
  44100. * Removes the given action manager from this scene.
  44101. * @param toRemove The action manager to remove
  44102. * @returns The index of the removed action manager
  44103. */
  44104. removeActionManager(toRemove: AbstractActionManager): number;
  44105. /**
  44106. * Removes the given texture from this scene.
  44107. * @param toRemove The texture to remove
  44108. * @returns The index of the removed texture
  44109. */
  44110. removeTexture(toRemove: BaseTexture): number;
  44111. /**
  44112. * Adds the given light to this scene
  44113. * @param newLight The light to add
  44114. */
  44115. addLight(newLight: Light): void;
  44116. /**
  44117. * Sorts the list list based on light priorities
  44118. */
  44119. sortLightsByPriority(): void;
  44120. /**
  44121. * Adds the given camera to this scene
  44122. * @param newCamera The camera to add
  44123. */
  44124. addCamera(newCamera: Camera): void;
  44125. /**
  44126. * Adds the given skeleton to this scene
  44127. * @param newSkeleton The skeleton to add
  44128. */
  44129. addSkeleton(newSkeleton: Skeleton): void;
  44130. /**
  44131. * Adds the given particle system to this scene
  44132. * @param newParticleSystem The particle system to add
  44133. */
  44134. addParticleSystem(newParticleSystem: IParticleSystem): void;
  44135. /**
  44136. * Adds the given animation to this scene
  44137. * @param newAnimation The animation to add
  44138. */
  44139. addAnimation(newAnimation: Animation): void;
  44140. /**
  44141. * Adds the given animation group to this scene.
  44142. * @param newAnimationGroup The animation group to add
  44143. */
  44144. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  44145. /**
  44146. * Adds the given multi-material to this scene
  44147. * @param newMultiMaterial The multi-material to add
  44148. */
  44149. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  44150. /**
  44151. * Adds the given material to this scene
  44152. * @param newMaterial The material to add
  44153. */
  44154. addMaterial(newMaterial: Material): void;
  44155. /**
  44156. * Adds the given morph target to this scene
  44157. * @param newMorphTargetManager The morph target to add
  44158. */
  44159. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  44160. /**
  44161. * Adds the given geometry to this scene
  44162. * @param newGeometry The geometry to add
  44163. */
  44164. addGeometry(newGeometry: Geometry): void;
  44165. /**
  44166. * Adds the given action manager to this scene
  44167. * @param newActionManager The action manager to add
  44168. */
  44169. addActionManager(newActionManager: AbstractActionManager): void;
  44170. /**
  44171. * Adds the given texture to this scene.
  44172. * @param newTexture The texture to add
  44173. */
  44174. addTexture(newTexture: BaseTexture): void;
  44175. /**
  44176. * Switch active camera
  44177. * @param newCamera defines the new active camera
  44178. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  44179. */
  44180. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  44181. /**
  44182. * sets the active camera of the scene using its ID
  44183. * @param id defines the camera's ID
  44184. * @return the new active camera or null if none found.
  44185. */
  44186. setActiveCameraByID(id: string): Nullable<Camera>;
  44187. /**
  44188. * sets the active camera of the scene using its name
  44189. * @param name defines the camera's name
  44190. * @returns the new active camera or null if none found.
  44191. */
  44192. setActiveCameraByName(name: string): Nullable<Camera>;
  44193. /**
  44194. * get an animation group using its name
  44195. * @param name defines the material's name
  44196. * @return the animation group or null if none found.
  44197. */
  44198. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  44199. /**
  44200. * Get a material using its unique id
  44201. * @param uniqueId defines the material's unique id
  44202. * @return the material or null if none found.
  44203. */
  44204. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  44205. /**
  44206. * get a material using its id
  44207. * @param id defines the material's ID
  44208. * @return the material or null if none found.
  44209. */
  44210. getMaterialByID(id: string): Nullable<Material>;
  44211. /**
  44212. * Gets a the last added material using a given id
  44213. * @param id defines the material's ID
  44214. * @return the last material with the given id or null if none found.
  44215. */
  44216. getLastMaterialByID(id: string): Nullable<Material>;
  44217. /**
  44218. * Gets a material using its name
  44219. * @param name defines the material's name
  44220. * @return the material or null if none found.
  44221. */
  44222. getMaterialByName(name: string): Nullable<Material>;
  44223. /**
  44224. * Get a texture using its unique id
  44225. * @param uniqueId defines the texture's unique id
  44226. * @return the texture or null if none found.
  44227. */
  44228. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  44229. /**
  44230. * Gets a camera using its id
  44231. * @param id defines the id to look for
  44232. * @returns the camera or null if not found
  44233. */
  44234. getCameraByID(id: string): Nullable<Camera>;
  44235. /**
  44236. * Gets a camera using its unique id
  44237. * @param uniqueId defines the unique id to look for
  44238. * @returns the camera or null if not found
  44239. */
  44240. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  44241. /**
  44242. * Gets a camera using its name
  44243. * @param name defines the camera's name
  44244. * @return the camera or null if none found.
  44245. */
  44246. getCameraByName(name: string): Nullable<Camera>;
  44247. /**
  44248. * Gets a bone using its id
  44249. * @param id defines the bone's id
  44250. * @return the bone or null if not found
  44251. */
  44252. getBoneByID(id: string): Nullable<Bone>;
  44253. /**
  44254. * Gets a bone using its id
  44255. * @param name defines the bone's name
  44256. * @return the bone or null if not found
  44257. */
  44258. getBoneByName(name: string): Nullable<Bone>;
  44259. /**
  44260. * Gets a light node using its name
  44261. * @param name defines the the light's name
  44262. * @return the light or null if none found.
  44263. */
  44264. getLightByName(name: string): Nullable<Light>;
  44265. /**
  44266. * Gets a light node using its id
  44267. * @param id defines the light's id
  44268. * @return the light or null if none found.
  44269. */
  44270. getLightByID(id: string): Nullable<Light>;
  44271. /**
  44272. * Gets a light node using its scene-generated unique ID
  44273. * @param uniqueId defines the light's unique id
  44274. * @return the light or null if none found.
  44275. */
  44276. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  44277. /**
  44278. * Gets a particle system by id
  44279. * @param id defines the particle system id
  44280. * @return the corresponding system or null if none found
  44281. */
  44282. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  44283. /**
  44284. * Gets a geometry using its ID
  44285. * @param id defines the geometry's id
  44286. * @return the geometry or null if none found.
  44287. */
  44288. getGeometryByID(id: string): Nullable<Geometry>;
  44289. private _getGeometryByUniqueID;
  44290. /**
  44291. * Add a new geometry to this scene
  44292. * @param geometry defines the geometry to be added to the scene.
  44293. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  44294. * @return a boolean defining if the geometry was added or not
  44295. */
  44296. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  44297. /**
  44298. * Removes an existing geometry
  44299. * @param geometry defines the geometry to be removed from the scene
  44300. * @return a boolean defining if the geometry was removed or not
  44301. */
  44302. removeGeometry(geometry: Geometry): boolean;
  44303. /**
  44304. * Gets the list of geometries attached to the scene
  44305. * @returns an array of Geometry
  44306. */
  44307. getGeometries(): Geometry[];
  44308. /**
  44309. * Gets the first added mesh found of a given ID
  44310. * @param id defines the id to search for
  44311. * @return the mesh found or null if not found at all
  44312. */
  44313. getMeshByID(id: string): Nullable<AbstractMesh>;
  44314. /**
  44315. * Gets a list of meshes using their id
  44316. * @param id defines the id to search for
  44317. * @returns a list of meshes
  44318. */
  44319. getMeshesByID(id: string): Array<AbstractMesh>;
  44320. /**
  44321. * Gets the first added transform node found of a given ID
  44322. * @param id defines the id to search for
  44323. * @return the found transform node or null if not found at all.
  44324. */
  44325. getTransformNodeByID(id: string): Nullable<TransformNode>;
  44326. /**
  44327. * Gets a transform node with its auto-generated unique id
  44328. * @param uniqueId efines the unique id to search for
  44329. * @return the found transform node or null if not found at all.
  44330. */
  44331. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  44332. /**
  44333. * Gets a list of transform nodes using their id
  44334. * @param id defines the id to search for
  44335. * @returns a list of transform nodes
  44336. */
  44337. getTransformNodesByID(id: string): Array<TransformNode>;
  44338. /**
  44339. * Gets a mesh with its auto-generated unique id
  44340. * @param uniqueId defines the unique id to search for
  44341. * @return the found mesh or null if not found at all.
  44342. */
  44343. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  44344. /**
  44345. * Gets a the last added mesh using a given id
  44346. * @param id defines the id to search for
  44347. * @return the found mesh or null if not found at all.
  44348. */
  44349. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  44350. /**
  44351. * Gets a the last added node (Mesh, Camera, Light) using a given id
  44352. * @param id defines the id to search for
  44353. * @return the found node or null if not found at all
  44354. */
  44355. getLastEntryByID(id: string): Nullable<Node>;
  44356. /**
  44357. * Gets a node (Mesh, Camera, Light) using a given id
  44358. * @param id defines the id to search for
  44359. * @return the found node or null if not found at all
  44360. */
  44361. getNodeByID(id: string): Nullable<Node>;
  44362. /**
  44363. * Gets a node (Mesh, Camera, Light) using a given name
  44364. * @param name defines the name to search for
  44365. * @return the found node or null if not found at all.
  44366. */
  44367. getNodeByName(name: string): Nullable<Node>;
  44368. /**
  44369. * Gets a mesh using a given name
  44370. * @param name defines the name to search for
  44371. * @return the found mesh or null if not found at all.
  44372. */
  44373. getMeshByName(name: string): Nullable<AbstractMesh>;
  44374. /**
  44375. * Gets a transform node using a given name
  44376. * @param name defines the name to search for
  44377. * @return the found transform node or null if not found at all.
  44378. */
  44379. getTransformNodeByName(name: string): Nullable<TransformNode>;
  44380. /**
  44381. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  44382. * @param id defines the id to search for
  44383. * @return the found skeleton or null if not found at all.
  44384. */
  44385. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  44386. /**
  44387. * Gets a skeleton using a given auto generated unique id
  44388. * @param uniqueId defines the unique id to search for
  44389. * @return the found skeleton or null if not found at all.
  44390. */
  44391. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  44392. /**
  44393. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  44394. * @param id defines the id to search for
  44395. * @return the found skeleton or null if not found at all.
  44396. */
  44397. getSkeletonById(id: string): Nullable<Skeleton>;
  44398. /**
  44399. * Gets a skeleton using a given name
  44400. * @param name defines the name to search for
  44401. * @return the found skeleton or null if not found at all.
  44402. */
  44403. getSkeletonByName(name: string): Nullable<Skeleton>;
  44404. /**
  44405. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  44406. * @param id defines the id to search for
  44407. * @return the found morph target manager or null if not found at all.
  44408. */
  44409. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  44410. /**
  44411. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  44412. * @param id defines the id to search for
  44413. * @return the found morph target or null if not found at all.
  44414. */
  44415. getMorphTargetById(id: string): Nullable<MorphTarget>;
  44416. /**
  44417. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  44418. * @param name defines the name to search for
  44419. * @return the found morph target or null if not found at all.
  44420. */
  44421. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  44422. /**
  44423. * Gets a post process using a given name (if many are found, this function will pick the first one)
  44424. * @param name defines the name to search for
  44425. * @return the found post process or null if not found at all.
  44426. */
  44427. getPostProcessByName(name: string): Nullable<PostProcess>;
  44428. /**
  44429. * Gets a boolean indicating if the given mesh is active
  44430. * @param mesh defines the mesh to look for
  44431. * @returns true if the mesh is in the active list
  44432. */
  44433. isActiveMesh(mesh: AbstractMesh): boolean;
  44434. /**
  44435. * Return a unique id as a string which can serve as an identifier for the scene
  44436. */
  44437. get uid(): string;
  44438. /**
  44439. * Add an externaly attached data from its key.
  44440. * This method call will fail and return false, if such key already exists.
  44441. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  44442. * @param key the unique key that identifies the data
  44443. * @param data the data object to associate to the key for this Engine instance
  44444. * @return true if no such key were already present and the data was added successfully, false otherwise
  44445. */
  44446. addExternalData<T>(key: string, data: T): boolean;
  44447. /**
  44448. * Get an externaly attached data from its key
  44449. * @param key the unique key that identifies the data
  44450. * @return the associated data, if present (can be null), or undefined if not present
  44451. */
  44452. getExternalData<T>(key: string): Nullable<T>;
  44453. /**
  44454. * Get an externaly attached data from its key, create it using a factory if it's not already present
  44455. * @param key the unique key that identifies the data
  44456. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  44457. * @return the associated data, can be null if the factory returned null.
  44458. */
  44459. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  44460. /**
  44461. * Remove an externaly attached data from the Engine instance
  44462. * @param key the unique key that identifies the data
  44463. * @return true if the data was successfully removed, false if it doesn't exist
  44464. */
  44465. removeExternalData(key: string): boolean;
  44466. private _evaluateSubMesh;
  44467. /**
  44468. * Clear the processed materials smart array preventing retention point in material dispose.
  44469. */
  44470. freeProcessedMaterials(): void;
  44471. private _preventFreeActiveMeshesAndRenderingGroups;
  44472. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  44473. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  44474. * when disposing several meshes in a row or a hierarchy of meshes.
  44475. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  44476. */
  44477. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  44478. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  44479. /**
  44480. * Clear the active meshes smart array preventing retention point in mesh dispose.
  44481. */
  44482. freeActiveMeshes(): void;
  44483. /**
  44484. * Clear the info related to rendering groups preventing retention points during dispose.
  44485. */
  44486. freeRenderingGroups(): void;
  44487. /** @hidden */
  44488. _isInIntermediateRendering(): boolean;
  44489. /**
  44490. * Lambda returning the list of potentially active meshes.
  44491. */
  44492. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  44493. /**
  44494. * Lambda returning the list of potentially active sub meshes.
  44495. */
  44496. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  44497. /**
  44498. * Lambda returning the list of potentially intersecting sub meshes.
  44499. */
  44500. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  44501. /**
  44502. * Lambda returning the list of potentially colliding sub meshes.
  44503. */
  44504. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  44505. /** @hidden */
  44506. _activeMeshesFrozen: boolean;
  44507. private _skipEvaluateActiveMeshesCompletely;
  44508. /**
  44509. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  44510. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  44511. * @param onSuccess optional success callback
  44512. * @param onError optional error callback
  44513. * @returns the current scene
  44514. */
  44515. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean, onSuccess?: () => void, onError?: (message: string) => void): Scene;
  44516. /**
  44517. * Use this function to restart evaluating active meshes on every frame
  44518. * @returns the current scene
  44519. */
  44520. unfreezeActiveMeshes(): Scene;
  44521. private _evaluateActiveMeshes;
  44522. private _activeMesh;
  44523. /**
  44524. * Update the transform matrix to update from the current active camera
  44525. * @param force defines a boolean used to force the update even if cache is up to date
  44526. */
  44527. updateTransformMatrix(force?: boolean): void;
  44528. private _bindFrameBuffer;
  44529. /** @hidden */
  44530. _allowPostProcessClearColor: boolean;
  44531. /** @hidden */
  44532. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  44533. private _processSubCameras;
  44534. private _checkIntersections;
  44535. /** @hidden */
  44536. _advancePhysicsEngineStep(step: number): void;
  44537. /**
  44538. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  44539. */
  44540. getDeterministicFrameTime: () => number;
  44541. /** @hidden */
  44542. _animate(): void;
  44543. /** Execute all animations (for a frame) */
  44544. animate(): void;
  44545. /**
  44546. * Render the scene
  44547. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  44548. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  44549. */
  44550. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  44551. /**
  44552. * Freeze all materials
  44553. * A frozen material will not be updatable but should be faster to render
  44554. */
  44555. freezeMaterials(): void;
  44556. /**
  44557. * Unfreeze all materials
  44558. * A frozen material will not be updatable but should be faster to render
  44559. */
  44560. unfreezeMaterials(): void;
  44561. /**
  44562. * Releases all held ressources
  44563. */
  44564. dispose(): void;
  44565. /**
  44566. * Gets if the scene is already disposed
  44567. */
  44568. get isDisposed(): boolean;
  44569. /**
  44570. * Call this function to reduce memory footprint of the scene.
  44571. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  44572. */
  44573. clearCachedVertexData(): void;
  44574. /**
  44575. * This function will remove the local cached buffer data from texture.
  44576. * It will save memory but will prevent the texture from being rebuilt
  44577. */
  44578. cleanCachedTextureBuffer(): void;
  44579. /**
  44580. * Get the world extend vectors with an optional filter
  44581. *
  44582. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  44583. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  44584. */
  44585. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  44586. min: Vector3;
  44587. max: Vector3;
  44588. };
  44589. /**
  44590. * Creates a ray that can be used to pick in the scene
  44591. * @param x defines the x coordinate of the origin (on-screen)
  44592. * @param y defines the y coordinate of the origin (on-screen)
  44593. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  44594. * @param camera defines the camera to use for the picking
  44595. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  44596. * @returns a Ray
  44597. */
  44598. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  44599. /**
  44600. * Creates a ray that can be used to pick in the scene
  44601. * @param x defines the x coordinate of the origin (on-screen)
  44602. * @param y defines the y coordinate of the origin (on-screen)
  44603. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  44604. * @param result defines the ray where to store the picking ray
  44605. * @param camera defines the camera to use for the picking
  44606. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  44607. * @returns the current scene
  44608. */
  44609. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  44610. /**
  44611. * Creates a ray that can be used to pick in the scene
  44612. * @param x defines the x coordinate of the origin (on-screen)
  44613. * @param y defines the y coordinate of the origin (on-screen)
  44614. * @param camera defines the camera to use for the picking
  44615. * @returns a Ray
  44616. */
  44617. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  44618. /**
  44619. * Creates a ray that can be used to pick in the scene
  44620. * @param x defines the x coordinate of the origin (on-screen)
  44621. * @param y defines the y coordinate of the origin (on-screen)
  44622. * @param result defines the ray where to store the picking ray
  44623. * @param camera defines the camera to use for the picking
  44624. * @returns the current scene
  44625. */
  44626. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  44627. /** Launch a ray to try to pick a mesh in the scene
  44628. * @param x position on screen
  44629. * @param y position on screen
  44630. * @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
  44631. * @param fastCheck defines if the first intersection will be used (and not the closest)
  44632. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  44633. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  44634. * @returns a PickingInfo
  44635. */
  44636. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  44637. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  44638. * @param x position on screen
  44639. * @param y position on screen
  44640. * @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
  44641. * @param fastCheck defines if the first intersection will be used (and not the closest)
  44642. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  44643. * @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)
  44644. */
  44645. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  44646. /** Use the given ray to pick a mesh in the scene
  44647. * @param ray The ray to use to pick meshes
  44648. * @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
  44649. * @param fastCheck defines if the first intersection will be used (and not the closest)
  44650. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  44651. * @returns a PickingInfo
  44652. */
  44653. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  44654. /**
  44655. * Launch a ray to try to pick a mesh in the scene
  44656. * @param x X position on screen
  44657. * @param y Y position on screen
  44658. * @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
  44659. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  44660. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  44661. * @returns an array of PickingInfo
  44662. */
  44663. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  44664. /**
  44665. * Launch a ray to try to pick a mesh in the scene
  44666. * @param ray Ray to use
  44667. * @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
  44668. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  44669. * @returns an array of PickingInfo
  44670. */
  44671. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  44672. /**
  44673. * Force the value of meshUnderPointer
  44674. * @param mesh defines the mesh to use
  44675. * @param pointerId optional pointer id when using more than one pointer
  44676. */
  44677. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  44678. /**
  44679. * Gets the mesh under the pointer
  44680. * @returns a Mesh or null if no mesh is under the pointer
  44681. */
  44682. getPointerOverMesh(): Nullable<AbstractMesh>;
  44683. /** @hidden */
  44684. _rebuildGeometries(): void;
  44685. /** @hidden */
  44686. _rebuildTextures(): void;
  44687. private _getByTags;
  44688. /**
  44689. * Get a list of meshes by tags
  44690. * @param tagsQuery defines the tags query to use
  44691. * @param forEach defines a predicate used to filter results
  44692. * @returns an array of Mesh
  44693. */
  44694. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  44695. /**
  44696. * Get a list of cameras by tags
  44697. * @param tagsQuery defines the tags query to use
  44698. * @param forEach defines a predicate used to filter results
  44699. * @returns an array of Camera
  44700. */
  44701. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  44702. /**
  44703. * Get a list of lights by tags
  44704. * @param tagsQuery defines the tags query to use
  44705. * @param forEach defines a predicate used to filter results
  44706. * @returns an array of Light
  44707. */
  44708. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  44709. /**
  44710. * Get a list of materials by tags
  44711. * @param tagsQuery defines the tags query to use
  44712. * @param forEach defines a predicate used to filter results
  44713. * @returns an array of Material
  44714. */
  44715. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  44716. /**
  44717. * Get a list of transform nodes by tags
  44718. * @param tagsQuery defines the tags query to use
  44719. * @param forEach defines a predicate used to filter results
  44720. * @returns an array of TransformNode
  44721. */
  44722. getTransformNodesByTags(tagsQuery: string, forEach?: (transform: TransformNode) => void): TransformNode[];
  44723. /**
  44724. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  44725. * This allowed control for front to back rendering or reversly depending of the special needs.
  44726. *
  44727. * @param renderingGroupId The rendering group id corresponding to its index
  44728. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  44729. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  44730. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  44731. */
  44732. 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;
  44733. /**
  44734. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  44735. *
  44736. * @param renderingGroupId The rendering group id corresponding to its index
  44737. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  44738. * @param depth Automatically clears depth between groups if true and autoClear is true.
  44739. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  44740. */
  44741. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  44742. /**
  44743. * Gets the current auto clear configuration for one rendering group of the rendering
  44744. * manager.
  44745. * @param index the rendering group index to get the information for
  44746. * @returns The auto clear setup for the requested rendering group
  44747. */
  44748. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  44749. private _blockMaterialDirtyMechanism;
  44750. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  44751. get blockMaterialDirtyMechanism(): boolean;
  44752. set blockMaterialDirtyMechanism(value: boolean);
  44753. /**
  44754. * Will flag all materials as dirty to trigger new shader compilation
  44755. * @param flag defines the flag used to specify which material part must be marked as dirty
  44756. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  44757. */
  44758. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  44759. /** @hidden */
  44760. _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;
  44761. /** @hidden */
  44762. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  44763. /** @hidden */
  44764. _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;
  44765. /** @hidden */
  44766. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  44767. /** @hidden */
  44768. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  44769. /** @hidden */
  44770. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  44771. }
  44772. }
  44773. declare module BABYLON {
  44774. /**
  44775. * Set of assets to keep when moving a scene into an asset container.
  44776. */
  44777. export class KeepAssets extends AbstractScene {
  44778. }
  44779. /**
  44780. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  44781. */
  44782. export class InstantiatedEntries {
  44783. /**
  44784. * List of new root nodes (eg. nodes with no parent)
  44785. */
  44786. rootNodes: TransformNode[];
  44787. /**
  44788. * List of new skeletons
  44789. */
  44790. skeletons: Skeleton[];
  44791. /**
  44792. * List of new animation groups
  44793. */
  44794. animationGroups: AnimationGroup[];
  44795. }
  44796. /**
  44797. * Container with a set of assets that can be added or removed from a scene.
  44798. */
  44799. export class AssetContainer extends AbstractScene {
  44800. private _wasAddedToScene;
  44801. /**
  44802. * The scene the AssetContainer belongs to.
  44803. */
  44804. scene: Scene;
  44805. /**
  44806. * Instantiates an AssetContainer.
  44807. * @param scene The scene the AssetContainer belongs to.
  44808. */
  44809. constructor(scene: Scene);
  44810. /**
  44811. * Instantiate or clone all meshes and add the new ones to the scene.
  44812. * Skeletons and animation groups will all be cloned
  44813. * @param nameFunction defines an optional function used to get new names for clones
  44814. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  44815. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  44816. */
  44817. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  44818. /**
  44819. * Adds all the assets from the container to the scene.
  44820. */
  44821. addAllToScene(): void;
  44822. /**
  44823. * Removes all the assets in the container from the scene
  44824. */
  44825. removeAllFromScene(): void;
  44826. /**
  44827. * Disposes all the assets in the container
  44828. */
  44829. dispose(): void;
  44830. private _moveAssets;
  44831. /**
  44832. * Removes all the assets contained in the scene and adds them to the container.
  44833. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  44834. */
  44835. moveAllFromScene(keepAssets?: KeepAssets): void;
  44836. /**
  44837. * 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.
  44838. * @returns the root mesh
  44839. */
  44840. createRootMesh(): Mesh;
  44841. /**
  44842. * Merge animations (direct and animation groups) from this asset container into a scene
  44843. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  44844. * @param animatables set of animatables to retarget to a node from the scene
  44845. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  44846. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  44847. */
  44848. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  44849. }
  44850. }
  44851. declare module BABYLON {
  44852. /**
  44853. * Defines how the parser contract is defined.
  44854. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  44855. */
  44856. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  44857. /**
  44858. * Defines how the individual parser contract is defined.
  44859. * These parser can parse an individual asset
  44860. */
  44861. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  44862. /**
  44863. * Base class of the scene acting as a container for the different elements composing a scene.
  44864. * This class is dynamically extended by the different components of the scene increasing
  44865. * flexibility and reducing coupling
  44866. */
  44867. export abstract class AbstractScene {
  44868. /**
  44869. * Stores the list of available parsers in the application.
  44870. */
  44871. private static _BabylonFileParsers;
  44872. /**
  44873. * Stores the list of available individual parsers in the application.
  44874. */
  44875. private static _IndividualBabylonFileParsers;
  44876. /**
  44877. * Adds a parser in the list of available ones
  44878. * @param name Defines the name of the parser
  44879. * @param parser Defines the parser to add
  44880. */
  44881. static AddParser(name: string, parser: BabylonFileParser): void;
  44882. /**
  44883. * Gets a general parser from the list of avaialble ones
  44884. * @param name Defines the name of the parser
  44885. * @returns the requested parser or null
  44886. */
  44887. static GetParser(name: string): Nullable<BabylonFileParser>;
  44888. /**
  44889. * Adds n individual parser in the list of available ones
  44890. * @param name Defines the name of the parser
  44891. * @param parser Defines the parser to add
  44892. */
  44893. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  44894. /**
  44895. * Gets an individual parser from the list of avaialble ones
  44896. * @param name Defines the name of the parser
  44897. * @returns the requested parser or null
  44898. */
  44899. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  44900. /**
  44901. * Parser json data and populate both a scene and its associated container object
  44902. * @param jsonData Defines the data to parse
  44903. * @param scene Defines the scene to parse the data for
  44904. * @param container Defines the container attached to the parsing sequence
  44905. * @param rootUrl Defines the root url of the data
  44906. */
  44907. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  44908. /**
  44909. * Gets the list of root nodes (ie. nodes with no parent)
  44910. */
  44911. rootNodes: Node[];
  44912. /** All of the cameras added to this scene
  44913. * @see https://doc.babylonjs.com/babylon101/cameras
  44914. */
  44915. cameras: Camera[];
  44916. /**
  44917. * All of the lights added to this scene
  44918. * @see https://doc.babylonjs.com/babylon101/lights
  44919. */
  44920. lights: Light[];
  44921. /**
  44922. * All of the (abstract) meshes added to this scene
  44923. */
  44924. meshes: AbstractMesh[];
  44925. /**
  44926. * The list of skeletons added to the scene
  44927. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  44928. */
  44929. skeletons: Skeleton[];
  44930. /**
  44931. * All of the particle systems added to this scene
  44932. * @see https://doc.babylonjs.com/babylon101/particles
  44933. */
  44934. particleSystems: IParticleSystem[];
  44935. /**
  44936. * Gets a list of Animations associated with the scene
  44937. */
  44938. animations: Animation[];
  44939. /**
  44940. * All of the animation groups added to this scene
  44941. * @see https://doc.babylonjs.com/how_to/group
  44942. */
  44943. animationGroups: AnimationGroup[];
  44944. /**
  44945. * All of the multi-materials added to this scene
  44946. * @see https://doc.babylonjs.com/how_to/multi_materials
  44947. */
  44948. multiMaterials: MultiMaterial[];
  44949. /**
  44950. * All of the materials added to this scene
  44951. * In the context of a Scene, it is not supposed to be modified manually.
  44952. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  44953. * Note also that the order of the Material within the array is not significant and might change.
  44954. * @see https://doc.babylonjs.com/babylon101/materials
  44955. */
  44956. materials: Material[];
  44957. /**
  44958. * The list of morph target managers added to the scene
  44959. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  44960. */
  44961. morphTargetManagers: MorphTargetManager[];
  44962. /**
  44963. * The list of geometries used in the scene.
  44964. */
  44965. geometries: Geometry[];
  44966. /**
  44967. * All of the tranform nodes added to this scene
  44968. * In the context of a Scene, it is not supposed to be modified manually.
  44969. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  44970. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  44971. * @see https://doc.babylonjs.com/how_to/transformnode
  44972. */
  44973. transformNodes: TransformNode[];
  44974. /**
  44975. * ActionManagers available on the scene.
  44976. */
  44977. actionManagers: AbstractActionManager[];
  44978. /**
  44979. * Textures to keep.
  44980. */
  44981. textures: BaseTexture[];
  44982. /** @hidden */
  44983. protected _environmentTexture: Nullable<BaseTexture>;
  44984. /**
  44985. * Texture used in all pbr material as the reflection texture.
  44986. * As in the majority of the scene they are the same (exception for multi room and so on),
  44987. * this is easier to reference from here than from all the materials.
  44988. */
  44989. get environmentTexture(): Nullable<BaseTexture>;
  44990. set environmentTexture(value: Nullable<BaseTexture>);
  44991. /**
  44992. * The list of postprocesses added to the scene
  44993. */
  44994. postProcesses: PostProcess[];
  44995. /**
  44996. * @returns all meshes, lights, cameras, transformNodes and bones
  44997. */
  44998. getNodes(): Array<Node>;
  44999. }
  45000. }
  45001. declare module BABYLON {
  45002. /**
  45003. * Interface used to define options for Sound class
  45004. */
  45005. export interface ISoundOptions {
  45006. /**
  45007. * Does the sound autoplay once loaded.
  45008. */
  45009. autoplay?: boolean;
  45010. /**
  45011. * Does the sound loop after it finishes playing once.
  45012. */
  45013. loop?: boolean;
  45014. /**
  45015. * Sound's volume
  45016. */
  45017. volume?: number;
  45018. /**
  45019. * Is it a spatial sound?
  45020. */
  45021. spatialSound?: boolean;
  45022. /**
  45023. * Maximum distance to hear that sound
  45024. */
  45025. maxDistance?: number;
  45026. /**
  45027. * Uses user defined attenuation function
  45028. */
  45029. useCustomAttenuation?: boolean;
  45030. /**
  45031. * Define the roll off factor of spatial sounds.
  45032. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  45033. */
  45034. rolloffFactor?: number;
  45035. /**
  45036. * Define the reference distance the sound should be heard perfectly.
  45037. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  45038. */
  45039. refDistance?: number;
  45040. /**
  45041. * Define the distance attenuation model the sound will follow.
  45042. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  45043. */
  45044. distanceModel?: string;
  45045. /**
  45046. * Defines the playback speed (1 by default)
  45047. */
  45048. playbackRate?: number;
  45049. /**
  45050. * Defines if the sound is from a streaming source
  45051. */
  45052. streaming?: boolean;
  45053. /**
  45054. * Defines an optional length (in seconds) inside the sound file
  45055. */
  45056. length?: number;
  45057. /**
  45058. * Defines an optional offset (in seconds) inside the sound file
  45059. */
  45060. offset?: number;
  45061. /**
  45062. * If true, URLs will not be required to state the audio file codec to use.
  45063. */
  45064. skipCodecCheck?: boolean;
  45065. }
  45066. }
  45067. declare module BABYLON {
  45068. /**
  45069. * Defines a sound that can be played in the application.
  45070. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  45071. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  45072. */
  45073. export class Sound {
  45074. /**
  45075. * The name of the sound in the scene.
  45076. */
  45077. name: string;
  45078. /**
  45079. * Does the sound autoplay once loaded.
  45080. */
  45081. autoplay: boolean;
  45082. /**
  45083. * Does the sound loop after it finishes playing once.
  45084. */
  45085. loop: boolean;
  45086. /**
  45087. * Does the sound use a custom attenuation curve to simulate the falloff
  45088. * happening when the source gets further away from the camera.
  45089. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  45090. */
  45091. useCustomAttenuation: boolean;
  45092. /**
  45093. * The sound track id this sound belongs to.
  45094. */
  45095. soundTrackId: number;
  45096. /**
  45097. * Is this sound currently played.
  45098. */
  45099. isPlaying: boolean;
  45100. /**
  45101. * Is this sound currently paused.
  45102. */
  45103. isPaused: boolean;
  45104. /**
  45105. * Does this sound enables spatial sound.
  45106. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  45107. */
  45108. spatialSound: boolean;
  45109. /**
  45110. * Define the reference distance the sound should be heard perfectly.
  45111. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  45112. */
  45113. refDistance: number;
  45114. /**
  45115. * Define the roll off factor of spatial sounds.
  45116. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  45117. */
  45118. rolloffFactor: number;
  45119. /**
  45120. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  45121. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  45122. */
  45123. maxDistance: number;
  45124. /**
  45125. * Define the distance attenuation model the sound will follow.
  45126. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  45127. */
  45128. distanceModel: string;
  45129. /**
  45130. * @hidden
  45131. * Back Compat
  45132. **/
  45133. onended: () => any;
  45134. /**
  45135. * Gets or sets an object used to store user defined information for the sound.
  45136. */
  45137. metadata: any;
  45138. /**
  45139. * Observable event when the current playing sound finishes.
  45140. */
  45141. onEndedObservable: Observable<Sound>;
  45142. /**
  45143. * Gets the current time for the sound.
  45144. */
  45145. get currentTime(): number;
  45146. private _panningModel;
  45147. private _playbackRate;
  45148. private _streaming;
  45149. private _startTime;
  45150. private _startOffset;
  45151. private _position;
  45152. /** @hidden */
  45153. _positionInEmitterSpace: boolean;
  45154. private _localDirection;
  45155. private _volume;
  45156. private _isReadyToPlay;
  45157. private _isDirectional;
  45158. private _readyToPlayCallback;
  45159. private _audioBuffer;
  45160. private _soundSource;
  45161. private _streamingSource;
  45162. private _soundPanner;
  45163. private _soundGain;
  45164. private _inputAudioNode;
  45165. private _outputAudioNode;
  45166. private _coneInnerAngle;
  45167. private _coneOuterAngle;
  45168. private _coneOuterGain;
  45169. private _scene;
  45170. private _connectedTransformNode;
  45171. private _customAttenuationFunction;
  45172. private _registerFunc;
  45173. private _isOutputConnected;
  45174. private _htmlAudioElement;
  45175. private _urlType;
  45176. private _length?;
  45177. private _offset?;
  45178. /** @hidden */
  45179. static _SceneComponentInitialization: (scene: Scene) => void;
  45180. /**
  45181. * Create a sound and attach it to a scene
  45182. * @param name Name of your sound
  45183. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  45184. * @param scene defines the scene the sound belongs to
  45185. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  45186. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  45187. */
  45188. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  45189. /**
  45190. * Release the sound and its associated resources
  45191. */
  45192. dispose(): void;
  45193. /**
  45194. * Gets if the sounds is ready to be played or not.
  45195. * @returns true if ready, otherwise false
  45196. */
  45197. isReady(): boolean;
  45198. private _soundLoaded;
  45199. /**
  45200. * Sets the data of the sound from an audiobuffer
  45201. * @param audioBuffer The audioBuffer containing the data
  45202. */
  45203. setAudioBuffer(audioBuffer: AudioBuffer): void;
  45204. /**
  45205. * Updates the current sounds options such as maxdistance, loop...
  45206. * @param options A JSON object containing values named as the object properties
  45207. */
  45208. updateOptions(options: ISoundOptions): void;
  45209. private _createSpatialParameters;
  45210. private _updateSpatialParameters;
  45211. /**
  45212. * Switch the panning model to HRTF:
  45213. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  45214. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  45215. */
  45216. switchPanningModelToHRTF(): void;
  45217. /**
  45218. * Switch the panning model to Equal Power:
  45219. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  45220. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  45221. */
  45222. switchPanningModelToEqualPower(): void;
  45223. private _switchPanningModel;
  45224. /**
  45225. * Connect this sound to a sound track audio node like gain...
  45226. * @param soundTrackAudioNode the sound track audio node to connect to
  45227. */
  45228. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  45229. /**
  45230. * Transform this sound into a directional source
  45231. * @param coneInnerAngle Size of the inner cone in degree
  45232. * @param coneOuterAngle Size of the outer cone in degree
  45233. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  45234. */
  45235. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  45236. /**
  45237. * Gets or sets the inner angle for the directional cone.
  45238. */
  45239. get directionalConeInnerAngle(): number;
  45240. /**
  45241. * Gets or sets the inner angle for the directional cone.
  45242. */
  45243. set directionalConeInnerAngle(value: number);
  45244. /**
  45245. * Gets or sets the outer angle for the directional cone.
  45246. */
  45247. get directionalConeOuterAngle(): number;
  45248. /**
  45249. * Gets or sets the outer angle for the directional cone.
  45250. */
  45251. set directionalConeOuterAngle(value: number);
  45252. /**
  45253. * Sets the position of the emitter if spatial sound is enabled
  45254. * @param newPosition Defines the new posisiton
  45255. */
  45256. setPosition(newPosition: Vector3): void;
  45257. /**
  45258. * Sets the local direction of the emitter if spatial sound is enabled
  45259. * @param newLocalDirection Defines the new local direction
  45260. */
  45261. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  45262. private _updateDirection;
  45263. /** @hidden */
  45264. updateDistanceFromListener(): void;
  45265. /**
  45266. * Sets a new custom attenuation function for the sound.
  45267. * @param callback Defines the function used for the attenuation
  45268. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  45269. */
  45270. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  45271. /**
  45272. * Play the sound
  45273. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  45274. * @param offset (optional) Start the sound at a specific time in seconds
  45275. * @param length (optional) Sound duration (in seconds)
  45276. */
  45277. play(time?: number, offset?: number, length?: number): void;
  45278. private _onended;
  45279. /**
  45280. * Stop the sound
  45281. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  45282. */
  45283. stop(time?: number): void;
  45284. /**
  45285. * Put the sound in pause
  45286. */
  45287. pause(): void;
  45288. /**
  45289. * Sets a dedicated volume for this sounds
  45290. * @param newVolume Define the new volume of the sound
  45291. * @param time Define time for gradual change to new volume
  45292. */
  45293. setVolume(newVolume: number, time?: number): void;
  45294. /**
  45295. * Set the sound play back rate
  45296. * @param newPlaybackRate Define the playback rate the sound should be played at
  45297. */
  45298. setPlaybackRate(newPlaybackRate: number): void;
  45299. /**
  45300. * Gets the volume of the sound.
  45301. * @returns the volume of the sound
  45302. */
  45303. getVolume(): number;
  45304. /**
  45305. * Attach the sound to a dedicated mesh
  45306. * @param transformNode The transform node to connect the sound with
  45307. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  45308. */
  45309. attachToMesh(transformNode: TransformNode): void;
  45310. /**
  45311. * Detach the sound from the previously attached mesh
  45312. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  45313. */
  45314. detachFromMesh(): void;
  45315. private _onRegisterAfterWorldMatrixUpdate;
  45316. /**
  45317. * Clone the current sound in the scene.
  45318. * @returns the new sound clone
  45319. */
  45320. clone(): Nullable<Sound>;
  45321. /**
  45322. * Gets the current underlying audio buffer containing the data
  45323. * @returns the audio buffer
  45324. */
  45325. getAudioBuffer(): Nullable<AudioBuffer>;
  45326. /**
  45327. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  45328. * @returns the source node
  45329. */
  45330. getSoundSource(): Nullable<AudioBufferSourceNode>;
  45331. /**
  45332. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  45333. * @returns the gain node
  45334. */
  45335. getSoundGain(): Nullable<GainNode>;
  45336. /**
  45337. * Serializes the Sound in a JSON representation
  45338. * @returns the JSON representation of the sound
  45339. */
  45340. serialize(): any;
  45341. /**
  45342. * Parse a JSON representation of a sound to innstantiate in a given scene
  45343. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  45344. * @param scene Define the scene the new parsed sound should be created in
  45345. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  45346. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  45347. * @returns the newly parsed sound
  45348. */
  45349. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  45350. }
  45351. }
  45352. declare module BABYLON {
  45353. /**
  45354. * This defines an action helpful to play a defined sound on a triggered action.
  45355. */
  45356. export class PlaySoundAction extends Action {
  45357. private _sound;
  45358. /**
  45359. * Instantiate the action
  45360. * @param triggerOptions defines the trigger options
  45361. * @param sound defines the sound to play
  45362. * @param condition defines the trigger related conditions
  45363. */
  45364. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  45365. /** @hidden */
  45366. _prepare(): void;
  45367. /**
  45368. * Execute the action and play the sound.
  45369. */
  45370. execute(): void;
  45371. /**
  45372. * Serializes the actions and its related information.
  45373. * @param parent defines the object to serialize in
  45374. * @returns the serialized object
  45375. */
  45376. serialize(parent: any): any;
  45377. }
  45378. /**
  45379. * This defines an action helpful to stop a defined sound on a triggered action.
  45380. */
  45381. export class StopSoundAction extends Action {
  45382. private _sound;
  45383. /**
  45384. * Instantiate the action
  45385. * @param triggerOptions defines the trigger options
  45386. * @param sound defines the sound to stop
  45387. * @param condition defines the trigger related conditions
  45388. */
  45389. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  45390. /** @hidden */
  45391. _prepare(): void;
  45392. /**
  45393. * Execute the action and stop the sound.
  45394. */
  45395. execute(): void;
  45396. /**
  45397. * Serializes the actions and its related information.
  45398. * @param parent defines the object to serialize in
  45399. * @returns the serialized object
  45400. */
  45401. serialize(parent: any): any;
  45402. }
  45403. }
  45404. declare module BABYLON {
  45405. /**
  45406. * This defines an action responsible to change the value of a property
  45407. * by interpolating between its current value and the newly set one once triggered.
  45408. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  45409. */
  45410. export class InterpolateValueAction extends Action {
  45411. /**
  45412. * Defines the path of the property where the value should be interpolated
  45413. */
  45414. propertyPath: string;
  45415. /**
  45416. * Defines the target value at the end of the interpolation.
  45417. */
  45418. value: any;
  45419. /**
  45420. * Defines the time it will take for the property to interpolate to the value.
  45421. */
  45422. duration: number;
  45423. /**
  45424. * Defines if the other scene animations should be stopped when the action has been triggered
  45425. */
  45426. stopOtherAnimations?: boolean;
  45427. /**
  45428. * Defines a callback raised once the interpolation animation has been done.
  45429. */
  45430. onInterpolationDone?: () => void;
  45431. /**
  45432. * Observable triggered once the interpolation animation has been done.
  45433. */
  45434. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  45435. private _target;
  45436. private _effectiveTarget;
  45437. private _property;
  45438. /**
  45439. * Instantiate the action
  45440. * @param triggerOptions defines the trigger options
  45441. * @param target defines the object containing the value to interpolate
  45442. * @param propertyPath defines the path to the property in the target object
  45443. * @param value defines the target value at the end of the interpolation
  45444. * @param duration deines the time it will take for the property to interpolate to the value.
  45445. * @param condition defines the trigger related conditions
  45446. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  45447. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  45448. */
  45449. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  45450. /** @hidden */
  45451. _prepare(): void;
  45452. /**
  45453. * Execute the action starts the value interpolation.
  45454. */
  45455. execute(): void;
  45456. /**
  45457. * Serializes the actions and its related information.
  45458. * @param parent defines the object to serialize in
  45459. * @returns the serialized object
  45460. */
  45461. serialize(parent: any): any;
  45462. }
  45463. }
  45464. declare module BABYLON {
  45465. /**
  45466. * This represents the default audio engine used in babylon.
  45467. * It is responsible to play, synchronize and analyse sounds throughout the application.
  45468. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  45469. */
  45470. export class AudioEngine implements IAudioEngine {
  45471. private _audioContext;
  45472. private _audioContextInitialized;
  45473. private _muteButton;
  45474. private _hostElement;
  45475. /**
  45476. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  45477. */
  45478. canUseWebAudio: boolean;
  45479. /**
  45480. * The master gain node defines the global audio volume of your audio engine.
  45481. */
  45482. masterGain: GainNode;
  45483. /**
  45484. * Defines if Babylon should emit a warning if WebAudio is not supported.
  45485. * @ignoreNaming
  45486. */
  45487. WarnedWebAudioUnsupported: boolean;
  45488. /**
  45489. * Gets whether or not mp3 are supported by your browser.
  45490. */
  45491. isMP3supported: boolean;
  45492. /**
  45493. * Gets whether or not ogg are supported by your browser.
  45494. */
  45495. isOGGsupported: boolean;
  45496. /**
  45497. * Gets whether audio has been unlocked on the device.
  45498. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  45499. * a user interaction has happened.
  45500. */
  45501. unlocked: boolean;
  45502. /**
  45503. * Defines if the audio engine relies on a custom unlocked button.
  45504. * In this case, the embedded button will not be displayed.
  45505. */
  45506. useCustomUnlockedButton: boolean;
  45507. /**
  45508. * Event raised when audio has been unlocked on the browser.
  45509. */
  45510. onAudioUnlockedObservable: Observable<IAudioEngine>;
  45511. /**
  45512. * Event raised when audio has been locked on the browser.
  45513. */
  45514. onAudioLockedObservable: Observable<IAudioEngine>;
  45515. /**
  45516. * Gets the current AudioContext if available.
  45517. */
  45518. get audioContext(): Nullable<AudioContext>;
  45519. private _connectedAnalyser;
  45520. /**
  45521. * Instantiates a new audio engine.
  45522. *
  45523. * There should be only one per page as some browsers restrict the number
  45524. * of audio contexts you can create.
  45525. * @param hostElement defines the host element where to display the mute icon if necessary
  45526. */
  45527. constructor(hostElement?: Nullable<HTMLElement>);
  45528. /**
  45529. * Flags the audio engine in Locked state.
  45530. * This happens due to new browser policies preventing audio to autoplay.
  45531. */
  45532. lock(): void;
  45533. /**
  45534. * Unlocks the audio engine once a user action has been done on the dom.
  45535. * This is helpful to resume play once browser policies have been satisfied.
  45536. */
  45537. unlock(): void;
  45538. private _resumeAudioContext;
  45539. private _initializeAudioContext;
  45540. private _tryToRun;
  45541. private _triggerRunningState;
  45542. private _triggerSuspendedState;
  45543. private _displayMuteButton;
  45544. private _moveButtonToTopLeft;
  45545. private _onResize;
  45546. private _hideMuteButton;
  45547. /**
  45548. * Destroy and release the resources associated with the audio ccontext.
  45549. */
  45550. dispose(): void;
  45551. /**
  45552. * Gets the global volume sets on the master gain.
  45553. * @returns the global volume if set or -1 otherwise
  45554. */
  45555. getGlobalVolume(): number;
  45556. /**
  45557. * Sets the global volume of your experience (sets on the master gain).
  45558. * @param newVolume Defines the new global volume of the application
  45559. */
  45560. setGlobalVolume(newVolume: number): void;
  45561. /**
  45562. * Connect the audio engine to an audio analyser allowing some amazing
  45563. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  45564. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  45565. * @param analyser The analyser to connect to the engine
  45566. */
  45567. connectToAnalyser(analyser: Analyser): void;
  45568. }
  45569. }
  45570. declare module BABYLON {
  45571. /**
  45572. * Options allowed during the creation of a sound track.
  45573. */
  45574. export interface ISoundTrackOptions {
  45575. /**
  45576. * The volume the sound track should take during creation
  45577. */
  45578. volume?: number;
  45579. /**
  45580. * Define if the sound track is the main sound track of the scene
  45581. */
  45582. mainTrack?: boolean;
  45583. }
  45584. /**
  45585. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  45586. * It will be also used in a future release to apply effects on a specific track.
  45587. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  45588. */
  45589. export class SoundTrack {
  45590. /**
  45591. * The unique identifier of the sound track in the scene.
  45592. */
  45593. id: number;
  45594. /**
  45595. * The list of sounds included in the sound track.
  45596. */
  45597. soundCollection: Array<Sound>;
  45598. private _outputAudioNode;
  45599. private _scene;
  45600. private _connectedAnalyser;
  45601. private _options;
  45602. private _isInitialized;
  45603. /**
  45604. * Creates a new sound track.
  45605. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  45606. * @param scene Define the scene the sound track belongs to
  45607. * @param options
  45608. */
  45609. constructor(scene: Scene, options?: ISoundTrackOptions);
  45610. private _initializeSoundTrackAudioGraph;
  45611. /**
  45612. * Release the sound track and its associated resources
  45613. */
  45614. dispose(): void;
  45615. /**
  45616. * Adds a sound to this sound track
  45617. * @param sound define the cound to add
  45618. * @ignoreNaming
  45619. */
  45620. addSound(sound: Sound): void;
  45621. /**
  45622. * Removes a sound to this sound track
  45623. * @param sound define the cound to remove
  45624. * @ignoreNaming
  45625. */
  45626. removeSound(sound: Sound): void;
  45627. /**
  45628. * Set a global volume for the full sound track.
  45629. * @param newVolume Define the new volume of the sound track
  45630. */
  45631. setVolume(newVolume: number): void;
  45632. /**
  45633. * Switch the panning model to HRTF:
  45634. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  45635. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  45636. */
  45637. switchPanningModelToHRTF(): void;
  45638. /**
  45639. * Switch the panning model to Equal Power:
  45640. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  45641. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  45642. */
  45643. switchPanningModelToEqualPower(): void;
  45644. /**
  45645. * Connect the sound track to an audio analyser allowing some amazing
  45646. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  45647. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  45648. * @param analyser The analyser to connect to the engine
  45649. */
  45650. connectToAnalyser(analyser: Analyser): void;
  45651. }
  45652. }
  45653. declare module BABYLON {
  45654. interface AbstractScene {
  45655. /**
  45656. * The list of sounds used in the scene.
  45657. */
  45658. sounds: Nullable<Array<Sound>>;
  45659. }
  45660. interface Scene {
  45661. /**
  45662. * @hidden
  45663. * Backing field
  45664. */
  45665. _mainSoundTrack: SoundTrack;
  45666. /**
  45667. * The main sound track played by the scene.
  45668. * It cotains your primary collection of sounds.
  45669. */
  45670. mainSoundTrack: SoundTrack;
  45671. /**
  45672. * The list of sound tracks added to the scene
  45673. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  45674. */
  45675. soundTracks: Nullable<Array<SoundTrack>>;
  45676. /**
  45677. * Gets a sound using a given name
  45678. * @param name defines the name to search for
  45679. * @return the found sound or null if not found at all.
  45680. */
  45681. getSoundByName(name: string): Nullable<Sound>;
  45682. /**
  45683. * Gets or sets if audio support is enabled
  45684. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  45685. */
  45686. audioEnabled: boolean;
  45687. /**
  45688. * Gets or sets if audio will be output to headphones
  45689. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  45690. */
  45691. headphone: boolean;
  45692. /**
  45693. * Gets or sets custom audio listener position provider
  45694. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  45695. */
  45696. audioListenerPositionProvider: Nullable<() => Vector3>;
  45697. /**
  45698. * Gets or sets a refresh rate when using 3D audio positioning
  45699. */
  45700. audioPositioningRefreshRate: number;
  45701. }
  45702. /**
  45703. * Defines the sound scene component responsible to manage any sounds
  45704. * in a given scene.
  45705. */
  45706. export class AudioSceneComponent implements ISceneSerializableComponent {
  45707. private static _CameraDirectionLH;
  45708. private static _CameraDirectionRH;
  45709. /**
  45710. * The component name helpfull to identify the component in the list of scene components.
  45711. */
  45712. readonly name: string;
  45713. /**
  45714. * The scene the component belongs to.
  45715. */
  45716. scene: Scene;
  45717. private _audioEnabled;
  45718. /**
  45719. * Gets whether audio is enabled or not.
  45720. * Please use related enable/disable method to switch state.
  45721. */
  45722. get audioEnabled(): boolean;
  45723. private _headphone;
  45724. /**
  45725. * Gets whether audio is outputing to headphone or not.
  45726. * Please use the according Switch methods to change output.
  45727. */
  45728. get headphone(): boolean;
  45729. /**
  45730. * Gets or sets a refresh rate when using 3D audio positioning
  45731. */
  45732. audioPositioningRefreshRate: number;
  45733. private _audioListenerPositionProvider;
  45734. /**
  45735. * Gets the current audio listener position provider
  45736. */
  45737. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  45738. /**
  45739. * Sets a custom listener position for all sounds in the scene
  45740. * By default, this is the position of the first active camera
  45741. */
  45742. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  45743. /**
  45744. * Creates a new instance of the component for the given scene
  45745. * @param scene Defines the scene to register the component in
  45746. */
  45747. constructor(scene: Scene);
  45748. /**
  45749. * Registers the component in a given scene
  45750. */
  45751. register(): void;
  45752. /**
  45753. * Rebuilds the elements related to this component in case of
  45754. * context lost for instance.
  45755. */
  45756. rebuild(): void;
  45757. /**
  45758. * Serializes the component data to the specified json object
  45759. * @param serializationObject The object to serialize to
  45760. */
  45761. serialize(serializationObject: any): void;
  45762. /**
  45763. * Adds all the elements from the container to the scene
  45764. * @param container the container holding the elements
  45765. */
  45766. addFromContainer(container: AbstractScene): void;
  45767. /**
  45768. * Removes all the elements in the container from the scene
  45769. * @param container contains the elements to remove
  45770. * @param dispose if the removed element should be disposed (default: false)
  45771. */
  45772. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  45773. /**
  45774. * Disposes the component and the associated ressources.
  45775. */
  45776. dispose(): void;
  45777. /**
  45778. * Disables audio in the associated scene.
  45779. */
  45780. disableAudio(): void;
  45781. /**
  45782. * Enables audio in the associated scene.
  45783. */
  45784. enableAudio(): void;
  45785. /**
  45786. * Switch audio to headphone output.
  45787. */
  45788. switchAudioModeForHeadphones(): void;
  45789. /**
  45790. * Switch audio to normal speakers.
  45791. */
  45792. switchAudioModeForNormalSpeakers(): void;
  45793. private _cachedCameraDirection;
  45794. private _cachedCameraPosition;
  45795. private _lastCheck;
  45796. private _afterRender;
  45797. }
  45798. }
  45799. declare module BABYLON {
  45800. /**
  45801. * Wraps one or more Sound objects and selects one with random weight for playback.
  45802. */
  45803. export class WeightedSound {
  45804. /** When true a Sound will be selected and played when the current playing Sound completes. */
  45805. loop: boolean;
  45806. private _coneInnerAngle;
  45807. private _coneOuterAngle;
  45808. private _volume;
  45809. /** A Sound is currently playing. */
  45810. isPlaying: boolean;
  45811. /** A Sound is currently paused. */
  45812. isPaused: boolean;
  45813. private _sounds;
  45814. private _weights;
  45815. private _currentIndex?;
  45816. /**
  45817. * Creates a new WeightedSound from the list of sounds given.
  45818. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  45819. * @param sounds Array of Sounds that will be selected from.
  45820. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  45821. */
  45822. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  45823. /**
  45824. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  45825. */
  45826. get directionalConeInnerAngle(): number;
  45827. /**
  45828. * The size of cone in degress for a directional sound in which there will be no attenuation.
  45829. */
  45830. set directionalConeInnerAngle(value: number);
  45831. /**
  45832. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  45833. * Listener angles between innerAngle and outerAngle will falloff linearly.
  45834. */
  45835. get directionalConeOuterAngle(): number;
  45836. /**
  45837. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  45838. * Listener angles between innerAngle and outerAngle will falloff linearly.
  45839. */
  45840. set directionalConeOuterAngle(value: number);
  45841. /**
  45842. * Playback volume.
  45843. */
  45844. get volume(): number;
  45845. /**
  45846. * Playback volume.
  45847. */
  45848. set volume(value: number);
  45849. private _onended;
  45850. /**
  45851. * Suspend playback
  45852. */
  45853. pause(): void;
  45854. /**
  45855. * Stop playback
  45856. */
  45857. stop(): void;
  45858. /**
  45859. * Start playback.
  45860. * @param startOffset Position the clip head at a specific time in seconds.
  45861. */
  45862. play(startOffset?: number): void;
  45863. }
  45864. }
  45865. declare module BABYLON {
  45866. /**
  45867. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  45868. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  45869. */
  45870. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  45871. /**
  45872. * Gets the name of the behavior.
  45873. */
  45874. get name(): string;
  45875. /**
  45876. * The easing function used by animations
  45877. */
  45878. static EasingFunction: BackEase;
  45879. /**
  45880. * The easing mode used by animations
  45881. */
  45882. static EasingMode: number;
  45883. /**
  45884. * The duration of the animation, in milliseconds
  45885. */
  45886. transitionDuration: number;
  45887. /**
  45888. * Length of the distance animated by the transition when lower radius is reached
  45889. */
  45890. lowerRadiusTransitionRange: number;
  45891. /**
  45892. * Length of the distance animated by the transition when upper radius is reached
  45893. */
  45894. upperRadiusTransitionRange: number;
  45895. private _autoTransitionRange;
  45896. /**
  45897. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  45898. */
  45899. get autoTransitionRange(): boolean;
  45900. /**
  45901. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  45902. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  45903. */
  45904. set autoTransitionRange(value: boolean);
  45905. private _attachedCamera;
  45906. private _onAfterCheckInputsObserver;
  45907. private _onMeshTargetChangedObserver;
  45908. /**
  45909. * Initializes the behavior.
  45910. */
  45911. init(): void;
  45912. /**
  45913. * Attaches the behavior to its arc rotate camera.
  45914. * @param camera Defines the camera to attach the behavior to
  45915. */
  45916. attach(camera: ArcRotateCamera): void;
  45917. /**
  45918. * Detaches the behavior from its current arc rotate camera.
  45919. */
  45920. detach(): void;
  45921. private _radiusIsAnimating;
  45922. private _radiusBounceTransition;
  45923. private _animatables;
  45924. private _cachedWheelPrecision;
  45925. /**
  45926. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  45927. * @param radiusLimit The limit to check against.
  45928. * @return Bool to indicate if at limit.
  45929. */
  45930. private _isRadiusAtLimit;
  45931. /**
  45932. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  45933. * @param radiusDelta The delta by which to animate to. Can be negative.
  45934. */
  45935. private _applyBoundRadiusAnimation;
  45936. /**
  45937. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  45938. */
  45939. protected _clearAnimationLocks(): void;
  45940. /**
  45941. * Stops and removes all animations that have been applied to the camera
  45942. */
  45943. stopAllAnimations(): void;
  45944. }
  45945. }
  45946. declare module BABYLON {
  45947. /**
  45948. * 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.
  45949. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  45950. */
  45951. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  45952. /**
  45953. * Gets the name of the behavior.
  45954. */
  45955. get name(): string;
  45956. private _mode;
  45957. private _radiusScale;
  45958. private _positionScale;
  45959. private _defaultElevation;
  45960. private _elevationReturnTime;
  45961. private _elevationReturnWaitTime;
  45962. private _zoomStopsAnimation;
  45963. private _framingTime;
  45964. /**
  45965. * The easing function used by animations
  45966. */
  45967. static EasingFunction: ExponentialEase;
  45968. /**
  45969. * The easing mode used by animations
  45970. */
  45971. static EasingMode: number;
  45972. /**
  45973. * Sets the current mode used by the behavior
  45974. */
  45975. set mode(mode: number);
  45976. /**
  45977. * Gets current mode used by the behavior.
  45978. */
  45979. get mode(): number;
  45980. /**
  45981. * Sets the scale applied to the radius (1 by default)
  45982. */
  45983. set radiusScale(radius: number);
  45984. /**
  45985. * Gets the scale applied to the radius
  45986. */
  45987. get radiusScale(): number;
  45988. /**
  45989. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  45990. */
  45991. set positionScale(scale: number);
  45992. /**
  45993. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  45994. */
  45995. get positionScale(): number;
  45996. /**
  45997. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  45998. * behaviour is triggered, in radians.
  45999. */
  46000. set defaultElevation(elevation: number);
  46001. /**
  46002. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  46003. * behaviour is triggered, in radians.
  46004. */
  46005. get defaultElevation(): number;
  46006. /**
  46007. * Sets the time (in milliseconds) taken to return to the default beta position.
  46008. * Negative value indicates camera should not return to default.
  46009. */
  46010. set elevationReturnTime(speed: number);
  46011. /**
  46012. * Gets the time (in milliseconds) taken to return to the default beta position.
  46013. * Negative value indicates camera should not return to default.
  46014. */
  46015. get elevationReturnTime(): number;
  46016. /**
  46017. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  46018. */
  46019. set elevationReturnWaitTime(time: number);
  46020. /**
  46021. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  46022. */
  46023. get elevationReturnWaitTime(): number;
  46024. /**
  46025. * Sets the flag that indicates if user zooming should stop animation.
  46026. */
  46027. set zoomStopsAnimation(flag: boolean);
  46028. /**
  46029. * Gets the flag that indicates if user zooming should stop animation.
  46030. */
  46031. get zoomStopsAnimation(): boolean;
  46032. /**
  46033. * Sets the transition time when framing the mesh, in milliseconds
  46034. */
  46035. set framingTime(time: number);
  46036. /**
  46037. * Gets the transition time when framing the mesh, in milliseconds
  46038. */
  46039. get framingTime(): number;
  46040. /**
  46041. * Define if the behavior should automatically change the configured
  46042. * camera limits and sensibilities.
  46043. */
  46044. autoCorrectCameraLimitsAndSensibility: boolean;
  46045. private _onPrePointerObservableObserver;
  46046. private _onAfterCheckInputsObserver;
  46047. private _onMeshTargetChangedObserver;
  46048. private _attachedCamera;
  46049. private _isPointerDown;
  46050. private _lastInteractionTime;
  46051. /**
  46052. * Initializes the behavior.
  46053. */
  46054. init(): void;
  46055. /**
  46056. * Attaches the behavior to its arc rotate camera.
  46057. * @param camera Defines the camera to attach the behavior to
  46058. */
  46059. attach(camera: ArcRotateCamera): void;
  46060. /**
  46061. * Detaches the behavior from its current arc rotate camera.
  46062. */
  46063. detach(): void;
  46064. private _animatables;
  46065. private _betaIsAnimating;
  46066. private _betaTransition;
  46067. private _radiusTransition;
  46068. private _vectorTransition;
  46069. /**
  46070. * Targets the given mesh and updates zoom level accordingly.
  46071. * @param mesh The mesh to target.
  46072. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  46073. * @param onAnimationEnd Callback triggered at the end of the framing animation
  46074. */
  46075. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  46076. /**
  46077. * Targets the given mesh with its children and updates zoom level accordingly.
  46078. * @param mesh The mesh to target.
  46079. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  46080. * @param onAnimationEnd Callback triggered at the end of the framing animation
  46081. */
  46082. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  46083. /**
  46084. * Targets the given meshes with their children and updates zoom level accordingly.
  46085. * @param meshes The mesh to target.
  46086. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  46087. * @param onAnimationEnd Callback triggered at the end of the framing animation
  46088. */
  46089. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  46090. /**
  46091. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  46092. * @param minimumWorld Determines the smaller position of the bounding box extend
  46093. * @param maximumWorld Determines the bigger position of the bounding box extend
  46094. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  46095. * @param onAnimationEnd Callback triggered at the end of the framing animation
  46096. */
  46097. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  46098. /**
  46099. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  46100. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  46101. * frustum width.
  46102. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  46103. * to fully enclose the mesh in the viewing frustum.
  46104. */
  46105. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  46106. /**
  46107. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  46108. * is automatically returned to its default position (expected to be above ground plane).
  46109. */
  46110. private _maintainCameraAboveGround;
  46111. /**
  46112. * Returns the frustum slope based on the canvas ratio and camera FOV
  46113. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  46114. */
  46115. private _getFrustumSlope;
  46116. /**
  46117. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  46118. */
  46119. private _clearAnimationLocks;
  46120. /**
  46121. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  46122. */
  46123. private _applyUserInteraction;
  46124. /**
  46125. * Stops and removes all animations that have been applied to the camera
  46126. */
  46127. stopAllAnimations(): void;
  46128. /**
  46129. * Gets a value indicating if the user is moving the camera
  46130. */
  46131. get isUserIsMoving(): boolean;
  46132. /**
  46133. * The camera can move all the way towards the mesh.
  46134. */
  46135. static IgnoreBoundsSizeMode: number;
  46136. /**
  46137. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  46138. */
  46139. static FitFrustumSidesMode: number;
  46140. }
  46141. }
  46142. declare module BABYLON {
  46143. /**
  46144. * Base class for Camera Pointer Inputs.
  46145. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  46146. * for example usage.
  46147. */
  46148. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  46149. /**
  46150. * Defines the camera the input is attached to.
  46151. */
  46152. abstract camera: Camera;
  46153. /**
  46154. * Whether keyboard modifier keys are pressed at time of last mouse event.
  46155. */
  46156. protected _altKey: boolean;
  46157. protected _ctrlKey: boolean;
  46158. protected _metaKey: boolean;
  46159. protected _shiftKey: boolean;
  46160. /**
  46161. * Which mouse buttons were pressed at time of last mouse event.
  46162. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  46163. */
  46164. protected _buttonsPressed: number;
  46165. /**
  46166. * Defines the buttons associated with the input to handle camera move.
  46167. */
  46168. buttons: number[];
  46169. /**
  46170. * Attach the input controls to a specific dom element to get the input from.
  46171. * @param element Defines the element the controls should be listened from
  46172. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46173. */
  46174. attachControl(noPreventDefault?: boolean): void;
  46175. /**
  46176. * Detach the current controls from the specified dom element.
  46177. */
  46178. detachControl(): void;
  46179. /**
  46180. * Gets the class name of the current input.
  46181. * @returns the class name
  46182. */
  46183. getClassName(): string;
  46184. /**
  46185. * Get the friendly name associated with the input class.
  46186. * @returns the input friendly name
  46187. */
  46188. getSimpleName(): string;
  46189. /**
  46190. * Called on pointer POINTERDOUBLETAP event.
  46191. * Override this method to provide functionality on POINTERDOUBLETAP event.
  46192. */
  46193. protected onDoubleTap(type: string): void;
  46194. /**
  46195. * Called on pointer POINTERMOVE event if only a single touch is active.
  46196. * Override this method to provide functionality.
  46197. */
  46198. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  46199. /**
  46200. * Called on pointer POINTERMOVE event if multiple touches are active.
  46201. * Override this method to provide functionality.
  46202. */
  46203. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  46204. /**
  46205. * Called on JS contextmenu event.
  46206. * Override this method to provide functionality.
  46207. */
  46208. protected onContextMenu(evt: PointerEvent): void;
  46209. /**
  46210. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  46211. * press.
  46212. * Override this method to provide functionality.
  46213. */
  46214. protected onButtonDown(evt: PointerEvent): void;
  46215. /**
  46216. * Called each time a new POINTERUP event occurs. Ie, for each button
  46217. * release.
  46218. * Override this method to provide functionality.
  46219. */
  46220. protected onButtonUp(evt: PointerEvent): void;
  46221. /**
  46222. * Called when window becomes inactive.
  46223. * Override this method to provide functionality.
  46224. */
  46225. protected onLostFocus(): void;
  46226. private _pointerInput;
  46227. private _observer;
  46228. private _onLostFocus;
  46229. private pointA;
  46230. private pointB;
  46231. }
  46232. }
  46233. declare module BABYLON {
  46234. /**
  46235. * Manage the pointers inputs to control an arc rotate camera.
  46236. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46237. */
  46238. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  46239. /**
  46240. * Defines the camera the input is attached to.
  46241. */
  46242. camera: ArcRotateCamera;
  46243. /**
  46244. * Gets the class name of the current input.
  46245. * @returns the class name
  46246. */
  46247. getClassName(): string;
  46248. /**
  46249. * Defines the buttons associated with the input to handle camera move.
  46250. */
  46251. buttons: number[];
  46252. /**
  46253. * Defines the pointer angular sensibility along the X axis or how fast is
  46254. * the camera rotating.
  46255. */
  46256. angularSensibilityX: number;
  46257. /**
  46258. * Defines the pointer angular sensibility along the Y axis or how fast is
  46259. * the camera rotating.
  46260. */
  46261. angularSensibilityY: number;
  46262. /**
  46263. * Defines the pointer pinch precision or how fast is the camera zooming.
  46264. */
  46265. pinchPrecision: number;
  46266. /**
  46267. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  46268. * from 0.
  46269. * It defines the percentage of current camera.radius to use as delta when
  46270. * pinch zoom is used.
  46271. */
  46272. pinchDeltaPercentage: number;
  46273. /**
  46274. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  46275. * that any object in the plane at the camera's target point will scale
  46276. * perfectly with finger motion.
  46277. * Overrides pinchDeltaPercentage and pinchPrecision.
  46278. */
  46279. useNaturalPinchZoom: boolean;
  46280. /**
  46281. * Defines the pointer panning sensibility or how fast is the camera moving.
  46282. */
  46283. panningSensibility: number;
  46284. /**
  46285. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  46286. */
  46287. multiTouchPanning: boolean;
  46288. /**
  46289. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  46290. * zoom (pinch) through multitouch.
  46291. */
  46292. multiTouchPanAndZoom: boolean;
  46293. /**
  46294. * Revers pinch action direction.
  46295. */
  46296. pinchInwards: boolean;
  46297. private _isPanClick;
  46298. private _twoFingerActivityCount;
  46299. private _isPinching;
  46300. /**
  46301. * Called on pointer POINTERMOVE event if only a single touch is active.
  46302. */
  46303. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  46304. /**
  46305. * Called on pointer POINTERDOUBLETAP event.
  46306. */
  46307. protected onDoubleTap(type: string): void;
  46308. /**
  46309. * Called on pointer POINTERMOVE event if multiple touches are active.
  46310. */
  46311. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  46312. /**
  46313. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  46314. * press.
  46315. */
  46316. protected onButtonDown(evt: PointerEvent): void;
  46317. /**
  46318. * Called each time a new POINTERUP event occurs. Ie, for each button
  46319. * release.
  46320. */
  46321. protected onButtonUp(evt: PointerEvent): void;
  46322. /**
  46323. * Called when window becomes inactive.
  46324. */
  46325. protected onLostFocus(): void;
  46326. }
  46327. }
  46328. declare module BABYLON {
  46329. /**
  46330. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  46331. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46332. */
  46333. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  46334. /**
  46335. * Defines the camera the input is attached to.
  46336. */
  46337. camera: ArcRotateCamera;
  46338. /**
  46339. * Defines the list of key codes associated with the up action (increase alpha)
  46340. */
  46341. keysUp: number[];
  46342. /**
  46343. * Defines the list of key codes associated with the down action (decrease alpha)
  46344. */
  46345. keysDown: number[];
  46346. /**
  46347. * Defines the list of key codes associated with the left action (increase beta)
  46348. */
  46349. keysLeft: number[];
  46350. /**
  46351. * Defines the list of key codes associated with the right action (decrease beta)
  46352. */
  46353. keysRight: number[];
  46354. /**
  46355. * Defines the list of key codes associated with the reset action.
  46356. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  46357. */
  46358. keysReset: number[];
  46359. /**
  46360. * Defines the panning sensibility of the inputs.
  46361. * (How fast is the camera panning)
  46362. */
  46363. panningSensibility: number;
  46364. /**
  46365. * Defines the zooming sensibility of the inputs.
  46366. * (How fast is the camera zooming)
  46367. */
  46368. zoomingSensibility: number;
  46369. /**
  46370. * Defines whether maintaining the alt key down switch the movement mode from
  46371. * orientation to zoom.
  46372. */
  46373. useAltToZoom: boolean;
  46374. /**
  46375. * Rotation speed of the camera
  46376. */
  46377. angularSpeed: number;
  46378. private _keys;
  46379. private _ctrlPressed;
  46380. private _altPressed;
  46381. private _onCanvasBlurObserver;
  46382. private _onKeyboardObserver;
  46383. private _engine;
  46384. private _scene;
  46385. /**
  46386. * Attach the input controls to a specific dom element to get the input from.
  46387. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46388. */
  46389. attachControl(noPreventDefault?: boolean): void;
  46390. /**
  46391. * Detach the current controls from the specified dom element.
  46392. */
  46393. detachControl(): void;
  46394. /**
  46395. * Update the current camera state depending on the inputs that have been used this frame.
  46396. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  46397. */
  46398. checkInputs(): void;
  46399. /**
  46400. * Gets the class name of the current intput.
  46401. * @returns the class name
  46402. */
  46403. getClassName(): string;
  46404. /**
  46405. * Get the friendly name associated with the input class.
  46406. * @returns the input friendly name
  46407. */
  46408. getSimpleName(): string;
  46409. }
  46410. }
  46411. declare module BABYLON {
  46412. /**
  46413. * Manage the mouse wheel inputs to control an arc rotate camera.
  46414. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46415. */
  46416. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  46417. /**
  46418. * Defines the camera the input is attached to.
  46419. */
  46420. camera: ArcRotateCamera;
  46421. /**
  46422. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  46423. */
  46424. wheelPrecision: number;
  46425. /**
  46426. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  46427. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  46428. */
  46429. wheelDeltaPercentage: number;
  46430. private _wheel;
  46431. private _observer;
  46432. private computeDeltaFromMouseWheelLegacyEvent;
  46433. /**
  46434. * Attach the input controls to a specific dom element to get the input from.
  46435. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46436. */
  46437. attachControl(noPreventDefault?: boolean): void;
  46438. /**
  46439. * Detach the current controls from the specified dom element.
  46440. */
  46441. detachControl(): void;
  46442. /**
  46443. * Gets the class name of the current intput.
  46444. * @returns the class name
  46445. */
  46446. getClassName(): string;
  46447. /**
  46448. * Get the friendly name associated with the input class.
  46449. * @returns the input friendly name
  46450. */
  46451. getSimpleName(): string;
  46452. }
  46453. }
  46454. declare module BABYLON {
  46455. /**
  46456. * Default Inputs manager for the ArcRotateCamera.
  46457. * It groups all the default supported inputs for ease of use.
  46458. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46459. */
  46460. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  46461. /**
  46462. * Instantiates a new ArcRotateCameraInputsManager.
  46463. * @param camera Defines the camera the inputs belong to
  46464. */
  46465. constructor(camera: ArcRotateCamera);
  46466. /**
  46467. * Add mouse wheel input support to the input manager.
  46468. * @returns the current input manager
  46469. */
  46470. addMouseWheel(): ArcRotateCameraInputsManager;
  46471. /**
  46472. * Add pointers input support to the input manager.
  46473. * @returns the current input manager
  46474. */
  46475. addPointers(): ArcRotateCameraInputsManager;
  46476. /**
  46477. * Add keyboard input support to the input manager.
  46478. * @returns the current input manager
  46479. */
  46480. addKeyboard(): ArcRotateCameraInputsManager;
  46481. }
  46482. }
  46483. declare module BABYLON {
  46484. /**
  46485. * This represents an orbital type of camera.
  46486. *
  46487. * 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.
  46488. * 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.
  46489. * @see https://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  46490. */
  46491. export class ArcRotateCamera extends TargetCamera {
  46492. /**
  46493. * Defines the rotation angle of the camera along the longitudinal axis.
  46494. */
  46495. alpha: number;
  46496. /**
  46497. * Defines the rotation angle of the camera along the latitudinal axis.
  46498. */
  46499. beta: number;
  46500. /**
  46501. * Defines the radius of the camera from it s target point.
  46502. */
  46503. radius: number;
  46504. protected _target: Vector3;
  46505. protected _targetHost: Nullable<AbstractMesh>;
  46506. /**
  46507. * Defines the target point of the camera.
  46508. * The camera looks towards it form the radius distance.
  46509. * Please note that you can set the target to a mesh and thus the target will be copied from mesh.position
  46510. */
  46511. get target(): Vector3;
  46512. set target(value: Vector3);
  46513. /**
  46514. * Define the current local position of the camera in the scene
  46515. */
  46516. get position(): Vector3;
  46517. set position(newPosition: Vector3);
  46518. protected _upToYMatrix: Matrix;
  46519. protected _YToUpMatrix: Matrix;
  46520. /**
  46521. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  46522. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  46523. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  46524. */
  46525. set upVector(vec: Vector3);
  46526. get upVector(): Vector3;
  46527. /**
  46528. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  46529. */
  46530. setMatUp(): void;
  46531. /**
  46532. * Current inertia value on the longitudinal axis.
  46533. * The bigger this number the longer it will take for the camera to stop.
  46534. */
  46535. inertialAlphaOffset: number;
  46536. /**
  46537. * Current inertia value on the latitudinal axis.
  46538. * The bigger this number the longer it will take for the camera to stop.
  46539. */
  46540. inertialBetaOffset: number;
  46541. /**
  46542. * Current inertia value on the radius axis.
  46543. * The bigger this number the longer it will take for the camera to stop.
  46544. */
  46545. inertialRadiusOffset: number;
  46546. /**
  46547. * Minimum allowed angle on the longitudinal axis.
  46548. * This can help limiting how the Camera is able to move in the scene.
  46549. */
  46550. lowerAlphaLimit: Nullable<number>;
  46551. /**
  46552. * Maximum allowed angle on the longitudinal axis.
  46553. * This can help limiting how the Camera is able to move in the scene.
  46554. */
  46555. upperAlphaLimit: Nullable<number>;
  46556. /**
  46557. * Minimum allowed angle on the latitudinal axis.
  46558. * This can help limiting how the Camera is able to move in the scene.
  46559. */
  46560. lowerBetaLimit: number;
  46561. /**
  46562. * Maximum allowed angle on the latitudinal axis.
  46563. * This can help limiting how the Camera is able to move in the scene.
  46564. */
  46565. upperBetaLimit: number;
  46566. /**
  46567. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  46568. * This can help limiting how the Camera is able to move in the scene.
  46569. */
  46570. lowerRadiusLimit: Nullable<number>;
  46571. /**
  46572. * Maximum allowed distance of the camera to the target (The camera can not get further).
  46573. * This can help limiting how the Camera is able to move in the scene.
  46574. */
  46575. upperRadiusLimit: Nullable<number>;
  46576. /**
  46577. * Defines the current inertia value used during panning of the camera along the X axis.
  46578. */
  46579. inertialPanningX: number;
  46580. /**
  46581. * Defines the current inertia value used during panning of the camera along the Y axis.
  46582. */
  46583. inertialPanningY: number;
  46584. /**
  46585. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  46586. * Basically if your fingers moves away from more than this distance you will be considered
  46587. * in pinch mode.
  46588. */
  46589. pinchToPanMaxDistance: number;
  46590. /**
  46591. * Defines the maximum distance the camera can pan.
  46592. * This could help keeping the cammera always in your scene.
  46593. */
  46594. panningDistanceLimit: Nullable<number>;
  46595. /**
  46596. * Defines the target of the camera before paning.
  46597. */
  46598. panningOriginTarget: Vector3;
  46599. /**
  46600. * Defines the value of the inertia used during panning.
  46601. * 0 would mean stop inertia and one would mean no decelleration at all.
  46602. */
  46603. panningInertia: number;
  46604. /**
  46605. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  46606. */
  46607. get angularSensibilityX(): number;
  46608. set angularSensibilityX(value: number);
  46609. /**
  46610. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  46611. */
  46612. get angularSensibilityY(): number;
  46613. set angularSensibilityY(value: number);
  46614. /**
  46615. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  46616. */
  46617. get pinchPrecision(): number;
  46618. set pinchPrecision(value: number);
  46619. /**
  46620. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  46621. * It will be used instead of pinchDeltaPrecision if different from 0.
  46622. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  46623. */
  46624. get pinchDeltaPercentage(): number;
  46625. set pinchDeltaPercentage(value: number);
  46626. /**
  46627. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  46628. * and pinch delta percentage.
  46629. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  46630. * that any object in the plane at the camera's target point will scale
  46631. * perfectly with finger motion.
  46632. */
  46633. get useNaturalPinchZoom(): boolean;
  46634. set useNaturalPinchZoom(value: boolean);
  46635. /**
  46636. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  46637. */
  46638. get panningSensibility(): number;
  46639. set panningSensibility(value: number);
  46640. /**
  46641. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  46642. */
  46643. get keysUp(): number[];
  46644. set keysUp(value: number[]);
  46645. /**
  46646. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  46647. */
  46648. get keysDown(): number[];
  46649. set keysDown(value: number[]);
  46650. /**
  46651. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  46652. */
  46653. get keysLeft(): number[];
  46654. set keysLeft(value: number[]);
  46655. /**
  46656. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  46657. */
  46658. get keysRight(): number[];
  46659. set keysRight(value: number[]);
  46660. /**
  46661. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  46662. */
  46663. get wheelPrecision(): number;
  46664. set wheelPrecision(value: number);
  46665. /**
  46666. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  46667. * It will be used instead of pinchDeltaPrecision if different from 0.
  46668. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  46669. */
  46670. get wheelDeltaPercentage(): number;
  46671. set wheelDeltaPercentage(value: number);
  46672. /**
  46673. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  46674. */
  46675. zoomOnFactor: number;
  46676. /**
  46677. * Defines a screen offset for the camera position.
  46678. */
  46679. targetScreenOffset: Vector2;
  46680. /**
  46681. * Allows the camera to be completely reversed.
  46682. * If false the camera can not arrive upside down.
  46683. */
  46684. allowUpsideDown: boolean;
  46685. /**
  46686. * Define if double tap/click is used to restore the previously saved state of the camera.
  46687. */
  46688. useInputToRestoreState: boolean;
  46689. /** @hidden */
  46690. _viewMatrix: Matrix;
  46691. /** @hidden */
  46692. _useCtrlForPanning: boolean;
  46693. /** @hidden */
  46694. _panningMouseButton: number;
  46695. /**
  46696. * Defines the input associated to the camera.
  46697. */
  46698. inputs: ArcRotateCameraInputsManager;
  46699. /** @hidden */
  46700. _reset: () => void;
  46701. /**
  46702. * Defines the allowed panning axis.
  46703. */
  46704. panningAxis: Vector3;
  46705. protected _localDirection: Vector3;
  46706. protected _transformedDirection: Vector3;
  46707. private _bouncingBehavior;
  46708. /**
  46709. * Gets the bouncing behavior of the camera if it has been enabled.
  46710. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  46711. */
  46712. get bouncingBehavior(): Nullable<BouncingBehavior>;
  46713. /**
  46714. * Defines if the bouncing behavior of the camera is enabled on the camera.
  46715. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  46716. */
  46717. get useBouncingBehavior(): boolean;
  46718. set useBouncingBehavior(value: boolean);
  46719. private _framingBehavior;
  46720. /**
  46721. * Gets the framing behavior of the camera if it has been enabled.
  46722. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  46723. */
  46724. get framingBehavior(): Nullable<FramingBehavior>;
  46725. /**
  46726. * Defines if the framing behavior of the camera is enabled on the camera.
  46727. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  46728. */
  46729. get useFramingBehavior(): boolean;
  46730. set useFramingBehavior(value: boolean);
  46731. private _autoRotationBehavior;
  46732. /**
  46733. * Gets the auto rotation behavior of the camera if it has been enabled.
  46734. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  46735. */
  46736. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  46737. /**
  46738. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  46739. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  46740. */
  46741. get useAutoRotationBehavior(): boolean;
  46742. set useAutoRotationBehavior(value: boolean);
  46743. /**
  46744. * Observable triggered when the mesh target has been changed on the camera.
  46745. */
  46746. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  46747. /**
  46748. * Event raised when the camera is colliding with a mesh.
  46749. */
  46750. onCollide: (collidedMesh: AbstractMesh) => void;
  46751. /**
  46752. * Defines whether the camera should check collision with the objects oh the scene.
  46753. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  46754. */
  46755. checkCollisions: boolean;
  46756. /**
  46757. * Defines the collision radius of the camera.
  46758. * This simulates a sphere around the camera.
  46759. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  46760. */
  46761. collisionRadius: Vector3;
  46762. protected _collider: Collider;
  46763. protected _previousPosition: Vector3;
  46764. protected _collisionVelocity: Vector3;
  46765. protected _newPosition: Vector3;
  46766. protected _previousAlpha: number;
  46767. protected _previousBeta: number;
  46768. protected _previousRadius: number;
  46769. protected _collisionTriggered: boolean;
  46770. protected _targetBoundingCenter: Nullable<Vector3>;
  46771. private _computationVector;
  46772. /**
  46773. * Instantiates a new ArcRotateCamera in a given scene
  46774. * @param name Defines the name of the camera
  46775. * @param alpha Defines the camera rotation along the logitudinal axis
  46776. * @param beta Defines the camera rotation along the latitudinal axis
  46777. * @param radius Defines the camera distance from its target
  46778. * @param target Defines the camera target
  46779. * @param scene Defines the scene the camera belongs to
  46780. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  46781. */
  46782. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  46783. /** @hidden */
  46784. _initCache(): void;
  46785. /** @hidden */
  46786. _updateCache(ignoreParentClass?: boolean): void;
  46787. protected _getTargetPosition(): Vector3;
  46788. private _storedAlpha;
  46789. private _storedBeta;
  46790. private _storedRadius;
  46791. private _storedTarget;
  46792. private _storedTargetScreenOffset;
  46793. /**
  46794. * Stores the current state of the camera (alpha, beta, radius and target)
  46795. * @returns the camera itself
  46796. */
  46797. storeState(): Camera;
  46798. /**
  46799. * @hidden
  46800. * Restored camera state. You must call storeState() first
  46801. */
  46802. _restoreStateValues(): boolean;
  46803. /** @hidden */
  46804. _isSynchronizedViewMatrix(): boolean;
  46805. /**
  46806. * Attach the input controls to a specific dom element to get the input from.
  46807. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46808. */
  46809. attachControl(noPreventDefault?: boolean): void;
  46810. /**
  46811. * Attach the input controls to a specific dom element to get the input from.
  46812. * @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
  46813. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46814. */
  46815. attachControl(ignored: any, noPreventDefault?: boolean): void;
  46816. /**
  46817. * Attached controls to the current camera.
  46818. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46819. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  46820. */
  46821. attachControl(noPreventDefault: boolean, useCtrlForPanning: boolean): void;
  46822. /**
  46823. * Attached controls to the current camera.
  46824. * @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
  46825. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46826. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  46827. */
  46828. attachControl(ignored: any, noPreventDefault: boolean, useCtrlForPanning: boolean): void;
  46829. /**
  46830. * Attached controls to the current camera.
  46831. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46832. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  46833. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  46834. */
  46835. attachControl(noPreventDefault: boolean, useCtrlForPanning: boolean, panningMouseButton: number): void;
  46836. /**
  46837. * Detach the current controls from the specified dom element.
  46838. */
  46839. detachControl(): void;
  46840. /**
  46841. * Detach the current controls from the specified dom element.
  46842. * @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
  46843. */
  46844. detachControl(ignored: any): void;
  46845. /** @hidden */
  46846. _checkInputs(): void;
  46847. protected _checkLimits(): void;
  46848. /**
  46849. * Rebuilds angles (alpha, beta) and radius from the give position and target
  46850. */
  46851. rebuildAnglesAndRadius(): void;
  46852. /**
  46853. * Use a position to define the current camera related information like alpha, beta and radius
  46854. * @param position Defines the position to set the camera at
  46855. */
  46856. setPosition(position: Vector3): void;
  46857. /**
  46858. * Defines the target the camera should look at.
  46859. * This will automatically adapt alpha beta and radius to fit within the new target.
  46860. * @param target Defines the new target as a Vector or a mesh
  46861. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  46862. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  46863. */
  46864. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  46865. /** @hidden */
  46866. _getViewMatrix(): Matrix;
  46867. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  46868. /**
  46869. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  46870. * @param meshes Defines the mesh to zoom on
  46871. * @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)
  46872. */
  46873. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  46874. /**
  46875. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  46876. * The target will be changed but the radius
  46877. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  46878. * @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)
  46879. */
  46880. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  46881. min: Vector3;
  46882. max: Vector3;
  46883. distance: number;
  46884. }, doNotUpdateMaxZ?: boolean): void;
  46885. /**
  46886. * @override
  46887. * Override Camera.createRigCamera
  46888. */
  46889. createRigCamera(name: string, cameraIndex: number): Camera;
  46890. /**
  46891. * @hidden
  46892. * @override
  46893. * Override Camera._updateRigCameras
  46894. */
  46895. _updateRigCameras(): void;
  46896. /**
  46897. * Destroy the camera and release the current resources hold by it.
  46898. */
  46899. dispose(): void;
  46900. /**
  46901. * Gets the current object class name.
  46902. * @return the class name
  46903. */
  46904. getClassName(): string;
  46905. }
  46906. }
  46907. declare module BABYLON {
  46908. /**
  46909. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  46910. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  46911. */
  46912. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  46913. /**
  46914. * Gets the name of the behavior.
  46915. */
  46916. get name(): string;
  46917. private _zoomStopsAnimation;
  46918. private _idleRotationSpeed;
  46919. private _idleRotationWaitTime;
  46920. private _idleRotationSpinupTime;
  46921. /**
  46922. * Sets the flag that indicates if user zooming should stop animation.
  46923. */
  46924. set zoomStopsAnimation(flag: boolean);
  46925. /**
  46926. * Gets the flag that indicates if user zooming should stop animation.
  46927. */
  46928. get zoomStopsAnimation(): boolean;
  46929. /**
  46930. * Sets the default speed at which the camera rotates around the model.
  46931. */
  46932. set idleRotationSpeed(speed: number);
  46933. /**
  46934. * Gets the default speed at which the camera rotates around the model.
  46935. */
  46936. get idleRotationSpeed(): number;
  46937. /**
  46938. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  46939. */
  46940. set idleRotationWaitTime(time: number);
  46941. /**
  46942. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  46943. */
  46944. get idleRotationWaitTime(): number;
  46945. /**
  46946. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  46947. */
  46948. set idleRotationSpinupTime(time: number);
  46949. /**
  46950. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  46951. */
  46952. get idleRotationSpinupTime(): number;
  46953. /**
  46954. * Gets a value indicating if the camera is currently rotating because of this behavior
  46955. */
  46956. get rotationInProgress(): boolean;
  46957. private _onPrePointerObservableObserver;
  46958. private _onAfterCheckInputsObserver;
  46959. private _attachedCamera;
  46960. private _isPointerDown;
  46961. private _lastFrameTime;
  46962. private _lastInteractionTime;
  46963. private _cameraRotationSpeed;
  46964. /**
  46965. * Initializes the behavior.
  46966. */
  46967. init(): void;
  46968. /**
  46969. * Attaches the behavior to its arc rotate camera.
  46970. * @param camera Defines the camera to attach the behavior to
  46971. */
  46972. attach(camera: ArcRotateCamera): void;
  46973. /**
  46974. * Detaches the behavior from its current arc rotate camera.
  46975. */
  46976. detach(): void;
  46977. /**
  46978. * Returns true if user is scrolling.
  46979. * @return true if user is scrolling.
  46980. */
  46981. private _userIsZooming;
  46982. private _lastFrameRadius;
  46983. private _shouldAnimationStopForInteraction;
  46984. /**
  46985. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  46986. */
  46987. private _applyUserInteraction;
  46988. private _userIsMoving;
  46989. }
  46990. }
  46991. declare module BABYLON {
  46992. /**
  46993. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  46994. */
  46995. export class AttachToBoxBehavior implements Behavior<Mesh> {
  46996. private ui;
  46997. /**
  46998. * The name of the behavior
  46999. */
  47000. name: string;
  47001. /**
  47002. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  47003. */
  47004. distanceAwayFromFace: number;
  47005. /**
  47006. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  47007. */
  47008. distanceAwayFromBottomOfFace: number;
  47009. private _faceVectors;
  47010. private _target;
  47011. private _scene;
  47012. private _onRenderObserver;
  47013. private _tmpMatrix;
  47014. private _tmpVector;
  47015. /**
  47016. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  47017. * @param ui The transform node that should be attched to the mesh
  47018. */
  47019. constructor(ui: TransformNode);
  47020. /**
  47021. * Initializes the behavior
  47022. */
  47023. init(): void;
  47024. private _closestFace;
  47025. private _zeroVector;
  47026. private _lookAtTmpMatrix;
  47027. private _lookAtToRef;
  47028. /**
  47029. * Attaches the AttachToBoxBehavior to the passed in mesh
  47030. * @param target The mesh that the specified node will be attached to
  47031. */
  47032. attach(target: Mesh): void;
  47033. /**
  47034. * Detaches the behavior from the mesh
  47035. */
  47036. detach(): void;
  47037. }
  47038. }
  47039. declare module BABYLON {
  47040. /**
  47041. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  47042. */
  47043. export class FadeInOutBehavior implements Behavior<Mesh> {
  47044. /**
  47045. * Time in milliseconds to delay before fading in (Default: 0)
  47046. */
  47047. delay: number;
  47048. /**
  47049. * Time in milliseconds for the mesh to fade in (Default: 300)
  47050. */
  47051. fadeInTime: number;
  47052. private _millisecondsPerFrame;
  47053. private _hovered;
  47054. private _hoverValue;
  47055. private _ownerNode;
  47056. /**
  47057. * Instatiates the FadeInOutBehavior
  47058. */
  47059. constructor();
  47060. /**
  47061. * The name of the behavior
  47062. */
  47063. get name(): string;
  47064. /**
  47065. * Initializes the behavior
  47066. */
  47067. init(): void;
  47068. /**
  47069. * Attaches the fade behavior on the passed in mesh
  47070. * @param ownerNode The mesh that will be faded in/out once attached
  47071. */
  47072. attach(ownerNode: Mesh): void;
  47073. /**
  47074. * Detaches the behavior from the mesh
  47075. */
  47076. detach(): void;
  47077. /**
  47078. * Triggers the mesh to begin fading in or out
  47079. * @param value if the object should fade in or out (true to fade in)
  47080. */
  47081. fadeIn(value: boolean): void;
  47082. private _update;
  47083. private _setAllVisibility;
  47084. }
  47085. }
  47086. declare module BABYLON {
  47087. /**
  47088. * Class containing a set of static utilities functions for managing Pivots
  47089. * @hidden
  47090. */
  47091. export class PivotTools {
  47092. private static _PivotCached;
  47093. private static _OldPivotPoint;
  47094. private static _PivotTranslation;
  47095. private static _PivotTmpVector;
  47096. private static _PivotPostMultiplyPivotMatrix;
  47097. /** @hidden */
  47098. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  47099. /** @hidden */
  47100. static _RestorePivotPoint(mesh: AbstractMesh): void;
  47101. }
  47102. }
  47103. declare module BABYLON {
  47104. /**
  47105. * Class containing static functions to help procedurally build meshes
  47106. */
  47107. export class PlaneBuilder {
  47108. /**
  47109. * Creates a plane mesh
  47110. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  47111. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  47112. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  47113. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47114. * * 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
  47115. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47116. * @param name defines the name of the mesh
  47117. * @param options defines the options used to create the mesh
  47118. * @param scene defines the hosting scene
  47119. * @returns the plane mesh
  47120. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  47121. */
  47122. static CreatePlane(name: string, options: {
  47123. size?: number;
  47124. width?: number;
  47125. height?: number;
  47126. sideOrientation?: number;
  47127. frontUVs?: Vector4;
  47128. backUVs?: Vector4;
  47129. updatable?: boolean;
  47130. sourcePlane?: Plane;
  47131. }, scene?: Nullable<Scene>): Mesh;
  47132. }
  47133. }
  47134. declare module BABYLON {
  47135. /**
  47136. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  47137. */
  47138. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  47139. private static _AnyMouseID;
  47140. /**
  47141. * Abstract mesh the behavior is set on
  47142. */
  47143. attachedNode: AbstractMesh;
  47144. private _dragPlane;
  47145. private _scene;
  47146. private _pointerObserver;
  47147. private _beforeRenderObserver;
  47148. private static _planeScene;
  47149. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  47150. /**
  47151. * 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)
  47152. */
  47153. maxDragAngle: number;
  47154. /**
  47155. * @hidden
  47156. */
  47157. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  47158. /**
  47159. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  47160. */
  47161. currentDraggingPointerID: number;
  47162. /**
  47163. * The last position where the pointer hit the drag plane in world space
  47164. */
  47165. lastDragPosition: Vector3;
  47166. /**
  47167. * If the behavior is currently in a dragging state
  47168. */
  47169. dragging: boolean;
  47170. /**
  47171. * 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)
  47172. */
  47173. dragDeltaRatio: number;
  47174. /**
  47175. * If the drag plane orientation should be updated during the dragging (Default: true)
  47176. */
  47177. updateDragPlane: boolean;
  47178. private _debugMode;
  47179. private _moving;
  47180. /**
  47181. * Fires each time the attached mesh is dragged with the pointer
  47182. * * delta between last drag position and current drag position in world space
  47183. * * dragDistance along the drag axis
  47184. * * dragPlaneNormal normal of the current drag plane used during the drag
  47185. * * dragPlanePoint in world space where the drag intersects the drag plane
  47186. */
  47187. onDragObservable: Observable<{
  47188. delta: Vector3;
  47189. dragPlanePoint: Vector3;
  47190. dragPlaneNormal: Vector3;
  47191. dragDistance: number;
  47192. pointerId: number;
  47193. }>;
  47194. /**
  47195. * Fires each time a drag begins (eg. mouse down on mesh)
  47196. */
  47197. onDragStartObservable: Observable<{
  47198. dragPlanePoint: Vector3;
  47199. pointerId: number;
  47200. }>;
  47201. /**
  47202. * Fires each time a drag ends (eg. mouse release after drag)
  47203. */
  47204. onDragEndObservable: Observable<{
  47205. dragPlanePoint: Vector3;
  47206. pointerId: number;
  47207. }>;
  47208. /**
  47209. * If the attached mesh should be moved when dragged
  47210. */
  47211. moveAttached: boolean;
  47212. /**
  47213. * If the drag behavior will react to drag events (Default: true)
  47214. */
  47215. enabled: boolean;
  47216. /**
  47217. * If pointer events should start and release the drag (Default: true)
  47218. */
  47219. startAndReleaseDragOnPointerEvents: boolean;
  47220. /**
  47221. * If camera controls should be detached during the drag
  47222. */
  47223. detachCameraControls: boolean;
  47224. /**
  47225. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  47226. */
  47227. useObjectOrientationForDragging: boolean;
  47228. private _options;
  47229. /**
  47230. * Gets the options used by the behavior
  47231. */
  47232. get options(): {
  47233. dragAxis?: Vector3;
  47234. dragPlaneNormal?: Vector3;
  47235. };
  47236. /**
  47237. * Sets the options used by the behavior
  47238. */
  47239. set options(options: {
  47240. dragAxis?: Vector3;
  47241. dragPlaneNormal?: Vector3;
  47242. });
  47243. /**
  47244. * Creates a pointer drag behavior that can be attached to a mesh
  47245. * @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)
  47246. */
  47247. constructor(options?: {
  47248. dragAxis?: Vector3;
  47249. dragPlaneNormal?: Vector3;
  47250. });
  47251. /**
  47252. * Predicate to determine if it is valid to move the object to a new position when it is moved
  47253. */
  47254. validateDrag: (targetPosition: Vector3) => boolean;
  47255. /**
  47256. * The name of the behavior
  47257. */
  47258. get name(): string;
  47259. /**
  47260. * Initializes the behavior
  47261. */
  47262. init(): void;
  47263. private _tmpVector;
  47264. private _alternatePickedPoint;
  47265. private _worldDragAxis;
  47266. private _targetPosition;
  47267. private _attachedToElement;
  47268. /**
  47269. * Attaches the drag behavior the passed in mesh
  47270. * @param ownerNode The mesh that will be dragged around once attached
  47271. * @param predicate Predicate to use for pick filtering
  47272. */
  47273. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  47274. /**
  47275. * Force relase the drag action by code.
  47276. */
  47277. releaseDrag(): void;
  47278. private _startDragRay;
  47279. private _lastPointerRay;
  47280. /**
  47281. * Simulates the start of a pointer drag event on the behavior
  47282. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  47283. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  47284. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  47285. */
  47286. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  47287. protected _startDrag(pointerId: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  47288. private _dragDelta;
  47289. protected _moveDrag(ray: Ray): void;
  47290. private _pickWithRayOnDragPlane;
  47291. private _pointA;
  47292. private _pointC;
  47293. private _localAxis;
  47294. private _lookAt;
  47295. private _updateDragPlanePosition;
  47296. /**
  47297. * Detaches the behavior from the mesh
  47298. */
  47299. detach(): void;
  47300. }
  47301. }
  47302. declare module BABYLON {
  47303. /**
  47304. * A behavior that when attached to a mesh will allow the mesh to be scaled
  47305. */
  47306. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  47307. private _dragBehaviorA;
  47308. private _dragBehaviorB;
  47309. private _startDistance;
  47310. private _initialScale;
  47311. private _targetScale;
  47312. private _ownerNode;
  47313. private _sceneRenderObserver;
  47314. /**
  47315. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  47316. */
  47317. constructor();
  47318. /**
  47319. * The name of the behavior
  47320. */
  47321. get name(): string;
  47322. /**
  47323. * Initializes the behavior
  47324. */
  47325. init(): void;
  47326. private _getCurrentDistance;
  47327. /**
  47328. * Attaches the scale behavior the passed in mesh
  47329. * @param ownerNode The mesh that will be scaled around once attached
  47330. */
  47331. attach(ownerNode: Mesh): void;
  47332. /**
  47333. * Detaches the behavior from the mesh
  47334. */
  47335. detach(): void;
  47336. }
  47337. }
  47338. declare module BABYLON {
  47339. /**
  47340. * 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
  47341. */
  47342. export class SixDofDragBehavior implements Behavior<Mesh> {
  47343. private static _virtualScene;
  47344. private _ownerNode;
  47345. private _sceneRenderObserver;
  47346. private _scene;
  47347. private _targetPosition;
  47348. private _virtualOriginMesh;
  47349. private _virtualDragMesh;
  47350. private _pointerObserver;
  47351. private _moving;
  47352. private _startingOrientation;
  47353. private _attachedToElement;
  47354. /**
  47355. * 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)
  47356. */
  47357. private zDragFactor;
  47358. /**
  47359. * If the object should rotate to face the drag origin
  47360. */
  47361. rotateDraggedObject: boolean;
  47362. /**
  47363. * If the behavior is currently in a dragging state
  47364. */
  47365. dragging: boolean;
  47366. /**
  47367. * 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)
  47368. */
  47369. dragDeltaRatio: number;
  47370. /**
  47371. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  47372. */
  47373. currentDraggingPointerID: number;
  47374. /**
  47375. * If camera controls should be detached during the drag
  47376. */
  47377. detachCameraControls: boolean;
  47378. /**
  47379. * Fires each time a drag starts
  47380. */
  47381. onDragStartObservable: Observable<{}>;
  47382. /**
  47383. * Fires each time a drag happens
  47384. */
  47385. onDragObservable: Observable<void>;
  47386. /**
  47387. * Fires each time a drag ends (eg. mouse release after drag)
  47388. */
  47389. onDragEndObservable: Observable<{}>;
  47390. /**
  47391. * 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
  47392. */
  47393. constructor();
  47394. /**
  47395. * The name of the behavior
  47396. */
  47397. get name(): string;
  47398. /**
  47399. * Initializes the behavior
  47400. */
  47401. init(): void;
  47402. /**
  47403. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  47404. */
  47405. private get _pointerCamera();
  47406. /**
  47407. * Attaches the scale behavior the passed in mesh
  47408. * @param ownerNode The mesh that will be scaled around once attached
  47409. */
  47410. attach(ownerNode: Mesh): void;
  47411. /**
  47412. * Detaches the behavior from the mesh
  47413. */
  47414. detach(): void;
  47415. }
  47416. }
  47417. declare module BABYLON {
  47418. /**
  47419. * Class used to apply inverse kinematics to bones
  47420. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  47421. */
  47422. export class BoneIKController {
  47423. private static _tmpVecs;
  47424. private static _tmpQuat;
  47425. private static _tmpMats;
  47426. /**
  47427. * Gets or sets the target mesh
  47428. */
  47429. targetMesh: AbstractMesh;
  47430. /** Gets or sets the mesh used as pole */
  47431. poleTargetMesh: AbstractMesh;
  47432. /**
  47433. * Gets or sets the bone used as pole
  47434. */
  47435. poleTargetBone: Nullable<Bone>;
  47436. /**
  47437. * Gets or sets the target position
  47438. */
  47439. targetPosition: Vector3;
  47440. /**
  47441. * Gets or sets the pole target position
  47442. */
  47443. poleTargetPosition: Vector3;
  47444. /**
  47445. * Gets or sets the pole target local offset
  47446. */
  47447. poleTargetLocalOffset: Vector3;
  47448. /**
  47449. * Gets or sets the pole angle
  47450. */
  47451. poleAngle: number;
  47452. /**
  47453. * Gets or sets the mesh associated with the controller
  47454. */
  47455. mesh: AbstractMesh;
  47456. /**
  47457. * 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)
  47458. */
  47459. slerpAmount: number;
  47460. private _bone1Quat;
  47461. private _bone1Mat;
  47462. private _bone2Ang;
  47463. private _bone1;
  47464. private _bone2;
  47465. private _bone1Length;
  47466. private _bone2Length;
  47467. private _maxAngle;
  47468. private _maxReach;
  47469. private _rightHandedSystem;
  47470. private _bendAxis;
  47471. private _slerping;
  47472. private _adjustRoll;
  47473. /**
  47474. * Gets or sets maximum allowed angle
  47475. */
  47476. get maxAngle(): number;
  47477. set maxAngle(value: number);
  47478. /**
  47479. * Creates a new BoneIKController
  47480. * @param mesh defines the mesh to control
  47481. * @param bone defines the bone to control
  47482. * @param options defines options to set up the controller
  47483. */
  47484. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  47485. targetMesh?: AbstractMesh;
  47486. poleTargetMesh?: AbstractMesh;
  47487. poleTargetBone?: Bone;
  47488. poleTargetLocalOffset?: Vector3;
  47489. poleAngle?: number;
  47490. bendAxis?: Vector3;
  47491. maxAngle?: number;
  47492. slerpAmount?: number;
  47493. });
  47494. private _setMaxAngle;
  47495. /**
  47496. * Force the controller to update the bones
  47497. */
  47498. update(): void;
  47499. }
  47500. }
  47501. declare module BABYLON {
  47502. /**
  47503. * Class used to make a bone look toward a point in space
  47504. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  47505. */
  47506. export class BoneLookController {
  47507. private static _tmpVecs;
  47508. private static _tmpQuat;
  47509. private static _tmpMats;
  47510. /**
  47511. * The target Vector3 that the bone will look at
  47512. */
  47513. target: Vector3;
  47514. /**
  47515. * The mesh that the bone is attached to
  47516. */
  47517. mesh: AbstractMesh;
  47518. /**
  47519. * The bone that will be looking to the target
  47520. */
  47521. bone: Bone;
  47522. /**
  47523. * The up axis of the coordinate system that is used when the bone is rotated
  47524. */
  47525. upAxis: Vector3;
  47526. /**
  47527. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  47528. */
  47529. upAxisSpace: Space;
  47530. /**
  47531. * Used to make an adjustment to the yaw of the bone
  47532. */
  47533. adjustYaw: number;
  47534. /**
  47535. * Used to make an adjustment to the pitch of the bone
  47536. */
  47537. adjustPitch: number;
  47538. /**
  47539. * Used to make an adjustment to the roll of the bone
  47540. */
  47541. adjustRoll: number;
  47542. /**
  47543. * 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)
  47544. */
  47545. slerpAmount: number;
  47546. private _minYaw;
  47547. private _maxYaw;
  47548. private _minPitch;
  47549. private _maxPitch;
  47550. private _minYawSin;
  47551. private _minYawCos;
  47552. private _maxYawSin;
  47553. private _maxYawCos;
  47554. private _midYawConstraint;
  47555. private _minPitchTan;
  47556. private _maxPitchTan;
  47557. private _boneQuat;
  47558. private _slerping;
  47559. private _transformYawPitch;
  47560. private _transformYawPitchInv;
  47561. private _firstFrameSkipped;
  47562. private _yawRange;
  47563. private _fowardAxis;
  47564. /**
  47565. * Gets or sets the minimum yaw angle that the bone can look to
  47566. */
  47567. get minYaw(): number;
  47568. set minYaw(value: number);
  47569. /**
  47570. * Gets or sets the maximum yaw angle that the bone can look to
  47571. */
  47572. get maxYaw(): number;
  47573. set maxYaw(value: number);
  47574. /**
  47575. * Gets or sets the minimum pitch angle that the bone can look to
  47576. */
  47577. get minPitch(): number;
  47578. set minPitch(value: number);
  47579. /**
  47580. * Gets or sets the maximum pitch angle that the bone can look to
  47581. */
  47582. get maxPitch(): number;
  47583. set maxPitch(value: number);
  47584. /**
  47585. * Create a BoneLookController
  47586. * @param mesh the mesh that the bone belongs to
  47587. * @param bone the bone that will be looking to the target
  47588. * @param target the target Vector3 to look at
  47589. * @param options optional settings:
  47590. * * maxYaw: the maximum angle the bone will yaw to
  47591. * * minYaw: the minimum angle the bone will yaw to
  47592. * * maxPitch: the maximum angle the bone will pitch to
  47593. * * minPitch: the minimum angle the bone will yaw to
  47594. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  47595. * * upAxis: the up axis of the coordinate system
  47596. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  47597. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  47598. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  47599. * * adjustYaw: used to make an adjustment to the yaw of the bone
  47600. * * adjustPitch: used to make an adjustment to the pitch of the bone
  47601. * * adjustRoll: used to make an adjustment to the roll of the bone
  47602. **/
  47603. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  47604. maxYaw?: number;
  47605. minYaw?: number;
  47606. maxPitch?: number;
  47607. minPitch?: number;
  47608. slerpAmount?: number;
  47609. upAxis?: Vector3;
  47610. upAxisSpace?: Space;
  47611. yawAxis?: Vector3;
  47612. pitchAxis?: Vector3;
  47613. adjustYaw?: number;
  47614. adjustPitch?: number;
  47615. adjustRoll?: number;
  47616. });
  47617. /**
  47618. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  47619. */
  47620. update(): void;
  47621. private _getAngleDiff;
  47622. private _getAngleBetween;
  47623. private _isAngleBetween;
  47624. }
  47625. }
  47626. declare module BABYLON {
  47627. /**
  47628. * Manage the gamepad inputs to control an arc rotate camera.
  47629. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47630. */
  47631. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  47632. /**
  47633. * Defines the camera the input is attached to.
  47634. */
  47635. camera: ArcRotateCamera;
  47636. /**
  47637. * Defines the gamepad the input is gathering event from.
  47638. */
  47639. gamepad: Nullable<Gamepad>;
  47640. /**
  47641. * Defines the gamepad rotation sensiblity.
  47642. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  47643. */
  47644. gamepadRotationSensibility: number;
  47645. /**
  47646. * Defines the gamepad move sensiblity.
  47647. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  47648. */
  47649. gamepadMoveSensibility: number;
  47650. private _yAxisScale;
  47651. /**
  47652. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  47653. */
  47654. get invertYAxis(): boolean;
  47655. set invertYAxis(value: boolean);
  47656. private _onGamepadConnectedObserver;
  47657. private _onGamepadDisconnectedObserver;
  47658. /**
  47659. * Attach the input controls to a specific dom element to get the input from.
  47660. */
  47661. attachControl(): void;
  47662. /**
  47663. * Detach the current controls from the specified dom element.
  47664. */
  47665. detachControl(): void;
  47666. /**
  47667. * Update the current camera state depending on the inputs that have been used this frame.
  47668. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  47669. */
  47670. checkInputs(): void;
  47671. /**
  47672. * Gets the class name of the current intput.
  47673. * @returns the class name
  47674. */
  47675. getClassName(): string;
  47676. /**
  47677. * Get the friendly name associated with the input class.
  47678. * @returns the input friendly name
  47679. */
  47680. getSimpleName(): string;
  47681. }
  47682. }
  47683. declare module BABYLON {
  47684. interface ArcRotateCameraInputsManager {
  47685. /**
  47686. * Add orientation input support to the input manager.
  47687. * @returns the current input manager
  47688. */
  47689. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  47690. }
  47691. /**
  47692. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  47693. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47694. */
  47695. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  47696. /**
  47697. * Defines the camera the input is attached to.
  47698. */
  47699. camera: ArcRotateCamera;
  47700. /**
  47701. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  47702. */
  47703. alphaCorrection: number;
  47704. /**
  47705. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  47706. */
  47707. gammaCorrection: number;
  47708. private _alpha;
  47709. private _gamma;
  47710. private _dirty;
  47711. private _deviceOrientationHandler;
  47712. /**
  47713. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  47714. */
  47715. constructor();
  47716. /**
  47717. * Attach the input controls to a specific dom element to get the input from.
  47718. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  47719. */
  47720. attachControl(noPreventDefault?: boolean): void;
  47721. /** @hidden */
  47722. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  47723. /**
  47724. * Update the current camera state depending on the inputs that have been used this frame.
  47725. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  47726. */
  47727. checkInputs(): void;
  47728. /**
  47729. * Detach the current controls from the specified dom element.
  47730. */
  47731. detachControl(): void;
  47732. /**
  47733. * Gets the class name of the current intput.
  47734. * @returns the class name
  47735. */
  47736. getClassName(): string;
  47737. /**
  47738. * Get the friendly name associated with the input class.
  47739. * @returns the input friendly name
  47740. */
  47741. getSimpleName(): string;
  47742. }
  47743. }
  47744. declare module BABYLON {
  47745. /**
  47746. * Listen to mouse events to control the camera.
  47747. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47748. */
  47749. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  47750. /**
  47751. * Defines the camera the input is attached to.
  47752. */
  47753. camera: FlyCamera;
  47754. /**
  47755. * Defines if touch is enabled. (Default is true.)
  47756. */
  47757. touchEnabled: boolean;
  47758. /**
  47759. * Defines the buttons associated with the input to handle camera rotation.
  47760. */
  47761. buttons: number[];
  47762. /**
  47763. * Assign buttons for Yaw control.
  47764. */
  47765. buttonsYaw: number[];
  47766. /**
  47767. * Assign buttons for Pitch control.
  47768. */
  47769. buttonsPitch: number[];
  47770. /**
  47771. * Assign buttons for Roll control.
  47772. */
  47773. buttonsRoll: number[];
  47774. /**
  47775. * Detect if any button is being pressed while mouse is moved.
  47776. * -1 = Mouse locked.
  47777. * 0 = Left button.
  47778. * 1 = Middle Button.
  47779. * 2 = Right Button.
  47780. */
  47781. activeButton: number;
  47782. /**
  47783. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  47784. * Higher values reduce its sensitivity.
  47785. */
  47786. angularSensibility: number;
  47787. private _observer;
  47788. private _rollObserver;
  47789. private previousPosition;
  47790. private noPreventDefault;
  47791. private element;
  47792. /**
  47793. * Listen to mouse events to control the camera.
  47794. * @param touchEnabled Define if touch is enabled. (Default is true.)
  47795. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47796. */
  47797. constructor(touchEnabled?: boolean);
  47798. /**
  47799. * Attach the mouse control to the HTML DOM element.
  47800. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  47801. */
  47802. attachControl(noPreventDefault?: boolean): void;
  47803. /**
  47804. * Detach the current controls from the specified dom element.
  47805. */
  47806. detachControl(): void;
  47807. /**
  47808. * Gets the class name of the current input.
  47809. * @returns the class name.
  47810. */
  47811. getClassName(): string;
  47812. /**
  47813. * Get the friendly name associated with the input class.
  47814. * @returns the input's friendly name.
  47815. */
  47816. getSimpleName(): string;
  47817. private _pointerInput;
  47818. private _onMouseMove;
  47819. /**
  47820. * Rotate camera by mouse offset.
  47821. */
  47822. private rotateCamera;
  47823. }
  47824. }
  47825. declare module BABYLON {
  47826. /**
  47827. * Default Inputs manager for the FlyCamera.
  47828. * It groups all the default supported inputs for ease of use.
  47829. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47830. */
  47831. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  47832. /**
  47833. * Instantiates a new FlyCameraInputsManager.
  47834. * @param camera Defines the camera the inputs belong to.
  47835. */
  47836. constructor(camera: FlyCamera);
  47837. /**
  47838. * Add keyboard input support to the input manager.
  47839. * @returns the new FlyCameraKeyboardMoveInput().
  47840. */
  47841. addKeyboard(): FlyCameraInputsManager;
  47842. /**
  47843. * Add mouse input support to the input manager.
  47844. * @param touchEnabled Enable touch screen support.
  47845. * @returns the new FlyCameraMouseInput().
  47846. */
  47847. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  47848. }
  47849. }
  47850. declare module BABYLON {
  47851. /**
  47852. * This is a flying camera, designed for 3D movement and rotation in all directions,
  47853. * such as in a 3D Space Shooter or a Flight Simulator.
  47854. */
  47855. export class FlyCamera extends TargetCamera {
  47856. /**
  47857. * Define the collision ellipsoid of the camera.
  47858. * This is helpful for simulating a camera body, like a player's body.
  47859. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  47860. */
  47861. ellipsoid: Vector3;
  47862. /**
  47863. * Define an offset for the position of the ellipsoid around the camera.
  47864. * This can be helpful if the camera is attached away from the player's body center,
  47865. * such as at its head.
  47866. */
  47867. ellipsoidOffset: Vector3;
  47868. /**
  47869. * Enable or disable collisions of the camera with the rest of the scene objects.
  47870. */
  47871. checkCollisions: boolean;
  47872. /**
  47873. * Enable or disable gravity on the camera.
  47874. */
  47875. applyGravity: boolean;
  47876. /**
  47877. * Define the current direction the camera is moving to.
  47878. */
  47879. cameraDirection: Vector3;
  47880. /**
  47881. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  47882. * This overrides and empties cameraRotation.
  47883. */
  47884. rotationQuaternion: Quaternion;
  47885. /**
  47886. * Track Roll to maintain the wanted Rolling when looking around.
  47887. */
  47888. _trackRoll: number;
  47889. /**
  47890. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  47891. */
  47892. rollCorrect: number;
  47893. /**
  47894. * Mimic a banked turn, Rolling the camera when Yawing.
  47895. * It's recommended to use rollCorrect = 10 for faster banking correction.
  47896. */
  47897. bankedTurn: boolean;
  47898. /**
  47899. * Limit in radians for how much Roll banking will add. (Default: 90°)
  47900. */
  47901. bankedTurnLimit: number;
  47902. /**
  47903. * Value of 0 disables the banked Roll.
  47904. * Value of 1 is equal to the Yaw angle in radians.
  47905. */
  47906. bankedTurnMultiplier: number;
  47907. /**
  47908. * The inputs manager loads all the input sources, such as keyboard and mouse.
  47909. */
  47910. inputs: FlyCameraInputsManager;
  47911. /**
  47912. * Gets the input sensibility for mouse input.
  47913. * Higher values reduce sensitivity.
  47914. */
  47915. get angularSensibility(): number;
  47916. /**
  47917. * Sets the input sensibility for a mouse input.
  47918. * Higher values reduce sensitivity.
  47919. */
  47920. set angularSensibility(value: number);
  47921. /**
  47922. * Get the keys for camera movement forward.
  47923. */
  47924. get keysForward(): number[];
  47925. /**
  47926. * Set the keys for camera movement forward.
  47927. */
  47928. set keysForward(value: number[]);
  47929. /**
  47930. * Get the keys for camera movement backward.
  47931. */
  47932. get keysBackward(): number[];
  47933. set keysBackward(value: number[]);
  47934. /**
  47935. * Get the keys for camera movement up.
  47936. */
  47937. get keysUp(): number[];
  47938. /**
  47939. * Set the keys for camera movement up.
  47940. */
  47941. set keysUp(value: number[]);
  47942. /**
  47943. * Get the keys for camera movement down.
  47944. */
  47945. get keysDown(): number[];
  47946. /**
  47947. * Set the keys for camera movement down.
  47948. */
  47949. set keysDown(value: number[]);
  47950. /**
  47951. * Get the keys for camera movement left.
  47952. */
  47953. get keysLeft(): number[];
  47954. /**
  47955. * Set the keys for camera movement left.
  47956. */
  47957. set keysLeft(value: number[]);
  47958. /**
  47959. * Set the keys for camera movement right.
  47960. */
  47961. get keysRight(): number[];
  47962. /**
  47963. * Set the keys for camera movement right.
  47964. */
  47965. set keysRight(value: number[]);
  47966. /**
  47967. * Event raised when the camera collides with a mesh in the scene.
  47968. */
  47969. onCollide: (collidedMesh: AbstractMesh) => void;
  47970. private _collider;
  47971. private _needMoveForGravity;
  47972. private _oldPosition;
  47973. private _diffPosition;
  47974. private _newPosition;
  47975. /** @hidden */
  47976. _localDirection: Vector3;
  47977. /** @hidden */
  47978. _transformedDirection: Vector3;
  47979. /**
  47980. * Instantiates a FlyCamera.
  47981. * This is a flying camera, designed for 3D movement and rotation in all directions,
  47982. * such as in a 3D Space Shooter or a Flight Simulator.
  47983. * @param name Define the name of the camera in the scene.
  47984. * @param position Define the starting position of the camera in the scene.
  47985. * @param scene Define the scene the camera belongs to.
  47986. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  47987. */
  47988. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  47989. /**
  47990. * Attach the input controls to a specific dom element to get the input from.
  47991. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  47992. */
  47993. attachControl(noPreventDefault?: boolean): void;
  47994. /**
  47995. * Detach a control from the HTML DOM element.
  47996. * The camera will stop reacting to that input.
  47997. */
  47998. detachControl(): void;
  47999. private _collisionMask;
  48000. /**
  48001. * Get the mask that the camera ignores in collision events.
  48002. */
  48003. get collisionMask(): number;
  48004. /**
  48005. * Set the mask that the camera ignores in collision events.
  48006. */
  48007. set collisionMask(mask: number);
  48008. /** @hidden */
  48009. _collideWithWorld(displacement: Vector3): void;
  48010. /** @hidden */
  48011. private _onCollisionPositionChange;
  48012. /** @hidden */
  48013. _checkInputs(): void;
  48014. /** @hidden */
  48015. _decideIfNeedsToMove(): boolean;
  48016. /** @hidden */
  48017. _updatePosition(): void;
  48018. /**
  48019. * Restore the Roll to its target value at the rate specified.
  48020. * @param rate - Higher means slower restoring.
  48021. * @hidden
  48022. */
  48023. restoreRoll(rate: number): void;
  48024. /**
  48025. * Destroy the camera and release the current resources held by it.
  48026. */
  48027. dispose(): void;
  48028. /**
  48029. * Get the current object class name.
  48030. * @returns the class name.
  48031. */
  48032. getClassName(): string;
  48033. }
  48034. }
  48035. declare module BABYLON {
  48036. /**
  48037. * Listen to keyboard events to control the camera.
  48038. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48039. */
  48040. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  48041. /**
  48042. * Defines the camera the input is attached to.
  48043. */
  48044. camera: FlyCamera;
  48045. /**
  48046. * The list of keyboard keys used to control the forward move of the camera.
  48047. */
  48048. keysForward: number[];
  48049. /**
  48050. * The list of keyboard keys used to control the backward move of the camera.
  48051. */
  48052. keysBackward: number[];
  48053. /**
  48054. * The list of keyboard keys used to control the forward move of the camera.
  48055. */
  48056. keysUp: number[];
  48057. /**
  48058. * The list of keyboard keys used to control the backward move of the camera.
  48059. */
  48060. keysDown: number[];
  48061. /**
  48062. * The list of keyboard keys used to control the right strafe move of the camera.
  48063. */
  48064. keysRight: number[];
  48065. /**
  48066. * The list of keyboard keys used to control the left strafe move of the camera.
  48067. */
  48068. keysLeft: number[];
  48069. private _keys;
  48070. private _onCanvasBlurObserver;
  48071. private _onKeyboardObserver;
  48072. private _engine;
  48073. private _scene;
  48074. /**
  48075. * Attach the input controls to a specific dom element to get the input from.
  48076. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  48077. */
  48078. attachControl(noPreventDefault?: boolean): void;
  48079. /**
  48080. * Detach the current controls from the specified dom element.
  48081. */
  48082. detachControl(): void;
  48083. /**
  48084. * Gets the class name of the current intput.
  48085. * @returns the class name
  48086. */
  48087. getClassName(): string;
  48088. /** @hidden */
  48089. _onLostFocus(e: FocusEvent): void;
  48090. /**
  48091. * Get the friendly name associated with the input class.
  48092. * @returns the input friendly name
  48093. */
  48094. getSimpleName(): string;
  48095. /**
  48096. * Update the current camera state depending on the inputs that have been used this frame.
  48097. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  48098. */
  48099. checkInputs(): void;
  48100. }
  48101. }
  48102. declare module BABYLON {
  48103. /**
  48104. * Manage the mouse wheel inputs to control a follow camera.
  48105. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48106. */
  48107. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  48108. /**
  48109. * Defines the camera the input is attached to.
  48110. */
  48111. camera: FollowCamera;
  48112. /**
  48113. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  48114. */
  48115. axisControlRadius: boolean;
  48116. /**
  48117. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  48118. */
  48119. axisControlHeight: boolean;
  48120. /**
  48121. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  48122. */
  48123. axisControlRotation: boolean;
  48124. /**
  48125. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  48126. * relation to mouseWheel events.
  48127. */
  48128. wheelPrecision: number;
  48129. /**
  48130. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  48131. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  48132. */
  48133. wheelDeltaPercentage: number;
  48134. private _wheel;
  48135. private _observer;
  48136. /**
  48137. * Attach the input controls to a specific dom element to get the input from.
  48138. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  48139. */
  48140. attachControl(noPreventDefault?: boolean): void;
  48141. /**
  48142. * Detach the current controls from the specified dom element.
  48143. */
  48144. detachControl(): void;
  48145. /**
  48146. * Gets the class name of the current intput.
  48147. * @returns the class name
  48148. */
  48149. getClassName(): string;
  48150. /**
  48151. * Get the friendly name associated with the input class.
  48152. * @returns the input friendly name
  48153. */
  48154. getSimpleName(): string;
  48155. }
  48156. }
  48157. declare module BABYLON {
  48158. /**
  48159. * Manage the pointers inputs to control an follow camera.
  48160. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48161. */
  48162. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  48163. /**
  48164. * Defines the camera the input is attached to.
  48165. */
  48166. camera: FollowCamera;
  48167. /**
  48168. * Gets the class name of the current input.
  48169. * @returns the class name
  48170. */
  48171. getClassName(): string;
  48172. /**
  48173. * Defines the pointer angular sensibility along the X axis or how fast is
  48174. * the camera rotating.
  48175. * A negative number will reverse the axis direction.
  48176. */
  48177. angularSensibilityX: number;
  48178. /**
  48179. * Defines the pointer angular sensibility along the Y axis or how fast is
  48180. * the camera rotating.
  48181. * A negative number will reverse the axis direction.
  48182. */
  48183. angularSensibilityY: number;
  48184. /**
  48185. * Defines the pointer pinch precision or how fast is the camera zooming.
  48186. * A negative number will reverse the axis direction.
  48187. */
  48188. pinchPrecision: number;
  48189. /**
  48190. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  48191. * from 0.
  48192. * It defines the percentage of current camera.radius to use as delta when
  48193. * pinch zoom is used.
  48194. */
  48195. pinchDeltaPercentage: number;
  48196. /**
  48197. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  48198. */
  48199. axisXControlRadius: boolean;
  48200. /**
  48201. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  48202. */
  48203. axisXControlHeight: boolean;
  48204. /**
  48205. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  48206. */
  48207. axisXControlRotation: boolean;
  48208. /**
  48209. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  48210. */
  48211. axisYControlRadius: boolean;
  48212. /**
  48213. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  48214. */
  48215. axisYControlHeight: boolean;
  48216. /**
  48217. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  48218. */
  48219. axisYControlRotation: boolean;
  48220. /**
  48221. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  48222. */
  48223. axisPinchControlRadius: boolean;
  48224. /**
  48225. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  48226. */
  48227. axisPinchControlHeight: boolean;
  48228. /**
  48229. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  48230. */
  48231. axisPinchControlRotation: boolean;
  48232. /**
  48233. * Log error messages if basic misconfiguration has occurred.
  48234. */
  48235. warningEnable: boolean;
  48236. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  48237. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  48238. private _warningCounter;
  48239. private _warning;
  48240. }
  48241. }
  48242. declare module BABYLON {
  48243. /**
  48244. * Default Inputs manager for the FollowCamera.
  48245. * It groups all the default supported inputs for ease of use.
  48246. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48247. */
  48248. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  48249. /**
  48250. * Instantiates a new FollowCameraInputsManager.
  48251. * @param camera Defines the camera the inputs belong to
  48252. */
  48253. constructor(camera: FollowCamera);
  48254. /**
  48255. * Add keyboard input support to the input manager.
  48256. * @returns the current input manager
  48257. */
  48258. addKeyboard(): FollowCameraInputsManager;
  48259. /**
  48260. * Add mouse wheel input support to the input manager.
  48261. * @returns the current input manager
  48262. */
  48263. addMouseWheel(): FollowCameraInputsManager;
  48264. /**
  48265. * Add pointers input support to the input manager.
  48266. * @returns the current input manager
  48267. */
  48268. addPointers(): FollowCameraInputsManager;
  48269. /**
  48270. * Add orientation input support to the input manager.
  48271. * @returns the current input manager
  48272. */
  48273. addVRDeviceOrientation(): FollowCameraInputsManager;
  48274. }
  48275. }
  48276. declare module BABYLON {
  48277. /**
  48278. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  48279. * an arc rotate version arcFollowCamera are available.
  48280. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  48281. */
  48282. export class FollowCamera extends TargetCamera {
  48283. /**
  48284. * Distance the follow camera should follow an object at
  48285. */
  48286. radius: number;
  48287. /**
  48288. * Minimum allowed distance of the camera to the axis of rotation
  48289. * (The camera can not get closer).
  48290. * This can help limiting how the Camera is able to move in the scene.
  48291. */
  48292. lowerRadiusLimit: Nullable<number>;
  48293. /**
  48294. * Maximum allowed distance of the camera to the axis of rotation
  48295. * (The camera can not get further).
  48296. * This can help limiting how the Camera is able to move in the scene.
  48297. */
  48298. upperRadiusLimit: Nullable<number>;
  48299. /**
  48300. * Define a rotation offset between the camera and the object it follows
  48301. */
  48302. rotationOffset: number;
  48303. /**
  48304. * Minimum allowed angle to camera position relative to target object.
  48305. * This can help limiting how the Camera is able to move in the scene.
  48306. */
  48307. lowerRotationOffsetLimit: Nullable<number>;
  48308. /**
  48309. * Maximum allowed angle to camera position relative to target object.
  48310. * This can help limiting how the Camera is able to move in the scene.
  48311. */
  48312. upperRotationOffsetLimit: Nullable<number>;
  48313. /**
  48314. * Define a height offset between the camera and the object it follows.
  48315. * It can help following an object from the top (like a car chaing a plane)
  48316. */
  48317. heightOffset: number;
  48318. /**
  48319. * Minimum allowed height of camera position relative to target object.
  48320. * This can help limiting how the Camera is able to move in the scene.
  48321. */
  48322. lowerHeightOffsetLimit: Nullable<number>;
  48323. /**
  48324. * Maximum allowed height of camera position relative to target object.
  48325. * This can help limiting how the Camera is able to move in the scene.
  48326. */
  48327. upperHeightOffsetLimit: Nullable<number>;
  48328. /**
  48329. * Define how fast the camera can accelerate to follow it s target.
  48330. */
  48331. cameraAcceleration: number;
  48332. /**
  48333. * Define the speed limit of the camera following an object.
  48334. */
  48335. maxCameraSpeed: number;
  48336. /**
  48337. * Define the target of the camera.
  48338. */
  48339. lockedTarget: Nullable<AbstractMesh>;
  48340. /**
  48341. * Defines the input associated with the camera.
  48342. */
  48343. inputs: FollowCameraInputsManager;
  48344. /**
  48345. * Instantiates the follow camera.
  48346. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  48347. * @param name Define the name of the camera in the scene
  48348. * @param position Define the position of the camera
  48349. * @param scene Define the scene the camera belong to
  48350. * @param lockedTarget Define the target of the camera
  48351. */
  48352. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  48353. private _follow;
  48354. /**
  48355. * Attach the input controls to a specific dom element to get the input from.
  48356. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  48357. */
  48358. attachControl(noPreventDefault?: boolean): void;
  48359. /**
  48360. * Detach the current controls from the specified dom element.
  48361. */
  48362. detachControl(): void;
  48363. /** @hidden */
  48364. _checkInputs(): void;
  48365. private _checkLimits;
  48366. /**
  48367. * Gets the camera class name.
  48368. * @returns the class name
  48369. */
  48370. getClassName(): string;
  48371. }
  48372. /**
  48373. * Arc Rotate version of the follow camera.
  48374. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  48375. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  48376. */
  48377. export class ArcFollowCamera extends TargetCamera {
  48378. /** The longitudinal angle of the camera */
  48379. alpha: number;
  48380. /** The latitudinal angle of the camera */
  48381. beta: number;
  48382. /** The radius of the camera from its target */
  48383. radius: number;
  48384. private _cartesianCoordinates;
  48385. /** Define the camera target (the mesh it should follow) */
  48386. private _meshTarget;
  48387. /**
  48388. * Instantiates a new ArcFollowCamera
  48389. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  48390. * @param name Define the name of the camera
  48391. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  48392. * @param beta Define the rotation angle of the camera around the elevation axis
  48393. * @param radius Define the radius of the camera from its target point
  48394. * @param target Define the target of the camera
  48395. * @param scene Define the scene the camera belongs to
  48396. */
  48397. constructor(name: string,
  48398. /** The longitudinal angle of the camera */
  48399. alpha: number,
  48400. /** The latitudinal angle of the camera */
  48401. beta: number,
  48402. /** The radius of the camera from its target */
  48403. radius: number,
  48404. /** Define the camera target (the mesh it should follow) */
  48405. target: Nullable<AbstractMesh>, scene: Scene);
  48406. private _follow;
  48407. /** @hidden */
  48408. _checkInputs(): void;
  48409. /**
  48410. * Returns the class name of the object.
  48411. * It is mostly used internally for serialization purposes.
  48412. */
  48413. getClassName(): string;
  48414. }
  48415. }
  48416. declare module BABYLON {
  48417. /**
  48418. * Manage the keyboard inputs to control the movement of a follow camera.
  48419. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48420. */
  48421. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  48422. /**
  48423. * Defines the camera the input is attached to.
  48424. */
  48425. camera: FollowCamera;
  48426. /**
  48427. * Defines the list of key codes associated with the up action (increase heightOffset)
  48428. */
  48429. keysHeightOffsetIncr: number[];
  48430. /**
  48431. * Defines the list of key codes associated with the down action (decrease heightOffset)
  48432. */
  48433. keysHeightOffsetDecr: number[];
  48434. /**
  48435. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  48436. */
  48437. keysHeightOffsetModifierAlt: boolean;
  48438. /**
  48439. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  48440. */
  48441. keysHeightOffsetModifierCtrl: boolean;
  48442. /**
  48443. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  48444. */
  48445. keysHeightOffsetModifierShift: boolean;
  48446. /**
  48447. * Defines the list of key codes associated with the left action (increase rotationOffset)
  48448. */
  48449. keysRotationOffsetIncr: number[];
  48450. /**
  48451. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  48452. */
  48453. keysRotationOffsetDecr: number[];
  48454. /**
  48455. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  48456. */
  48457. keysRotationOffsetModifierAlt: boolean;
  48458. /**
  48459. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  48460. */
  48461. keysRotationOffsetModifierCtrl: boolean;
  48462. /**
  48463. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  48464. */
  48465. keysRotationOffsetModifierShift: boolean;
  48466. /**
  48467. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  48468. */
  48469. keysRadiusIncr: number[];
  48470. /**
  48471. * Defines the list of key codes associated with the zoom-out action (increase radius)
  48472. */
  48473. keysRadiusDecr: number[];
  48474. /**
  48475. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  48476. */
  48477. keysRadiusModifierAlt: boolean;
  48478. /**
  48479. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  48480. */
  48481. keysRadiusModifierCtrl: boolean;
  48482. /**
  48483. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  48484. */
  48485. keysRadiusModifierShift: boolean;
  48486. /**
  48487. * Defines the rate of change of heightOffset.
  48488. */
  48489. heightSensibility: number;
  48490. /**
  48491. * Defines the rate of change of rotationOffset.
  48492. */
  48493. rotationSensibility: number;
  48494. /**
  48495. * Defines the rate of change of radius.
  48496. */
  48497. radiusSensibility: number;
  48498. private _keys;
  48499. private _ctrlPressed;
  48500. private _altPressed;
  48501. private _shiftPressed;
  48502. private _onCanvasBlurObserver;
  48503. private _onKeyboardObserver;
  48504. private _engine;
  48505. private _scene;
  48506. /**
  48507. * Attach the input controls to a specific dom element to get the input from.
  48508. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  48509. */
  48510. attachControl(noPreventDefault?: boolean): void;
  48511. /**
  48512. * Detach the current controls from the specified dom element.
  48513. */
  48514. detachControl(): void;
  48515. /**
  48516. * Update the current camera state depending on the inputs that have been used this frame.
  48517. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  48518. */
  48519. checkInputs(): void;
  48520. /**
  48521. * Gets the class name of the current input.
  48522. * @returns the class name
  48523. */
  48524. getClassName(): string;
  48525. /**
  48526. * Get the friendly name associated with the input class.
  48527. * @returns the input friendly name
  48528. */
  48529. getSimpleName(): string;
  48530. /**
  48531. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  48532. * allow modification of the heightOffset value.
  48533. */
  48534. private _modifierHeightOffset;
  48535. /**
  48536. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  48537. * allow modification of the rotationOffset value.
  48538. */
  48539. private _modifierRotationOffset;
  48540. /**
  48541. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  48542. * allow modification of the radius value.
  48543. */
  48544. private _modifierRadius;
  48545. }
  48546. }
  48547. declare module BABYLON {
  48548. interface FreeCameraInputsManager {
  48549. /**
  48550. * @hidden
  48551. */
  48552. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  48553. /**
  48554. * Add orientation input support to the input manager.
  48555. * @returns the current input manager
  48556. */
  48557. addDeviceOrientation(): FreeCameraInputsManager;
  48558. }
  48559. /**
  48560. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  48561. * Screen rotation is taken into account.
  48562. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48563. */
  48564. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  48565. private _camera;
  48566. private _screenOrientationAngle;
  48567. private _constantTranform;
  48568. private _screenQuaternion;
  48569. private _alpha;
  48570. private _beta;
  48571. private _gamma;
  48572. /**
  48573. * Can be used to detect if a device orientation sensor is available on a device
  48574. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  48575. * @returns a promise that will resolve on orientation change
  48576. */
  48577. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  48578. /**
  48579. * @hidden
  48580. */
  48581. _onDeviceOrientationChangedObservable: Observable<void>;
  48582. /**
  48583. * Instantiates a new input
  48584. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48585. */
  48586. constructor();
  48587. /**
  48588. * Define the camera controlled by the input.
  48589. */
  48590. get camera(): FreeCamera;
  48591. set camera(camera: FreeCamera);
  48592. /**
  48593. * Attach the input controls to a specific dom element to get the input from.
  48594. */
  48595. attachControl(): void;
  48596. private _orientationChanged;
  48597. private _deviceOrientation;
  48598. /**
  48599. * Detach the current controls from the specified dom element.
  48600. */
  48601. detachControl(): void;
  48602. /**
  48603. * Update the current camera state depending on the inputs that have been used this frame.
  48604. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  48605. */
  48606. checkInputs(): void;
  48607. /**
  48608. * Gets the class name of the current intput.
  48609. * @returns the class name
  48610. */
  48611. getClassName(): string;
  48612. /**
  48613. * Get the friendly name associated with the input class.
  48614. * @returns the input friendly name
  48615. */
  48616. getSimpleName(): string;
  48617. }
  48618. }
  48619. declare module BABYLON {
  48620. /**
  48621. * Manage the gamepad inputs to control a free camera.
  48622. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48623. */
  48624. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  48625. /**
  48626. * Define the camera the input is attached to.
  48627. */
  48628. camera: FreeCamera;
  48629. /**
  48630. * Define the Gamepad controlling the input
  48631. */
  48632. gamepad: Nullable<Gamepad>;
  48633. /**
  48634. * Defines the gamepad rotation sensiblity.
  48635. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  48636. */
  48637. gamepadAngularSensibility: number;
  48638. /**
  48639. * Defines the gamepad move sensiblity.
  48640. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  48641. */
  48642. gamepadMoveSensibility: number;
  48643. private _yAxisScale;
  48644. /**
  48645. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  48646. */
  48647. get invertYAxis(): boolean;
  48648. set invertYAxis(value: boolean);
  48649. private _onGamepadConnectedObserver;
  48650. private _onGamepadDisconnectedObserver;
  48651. private _cameraTransform;
  48652. private _deltaTransform;
  48653. private _vector3;
  48654. private _vector2;
  48655. /**
  48656. * Attach the input controls to a specific dom element to get the input from.
  48657. */
  48658. attachControl(): void;
  48659. /**
  48660. * Detach the current controls from the specified dom element.
  48661. */
  48662. detachControl(): void;
  48663. /**
  48664. * Update the current camera state depending on the inputs that have been used this frame.
  48665. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  48666. */
  48667. checkInputs(): void;
  48668. /**
  48669. * Gets the class name of the current intput.
  48670. * @returns the class name
  48671. */
  48672. getClassName(): string;
  48673. /**
  48674. * Get the friendly name associated with the input class.
  48675. * @returns the input friendly name
  48676. */
  48677. getSimpleName(): string;
  48678. }
  48679. }
  48680. declare module BABYLON {
  48681. /**
  48682. * Defines the potential axis of a Joystick
  48683. */
  48684. export enum JoystickAxis {
  48685. /** X axis */
  48686. X = 0,
  48687. /** Y axis */
  48688. Y = 1,
  48689. /** Z axis */
  48690. Z = 2
  48691. }
  48692. /**
  48693. * Represents the different customization options available
  48694. * for VirtualJoystick
  48695. */
  48696. interface VirtualJoystickCustomizations {
  48697. /**
  48698. * Size of the joystick's puck
  48699. */
  48700. puckSize: number;
  48701. /**
  48702. * Size of the joystick's container
  48703. */
  48704. containerSize: number;
  48705. /**
  48706. * Color of the joystick && puck
  48707. */
  48708. color: string;
  48709. /**
  48710. * Image URL for the joystick's puck
  48711. */
  48712. puckImage?: string;
  48713. /**
  48714. * Image URL for the joystick's container
  48715. */
  48716. containerImage?: string;
  48717. /**
  48718. * Defines the unmoving position of the joystick container
  48719. */
  48720. position?: {
  48721. x: number;
  48722. y: number;
  48723. };
  48724. /**
  48725. * Defines whether or not the joystick container is always visible
  48726. */
  48727. alwaysVisible: boolean;
  48728. /**
  48729. * Defines whether or not to limit the movement of the puck to the joystick's container
  48730. */
  48731. limitToContainer: boolean;
  48732. }
  48733. /**
  48734. * Class used to define virtual joystick (used in touch mode)
  48735. */
  48736. export class VirtualJoystick {
  48737. /**
  48738. * Gets or sets a boolean indicating that left and right values must be inverted
  48739. */
  48740. reverseLeftRight: boolean;
  48741. /**
  48742. * Gets or sets a boolean indicating that up and down values must be inverted
  48743. */
  48744. reverseUpDown: boolean;
  48745. /**
  48746. * Gets the offset value for the position (ie. the change of the position value)
  48747. */
  48748. deltaPosition: Vector3;
  48749. /**
  48750. * Gets a boolean indicating if the virtual joystick was pressed
  48751. */
  48752. pressed: boolean;
  48753. /**
  48754. * Canvas the virtual joystick will render onto, default z-index of this is 5
  48755. */
  48756. static Canvas: Nullable<HTMLCanvasElement>;
  48757. /**
  48758. * boolean indicating whether or not the joystick's puck's movement should be limited to the joystick's container area
  48759. */
  48760. limitToContainer: boolean;
  48761. private static _globalJoystickIndex;
  48762. private static _alwaysVisibleSticks;
  48763. private static vjCanvasContext;
  48764. private static vjCanvasWidth;
  48765. private static vjCanvasHeight;
  48766. private static halfWidth;
  48767. private static _GetDefaultOptions;
  48768. private _action;
  48769. private _axisTargetedByLeftAndRight;
  48770. private _axisTargetedByUpAndDown;
  48771. private _joystickSensibility;
  48772. private _inversedSensibility;
  48773. private _joystickPointerID;
  48774. private _joystickColor;
  48775. private _joystickPointerPos;
  48776. private _joystickPreviousPointerPos;
  48777. private _joystickPointerStartPos;
  48778. private _deltaJoystickVector;
  48779. private _leftJoystick;
  48780. private _touches;
  48781. private _joystickPosition;
  48782. private _alwaysVisible;
  48783. private _puckImage;
  48784. private _containerImage;
  48785. private _joystickPuckSize;
  48786. private _joystickContainerSize;
  48787. private _clearPuckSize;
  48788. private _clearContainerSize;
  48789. private _clearPuckSizeOffset;
  48790. private _clearContainerSizeOffset;
  48791. private _onPointerDownHandlerRef;
  48792. private _onPointerMoveHandlerRef;
  48793. private _onPointerUpHandlerRef;
  48794. private _onResize;
  48795. /**
  48796. * Creates a new virtual joystick
  48797. * @param leftJoystick defines that the joystick is for left hand (false by default)
  48798. * @param customizations Defines the options we want to customize the VirtualJoystick
  48799. */
  48800. constructor(leftJoystick?: boolean, customizations?: Partial<VirtualJoystickCustomizations>);
  48801. /**
  48802. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  48803. * @param newJoystickSensibility defines the new sensibility
  48804. */
  48805. setJoystickSensibility(newJoystickSensibility: number): void;
  48806. private _onPointerDown;
  48807. private _onPointerMove;
  48808. private _onPointerUp;
  48809. /**
  48810. * Change the color of the virtual joystick
  48811. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  48812. */
  48813. setJoystickColor(newColor: string): void;
  48814. /**
  48815. * Size of the joystick's container
  48816. */
  48817. set containerSize(newSize: number);
  48818. get containerSize(): number;
  48819. /**
  48820. * Size of the joystick's puck
  48821. */
  48822. set puckSize(newSize: number);
  48823. get puckSize(): number;
  48824. /**
  48825. * Clears the set position of the joystick
  48826. */
  48827. clearPosition(): void;
  48828. /**
  48829. * Defines whether or not the joystick container is always visible
  48830. */
  48831. set alwaysVisible(value: boolean);
  48832. get alwaysVisible(): boolean;
  48833. /**
  48834. * Sets the constant position of the Joystick container
  48835. * @param x X axis coordinate
  48836. * @param y Y axis coordinate
  48837. */
  48838. setPosition(x: number, y: number): void;
  48839. /**
  48840. * Defines a callback to call when the joystick is touched
  48841. * @param action defines the callback
  48842. */
  48843. setActionOnTouch(action: () => any): void;
  48844. /**
  48845. * Defines which axis you'd like to control for left & right
  48846. * @param axis defines the axis to use
  48847. */
  48848. setAxisForLeftRight(axis: JoystickAxis): void;
  48849. /**
  48850. * Defines which axis you'd like to control for up & down
  48851. * @param axis defines the axis to use
  48852. */
  48853. setAxisForUpDown(axis: JoystickAxis): void;
  48854. /**
  48855. * Clears the canvas from the previous puck / container draw
  48856. */
  48857. private _clearPreviousDraw;
  48858. /**
  48859. * Loads `urlPath` to be used for the container's image
  48860. * @param urlPath defines the urlPath of an image to use
  48861. */
  48862. setContainerImage(urlPath: string): void;
  48863. /**
  48864. * Loads `urlPath` to be used for the puck's image
  48865. * @param urlPath defines the urlPath of an image to use
  48866. */
  48867. setPuckImage(urlPath: string): void;
  48868. /**
  48869. * Draws the Virtual Joystick's container
  48870. */
  48871. private _drawContainer;
  48872. /**
  48873. * Draws the Virtual Joystick's puck
  48874. */
  48875. private _drawPuck;
  48876. private _drawVirtualJoystick;
  48877. /**
  48878. * Release internal HTML canvas
  48879. */
  48880. releaseCanvas(): void;
  48881. }
  48882. }
  48883. declare module BABYLON {
  48884. interface FreeCameraInputsManager {
  48885. /**
  48886. * Add virtual joystick input support to the input manager.
  48887. * @returns the current input manager
  48888. */
  48889. addVirtualJoystick(): FreeCameraInputsManager;
  48890. }
  48891. /**
  48892. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  48893. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48894. */
  48895. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  48896. /**
  48897. * Defines the camera the input is attached to.
  48898. */
  48899. camera: FreeCamera;
  48900. private _leftjoystick;
  48901. private _rightjoystick;
  48902. /**
  48903. * Gets the left stick of the virtual joystick.
  48904. * @returns The virtual Joystick
  48905. */
  48906. getLeftJoystick(): VirtualJoystick;
  48907. /**
  48908. * Gets the right stick of the virtual joystick.
  48909. * @returns The virtual Joystick
  48910. */
  48911. getRightJoystick(): VirtualJoystick;
  48912. /**
  48913. * Update the current camera state depending on the inputs that have been used this frame.
  48914. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  48915. */
  48916. checkInputs(): void;
  48917. /**
  48918. * Attach the input controls to a specific dom element to get the input from.
  48919. */
  48920. attachControl(): void;
  48921. /**
  48922. * Detach the current controls from the specified dom element.
  48923. */
  48924. detachControl(): void;
  48925. /**
  48926. * Gets the class name of the current intput.
  48927. * @returns the class name
  48928. */
  48929. getClassName(): string;
  48930. /**
  48931. * Get the friendly name associated with the input class.
  48932. * @returns the input friendly name
  48933. */
  48934. getSimpleName(): string;
  48935. }
  48936. }
  48937. declare module BABYLON {
  48938. /**
  48939. * This represents a FPS type of camera controlled by touch.
  48940. * This is like a universal camera minus the Gamepad controls.
  48941. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  48942. */
  48943. export class TouchCamera extends FreeCamera {
  48944. /**
  48945. * Defines the touch sensibility for rotation.
  48946. * The higher the faster.
  48947. */
  48948. get touchAngularSensibility(): number;
  48949. set touchAngularSensibility(value: number);
  48950. /**
  48951. * Defines the touch sensibility for move.
  48952. * The higher the faster.
  48953. */
  48954. get touchMoveSensibility(): number;
  48955. set touchMoveSensibility(value: number);
  48956. /**
  48957. * Instantiates a new touch camera.
  48958. * This represents a FPS type of camera controlled by touch.
  48959. * This is like a universal camera minus the Gamepad controls.
  48960. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  48961. * @param name Define the name of the camera in the scene
  48962. * @param position Define the start position of the camera in the scene
  48963. * @param scene Define the scene the camera belongs to
  48964. */
  48965. constructor(name: string, position: Vector3, scene: Scene);
  48966. /**
  48967. * Gets the current object class name.
  48968. * @return the class name
  48969. */
  48970. getClassName(): string;
  48971. /** @hidden */
  48972. _setupInputs(): void;
  48973. }
  48974. }
  48975. declare module BABYLON {
  48976. /**
  48977. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  48978. * being tilted forward or back and left or right.
  48979. */
  48980. export class DeviceOrientationCamera extends FreeCamera {
  48981. private _initialQuaternion;
  48982. private _quaternionCache;
  48983. private _tmpDragQuaternion;
  48984. private _disablePointerInputWhenUsingDeviceOrientation;
  48985. /**
  48986. * Creates a new device orientation camera
  48987. * @param name The name of the camera
  48988. * @param position The start position camera
  48989. * @param scene The scene the camera belongs to
  48990. */
  48991. constructor(name: string, position: Vector3, scene: Scene);
  48992. /**
  48993. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  48994. */
  48995. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  48996. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  48997. private _dragFactor;
  48998. /**
  48999. * Enabled turning on the y axis when the orientation sensor is active
  49000. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  49001. */
  49002. enableHorizontalDragging(dragFactor?: number): void;
  49003. /**
  49004. * Gets the current instance class name ("DeviceOrientationCamera").
  49005. * This helps avoiding instanceof at run time.
  49006. * @returns the class name
  49007. */
  49008. getClassName(): string;
  49009. /**
  49010. * @hidden
  49011. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  49012. */
  49013. _checkInputs(): void;
  49014. /**
  49015. * Reset the camera to its default orientation on the specified axis only.
  49016. * @param axis The axis to reset
  49017. */
  49018. resetToCurrentRotation(axis?: Axis): void;
  49019. }
  49020. }
  49021. declare module BABYLON {
  49022. /**
  49023. * Defines supported buttons for XBox360 compatible gamepads
  49024. */
  49025. export enum Xbox360Button {
  49026. /** A */
  49027. A = 0,
  49028. /** B */
  49029. B = 1,
  49030. /** X */
  49031. X = 2,
  49032. /** Y */
  49033. Y = 3,
  49034. /** Left button */
  49035. LB = 4,
  49036. /** Right button */
  49037. RB = 5,
  49038. /** Back */
  49039. Back = 8,
  49040. /** Start */
  49041. Start = 9,
  49042. /** Left stick */
  49043. LeftStick = 10,
  49044. /** Right stick */
  49045. RightStick = 11
  49046. }
  49047. /** Defines values for XBox360 DPad */
  49048. export enum Xbox360Dpad {
  49049. /** Up */
  49050. Up = 12,
  49051. /** Down */
  49052. Down = 13,
  49053. /** Left */
  49054. Left = 14,
  49055. /** Right */
  49056. Right = 15
  49057. }
  49058. /**
  49059. * Defines a XBox360 gamepad
  49060. */
  49061. export class Xbox360Pad extends Gamepad {
  49062. private _leftTrigger;
  49063. private _rightTrigger;
  49064. private _onlefttriggerchanged;
  49065. private _onrighttriggerchanged;
  49066. private _onbuttondown;
  49067. private _onbuttonup;
  49068. private _ondpaddown;
  49069. private _ondpadup;
  49070. /** Observable raised when a button is pressed */
  49071. onButtonDownObservable: Observable<Xbox360Button>;
  49072. /** Observable raised when a button is released */
  49073. onButtonUpObservable: Observable<Xbox360Button>;
  49074. /** Observable raised when a pad is pressed */
  49075. onPadDownObservable: Observable<Xbox360Dpad>;
  49076. /** Observable raised when a pad is released */
  49077. onPadUpObservable: Observable<Xbox360Dpad>;
  49078. private _buttonA;
  49079. private _buttonB;
  49080. private _buttonX;
  49081. private _buttonY;
  49082. private _buttonBack;
  49083. private _buttonStart;
  49084. private _buttonLB;
  49085. private _buttonRB;
  49086. private _buttonLeftStick;
  49087. private _buttonRightStick;
  49088. private _dPadUp;
  49089. private _dPadDown;
  49090. private _dPadLeft;
  49091. private _dPadRight;
  49092. private _isXboxOnePad;
  49093. /**
  49094. * Creates a new XBox360 gamepad object
  49095. * @param id defines the id of this gamepad
  49096. * @param index defines its index
  49097. * @param gamepad defines the internal HTML gamepad object
  49098. * @param xboxOne defines if it is a XBox One gamepad
  49099. */
  49100. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  49101. /**
  49102. * Defines the callback to call when left trigger is pressed
  49103. * @param callback defines the callback to use
  49104. */
  49105. onlefttriggerchanged(callback: (value: number) => void): void;
  49106. /**
  49107. * Defines the callback to call when right trigger is pressed
  49108. * @param callback defines the callback to use
  49109. */
  49110. onrighttriggerchanged(callback: (value: number) => void): void;
  49111. /**
  49112. * Gets the left trigger value
  49113. */
  49114. get leftTrigger(): number;
  49115. /**
  49116. * Sets the left trigger value
  49117. */
  49118. set leftTrigger(newValue: number);
  49119. /**
  49120. * Gets the right trigger value
  49121. */
  49122. get rightTrigger(): number;
  49123. /**
  49124. * Sets the right trigger value
  49125. */
  49126. set rightTrigger(newValue: number);
  49127. /**
  49128. * Defines the callback to call when a button is pressed
  49129. * @param callback defines the callback to use
  49130. */
  49131. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  49132. /**
  49133. * Defines the callback to call when a button is released
  49134. * @param callback defines the callback to use
  49135. */
  49136. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  49137. /**
  49138. * Defines the callback to call when a pad is pressed
  49139. * @param callback defines the callback to use
  49140. */
  49141. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  49142. /**
  49143. * Defines the callback to call when a pad is released
  49144. * @param callback defines the callback to use
  49145. */
  49146. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  49147. private _setButtonValue;
  49148. private _setDPadValue;
  49149. /**
  49150. * Gets the value of the `A` button
  49151. */
  49152. get buttonA(): number;
  49153. /**
  49154. * Sets the value of the `A` button
  49155. */
  49156. set buttonA(value: number);
  49157. /**
  49158. * Gets the value of the `B` button
  49159. */
  49160. get buttonB(): number;
  49161. /**
  49162. * Sets the value of the `B` button
  49163. */
  49164. set buttonB(value: number);
  49165. /**
  49166. * Gets the value of the `X` button
  49167. */
  49168. get buttonX(): number;
  49169. /**
  49170. * Sets the value of the `X` button
  49171. */
  49172. set buttonX(value: number);
  49173. /**
  49174. * Gets the value of the `Y` button
  49175. */
  49176. get buttonY(): number;
  49177. /**
  49178. * Sets the value of the `Y` button
  49179. */
  49180. set buttonY(value: number);
  49181. /**
  49182. * Gets the value of the `Start` button
  49183. */
  49184. get buttonStart(): number;
  49185. /**
  49186. * Sets the value of the `Start` button
  49187. */
  49188. set buttonStart(value: number);
  49189. /**
  49190. * Gets the value of the `Back` button
  49191. */
  49192. get buttonBack(): number;
  49193. /**
  49194. * Sets the value of the `Back` button
  49195. */
  49196. set buttonBack(value: number);
  49197. /**
  49198. * Gets the value of the `Left` button
  49199. */
  49200. get buttonLB(): number;
  49201. /**
  49202. * Sets the value of the `Left` button
  49203. */
  49204. set buttonLB(value: number);
  49205. /**
  49206. * Gets the value of the `Right` button
  49207. */
  49208. get buttonRB(): number;
  49209. /**
  49210. * Sets the value of the `Right` button
  49211. */
  49212. set buttonRB(value: number);
  49213. /**
  49214. * Gets the value of the Left joystick
  49215. */
  49216. get buttonLeftStick(): number;
  49217. /**
  49218. * Sets the value of the Left joystick
  49219. */
  49220. set buttonLeftStick(value: number);
  49221. /**
  49222. * Gets the value of the Right joystick
  49223. */
  49224. get buttonRightStick(): number;
  49225. /**
  49226. * Sets the value of the Right joystick
  49227. */
  49228. set buttonRightStick(value: number);
  49229. /**
  49230. * Gets the value of D-pad up
  49231. */
  49232. get dPadUp(): number;
  49233. /**
  49234. * Sets the value of D-pad up
  49235. */
  49236. set dPadUp(value: number);
  49237. /**
  49238. * Gets the value of D-pad down
  49239. */
  49240. get dPadDown(): number;
  49241. /**
  49242. * Sets the value of D-pad down
  49243. */
  49244. set dPadDown(value: number);
  49245. /**
  49246. * Gets the value of D-pad left
  49247. */
  49248. get dPadLeft(): number;
  49249. /**
  49250. * Sets the value of D-pad left
  49251. */
  49252. set dPadLeft(value: number);
  49253. /**
  49254. * Gets the value of D-pad right
  49255. */
  49256. get dPadRight(): number;
  49257. /**
  49258. * Sets the value of D-pad right
  49259. */
  49260. set dPadRight(value: number);
  49261. /**
  49262. * Force the gamepad to synchronize with device values
  49263. */
  49264. update(): void;
  49265. /**
  49266. * Disposes the gamepad
  49267. */
  49268. dispose(): void;
  49269. }
  49270. }
  49271. declare module BABYLON {
  49272. /**
  49273. * Defines supported buttons for DualShock compatible gamepads
  49274. */
  49275. export enum DualShockButton {
  49276. /** Cross */
  49277. Cross = 0,
  49278. /** Circle */
  49279. Circle = 1,
  49280. /** Square */
  49281. Square = 2,
  49282. /** Triangle */
  49283. Triangle = 3,
  49284. /** L1 */
  49285. L1 = 4,
  49286. /** R1 */
  49287. R1 = 5,
  49288. /** Share */
  49289. Share = 8,
  49290. /** Options */
  49291. Options = 9,
  49292. /** Left stick */
  49293. LeftStick = 10,
  49294. /** Right stick */
  49295. RightStick = 11
  49296. }
  49297. /** Defines values for DualShock DPad */
  49298. export enum DualShockDpad {
  49299. /** Up */
  49300. Up = 12,
  49301. /** Down */
  49302. Down = 13,
  49303. /** Left */
  49304. Left = 14,
  49305. /** Right */
  49306. Right = 15
  49307. }
  49308. /**
  49309. * Defines a DualShock gamepad
  49310. */
  49311. export class DualShockPad extends Gamepad {
  49312. private _leftTrigger;
  49313. private _rightTrigger;
  49314. private _onlefttriggerchanged;
  49315. private _onrighttriggerchanged;
  49316. private _onbuttondown;
  49317. private _onbuttonup;
  49318. private _ondpaddown;
  49319. private _ondpadup;
  49320. /** Observable raised when a button is pressed */
  49321. onButtonDownObservable: Observable<DualShockButton>;
  49322. /** Observable raised when a button is released */
  49323. onButtonUpObservable: Observable<DualShockButton>;
  49324. /** Observable raised when a pad is pressed */
  49325. onPadDownObservable: Observable<DualShockDpad>;
  49326. /** Observable raised when a pad is released */
  49327. onPadUpObservable: Observable<DualShockDpad>;
  49328. private _buttonCross;
  49329. private _buttonCircle;
  49330. private _buttonSquare;
  49331. private _buttonTriangle;
  49332. private _buttonShare;
  49333. private _buttonOptions;
  49334. private _buttonL1;
  49335. private _buttonR1;
  49336. private _buttonLeftStick;
  49337. private _buttonRightStick;
  49338. private _dPadUp;
  49339. private _dPadDown;
  49340. private _dPadLeft;
  49341. private _dPadRight;
  49342. /**
  49343. * Creates a new DualShock gamepad object
  49344. * @param id defines the id of this gamepad
  49345. * @param index defines its index
  49346. * @param gamepad defines the internal HTML gamepad object
  49347. */
  49348. constructor(id: string, index: number, gamepad: any);
  49349. /**
  49350. * Defines the callback to call when left trigger is pressed
  49351. * @param callback defines the callback to use
  49352. */
  49353. onlefttriggerchanged(callback: (value: number) => void): void;
  49354. /**
  49355. * Defines the callback to call when right trigger is pressed
  49356. * @param callback defines the callback to use
  49357. */
  49358. onrighttriggerchanged(callback: (value: number) => void): void;
  49359. /**
  49360. * Gets the left trigger value
  49361. */
  49362. get leftTrigger(): number;
  49363. /**
  49364. * Sets the left trigger value
  49365. */
  49366. set leftTrigger(newValue: number);
  49367. /**
  49368. * Gets the right trigger value
  49369. */
  49370. get rightTrigger(): number;
  49371. /**
  49372. * Sets the right trigger value
  49373. */
  49374. set rightTrigger(newValue: number);
  49375. /**
  49376. * Defines the callback to call when a button is pressed
  49377. * @param callback defines the callback to use
  49378. */
  49379. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  49380. /**
  49381. * Defines the callback to call when a button is released
  49382. * @param callback defines the callback to use
  49383. */
  49384. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  49385. /**
  49386. * Defines the callback to call when a pad is pressed
  49387. * @param callback defines the callback to use
  49388. */
  49389. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  49390. /**
  49391. * Defines the callback to call when a pad is released
  49392. * @param callback defines the callback to use
  49393. */
  49394. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  49395. private _setButtonValue;
  49396. private _setDPadValue;
  49397. /**
  49398. * Gets the value of the `Cross` button
  49399. */
  49400. get buttonCross(): number;
  49401. /**
  49402. * Sets the value of the `Cross` button
  49403. */
  49404. set buttonCross(value: number);
  49405. /**
  49406. * Gets the value of the `Circle` button
  49407. */
  49408. get buttonCircle(): number;
  49409. /**
  49410. * Sets the value of the `Circle` button
  49411. */
  49412. set buttonCircle(value: number);
  49413. /**
  49414. * Gets the value of the `Square` button
  49415. */
  49416. get buttonSquare(): number;
  49417. /**
  49418. * Sets the value of the `Square` button
  49419. */
  49420. set buttonSquare(value: number);
  49421. /**
  49422. * Gets the value of the `Triangle` button
  49423. */
  49424. get buttonTriangle(): number;
  49425. /**
  49426. * Sets the value of the `Triangle` button
  49427. */
  49428. set buttonTriangle(value: number);
  49429. /**
  49430. * Gets the value of the `Options` button
  49431. */
  49432. get buttonOptions(): number;
  49433. /**
  49434. * Sets the value of the `Options` button
  49435. */
  49436. set buttonOptions(value: number);
  49437. /**
  49438. * Gets the value of the `Share` button
  49439. */
  49440. get buttonShare(): number;
  49441. /**
  49442. * Sets the value of the `Share` button
  49443. */
  49444. set buttonShare(value: number);
  49445. /**
  49446. * Gets the value of the `L1` button
  49447. */
  49448. get buttonL1(): number;
  49449. /**
  49450. * Sets the value of the `L1` button
  49451. */
  49452. set buttonL1(value: number);
  49453. /**
  49454. * Gets the value of the `R1` button
  49455. */
  49456. get buttonR1(): number;
  49457. /**
  49458. * Sets the value of the `R1` button
  49459. */
  49460. set buttonR1(value: number);
  49461. /**
  49462. * Gets the value of the Left joystick
  49463. */
  49464. get buttonLeftStick(): number;
  49465. /**
  49466. * Sets the value of the Left joystick
  49467. */
  49468. set buttonLeftStick(value: number);
  49469. /**
  49470. * Gets the value of the Right joystick
  49471. */
  49472. get buttonRightStick(): number;
  49473. /**
  49474. * Sets the value of the Right joystick
  49475. */
  49476. set buttonRightStick(value: number);
  49477. /**
  49478. * Gets the value of D-pad up
  49479. */
  49480. get dPadUp(): number;
  49481. /**
  49482. * Sets the value of D-pad up
  49483. */
  49484. set dPadUp(value: number);
  49485. /**
  49486. * Gets the value of D-pad down
  49487. */
  49488. get dPadDown(): number;
  49489. /**
  49490. * Sets the value of D-pad down
  49491. */
  49492. set dPadDown(value: number);
  49493. /**
  49494. * Gets the value of D-pad left
  49495. */
  49496. get dPadLeft(): number;
  49497. /**
  49498. * Sets the value of D-pad left
  49499. */
  49500. set dPadLeft(value: number);
  49501. /**
  49502. * Gets the value of D-pad right
  49503. */
  49504. get dPadRight(): number;
  49505. /**
  49506. * Sets the value of D-pad right
  49507. */
  49508. set dPadRight(value: number);
  49509. /**
  49510. * Force the gamepad to synchronize with device values
  49511. */
  49512. update(): void;
  49513. /**
  49514. * Disposes the gamepad
  49515. */
  49516. dispose(): void;
  49517. }
  49518. }
  49519. declare module BABYLON {
  49520. /**
  49521. * Manager for handling gamepads
  49522. */
  49523. export class GamepadManager {
  49524. private _scene?;
  49525. private _babylonGamepads;
  49526. private _oneGamepadConnected;
  49527. /** @hidden */
  49528. _isMonitoring: boolean;
  49529. private _gamepadEventSupported;
  49530. private _gamepadSupport?;
  49531. /**
  49532. * observable to be triggered when the gamepad controller has been connected
  49533. */
  49534. onGamepadConnectedObservable: Observable<Gamepad>;
  49535. /**
  49536. * observable to be triggered when the gamepad controller has been disconnected
  49537. */
  49538. onGamepadDisconnectedObservable: Observable<Gamepad>;
  49539. private _onGamepadConnectedEvent;
  49540. private _onGamepadDisconnectedEvent;
  49541. /**
  49542. * Initializes the gamepad manager
  49543. * @param _scene BabylonJS scene
  49544. */
  49545. constructor(_scene?: Scene | undefined);
  49546. /**
  49547. * The gamepads in the game pad manager
  49548. */
  49549. get gamepads(): Gamepad[];
  49550. /**
  49551. * Get the gamepad controllers based on type
  49552. * @param type The type of gamepad controller
  49553. * @returns Nullable gamepad
  49554. */
  49555. getGamepadByType(type?: number): Nullable<Gamepad>;
  49556. /**
  49557. * Disposes the gamepad manager
  49558. */
  49559. dispose(): void;
  49560. private _addNewGamepad;
  49561. private _startMonitoringGamepads;
  49562. private _stopMonitoringGamepads;
  49563. /** @hidden */
  49564. _checkGamepadsStatus(): void;
  49565. private _updateGamepadObjects;
  49566. }
  49567. }
  49568. declare module BABYLON {
  49569. interface Scene {
  49570. /** @hidden */
  49571. _gamepadManager: Nullable<GamepadManager>;
  49572. /**
  49573. * Gets the gamepad manager associated with the scene
  49574. * @see https://doc.babylonjs.com/how_to/how_to_use_gamepads
  49575. */
  49576. gamepadManager: GamepadManager;
  49577. }
  49578. /**
  49579. * Interface representing a free camera inputs manager
  49580. */
  49581. interface FreeCameraInputsManager {
  49582. /**
  49583. * Adds gamepad input support to the FreeCameraInputsManager.
  49584. * @returns the FreeCameraInputsManager
  49585. */
  49586. addGamepad(): FreeCameraInputsManager;
  49587. }
  49588. /**
  49589. * Interface representing an arc rotate camera inputs manager
  49590. */
  49591. interface ArcRotateCameraInputsManager {
  49592. /**
  49593. * Adds gamepad input support to the ArcRotateCamera InputManager.
  49594. * @returns the camera inputs manager
  49595. */
  49596. addGamepad(): ArcRotateCameraInputsManager;
  49597. }
  49598. /**
  49599. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  49600. */
  49601. export class GamepadSystemSceneComponent implements ISceneComponent {
  49602. /**
  49603. * The component name helpfull to identify the component in the list of scene components.
  49604. */
  49605. readonly name: string;
  49606. /**
  49607. * The scene the component belongs to.
  49608. */
  49609. scene: Scene;
  49610. /**
  49611. * Creates a new instance of the component for the given scene
  49612. * @param scene Defines the scene to register the component in
  49613. */
  49614. constructor(scene: Scene);
  49615. /**
  49616. * Registers the component in a given scene
  49617. */
  49618. register(): void;
  49619. /**
  49620. * Rebuilds the elements related to this component in case of
  49621. * context lost for instance.
  49622. */
  49623. rebuild(): void;
  49624. /**
  49625. * Disposes the component and the associated ressources
  49626. */
  49627. dispose(): void;
  49628. private _beforeCameraUpdate;
  49629. }
  49630. }
  49631. declare module BABYLON {
  49632. /**
  49633. * 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,
  49634. * which still works and will still be found in many Playgrounds.
  49635. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  49636. */
  49637. export class UniversalCamera extends TouchCamera {
  49638. /**
  49639. * Defines the gamepad rotation sensiblity.
  49640. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  49641. */
  49642. get gamepadAngularSensibility(): number;
  49643. set gamepadAngularSensibility(value: number);
  49644. /**
  49645. * Defines the gamepad move sensiblity.
  49646. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  49647. */
  49648. get gamepadMoveSensibility(): number;
  49649. set gamepadMoveSensibility(value: number);
  49650. /**
  49651. * 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,
  49652. * which still works and will still be found in many Playgrounds.
  49653. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  49654. * @param name Define the name of the camera in the scene
  49655. * @param position Define the start position of the camera in the scene
  49656. * @param scene Define the scene the camera belongs to
  49657. */
  49658. constructor(name: string, position: Vector3, scene: Scene);
  49659. /**
  49660. * Gets the current object class name.
  49661. * @return the class name
  49662. */
  49663. getClassName(): string;
  49664. }
  49665. }
  49666. declare module BABYLON {
  49667. /**
  49668. * This represents a FPS type of camera. This is only here for back compat purpose.
  49669. * Please use the UniversalCamera instead as both are identical.
  49670. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  49671. */
  49672. export class GamepadCamera extends UniversalCamera {
  49673. /**
  49674. * Instantiates a new Gamepad Camera
  49675. * This represents a FPS type of camera. This is only here for back compat purpose.
  49676. * Please use the UniversalCamera instead as both are identical.
  49677. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  49678. * @param name Define the name of the camera in the scene
  49679. * @param position Define the start position of the camera in the scene
  49680. * @param scene Define the scene the camera belongs to
  49681. */
  49682. constructor(name: string, position: Vector3, scene: Scene);
  49683. /**
  49684. * Gets the current object class name.
  49685. * @return the class name
  49686. */
  49687. getClassName(): string;
  49688. }
  49689. }
  49690. declare module BABYLON {
  49691. /** @hidden */
  49692. export var passPixelShader: {
  49693. name: string;
  49694. shader: string;
  49695. };
  49696. }
  49697. declare module BABYLON {
  49698. /** @hidden */
  49699. export var passCubePixelShader: {
  49700. name: string;
  49701. shader: string;
  49702. };
  49703. }
  49704. declare module BABYLON {
  49705. /**
  49706. * PassPostProcess which produces an output the same as it's input
  49707. */
  49708. export class PassPostProcess extends PostProcess {
  49709. /**
  49710. * Gets a string identifying the name of the class
  49711. * @returns "PassPostProcess" string
  49712. */
  49713. getClassName(): string;
  49714. /**
  49715. * Creates the PassPostProcess
  49716. * @param name The name of the effect.
  49717. * @param options The required width/height ratio to downsize to before computing the render pass.
  49718. * @param camera The camera to apply the render pass to.
  49719. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  49720. * @param engine The engine which the post process will be applied. (default: current engine)
  49721. * @param reusable If the post process can be reused on the same frame. (default: false)
  49722. * @param textureType The type of texture to be used when performing the post processing.
  49723. * @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)
  49724. */
  49725. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  49726. /** @hidden */
  49727. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassPostProcess;
  49728. }
  49729. /**
  49730. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  49731. */
  49732. export class PassCubePostProcess extends PostProcess {
  49733. private _face;
  49734. /**
  49735. * Gets or sets the cube face to display.
  49736. * * 0 is +X
  49737. * * 1 is -X
  49738. * * 2 is +Y
  49739. * * 3 is -Y
  49740. * * 4 is +Z
  49741. * * 5 is -Z
  49742. */
  49743. get face(): number;
  49744. set face(value: number);
  49745. /**
  49746. * Gets a string identifying the name of the class
  49747. * @returns "PassCubePostProcess" string
  49748. */
  49749. getClassName(): string;
  49750. /**
  49751. * Creates the PassCubePostProcess
  49752. * @param name The name of the effect.
  49753. * @param options The required width/height ratio to downsize to before computing the render pass.
  49754. * @param camera The camera to apply the render pass to.
  49755. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  49756. * @param engine The engine which the post process will be applied. (default: current engine)
  49757. * @param reusable If the post process can be reused on the same frame. (default: false)
  49758. * @param textureType The type of texture to be used when performing the post processing.
  49759. * @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)
  49760. */
  49761. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  49762. /** @hidden */
  49763. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassCubePostProcess;
  49764. }
  49765. }
  49766. declare module BABYLON {
  49767. /** @hidden */
  49768. export var anaglyphPixelShader: {
  49769. name: string;
  49770. shader: string;
  49771. };
  49772. }
  49773. declare module BABYLON {
  49774. /**
  49775. * Postprocess used to generate anaglyphic rendering
  49776. */
  49777. export class AnaglyphPostProcess extends PostProcess {
  49778. private _passedProcess;
  49779. /**
  49780. * Gets a string identifying the name of the class
  49781. * @returns "AnaglyphPostProcess" string
  49782. */
  49783. getClassName(): string;
  49784. /**
  49785. * Creates a new AnaglyphPostProcess
  49786. * @param name defines postprocess name
  49787. * @param options defines creation options or target ratio scale
  49788. * @param rigCameras defines cameras using this postprocess
  49789. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  49790. * @param engine defines hosting engine
  49791. * @param reusable defines if the postprocess will be reused multiple times per frame
  49792. */
  49793. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  49794. }
  49795. }
  49796. declare module BABYLON {
  49797. /**
  49798. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  49799. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  49800. */
  49801. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  49802. /**
  49803. * Creates a new AnaglyphArcRotateCamera
  49804. * @param name defines camera name
  49805. * @param alpha defines alpha angle (in radians)
  49806. * @param beta defines beta angle (in radians)
  49807. * @param radius defines radius
  49808. * @param target defines camera target
  49809. * @param interaxialDistance defines distance between each color axis
  49810. * @param scene defines the hosting scene
  49811. */
  49812. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  49813. /**
  49814. * Gets camera class name
  49815. * @returns AnaglyphArcRotateCamera
  49816. */
  49817. getClassName(): string;
  49818. }
  49819. }
  49820. declare module BABYLON {
  49821. /**
  49822. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  49823. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  49824. */
  49825. export class AnaglyphFreeCamera extends FreeCamera {
  49826. /**
  49827. * Creates a new AnaglyphFreeCamera
  49828. * @param name defines camera name
  49829. * @param position defines initial position
  49830. * @param interaxialDistance defines distance between each color axis
  49831. * @param scene defines the hosting scene
  49832. */
  49833. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  49834. /**
  49835. * Gets camera class name
  49836. * @returns AnaglyphFreeCamera
  49837. */
  49838. getClassName(): string;
  49839. }
  49840. }
  49841. declare module BABYLON {
  49842. /**
  49843. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  49844. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  49845. */
  49846. export class AnaglyphGamepadCamera extends GamepadCamera {
  49847. /**
  49848. * Creates a new AnaglyphGamepadCamera
  49849. * @param name defines camera name
  49850. * @param position defines initial position
  49851. * @param interaxialDistance defines distance between each color axis
  49852. * @param scene defines the hosting scene
  49853. */
  49854. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  49855. /**
  49856. * Gets camera class name
  49857. * @returns AnaglyphGamepadCamera
  49858. */
  49859. getClassName(): string;
  49860. }
  49861. }
  49862. declare module BABYLON {
  49863. /**
  49864. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  49865. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  49866. */
  49867. export class AnaglyphUniversalCamera extends UniversalCamera {
  49868. /**
  49869. * Creates a new AnaglyphUniversalCamera
  49870. * @param name defines camera name
  49871. * @param position defines initial position
  49872. * @param interaxialDistance defines distance between each color axis
  49873. * @param scene defines the hosting scene
  49874. */
  49875. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  49876. /**
  49877. * Gets camera class name
  49878. * @returns AnaglyphUniversalCamera
  49879. */
  49880. getClassName(): string;
  49881. }
  49882. }
  49883. declare module BABYLON {
  49884. /**
  49885. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  49886. * @see https://doc.babylonjs.com/features/cameras
  49887. */
  49888. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  49889. /**
  49890. * Creates a new StereoscopicArcRotateCamera
  49891. * @param name defines camera name
  49892. * @param alpha defines alpha angle (in radians)
  49893. * @param beta defines beta angle (in radians)
  49894. * @param radius defines radius
  49895. * @param target defines camera target
  49896. * @param interaxialDistance defines distance between each color axis
  49897. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  49898. * @param scene defines the hosting scene
  49899. */
  49900. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  49901. /**
  49902. * Gets camera class name
  49903. * @returns StereoscopicArcRotateCamera
  49904. */
  49905. getClassName(): string;
  49906. }
  49907. }
  49908. declare module BABYLON {
  49909. /**
  49910. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  49911. * @see https://doc.babylonjs.com/features/cameras
  49912. */
  49913. export class StereoscopicFreeCamera extends FreeCamera {
  49914. /**
  49915. * Creates a new StereoscopicFreeCamera
  49916. * @param name defines camera name
  49917. * @param position defines initial position
  49918. * @param interaxialDistance defines distance between each color axis
  49919. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  49920. * @param scene defines the hosting scene
  49921. */
  49922. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  49923. /**
  49924. * Gets camera class name
  49925. * @returns StereoscopicFreeCamera
  49926. */
  49927. getClassName(): string;
  49928. }
  49929. }
  49930. declare module BABYLON {
  49931. /**
  49932. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  49933. * @see https://doc.babylonjs.com/features/cameras
  49934. */
  49935. export class StereoscopicGamepadCamera extends GamepadCamera {
  49936. /**
  49937. * Creates a new StereoscopicGamepadCamera
  49938. * @param name defines camera name
  49939. * @param position defines initial position
  49940. * @param interaxialDistance defines distance between each color axis
  49941. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  49942. * @param scene defines the hosting scene
  49943. */
  49944. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  49945. /**
  49946. * Gets camera class name
  49947. * @returns StereoscopicGamepadCamera
  49948. */
  49949. getClassName(): string;
  49950. }
  49951. }
  49952. declare module BABYLON {
  49953. /**
  49954. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  49955. * @see https://doc.babylonjs.com/features/cameras
  49956. */
  49957. export class StereoscopicUniversalCamera extends UniversalCamera {
  49958. /**
  49959. * Creates a new StereoscopicUniversalCamera
  49960. * @param name defines camera name
  49961. * @param position defines initial position
  49962. * @param interaxialDistance defines distance between each color axis
  49963. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  49964. * @param scene defines the hosting scene
  49965. */
  49966. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  49967. /**
  49968. * Gets camera class name
  49969. * @returns StereoscopicUniversalCamera
  49970. */
  49971. getClassName(): string;
  49972. }
  49973. }
  49974. declare module BABYLON {
  49975. /**
  49976. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  49977. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  49978. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  49979. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  49980. */
  49981. export class VirtualJoysticksCamera extends FreeCamera {
  49982. /**
  49983. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  49984. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  49985. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  49986. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  49987. * @param name Define the name of the camera in the scene
  49988. * @param position Define the start position of the camera in the scene
  49989. * @param scene Define the scene the camera belongs to
  49990. */
  49991. constructor(name: string, position: Vector3, scene: Scene);
  49992. /**
  49993. * Gets the current object class name.
  49994. * @return the class name
  49995. */
  49996. getClassName(): string;
  49997. }
  49998. }
  49999. declare module BABYLON {
  50000. /**
  50001. * This represents all the required metrics to create a VR camera.
  50002. * @see https://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  50003. */
  50004. export class VRCameraMetrics {
  50005. /**
  50006. * Define the horizontal resolution off the screen.
  50007. */
  50008. hResolution: number;
  50009. /**
  50010. * Define the vertical resolution off the screen.
  50011. */
  50012. vResolution: number;
  50013. /**
  50014. * Define the horizontal screen size.
  50015. */
  50016. hScreenSize: number;
  50017. /**
  50018. * Define the vertical screen size.
  50019. */
  50020. vScreenSize: number;
  50021. /**
  50022. * Define the vertical screen center position.
  50023. */
  50024. vScreenCenter: number;
  50025. /**
  50026. * Define the distance of the eyes to the screen.
  50027. */
  50028. eyeToScreenDistance: number;
  50029. /**
  50030. * Define the distance between both lenses
  50031. */
  50032. lensSeparationDistance: number;
  50033. /**
  50034. * Define the distance between both viewer's eyes.
  50035. */
  50036. interpupillaryDistance: number;
  50037. /**
  50038. * Define the distortion factor of the VR postprocess.
  50039. * Please, touch with care.
  50040. */
  50041. distortionK: number[];
  50042. /**
  50043. * Define the chromatic aberration correction factors for the VR post process.
  50044. */
  50045. chromaAbCorrection: number[];
  50046. /**
  50047. * Define the scale factor of the post process.
  50048. * The smaller the better but the slower.
  50049. */
  50050. postProcessScaleFactor: number;
  50051. /**
  50052. * Define an offset for the lens center.
  50053. */
  50054. lensCenterOffset: number;
  50055. /**
  50056. * Define if the current vr camera should compensate the distortion of the lense or not.
  50057. */
  50058. compensateDistortion: boolean;
  50059. /**
  50060. * Defines if multiview should be enabled when rendering (Default: false)
  50061. */
  50062. multiviewEnabled: boolean;
  50063. /**
  50064. * Gets the rendering aspect ratio based on the provided resolutions.
  50065. */
  50066. get aspectRatio(): number;
  50067. /**
  50068. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  50069. */
  50070. get aspectRatioFov(): number;
  50071. /**
  50072. * @hidden
  50073. */
  50074. get leftHMatrix(): Matrix;
  50075. /**
  50076. * @hidden
  50077. */
  50078. get rightHMatrix(): Matrix;
  50079. /**
  50080. * @hidden
  50081. */
  50082. get leftPreViewMatrix(): Matrix;
  50083. /**
  50084. * @hidden
  50085. */
  50086. get rightPreViewMatrix(): Matrix;
  50087. /**
  50088. * Get the default VRMetrics based on the most generic setup.
  50089. * @returns the default vr metrics
  50090. */
  50091. static GetDefault(): VRCameraMetrics;
  50092. }
  50093. }
  50094. declare module BABYLON {
  50095. /** @hidden */
  50096. export var vrDistortionCorrectionPixelShader: {
  50097. name: string;
  50098. shader: string;
  50099. };
  50100. }
  50101. declare module BABYLON {
  50102. /**
  50103. * VRDistortionCorrectionPostProcess used for mobile VR
  50104. */
  50105. export class VRDistortionCorrectionPostProcess extends PostProcess {
  50106. private _isRightEye;
  50107. private _distortionFactors;
  50108. private _postProcessScaleFactor;
  50109. private _lensCenterOffset;
  50110. private _scaleIn;
  50111. private _scaleFactor;
  50112. private _lensCenter;
  50113. /**
  50114. * Gets a string identifying the name of the class
  50115. * @returns "VRDistortionCorrectionPostProcess" string
  50116. */
  50117. getClassName(): string;
  50118. /**
  50119. * Initializes the VRDistortionCorrectionPostProcess
  50120. * @param name The name of the effect.
  50121. * @param camera The camera to apply the render pass to.
  50122. * @param isRightEye If this is for the right eye distortion
  50123. * @param vrMetrics All the required metrics for the VR camera
  50124. */
  50125. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  50126. }
  50127. }
  50128. declare module BABYLON {
  50129. /**
  50130. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  50131. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  50132. */
  50133. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  50134. /**
  50135. * Creates a new VRDeviceOrientationArcRotateCamera
  50136. * @param name defines camera name
  50137. * @param alpha defines the camera rotation along the logitudinal axis
  50138. * @param beta defines the camera rotation along the latitudinal axis
  50139. * @param radius defines the camera distance from its target
  50140. * @param target defines the camera target
  50141. * @param scene defines the scene the camera belongs to
  50142. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  50143. * @param vrCameraMetrics defines the vr metrics associated to the camera
  50144. */
  50145. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  50146. /**
  50147. * Gets camera class name
  50148. * @returns VRDeviceOrientationArcRotateCamera
  50149. */
  50150. getClassName(): string;
  50151. }
  50152. }
  50153. declare module BABYLON {
  50154. /**
  50155. * Camera used to simulate VR rendering (based on FreeCamera)
  50156. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  50157. */
  50158. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  50159. /**
  50160. * Creates a new VRDeviceOrientationFreeCamera
  50161. * @param name defines camera name
  50162. * @param position defines the start position of the camera
  50163. * @param scene defines the scene the camera belongs to
  50164. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  50165. * @param vrCameraMetrics defines the vr metrics associated to the camera
  50166. */
  50167. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  50168. /**
  50169. * Gets camera class name
  50170. * @returns VRDeviceOrientationFreeCamera
  50171. */
  50172. getClassName(): string;
  50173. }
  50174. }
  50175. declare module BABYLON {
  50176. /**
  50177. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  50178. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  50179. */
  50180. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  50181. /**
  50182. * Creates a new VRDeviceOrientationGamepadCamera
  50183. * @param name defines camera name
  50184. * @param position defines the start position of the camera
  50185. * @param scene defines the scene the camera belongs to
  50186. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  50187. * @param vrCameraMetrics defines the vr metrics associated to the camera
  50188. */
  50189. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  50190. /**
  50191. * Gets camera class name
  50192. * @returns VRDeviceOrientationGamepadCamera
  50193. */
  50194. getClassName(): string;
  50195. }
  50196. }
  50197. declare module BABYLON {
  50198. /**
  50199. * A class extending Texture allowing drawing on a texture
  50200. * @see https://doc.babylonjs.com/how_to/dynamictexture
  50201. */
  50202. export class DynamicTexture extends Texture {
  50203. private _generateMipMaps;
  50204. private _canvas;
  50205. private _context;
  50206. /**
  50207. * Creates a DynamicTexture
  50208. * @param name defines the name of the texture
  50209. * @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
  50210. * @param scene defines the scene where you want the texture
  50211. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  50212. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  50213. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  50214. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  50215. */
  50216. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number, invertY?: boolean);
  50217. /**
  50218. * Get the current class name of the texture useful for serialization or dynamic coding.
  50219. * @returns "DynamicTexture"
  50220. */
  50221. getClassName(): string;
  50222. /**
  50223. * Gets the current state of canRescale
  50224. */
  50225. get canRescale(): boolean;
  50226. private _recreate;
  50227. /**
  50228. * Scales the texture
  50229. * @param ratio the scale factor to apply to both width and height
  50230. */
  50231. scale(ratio: number): void;
  50232. /**
  50233. * Resizes the texture
  50234. * @param width the new width
  50235. * @param height the new height
  50236. */
  50237. scaleTo(width: number, height: number): void;
  50238. /**
  50239. * Gets the context of the canvas used by the texture
  50240. * @returns the canvas context of the dynamic texture
  50241. */
  50242. getContext(): CanvasRenderingContext2D;
  50243. /**
  50244. * Clears the texture
  50245. */
  50246. clear(): void;
  50247. /**
  50248. * Updates the texture
  50249. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  50250. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  50251. */
  50252. update(invertY?: boolean, premulAlpha?: boolean): void;
  50253. /**
  50254. * Draws text onto the texture
  50255. * @param text defines the text to be drawn
  50256. * @param x defines the placement of the text from the left
  50257. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  50258. * @param font defines the font to be used with font-style, font-size, font-name
  50259. * @param color defines the color used for the text
  50260. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  50261. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  50262. * @param update defines whether texture is immediately update (default is true)
  50263. */
  50264. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  50265. /**
  50266. * Clones the texture
  50267. * @returns the clone of the texture.
  50268. */
  50269. clone(): DynamicTexture;
  50270. /**
  50271. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  50272. * @returns a serialized dynamic texture object
  50273. */
  50274. serialize(): any;
  50275. private _IsCanvasElement;
  50276. /** @hidden */
  50277. _rebuild(): void;
  50278. }
  50279. }
  50280. declare module BABYLON {
  50281. /**
  50282. * Class containing static functions to help procedurally build meshes
  50283. */
  50284. export class GroundBuilder {
  50285. /**
  50286. * Creates a ground mesh
  50287. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  50288. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  50289. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50290. * @param name defines the name of the mesh
  50291. * @param options defines the options used to create the mesh
  50292. * @param scene defines the hosting scene
  50293. * @returns the ground mesh
  50294. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  50295. */
  50296. static CreateGround(name: string, options: {
  50297. width?: number;
  50298. height?: number;
  50299. subdivisions?: number;
  50300. subdivisionsX?: number;
  50301. subdivisionsY?: number;
  50302. updatable?: boolean;
  50303. }, scene: any): Mesh;
  50304. /**
  50305. * Creates a tiled ground mesh
  50306. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  50307. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  50308. * * 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
  50309. * * 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
  50310. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50311. * @param name defines the name of the mesh
  50312. * @param options defines the options used to create the mesh
  50313. * @param scene defines the hosting scene
  50314. * @returns the tiled ground mesh
  50315. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  50316. */
  50317. static CreateTiledGround(name: string, options: {
  50318. xmin: number;
  50319. zmin: number;
  50320. xmax: number;
  50321. zmax: number;
  50322. subdivisions?: {
  50323. w: number;
  50324. h: number;
  50325. };
  50326. precision?: {
  50327. w: number;
  50328. h: number;
  50329. };
  50330. updatable?: boolean;
  50331. }, scene?: Nullable<Scene>): Mesh;
  50332. /**
  50333. * Creates a ground mesh from a height map
  50334. * * The parameter `url` sets the URL of the height map image resource.
  50335. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  50336. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  50337. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  50338. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  50339. * * 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.
  50340. * * 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).
  50341. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  50342. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50343. * @param name defines the name of the mesh
  50344. * @param url defines the url to the height map
  50345. * @param options defines the options used to create the mesh
  50346. * @param scene defines the hosting scene
  50347. * @returns the ground mesh
  50348. * @see https://doc.babylonjs.com/babylon101/height_map
  50349. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  50350. */
  50351. static CreateGroundFromHeightMap(name: string, url: string, options: {
  50352. width?: number;
  50353. height?: number;
  50354. subdivisions?: number;
  50355. minHeight?: number;
  50356. maxHeight?: number;
  50357. colorFilter?: Color3;
  50358. alphaFilter?: number;
  50359. updatable?: boolean;
  50360. onReady?: (mesh: GroundMesh) => void;
  50361. }, scene?: Nullable<Scene>): GroundMesh;
  50362. }
  50363. }
  50364. declare module BABYLON {
  50365. /**
  50366. * Class containing static functions to help procedurally build meshes
  50367. */
  50368. export class TorusBuilder {
  50369. /**
  50370. * Creates a torus mesh
  50371. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  50372. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  50373. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  50374. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50375. * * 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
  50376. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50377. * @param name defines the name of the mesh
  50378. * @param options defines the options used to create the mesh
  50379. * @param scene defines the hosting scene
  50380. * @returns the torus mesh
  50381. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  50382. */
  50383. static CreateTorus(name: string, options: {
  50384. diameter?: number;
  50385. thickness?: number;
  50386. tessellation?: number;
  50387. updatable?: boolean;
  50388. sideOrientation?: number;
  50389. frontUVs?: Vector4;
  50390. backUVs?: Vector4;
  50391. }, scene: any): Mesh;
  50392. }
  50393. }
  50394. declare module BABYLON {
  50395. /**
  50396. * Class containing static functions to help procedurally build meshes
  50397. */
  50398. export class CylinderBuilder {
  50399. /**
  50400. * Creates a cylinder or a cone mesh
  50401. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  50402. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  50403. * * 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.
  50404. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  50405. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  50406. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  50407. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  50408. * * 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).
  50409. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  50410. * * 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).
  50411. * * 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
  50412. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  50413. * * 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
  50414. * * 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.
  50415. * * If `enclose` is false, a ring surface is one element.
  50416. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  50417. * * 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
  50418. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50419. * * 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
  50420. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50421. * @param name defines the name of the mesh
  50422. * @param options defines the options used to create the mesh
  50423. * @param scene defines the hosting scene
  50424. * @returns the cylinder mesh
  50425. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  50426. */
  50427. static CreateCylinder(name: string, options: {
  50428. height?: number;
  50429. diameterTop?: number;
  50430. diameterBottom?: number;
  50431. diameter?: number;
  50432. tessellation?: number;
  50433. subdivisions?: number;
  50434. arc?: number;
  50435. faceColors?: Color4[];
  50436. faceUV?: Vector4[];
  50437. updatable?: boolean;
  50438. hasRings?: boolean;
  50439. enclose?: boolean;
  50440. cap?: number;
  50441. sideOrientation?: number;
  50442. frontUVs?: Vector4;
  50443. backUVs?: Vector4;
  50444. }, scene: any): Mesh;
  50445. }
  50446. }
  50447. declare module BABYLON {
  50448. /**
  50449. * States of the webXR experience
  50450. */
  50451. export enum WebXRState {
  50452. /**
  50453. * Transitioning to being in XR mode
  50454. */
  50455. ENTERING_XR = 0,
  50456. /**
  50457. * Transitioning to non XR mode
  50458. */
  50459. EXITING_XR = 1,
  50460. /**
  50461. * In XR mode and presenting
  50462. */
  50463. IN_XR = 2,
  50464. /**
  50465. * Not entered XR mode
  50466. */
  50467. NOT_IN_XR = 3
  50468. }
  50469. /**
  50470. * The state of the XR camera's tracking
  50471. */
  50472. export enum WebXRTrackingState {
  50473. /**
  50474. * No transformation received, device is not being tracked
  50475. */
  50476. NOT_TRACKING = 0,
  50477. /**
  50478. * Tracking lost - using emulated position
  50479. */
  50480. TRACKING_LOST = 1,
  50481. /**
  50482. * Transformation tracking works normally
  50483. */
  50484. TRACKING = 2
  50485. }
  50486. /**
  50487. * Abstraction of the XR render target
  50488. */
  50489. export interface WebXRRenderTarget extends IDisposable {
  50490. /**
  50491. * xrpresent context of the canvas which can be used to display/mirror xr content
  50492. */
  50493. canvasContext: WebGLRenderingContext;
  50494. /**
  50495. * xr layer for the canvas
  50496. */
  50497. xrLayer: Nullable<XRWebGLLayer>;
  50498. /**
  50499. * Initializes the xr layer for the session
  50500. * @param xrSession xr session
  50501. * @returns a promise that will resolve once the XR Layer has been created
  50502. */
  50503. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  50504. }
  50505. }
  50506. declare module BABYLON {
  50507. /**
  50508. * COnfiguration object for WebXR output canvas
  50509. */
  50510. export class WebXRManagedOutputCanvasOptions {
  50511. /**
  50512. * An optional canvas in case you wish to create it yourself and provide it here.
  50513. * If not provided, a new canvas will be created
  50514. */
  50515. canvasElement?: HTMLCanvasElement;
  50516. /**
  50517. * Options for this XR Layer output
  50518. */
  50519. canvasOptions?: XRWebGLLayerInit;
  50520. /**
  50521. * CSS styling for a newly created canvas (if not provided)
  50522. */
  50523. newCanvasCssStyle?: string;
  50524. /**
  50525. * Get the default values of the configuration object
  50526. * @param engine defines the engine to use (can be null)
  50527. * @returns default values of this configuration object
  50528. */
  50529. static GetDefaults(engine?: ThinEngine): WebXRManagedOutputCanvasOptions;
  50530. }
  50531. /**
  50532. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  50533. */
  50534. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  50535. private _options;
  50536. private _canvas;
  50537. private _engine;
  50538. private _originalCanvasSize;
  50539. /**
  50540. * Rendering context of the canvas which can be used to display/mirror xr content
  50541. */
  50542. canvasContext: WebGLRenderingContext;
  50543. /**
  50544. * xr layer for the canvas
  50545. */
  50546. xrLayer: Nullable<XRWebGLLayer>;
  50547. /**
  50548. * Obseervers registered here will be triggered when the xr layer was initialized
  50549. */
  50550. onXRLayerInitObservable: Observable<XRWebGLLayer>;
  50551. /**
  50552. * Initializes the canvas to be added/removed upon entering/exiting xr
  50553. * @param _xrSessionManager The XR Session manager
  50554. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  50555. */
  50556. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  50557. /**
  50558. * Disposes of the object
  50559. */
  50560. dispose(): void;
  50561. /**
  50562. * Initializes the xr layer for the session
  50563. * @param xrSession xr session
  50564. * @returns a promise that will resolve once the XR Layer has been created
  50565. */
  50566. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  50567. private _addCanvas;
  50568. private _removeCanvas;
  50569. private _setCanvasSize;
  50570. private _setManagedOutputCanvas;
  50571. }
  50572. }
  50573. declare module BABYLON {
  50574. /**
  50575. * Manages an XRSession to work with Babylon's engine
  50576. * @see https://doc.babylonjs.com/how_to/webxr_session_manager
  50577. */
  50578. export class WebXRSessionManager implements IDisposable {
  50579. /** The scene which the session should be created for */
  50580. scene: Scene;
  50581. private _referenceSpace;
  50582. private _rttProvider;
  50583. private _sessionEnded;
  50584. private _xrNavigator;
  50585. private baseLayer;
  50586. /**
  50587. * The base reference space from which the session started. good if you want to reset your
  50588. * reference space
  50589. */
  50590. baseReferenceSpace: XRReferenceSpace;
  50591. /**
  50592. * Current XR frame
  50593. */
  50594. currentFrame: Nullable<XRFrame>;
  50595. /** WebXR timestamp updated every frame */
  50596. currentTimestamp: number;
  50597. /**
  50598. * Used just in case of a failure to initialize an immersive session.
  50599. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  50600. */
  50601. defaultHeightCompensation: number;
  50602. /**
  50603. * Fires every time a new xrFrame arrives which can be used to update the camera
  50604. */
  50605. onXRFrameObservable: Observable<XRFrame>;
  50606. /**
  50607. * Fires when the reference space changed
  50608. */
  50609. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  50610. /**
  50611. * Fires when the xr session is ended either by the device or manually done
  50612. */
  50613. onXRSessionEnded: Observable<any>;
  50614. /**
  50615. * Fires when the xr session is ended either by the device or manually done
  50616. */
  50617. onXRSessionInit: Observable<XRSession>;
  50618. /**
  50619. * Underlying xr session
  50620. */
  50621. session: XRSession;
  50622. /**
  50623. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  50624. * or get the offset the player is currently at.
  50625. */
  50626. viewerReferenceSpace: XRReferenceSpace;
  50627. /**
  50628. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  50629. * @param scene The scene which the session should be created for
  50630. */
  50631. constructor(
  50632. /** The scene which the session should be created for */
  50633. scene: Scene);
  50634. /**
  50635. * The current reference space used in this session. This reference space can constantly change!
  50636. * It is mainly used to offset the camera's position.
  50637. */
  50638. get referenceSpace(): XRReferenceSpace;
  50639. /**
  50640. * Set a new reference space and triggers the observable
  50641. */
  50642. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  50643. /**
  50644. * Disposes of the session manager
  50645. */
  50646. dispose(): void;
  50647. /**
  50648. * Stops the xrSession and restores the render loop
  50649. * @returns Promise which resolves after it exits XR
  50650. */
  50651. exitXRAsync(): Promise<void>;
  50652. /**
  50653. * Gets the correct render target texture to be rendered this frame for this eye
  50654. * @param eye the eye for which to get the render target
  50655. * @returns the render target for the specified eye
  50656. */
  50657. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  50658. /**
  50659. * Creates a WebXRRenderTarget object for the XR session
  50660. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  50661. * @param options optional options to provide when creating a new render target
  50662. * @returns a WebXR render target to which the session can render
  50663. */
  50664. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  50665. /**
  50666. * Initializes the manager
  50667. * After initialization enterXR can be called to start an XR session
  50668. * @returns Promise which resolves after it is initialized
  50669. */
  50670. initializeAsync(): Promise<void>;
  50671. /**
  50672. * Initializes an xr session
  50673. * @param xrSessionMode mode to initialize
  50674. * @param xrSessionInit defines optional and required values to pass to the session builder
  50675. * @returns a promise which will resolve once the session has been initialized
  50676. */
  50677. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  50678. /**
  50679. * Checks if a session would be supported for the creation options specified
  50680. * @param sessionMode session mode to check if supported eg. immersive-vr
  50681. * @returns A Promise that resolves to true if supported and false if not
  50682. */
  50683. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  50684. /**
  50685. * Resets the reference space to the one started the session
  50686. */
  50687. resetReferenceSpace(): void;
  50688. /**
  50689. * Starts rendering to the xr layer
  50690. */
  50691. runXRRenderLoop(): void;
  50692. /**
  50693. * Sets the reference space on the xr session
  50694. * @param referenceSpaceType space to set
  50695. * @returns a promise that will resolve once the reference space has been set
  50696. */
  50697. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  50698. /**
  50699. * Updates the render state of the session
  50700. * @param state state to set
  50701. * @returns a promise that resolves once the render state has been updated
  50702. */
  50703. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  50704. /**
  50705. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  50706. * @param sessionMode defines the session to test
  50707. * @returns a promise with boolean as final value
  50708. */
  50709. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  50710. private _createRenderTargetTexture;
  50711. }
  50712. }
  50713. declare module BABYLON {
  50714. /**
  50715. * WebXR Camera which holds the views for the xrSession
  50716. * @see https://doc.babylonjs.com/how_to/webxr_camera
  50717. */
  50718. export class WebXRCamera extends FreeCamera {
  50719. private _xrSessionManager;
  50720. private _firstFrame;
  50721. private _referenceQuaternion;
  50722. private _referencedPosition;
  50723. private _xrInvPositionCache;
  50724. private _xrInvQuaternionCache;
  50725. private _trackingState;
  50726. /**
  50727. * Observable raised before camera teleportation
  50728. */
  50729. onBeforeCameraTeleport: Observable<Vector3>;
  50730. /**
  50731. * Observable raised after camera teleportation
  50732. */
  50733. onAfterCameraTeleport: Observable<Vector3>;
  50734. /**
  50735. * Notifies when the camera's tracking state has changed.
  50736. * Notice - will also be triggered when tracking has started (at the beginning of the session)
  50737. */
  50738. onTrackingStateChanged: Observable<WebXRTrackingState>;
  50739. /**
  50740. * Should position compensation execute on first frame.
  50741. * This is used when copying the position from a native (non XR) camera
  50742. */
  50743. compensateOnFirstFrame: boolean;
  50744. /**
  50745. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  50746. * @param name the name of the camera
  50747. * @param scene the scene to add the camera to
  50748. * @param _xrSessionManager a constructed xr session manager
  50749. */
  50750. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  50751. /**
  50752. * Get the current XR tracking state of the camera
  50753. */
  50754. get trackingState(): WebXRTrackingState;
  50755. private _setTrackingState;
  50756. /**
  50757. * Return the user's height, unrelated to the current ground.
  50758. * This will be the y position of this camera, when ground level is 0.
  50759. */
  50760. get realWorldHeight(): number;
  50761. /** @hidden */
  50762. _updateForDualEyeDebugging(): void;
  50763. /**
  50764. * Sets this camera's transformation based on a non-vr camera
  50765. * @param otherCamera the non-vr camera to copy the transformation from
  50766. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  50767. */
  50768. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  50769. /**
  50770. * Gets the current instance class name ("WebXRCamera").
  50771. * @returns the class name
  50772. */
  50773. getClassName(): string;
  50774. private _rotate180;
  50775. private _updateFromXRSession;
  50776. private _updateNumberOfRigCameras;
  50777. private _updateReferenceSpace;
  50778. private _updateReferenceSpaceOffset;
  50779. }
  50780. }
  50781. declare module BABYLON {
  50782. /**
  50783. * Defining the interface required for a (webxr) feature
  50784. */
  50785. export interface IWebXRFeature extends IDisposable {
  50786. /**
  50787. * Is this feature attached
  50788. */
  50789. attached: boolean;
  50790. /**
  50791. * Should auto-attach be disabled?
  50792. */
  50793. disableAutoAttach: boolean;
  50794. /**
  50795. * Attach the feature to the session
  50796. * Will usually be called by the features manager
  50797. *
  50798. * @param force should attachment be forced (even when already attached)
  50799. * @returns true if successful.
  50800. */
  50801. attach(force?: boolean): boolean;
  50802. /**
  50803. * Detach the feature from the session
  50804. * Will usually be called by the features manager
  50805. *
  50806. * @returns true if successful.
  50807. */
  50808. detach(): boolean;
  50809. /**
  50810. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  50811. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  50812. *
  50813. * @returns whether or not the feature is compatible in this environment
  50814. */
  50815. isCompatible(): boolean;
  50816. /**
  50817. * Was this feature disposed;
  50818. */
  50819. isDisposed: boolean;
  50820. /**
  50821. * The name of the native xr feature name, if applicable (like anchor, hit-test, or hand-tracking)
  50822. */
  50823. xrNativeFeatureName?: string;
  50824. /**
  50825. * A list of (Babylon WebXR) features this feature depends on
  50826. */
  50827. dependsOn?: string[];
  50828. }
  50829. /**
  50830. * A list of the currently available features without referencing them
  50831. */
  50832. export class WebXRFeatureName {
  50833. /**
  50834. * The name of the anchor system feature
  50835. */
  50836. static readonly ANCHOR_SYSTEM: string;
  50837. /**
  50838. * The name of the background remover feature
  50839. */
  50840. static readonly BACKGROUND_REMOVER: string;
  50841. /**
  50842. * The name of the hit test feature
  50843. */
  50844. static readonly HIT_TEST: string;
  50845. /**
  50846. * physics impostors for xr controllers feature
  50847. */
  50848. static readonly PHYSICS_CONTROLLERS: string;
  50849. /**
  50850. * The name of the plane detection feature
  50851. */
  50852. static readonly PLANE_DETECTION: string;
  50853. /**
  50854. * The name of the pointer selection feature
  50855. */
  50856. static readonly POINTER_SELECTION: string;
  50857. /**
  50858. * The name of the teleportation feature
  50859. */
  50860. static readonly TELEPORTATION: string;
  50861. /**
  50862. * The name of the feature points feature.
  50863. */
  50864. static readonly FEATURE_POINTS: string;
  50865. /**
  50866. * The name of the hand tracking feature.
  50867. */
  50868. static readonly HAND_TRACKING: string;
  50869. }
  50870. /**
  50871. * Defining the constructor of a feature. Used to register the modules.
  50872. */
  50873. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => () => IWebXRFeature;
  50874. /**
  50875. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  50876. * It is mainly used in AR sessions.
  50877. *
  50878. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  50879. */
  50880. export class WebXRFeaturesManager implements IDisposable {
  50881. private _xrSessionManager;
  50882. private static readonly _AvailableFeatures;
  50883. private _features;
  50884. /**
  50885. * constructs a new features manages.
  50886. *
  50887. * @param _xrSessionManager an instance of WebXRSessionManager
  50888. */
  50889. constructor(_xrSessionManager: WebXRSessionManager);
  50890. /**
  50891. * Used to register a module. After calling this function a developer can use this feature in the scene.
  50892. * Mainly used internally.
  50893. *
  50894. * @param featureName the name of the feature to register
  50895. * @param constructorFunction the function used to construct the module
  50896. * @param version the (babylon) version of the module
  50897. * @param stable is that a stable version of this module
  50898. */
  50899. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  50900. /**
  50901. * Returns a constructor of a specific feature.
  50902. *
  50903. * @param featureName the name of the feature to construct
  50904. * @param version the version of the feature to load
  50905. * @param xrSessionManager the xrSessionManager. Used to construct the module
  50906. * @param options optional options provided to the module.
  50907. * @returns a function that, when called, will return a new instance of this feature
  50908. */
  50909. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): () => IWebXRFeature;
  50910. /**
  50911. * Can be used to return the list of features currently registered
  50912. *
  50913. * @returns an Array of available features
  50914. */
  50915. static GetAvailableFeatures(): string[];
  50916. /**
  50917. * Gets the versions available for a specific feature
  50918. * @param featureName the name of the feature
  50919. * @returns an array with the available versions
  50920. */
  50921. static GetAvailableVersions(featureName: string): string[];
  50922. /**
  50923. * Return the latest unstable version of this feature
  50924. * @param featureName the name of the feature to search
  50925. * @returns the version number. if not found will return -1
  50926. */
  50927. static GetLatestVersionOfFeature(featureName: string): number;
  50928. /**
  50929. * Return the latest stable version of this feature
  50930. * @param featureName the name of the feature to search
  50931. * @returns the version number. if not found will return -1
  50932. */
  50933. static GetStableVersionOfFeature(featureName: string): number;
  50934. /**
  50935. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  50936. * Can be used during a session to start a feature
  50937. * @param featureName the name of feature to attach
  50938. */
  50939. attachFeature(featureName: string): void;
  50940. /**
  50941. * Can be used inside a session or when the session ends to detach a specific feature
  50942. * @param featureName the name of the feature to detach
  50943. */
  50944. detachFeature(featureName: string): void;
  50945. /**
  50946. * Used to disable an already-enabled feature
  50947. * The feature will be disposed and will be recreated once enabled.
  50948. * @param featureName the feature to disable
  50949. * @returns true if disable was successful
  50950. */
  50951. disableFeature(featureName: string | {
  50952. Name: string;
  50953. }): boolean;
  50954. /**
  50955. * dispose this features manager
  50956. */
  50957. dispose(): void;
  50958. /**
  50959. * 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.
  50960. * 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.
  50961. *
  50962. * @param featureName the name of the feature to load or the class of the feature
  50963. * @param version optional version to load. if not provided the latest version will be enabled
  50964. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  50965. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  50966. * @param required is this feature required to the app. If set to true the session init will fail if the feature is not available.
  50967. * @returns a new constructed feature or throws an error if feature not found.
  50968. */
  50969. enableFeature(featureName: string | {
  50970. Name: string;
  50971. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean, required?: boolean): IWebXRFeature;
  50972. /**
  50973. * get the implementation of an enabled feature.
  50974. * @param featureName the name of the feature to load
  50975. * @returns the feature class, if found
  50976. */
  50977. getEnabledFeature(featureName: string): IWebXRFeature;
  50978. /**
  50979. * Get the list of enabled features
  50980. * @returns an array of enabled features
  50981. */
  50982. getEnabledFeatures(): string[];
  50983. /**
  50984. * This function will exten the session creation configuration object with enabled features.
  50985. * If, for example, the anchors feature is enabled, it will be automatically added to the optional or required features list,
  50986. * according to the defined "required" variable, provided during enableFeature call
  50987. * @param xrSessionInit the xr Session init object to extend
  50988. *
  50989. * @returns an extended XRSessionInit object
  50990. */
  50991. extendXRSessionInitObject(xrSessionInit: XRSessionInit): XRSessionInit;
  50992. }
  50993. }
  50994. declare module BABYLON {
  50995. /**
  50996. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  50997. * @see https://doc.babylonjs.com/how_to/webxr_experience_helpers
  50998. */
  50999. export class WebXRExperienceHelper implements IDisposable {
  51000. private scene;
  51001. private _nonVRCamera;
  51002. private _originalSceneAutoClear;
  51003. private _supported;
  51004. /**
  51005. * Camera used to render xr content
  51006. */
  51007. camera: WebXRCamera;
  51008. /** A features manager for this xr session */
  51009. featuresManager: WebXRFeaturesManager;
  51010. /**
  51011. * Observers registered here will be triggered after the camera's initial transformation is set
  51012. * This can be used to set a different ground level or an extra rotation.
  51013. *
  51014. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  51015. * to the position set after this observable is done executing.
  51016. */
  51017. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  51018. /**
  51019. * Fires when the state of the experience helper has changed
  51020. */
  51021. onStateChangedObservable: Observable<WebXRState>;
  51022. /** Session manager used to keep track of xr session */
  51023. sessionManager: WebXRSessionManager;
  51024. /**
  51025. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  51026. */
  51027. state: WebXRState;
  51028. /**
  51029. * Creates a WebXRExperienceHelper
  51030. * @param scene The scene the helper should be created in
  51031. */
  51032. private constructor();
  51033. /**
  51034. * Creates the experience helper
  51035. * @param scene the scene to attach the experience helper to
  51036. * @returns a promise for the experience helper
  51037. */
  51038. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  51039. /**
  51040. * Disposes of the experience helper
  51041. */
  51042. dispose(): void;
  51043. /**
  51044. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  51045. * @param sessionMode options for the XR session
  51046. * @param referenceSpaceType frame of reference of the XR session
  51047. * @param renderTarget the output canvas that will be used to enter XR mode
  51048. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  51049. * @returns promise that resolves after xr mode has entered
  51050. */
  51051. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  51052. /**
  51053. * Exits XR mode and returns the scene to its original state
  51054. * @returns promise that resolves after xr mode has exited
  51055. */
  51056. exitXRAsync(): Promise<void>;
  51057. private _nonXRToXRCamera;
  51058. private _setState;
  51059. }
  51060. }
  51061. declare module BABYLON {
  51062. /**
  51063. * X-Y values for axes in WebXR
  51064. */
  51065. export interface IWebXRMotionControllerAxesValue {
  51066. /**
  51067. * The value of the x axis
  51068. */
  51069. x: number;
  51070. /**
  51071. * The value of the y-axis
  51072. */
  51073. y: number;
  51074. }
  51075. /**
  51076. * changed / previous values for the values of this component
  51077. */
  51078. export interface IWebXRMotionControllerComponentChangesValues<T> {
  51079. /**
  51080. * current (this frame) value
  51081. */
  51082. current: T;
  51083. /**
  51084. * previous (last change) value
  51085. */
  51086. previous: T;
  51087. }
  51088. /**
  51089. * Represents changes in the component between current frame and last values recorded
  51090. */
  51091. export interface IWebXRMotionControllerComponentChanges {
  51092. /**
  51093. * will be populated with previous and current values if axes changed
  51094. */
  51095. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  51096. /**
  51097. * will be populated with previous and current values if pressed changed
  51098. */
  51099. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  51100. /**
  51101. * will be populated with previous and current values if touched changed
  51102. */
  51103. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  51104. /**
  51105. * will be populated with previous and current values if value changed
  51106. */
  51107. value?: IWebXRMotionControllerComponentChangesValues<number>;
  51108. }
  51109. /**
  51110. * This class represents a single component (for example button or thumbstick) of a motion controller
  51111. */
  51112. export class WebXRControllerComponent implements IDisposable {
  51113. /**
  51114. * the id of this component
  51115. */
  51116. id: string;
  51117. /**
  51118. * the type of the component
  51119. */
  51120. type: MotionControllerComponentType;
  51121. private _buttonIndex;
  51122. private _axesIndices;
  51123. private _axes;
  51124. private _changes;
  51125. private _currentValue;
  51126. private _hasChanges;
  51127. private _pressed;
  51128. private _touched;
  51129. /**
  51130. * button component type
  51131. */
  51132. static BUTTON_TYPE: MotionControllerComponentType;
  51133. /**
  51134. * squeeze component type
  51135. */
  51136. static SQUEEZE_TYPE: MotionControllerComponentType;
  51137. /**
  51138. * Thumbstick component type
  51139. */
  51140. static THUMBSTICK_TYPE: MotionControllerComponentType;
  51141. /**
  51142. * Touchpad component type
  51143. */
  51144. static TOUCHPAD_TYPE: MotionControllerComponentType;
  51145. /**
  51146. * trigger component type
  51147. */
  51148. static TRIGGER_TYPE: MotionControllerComponentType;
  51149. /**
  51150. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  51151. * the axes data changes
  51152. */
  51153. onAxisValueChangedObservable: Observable<{
  51154. x: number;
  51155. y: number;
  51156. }>;
  51157. /**
  51158. * Observers registered here will be triggered when the state of a button changes
  51159. * State change is either pressed / touched / value
  51160. */
  51161. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  51162. /**
  51163. * Creates a new component for a motion controller.
  51164. * It is created by the motion controller itself
  51165. *
  51166. * @param id the id of this component
  51167. * @param type the type of the component
  51168. * @param _buttonIndex index in the buttons array of the gamepad
  51169. * @param _axesIndices indices of the values in the axes array of the gamepad
  51170. */
  51171. constructor(
  51172. /**
  51173. * the id of this component
  51174. */
  51175. id: string,
  51176. /**
  51177. * the type of the component
  51178. */
  51179. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  51180. /**
  51181. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  51182. */
  51183. get axes(): IWebXRMotionControllerAxesValue;
  51184. /**
  51185. * Get the changes. Elements will be populated only if they changed with their previous and current value
  51186. */
  51187. get changes(): IWebXRMotionControllerComponentChanges;
  51188. /**
  51189. * Return whether or not the component changed the last frame
  51190. */
  51191. get hasChanges(): boolean;
  51192. /**
  51193. * is the button currently pressed
  51194. */
  51195. get pressed(): boolean;
  51196. /**
  51197. * is the button currently touched
  51198. */
  51199. get touched(): boolean;
  51200. /**
  51201. * Get the current value of this component
  51202. */
  51203. get value(): number;
  51204. /**
  51205. * Dispose this component
  51206. */
  51207. dispose(): void;
  51208. /**
  51209. * Are there axes correlating to this component
  51210. * @return true is axes data is available
  51211. */
  51212. isAxes(): boolean;
  51213. /**
  51214. * Is this component a button (hence - pressable)
  51215. * @returns true if can be pressed
  51216. */
  51217. isButton(): boolean;
  51218. /**
  51219. * update this component using the gamepad object it is in. Called on every frame
  51220. * @param nativeController the native gamepad controller object
  51221. */
  51222. update(nativeController: IMinimalMotionControllerObject): void;
  51223. }
  51224. }
  51225. declare module BABYLON {
  51226. /**
  51227. * Type used for the success callback of ImportMesh
  51228. */
  51229. export type SceneLoaderSuccessCallback = (meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], animationGroups: AnimationGroup[], transformNodes: TransformNode[], geometries: Geometry[], lights: Light[]) => void;
  51230. /**
  51231. * Interface used for the result of ImportMeshAsync
  51232. */
  51233. export interface ISceneLoaderAsyncResult {
  51234. /**
  51235. * The array of loaded meshes
  51236. */
  51237. readonly meshes: AbstractMesh[];
  51238. /**
  51239. * The array of loaded particle systems
  51240. */
  51241. readonly particleSystems: IParticleSystem[];
  51242. /**
  51243. * The array of loaded skeletons
  51244. */
  51245. readonly skeletons: Skeleton[];
  51246. /**
  51247. * The array of loaded animation groups
  51248. */
  51249. readonly animationGroups: AnimationGroup[];
  51250. /**
  51251. * The array of loaded transform nodes
  51252. */
  51253. readonly transformNodes: TransformNode[];
  51254. /**
  51255. * The array of loaded geometries
  51256. */
  51257. readonly geometries: Geometry[];
  51258. /**
  51259. * The array of loaded lights
  51260. */
  51261. readonly lights: Light[];
  51262. }
  51263. /**
  51264. * Interface used to represent data loading progression
  51265. */
  51266. export interface ISceneLoaderProgressEvent {
  51267. /**
  51268. * Defines if data length to load can be evaluated
  51269. */
  51270. readonly lengthComputable: boolean;
  51271. /**
  51272. * Defines the loaded data length
  51273. */
  51274. readonly loaded: number;
  51275. /**
  51276. * Defines the data length to load
  51277. */
  51278. readonly total: number;
  51279. }
  51280. /**
  51281. * Interface used by SceneLoader plugins to define supported file extensions
  51282. */
  51283. export interface ISceneLoaderPluginExtensions {
  51284. /**
  51285. * Defines the list of supported extensions
  51286. */
  51287. [extension: string]: {
  51288. isBinary: boolean;
  51289. };
  51290. }
  51291. /**
  51292. * Interface used by SceneLoader plugin factory
  51293. */
  51294. export interface ISceneLoaderPluginFactory {
  51295. /**
  51296. * Defines the name of the factory
  51297. */
  51298. name: string;
  51299. /**
  51300. * Function called to create a new plugin
  51301. * @return the new plugin
  51302. */
  51303. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  51304. /**
  51305. * The callback that returns true if the data can be directly loaded.
  51306. * @param data string containing the file data
  51307. * @returns if the data can be loaded directly
  51308. */
  51309. canDirectLoad?(data: string): boolean;
  51310. }
  51311. /**
  51312. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  51313. */
  51314. export interface ISceneLoaderPluginBase {
  51315. /**
  51316. * The friendly name of this plugin.
  51317. */
  51318. name: string;
  51319. /**
  51320. * The file extensions supported by this plugin.
  51321. */
  51322. extensions: string | ISceneLoaderPluginExtensions;
  51323. /**
  51324. * The callback called when loading from a url.
  51325. * @param scene scene loading this url
  51326. * @param url url to load
  51327. * @param onSuccess callback called when the file successfully loads
  51328. * @param onProgress callback called while file is loading (if the server supports this mode)
  51329. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  51330. * @param onError callback called when the file fails to load
  51331. * @returns a file request object
  51332. */
  51333. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  51334. /**
  51335. * The callback called when loading from a file object.
  51336. * @param scene scene loading this file
  51337. * @param file defines the file to load
  51338. * @param onSuccess defines the callback to call when data is loaded
  51339. * @param onProgress defines the callback to call during loading process
  51340. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  51341. * @param onError defines the callback to call when an error occurs
  51342. * @returns a file request object
  51343. */
  51344. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  51345. /**
  51346. * The callback that returns true if the data can be directly loaded.
  51347. * @param data string containing the file data
  51348. * @returns if the data can be loaded directly
  51349. */
  51350. canDirectLoad?(data: string): boolean;
  51351. /**
  51352. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  51353. * @param scene scene loading this data
  51354. * @param data string containing the data
  51355. * @returns data to pass to the plugin
  51356. */
  51357. directLoad?(scene: Scene, data: string): any;
  51358. /**
  51359. * The callback that allows custom handling of the root url based on the response url.
  51360. * @param rootUrl the original root url
  51361. * @param responseURL the response url if available
  51362. * @returns the new root url
  51363. */
  51364. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  51365. }
  51366. /**
  51367. * Interface used to define a SceneLoader plugin
  51368. */
  51369. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  51370. /**
  51371. * Import meshes into a scene.
  51372. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  51373. * @param scene The scene to import into
  51374. * @param data The data to import
  51375. * @param rootUrl The root url for scene and resources
  51376. * @param meshes The meshes array to import into
  51377. * @param particleSystems The particle systems array to import into
  51378. * @param skeletons The skeletons array to import into
  51379. * @param onError The callback when import fails
  51380. * @returns True if successful or false otherwise
  51381. */
  51382. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  51383. /**
  51384. * Load into a scene.
  51385. * @param scene The scene to load into
  51386. * @param data The data to import
  51387. * @param rootUrl The root url for scene and resources
  51388. * @param onError The callback when import fails
  51389. * @returns True if successful or false otherwise
  51390. */
  51391. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  51392. /**
  51393. * Load into an asset container.
  51394. * @param scene The scene to load into
  51395. * @param data The data to import
  51396. * @param rootUrl The root url for scene and resources
  51397. * @param onError The callback when import fails
  51398. * @returns The loaded asset container
  51399. */
  51400. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  51401. }
  51402. /**
  51403. * Interface used to define an async SceneLoader plugin
  51404. */
  51405. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  51406. /**
  51407. * Import meshes into a scene.
  51408. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  51409. * @param scene The scene to import into
  51410. * @param data The data to import
  51411. * @param rootUrl The root url for scene and resources
  51412. * @param onProgress The callback when the load progresses
  51413. * @param fileName Defines the name of the file to load
  51414. * @returns The loaded objects (e.g. meshes, particle systems, skeletons, animation groups, etc.)
  51415. */
  51416. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<ISceneLoaderAsyncResult>;
  51417. /**
  51418. * Load into a scene.
  51419. * @param scene The scene to load into
  51420. * @param data The data to import
  51421. * @param rootUrl The root url for scene and resources
  51422. * @param onProgress The callback when the load progresses
  51423. * @param fileName Defines the name of the file to load
  51424. * @returns Nothing
  51425. */
  51426. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  51427. /**
  51428. * Load into an asset container.
  51429. * @param scene The scene to load into
  51430. * @param data The data to import
  51431. * @param rootUrl The root url for scene and resources
  51432. * @param onProgress The callback when the load progresses
  51433. * @param fileName Defines the name of the file to load
  51434. * @returns The loaded asset container
  51435. */
  51436. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  51437. }
  51438. /**
  51439. * Mode that determines how to handle old animation groups before loading new ones.
  51440. */
  51441. export enum SceneLoaderAnimationGroupLoadingMode {
  51442. /**
  51443. * Reset all old animations to initial state then dispose them.
  51444. */
  51445. Clean = 0,
  51446. /**
  51447. * Stop all old animations.
  51448. */
  51449. Stop = 1,
  51450. /**
  51451. * Restart old animations from first frame.
  51452. */
  51453. Sync = 2,
  51454. /**
  51455. * Old animations remains untouched.
  51456. */
  51457. NoSync = 3
  51458. }
  51459. /**
  51460. * Defines a plugin registered by the SceneLoader
  51461. */
  51462. interface IRegisteredPlugin {
  51463. /**
  51464. * Defines the plugin to use
  51465. */
  51466. plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  51467. /**
  51468. * Defines if the plugin supports binary data
  51469. */
  51470. isBinary: boolean;
  51471. }
  51472. /**
  51473. * Class used to load scene from various file formats using registered plugins
  51474. * @see https://doc.babylonjs.com/how_to/load_from_any_file_type
  51475. */
  51476. export class SceneLoader {
  51477. /**
  51478. * No logging while loading
  51479. */
  51480. static readonly NO_LOGGING: number;
  51481. /**
  51482. * Minimal logging while loading
  51483. */
  51484. static readonly MINIMAL_LOGGING: number;
  51485. /**
  51486. * Summary logging while loading
  51487. */
  51488. static readonly SUMMARY_LOGGING: number;
  51489. /**
  51490. * Detailled logging while loading
  51491. */
  51492. static readonly DETAILED_LOGGING: number;
  51493. /**
  51494. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  51495. */
  51496. static get ForceFullSceneLoadingForIncremental(): boolean;
  51497. static set ForceFullSceneLoadingForIncremental(value: boolean);
  51498. /**
  51499. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  51500. */
  51501. static get ShowLoadingScreen(): boolean;
  51502. static set ShowLoadingScreen(value: boolean);
  51503. /**
  51504. * Defines the current logging level (while loading the scene)
  51505. * @ignorenaming
  51506. */
  51507. static get loggingLevel(): number;
  51508. static set loggingLevel(value: number);
  51509. /**
  51510. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  51511. */
  51512. static get CleanBoneMatrixWeights(): boolean;
  51513. static set CleanBoneMatrixWeights(value: boolean);
  51514. /**
  51515. * Event raised when a plugin is used to load a scene
  51516. */
  51517. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  51518. private static _registeredPlugins;
  51519. private static _showingLoadingScreen;
  51520. /**
  51521. * Gets the default plugin (used to load Babylon files)
  51522. * @returns the .babylon plugin
  51523. */
  51524. static GetDefaultPlugin(): IRegisteredPlugin;
  51525. private static _GetPluginForExtension;
  51526. private static _GetPluginForDirectLoad;
  51527. private static _GetPluginForFilename;
  51528. private static _GetDirectLoad;
  51529. private static _LoadData;
  51530. private static _GetFileInfo;
  51531. /**
  51532. * Gets a plugin that can load the given extension
  51533. * @param extension defines the extension to load
  51534. * @returns a plugin or null if none works
  51535. */
  51536. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  51537. /**
  51538. * Gets a boolean indicating that the given extension can be loaded
  51539. * @param extension defines the extension to load
  51540. * @returns true if the extension is supported
  51541. */
  51542. static IsPluginForExtensionAvailable(extension: string): boolean;
  51543. /**
  51544. * Adds a new plugin to the list of registered plugins
  51545. * @param plugin defines the plugin to add
  51546. */
  51547. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  51548. /**
  51549. * Import meshes into a scene
  51550. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  51551. * @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)
  51552. * @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)
  51553. * @param scene the instance of BABYLON.Scene to append to
  51554. * @param onSuccess a callback with a list of imported meshes, particleSystems, skeletons, and animationGroups when import succeeds
  51555. * @param onProgress a callback with a progress event for each file being loaded
  51556. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  51557. * @param pluginExtension the extension used to determine the plugin
  51558. * @returns The loaded plugin
  51559. */
  51560. 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>;
  51561. /**
  51562. * Import meshes into a scene
  51563. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  51564. * @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)
  51565. * @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)
  51566. * @param scene the instance of BABYLON.Scene to append to
  51567. * @param onProgress a callback with a progress event for each file being loaded
  51568. * @param pluginExtension the extension used to determine the plugin
  51569. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  51570. */
  51571. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<ISceneLoaderAsyncResult>;
  51572. /**
  51573. * Load a scene
  51574. * @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)
  51575. * @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)
  51576. * @param engine is the instance of BABYLON.Engine to use to create the scene
  51577. * @param onSuccess a callback with the scene when import succeeds
  51578. * @param onProgress a callback with a progress event for each file being loaded
  51579. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  51580. * @param pluginExtension the extension used to determine the plugin
  51581. * @returns The loaded plugin
  51582. */
  51583. 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>;
  51584. /**
  51585. * Load a scene
  51586. * @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)
  51587. * @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)
  51588. * @param engine is the instance of BABYLON.Engine to use to create the scene
  51589. * @param onProgress a callback with a progress event for each file being loaded
  51590. * @param pluginExtension the extension used to determine the plugin
  51591. * @returns The loaded scene
  51592. */
  51593. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  51594. /**
  51595. * Append a scene
  51596. * @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)
  51597. * @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)
  51598. * @param scene is the instance of BABYLON.Scene to append to
  51599. * @param onSuccess a callback with the scene when import succeeds
  51600. * @param onProgress a callback with a progress event for each file being loaded
  51601. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  51602. * @param pluginExtension the extension used to determine the plugin
  51603. * @returns The loaded plugin
  51604. */
  51605. 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>;
  51606. /**
  51607. * Append a scene
  51608. * @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)
  51609. * @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)
  51610. * @param scene is the instance of BABYLON.Scene to append to
  51611. * @param onProgress a callback with a progress event for each file being loaded
  51612. * @param pluginExtension the extension used to determine the plugin
  51613. * @returns The given scene
  51614. */
  51615. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  51616. /**
  51617. * Load a scene into an asset container
  51618. * @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)
  51619. * @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)
  51620. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  51621. * @param onSuccess a callback with the scene when import succeeds
  51622. * @param onProgress a callback with a progress event for each file being loaded
  51623. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  51624. * @param pluginExtension the extension used to determine the plugin
  51625. * @returns The loaded plugin
  51626. */
  51627. 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>;
  51628. /**
  51629. * Load a scene into an asset container
  51630. * @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)
  51631. * @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)
  51632. * @param scene is the instance of Scene to append to
  51633. * @param onProgress a callback with a progress event for each file being loaded
  51634. * @param pluginExtension the extension used to determine the plugin
  51635. * @returns The loaded asset container
  51636. */
  51637. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  51638. /**
  51639. * Import animations from a file into a scene
  51640. * @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)
  51641. * @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)
  51642. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  51643. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  51644. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  51645. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  51646. * @param onSuccess a callback with the scene when import succeeds
  51647. * @param onProgress a callback with a progress event for each file being loaded
  51648. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  51649. * @param pluginExtension the extension used to determine the plugin
  51650. */
  51651. 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;
  51652. /**
  51653. * Import animations from a file into a scene
  51654. * @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)
  51655. * @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)
  51656. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  51657. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  51658. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  51659. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  51660. * @param onSuccess a callback with the scene when import succeeds
  51661. * @param onProgress a callback with a progress event for each file being loaded
  51662. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  51663. * @param pluginExtension the extension used to determine the plugin
  51664. * @returns the updated scene with imported animations
  51665. */
  51666. 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>;
  51667. }
  51668. }
  51669. declare module BABYLON {
  51670. /**
  51671. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  51672. */
  51673. export type MotionControllerHandedness = "none" | "left" | "right";
  51674. /**
  51675. * The type of components available in motion controllers.
  51676. * This is not the name of the component.
  51677. */
  51678. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  51679. /**
  51680. * The state of a controller component
  51681. */
  51682. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  51683. /**
  51684. * The schema of motion controller layout.
  51685. * No object will be initialized using this interface
  51686. * This is used just to define the profile.
  51687. */
  51688. export interface IMotionControllerLayout {
  51689. /**
  51690. * Path to load the assets. Usually relative to the base path
  51691. */
  51692. assetPath: string;
  51693. /**
  51694. * Available components (unsorted)
  51695. */
  51696. components: {
  51697. /**
  51698. * A map of component Ids
  51699. */
  51700. [componentId: string]: {
  51701. /**
  51702. * The type of input the component outputs
  51703. */
  51704. type: MotionControllerComponentType;
  51705. /**
  51706. * The indices of this component in the gamepad object
  51707. */
  51708. gamepadIndices: {
  51709. /**
  51710. * Index of button
  51711. */
  51712. button?: number;
  51713. /**
  51714. * If available, index of x-axis
  51715. */
  51716. xAxis?: number;
  51717. /**
  51718. * If available, index of y-axis
  51719. */
  51720. yAxis?: number;
  51721. };
  51722. /**
  51723. * The mesh's root node name
  51724. */
  51725. rootNodeName: string;
  51726. /**
  51727. * Animation definitions for this model
  51728. */
  51729. visualResponses: {
  51730. [stateKey: string]: {
  51731. /**
  51732. * What property will be animated
  51733. */
  51734. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  51735. /**
  51736. * What states influence this visual response
  51737. */
  51738. states: MotionControllerComponentStateType[];
  51739. /**
  51740. * Type of animation - movement or visibility
  51741. */
  51742. valueNodeProperty: "transform" | "visibility";
  51743. /**
  51744. * Base node name to move. Its position will be calculated according to the min and max nodes
  51745. */
  51746. valueNodeName?: string;
  51747. /**
  51748. * Minimum movement node
  51749. */
  51750. minNodeName?: string;
  51751. /**
  51752. * Max movement node
  51753. */
  51754. maxNodeName?: string;
  51755. };
  51756. };
  51757. /**
  51758. * If touch enabled, what is the name of node to display user feedback
  51759. */
  51760. touchPointNodeName?: string;
  51761. };
  51762. };
  51763. /**
  51764. * Is it xr standard mapping or not
  51765. */
  51766. gamepadMapping: "" | "xr-standard";
  51767. /**
  51768. * Base root node of this entire model
  51769. */
  51770. rootNodeName: string;
  51771. /**
  51772. * Defines the main button component id
  51773. */
  51774. selectComponentId: string;
  51775. }
  51776. /**
  51777. * A definition for the layout map in the input profile
  51778. */
  51779. export interface IMotionControllerLayoutMap {
  51780. /**
  51781. * Layouts with handedness type as a key
  51782. */
  51783. [handedness: string]: IMotionControllerLayout;
  51784. }
  51785. /**
  51786. * The XR Input profile schema
  51787. * Profiles can be found here:
  51788. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  51789. */
  51790. export interface IMotionControllerProfile {
  51791. /**
  51792. * fallback profiles for this profileId
  51793. */
  51794. fallbackProfileIds: string[];
  51795. /**
  51796. * The layout map, with handedness as key
  51797. */
  51798. layouts: IMotionControllerLayoutMap;
  51799. /**
  51800. * The id of this profile
  51801. * correlates to the profile(s) in the xrInput.profiles array
  51802. */
  51803. profileId: string;
  51804. }
  51805. /**
  51806. * A helper-interface for the 3 meshes needed for controller button animation
  51807. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  51808. */
  51809. export interface IMotionControllerButtonMeshMap {
  51810. /**
  51811. * the mesh that defines the pressed value mesh position.
  51812. * This is used to find the max-position of this button
  51813. */
  51814. pressedMesh: AbstractMesh;
  51815. /**
  51816. * the mesh that defines the unpressed value mesh position.
  51817. * This is used to find the min (or initial) position of this button
  51818. */
  51819. unpressedMesh: AbstractMesh;
  51820. /**
  51821. * The mesh that will be changed when value changes
  51822. */
  51823. valueMesh: AbstractMesh;
  51824. }
  51825. /**
  51826. * A helper-interface for the 3 meshes needed for controller axis animation.
  51827. * This will be expanded when touchpad animations are fully supported
  51828. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  51829. */
  51830. export interface IMotionControllerMeshMap {
  51831. /**
  51832. * the mesh that defines the maximum value mesh position.
  51833. */
  51834. maxMesh?: AbstractMesh;
  51835. /**
  51836. * the mesh that defines the minimum value mesh position.
  51837. */
  51838. minMesh?: AbstractMesh;
  51839. /**
  51840. * The mesh that will be changed when axis value changes
  51841. */
  51842. valueMesh?: AbstractMesh;
  51843. }
  51844. /**
  51845. * The elements needed for change-detection of the gamepad objects in motion controllers
  51846. */
  51847. export interface IMinimalMotionControllerObject {
  51848. /**
  51849. * Available axes of this controller
  51850. */
  51851. axes: number[];
  51852. /**
  51853. * An array of available buttons
  51854. */
  51855. buttons: Array<{
  51856. /**
  51857. * Value of the button/trigger
  51858. */
  51859. value: number;
  51860. /**
  51861. * If the button/trigger is currently touched
  51862. */
  51863. touched: boolean;
  51864. /**
  51865. * If the button/trigger is currently pressed
  51866. */
  51867. pressed: boolean;
  51868. }>;
  51869. /**
  51870. * EXPERIMENTAL haptic support.
  51871. */
  51872. hapticActuators?: Array<{
  51873. pulse: (value: number, duration: number) => Promise<boolean>;
  51874. }>;
  51875. }
  51876. /**
  51877. * An Abstract Motion controller
  51878. * This class receives an xrInput and a profile layout and uses those to initialize the components
  51879. * Each component has an observable to check for changes in value and state
  51880. */
  51881. export abstract class WebXRAbstractMotionController implements IDisposable {
  51882. protected scene: Scene;
  51883. protected layout: IMotionControllerLayout;
  51884. /**
  51885. * The gamepad object correlating to this controller
  51886. */
  51887. gamepadObject: IMinimalMotionControllerObject;
  51888. /**
  51889. * handedness (left/right/none) of this controller
  51890. */
  51891. handedness: MotionControllerHandedness;
  51892. private _initComponent;
  51893. private _modelReady;
  51894. /**
  51895. * A map of components (WebXRControllerComponent) in this motion controller
  51896. * Components have a ComponentType and can also have both button and axis definitions
  51897. */
  51898. readonly components: {
  51899. [id: string]: WebXRControllerComponent;
  51900. };
  51901. /**
  51902. * Disable the model's animation. Can be set at any time.
  51903. */
  51904. disableAnimation: boolean;
  51905. /**
  51906. * Observers registered here will be triggered when the model of this controller is done loading
  51907. */
  51908. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  51909. /**
  51910. * The profile id of this motion controller
  51911. */
  51912. abstract profileId: string;
  51913. /**
  51914. * The root mesh of the model. It is null if the model was not yet initialized
  51915. */
  51916. rootMesh: Nullable<AbstractMesh>;
  51917. /**
  51918. * constructs a new abstract motion controller
  51919. * @param scene the scene to which the model of the controller will be added
  51920. * @param layout The profile layout to load
  51921. * @param gamepadObject The gamepad object correlating to this controller
  51922. * @param handedness handedness (left/right/none) of this controller
  51923. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  51924. */
  51925. constructor(scene: Scene, layout: IMotionControllerLayout,
  51926. /**
  51927. * The gamepad object correlating to this controller
  51928. */
  51929. gamepadObject: IMinimalMotionControllerObject,
  51930. /**
  51931. * handedness (left/right/none) of this controller
  51932. */
  51933. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  51934. /**
  51935. * Dispose this controller, the model mesh and all its components
  51936. */
  51937. dispose(): void;
  51938. /**
  51939. * Returns all components of specific type
  51940. * @param type the type to search for
  51941. * @return an array of components with this type
  51942. */
  51943. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  51944. /**
  51945. * get a component based an its component id as defined in layout.components
  51946. * @param id the id of the component
  51947. * @returns the component correlates to the id or undefined if not found
  51948. */
  51949. getComponent(id: string): WebXRControllerComponent;
  51950. /**
  51951. * Get the list of components available in this motion controller
  51952. * @returns an array of strings correlating to available components
  51953. */
  51954. getComponentIds(): string[];
  51955. /**
  51956. * Get the first component of specific type
  51957. * @param type type of component to find
  51958. * @return a controller component or null if not found
  51959. */
  51960. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  51961. /**
  51962. * Get the main (Select) component of this controller as defined in the layout
  51963. * @returns the main component of this controller
  51964. */
  51965. getMainComponent(): WebXRControllerComponent;
  51966. /**
  51967. * Loads the model correlating to this controller
  51968. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  51969. * @returns A promise fulfilled with the result of the model loading
  51970. */
  51971. loadModel(): Promise<boolean>;
  51972. /**
  51973. * Update this model using the current XRFrame
  51974. * @param xrFrame the current xr frame to use and update the model
  51975. */
  51976. updateFromXRFrame(xrFrame: XRFrame): void;
  51977. /**
  51978. * Backwards compatibility due to a deeply-integrated typo
  51979. */
  51980. get handness(): XREye;
  51981. /**
  51982. * Pulse (vibrate) this controller
  51983. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  51984. * Consecutive calls to this function will cancel the last pulse call
  51985. *
  51986. * @param value the strength of the pulse in 0.0...1.0 range
  51987. * @param duration Duration of the pulse in milliseconds
  51988. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  51989. * @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
  51990. */
  51991. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  51992. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  51993. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  51994. /**
  51995. * Moves the axis on the controller mesh based on its current state
  51996. * @param axis the index of the axis
  51997. * @param axisValue the value of the axis which determines the meshes new position
  51998. * @hidden
  51999. */
  52000. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  52001. /**
  52002. * Update the model itself with the current frame data
  52003. * @param xrFrame the frame to use for updating the model mesh
  52004. */
  52005. protected updateModel(xrFrame: XRFrame): void;
  52006. /**
  52007. * Get the filename and path for this controller's model
  52008. * @returns a map of filename and path
  52009. */
  52010. protected abstract _getFilenameAndPath(): {
  52011. filename: string;
  52012. path: string;
  52013. };
  52014. /**
  52015. * This function is called before the mesh is loaded. It checks for loading constraints.
  52016. * For example, this function can check if the GLB loader is available
  52017. * If this function returns false, the generic controller will be loaded instead
  52018. * @returns Is the client ready to load the mesh
  52019. */
  52020. protected abstract _getModelLoadingConstraints(): boolean;
  52021. /**
  52022. * This function will be called after the model was successfully loaded and can be used
  52023. * for mesh transformations before it is available for the user
  52024. * @param meshes the loaded meshes
  52025. */
  52026. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  52027. /**
  52028. * Set the root mesh for this controller. Important for the WebXR controller class
  52029. * @param meshes the loaded meshes
  52030. */
  52031. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  52032. /**
  52033. * A function executed each frame that updates the mesh (if needed)
  52034. * @param xrFrame the current xrFrame
  52035. */
  52036. protected abstract _updateModel(xrFrame: XRFrame): void;
  52037. private _getGenericFilenameAndPath;
  52038. private _getGenericParentMesh;
  52039. }
  52040. }
  52041. declare module BABYLON {
  52042. /**
  52043. * A generic trigger-only motion controller for WebXR
  52044. */
  52045. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  52046. /**
  52047. * Static version of the profile id of this controller
  52048. */
  52049. static ProfileId: string;
  52050. profileId: string;
  52051. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  52052. protected _getFilenameAndPath(): {
  52053. filename: string;
  52054. path: string;
  52055. };
  52056. protected _getModelLoadingConstraints(): boolean;
  52057. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  52058. protected _setRootMesh(meshes: AbstractMesh[]): void;
  52059. protected _updateModel(): void;
  52060. }
  52061. }
  52062. declare module BABYLON {
  52063. /**
  52064. * Class containing static functions to help procedurally build meshes
  52065. */
  52066. export class SphereBuilder {
  52067. /**
  52068. * Creates a sphere mesh
  52069. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  52070. * * 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`)
  52071. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  52072. * * 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
  52073. * * 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)
  52074. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52075. * * 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
  52076. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52077. * @param name defines the name of the mesh
  52078. * @param options defines the options used to create the mesh
  52079. * @param scene defines the hosting scene
  52080. * @returns the sphere mesh
  52081. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  52082. */
  52083. static CreateSphere(name: string, options: {
  52084. segments?: number;
  52085. diameter?: number;
  52086. diameterX?: number;
  52087. diameterY?: number;
  52088. diameterZ?: number;
  52089. arc?: number;
  52090. slice?: number;
  52091. sideOrientation?: number;
  52092. frontUVs?: Vector4;
  52093. backUVs?: Vector4;
  52094. updatable?: boolean;
  52095. }, scene?: Nullable<Scene>): Mesh;
  52096. }
  52097. }
  52098. declare module BABYLON {
  52099. /**
  52100. * A profiled motion controller has its profile loaded from an online repository.
  52101. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  52102. */
  52103. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  52104. private _repositoryUrl;
  52105. private _buttonMeshMapping;
  52106. private _touchDots;
  52107. /**
  52108. * The profile ID of this controller. Will be populated when the controller initializes.
  52109. */
  52110. profileId: string;
  52111. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  52112. dispose(): void;
  52113. protected _getFilenameAndPath(): {
  52114. filename: string;
  52115. path: string;
  52116. };
  52117. protected _getModelLoadingConstraints(): boolean;
  52118. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  52119. protected _setRootMesh(meshes: AbstractMesh[]): void;
  52120. protected _updateModel(_xrFrame: XRFrame): void;
  52121. }
  52122. }
  52123. declare module BABYLON {
  52124. /**
  52125. * A construction function type to create a new controller based on an xrInput object
  52126. */
  52127. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  52128. /**
  52129. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  52130. *
  52131. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  52132. * it should be replaced with auto-loaded controllers.
  52133. *
  52134. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  52135. */
  52136. export class WebXRMotionControllerManager {
  52137. private static _AvailableControllers;
  52138. private static _Fallbacks;
  52139. private static _ProfileLoadingPromises;
  52140. private static _ProfilesList;
  52141. /**
  52142. * The base URL of the online controller repository. Can be changed at any time.
  52143. */
  52144. static BaseRepositoryUrl: string;
  52145. /**
  52146. * Which repository gets priority - local or online
  52147. */
  52148. static PrioritizeOnlineRepository: boolean;
  52149. /**
  52150. * Use the online repository, or use only locally-defined controllers
  52151. */
  52152. static UseOnlineRepository: boolean;
  52153. /**
  52154. * Clear the cache used for profile loading and reload when requested again
  52155. */
  52156. static ClearProfilesCache(): void;
  52157. /**
  52158. * Register the default fallbacks.
  52159. * This function is called automatically when this file is imported.
  52160. */
  52161. static DefaultFallbacks(): void;
  52162. /**
  52163. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  52164. * @param profileId the profile to which a fallback needs to be found
  52165. * @return an array with corresponding fallback profiles
  52166. */
  52167. static FindFallbackWithProfileId(profileId: string): string[];
  52168. /**
  52169. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  52170. * The order of search:
  52171. *
  52172. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  52173. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  52174. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  52175. * 4) return the generic trigger controller if none were found
  52176. *
  52177. * @param xrInput the xrInput to which a new controller is initialized
  52178. * @param scene the scene to which the model will be added
  52179. * @param forceProfile force a certain profile for this controller
  52180. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  52181. */
  52182. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  52183. /**
  52184. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  52185. *
  52186. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  52187. *
  52188. * @param type the profile type to register
  52189. * @param constructFunction the function to be called when loading this profile
  52190. */
  52191. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  52192. /**
  52193. * Register a fallback to a specific profile.
  52194. * @param profileId the profileId that will receive the fallbacks
  52195. * @param fallbacks A list of fallback profiles
  52196. */
  52197. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  52198. /**
  52199. * Will update the list of profiles available in the repository
  52200. * @return a promise that resolves to a map of profiles available online
  52201. */
  52202. static UpdateProfilesList(): Promise<{
  52203. [profile: string]: string;
  52204. }>;
  52205. private static _LoadProfileFromRepository;
  52206. private static _LoadProfilesFromAvailableControllers;
  52207. }
  52208. }
  52209. declare module BABYLON {
  52210. /**
  52211. * Configuration options for the WebXR controller creation
  52212. */
  52213. export interface IWebXRControllerOptions {
  52214. /**
  52215. * Should the controller mesh be animated when a user interacts with it
  52216. * The pressed buttons / thumbstick and touchpad animations will be disabled
  52217. */
  52218. disableMotionControllerAnimation?: boolean;
  52219. /**
  52220. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  52221. */
  52222. doNotLoadControllerMesh?: boolean;
  52223. /**
  52224. * Force a specific controller type for this controller.
  52225. * This can be used when creating your own profile or when testing different controllers
  52226. */
  52227. forceControllerProfile?: string;
  52228. /**
  52229. * Defines a rendering group ID for meshes that will be loaded.
  52230. * This is for the default controllers only.
  52231. */
  52232. renderingGroupId?: number;
  52233. }
  52234. /**
  52235. * Represents an XR controller
  52236. */
  52237. export class WebXRInputSource {
  52238. private _scene;
  52239. /** The underlying input source for the controller */
  52240. inputSource: XRInputSource;
  52241. private _options;
  52242. private _tmpVector;
  52243. private _uniqueId;
  52244. private _disposed;
  52245. /**
  52246. * 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
  52247. */
  52248. grip?: AbstractMesh;
  52249. /**
  52250. * If available, this is the gamepad object related to this controller.
  52251. * Using this object it is possible to get click events and trackpad changes of the
  52252. * webxr controller that is currently being used.
  52253. */
  52254. motionController?: WebXRAbstractMotionController;
  52255. /**
  52256. * Event that fires when the controller is removed/disposed.
  52257. * The object provided as event data is this controller, after associated assets were disposed.
  52258. * uniqueId is still available.
  52259. */
  52260. onDisposeObservable: Observable<WebXRInputSource>;
  52261. /**
  52262. * Will be triggered when the mesh associated with the motion controller is done loading.
  52263. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  52264. * A shortened version of controller -> motion controller -> on mesh loaded.
  52265. */
  52266. onMeshLoadedObservable: Observable<AbstractMesh>;
  52267. /**
  52268. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  52269. */
  52270. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  52271. /**
  52272. * Pointer which can be used to select objects or attach a visible laser to
  52273. */
  52274. pointer: AbstractMesh;
  52275. /**
  52276. * Creates the input source object
  52277. * @see https://doc.babylonjs.com/how_to/webxr_controllers_support
  52278. * @param _scene the scene which the controller should be associated to
  52279. * @param inputSource the underlying input source for the controller
  52280. * @param _options options for this controller creation
  52281. */
  52282. constructor(_scene: Scene,
  52283. /** The underlying input source for the controller */
  52284. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  52285. /**
  52286. * Get this controllers unique id
  52287. */
  52288. get uniqueId(): string;
  52289. /**
  52290. * Disposes of the object
  52291. */
  52292. dispose(): void;
  52293. /**
  52294. * Gets a world space ray coming from the pointer or grip
  52295. * @param result the resulting ray
  52296. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  52297. */
  52298. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  52299. /**
  52300. * Updates the controller pose based on the given XRFrame
  52301. * @param xrFrame xr frame to update the pose with
  52302. * @param referenceSpace reference space to use
  52303. */
  52304. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  52305. }
  52306. }
  52307. declare module BABYLON {
  52308. /**
  52309. * The schema for initialization options of the XR Input class
  52310. */
  52311. export interface IWebXRInputOptions {
  52312. /**
  52313. * If set to true no model will be automatically loaded
  52314. */
  52315. doNotLoadControllerMeshes?: boolean;
  52316. /**
  52317. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  52318. * If not found, the xr input profile data will be used.
  52319. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  52320. */
  52321. forceInputProfile?: string;
  52322. /**
  52323. * Do not send a request to the controller repository to load the profile.
  52324. *
  52325. * Instead, use the controllers available in babylon itself.
  52326. */
  52327. disableOnlineControllerRepository?: boolean;
  52328. /**
  52329. * A custom URL for the controllers repository
  52330. */
  52331. customControllersRepositoryURL?: string;
  52332. /**
  52333. * Should the controller model's components not move according to the user input
  52334. */
  52335. disableControllerAnimation?: boolean;
  52336. /**
  52337. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  52338. */
  52339. controllerOptions?: IWebXRControllerOptions;
  52340. }
  52341. /**
  52342. * XR input used to track XR inputs such as controllers/rays
  52343. */
  52344. export class WebXRInput implements IDisposable {
  52345. /**
  52346. * the xr session manager for this session
  52347. */
  52348. xrSessionManager: WebXRSessionManager;
  52349. /**
  52350. * the WebXR camera for this session. Mainly used for teleportation
  52351. */
  52352. xrCamera: WebXRCamera;
  52353. private readonly options;
  52354. /**
  52355. * XR controllers being tracked
  52356. */
  52357. controllers: Array<WebXRInputSource>;
  52358. private _frameObserver;
  52359. private _sessionEndedObserver;
  52360. private _sessionInitObserver;
  52361. /**
  52362. * Event when a controller has been connected/added
  52363. */
  52364. onControllerAddedObservable: Observable<WebXRInputSource>;
  52365. /**
  52366. * Event when a controller has been removed/disconnected
  52367. */
  52368. onControllerRemovedObservable: Observable<WebXRInputSource>;
  52369. /**
  52370. * Initializes the WebXRInput
  52371. * @param xrSessionManager the xr session manager for this session
  52372. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  52373. * @param options = initialization options for this xr input
  52374. */
  52375. constructor(
  52376. /**
  52377. * the xr session manager for this session
  52378. */
  52379. xrSessionManager: WebXRSessionManager,
  52380. /**
  52381. * the WebXR camera for this session. Mainly used for teleportation
  52382. */
  52383. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  52384. private _onInputSourcesChange;
  52385. private _addAndRemoveControllers;
  52386. /**
  52387. * Disposes of the object
  52388. */
  52389. dispose(): void;
  52390. }
  52391. }
  52392. declare module BABYLON {
  52393. /**
  52394. * This is the base class for all WebXR features.
  52395. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  52396. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  52397. */
  52398. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  52399. protected _xrSessionManager: WebXRSessionManager;
  52400. private _attached;
  52401. private _removeOnDetach;
  52402. /**
  52403. * Is this feature disposed?
  52404. */
  52405. isDisposed: boolean;
  52406. /**
  52407. * Should auto-attach be disabled?
  52408. */
  52409. disableAutoAttach: boolean;
  52410. /**
  52411. * The name of the native xr feature name (like anchor, hit-test, or hand-tracking)
  52412. */
  52413. xrNativeFeatureName: string;
  52414. /**
  52415. * Construct a new (abstract) WebXR feature
  52416. * @param _xrSessionManager the xr session manager for this feature
  52417. */
  52418. constructor(_xrSessionManager: WebXRSessionManager);
  52419. /**
  52420. * Is this feature attached
  52421. */
  52422. get attached(): boolean;
  52423. /**
  52424. * attach this feature
  52425. *
  52426. * @param force should attachment be forced (even when already attached)
  52427. * @returns true if successful, false is failed or already attached
  52428. */
  52429. attach(force?: boolean): boolean;
  52430. /**
  52431. * detach this feature.
  52432. *
  52433. * @returns true if successful, false if failed or already detached
  52434. */
  52435. detach(): boolean;
  52436. /**
  52437. * Dispose this feature and all of the resources attached
  52438. */
  52439. dispose(): void;
  52440. /**
  52441. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  52442. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  52443. *
  52444. * @returns whether or not the feature is compatible in this environment
  52445. */
  52446. isCompatible(): boolean;
  52447. /**
  52448. * This is used to register callbacks that will automatically be removed when detach is called.
  52449. * @param observable the observable to which the observer will be attached
  52450. * @param callback the callback to register
  52451. */
  52452. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  52453. /**
  52454. * Code in this function will be executed on each xrFrame received from the browser.
  52455. * This function will not execute after the feature is detached.
  52456. * @param _xrFrame the current frame
  52457. */
  52458. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  52459. }
  52460. }
  52461. declare module BABYLON {
  52462. /**
  52463. * Renders a layer on top of an existing scene
  52464. */
  52465. export class UtilityLayerRenderer implements IDisposable {
  52466. /** the original scene that will be rendered on top of */
  52467. originalScene: Scene;
  52468. private _pointerCaptures;
  52469. private _lastPointerEvents;
  52470. private static _DefaultUtilityLayer;
  52471. private static _DefaultKeepDepthUtilityLayer;
  52472. private _sharedGizmoLight;
  52473. private _renderCamera;
  52474. /**
  52475. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  52476. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  52477. * @returns the camera that is used when rendering the utility layer
  52478. */
  52479. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  52480. /**
  52481. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  52482. * @param cam the camera that should be used when rendering the utility layer
  52483. */
  52484. setRenderCamera(cam: Nullable<Camera>): void;
  52485. /**
  52486. * @hidden
  52487. * Light which used by gizmos to get light shading
  52488. */
  52489. _getSharedGizmoLight(): HemisphericLight;
  52490. /**
  52491. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  52492. */
  52493. pickUtilitySceneFirst: boolean;
  52494. /**
  52495. * 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)
  52496. */
  52497. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  52498. /**
  52499. * 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)
  52500. */
  52501. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  52502. /**
  52503. * The scene that is rendered on top of the original scene
  52504. */
  52505. utilityLayerScene: Scene;
  52506. /**
  52507. * If the utility layer should automatically be rendered on top of existing scene
  52508. */
  52509. shouldRender: boolean;
  52510. /**
  52511. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  52512. */
  52513. onlyCheckPointerDownEvents: boolean;
  52514. /**
  52515. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  52516. */
  52517. processAllEvents: boolean;
  52518. /**
  52519. * Observable raised when the pointer move from the utility layer scene to the main scene
  52520. */
  52521. onPointerOutObservable: Observable<number>;
  52522. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  52523. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  52524. private _afterRenderObserver;
  52525. private _sceneDisposeObserver;
  52526. private _originalPointerObserver;
  52527. /**
  52528. * Instantiates a UtilityLayerRenderer
  52529. * @param originalScene the original scene that will be rendered on top of
  52530. * @param handleEvents boolean indicating if the utility layer should handle events
  52531. */
  52532. constructor(
  52533. /** the original scene that will be rendered on top of */
  52534. originalScene: Scene, handleEvents?: boolean);
  52535. private _notifyObservers;
  52536. /**
  52537. * Renders the utility layers scene on top of the original scene
  52538. */
  52539. render(): void;
  52540. /**
  52541. * Disposes of the renderer
  52542. */
  52543. dispose(): void;
  52544. private _updateCamera;
  52545. }
  52546. }
  52547. declare module BABYLON {
  52548. /**
  52549. * Options interface for the pointer selection module
  52550. */
  52551. export interface IWebXRControllerPointerSelectionOptions {
  52552. /**
  52553. * if provided, this scene will be used to render meshes.
  52554. */
  52555. customUtilityLayerScene?: Scene;
  52556. /**
  52557. * 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)
  52558. * If not disabled, the last picked point will be used to execute a pointer up event
  52559. * If disabled, pointer up event will be triggered right after the pointer down event.
  52560. * Used in screen and gaze target ray mode only
  52561. */
  52562. disablePointerUpOnTouchOut: boolean;
  52563. /**
  52564. * For gaze mode for tracked-pointer / controllers (time to select instead of button press)
  52565. */
  52566. forceGazeMode: boolean;
  52567. /**
  52568. * 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
  52569. * to start a new countdown to the pointer down event.
  52570. * Defaults to 1.
  52571. */
  52572. gazeModePointerMovedFactor?: number;
  52573. /**
  52574. * Different button type to use instead of the main component
  52575. */
  52576. overrideButtonId?: string;
  52577. /**
  52578. * use this rendering group id for the meshes (optional)
  52579. */
  52580. renderingGroupId?: number;
  52581. /**
  52582. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  52583. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  52584. * 3000 means 3 seconds between pointing at something and selecting it
  52585. */
  52586. timeToSelect?: number;
  52587. /**
  52588. * Should meshes created here be added to a utility layer or the main scene
  52589. */
  52590. useUtilityLayer?: boolean;
  52591. /**
  52592. * Optional WebXR camera to be used for gaze selection
  52593. */
  52594. gazeCamera?: WebXRCamera;
  52595. /**
  52596. * the xr input to use with this pointer selection
  52597. */
  52598. xrInput: WebXRInput;
  52599. /**
  52600. * Should the scene pointerX and pointerY update be disabled
  52601. * This is required for fullscreen AR GUI, but might slow down other experiences.
  52602. * Disable in VR, if not needed.
  52603. * The first rig camera (left eye) will be used to calculate the projection
  52604. */
  52605. disableScenePointerVectorUpdate: boolean;
  52606. /**
  52607. * Enable pointer selection on all controllers instead of switching between them
  52608. */
  52609. enablePointerSelectionOnAllControllers?: boolean;
  52610. /**
  52611. * The preferred hand to give the pointer selection to. This will be prioritized when the controller initialize.
  52612. * If switch is enabled, it will still allow the user to switch between the different controllers
  52613. */
  52614. preferredHandedness?: XRHandedness;
  52615. /**
  52616. * Disable switching the pointer selection from one controller to the other.
  52617. * 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
  52618. */
  52619. disableSwitchOnClick?: boolean;
  52620. /**
  52621. * The maximum distance of the pointer selection feature. Defaults to 100.
  52622. */
  52623. maxPointerDistance?: number;
  52624. }
  52625. /**
  52626. * A module that will enable pointer selection for motion controllers of XR Input Sources
  52627. */
  52628. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  52629. private readonly _options;
  52630. private static _idCounter;
  52631. private _attachController;
  52632. private _controllers;
  52633. private _scene;
  52634. private _tmpVectorForPickCompare;
  52635. private _attachedController;
  52636. /**
  52637. * The module's name
  52638. */
  52639. static readonly Name: string;
  52640. /**
  52641. * The (Babylon) version of this module.
  52642. * This is an integer representing the implementation version.
  52643. * This number does not correspond to the WebXR specs version
  52644. */
  52645. static readonly Version: number;
  52646. /**
  52647. * Disable lighting on the laser pointer (so it will always be visible)
  52648. */
  52649. disablePointerLighting: boolean;
  52650. /**
  52651. * Disable lighting on the selection mesh (so it will always be visible)
  52652. */
  52653. disableSelectionMeshLighting: boolean;
  52654. /**
  52655. * Should the laser pointer be displayed
  52656. */
  52657. displayLaserPointer: boolean;
  52658. /**
  52659. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  52660. */
  52661. displaySelectionMesh: boolean;
  52662. /**
  52663. * This color will be set to the laser pointer when selection is triggered
  52664. */
  52665. laserPointerPickedColor: Color3;
  52666. /**
  52667. * Default color of the laser pointer
  52668. */
  52669. laserPointerDefaultColor: Color3;
  52670. /**
  52671. * default color of the selection ring
  52672. */
  52673. selectionMeshDefaultColor: Color3;
  52674. /**
  52675. * This color will be applied to the selection ring when selection is triggered
  52676. */
  52677. selectionMeshPickedColor: Color3;
  52678. /**
  52679. * Optional filter to be used for ray selection. This predicate shares behavior with
  52680. * scene.pointerMovePredicate which takes priority if it is also assigned.
  52681. */
  52682. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  52683. /**
  52684. * constructs a new background remover module
  52685. * @param _xrSessionManager the session manager for this module
  52686. * @param _options read-only options to be used in this module
  52687. */
  52688. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  52689. /**
  52690. * attach this feature
  52691. * Will usually be called by the features manager
  52692. *
  52693. * @returns true if successful.
  52694. */
  52695. attach(): boolean;
  52696. /**
  52697. * detach this feature.
  52698. * Will usually be called by the features manager
  52699. *
  52700. * @returns true if successful.
  52701. */
  52702. detach(): boolean;
  52703. /**
  52704. * Will get the mesh under a specific pointer.
  52705. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  52706. * @param controllerId the controllerId to check
  52707. * @returns The mesh under pointer or null if no mesh is under the pointer
  52708. */
  52709. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  52710. /**
  52711. * Get the xr controller that correlates to the pointer id in the pointer event
  52712. *
  52713. * @param id the pointer id to search for
  52714. * @returns the controller that correlates to this id or null if not found
  52715. */
  52716. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  52717. private _identityMatrix;
  52718. private _screenCoordinatesRef;
  52719. private _viewportRef;
  52720. protected _onXRFrame(_xrFrame: XRFrame): void;
  52721. private _attachGazeMode;
  52722. private _attachScreenRayMode;
  52723. private _attachTrackedPointerRayMode;
  52724. private _convertNormalToDirectionOfRay;
  52725. private _detachController;
  52726. private _generateNewMeshPair;
  52727. private _pickingMoved;
  52728. private _updatePointerDistance;
  52729. /** @hidden */
  52730. get lasterPointerDefaultColor(): Color3;
  52731. }
  52732. }
  52733. declare module BABYLON {
  52734. /**
  52735. * Button which can be used to enter a different mode of XR
  52736. */
  52737. export class WebXREnterExitUIButton {
  52738. /** button element */
  52739. element: HTMLElement;
  52740. /** XR initialization options for the button */
  52741. sessionMode: XRSessionMode;
  52742. /** Reference space type */
  52743. referenceSpaceType: XRReferenceSpaceType;
  52744. /**
  52745. * Creates a WebXREnterExitUIButton
  52746. * @param element button element
  52747. * @param sessionMode XR initialization session mode
  52748. * @param referenceSpaceType the type of reference space to be used
  52749. */
  52750. constructor(
  52751. /** button element */
  52752. element: HTMLElement,
  52753. /** XR initialization options for the button */
  52754. sessionMode: XRSessionMode,
  52755. /** Reference space type */
  52756. referenceSpaceType: XRReferenceSpaceType);
  52757. /**
  52758. * Extendable function which can be used to update the button's visuals when the state changes
  52759. * @param activeButton the current active button in the UI
  52760. */
  52761. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  52762. }
  52763. /**
  52764. * Options to create the webXR UI
  52765. */
  52766. export class WebXREnterExitUIOptions {
  52767. /**
  52768. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  52769. */
  52770. customButtons?: Array<WebXREnterExitUIButton>;
  52771. /**
  52772. * A reference space type to use when creating the default button.
  52773. * Default is local-floor
  52774. */
  52775. referenceSpaceType?: XRReferenceSpaceType;
  52776. /**
  52777. * Context to enter xr with
  52778. */
  52779. renderTarget?: Nullable<WebXRRenderTarget>;
  52780. /**
  52781. * A session mode to use when creating the default button.
  52782. * Default is immersive-vr
  52783. */
  52784. sessionMode?: XRSessionMode;
  52785. /**
  52786. * A list of optional features to init the session with
  52787. */
  52788. optionalFeatures?: string[];
  52789. /**
  52790. * A list of optional features to init the session with
  52791. */
  52792. requiredFeatures?: string[];
  52793. /**
  52794. * If defined, this function will be executed if the UI encounters an error when entering XR
  52795. */
  52796. onError?: (error: any) => void;
  52797. }
  52798. /**
  52799. * UI to allow the user to enter/exit XR mode
  52800. */
  52801. export class WebXREnterExitUI implements IDisposable {
  52802. private scene;
  52803. /** version of the options passed to this UI */
  52804. options: WebXREnterExitUIOptions;
  52805. private _activeButton;
  52806. private _buttons;
  52807. /**
  52808. * The HTML Div Element to which buttons are added.
  52809. */
  52810. readonly overlay: HTMLDivElement;
  52811. /**
  52812. * Fired every time the active button is changed.
  52813. *
  52814. * When xr is entered via a button that launches xr that button will be the callback parameter
  52815. *
  52816. * When exiting xr the callback parameter will be null)
  52817. */
  52818. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  52819. /**
  52820. *
  52821. * @param scene babylon scene object to use
  52822. * @param options (read-only) version of the options passed to this UI
  52823. */
  52824. private constructor();
  52825. /**
  52826. * Creates UI to allow the user to enter/exit XR mode
  52827. * @param scene the scene to add the ui to
  52828. * @param helper the xr experience helper to enter/exit xr with
  52829. * @param options options to configure the UI
  52830. * @returns the created ui
  52831. */
  52832. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  52833. /**
  52834. * Disposes of the XR UI component
  52835. */
  52836. dispose(): void;
  52837. private _updateButtons;
  52838. }
  52839. }
  52840. declare module BABYLON {
  52841. /**
  52842. * Class containing static functions to help procedurally build meshes
  52843. */
  52844. export class LinesBuilder {
  52845. /**
  52846. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  52847. * * 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
  52848. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  52849. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  52850. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  52851. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  52852. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  52853. * * 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
  52854. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  52855. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52856. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  52857. * @param name defines the name of the new line system
  52858. * @param options defines the options used to create the line system
  52859. * @param scene defines the hosting scene
  52860. * @returns a new line system mesh
  52861. */
  52862. static CreateLineSystem(name: string, options: {
  52863. lines: Vector3[][];
  52864. updatable?: boolean;
  52865. instance?: Nullable<LinesMesh>;
  52866. colors?: Nullable<Color4[][]>;
  52867. useVertexAlpha?: boolean;
  52868. }, scene: Nullable<Scene>): LinesMesh;
  52869. /**
  52870. * Creates a line mesh
  52871. * 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
  52872. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  52873. * * The parameter `points` is an array successive Vector3
  52874. * * 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
  52875. * * The optional parameter `colors` is an array of successive Color4, one per line point
  52876. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  52877. * * When updating an instance, remember that only point positions can change, not the number of points
  52878. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52879. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  52880. * @param name defines the name of the new line system
  52881. * @param options defines the options used to create the line system
  52882. * @param scene defines the hosting scene
  52883. * @returns a new line mesh
  52884. */
  52885. static CreateLines(name: string, options: {
  52886. points: Vector3[];
  52887. updatable?: boolean;
  52888. instance?: Nullable<LinesMesh>;
  52889. colors?: Color4[];
  52890. useVertexAlpha?: boolean;
  52891. }, scene?: Nullable<Scene>): LinesMesh;
  52892. /**
  52893. * Creates a dashed line mesh
  52894. * * 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
  52895. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  52896. * * The parameter `points` is an array successive Vector3
  52897. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  52898. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  52899. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  52900. * * 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
  52901. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  52902. * * When updating an instance, remember that only point positions can change, not the number of points
  52903. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52904. * @param name defines the name of the mesh
  52905. * @param options defines the options used to create the mesh
  52906. * @param scene defines the hosting scene
  52907. * @returns the dashed line mesh
  52908. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  52909. */
  52910. static CreateDashedLines(name: string, options: {
  52911. points: Vector3[];
  52912. dashSize?: number;
  52913. gapSize?: number;
  52914. dashNb?: number;
  52915. updatable?: boolean;
  52916. instance?: LinesMesh;
  52917. useVertexAlpha?: boolean;
  52918. }, scene?: Nullable<Scene>): LinesMesh;
  52919. }
  52920. }
  52921. declare module BABYLON {
  52922. /**
  52923. * Construction options for a timer
  52924. */
  52925. export interface ITimerOptions<T> {
  52926. /**
  52927. * Time-to-end
  52928. */
  52929. timeout: number;
  52930. /**
  52931. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  52932. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  52933. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  52934. */
  52935. contextObservable: Observable<T>;
  52936. /**
  52937. * Optional parameters when adding an observer to the observable
  52938. */
  52939. observableParameters?: {
  52940. mask?: number;
  52941. insertFirst?: boolean;
  52942. scope?: any;
  52943. };
  52944. /**
  52945. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  52946. */
  52947. breakCondition?: (data?: ITimerData<T>) => boolean;
  52948. /**
  52949. * Will be triggered when the time condition has met
  52950. */
  52951. onEnded?: (data: ITimerData<any>) => void;
  52952. /**
  52953. * Will be triggered when the break condition has met (prematurely ended)
  52954. */
  52955. onAborted?: (data: ITimerData<any>) => void;
  52956. /**
  52957. * Optional function to execute on each tick (or count)
  52958. */
  52959. onTick?: (data: ITimerData<any>) => void;
  52960. }
  52961. /**
  52962. * An interface defining the data sent by the timer
  52963. */
  52964. export interface ITimerData<T> {
  52965. /**
  52966. * When did it start
  52967. */
  52968. startTime: number;
  52969. /**
  52970. * Time now
  52971. */
  52972. currentTime: number;
  52973. /**
  52974. * Time passed since started
  52975. */
  52976. deltaTime: number;
  52977. /**
  52978. * How much is completed, in [0.0...1.0].
  52979. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  52980. */
  52981. completeRate: number;
  52982. /**
  52983. * What the registered observable sent in the last count
  52984. */
  52985. payload: T;
  52986. }
  52987. /**
  52988. * The current state of the timer
  52989. */
  52990. export enum TimerState {
  52991. /**
  52992. * Timer initialized, not yet started
  52993. */
  52994. INIT = 0,
  52995. /**
  52996. * Timer started and counting
  52997. */
  52998. STARTED = 1,
  52999. /**
  53000. * Timer ended (whether aborted or time reached)
  53001. */
  53002. ENDED = 2
  53003. }
  53004. /**
  53005. * A simple version of the timer. Will take options and start the timer immediately after calling it
  53006. *
  53007. * @param options options with which to initialize this timer
  53008. */
  53009. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  53010. /**
  53011. * An advanced implementation of a timer class
  53012. */
  53013. export class AdvancedTimer<T = any> implements IDisposable {
  53014. /**
  53015. * Will notify each time the timer calculates the remaining time
  53016. */
  53017. onEachCountObservable: Observable<ITimerData<T>>;
  53018. /**
  53019. * Will trigger when the timer was aborted due to the break condition
  53020. */
  53021. onTimerAbortedObservable: Observable<ITimerData<T>>;
  53022. /**
  53023. * Will trigger when the timer ended successfully
  53024. */
  53025. onTimerEndedObservable: Observable<ITimerData<T>>;
  53026. /**
  53027. * Will trigger when the timer state has changed
  53028. */
  53029. onStateChangedObservable: Observable<TimerState>;
  53030. private _observer;
  53031. private _contextObservable;
  53032. private _observableParameters;
  53033. private _startTime;
  53034. private _timer;
  53035. private _state;
  53036. private _breakCondition;
  53037. private _timeToEnd;
  53038. private _breakOnNextTick;
  53039. /**
  53040. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  53041. * @param options construction options for this advanced timer
  53042. */
  53043. constructor(options: ITimerOptions<T>);
  53044. /**
  53045. * set a breaking condition for this timer. Default is to never break during count
  53046. * @param predicate the new break condition. Returns true to break, false otherwise
  53047. */
  53048. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  53049. /**
  53050. * Reset ALL associated observables in this advanced timer
  53051. */
  53052. clearObservables(): void;
  53053. /**
  53054. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  53055. *
  53056. * @param timeToEnd how much time to measure until timer ended
  53057. */
  53058. start(timeToEnd?: number): void;
  53059. /**
  53060. * Will force a stop on the next tick.
  53061. */
  53062. stop(): void;
  53063. /**
  53064. * Dispose this timer, clearing all resources
  53065. */
  53066. dispose(): void;
  53067. private _setState;
  53068. private _tick;
  53069. private _stop;
  53070. }
  53071. }
  53072. declare module BABYLON {
  53073. /**
  53074. * The options container for the teleportation module
  53075. */
  53076. export interface IWebXRTeleportationOptions {
  53077. /**
  53078. * if provided, this scene will be used to render meshes.
  53079. */
  53080. customUtilityLayerScene?: Scene;
  53081. /**
  53082. * Values to configure the default target mesh
  53083. */
  53084. defaultTargetMeshOptions?: {
  53085. /**
  53086. * Fill color of the teleportation area
  53087. */
  53088. teleportationFillColor?: string;
  53089. /**
  53090. * Border color for the teleportation area
  53091. */
  53092. teleportationBorderColor?: string;
  53093. /**
  53094. * Disable the mesh's animation sequence
  53095. */
  53096. disableAnimation?: boolean;
  53097. /**
  53098. * Disable lighting on the material or the ring and arrow
  53099. */
  53100. disableLighting?: boolean;
  53101. /**
  53102. * Override the default material of the torus and arrow
  53103. */
  53104. torusArrowMaterial?: Material;
  53105. };
  53106. /**
  53107. * A list of meshes to use as floor meshes.
  53108. * Meshes can be added and removed after initializing the feature using the
  53109. * addFloorMesh and removeFloorMesh functions
  53110. * If empty, rotation will still work
  53111. */
  53112. floorMeshes?: AbstractMesh[];
  53113. /**
  53114. * use this rendering group id for the meshes (optional)
  53115. */
  53116. renderingGroupId?: number;
  53117. /**
  53118. * Should teleportation move only to snap points
  53119. */
  53120. snapPointsOnly?: boolean;
  53121. /**
  53122. * An array of points to which the teleportation will snap to.
  53123. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  53124. */
  53125. snapPositions?: Vector3[];
  53126. /**
  53127. * How close should the teleportation ray be in order to snap to position.
  53128. * Default to 0.8 units (meters)
  53129. */
  53130. snapToPositionRadius?: number;
  53131. /**
  53132. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  53133. * If you want to support rotation, make sure your mesh has a direction indicator.
  53134. *
  53135. * When left untouched, the default mesh will be initialized.
  53136. */
  53137. teleportationTargetMesh?: AbstractMesh;
  53138. /**
  53139. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  53140. */
  53141. timeToTeleport?: number;
  53142. /**
  53143. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  53144. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  53145. */
  53146. useMainComponentOnly?: boolean;
  53147. /**
  53148. * Should meshes created here be added to a utility layer or the main scene
  53149. */
  53150. useUtilityLayer?: boolean;
  53151. /**
  53152. * Babylon XR Input class for controller
  53153. */
  53154. xrInput: WebXRInput;
  53155. /**
  53156. * Meshes that the teleportation ray cannot go through
  53157. */
  53158. pickBlockerMeshes?: AbstractMesh[];
  53159. /**
  53160. * Should teleport work only on a specific hand?
  53161. */
  53162. forceHandedness?: XRHandedness;
  53163. /**
  53164. * If provided, this function will be used to generate the ray mesh instead of the lines mesh being used per default
  53165. */
  53166. generateRayPathMesh?: (points: Vector3[]) => AbstractMesh;
  53167. }
  53168. /**
  53169. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  53170. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  53171. * the input of the attached controllers.
  53172. */
  53173. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  53174. private _options;
  53175. private _controllers;
  53176. private _currentTeleportationControllerId;
  53177. private _floorMeshes;
  53178. private _quadraticBezierCurve;
  53179. private _selectionFeature;
  53180. private _snapToPositions;
  53181. private _snappedToPoint;
  53182. private _teleportationRingMaterial?;
  53183. private _tmpRay;
  53184. private _tmpVector;
  53185. private _tmpQuaternion;
  53186. /**
  53187. * The module's name
  53188. */
  53189. static readonly Name: string;
  53190. /**
  53191. * The (Babylon) version of this module.
  53192. * This is an integer representing the implementation version.
  53193. * This number does not correspond to the webxr specs version
  53194. */
  53195. static readonly Version: number;
  53196. /**
  53197. * Is movement backwards enabled
  53198. */
  53199. backwardsMovementEnabled: boolean;
  53200. /**
  53201. * Distance to travel when moving backwards
  53202. */
  53203. backwardsTeleportationDistance: number;
  53204. /**
  53205. * The distance from the user to the inspection point in the direction of the controller
  53206. * A higher number will allow the user to move further
  53207. * defaults to 5 (meters, in xr units)
  53208. */
  53209. parabolicCheckRadius: number;
  53210. /**
  53211. * Should the module support parabolic ray on top of direct ray
  53212. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  53213. * Very helpful when moving between floors / different heights
  53214. */
  53215. parabolicRayEnabled: boolean;
  53216. /**
  53217. * The second type of ray - straight line.
  53218. * Should it be enabled or should the parabolic line be the only one.
  53219. */
  53220. straightRayEnabled: boolean;
  53221. /**
  53222. * How much rotation should be applied when rotating right and left
  53223. */
  53224. rotationAngle: number;
  53225. private _rotationEnabled;
  53226. /**
  53227. * Is rotation enabled when moving forward?
  53228. * Disabling this feature will prevent the user from deciding the direction when teleporting
  53229. */
  53230. get rotationEnabled(): boolean;
  53231. /**
  53232. * Sets wether rotation is enabled or not
  53233. * @param enabled is rotation enabled when teleportation is shown
  53234. */
  53235. set rotationEnabled(enabled: boolean);
  53236. /**
  53237. * Exposes the currently set teleportation target mesh.
  53238. */
  53239. get teleportationTargetMesh(): Nullable<AbstractMesh>;
  53240. /**
  53241. * constructs a new anchor system
  53242. * @param _xrSessionManager an instance of WebXRSessionManager
  53243. * @param _options configuration object for this feature
  53244. */
  53245. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  53246. /**
  53247. * Get the snapPointsOnly flag
  53248. */
  53249. get snapPointsOnly(): boolean;
  53250. /**
  53251. * Sets the snapPointsOnly flag
  53252. * @param snapToPoints should teleportation be exclusively to snap points
  53253. */
  53254. set snapPointsOnly(snapToPoints: boolean);
  53255. /**
  53256. * Add a new mesh to the floor meshes array
  53257. * @param mesh the mesh to use as floor mesh
  53258. */
  53259. addFloorMesh(mesh: AbstractMesh): void;
  53260. /**
  53261. * Add a new snap-to point to fix teleportation to this position
  53262. * @param newSnapPoint The new Snap-To point
  53263. */
  53264. addSnapPoint(newSnapPoint: Vector3): void;
  53265. attach(): boolean;
  53266. detach(): boolean;
  53267. dispose(): void;
  53268. /**
  53269. * Remove a mesh from the floor meshes array
  53270. * @param mesh the mesh to remove
  53271. */
  53272. removeFloorMesh(mesh: AbstractMesh): void;
  53273. /**
  53274. * Remove a mesh from the floor meshes array using its name
  53275. * @param name the mesh name to remove
  53276. */
  53277. removeFloorMeshByName(name: string): void;
  53278. /**
  53279. * 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
  53280. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  53281. * @returns was the point found and removed or not
  53282. */
  53283. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  53284. /**
  53285. * This function sets a selection feature that will be disabled when
  53286. * the forward ray is shown and will be reattached when hidden.
  53287. * This is used to remove the selection rays when moving.
  53288. * @param selectionFeature the feature to disable when forward movement is enabled
  53289. */
  53290. setSelectionFeature(selectionFeature: Nullable<IWebXRFeature>): void;
  53291. protected _onXRFrame(_xrFrame: XRFrame): void;
  53292. private _attachController;
  53293. private _createDefaultTargetMesh;
  53294. private _detachController;
  53295. private _findClosestSnapPointWithRadius;
  53296. private _setTargetMeshPosition;
  53297. private _setTargetMeshVisibility;
  53298. private _showParabolicPath;
  53299. private _teleportForward;
  53300. }
  53301. }
  53302. declare module BABYLON {
  53303. /**
  53304. * Options for the default xr helper
  53305. */
  53306. export class WebXRDefaultExperienceOptions {
  53307. /**
  53308. * Enable or disable default UI to enter XR
  53309. */
  53310. disableDefaultUI?: boolean;
  53311. /**
  53312. * Should teleportation not initialize. defaults to false.
  53313. */
  53314. disableTeleportation?: boolean;
  53315. /**
  53316. * Floor meshes that will be used for teleport
  53317. */
  53318. floorMeshes?: Array<AbstractMesh>;
  53319. /**
  53320. * If set to true, the first frame will not be used to reset position
  53321. * The first frame is mainly used when copying transformation from the old camera
  53322. * Mainly used in AR
  53323. */
  53324. ignoreNativeCameraTransformation?: boolean;
  53325. /**
  53326. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  53327. */
  53328. inputOptions?: IWebXRInputOptions;
  53329. /**
  53330. * optional configuration for the output canvas
  53331. */
  53332. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  53333. /**
  53334. * optional UI options. This can be used among other to change session mode and reference space type
  53335. */
  53336. uiOptions?: WebXREnterExitUIOptions;
  53337. /**
  53338. * When loading teleportation and pointer select, use stable versions instead of latest.
  53339. */
  53340. useStablePlugins?: boolean;
  53341. /**
  53342. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  53343. */
  53344. renderingGroupId?: number;
  53345. /**
  53346. * A list of optional features to init the session with
  53347. * If set to true, all features we support will be added
  53348. */
  53349. optionalFeatures?: boolean | string[];
  53350. }
  53351. /**
  53352. * Default experience which provides a similar setup to the previous webVRExperience
  53353. */
  53354. export class WebXRDefaultExperience {
  53355. /**
  53356. * Base experience
  53357. */
  53358. baseExperience: WebXRExperienceHelper;
  53359. /**
  53360. * Enables ui for entering/exiting xr
  53361. */
  53362. enterExitUI: WebXREnterExitUI;
  53363. /**
  53364. * Input experience extension
  53365. */
  53366. input: WebXRInput;
  53367. /**
  53368. * Enables laser pointer and selection
  53369. */
  53370. pointerSelection: WebXRControllerPointerSelection;
  53371. /**
  53372. * Default target xr should render to
  53373. */
  53374. renderTarget: WebXRRenderTarget;
  53375. /**
  53376. * Enables teleportation
  53377. */
  53378. teleportation: WebXRMotionControllerTeleportation;
  53379. private constructor();
  53380. /**
  53381. * Creates the default xr experience
  53382. * @param scene scene
  53383. * @param options options for basic configuration
  53384. * @returns resulting WebXRDefaultExperience
  53385. */
  53386. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  53387. /**
  53388. * DIsposes of the experience helper
  53389. */
  53390. dispose(): void;
  53391. }
  53392. }
  53393. declare module BABYLON {
  53394. /**
  53395. * Options to modify the vr teleportation behavior.
  53396. */
  53397. export interface VRTeleportationOptions {
  53398. /**
  53399. * The name of the mesh which should be used as the teleportation floor. (default: null)
  53400. */
  53401. floorMeshName?: string;
  53402. /**
  53403. * A list of meshes to be used as the teleportation floor. (default: empty)
  53404. */
  53405. floorMeshes?: Mesh[];
  53406. /**
  53407. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  53408. */
  53409. teleportationMode?: number;
  53410. /**
  53411. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  53412. */
  53413. teleportationTime?: number;
  53414. /**
  53415. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  53416. */
  53417. teleportationSpeed?: number;
  53418. /**
  53419. * The easing function used in the animation or null for Linear. (default CircleEase)
  53420. */
  53421. easingFunction?: EasingFunction;
  53422. }
  53423. /**
  53424. * Options to modify the vr experience helper's behavior.
  53425. */
  53426. export interface VRExperienceHelperOptions extends WebVROptions {
  53427. /**
  53428. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  53429. */
  53430. createDeviceOrientationCamera?: boolean;
  53431. /**
  53432. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  53433. */
  53434. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  53435. /**
  53436. * Uses the main button on the controller to toggle the laser casted. (default: true)
  53437. */
  53438. laserToggle?: boolean;
  53439. /**
  53440. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  53441. */
  53442. floorMeshes?: Mesh[];
  53443. /**
  53444. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  53445. */
  53446. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  53447. /**
  53448. * Defines if WebXR should be used instead of WebVR (if available)
  53449. */
  53450. useXR?: boolean;
  53451. }
  53452. /**
  53453. * Event containing information after VR has been entered
  53454. */
  53455. export class OnAfterEnteringVRObservableEvent {
  53456. /**
  53457. * If entering vr was successful
  53458. */
  53459. success: boolean;
  53460. }
  53461. /**
  53462. * Helps to quickly add VR support to an existing scene.
  53463. * See https://doc.babylonjs.com/how_to/webvr_helper
  53464. */
  53465. export class VRExperienceHelper {
  53466. /** Options to modify the vr experience helper's behavior. */
  53467. webVROptions: VRExperienceHelperOptions;
  53468. private _scene;
  53469. private _position;
  53470. private _btnVR;
  53471. private _btnVRDisplayed;
  53472. private _webVRsupported;
  53473. private _webVRready;
  53474. private _webVRrequesting;
  53475. private _webVRpresenting;
  53476. private _hasEnteredVR;
  53477. private _fullscreenVRpresenting;
  53478. private _inputElement;
  53479. private _webVRCamera;
  53480. private _vrDeviceOrientationCamera;
  53481. private _deviceOrientationCamera;
  53482. private _existingCamera;
  53483. private _onKeyDown;
  53484. private _onVrDisplayPresentChange;
  53485. private _onVRDisplayChanged;
  53486. private _onVRRequestPresentStart;
  53487. private _onVRRequestPresentComplete;
  53488. /**
  53489. * 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)
  53490. */
  53491. enableGazeEvenWhenNoPointerLock: boolean;
  53492. /**
  53493. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  53494. */
  53495. exitVROnDoubleTap: boolean;
  53496. /**
  53497. * Observable raised right before entering VR.
  53498. */
  53499. onEnteringVRObservable: Observable<VRExperienceHelper>;
  53500. /**
  53501. * Observable raised when entering VR has completed.
  53502. */
  53503. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  53504. /**
  53505. * Observable raised when exiting VR.
  53506. */
  53507. onExitingVRObservable: Observable<VRExperienceHelper>;
  53508. /**
  53509. * Observable raised when controller mesh is loaded.
  53510. */
  53511. onControllerMeshLoadedObservable: Observable<WebVRController>;
  53512. /** Return this.onEnteringVRObservable
  53513. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  53514. */
  53515. get onEnteringVR(): Observable<VRExperienceHelper>;
  53516. /** Return this.onExitingVRObservable
  53517. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  53518. */
  53519. get onExitingVR(): Observable<VRExperienceHelper>;
  53520. /** Return this.onControllerMeshLoadedObservable
  53521. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  53522. */
  53523. get onControllerMeshLoaded(): Observable<WebVRController>;
  53524. private _rayLength;
  53525. private _useCustomVRButton;
  53526. private _teleportationRequested;
  53527. private _teleportActive;
  53528. private _floorMeshName;
  53529. private _floorMeshesCollection;
  53530. private _teleportationMode;
  53531. private _teleportationTime;
  53532. private _teleportationSpeed;
  53533. private _teleportationEasing;
  53534. private _rotationAllowed;
  53535. private _teleportBackwardsVector;
  53536. private _teleportationTarget;
  53537. private _isDefaultTeleportationTarget;
  53538. private _postProcessMove;
  53539. private _teleportationFillColor;
  53540. private _teleportationBorderColor;
  53541. private _rotationAngle;
  53542. private _haloCenter;
  53543. private _cameraGazer;
  53544. private _padSensibilityUp;
  53545. private _padSensibilityDown;
  53546. private _leftController;
  53547. private _rightController;
  53548. private _gazeColor;
  53549. private _laserColor;
  53550. private _pickedLaserColor;
  53551. private _pickedGazeColor;
  53552. /**
  53553. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  53554. */
  53555. onNewMeshSelected: Observable<AbstractMesh>;
  53556. /**
  53557. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  53558. * This observable will provide the mesh and the controller used to select the mesh
  53559. */
  53560. onMeshSelectedWithController: Observable<{
  53561. mesh: AbstractMesh;
  53562. controller: WebVRController;
  53563. }>;
  53564. /**
  53565. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  53566. */
  53567. onNewMeshPicked: Observable<PickingInfo>;
  53568. private _circleEase;
  53569. /**
  53570. * Observable raised before camera teleportation
  53571. */
  53572. onBeforeCameraTeleport: Observable<Vector3>;
  53573. /**
  53574. * Observable raised after camera teleportation
  53575. */
  53576. onAfterCameraTeleport: Observable<Vector3>;
  53577. /**
  53578. * Observable raised when current selected mesh gets unselected
  53579. */
  53580. onSelectedMeshUnselected: Observable<AbstractMesh>;
  53581. private _raySelectionPredicate;
  53582. /**
  53583. * To be optionaly changed by user to define custom ray selection
  53584. */
  53585. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  53586. /**
  53587. * To be optionaly changed by user to define custom selection logic (after ray selection)
  53588. */
  53589. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  53590. /**
  53591. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  53592. */
  53593. teleportationEnabled: boolean;
  53594. private _defaultHeight;
  53595. private _teleportationInitialized;
  53596. private _interactionsEnabled;
  53597. private _interactionsRequested;
  53598. private _displayGaze;
  53599. private _displayLaserPointer;
  53600. /**
  53601. * The mesh used to display where the user is going to teleport.
  53602. */
  53603. get teleportationTarget(): Mesh;
  53604. /**
  53605. * Sets the mesh to be used to display where the user is going to teleport.
  53606. */
  53607. set teleportationTarget(value: Mesh);
  53608. /**
  53609. * 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
  53610. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  53611. * See https://doc.babylonjs.com/resources/baking_transformations
  53612. */
  53613. get gazeTrackerMesh(): Mesh;
  53614. set gazeTrackerMesh(value: Mesh);
  53615. /**
  53616. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  53617. */
  53618. updateGazeTrackerScale: boolean;
  53619. /**
  53620. * If the gaze trackers color should be updated when selecting meshes
  53621. */
  53622. updateGazeTrackerColor: boolean;
  53623. /**
  53624. * If the controller laser color should be updated when selecting meshes
  53625. */
  53626. updateControllerLaserColor: boolean;
  53627. /**
  53628. * The gaze tracking mesh corresponding to the left controller
  53629. */
  53630. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  53631. /**
  53632. * The gaze tracking mesh corresponding to the right controller
  53633. */
  53634. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  53635. /**
  53636. * If the ray of the gaze should be displayed.
  53637. */
  53638. get displayGaze(): boolean;
  53639. /**
  53640. * Sets if the ray of the gaze should be displayed.
  53641. */
  53642. set displayGaze(value: boolean);
  53643. /**
  53644. * If the ray of the LaserPointer should be displayed.
  53645. */
  53646. get displayLaserPointer(): boolean;
  53647. /**
  53648. * Sets if the ray of the LaserPointer should be displayed.
  53649. */
  53650. set displayLaserPointer(value: boolean);
  53651. /**
  53652. * The deviceOrientationCamera used as the camera when not in VR.
  53653. */
  53654. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  53655. /**
  53656. * Based on the current WebVR support, returns the current VR camera used.
  53657. */
  53658. get currentVRCamera(): Nullable<Camera>;
  53659. /**
  53660. * The webVRCamera which is used when in VR.
  53661. */
  53662. get webVRCamera(): WebVRFreeCamera;
  53663. /**
  53664. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  53665. */
  53666. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  53667. /**
  53668. * The html button that is used to trigger entering into VR.
  53669. */
  53670. get vrButton(): Nullable<HTMLButtonElement>;
  53671. private get _teleportationRequestInitiated();
  53672. /**
  53673. * Defines whether or not Pointer lock should be requested when switching to
  53674. * full screen.
  53675. */
  53676. requestPointerLockOnFullScreen: boolean;
  53677. /**
  53678. * If asking to force XR, this will be populated with the default xr experience
  53679. */
  53680. xr: WebXRDefaultExperience;
  53681. /**
  53682. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  53683. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  53684. */
  53685. xrTestDone: boolean;
  53686. /**
  53687. * Instantiates a VRExperienceHelper.
  53688. * Helps to quickly add VR support to an existing scene.
  53689. * @param scene The scene the VRExperienceHelper belongs to.
  53690. * @param webVROptions Options to modify the vr experience helper's behavior.
  53691. */
  53692. constructor(scene: Scene,
  53693. /** Options to modify the vr experience helper's behavior. */
  53694. webVROptions?: VRExperienceHelperOptions);
  53695. private completeVRInit;
  53696. private _onDefaultMeshLoaded;
  53697. private _onResize;
  53698. private _onFullscreenChange;
  53699. /**
  53700. * Gets a value indicating if we are currently in VR mode.
  53701. */
  53702. get isInVRMode(): boolean;
  53703. private onVrDisplayPresentChange;
  53704. private onVRDisplayChanged;
  53705. private moveButtonToBottomRight;
  53706. private displayVRButton;
  53707. private updateButtonVisibility;
  53708. private _cachedAngularSensibility;
  53709. /**
  53710. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  53711. * Otherwise, will use the fullscreen API.
  53712. */
  53713. enterVR(): void;
  53714. /**
  53715. * Attempt to exit VR, or fullscreen.
  53716. */
  53717. exitVR(): void;
  53718. /**
  53719. * The position of the vr experience helper.
  53720. */
  53721. get position(): Vector3;
  53722. /**
  53723. * Sets the position of the vr experience helper.
  53724. */
  53725. set position(value: Vector3);
  53726. /**
  53727. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  53728. */
  53729. enableInteractions(): void;
  53730. private get _noControllerIsActive();
  53731. private beforeRender;
  53732. private _isTeleportationFloor;
  53733. /**
  53734. * Adds a floor mesh to be used for teleportation.
  53735. * @param floorMesh the mesh to be used for teleportation.
  53736. */
  53737. addFloorMesh(floorMesh: Mesh): void;
  53738. /**
  53739. * Removes a floor mesh from being used for teleportation.
  53740. * @param floorMesh the mesh to be removed.
  53741. */
  53742. removeFloorMesh(floorMesh: Mesh): void;
  53743. /**
  53744. * Enables interactions and teleportation using the VR controllers and gaze.
  53745. * @param vrTeleportationOptions options to modify teleportation behavior.
  53746. */
  53747. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  53748. private _onNewGamepadConnected;
  53749. private _tryEnableInteractionOnController;
  53750. private _onNewGamepadDisconnected;
  53751. private _enableInteractionOnController;
  53752. private _checkTeleportWithRay;
  53753. private _checkRotate;
  53754. private _checkTeleportBackwards;
  53755. private _enableTeleportationOnController;
  53756. private _createTeleportationCircles;
  53757. private _displayTeleportationTarget;
  53758. private _hideTeleportationTarget;
  53759. private _rotateCamera;
  53760. private _moveTeleportationSelectorTo;
  53761. private _workingVector;
  53762. private _workingQuaternion;
  53763. private _workingMatrix;
  53764. /**
  53765. * Time Constant Teleportation Mode
  53766. */
  53767. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  53768. /**
  53769. * Speed Constant Teleportation Mode
  53770. */
  53771. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  53772. /**
  53773. * Teleports the users feet to the desired location
  53774. * @param location The location where the user's feet should be placed
  53775. */
  53776. teleportCamera(location: Vector3): void;
  53777. private _convertNormalToDirectionOfRay;
  53778. private _castRayAndSelectObject;
  53779. private _notifySelectedMeshUnselected;
  53780. /**
  53781. * Permanently set new colors for the laser pointer
  53782. * @param color the new laser color
  53783. * @param pickedColor the new laser color when picked mesh detected
  53784. */
  53785. setLaserColor(color: Color3, pickedColor?: Color3): void;
  53786. /**
  53787. * Set lighting enabled / disabled on the laser pointer of both controllers
  53788. * @param enabled should the lighting be enabled on the laser pointer
  53789. */
  53790. setLaserLightingState(enabled?: boolean): void;
  53791. /**
  53792. * Permanently set new colors for the gaze pointer
  53793. * @param color the new gaze color
  53794. * @param pickedColor the new gaze color when picked mesh detected
  53795. */
  53796. setGazeColor(color: Color3, pickedColor?: Color3): void;
  53797. /**
  53798. * Sets the color of the laser ray from the vr controllers.
  53799. * @param color new color for the ray.
  53800. */
  53801. changeLaserColor(color: Color3): void;
  53802. /**
  53803. * Sets the color of the ray from the vr headsets gaze.
  53804. * @param color new color for the ray.
  53805. */
  53806. changeGazeColor(color: Color3): void;
  53807. /**
  53808. * Exits VR and disposes of the vr experience helper
  53809. */
  53810. dispose(): void;
  53811. /**
  53812. * Gets the name of the VRExperienceHelper class
  53813. * @returns "VRExperienceHelper"
  53814. */
  53815. getClassName(): string;
  53816. }
  53817. }
  53818. declare module BABYLON {
  53819. /**
  53820. * Contains an array of blocks representing the octree
  53821. */
  53822. export interface IOctreeContainer<T> {
  53823. /**
  53824. * Blocks within the octree
  53825. */
  53826. blocks: Array<OctreeBlock<T>>;
  53827. }
  53828. /**
  53829. * Class used to store a cell in an octree
  53830. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  53831. */
  53832. export class OctreeBlock<T> {
  53833. /**
  53834. * Gets the content of the current block
  53835. */
  53836. entries: T[];
  53837. /**
  53838. * Gets the list of block children
  53839. */
  53840. blocks: Array<OctreeBlock<T>>;
  53841. private _depth;
  53842. private _maxDepth;
  53843. private _capacity;
  53844. private _minPoint;
  53845. private _maxPoint;
  53846. private _boundingVectors;
  53847. private _creationFunc;
  53848. /**
  53849. * Creates a new block
  53850. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  53851. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  53852. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  53853. * @param depth defines the current depth of this block in the octree
  53854. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  53855. * @param creationFunc defines a callback to call when an element is added to the block
  53856. */
  53857. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  53858. /**
  53859. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  53860. */
  53861. get capacity(): number;
  53862. /**
  53863. * Gets the minimum vector (in world space) of the block's bounding box
  53864. */
  53865. get minPoint(): Vector3;
  53866. /**
  53867. * Gets the maximum vector (in world space) of the block's bounding box
  53868. */
  53869. get maxPoint(): Vector3;
  53870. /**
  53871. * Add a new element to this block
  53872. * @param entry defines the element to add
  53873. */
  53874. addEntry(entry: T): void;
  53875. /**
  53876. * Remove an element from this block
  53877. * @param entry defines the element to remove
  53878. */
  53879. removeEntry(entry: T): void;
  53880. /**
  53881. * Add an array of elements to this block
  53882. * @param entries defines the array of elements to add
  53883. */
  53884. addEntries(entries: T[]): void;
  53885. /**
  53886. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  53887. * @param frustumPlanes defines the frustum planes to test
  53888. * @param selection defines the array to store current content if selection is positive
  53889. * @param allowDuplicate defines if the selection array can contains duplicated entries
  53890. */
  53891. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  53892. /**
  53893. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  53894. * @param sphereCenter defines the bounding sphere center
  53895. * @param sphereRadius defines the bounding sphere radius
  53896. * @param selection defines the array to store current content if selection is positive
  53897. * @param allowDuplicate defines if the selection array can contains duplicated entries
  53898. */
  53899. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  53900. /**
  53901. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  53902. * @param ray defines the ray to test with
  53903. * @param selection defines the array to store current content if selection is positive
  53904. */
  53905. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  53906. /**
  53907. * Subdivide the content into child blocks (this block will then be empty)
  53908. */
  53909. createInnerBlocks(): void;
  53910. /**
  53911. * @hidden
  53912. */
  53913. 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;
  53914. }
  53915. }
  53916. declare module BABYLON {
  53917. /**
  53918. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  53919. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  53920. */
  53921. export class Octree<T> {
  53922. /** 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.) */
  53923. maxDepth: number;
  53924. /**
  53925. * Blocks within the octree containing objects
  53926. */
  53927. blocks: Array<OctreeBlock<T>>;
  53928. /**
  53929. * Content stored in the octree
  53930. */
  53931. dynamicContent: T[];
  53932. private _maxBlockCapacity;
  53933. private _selectionContent;
  53934. private _creationFunc;
  53935. /**
  53936. * Creates a octree
  53937. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  53938. * @param creationFunc function to be used to instatiate the octree
  53939. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  53940. * @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.)
  53941. */
  53942. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  53943. /** 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.) */
  53944. maxDepth?: number);
  53945. /**
  53946. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  53947. * @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);
  53948. * @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);
  53949. * @param entries meshes to be added to the octree blocks
  53950. */
  53951. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  53952. /**
  53953. * Adds a mesh to the octree
  53954. * @param entry Mesh to add to the octree
  53955. */
  53956. addMesh(entry: T): void;
  53957. /**
  53958. * Remove an element from the octree
  53959. * @param entry defines the element to remove
  53960. */
  53961. removeMesh(entry: T): void;
  53962. /**
  53963. * Selects an array of meshes within the frustum
  53964. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  53965. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  53966. * @returns array of meshes within the frustum
  53967. */
  53968. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  53969. /**
  53970. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  53971. * @param sphereCenter defines the bounding sphere center
  53972. * @param sphereRadius defines the bounding sphere radius
  53973. * @param allowDuplicate defines if the selection array can contains duplicated entries
  53974. * @returns an array of objects that intersect the sphere
  53975. */
  53976. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  53977. /**
  53978. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  53979. * @param ray defines the ray to test with
  53980. * @returns array of intersected objects
  53981. */
  53982. intersectsRay(ray: Ray): SmartArray<T>;
  53983. /**
  53984. * Adds a mesh into the octree block if it intersects the block
  53985. */
  53986. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  53987. /**
  53988. * Adds a submesh into the octree block if it intersects the block
  53989. */
  53990. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  53991. }
  53992. }
  53993. declare module BABYLON {
  53994. interface Scene {
  53995. /**
  53996. * @hidden
  53997. * Backing Filed
  53998. */
  53999. _selectionOctree: Octree<AbstractMesh>;
  54000. /**
  54001. * Gets the octree used to boost mesh selection (picking)
  54002. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  54003. */
  54004. selectionOctree: Octree<AbstractMesh>;
  54005. /**
  54006. * Creates or updates the octree used to boost selection (picking)
  54007. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  54008. * @param maxCapacity defines the maximum capacity per leaf
  54009. * @param maxDepth defines the maximum depth of the octree
  54010. * @returns an octree of AbstractMesh
  54011. */
  54012. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  54013. }
  54014. interface AbstractMesh {
  54015. /**
  54016. * @hidden
  54017. * Backing Field
  54018. */
  54019. _submeshesOctree: Octree<SubMesh>;
  54020. /**
  54021. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  54022. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  54023. * @param maxCapacity defines the maximum size of each block (64 by default)
  54024. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  54025. * @returns the new octree
  54026. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  54027. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  54028. */
  54029. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  54030. }
  54031. /**
  54032. * Defines the octree scene component responsible to manage any octrees
  54033. * in a given scene.
  54034. */
  54035. export class OctreeSceneComponent {
  54036. /**
  54037. * The component name help to identify the component in the list of scene components.
  54038. */
  54039. readonly name: string;
  54040. /**
  54041. * The scene the component belongs to.
  54042. */
  54043. scene: Scene;
  54044. /**
  54045. * Indicates if the meshes have been checked to make sure they are isEnabled()
  54046. */
  54047. readonly checksIsEnabled: boolean;
  54048. /**
  54049. * Creates a new instance of the component for the given scene
  54050. * @param scene Defines the scene to register the component in
  54051. */
  54052. constructor(scene: Scene);
  54053. /**
  54054. * Registers the component in a given scene
  54055. */
  54056. register(): void;
  54057. /**
  54058. * Return the list of active meshes
  54059. * @returns the list of active meshes
  54060. */
  54061. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  54062. /**
  54063. * Return the list of active sub meshes
  54064. * @param mesh The mesh to get the candidates sub meshes from
  54065. * @returns the list of active sub meshes
  54066. */
  54067. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  54068. private _tempRay;
  54069. /**
  54070. * Return the list of sub meshes intersecting with a given local ray
  54071. * @param mesh defines the mesh to find the submesh for
  54072. * @param localRay defines the ray in local space
  54073. * @returns the list of intersecting sub meshes
  54074. */
  54075. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  54076. /**
  54077. * Return the list of sub meshes colliding with a collider
  54078. * @param mesh defines the mesh to find the submesh for
  54079. * @param collider defines the collider to evaluate the collision against
  54080. * @returns the list of colliding sub meshes
  54081. */
  54082. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  54083. /**
  54084. * Rebuilds the elements related to this component in case of
  54085. * context lost for instance.
  54086. */
  54087. rebuild(): void;
  54088. /**
  54089. * Disposes the component and the associated ressources.
  54090. */
  54091. dispose(): void;
  54092. }
  54093. }
  54094. declare module BABYLON {
  54095. /**
  54096. * Cache built by each axis. Used for managing state between all elements of gizmo for enhanced UI
  54097. */
  54098. export interface GizmoAxisCache {
  54099. /** Mesh used to runder the Gizmo */
  54100. gizmoMeshes: Mesh[];
  54101. /** Mesh used to detect user interaction with Gizmo */
  54102. colliderMeshes: Mesh[];
  54103. /** Material used to inicate color of gizmo mesh */
  54104. material: StandardMaterial;
  54105. /** Material used to inicate hover state of the Gizmo */
  54106. hoverMaterial: StandardMaterial;
  54107. /** Material used to inicate disabled state of the Gizmo */
  54108. disableMaterial: StandardMaterial;
  54109. /** Used to indicate Active state of the Gizmo */
  54110. active: boolean;
  54111. }
  54112. /**
  54113. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  54114. */
  54115. export class Gizmo implements IDisposable {
  54116. /** The utility layer the gizmo will be added to */
  54117. gizmoLayer: UtilityLayerRenderer;
  54118. /**
  54119. * The root mesh of the gizmo
  54120. */
  54121. _rootMesh: Mesh;
  54122. private _attachedMesh;
  54123. private _attachedNode;
  54124. /**
  54125. * Ratio for the scale of the gizmo (Default: 1)
  54126. */
  54127. protected _scaleRatio: number;
  54128. /**
  54129. * boolean updated by pointermove when a gizmo mesh is hovered
  54130. */
  54131. protected _isHovered: boolean;
  54132. /**
  54133. * Ratio for the scale of the gizmo (Default: 1)
  54134. */
  54135. set scaleRatio(value: number);
  54136. get scaleRatio(): number;
  54137. /**
  54138. * True when the mouse pointer is hovered a gizmo mesh
  54139. */
  54140. get isHovered(): boolean;
  54141. /**
  54142. * If a custom mesh has been set (Default: false)
  54143. */
  54144. protected _customMeshSet: boolean;
  54145. /**
  54146. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  54147. * * When set, interactions will be enabled
  54148. */
  54149. get attachedMesh(): Nullable<AbstractMesh>;
  54150. set attachedMesh(value: Nullable<AbstractMesh>);
  54151. /**
  54152. * Node that the gizmo will be attached to. (eg. on a drag gizmo the mesh, bone or NodeTransform that will be dragged)
  54153. * * When set, interactions will be enabled
  54154. */
  54155. get attachedNode(): Nullable<Node>;
  54156. set attachedNode(value: Nullable<Node>);
  54157. /**
  54158. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  54159. * @param mesh The mesh to replace the default mesh of the gizmo
  54160. */
  54161. setCustomMesh(mesh: Mesh): void;
  54162. protected _updateGizmoRotationToMatchAttachedMesh: boolean;
  54163. /**
  54164. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  54165. */
  54166. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  54167. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  54168. /**
  54169. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  54170. */
  54171. updateGizmoPositionToMatchAttachedMesh: boolean;
  54172. /**
  54173. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  54174. */
  54175. updateScale: boolean;
  54176. protected _interactionsEnabled: boolean;
  54177. protected _attachedNodeChanged(value: Nullable<Node>): void;
  54178. private _beforeRenderObserver;
  54179. private _tempQuaternion;
  54180. private _tempVector;
  54181. private _tempVector2;
  54182. private _tempMatrix1;
  54183. private _tempMatrix2;
  54184. private _rightHandtoLeftHandMatrix;
  54185. /**
  54186. * Creates a gizmo
  54187. * @param gizmoLayer The utility layer the gizmo will be added to
  54188. */
  54189. constructor(
  54190. /** The utility layer the gizmo will be added to */
  54191. gizmoLayer?: UtilityLayerRenderer);
  54192. /**
  54193. * Updates the gizmo to match the attached mesh's position/rotation
  54194. */
  54195. protected _update(): void;
  54196. /**
  54197. * computes the rotation/scaling/position of the transform once the Node world matrix has changed.
  54198. * @param value Node, TransformNode or mesh
  54199. */
  54200. protected _matrixChanged(): void;
  54201. /**
  54202. * Subscribes to pointer up, down, and hover events. Used for responsive gizmos.
  54203. * @param gizmoLayer The utility layer the gizmo will be added to
  54204. * @param gizmoAxisCache Gizmo axis definition used for reactive gizmo UI
  54205. * @returns {Observer<PointerInfo>} pointerObserver
  54206. */
  54207. static GizmoAxisPointerObserver(gizmoLayer: UtilityLayerRenderer, gizmoAxisCache: Map<Mesh, GizmoAxisCache>): Observer<PointerInfo>;
  54208. /**
  54209. * Disposes of the gizmo
  54210. */
  54211. dispose(): void;
  54212. }
  54213. }
  54214. declare module BABYLON {
  54215. /**
  54216. * Single plane drag gizmo
  54217. */
  54218. export class PlaneDragGizmo extends Gizmo {
  54219. /**
  54220. * Drag behavior responsible for the gizmos dragging interactions
  54221. */
  54222. dragBehavior: PointerDragBehavior;
  54223. private _pointerObserver;
  54224. /**
  54225. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  54226. */
  54227. snapDistance: number;
  54228. /**
  54229. * Event that fires each time the gizmo snaps to a new location.
  54230. * * snapDistance is the the change in distance
  54231. */
  54232. onSnapObservable: Observable<{
  54233. snapDistance: number;
  54234. }>;
  54235. private _gizmoMesh;
  54236. private _coloredMaterial;
  54237. private _hoverMaterial;
  54238. private _disableMaterial;
  54239. private _isEnabled;
  54240. private _parent;
  54241. private _dragging;
  54242. /** @hidden */
  54243. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  54244. /**
  54245. * Creates a PlaneDragGizmo
  54246. * @param gizmoLayer The utility layer the gizmo will be added to
  54247. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  54248. * @param color The color of the gizmo
  54249. */
  54250. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  54251. protected _attachedNodeChanged(value: Nullable<Node>): void;
  54252. /**
  54253. * If the gizmo is enabled
  54254. */
  54255. set isEnabled(value: boolean);
  54256. get isEnabled(): boolean;
  54257. /**
  54258. * Disposes of the gizmo
  54259. */
  54260. dispose(): void;
  54261. }
  54262. }
  54263. declare module BABYLON {
  54264. /**
  54265. * Single plane rotation gizmo
  54266. */
  54267. export class PlaneRotationGizmo extends Gizmo {
  54268. /**
  54269. * Drag behavior responsible for the gizmos dragging interactions
  54270. */
  54271. dragBehavior: PointerDragBehavior;
  54272. private _pointerObserver;
  54273. /**
  54274. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  54275. */
  54276. snapDistance: number;
  54277. /**
  54278. * Event that fires each time the gizmo snaps to a new location.
  54279. * * snapDistance is the the change in distance
  54280. */
  54281. onSnapObservable: Observable<{
  54282. snapDistance: number;
  54283. }>;
  54284. private _isEnabled;
  54285. private _parent;
  54286. private _coloredMaterial;
  54287. private _hoverMaterial;
  54288. private _disableMaterial;
  54289. private _gizmoMesh;
  54290. private _rotationCircle;
  54291. private _dragging;
  54292. private static _CircleConstants;
  54293. /**
  54294. * Creates a PlaneRotationGizmo
  54295. * @param gizmoLayer The utility layer the gizmo will be added to
  54296. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  54297. * @param color The color of the gizmo
  54298. * @param tessellation Amount of tessellation to be used when creating rotation circles
  54299. * @param useEulerRotation Use and update Euler angle instead of quaternion
  54300. * @param thickness display gizmo axis thickness
  54301. */
  54302. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean, thickness?: number);
  54303. /** Create Geometry for Gizmo */
  54304. private _createGizmoMesh;
  54305. protected _attachedNodeChanged(value: Nullable<Node>): void;
  54306. private setupRotationCircle;
  54307. private updateRotationPath;
  54308. private updateRotationCircle;
  54309. /**
  54310. * If the gizmo is enabled
  54311. */
  54312. set isEnabled(value: boolean);
  54313. get isEnabled(): boolean;
  54314. /**
  54315. * Disposes of the gizmo
  54316. */
  54317. dispose(): void;
  54318. }
  54319. }
  54320. declare module BABYLON {
  54321. /**
  54322. * Gizmo that enables rotating a mesh along 3 axis
  54323. */
  54324. export class RotationGizmo extends Gizmo {
  54325. /**
  54326. * Internal gizmo used for interactions on the x axis
  54327. */
  54328. xGizmo: PlaneRotationGizmo;
  54329. /**
  54330. * Internal gizmo used for interactions on the y axis
  54331. */
  54332. yGizmo: PlaneRotationGizmo;
  54333. /**
  54334. * Internal gizmo used for interactions on the z axis
  54335. */
  54336. zGizmo: PlaneRotationGizmo;
  54337. /** Fires an event when any of it's sub gizmos are dragged */
  54338. onDragStartObservable: Observable<unknown>;
  54339. /** Fires an event when any of it's sub gizmos are released from dragging */
  54340. onDragEndObservable: Observable<unknown>;
  54341. private _meshAttached;
  54342. private _nodeAttached;
  54343. private _observables;
  54344. /** Node Caching for quick lookup */
  54345. private _gizmoAxisCache;
  54346. get attachedMesh(): Nullable<AbstractMesh>;
  54347. set attachedMesh(mesh: Nullable<AbstractMesh>);
  54348. get attachedNode(): Nullable<Node>;
  54349. set attachedNode(node: Nullable<Node>);
  54350. protected _checkBillboardTransform(): void;
  54351. /**
  54352. * True when the mouse pointer is hovering a gizmo mesh
  54353. */
  54354. get isHovered(): boolean;
  54355. /**
  54356. * Creates a RotationGizmo
  54357. * @param gizmoLayer The utility layer the gizmo will be added to
  54358. * @param tessellation Amount of tessellation to be used when creating rotation circles
  54359. * @param useEulerRotation Use and update Euler angle instead of quaternion
  54360. * @param thickness display gizmo axis thickness
  54361. */
  54362. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean, thickness?: number, gizmoManager?: GizmoManager);
  54363. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  54364. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  54365. /**
  54366. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  54367. */
  54368. set snapDistance(value: number);
  54369. get snapDistance(): number;
  54370. /**
  54371. * Ratio for the scale of the gizmo (Default: 1)
  54372. */
  54373. set scaleRatio(value: number);
  54374. get scaleRatio(): number;
  54375. /**
  54376. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  54377. * @param mesh Axis gizmo mesh
  54378. * @param cache Gizmo axis definition used for reactive gizmo UI
  54379. */
  54380. addToAxisCache(mesh: Mesh, cache: GizmoAxisCache): void;
  54381. /**
  54382. * Disposes of the gizmo
  54383. */
  54384. dispose(): void;
  54385. /**
  54386. * CustomMeshes are not supported by this gizmo
  54387. * @param mesh The mesh to replace the default mesh of the gizmo
  54388. */
  54389. setCustomMesh(mesh: Mesh): void;
  54390. }
  54391. }
  54392. declare module BABYLON {
  54393. /**
  54394. * Class containing static functions to help procedurally build meshes
  54395. */
  54396. export class PolyhedronBuilder {
  54397. /**
  54398. * Creates a polyhedron mesh
  54399. * * 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
  54400. * * The parameter `size` (positive float, default 1) sets the polygon size
  54401. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  54402. * * 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`
  54403. * * 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
  54404. * * 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)`)
  54405. * * 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
  54406. * * 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
  54407. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54408. * * 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
  54409. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54410. * @param name defines the name of the mesh
  54411. * @param options defines the options used to create the mesh
  54412. * @param scene defines the hosting scene
  54413. * @returns the polyhedron mesh
  54414. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  54415. */
  54416. static CreatePolyhedron(name: string, options: {
  54417. type?: number;
  54418. size?: number;
  54419. sizeX?: number;
  54420. sizeY?: number;
  54421. sizeZ?: number;
  54422. custom?: any;
  54423. faceUV?: Vector4[];
  54424. faceColors?: Color4[];
  54425. flat?: boolean;
  54426. updatable?: boolean;
  54427. sideOrientation?: number;
  54428. frontUVs?: Vector4;
  54429. backUVs?: Vector4;
  54430. }, scene?: Nullable<Scene>): Mesh;
  54431. }
  54432. }
  54433. declare module BABYLON {
  54434. /**
  54435. * Class containing static functions to help procedurally build meshes
  54436. */
  54437. export class BoxBuilder {
  54438. /**
  54439. * Creates a box mesh
  54440. * * The parameter `size` sets the size (float) of each box side (default 1)
  54441. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  54442. * * 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)
  54443. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  54444. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54445. * * 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
  54446. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54447. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  54448. * @param name defines the name of the mesh
  54449. * @param options defines the options used to create the mesh
  54450. * @param scene defines the hosting scene
  54451. * @returns the box mesh
  54452. */
  54453. static CreateBox(name: string, options: {
  54454. size?: number;
  54455. width?: number;
  54456. height?: number;
  54457. depth?: number;
  54458. faceUV?: Vector4[];
  54459. faceColors?: Color4[];
  54460. sideOrientation?: number;
  54461. frontUVs?: Vector4;
  54462. backUVs?: Vector4;
  54463. wrap?: boolean;
  54464. topBaseAt?: number;
  54465. bottomBaseAt?: number;
  54466. updatable?: boolean;
  54467. }, scene?: Nullable<Scene>): Mesh;
  54468. }
  54469. }
  54470. declare module BABYLON {
  54471. /**
  54472. * Single axis scale gizmo
  54473. */
  54474. export class AxisScaleGizmo extends Gizmo {
  54475. /**
  54476. * Drag behavior responsible for the gizmos dragging interactions
  54477. */
  54478. dragBehavior: PointerDragBehavior;
  54479. private _pointerObserver;
  54480. /**
  54481. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  54482. */
  54483. snapDistance: number;
  54484. /**
  54485. * Event that fires each time the gizmo snaps to a new location.
  54486. * * snapDistance is the the change in distance
  54487. */
  54488. onSnapObservable: Observable<{
  54489. snapDistance: number;
  54490. }>;
  54491. /**
  54492. * If the scaling operation should be done on all axis (default: false)
  54493. */
  54494. uniformScaling: boolean;
  54495. /**
  54496. * Custom sensitivity value for the drag strength
  54497. */
  54498. sensitivity: number;
  54499. private _isEnabled;
  54500. private _parent;
  54501. private _gizmoMesh;
  54502. private _coloredMaterial;
  54503. private _hoverMaterial;
  54504. private _disableMaterial;
  54505. private _dragging;
  54506. private _tmpVector;
  54507. private _tmpMatrix;
  54508. private _tmpMatrix2;
  54509. /**
  54510. * Creates an AxisScaleGizmo
  54511. * @param gizmoLayer The utility layer the gizmo will be added to
  54512. * @param dragAxis The axis which the gizmo will be able to scale on
  54513. * @param color The color of the gizmo
  54514. * @param thickness display gizmo axis thickness
  54515. */
  54516. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>, thickness?: number);
  54517. /** Create Geometry for Gizmo */
  54518. private _createGizmoMesh;
  54519. protected _attachedNodeChanged(value: Nullable<Node>): void;
  54520. /**
  54521. * If the gizmo is enabled
  54522. */
  54523. set isEnabled(value: boolean);
  54524. get isEnabled(): boolean;
  54525. /**
  54526. * Disposes of the gizmo
  54527. */
  54528. dispose(): void;
  54529. /**
  54530. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  54531. * @param mesh The mesh to replace the default mesh of the gizmo
  54532. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  54533. */
  54534. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  54535. }
  54536. }
  54537. declare module BABYLON {
  54538. /**
  54539. * Gizmo that enables scaling a mesh along 3 axis
  54540. */
  54541. export class ScaleGizmo extends Gizmo {
  54542. /**
  54543. * Internal gizmo used for interactions on the x axis
  54544. */
  54545. xGizmo: AxisScaleGizmo;
  54546. /**
  54547. * Internal gizmo used for interactions on the y axis
  54548. */
  54549. yGizmo: AxisScaleGizmo;
  54550. /**
  54551. * Internal gizmo used for interactions on the z axis
  54552. */
  54553. zGizmo: AxisScaleGizmo;
  54554. /**
  54555. * Internal gizmo used to scale all axis equally
  54556. */
  54557. uniformScaleGizmo: AxisScaleGizmo;
  54558. private _meshAttached;
  54559. private _nodeAttached;
  54560. private _snapDistance;
  54561. private _uniformScalingMesh;
  54562. private _octahedron;
  54563. private _sensitivity;
  54564. private _coloredMaterial;
  54565. private _hoverMaterial;
  54566. private _disableMaterial;
  54567. private _observables;
  54568. /** Node Caching for quick lookup */
  54569. private _gizmoAxisCache;
  54570. /** Fires an event when any of it's sub gizmos are dragged */
  54571. onDragStartObservable: Observable<unknown>;
  54572. /** Fires an event when any of it's sub gizmos are released from dragging */
  54573. onDragEndObservable: Observable<unknown>;
  54574. get attachedMesh(): Nullable<AbstractMesh>;
  54575. set attachedMesh(mesh: Nullable<AbstractMesh>);
  54576. get attachedNode(): Nullable<Node>;
  54577. set attachedNode(node: Nullable<Node>);
  54578. /**
  54579. * True when the mouse pointer is hovering a gizmo mesh
  54580. */
  54581. get isHovered(): boolean;
  54582. /**
  54583. * Creates a ScaleGizmo
  54584. * @param gizmoLayer The utility layer the gizmo will be added to
  54585. * @param thickness display gizmo axis thickness
  54586. */
  54587. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number, gizmoManager?: GizmoManager);
  54588. /** Create Geometry for Gizmo */
  54589. private _createUniformScaleMesh;
  54590. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  54591. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  54592. /**
  54593. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  54594. */
  54595. set snapDistance(value: number);
  54596. get snapDistance(): number;
  54597. /**
  54598. * Ratio for the scale of the gizmo (Default: 1)
  54599. */
  54600. set scaleRatio(value: number);
  54601. get scaleRatio(): number;
  54602. /**
  54603. * Sensitivity factor for dragging (Default: 1)
  54604. */
  54605. set sensitivity(value: number);
  54606. get sensitivity(): number;
  54607. /**
  54608. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  54609. * @param mesh Axis gizmo mesh
  54610. * @param cache Gizmo axis definition used for reactive gizmo UI
  54611. */
  54612. addToAxisCache(mesh: Mesh, cache: GizmoAxisCache): void;
  54613. /**
  54614. * Disposes of the gizmo
  54615. */
  54616. dispose(): void;
  54617. }
  54618. }
  54619. declare module BABYLON {
  54620. /**
  54621. * Bounding box gizmo
  54622. */
  54623. export class BoundingBoxGizmo extends Gizmo {
  54624. private _lineBoundingBox;
  54625. private _rotateSpheresParent;
  54626. private _scaleBoxesParent;
  54627. private _boundingDimensions;
  54628. private _renderObserver;
  54629. private _pointerObserver;
  54630. private _scaleDragSpeed;
  54631. private _tmpQuaternion;
  54632. private _tmpVector;
  54633. private _tmpRotationMatrix;
  54634. /**
  54635. * 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)
  54636. */
  54637. ignoreChildren: boolean;
  54638. /**
  54639. * 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)
  54640. */
  54641. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  54642. /**
  54643. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  54644. */
  54645. rotationSphereSize: number;
  54646. /**
  54647. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  54648. */
  54649. scaleBoxSize: number;
  54650. /**
  54651. * 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)
  54652. */
  54653. fixedDragMeshScreenSize: boolean;
  54654. /**
  54655. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  54656. */
  54657. fixedDragMeshScreenSizeDistanceFactor: number;
  54658. /**
  54659. * Fired when a rotation sphere or scale box is dragged
  54660. */
  54661. onDragStartObservable: Observable<{}>;
  54662. /**
  54663. * Fired when a scale box is dragged
  54664. */
  54665. onScaleBoxDragObservable: Observable<{}>;
  54666. /**
  54667. * Fired when a scale box drag is ended
  54668. */
  54669. onScaleBoxDragEndObservable: Observable<{}>;
  54670. /**
  54671. * Fired when a rotation sphere is dragged
  54672. */
  54673. onRotationSphereDragObservable: Observable<{}>;
  54674. /**
  54675. * Fired when a rotation sphere drag is ended
  54676. */
  54677. onRotationSphereDragEndObservable: Observable<{}>;
  54678. /**
  54679. * 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)
  54680. */
  54681. scalePivot: Nullable<Vector3>;
  54682. /**
  54683. * Mesh used as a pivot to rotate the attached node
  54684. */
  54685. private _anchorMesh;
  54686. private _existingMeshScale;
  54687. private _dragMesh;
  54688. private pointerDragBehavior;
  54689. private coloredMaterial;
  54690. private hoverColoredMaterial;
  54691. /**
  54692. * Sets the color of the bounding box gizmo
  54693. * @param color the color to set
  54694. */
  54695. setColor(color: Color3): void;
  54696. /**
  54697. * Creates an BoundingBoxGizmo
  54698. * @param gizmoLayer The utility layer the gizmo will be added to
  54699. * @param color The color of the gizmo
  54700. */
  54701. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  54702. protected _attachedNodeChanged(value: Nullable<AbstractMesh>): void;
  54703. private _selectNode;
  54704. /**
  54705. * Updates the bounding box information for the Gizmo
  54706. */
  54707. updateBoundingBox(): void;
  54708. private _updateRotationSpheres;
  54709. private _updateScaleBoxes;
  54710. /**
  54711. * Enables rotation on the specified axis and disables rotation on the others
  54712. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  54713. */
  54714. setEnabledRotationAxis(axis: string): void;
  54715. /**
  54716. * Enables/disables scaling
  54717. * @param enable if scaling should be enabled
  54718. * @param homogeneousScaling defines if scaling should only be homogeneous
  54719. */
  54720. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  54721. private _updateDummy;
  54722. /**
  54723. * Enables a pointer drag behavior on the bounding box of the gizmo
  54724. */
  54725. enableDragBehavior(): void;
  54726. /**
  54727. * Disposes of the gizmo
  54728. */
  54729. dispose(): void;
  54730. /**
  54731. * 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)
  54732. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  54733. * @returns the bounding box mesh with the passed in mesh as a child
  54734. */
  54735. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  54736. /**
  54737. * CustomMeshes are not supported by this gizmo
  54738. * @param mesh The mesh to replace the default mesh of the gizmo
  54739. */
  54740. setCustomMesh(mesh: Mesh): void;
  54741. }
  54742. }
  54743. declare module BABYLON {
  54744. /**
  54745. * Helps setup gizmo's in the scene to rotate/scale/position nodes
  54746. */
  54747. export class GizmoManager implements IDisposable {
  54748. private scene;
  54749. /**
  54750. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  54751. */
  54752. gizmos: {
  54753. positionGizmo: Nullable<PositionGizmo>;
  54754. rotationGizmo: Nullable<RotationGizmo>;
  54755. scaleGizmo: Nullable<ScaleGizmo>;
  54756. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  54757. };
  54758. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  54759. clearGizmoOnEmptyPointerEvent: boolean;
  54760. /** Fires an event when the manager is attached to a mesh */
  54761. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  54762. /** Fires an event when the manager is attached to a node */
  54763. onAttachedToNodeObservable: Observable<Nullable<Node>>;
  54764. private _gizmosEnabled;
  54765. private _pointerObservers;
  54766. private _attachedMesh;
  54767. private _attachedNode;
  54768. private _boundingBoxColor;
  54769. private _defaultUtilityLayer;
  54770. private _defaultKeepDepthUtilityLayer;
  54771. private _thickness;
  54772. /** Node Caching for quick lookup */
  54773. private _gizmoAxisCache;
  54774. /**
  54775. * When bounding box gizmo is enabled, this can be used to track drag/end events
  54776. */
  54777. boundingBoxDragBehavior: SixDofDragBehavior;
  54778. /**
  54779. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  54780. */
  54781. attachableMeshes: Nullable<Array<AbstractMesh>>;
  54782. /**
  54783. * Array of nodes which will have the gizmo attached when a pointer selected them. If null, all nodes are attachable. (Default: null)
  54784. */
  54785. attachableNodes: Nullable<Array<Node>>;
  54786. /**
  54787. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh/attachToNode. (Default: true)
  54788. */
  54789. usePointerToAttachGizmos: boolean;
  54790. /**
  54791. * Utility layer that the bounding box gizmo belongs to
  54792. */
  54793. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  54794. /**
  54795. * Utility layer that all gizmos besides bounding box belong to
  54796. */
  54797. get utilityLayer(): UtilityLayerRenderer;
  54798. /**
  54799. * True when the mouse pointer is hovering a gizmo mesh
  54800. */
  54801. get isHovered(): boolean;
  54802. /**
  54803. * Instatiates a gizmo manager
  54804. * @param scene the scene to overlay the gizmos on top of
  54805. * @param thickness display gizmo axis thickness
  54806. * @param utilityLayer the layer where gizmos are rendered
  54807. * @param keepDepthUtilityLayer the layer where occluded gizmos are rendered
  54808. */
  54809. constructor(scene: Scene, thickness?: number, utilityLayer?: UtilityLayerRenderer, keepDepthUtilityLayer?: UtilityLayerRenderer);
  54810. /**
  54811. * Subscribes to pointer down events, for attaching and detaching mesh
  54812. * @param scene The sceme layer the observer will be added to
  54813. */
  54814. private _attachToMeshPointerObserver;
  54815. /**
  54816. * Attaches a set of gizmos to the specified mesh
  54817. * @param mesh The mesh the gizmo's should be attached to
  54818. */
  54819. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  54820. /**
  54821. * Attaches a set of gizmos to the specified node
  54822. * @param node The node the gizmo's should be attached to
  54823. */
  54824. attachToNode(node: Nullable<Node>): void;
  54825. /**
  54826. * If the position gizmo is enabled
  54827. */
  54828. set positionGizmoEnabled(value: boolean);
  54829. get positionGizmoEnabled(): boolean;
  54830. /**
  54831. * If the rotation gizmo is enabled
  54832. */
  54833. set rotationGizmoEnabled(value: boolean);
  54834. get rotationGizmoEnabled(): boolean;
  54835. /**
  54836. * If the scale gizmo is enabled
  54837. */
  54838. set scaleGizmoEnabled(value: boolean);
  54839. get scaleGizmoEnabled(): boolean;
  54840. /**
  54841. * If the boundingBox gizmo is enabled
  54842. */
  54843. set boundingBoxGizmoEnabled(value: boolean);
  54844. get boundingBoxGizmoEnabled(): boolean;
  54845. /**
  54846. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  54847. * @param gizmoAxisCache Gizmo axis definition used for reactive gizmo UI
  54848. */
  54849. addToAxisCache(gizmoAxisCache: Map<Mesh, GizmoAxisCache>): void;
  54850. /**
  54851. * Disposes of the gizmo manager
  54852. */
  54853. dispose(): void;
  54854. }
  54855. }
  54856. declare module BABYLON {
  54857. /**
  54858. * Gizmo that enables dragging a mesh along 3 axis
  54859. */
  54860. export class PositionGizmo extends Gizmo {
  54861. /**
  54862. * Internal gizmo used for interactions on the x axis
  54863. */
  54864. xGizmo: AxisDragGizmo;
  54865. /**
  54866. * Internal gizmo used for interactions on the y axis
  54867. */
  54868. yGizmo: AxisDragGizmo;
  54869. /**
  54870. * Internal gizmo used for interactions on the z axis
  54871. */
  54872. zGizmo: AxisDragGizmo;
  54873. /**
  54874. * Internal gizmo used for interactions on the yz plane
  54875. */
  54876. xPlaneGizmo: PlaneDragGizmo;
  54877. /**
  54878. * Internal gizmo used for interactions on the xz plane
  54879. */
  54880. yPlaneGizmo: PlaneDragGizmo;
  54881. /**
  54882. * Internal gizmo used for interactions on the xy plane
  54883. */
  54884. zPlaneGizmo: PlaneDragGizmo;
  54885. /**
  54886. * private variables
  54887. */
  54888. private _meshAttached;
  54889. private _nodeAttached;
  54890. private _snapDistance;
  54891. private _observables;
  54892. /** Node Caching for quick lookup */
  54893. private _gizmoAxisCache;
  54894. /** Fires an event when any of it's sub gizmos are dragged */
  54895. onDragStartObservable: Observable<unknown>;
  54896. /** Fires an event when any of it's sub gizmos are released from dragging */
  54897. onDragEndObservable: Observable<unknown>;
  54898. /**
  54899. * If set to true, planar drag is enabled
  54900. */
  54901. private _planarGizmoEnabled;
  54902. get attachedMesh(): Nullable<AbstractMesh>;
  54903. set attachedMesh(mesh: Nullable<AbstractMesh>);
  54904. get attachedNode(): Nullable<Node>;
  54905. set attachedNode(node: Nullable<Node>);
  54906. /**
  54907. * True when the mouse pointer is hovering a gizmo mesh
  54908. */
  54909. get isHovered(): boolean;
  54910. /**
  54911. * Creates a PositionGizmo
  54912. * @param gizmoLayer The utility layer the gizmo will be added to
  54913. @param thickness display gizmo axis thickness
  54914. */
  54915. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number, gizmoManager?: GizmoManager);
  54916. /**
  54917. * If the planar drag gizmo is enabled
  54918. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  54919. */
  54920. set planarGizmoEnabled(value: boolean);
  54921. get planarGizmoEnabled(): boolean;
  54922. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  54923. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  54924. /**
  54925. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  54926. */
  54927. set snapDistance(value: number);
  54928. get snapDistance(): number;
  54929. /**
  54930. * Ratio for the scale of the gizmo (Default: 1)
  54931. */
  54932. set scaleRatio(value: number);
  54933. get scaleRatio(): number;
  54934. /**
  54935. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  54936. * @param mesh Axis gizmo mesh
  54937. * @param cache Gizmo axis definition used for reactive gizmo UI
  54938. */
  54939. addToAxisCache(mesh: Mesh, cache: GizmoAxisCache): void;
  54940. /**
  54941. * Disposes of the gizmo
  54942. */
  54943. dispose(): void;
  54944. /**
  54945. * CustomMeshes are not supported by this gizmo
  54946. * @param mesh The mesh to replace the default mesh of the gizmo
  54947. */
  54948. setCustomMesh(mesh: Mesh): void;
  54949. }
  54950. }
  54951. declare module BABYLON {
  54952. /**
  54953. * Single axis drag gizmo
  54954. */
  54955. export class AxisDragGizmo extends Gizmo {
  54956. /**
  54957. * Drag behavior responsible for the gizmos dragging interactions
  54958. */
  54959. dragBehavior: PointerDragBehavior;
  54960. private _pointerObserver;
  54961. /**
  54962. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  54963. */
  54964. snapDistance: number;
  54965. /**
  54966. * Event that fires each time the gizmo snaps to a new location.
  54967. * * snapDistance is the the change in distance
  54968. */
  54969. onSnapObservable: Observable<{
  54970. snapDistance: number;
  54971. }>;
  54972. private _isEnabled;
  54973. private _parent;
  54974. private _gizmoMesh;
  54975. private _coloredMaterial;
  54976. private _hoverMaterial;
  54977. private _disableMaterial;
  54978. private _dragging;
  54979. /** @hidden */
  54980. static _CreateArrow(scene: Scene, material: StandardMaterial, thickness?: number, isCollider?: boolean): TransformNode;
  54981. /** @hidden */
  54982. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  54983. /**
  54984. * Creates an AxisDragGizmo
  54985. * @param gizmoLayer The utility layer the gizmo will be added to
  54986. * @param dragAxis The axis which the gizmo will be able to drag on
  54987. * @param color The color of the gizmo
  54988. * @param thickness display gizmo axis thickness
  54989. */
  54990. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>, thickness?: number);
  54991. protected _attachedNodeChanged(value: Nullable<Node>): void;
  54992. /**
  54993. * If the gizmo is enabled
  54994. */
  54995. set isEnabled(value: boolean);
  54996. get isEnabled(): boolean;
  54997. /**
  54998. * Disposes of the gizmo
  54999. */
  55000. dispose(): void;
  55001. }
  55002. }
  55003. declare module BABYLON.Debug {
  55004. /**
  55005. * The Axes viewer will show 3 axes in a specific point in space
  55006. */
  55007. export class AxesViewer {
  55008. private _xAxis;
  55009. private _yAxis;
  55010. private _zAxis;
  55011. private _scaleLinesFactor;
  55012. private _instanced;
  55013. /**
  55014. * Gets the hosting scene
  55015. */
  55016. scene: Nullable<Scene>;
  55017. /**
  55018. * Gets or sets a number used to scale line length
  55019. */
  55020. scaleLines: number;
  55021. /** Gets the node hierarchy used to render x-axis */
  55022. get xAxis(): TransformNode;
  55023. /** Gets the node hierarchy used to render y-axis */
  55024. get yAxis(): TransformNode;
  55025. /** Gets the node hierarchy used to render z-axis */
  55026. get zAxis(): TransformNode;
  55027. /**
  55028. * Creates a new AxesViewer
  55029. * @param scene defines the hosting scene
  55030. * @param scaleLines defines a number used to scale line length (1 by default)
  55031. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  55032. * @param xAxis defines the node hierarchy used to render the x-axis
  55033. * @param yAxis defines the node hierarchy used to render the y-axis
  55034. * @param zAxis defines the node hierarchy used to render the z-axis
  55035. */
  55036. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  55037. /**
  55038. * Force the viewer to update
  55039. * @param position defines the position of the viewer
  55040. * @param xaxis defines the x axis of the viewer
  55041. * @param yaxis defines the y axis of the viewer
  55042. * @param zaxis defines the z axis of the viewer
  55043. */
  55044. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  55045. /**
  55046. * Creates an instance of this axes viewer.
  55047. * @returns a new axes viewer with instanced meshes
  55048. */
  55049. createInstance(): AxesViewer;
  55050. /** Releases resources */
  55051. dispose(): void;
  55052. private static _SetRenderingGroupId;
  55053. }
  55054. }
  55055. declare module BABYLON.Debug {
  55056. /**
  55057. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  55058. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  55059. */
  55060. export class BoneAxesViewer extends AxesViewer {
  55061. /**
  55062. * Gets or sets the target mesh where to display the axes viewer
  55063. */
  55064. mesh: Nullable<Mesh>;
  55065. /**
  55066. * Gets or sets the target bone where to display the axes viewer
  55067. */
  55068. bone: Nullable<Bone>;
  55069. /** Gets current position */
  55070. pos: Vector3;
  55071. /** Gets direction of X axis */
  55072. xaxis: Vector3;
  55073. /** Gets direction of Y axis */
  55074. yaxis: Vector3;
  55075. /** Gets direction of Z axis */
  55076. zaxis: Vector3;
  55077. /**
  55078. * Creates a new BoneAxesViewer
  55079. * @param scene defines the hosting scene
  55080. * @param bone defines the target bone
  55081. * @param mesh defines the target mesh
  55082. * @param scaleLines defines a scaling factor for line length (1 by default)
  55083. */
  55084. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  55085. /**
  55086. * Force the viewer to update
  55087. */
  55088. update(): void;
  55089. /** Releases resources */
  55090. dispose(): void;
  55091. }
  55092. }
  55093. declare module BABYLON {
  55094. /**
  55095. * Interface used to define scene explorer extensibility option
  55096. */
  55097. export interface IExplorerExtensibilityOption {
  55098. /**
  55099. * Define the option label
  55100. */
  55101. label: string;
  55102. /**
  55103. * Defines the action to execute on click
  55104. */
  55105. action: (entity: any) => void;
  55106. }
  55107. /**
  55108. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  55109. */
  55110. export interface IExplorerExtensibilityGroup {
  55111. /**
  55112. * Defines a predicate to test if a given type mut be extended
  55113. */
  55114. predicate: (entity: any) => boolean;
  55115. /**
  55116. * Gets the list of options added to a type
  55117. */
  55118. entries: IExplorerExtensibilityOption[];
  55119. }
  55120. /**
  55121. * Interface used to define the options to use to create the Inspector
  55122. */
  55123. export interface IInspectorOptions {
  55124. /**
  55125. * Display in overlay mode (default: false)
  55126. */
  55127. overlay?: boolean;
  55128. /**
  55129. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  55130. */
  55131. globalRoot?: HTMLElement;
  55132. /**
  55133. * Display the Scene explorer
  55134. */
  55135. showExplorer?: boolean;
  55136. /**
  55137. * Display the property inspector
  55138. */
  55139. showInspector?: boolean;
  55140. /**
  55141. * Display in embed mode (both panes on the right)
  55142. */
  55143. embedMode?: boolean;
  55144. /**
  55145. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  55146. */
  55147. handleResize?: boolean;
  55148. /**
  55149. * Allow the panes to popup (default: true)
  55150. */
  55151. enablePopup?: boolean;
  55152. /**
  55153. * Allow the panes to be closed by users (default: true)
  55154. */
  55155. enableClose?: boolean;
  55156. /**
  55157. * Optional list of extensibility entries
  55158. */
  55159. explorerExtensibility?: IExplorerExtensibilityGroup[];
  55160. /**
  55161. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  55162. */
  55163. inspectorURL?: string;
  55164. /**
  55165. * Optional initial tab (default to DebugLayerTab.Properties)
  55166. */
  55167. initialTab?: DebugLayerTab;
  55168. }
  55169. interface Scene {
  55170. /**
  55171. * @hidden
  55172. * Backing field
  55173. */
  55174. _debugLayer: DebugLayer;
  55175. /**
  55176. * Gets the debug layer (aka Inspector) associated with the scene
  55177. * @see https://doc.babylonjs.com/features/playground_debuglayer
  55178. */
  55179. debugLayer: DebugLayer;
  55180. }
  55181. /**
  55182. * Enum of inspector action tab
  55183. */
  55184. export enum DebugLayerTab {
  55185. /**
  55186. * Properties tag (default)
  55187. */
  55188. Properties = 0,
  55189. /**
  55190. * Debug tab
  55191. */
  55192. Debug = 1,
  55193. /**
  55194. * Statistics tab
  55195. */
  55196. Statistics = 2,
  55197. /**
  55198. * Tools tab
  55199. */
  55200. Tools = 3,
  55201. /**
  55202. * Settings tab
  55203. */
  55204. Settings = 4
  55205. }
  55206. /**
  55207. * The debug layer (aka Inspector) is the go to tool in order to better understand
  55208. * what is happening in your scene
  55209. * @see https://doc.babylonjs.com/features/playground_debuglayer
  55210. */
  55211. export class DebugLayer {
  55212. /**
  55213. * Define the url to get the inspector script from.
  55214. * By default it uses the babylonjs CDN.
  55215. * @ignoreNaming
  55216. */
  55217. static InspectorURL: string;
  55218. private _scene;
  55219. private BJSINSPECTOR;
  55220. private _onPropertyChangedObservable?;
  55221. /**
  55222. * Observable triggered when a property is changed through the inspector.
  55223. */
  55224. get onPropertyChangedObservable(): any;
  55225. /**
  55226. * Instantiates a new debug layer.
  55227. * The debug layer (aka Inspector) is the go to tool in order to better understand
  55228. * what is happening in your scene
  55229. * @see https://doc.babylonjs.com/features/playground_debuglayer
  55230. * @param scene Defines the scene to inspect
  55231. */
  55232. constructor(scene: Scene);
  55233. /** Creates the inspector window. */
  55234. private _createInspector;
  55235. /**
  55236. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  55237. * @param entity defines the entity to select
  55238. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  55239. */
  55240. select(entity: any, lineContainerTitles?: string | string[]): void;
  55241. /** Get the inspector from bundle or global */
  55242. private _getGlobalInspector;
  55243. /**
  55244. * Get if the inspector is visible or not.
  55245. * @returns true if visible otherwise, false
  55246. */
  55247. isVisible(): boolean;
  55248. /**
  55249. * Hide the inspector and close its window.
  55250. */
  55251. hide(): void;
  55252. /**
  55253. * Update the scene in the inspector
  55254. */
  55255. setAsActiveScene(): void;
  55256. /**
  55257. * Launch the debugLayer.
  55258. * @param config Define the configuration of the inspector
  55259. * @return a promise fulfilled when the debug layer is visible
  55260. */
  55261. show(config?: IInspectorOptions): Promise<DebugLayer>;
  55262. }
  55263. }
  55264. declare module BABYLON.Debug {
  55265. /**
  55266. * Used to show the physics impostor around the specific mesh
  55267. */
  55268. export class PhysicsViewer {
  55269. /** @hidden */
  55270. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  55271. /** @hidden */
  55272. protected _meshes: Array<Nullable<AbstractMesh>>;
  55273. /** @hidden */
  55274. protected _scene: Nullable<Scene>;
  55275. /** @hidden */
  55276. protected _numMeshes: number;
  55277. /** @hidden */
  55278. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  55279. private _renderFunction;
  55280. private _utilityLayer;
  55281. private _debugBoxMesh;
  55282. private _debugSphereMesh;
  55283. private _debugCylinderMesh;
  55284. private _debugMaterial;
  55285. private _debugMeshMeshes;
  55286. /**
  55287. * Creates a new PhysicsViewer
  55288. * @param scene defines the hosting scene
  55289. */
  55290. constructor(scene: Scene);
  55291. /** @hidden */
  55292. protected _updateDebugMeshes(): void;
  55293. /**
  55294. * Renders a specified physic impostor
  55295. * @param impostor defines the impostor to render
  55296. * @param targetMesh defines the mesh represented by the impostor
  55297. * @returns the new debug mesh used to render the impostor
  55298. */
  55299. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  55300. /**
  55301. * Hides a specified physic impostor
  55302. * @param impostor defines the impostor to hide
  55303. */
  55304. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  55305. private _getDebugMaterial;
  55306. private _getDebugBoxMesh;
  55307. private _getDebugSphereMesh;
  55308. private _getDebugCylinderMesh;
  55309. private _getDebugMeshMesh;
  55310. private _getDebugMesh;
  55311. /** Releases all resources */
  55312. dispose(): void;
  55313. }
  55314. }
  55315. declare module BABYLON {
  55316. /**
  55317. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  55318. * in order to better appreciate the issue one might have.
  55319. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  55320. */
  55321. export class RayHelper {
  55322. /**
  55323. * Defines the ray we are currently tryin to visualize.
  55324. */
  55325. ray: Nullable<Ray>;
  55326. private _renderPoints;
  55327. private _renderLine;
  55328. private _renderFunction;
  55329. private _scene;
  55330. private _onAfterRenderObserver;
  55331. private _onAfterStepObserver;
  55332. private _attachedToMesh;
  55333. private _meshSpaceDirection;
  55334. private _meshSpaceOrigin;
  55335. /**
  55336. * Helper function to create a colored helper in a scene in one line.
  55337. * @param ray Defines the ray we are currently tryin to visualize
  55338. * @param scene Defines the scene the ray is used in
  55339. * @param color Defines the color we want to see the ray in
  55340. * @returns The newly created ray helper.
  55341. */
  55342. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  55343. /**
  55344. * Instantiate a new ray helper.
  55345. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  55346. * in order to better appreciate the issue one might have.
  55347. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  55348. * @param ray Defines the ray we are currently tryin to visualize
  55349. */
  55350. constructor(ray: Ray);
  55351. /**
  55352. * Shows the ray we are willing to debug.
  55353. * @param scene Defines the scene the ray needs to be rendered in
  55354. * @param color Defines the color the ray needs to be rendered in
  55355. */
  55356. show(scene: Scene, color?: Color3): void;
  55357. /**
  55358. * Hides the ray we are debugging.
  55359. */
  55360. hide(): void;
  55361. private _render;
  55362. /**
  55363. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  55364. * @param mesh Defines the mesh we want the helper attached to
  55365. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  55366. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  55367. * @param length Defines the length of the ray
  55368. */
  55369. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  55370. /**
  55371. * Detach the ray helper from the mesh it has previously been attached to.
  55372. */
  55373. detachFromMesh(): void;
  55374. private _updateToMesh;
  55375. /**
  55376. * Dispose the helper and release its associated resources.
  55377. */
  55378. dispose(): void;
  55379. }
  55380. }
  55381. declare module BABYLON {
  55382. /**
  55383. * Defines the options associated with the creation of a SkeletonViewer.
  55384. */
  55385. export interface ISkeletonViewerOptions {
  55386. /** Should the system pause animations before building the Viewer? */
  55387. pauseAnimations: boolean;
  55388. /** Should the system return the skeleton to rest before building? */
  55389. returnToRest: boolean;
  55390. /** public Display Mode of the Viewer */
  55391. displayMode: number;
  55392. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  55393. displayOptions: ISkeletonViewerDisplayOptions;
  55394. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  55395. computeBonesUsingShaders: boolean;
  55396. /** Flag ignore non weighted bones */
  55397. useAllBones: boolean;
  55398. }
  55399. /**
  55400. * Defines how to display the various bone meshes for the viewer.
  55401. */
  55402. export interface ISkeletonViewerDisplayOptions {
  55403. /** How far down to start tapering the bone spurs */
  55404. midStep?: number;
  55405. /** How big is the midStep? */
  55406. midStepFactor?: number;
  55407. /** Base for the Sphere Size */
  55408. sphereBaseSize?: number;
  55409. /** The ratio of the sphere to the longest bone in units */
  55410. sphereScaleUnit?: number;
  55411. /** Ratio for the Sphere Size */
  55412. sphereFactor?: number;
  55413. /** Whether a spur should attach its far end to the child bone position */
  55414. spurFollowsChild?: boolean;
  55415. /** Whether to show local axes or not */
  55416. showLocalAxes?: boolean;
  55417. /** Length of each local axis */
  55418. localAxesSize?: number;
  55419. }
  55420. /**
  55421. * Defines the constructor options for the BoneWeight Shader.
  55422. */
  55423. export interface IBoneWeightShaderOptions {
  55424. /** Skeleton to Map */
  55425. skeleton: Skeleton;
  55426. /** Colors for Uninfluenced bones */
  55427. colorBase?: Color3;
  55428. /** Colors for 0.0-0.25 Weight bones */
  55429. colorZero?: Color3;
  55430. /** Color for 0.25-0.5 Weight Influence */
  55431. colorQuarter?: Color3;
  55432. /** Color for 0.5-0.75 Weight Influence */
  55433. colorHalf?: Color3;
  55434. /** Color for 0.75-1 Weight Influence */
  55435. colorFull?: Color3;
  55436. /** Color for Zero Weight Influence */
  55437. targetBoneIndex?: number;
  55438. }
  55439. /**
  55440. * Simple structure of the gradient steps for the Color Map.
  55441. */
  55442. export interface ISkeletonMapShaderColorMapKnot {
  55443. /** Color of the Knot */
  55444. color: Color3;
  55445. /** Location of the Knot */
  55446. location: number;
  55447. }
  55448. /**
  55449. * Defines the constructor options for the SkeletonMap Shader.
  55450. */
  55451. export interface ISkeletonMapShaderOptions {
  55452. /** Skeleton to Map */
  55453. skeleton: Skeleton;
  55454. /** Array of ColorMapKnots that make the gradient must be ordered with knot[i].location < knot[i+1].location*/
  55455. colorMap?: ISkeletonMapShaderColorMapKnot[];
  55456. }
  55457. }
  55458. declare module BABYLON {
  55459. /**
  55460. * Class containing static functions to help procedurally build meshes
  55461. */
  55462. export class RibbonBuilder {
  55463. /**
  55464. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  55465. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  55466. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  55467. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  55468. * * 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
  55469. * * 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
  55470. * * 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
  55471. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55472. * * 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
  55473. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55474. * * 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
  55475. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  55476. * * 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
  55477. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  55478. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55479. * @param name defines the name of the mesh
  55480. * @param options defines the options used to create the mesh
  55481. * @param scene defines the hosting scene
  55482. * @returns the ribbon mesh
  55483. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  55484. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55485. */
  55486. static CreateRibbon(name: string, options: {
  55487. pathArray: Vector3[][];
  55488. closeArray?: boolean;
  55489. closePath?: boolean;
  55490. offset?: number;
  55491. updatable?: boolean;
  55492. sideOrientation?: number;
  55493. frontUVs?: Vector4;
  55494. backUVs?: Vector4;
  55495. instance?: Mesh;
  55496. invertUV?: boolean;
  55497. uvs?: Vector2[];
  55498. colors?: Color4[];
  55499. }, scene?: Nullable<Scene>): Mesh;
  55500. }
  55501. }
  55502. declare module BABYLON {
  55503. /**
  55504. * Class containing static functions to help procedurally build meshes
  55505. */
  55506. export class ShapeBuilder {
  55507. /**
  55508. * 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.
  55509. * * 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.
  55510. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  55511. * * 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.
  55512. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  55513. * * 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
  55514. * * 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
  55515. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  55516. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55517. * * 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
  55518. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  55519. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55520. * @param name defines the name of the mesh
  55521. * @param options defines the options used to create the mesh
  55522. * @param scene defines the hosting scene
  55523. * @returns the extruded shape mesh
  55524. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55525. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  55526. */
  55527. static ExtrudeShape(name: string, options: {
  55528. shape: Vector3[];
  55529. path: Vector3[];
  55530. scale?: number;
  55531. rotation?: number;
  55532. cap?: number;
  55533. updatable?: boolean;
  55534. sideOrientation?: number;
  55535. frontUVs?: Vector4;
  55536. backUVs?: Vector4;
  55537. instance?: Mesh;
  55538. invertUV?: boolean;
  55539. }, scene?: Nullable<Scene>): Mesh;
  55540. /**
  55541. * Creates an custom extruded shape mesh.
  55542. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  55543. * * 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.
  55544. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  55545. * * 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
  55546. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  55547. * * 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
  55548. * * It must returns a float value that will be the scale value applied to the shape on each path point
  55549. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  55550. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  55551. * * 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
  55552. * * 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
  55553. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  55554. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55555. * * 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
  55556. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55557. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55558. * @param name defines the name of the mesh
  55559. * @param options defines the options used to create the mesh
  55560. * @param scene defines the hosting scene
  55561. * @returns the custom extruded shape mesh
  55562. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  55563. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55564. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  55565. */
  55566. static ExtrudeShapeCustom(name: string, options: {
  55567. shape: Vector3[];
  55568. path: Vector3[];
  55569. scaleFunction?: any;
  55570. rotationFunction?: any;
  55571. ribbonCloseArray?: boolean;
  55572. ribbonClosePath?: boolean;
  55573. cap?: number;
  55574. updatable?: boolean;
  55575. sideOrientation?: number;
  55576. frontUVs?: Vector4;
  55577. backUVs?: Vector4;
  55578. instance?: Mesh;
  55579. invertUV?: boolean;
  55580. }, scene?: Nullable<Scene>): Mesh;
  55581. private static _ExtrudeShapeGeneric;
  55582. }
  55583. }
  55584. declare module BABYLON.Debug {
  55585. /**
  55586. * Class used to render a debug view of a given skeleton
  55587. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  55588. */
  55589. export class SkeletonViewer {
  55590. /** defines the skeleton to render */
  55591. skeleton: Skeleton;
  55592. /** defines the mesh attached to the skeleton */
  55593. mesh: AbstractMesh;
  55594. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  55595. autoUpdateBonesMatrices: boolean;
  55596. /** defines the rendering group id to use with the viewer */
  55597. renderingGroupId: number;
  55598. /** is the options for the viewer */
  55599. options: Partial<ISkeletonViewerOptions>;
  55600. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_LINES */
  55601. static readonly DISPLAY_LINES: number;
  55602. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERES */
  55603. static readonly DISPLAY_SPHERES: number;
  55604. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERE_AND_SPURS */
  55605. static readonly DISPLAY_SPHERE_AND_SPURS: number;
  55606. /** public static method to create a BoneWeight Shader
  55607. * @param options The constructor options
  55608. * @param scene The scene that the shader is scoped to
  55609. * @returns The created ShaderMaterial
  55610. * @see http://www.babylonjs-playground.com/#1BZJVJ#395
  55611. */
  55612. static CreateBoneWeightShader(options: IBoneWeightShaderOptions, scene: Scene): ShaderMaterial;
  55613. /** public static method to create a BoneWeight Shader
  55614. * @param options The constructor options
  55615. * @param scene The scene that the shader is scoped to
  55616. * @returns The created ShaderMaterial
  55617. */
  55618. static CreateSkeletonMapShader(options: ISkeletonMapShaderOptions, scene: Scene): ShaderMaterial;
  55619. /** private static method to create a BoneWeight Shader
  55620. * @param size The size of the buffer to create (usually the bone count)
  55621. * @param colorMap The gradient data to generate
  55622. * @param scene The scene that the shader is scoped to
  55623. * @returns an Array of floats from the color gradient values
  55624. */
  55625. private static _CreateBoneMapColorBuffer;
  55626. /** If SkeletonViewer scene scope. */
  55627. private _scene;
  55628. /** Gets or sets the color used to render the skeleton */
  55629. color: Color3;
  55630. /** Array of the points of the skeleton fo the line view. */
  55631. private _debugLines;
  55632. /** The SkeletonViewers Mesh. */
  55633. private _debugMesh;
  55634. /** The local axes Meshes. */
  55635. private _localAxes;
  55636. /** If SkeletonViewer is enabled. */
  55637. private _isEnabled;
  55638. /** If SkeletonViewer is ready. */
  55639. private _ready;
  55640. /** SkeletonViewer render observable. */
  55641. private _obs;
  55642. /** The Utility Layer to render the gizmos in. */
  55643. private _utilityLayer;
  55644. private _boneIndices;
  55645. /** Gets the Scene. */
  55646. get scene(): Scene;
  55647. /** Gets the utilityLayer. */
  55648. get utilityLayer(): Nullable<UtilityLayerRenderer>;
  55649. /** Checks Ready Status. */
  55650. get isReady(): Boolean;
  55651. /** Sets Ready Status. */
  55652. set ready(value: boolean);
  55653. /** Gets the debugMesh */
  55654. get debugMesh(): Nullable<AbstractMesh> | Nullable<LinesMesh>;
  55655. /** Sets the debugMesh */
  55656. set debugMesh(value: Nullable<AbstractMesh> | Nullable<LinesMesh>);
  55657. /** Gets the displayMode */
  55658. get displayMode(): number;
  55659. /** Sets the displayMode */
  55660. set displayMode(value: number);
  55661. /**
  55662. * Creates a new SkeletonViewer
  55663. * @param skeleton defines the skeleton to render
  55664. * @param mesh defines the mesh attached to the skeleton
  55665. * @param scene defines the hosting scene
  55666. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  55667. * @param renderingGroupId defines the rendering group id to use with the viewer
  55668. * @param options All of the extra constructor options for the SkeletonViewer
  55669. */
  55670. constructor(
  55671. /** defines the skeleton to render */
  55672. skeleton: Skeleton,
  55673. /** defines the mesh attached to the skeleton */
  55674. mesh: AbstractMesh,
  55675. /** The Scene scope*/
  55676. scene: Scene,
  55677. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  55678. autoUpdateBonesMatrices?: boolean,
  55679. /** defines the rendering group id to use with the viewer */
  55680. renderingGroupId?: number,
  55681. /** is the options for the viewer */
  55682. options?: Partial<ISkeletonViewerOptions>);
  55683. /** The Dynamic bindings for the update functions */
  55684. private _bindObs;
  55685. /** Update the viewer to sync with current skeleton state, only used to manually update. */
  55686. update(): void;
  55687. /** Gets or sets a boolean indicating if the viewer is enabled */
  55688. set isEnabled(value: boolean);
  55689. get isEnabled(): boolean;
  55690. private _getBonePosition;
  55691. private _getLinesForBonesWithLength;
  55692. private _getLinesForBonesNoLength;
  55693. /** function to revert the mesh and scene back to the initial state. */
  55694. private _revert;
  55695. /** function to get the absolute bind pose of a bone by accumulating transformations up the bone hierarchy. */
  55696. private _getAbsoluteBindPoseToRef;
  55697. /** function to build and bind sphere joint points and spur bone representations. */
  55698. private _buildSpheresAndSpurs;
  55699. private _buildLocalAxes;
  55700. /** Update the viewer to sync with current skeleton state, only used for the line display. */
  55701. private _displayLinesUpdate;
  55702. /** Changes the displayMode of the skeleton viewer
  55703. * @param mode The displayMode numerical value
  55704. */
  55705. changeDisplayMode(mode: number): void;
  55706. /** Sets a display option of the skeleton viewer
  55707. *
  55708. * | Option | Type | Default | Description |
  55709. * | ---------------- | ------- | ------- | ----------- |
  55710. * | 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`. |
  55711. * | 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`. |
  55712. * | sphereBaseSize | float | 2 | Sphere base size. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  55713. * | 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`. |
  55714. * | spurFollowsChild | boolean | false | Whether a spur should attach its far end to the child bone. |
  55715. * | showLocalAxes | boolean | false | Displays local axes on all bones. |
  55716. * | localAxesSize | float | 0.075 | Determines the length of each local axis. |
  55717. *
  55718. * @param option String of the option name
  55719. * @param value The numerical option value
  55720. */
  55721. changeDisplayOptions(option: string, value: number): void;
  55722. /** Release associated resources */
  55723. dispose(): void;
  55724. }
  55725. }
  55726. declare module BABYLON {
  55727. /**
  55728. * Enum for Device Types
  55729. */
  55730. export enum DeviceType {
  55731. /** Generic */
  55732. Generic = 0,
  55733. /** Keyboard */
  55734. Keyboard = 1,
  55735. /** Mouse */
  55736. Mouse = 2,
  55737. /** Touch Pointers */
  55738. Touch = 3,
  55739. /** PS4 Dual Shock */
  55740. DualShock = 4,
  55741. /** Xbox */
  55742. Xbox = 5,
  55743. /** Switch Controller */
  55744. Switch = 6
  55745. }
  55746. /**
  55747. * Enum for All Pointers (Touch/Mouse)
  55748. */
  55749. export enum PointerInput {
  55750. /** Horizontal Axis */
  55751. Horizontal = 0,
  55752. /** Vertical Axis */
  55753. Vertical = 1,
  55754. /** Left Click or Touch */
  55755. LeftClick = 2,
  55756. /** Middle Click */
  55757. MiddleClick = 3,
  55758. /** Right Click */
  55759. RightClick = 4,
  55760. /** Browser Back */
  55761. BrowserBack = 5,
  55762. /** Browser Forward */
  55763. BrowserForward = 6
  55764. }
  55765. /**
  55766. * Enum for Dual Shock Gamepad
  55767. */
  55768. export enum DualShockInput {
  55769. /** Cross */
  55770. Cross = 0,
  55771. /** Circle */
  55772. Circle = 1,
  55773. /** Square */
  55774. Square = 2,
  55775. /** Triangle */
  55776. Triangle = 3,
  55777. /** L1 */
  55778. L1 = 4,
  55779. /** R1 */
  55780. R1 = 5,
  55781. /** L2 */
  55782. L2 = 6,
  55783. /** R2 */
  55784. R2 = 7,
  55785. /** Share */
  55786. Share = 8,
  55787. /** Options */
  55788. Options = 9,
  55789. /** L3 */
  55790. L3 = 10,
  55791. /** R3 */
  55792. R3 = 11,
  55793. /** DPadUp */
  55794. DPadUp = 12,
  55795. /** DPadDown */
  55796. DPadDown = 13,
  55797. /** DPadLeft */
  55798. DPadLeft = 14,
  55799. /** DRight */
  55800. DPadRight = 15,
  55801. /** Home */
  55802. Home = 16,
  55803. /** TouchPad */
  55804. TouchPad = 17,
  55805. /** LStickXAxis */
  55806. LStickXAxis = 18,
  55807. /** LStickYAxis */
  55808. LStickYAxis = 19,
  55809. /** RStickXAxis */
  55810. RStickXAxis = 20,
  55811. /** RStickYAxis */
  55812. RStickYAxis = 21
  55813. }
  55814. /**
  55815. * Enum for Xbox Gamepad
  55816. */
  55817. export enum XboxInput {
  55818. /** A */
  55819. A = 0,
  55820. /** B */
  55821. B = 1,
  55822. /** X */
  55823. X = 2,
  55824. /** Y */
  55825. Y = 3,
  55826. /** LB */
  55827. LB = 4,
  55828. /** RB */
  55829. RB = 5,
  55830. /** LT */
  55831. LT = 6,
  55832. /** RT */
  55833. RT = 7,
  55834. /** Back */
  55835. Back = 8,
  55836. /** Start */
  55837. Start = 9,
  55838. /** LS */
  55839. LS = 10,
  55840. /** RS */
  55841. RS = 11,
  55842. /** DPadUp */
  55843. DPadUp = 12,
  55844. /** DPadDown */
  55845. DPadDown = 13,
  55846. /** DPadLeft */
  55847. DPadLeft = 14,
  55848. /** DRight */
  55849. DPadRight = 15,
  55850. /** Home */
  55851. Home = 16,
  55852. /** LStickXAxis */
  55853. LStickXAxis = 17,
  55854. /** LStickYAxis */
  55855. LStickYAxis = 18,
  55856. /** RStickXAxis */
  55857. RStickXAxis = 19,
  55858. /** RStickYAxis */
  55859. RStickYAxis = 20
  55860. }
  55861. /**
  55862. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  55863. */
  55864. export enum SwitchInput {
  55865. /** B */
  55866. B = 0,
  55867. /** A */
  55868. A = 1,
  55869. /** Y */
  55870. Y = 2,
  55871. /** X */
  55872. X = 3,
  55873. /** L */
  55874. L = 4,
  55875. /** R */
  55876. R = 5,
  55877. /** ZL */
  55878. ZL = 6,
  55879. /** ZR */
  55880. ZR = 7,
  55881. /** Minus */
  55882. Minus = 8,
  55883. /** Plus */
  55884. Plus = 9,
  55885. /** LS */
  55886. LS = 10,
  55887. /** RS */
  55888. RS = 11,
  55889. /** DPadUp */
  55890. DPadUp = 12,
  55891. /** DPadDown */
  55892. DPadDown = 13,
  55893. /** DPadLeft */
  55894. DPadLeft = 14,
  55895. /** DRight */
  55896. DPadRight = 15,
  55897. /** Home */
  55898. Home = 16,
  55899. /** Capture */
  55900. Capture = 17,
  55901. /** LStickXAxis */
  55902. LStickXAxis = 18,
  55903. /** LStickYAxis */
  55904. LStickYAxis = 19,
  55905. /** RStickXAxis */
  55906. RStickXAxis = 20,
  55907. /** RStickYAxis */
  55908. RStickYAxis = 21
  55909. }
  55910. }
  55911. declare module BABYLON {
  55912. /**
  55913. * This class will take all inputs from Keyboard, Pointer, and
  55914. * any Gamepads and provide a polling system that all devices
  55915. * will use. This class assumes that there will only be one
  55916. * pointer device and one keyboard.
  55917. */
  55918. export class DeviceInputSystem implements IDisposable {
  55919. /**
  55920. * Returns onDeviceConnected callback property
  55921. * @returns Callback with function to execute when a device is connected
  55922. */
  55923. get onDeviceConnected(): (deviceType: DeviceType, deviceSlot: number) => void;
  55924. /**
  55925. * Sets callback function when a device is connected and executes against all connected devices
  55926. * @param callback Function to execute when a device is connected
  55927. */
  55928. set onDeviceConnected(callback: (deviceType: DeviceType, deviceSlot: number) => void);
  55929. /**
  55930. * Callback to be triggered when a device is disconnected
  55931. */
  55932. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  55933. /**
  55934. * Callback to be triggered when event driven input is updated
  55935. */
  55936. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  55937. private _inputs;
  55938. private _gamepads;
  55939. private _keyboardActive;
  55940. private _pointerActive;
  55941. private _elementToAttachTo;
  55942. private _keyboardDownEvent;
  55943. private _keyboardUpEvent;
  55944. private _pointerMoveEvent;
  55945. private _pointerDownEvent;
  55946. private _pointerUpEvent;
  55947. private _gamepadConnectedEvent;
  55948. private _gamepadDisconnectedEvent;
  55949. private _onDeviceConnected;
  55950. private static _MAX_KEYCODES;
  55951. private static _MAX_POINTER_INPUTS;
  55952. private constructor();
  55953. /**
  55954. * Creates a new DeviceInputSystem instance
  55955. * @param engine Engine to pull input element from
  55956. * @returns The new instance
  55957. */
  55958. static Create(engine: Engine): DeviceInputSystem;
  55959. /**
  55960. * Checks for current device input value, given an id and input index
  55961. * @param deviceName Id of connected device
  55962. * @param inputIndex Index of device input
  55963. * @returns Current value of input
  55964. */
  55965. /**
  55966. * Checks for current device input value, given an id and input index. Throws exception if requested device not initialized.
  55967. * @param deviceType Enum specifiying device type
  55968. * @param deviceSlot "Slot" or index that device is referenced in
  55969. * @param inputIndex Id of input to be checked
  55970. * @returns Current value of input
  55971. */
  55972. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): number;
  55973. /**
  55974. * Dispose of all the eventlisteners
  55975. */
  55976. dispose(): void;
  55977. /**
  55978. * Checks for existing connections to devices and register them, if necessary
  55979. * Currently handles gamepads and mouse
  55980. */
  55981. private _checkForConnectedDevices;
  55982. /**
  55983. * Add a gamepad to the DeviceInputSystem
  55984. * @param gamepad A single DOM Gamepad object
  55985. */
  55986. private _addGamePad;
  55987. /**
  55988. * Add pointer device to DeviceInputSystem
  55989. * @param deviceType Type of Pointer to add
  55990. * @param deviceSlot Pointer ID (0 for mouse, pointerId for Touch)
  55991. * @param currentX Current X at point of adding
  55992. * @param currentY Current Y at point of adding
  55993. */
  55994. private _addPointerDevice;
  55995. /**
  55996. * Add device and inputs to device array
  55997. * @param deviceType Enum specifiying device type
  55998. * @param deviceSlot "Slot" or index that device is referenced in
  55999. * @param numberOfInputs Number of input entries to create for given device
  56000. */
  56001. private _registerDevice;
  56002. /**
  56003. * Given a specific device name, remove that device from the device map
  56004. * @param deviceType Enum specifiying device type
  56005. * @param deviceSlot "Slot" or index that device is referenced in
  56006. */
  56007. private _unregisterDevice;
  56008. /**
  56009. * Handle all actions that come from keyboard interaction
  56010. */
  56011. private _handleKeyActions;
  56012. /**
  56013. * Handle all actions that come from pointer interaction
  56014. */
  56015. private _handlePointerActions;
  56016. /**
  56017. * Handle all actions that come from gamepad interaction
  56018. */
  56019. private _handleGamepadActions;
  56020. /**
  56021. * Update all non-event based devices with each frame
  56022. * @param deviceType Enum specifiying device type
  56023. * @param deviceSlot "Slot" or index that device is referenced in
  56024. * @param inputIndex Id of input to be checked
  56025. */
  56026. private _updateDevice;
  56027. /**
  56028. * Gets DeviceType from the device name
  56029. * @param deviceName Name of Device from DeviceInputSystem
  56030. * @returns DeviceType enum value
  56031. */
  56032. private _getGamepadDeviceType;
  56033. }
  56034. }
  56035. declare module BABYLON {
  56036. /**
  56037. * Type to handle enforcement of inputs
  56038. */
  56039. 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;
  56040. }
  56041. declare module BABYLON {
  56042. /**
  56043. * Class that handles all input for a specific device
  56044. */
  56045. export class DeviceSource<T extends DeviceType> {
  56046. /** Type of device */
  56047. readonly deviceType: DeviceType;
  56048. /** "Slot" or index that device is referenced in */
  56049. readonly deviceSlot: number;
  56050. /**
  56051. * Observable to handle device input changes per device
  56052. */
  56053. readonly onInputChangedObservable: Observable<{
  56054. inputIndex: DeviceInput<T>;
  56055. previousState: Nullable<number>;
  56056. currentState: Nullable<number>;
  56057. }>;
  56058. private readonly _deviceInputSystem;
  56059. /**
  56060. * Default Constructor
  56061. * @param deviceInputSystem Reference to DeviceInputSystem
  56062. * @param deviceType Type of device
  56063. * @param deviceSlot "Slot" or index that device is referenced in
  56064. */
  56065. constructor(deviceInputSystem: DeviceInputSystem,
  56066. /** Type of device */
  56067. deviceType: DeviceType,
  56068. /** "Slot" or index that device is referenced in */
  56069. deviceSlot?: number);
  56070. /**
  56071. * Get input for specific input
  56072. * @param inputIndex index of specific input on device
  56073. * @returns Input value from DeviceInputSystem
  56074. */
  56075. getInput(inputIndex: DeviceInput<T>): number;
  56076. }
  56077. /**
  56078. * Class to keep track of devices
  56079. */
  56080. export class DeviceSourceManager implements IDisposable {
  56081. /**
  56082. * Observable to be triggered when after a device is connected, any new observers added will be triggered against already connected devices
  56083. */
  56084. readonly onDeviceConnectedObservable: Observable<DeviceSource<DeviceType>>;
  56085. /**
  56086. * Observable to be triggered when after a device is disconnected
  56087. */
  56088. readonly onDeviceDisconnectedObservable: Observable<DeviceSource<DeviceType>>;
  56089. private readonly _devices;
  56090. private readonly _firstDevice;
  56091. private readonly _deviceInputSystem;
  56092. /**
  56093. * Default Constructor
  56094. * @param engine engine to pull input element from
  56095. */
  56096. constructor(engine: Engine);
  56097. /**
  56098. * Gets a DeviceSource, given a type and slot
  56099. * @param deviceType Enum specifying device type
  56100. * @param deviceSlot "Slot" or index that device is referenced in
  56101. * @returns DeviceSource object
  56102. */
  56103. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  56104. /**
  56105. * Gets an array of DeviceSource objects for a given device type
  56106. * @param deviceType Enum specifying device type
  56107. * @returns Array of DeviceSource objects
  56108. */
  56109. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  56110. /**
  56111. * Returns a read-only list of all available devices
  56112. * @returns Read-only array with active devices
  56113. */
  56114. getDevices(): ReadonlyArray<DeviceSource<DeviceType>>;
  56115. /**
  56116. * Dispose of DeviceInputSystem and other parts
  56117. */
  56118. dispose(): void;
  56119. /**
  56120. * Function to add device name to device list
  56121. * @param deviceType Enum specifying device type
  56122. * @param deviceSlot "Slot" or index that device is referenced in
  56123. */
  56124. private _addDevice;
  56125. /**
  56126. * Function to remove device name to device list
  56127. * @param deviceType Enum specifying device type
  56128. * @param deviceSlot "Slot" or index that device is referenced in
  56129. */
  56130. private _removeDevice;
  56131. /**
  56132. * Updates array storing first connected device of each type
  56133. * @param type Type of Device
  56134. */
  56135. private _updateFirstDevices;
  56136. }
  56137. }
  56138. declare module BABYLON {
  56139. /**
  56140. * Options to create the null engine
  56141. */
  56142. export class NullEngineOptions {
  56143. /**
  56144. * Render width (Default: 512)
  56145. */
  56146. renderWidth: number;
  56147. /**
  56148. * Render height (Default: 256)
  56149. */
  56150. renderHeight: number;
  56151. /**
  56152. * Texture size (Default: 512)
  56153. */
  56154. textureSize: number;
  56155. /**
  56156. * If delta time between frames should be constant
  56157. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  56158. */
  56159. deterministicLockstep: boolean;
  56160. /**
  56161. * Maximum about of steps between frames (Default: 4)
  56162. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  56163. */
  56164. lockstepMaxSteps: number;
  56165. /**
  56166. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  56167. */
  56168. useHighPrecisionMatrix?: boolean;
  56169. }
  56170. /**
  56171. * The null engine class provides support for headless version of babylon.js.
  56172. * This can be used in server side scenario or for testing purposes
  56173. */
  56174. export class NullEngine extends Engine {
  56175. private _options;
  56176. /**
  56177. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  56178. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  56179. * @returns true if engine is in deterministic lock step mode
  56180. */
  56181. isDeterministicLockStep(): boolean;
  56182. /**
  56183. * Gets the max steps when engine is running in deterministic lock step
  56184. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  56185. * @returns the max steps
  56186. */
  56187. getLockstepMaxSteps(): number;
  56188. /**
  56189. * Gets the current hardware scaling level.
  56190. * By default the hardware scaling level is computed from the window device ratio.
  56191. * 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.
  56192. * @returns a number indicating the current hardware scaling level
  56193. */
  56194. getHardwareScalingLevel(): number;
  56195. constructor(options?: NullEngineOptions);
  56196. /**
  56197. * Creates a vertex buffer
  56198. * @param vertices the data for the vertex buffer
  56199. * @returns the new WebGL static buffer
  56200. */
  56201. createVertexBuffer(vertices: FloatArray): DataBuffer;
  56202. /**
  56203. * Creates a new index buffer
  56204. * @param indices defines the content of the index buffer
  56205. * @param updatable defines if the index buffer must be updatable
  56206. * @returns a new webGL buffer
  56207. */
  56208. createIndexBuffer(indices: IndicesArray): DataBuffer;
  56209. /**
  56210. * Clear the current render buffer or the current render target (if any is set up)
  56211. * @param color defines the color to use
  56212. * @param backBuffer defines if the back buffer must be cleared
  56213. * @param depth defines if the depth buffer must be cleared
  56214. * @param stencil defines if the stencil buffer must be cleared
  56215. */
  56216. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  56217. /**
  56218. * Gets the current render width
  56219. * @param useScreen defines if screen size must be used (or the current render target if any)
  56220. * @returns a number defining the current render width
  56221. */
  56222. getRenderWidth(useScreen?: boolean): number;
  56223. /**
  56224. * Gets the current render height
  56225. * @param useScreen defines if screen size must be used (or the current render target if any)
  56226. * @returns a number defining the current render height
  56227. */
  56228. getRenderHeight(useScreen?: boolean): number;
  56229. /**
  56230. * Set the WebGL's viewport
  56231. * @param viewport defines the viewport element to be used
  56232. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  56233. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  56234. */
  56235. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  56236. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  56237. /**
  56238. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  56239. * @param pipelineContext defines the pipeline context to use
  56240. * @param uniformsNames defines the list of uniform names
  56241. * @returns an array of webGL uniform locations
  56242. */
  56243. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  56244. /**
  56245. * Gets the lsit of active attributes for a given webGL program
  56246. * @param pipelineContext defines the pipeline context to use
  56247. * @param attributesNames defines the list of attribute names to get
  56248. * @returns an array of indices indicating the offset of each attribute
  56249. */
  56250. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  56251. /**
  56252. * Binds an effect to the webGL context
  56253. * @param effect defines the effect to bind
  56254. */
  56255. bindSamplers(effect: Effect): void;
  56256. /**
  56257. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  56258. * @param effect defines the effect to activate
  56259. */
  56260. enableEffect(effect: Effect): void;
  56261. /**
  56262. * Set various states to the webGL context
  56263. * @param culling defines backface culling state
  56264. * @param zOffset defines the value to apply to zOffset (0 by default)
  56265. * @param force defines if states must be applied even if cache is up to date
  56266. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  56267. */
  56268. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  56269. /**
  56270. * Set the value of an uniform to an array of int32
  56271. * @param uniform defines the webGL uniform location where to store the value
  56272. * @param array defines the array of int32 to store
  56273. * @returns true if value was set
  56274. */
  56275. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  56276. /**
  56277. * Set the value of an uniform to an array of int32 (stored as vec2)
  56278. * @param uniform defines the webGL uniform location where to store the value
  56279. * @param array defines the array of int32 to store
  56280. * @returns true if value was set
  56281. */
  56282. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  56283. /**
  56284. * Set the value of an uniform to an array of int32 (stored as vec3)
  56285. * @param uniform defines the webGL uniform location where to store the value
  56286. * @param array defines the array of int32 to store
  56287. * @returns true if value was set
  56288. */
  56289. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  56290. /**
  56291. * Set the value of an uniform to an array of int32 (stored as vec4)
  56292. * @param uniform defines the webGL uniform location where to store the value
  56293. * @param array defines the array of int32 to store
  56294. * @returns true if value was set
  56295. */
  56296. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  56297. /**
  56298. * Set the value of an uniform to an array of float32
  56299. * @param uniform defines the webGL uniform location where to store the value
  56300. * @param array defines the array of float32 to store
  56301. * @returns true if value was set
  56302. */
  56303. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  56304. /**
  56305. * Set the value of an uniform to an array of float32 (stored as vec2)
  56306. * @param uniform defines the webGL uniform location where to store the value
  56307. * @param array defines the array of float32 to store
  56308. * @returns true if value was set
  56309. */
  56310. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  56311. /**
  56312. * Set the value of an uniform to an array of float32 (stored as vec3)
  56313. * @param uniform defines the webGL uniform location where to store the value
  56314. * @param array defines the array of float32 to store
  56315. * @returns true if value was set
  56316. */
  56317. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  56318. /**
  56319. * Set the value of an uniform to an array of float32 (stored as vec4)
  56320. * @param uniform defines the webGL uniform location where to store the value
  56321. * @param array defines the array of float32 to store
  56322. * @returns true if value was set
  56323. */
  56324. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  56325. /**
  56326. * Set the value of an uniform to an array of number
  56327. * @param uniform defines the webGL uniform location where to store the value
  56328. * @param array defines the array of number to store
  56329. * @returns true if value was set
  56330. */
  56331. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  56332. /**
  56333. * Set the value of an uniform to an array of number (stored as vec2)
  56334. * @param uniform defines the webGL uniform location where to store the value
  56335. * @param array defines the array of number to store
  56336. * @returns true if value was set
  56337. */
  56338. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  56339. /**
  56340. * Set the value of an uniform to an array of number (stored as vec3)
  56341. * @param uniform defines the webGL uniform location where to store the value
  56342. * @param array defines the array of number to store
  56343. * @returns true if value was set
  56344. */
  56345. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  56346. /**
  56347. * Set the value of an uniform to an array of number (stored as vec4)
  56348. * @param uniform defines the webGL uniform location where to store the value
  56349. * @param array defines the array of number to store
  56350. * @returns true if value was set
  56351. */
  56352. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  56353. /**
  56354. * Set the value of an uniform to an array of float32 (stored as matrices)
  56355. * @param uniform defines the webGL uniform location where to store the value
  56356. * @param matrices defines the array of float32 to store
  56357. * @returns true if value was set
  56358. */
  56359. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  56360. /**
  56361. * Set the value of an uniform to a matrix (3x3)
  56362. * @param uniform defines the webGL uniform location where to store the value
  56363. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  56364. * @returns true if value was set
  56365. */
  56366. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  56367. /**
  56368. * Set the value of an uniform to a matrix (2x2)
  56369. * @param uniform defines the webGL uniform location where to store the value
  56370. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  56371. * @returns true if value was set
  56372. */
  56373. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  56374. /**
  56375. * Set the value of an uniform to a number (float)
  56376. * @param uniform defines the webGL uniform location where to store the value
  56377. * @param value defines the float number to store
  56378. * @returns true if value was set
  56379. */
  56380. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  56381. /**
  56382. * Set the value of an uniform to a vec2
  56383. * @param uniform defines the webGL uniform location where to store the value
  56384. * @param x defines the 1st component of the value
  56385. * @param y defines the 2nd component of the value
  56386. * @returns true if value was set
  56387. */
  56388. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  56389. /**
  56390. * Set the value of an uniform to a vec3
  56391. * @param uniform defines the webGL uniform location where to store the value
  56392. * @param x defines the 1st component of the value
  56393. * @param y defines the 2nd component of the value
  56394. * @param z defines the 3rd component of the value
  56395. * @returns true if value was set
  56396. */
  56397. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  56398. /**
  56399. * Set the value of an uniform to a boolean
  56400. * @param uniform defines the webGL uniform location where to store the value
  56401. * @param bool defines the boolean to store
  56402. * @returns true if value was set
  56403. */
  56404. setBool(uniform: WebGLUniformLocation, bool: number): boolean;
  56405. /**
  56406. * Set the value of an uniform to a vec4
  56407. * @param uniform defines the webGL uniform location where to store the value
  56408. * @param x defines the 1st component of the value
  56409. * @param y defines the 2nd component of the value
  56410. * @param z defines the 3rd component of the value
  56411. * @param w defines the 4th component of the value
  56412. * @returns true if value was set
  56413. */
  56414. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  56415. /**
  56416. * Sets the current alpha mode
  56417. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  56418. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  56419. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  56420. */
  56421. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  56422. /**
  56423. * Bind webGl buffers directly to the webGL context
  56424. * @param vertexBuffers defines the vertex buffer to bind
  56425. * @param indexBuffer defines the index buffer to bind
  56426. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  56427. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  56428. * @param effect defines the effect associated with the vertex buffer
  56429. */
  56430. bindBuffers(vertexBuffers: {
  56431. [key: string]: VertexBuffer;
  56432. }, indexBuffer: DataBuffer, effect: Effect): void;
  56433. /**
  56434. * Force the entire cache to be cleared
  56435. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  56436. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  56437. */
  56438. wipeCaches(bruteForce?: boolean): void;
  56439. /**
  56440. * Send a draw order
  56441. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  56442. * @param indexStart defines the starting index
  56443. * @param indexCount defines the number of index to draw
  56444. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  56445. */
  56446. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  56447. /**
  56448. * Draw a list of indexed primitives
  56449. * @param fillMode defines the primitive to use
  56450. * @param indexStart defines the starting index
  56451. * @param indexCount defines the number of index to draw
  56452. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  56453. */
  56454. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  56455. /**
  56456. * Draw a list of unindexed primitives
  56457. * @param fillMode defines the primitive to use
  56458. * @param verticesStart defines the index of first vertex to draw
  56459. * @param verticesCount defines the count of vertices to draw
  56460. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  56461. */
  56462. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  56463. /** @hidden */
  56464. _createTexture(): WebGLTexture;
  56465. /** @hidden */
  56466. _releaseTexture(texture: InternalTexture): void;
  56467. /**
  56468. * Usually called from Texture.ts.
  56469. * Passed information to create a WebGLTexture
  56470. * @param urlArg defines a value which contains one of the following:
  56471. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  56472. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  56473. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  56474. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  56475. * @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)
  56476. * @param scene needed for loading to the correct scene
  56477. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  56478. * @param onLoad optional callback to be called upon successful completion
  56479. * @param onError optional callback to be called upon failure
  56480. * @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
  56481. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  56482. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  56483. * @param forcedExtension defines the extension to use to pick the right loader
  56484. * @param mimeType defines an optional mime type
  56485. * @returns a InternalTexture for assignment back into BABYLON.Texture
  56486. */
  56487. 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;
  56488. /**
  56489. * Creates a new render target texture
  56490. * @param size defines the size of the texture
  56491. * @param options defines the options used to create the texture
  56492. * @returns a new render target texture stored in an InternalTexture
  56493. */
  56494. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  56495. /**
  56496. * Update the sampling mode of a given texture
  56497. * @param samplingMode defines the required sampling mode
  56498. * @param texture defines the texture to update
  56499. */
  56500. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  56501. /**
  56502. * Binds the frame buffer to the specified texture.
  56503. * @param texture The texture to render to or null for the default canvas
  56504. * @param faceIndex The face of the texture to render to in case of cube texture
  56505. * @param requiredWidth The width of the target to render to
  56506. * @param requiredHeight The height of the target to render to
  56507. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  56508. * @param lodLevel defines le lod level to bind to the frame buffer
  56509. */
  56510. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  56511. /**
  56512. * Unbind the current render target texture from the webGL context
  56513. * @param texture defines the render target texture to unbind
  56514. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  56515. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  56516. */
  56517. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  56518. /**
  56519. * Creates a dynamic vertex buffer
  56520. * @param vertices the data for the dynamic vertex buffer
  56521. * @returns the new WebGL dynamic buffer
  56522. */
  56523. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  56524. /**
  56525. * Update the content of a dynamic texture
  56526. * @param texture defines the texture to update
  56527. * @param canvas defines the canvas containing the source
  56528. * @param invertY defines if data must be stored with Y axis inverted
  56529. * @param premulAlpha defines if alpha is stored as premultiplied
  56530. * @param format defines the format of the data
  56531. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  56532. */
  56533. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  56534. /**
  56535. * Gets a boolean indicating if all created effects are ready
  56536. * @returns true if all effects are ready
  56537. */
  56538. areAllEffectsReady(): boolean;
  56539. /**
  56540. * @hidden
  56541. * Get the current error code of the webGL context
  56542. * @returns the error code
  56543. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  56544. */
  56545. getError(): number;
  56546. /** @hidden */
  56547. _getUnpackAlignement(): number;
  56548. /** @hidden */
  56549. _unpackFlipY(value: boolean): void;
  56550. /**
  56551. * Update a dynamic index buffer
  56552. * @param indexBuffer defines the target index buffer
  56553. * @param indices defines the data to update
  56554. * @param offset defines the offset in the target index buffer where update should start
  56555. */
  56556. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  56557. /**
  56558. * Updates a dynamic vertex buffer.
  56559. * @param vertexBuffer the vertex buffer to update
  56560. * @param vertices the data used to update the vertex buffer
  56561. * @param byteOffset the byte offset of the data (optional)
  56562. * @param byteLength the byte length of the data (optional)
  56563. */
  56564. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  56565. /** @hidden */
  56566. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  56567. /** @hidden */
  56568. _bindTexture(channel: number, texture: InternalTexture): void;
  56569. protected _deleteBuffer(buffer: WebGLBuffer): void;
  56570. /**
  56571. * 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
  56572. */
  56573. releaseEffects(): void;
  56574. displayLoadingUI(): void;
  56575. hideLoadingUI(): void;
  56576. /** @hidden */
  56577. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  56578. /** @hidden */
  56579. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  56580. /** @hidden */
  56581. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  56582. /** @hidden */
  56583. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  56584. }
  56585. }
  56586. declare module BABYLON {
  56587. /**
  56588. * @hidden
  56589. **/
  56590. export class _TimeToken {
  56591. _startTimeQuery: Nullable<WebGLQuery>;
  56592. _endTimeQuery: Nullable<WebGLQuery>;
  56593. _timeElapsedQuery: Nullable<WebGLQuery>;
  56594. _timeElapsedQueryEnded: boolean;
  56595. }
  56596. }
  56597. declare module BABYLON {
  56598. /** @hidden */
  56599. export class _OcclusionDataStorage {
  56600. /** @hidden */
  56601. occlusionInternalRetryCounter: number;
  56602. /** @hidden */
  56603. isOcclusionQueryInProgress: boolean;
  56604. /** @hidden */
  56605. isOccluded: boolean;
  56606. /** @hidden */
  56607. occlusionRetryCount: number;
  56608. /** @hidden */
  56609. occlusionType: number;
  56610. /** @hidden */
  56611. occlusionQueryAlgorithmType: number;
  56612. }
  56613. interface Engine {
  56614. /**
  56615. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  56616. * @return the new query
  56617. */
  56618. createQuery(): WebGLQuery;
  56619. /**
  56620. * Delete and release a webGL query
  56621. * @param query defines the query to delete
  56622. * @return the current engine
  56623. */
  56624. deleteQuery(query: WebGLQuery): Engine;
  56625. /**
  56626. * Check if a given query has resolved and got its value
  56627. * @param query defines the query to check
  56628. * @returns true if the query got its value
  56629. */
  56630. isQueryResultAvailable(query: WebGLQuery): boolean;
  56631. /**
  56632. * Gets the value of a given query
  56633. * @param query defines the query to check
  56634. * @returns the value of the query
  56635. */
  56636. getQueryResult(query: WebGLQuery): number;
  56637. /**
  56638. * Initiates an occlusion query
  56639. * @param algorithmType defines the algorithm to use
  56640. * @param query defines the query to use
  56641. * @returns the current engine
  56642. * @see https://doc.babylonjs.com/features/occlusionquery
  56643. */
  56644. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  56645. /**
  56646. * Ends an occlusion query
  56647. * @see https://doc.babylonjs.com/features/occlusionquery
  56648. * @param algorithmType defines the algorithm to use
  56649. * @returns the current engine
  56650. */
  56651. endOcclusionQuery(algorithmType: number): Engine;
  56652. /**
  56653. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  56654. * Please note that only one query can be issued at a time
  56655. * @returns a time token used to track the time span
  56656. */
  56657. startTimeQuery(): Nullable<_TimeToken>;
  56658. /**
  56659. * Ends a time query
  56660. * @param token defines the token used to measure the time span
  56661. * @returns the time spent (in ns)
  56662. */
  56663. endTimeQuery(token: _TimeToken): int;
  56664. /** @hidden */
  56665. _currentNonTimestampToken: Nullable<_TimeToken>;
  56666. /** @hidden */
  56667. _createTimeQuery(): WebGLQuery;
  56668. /** @hidden */
  56669. _deleteTimeQuery(query: WebGLQuery): void;
  56670. /** @hidden */
  56671. _getGlAlgorithmType(algorithmType: number): number;
  56672. /** @hidden */
  56673. _getTimeQueryResult(query: WebGLQuery): any;
  56674. /** @hidden */
  56675. _getTimeQueryAvailability(query: WebGLQuery): any;
  56676. }
  56677. interface AbstractMesh {
  56678. /**
  56679. * Backing filed
  56680. * @hidden
  56681. */
  56682. __occlusionDataStorage: _OcclusionDataStorage;
  56683. /**
  56684. * Access property
  56685. * @hidden
  56686. */
  56687. _occlusionDataStorage: _OcclusionDataStorage;
  56688. /**
  56689. * 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.
  56690. * The default value is -1 which means don't break the query and wait till the result
  56691. * @see https://doc.babylonjs.com/features/occlusionquery
  56692. */
  56693. occlusionRetryCount: number;
  56694. /**
  56695. * 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:
  56696. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  56697. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  56698. * * 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.
  56699. * @see https://doc.babylonjs.com/features/occlusionquery
  56700. */
  56701. occlusionType: number;
  56702. /**
  56703. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  56704. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  56705. * * 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.
  56706. * @see https://doc.babylonjs.com/features/occlusionquery
  56707. */
  56708. occlusionQueryAlgorithmType: number;
  56709. /**
  56710. * 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
  56711. * @see https://doc.babylonjs.com/features/occlusionquery
  56712. */
  56713. isOccluded: boolean;
  56714. /**
  56715. * Flag to check the progress status of the query
  56716. * @see https://doc.babylonjs.com/features/occlusionquery
  56717. */
  56718. isOcclusionQueryInProgress: boolean;
  56719. }
  56720. }
  56721. declare module BABYLON {
  56722. /** @hidden */
  56723. export var _forceTransformFeedbackToBundle: boolean;
  56724. interface Engine {
  56725. /**
  56726. * Creates a webGL transform feedback object
  56727. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  56728. * @returns the webGL transform feedback object
  56729. */
  56730. createTransformFeedback(): WebGLTransformFeedback;
  56731. /**
  56732. * Delete a webGL transform feedback object
  56733. * @param value defines the webGL transform feedback object to delete
  56734. */
  56735. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  56736. /**
  56737. * Bind a webGL transform feedback object to the webgl context
  56738. * @param value defines the webGL transform feedback object to bind
  56739. */
  56740. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  56741. /**
  56742. * Begins a transform feedback operation
  56743. * @param usePoints defines if points or triangles must be used
  56744. */
  56745. beginTransformFeedback(usePoints: boolean): void;
  56746. /**
  56747. * Ends a transform feedback operation
  56748. */
  56749. endTransformFeedback(): void;
  56750. /**
  56751. * Specify the varyings to use with transform feedback
  56752. * @param program defines the associated webGL program
  56753. * @param value defines the list of strings representing the varying names
  56754. */
  56755. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  56756. /**
  56757. * Bind a webGL buffer for a transform feedback operation
  56758. * @param value defines the webGL buffer to bind
  56759. */
  56760. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  56761. }
  56762. }
  56763. declare module BABYLON {
  56764. /**
  56765. * Class used to define an additional view for the engine
  56766. * @see https://doc.babylonjs.com/how_to/multi_canvases
  56767. */
  56768. export class EngineView {
  56769. /** Defines the canvas where to render the view */
  56770. target: HTMLCanvasElement;
  56771. /** Defines an optional camera used to render the view (will use active camera else) */
  56772. camera?: Camera;
  56773. }
  56774. interface Engine {
  56775. /**
  56776. * Gets or sets the HTML element to use for attaching events
  56777. */
  56778. inputElement: Nullable<HTMLElement>;
  56779. /**
  56780. * Gets the current engine view
  56781. * @see https://doc.babylonjs.com/how_to/multi_canvases
  56782. */
  56783. activeView: Nullable<EngineView>;
  56784. /** Gets or sets the list of views */
  56785. views: EngineView[];
  56786. /**
  56787. * Register a new child canvas
  56788. * @param canvas defines the canvas to register
  56789. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  56790. * @returns the associated view
  56791. */
  56792. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  56793. /**
  56794. * Remove a registered child canvas
  56795. * @param canvas defines the canvas to remove
  56796. * @returns the current engine
  56797. */
  56798. unRegisterView(canvas: HTMLCanvasElement): Engine;
  56799. }
  56800. }
  56801. declare module BABYLON {
  56802. interface Engine {
  56803. /** @hidden */
  56804. _excludedCompressedTextures: string[];
  56805. /** @hidden */
  56806. _textureFormatInUse: string;
  56807. /**
  56808. * Gets the list of texture formats supported
  56809. */
  56810. readonly texturesSupported: Array<string>;
  56811. /**
  56812. * Gets the texture format in use
  56813. */
  56814. readonly textureFormatInUse: Nullable<string>;
  56815. /**
  56816. * Set the compressed texture extensions or file names to skip.
  56817. *
  56818. * @param skippedFiles defines the list of those texture files you want to skip
  56819. * Example: [".dds", ".env", "myfile.png"]
  56820. */
  56821. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  56822. /**
  56823. * Set the compressed texture format to use, based on the formats you have, and the formats
  56824. * supported by the hardware / browser.
  56825. *
  56826. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  56827. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  56828. * to API arguments needed to compressed textures. This puts the burden on the container
  56829. * generator to house the arcane code for determining these for current & future formats.
  56830. *
  56831. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  56832. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  56833. *
  56834. * Note: The result of this call is not taken into account when a texture is base64.
  56835. *
  56836. * @param formatsAvailable defines the list of those format families you have created
  56837. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  56838. *
  56839. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  56840. * @returns The extension selected.
  56841. */
  56842. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  56843. }
  56844. }
  56845. declare module BABYLON {
  56846. /** @hidden */
  56847. export var rgbdEncodePixelShader: {
  56848. name: string;
  56849. shader: string;
  56850. };
  56851. }
  56852. declare module BABYLON {
  56853. /**
  56854. * Raw texture data and descriptor sufficient for WebGL texture upload
  56855. */
  56856. export interface EnvironmentTextureInfo {
  56857. /**
  56858. * Version of the environment map
  56859. */
  56860. version: number;
  56861. /**
  56862. * Width of image
  56863. */
  56864. width: number;
  56865. /**
  56866. * Irradiance information stored in the file.
  56867. */
  56868. irradiance: any;
  56869. /**
  56870. * Specular information stored in the file.
  56871. */
  56872. specular: any;
  56873. }
  56874. /**
  56875. * Defines One Image in the file. It requires only the position in the file
  56876. * as well as the length.
  56877. */
  56878. interface BufferImageData {
  56879. /**
  56880. * Length of the image data.
  56881. */
  56882. length: number;
  56883. /**
  56884. * Position of the data from the null terminator delimiting the end of the JSON.
  56885. */
  56886. position: number;
  56887. }
  56888. /**
  56889. * Defines the specular data enclosed in the file.
  56890. * This corresponds to the version 1 of the data.
  56891. */
  56892. export interface EnvironmentTextureSpecularInfoV1 {
  56893. /**
  56894. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  56895. */
  56896. specularDataPosition?: number;
  56897. /**
  56898. * This contains all the images data needed to reconstruct the cubemap.
  56899. */
  56900. mipmaps: Array<BufferImageData>;
  56901. /**
  56902. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  56903. */
  56904. lodGenerationScale: number;
  56905. }
  56906. /**
  56907. * Sets of helpers addressing the serialization and deserialization of environment texture
  56908. * stored in a BabylonJS env file.
  56909. * Those files are usually stored as .env files.
  56910. */
  56911. export class EnvironmentTextureTools {
  56912. /**
  56913. * Magic number identifying the env file.
  56914. */
  56915. private static _MagicBytes;
  56916. /**
  56917. * Gets the environment info from an env file.
  56918. * @param data The array buffer containing the .env bytes.
  56919. * @returns the environment file info (the json header) if successfully parsed.
  56920. */
  56921. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  56922. /**
  56923. * Creates an environment texture from a loaded cube texture.
  56924. * @param texture defines the cube texture to convert in env file
  56925. * @return a promise containing the environment data if succesfull.
  56926. */
  56927. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  56928. /**
  56929. * Creates a JSON representation of the spherical data.
  56930. * @param texture defines the texture containing the polynomials
  56931. * @return the JSON representation of the spherical info
  56932. */
  56933. private static _CreateEnvTextureIrradiance;
  56934. /**
  56935. * Creates the ArrayBufferViews used for initializing environment texture image data.
  56936. * @param data the image data
  56937. * @param info parameters that determine what views will be created for accessing the underlying buffer
  56938. * @return the views described by info providing access to the underlying buffer
  56939. */
  56940. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  56941. /**
  56942. * Uploads the texture info contained in the env file to the GPU.
  56943. * @param texture defines the internal texture to upload to
  56944. * @param data defines the data to load
  56945. * @param info defines the texture info retrieved through the GetEnvInfo method
  56946. * @returns a promise
  56947. */
  56948. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  56949. private static _OnImageReadyAsync;
  56950. /**
  56951. * Uploads the levels of image data to the GPU.
  56952. * @param texture defines the internal texture to upload to
  56953. * @param imageData defines the array buffer views of image data [mipmap][face]
  56954. * @returns a promise
  56955. */
  56956. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  56957. /**
  56958. * Uploads spherical polynomials information to the texture.
  56959. * @param texture defines the texture we are trying to upload the information to
  56960. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  56961. */
  56962. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  56963. /** @hidden */
  56964. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  56965. }
  56966. }
  56967. declare module BABYLON {
  56968. /**
  56969. * Class used to inline functions in shader code
  56970. */
  56971. export class ShaderCodeInliner {
  56972. private static readonly _RegexpFindFunctionNameAndType;
  56973. private _sourceCode;
  56974. private _functionDescr;
  56975. private _numMaxIterations;
  56976. /** Gets or sets the token used to mark the functions to inline */
  56977. inlineToken: string;
  56978. /** Gets or sets the debug mode */
  56979. debug: boolean;
  56980. /** Gets the code after the inlining process */
  56981. get code(): string;
  56982. /**
  56983. * Initializes the inliner
  56984. * @param sourceCode shader code source to inline
  56985. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  56986. */
  56987. constructor(sourceCode: string, numMaxIterations?: number);
  56988. /**
  56989. * Start the processing of the shader code
  56990. */
  56991. processCode(): void;
  56992. private _collectFunctions;
  56993. private _processInlining;
  56994. private _extractBetweenMarkers;
  56995. private _skipWhitespaces;
  56996. private _removeComments;
  56997. private _replaceFunctionCallsByCode;
  56998. private _findBackward;
  56999. private _escapeRegExp;
  57000. private _replaceNames;
  57001. }
  57002. }
  57003. declare module BABYLON {
  57004. /**
  57005. * Container for accessors for natively-stored mesh data buffers.
  57006. */
  57007. class NativeDataBuffer extends DataBuffer {
  57008. /**
  57009. * Accessor value used to identify/retrieve a natively-stored index buffer.
  57010. */
  57011. nativeIndexBuffer?: any;
  57012. /**
  57013. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  57014. */
  57015. nativeVertexBuffer?: any;
  57016. }
  57017. /** @hidden */
  57018. class NativeTexture extends InternalTexture {
  57019. getInternalTexture(): InternalTexture;
  57020. getViewCount(): number;
  57021. }
  57022. /** @hidden */
  57023. export class NativeEngine extends Engine {
  57024. private readonly _native;
  57025. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  57026. private readonly INVALID_HANDLE;
  57027. private _boundBuffersVertexArray;
  57028. private _currentDepthTest;
  57029. getHardwareScalingLevel(): number;
  57030. constructor();
  57031. dispose(): void;
  57032. /**
  57033. * Can be used to override the current requestAnimationFrame requester.
  57034. * @hidden
  57035. */
  57036. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  57037. /**
  57038. * Override default engine behavior.
  57039. * @param color
  57040. * @param backBuffer
  57041. * @param depth
  57042. * @param stencil
  57043. */
  57044. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  57045. /**
  57046. * Gets host document
  57047. * @returns the host document object
  57048. */
  57049. getHostDocument(): Nullable<Document>;
  57050. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  57051. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  57052. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  57053. protected _recordVertexArrayObject(vertexArray: any, vertexBuffers: {
  57054. [key: string]: VertexBuffer;
  57055. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  57056. bindBuffers(vertexBuffers: {
  57057. [key: string]: VertexBuffer;
  57058. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  57059. recordVertexArrayObject(vertexBuffers: {
  57060. [key: string]: VertexBuffer;
  57061. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  57062. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  57063. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  57064. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  57065. /**
  57066. * Draw a list of indexed primitives
  57067. * @param fillMode defines the primitive to use
  57068. * @param indexStart defines the starting index
  57069. * @param indexCount defines the number of index to draw
  57070. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  57071. */
  57072. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  57073. /**
  57074. * Draw a list of unindexed primitives
  57075. * @param fillMode defines the primitive to use
  57076. * @param verticesStart defines the index of first vertex to draw
  57077. * @param verticesCount defines the count of vertices to draw
  57078. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  57079. */
  57080. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  57081. createPipelineContext(): IPipelineContext;
  57082. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  57083. /** @hidden */
  57084. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  57085. /** @hidden */
  57086. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  57087. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  57088. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  57089. protected _setProgram(program: WebGLProgram): void;
  57090. _releaseEffect(effect: Effect): void;
  57091. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  57092. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  57093. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  57094. bindSamplers(effect: Effect): void;
  57095. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  57096. getRenderWidth(useScreen?: boolean): number;
  57097. getRenderHeight(useScreen?: boolean): number;
  57098. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  57099. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  57100. /**
  57101. * Set the z offset to apply to current rendering
  57102. * @param value defines the offset to apply
  57103. */
  57104. setZOffset(value: number): void;
  57105. /**
  57106. * Gets the current value of the zOffset
  57107. * @returns the current zOffset state
  57108. */
  57109. getZOffset(): number;
  57110. /**
  57111. * Enable or disable depth buffering
  57112. * @param enable defines the state to set
  57113. */
  57114. setDepthBuffer(enable: boolean): void;
  57115. /**
  57116. * Gets a boolean indicating if depth writing is enabled
  57117. * @returns the current depth writing state
  57118. */
  57119. getDepthWrite(): boolean;
  57120. setDepthFunctionToGreater(): void;
  57121. setDepthFunctionToGreaterOrEqual(): void;
  57122. setDepthFunctionToLess(): void;
  57123. setDepthFunctionToLessOrEqual(): void;
  57124. /**
  57125. * Enable or disable depth writing
  57126. * @param enable defines the state to set
  57127. */
  57128. setDepthWrite(enable: boolean): void;
  57129. /**
  57130. * Enable or disable color writing
  57131. * @param enable defines the state to set
  57132. */
  57133. setColorWrite(enable: boolean): void;
  57134. /**
  57135. * Gets a boolean indicating if color writing is enabled
  57136. * @returns the current color writing state
  57137. */
  57138. getColorWrite(): boolean;
  57139. /**
  57140. * Sets alpha constants used by some alpha blending modes
  57141. * @param r defines the red component
  57142. * @param g defines the green component
  57143. * @param b defines the blue component
  57144. * @param a defines the alpha component
  57145. */
  57146. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  57147. /**
  57148. * Sets the current alpha mode
  57149. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  57150. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  57151. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  57152. */
  57153. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  57154. /**
  57155. * Gets the current alpha mode
  57156. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  57157. * @returns the current alpha mode
  57158. */
  57159. getAlphaMode(): number;
  57160. setInt(uniform: WebGLUniformLocation, int: number): boolean;
  57161. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  57162. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  57163. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  57164. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  57165. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  57166. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  57167. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  57168. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  57169. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  57170. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  57171. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  57172. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  57173. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  57174. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  57175. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  57176. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  57177. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  57178. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  57179. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  57180. setColor3(uniform: WebGLUniformLocation, color3: Color3): boolean;
  57181. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): boolean;
  57182. wipeCaches(bruteForce?: boolean): void;
  57183. _createTexture(): WebGLTexture;
  57184. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  57185. /**
  57186. * Update the content of a dynamic texture
  57187. * @param texture defines the texture to update
  57188. * @param canvas defines the canvas containing the source
  57189. * @param invertY defines if data must be stored with Y axis inverted
  57190. * @param premulAlpha defines if alpha is stored as premultiplied
  57191. * @param format defines the format of the data
  57192. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  57193. */
  57194. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  57195. /**
  57196. * Usually called from Texture.ts.
  57197. * Passed information to create a WebGLTexture
  57198. * @param url defines a value which contains one of the following:
  57199. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  57200. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  57201. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  57202. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  57203. * @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)
  57204. * @param scene needed for loading to the correct scene
  57205. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  57206. * @param onLoad optional callback to be called upon successful completion
  57207. * @param onError optional callback to be called upon failure
  57208. * @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
  57209. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  57210. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  57211. * @param forcedExtension defines the extension to use to pick the right loader
  57212. * @param mimeType defines an optional mime type
  57213. * @param loaderOptions options to be passed to the loader
  57214. * @returns a InternalTexture for assignment back into BABYLON.Texture
  57215. */
  57216. 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;
  57217. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): NativeTexture;
  57218. _releaseFramebufferObjects(texture: InternalTexture): void;
  57219. /**
  57220. * Creates a cube texture
  57221. * @param rootUrl defines the url where the files to load is located
  57222. * @param scene defines the current scene
  57223. * @param files defines the list of files to load (1 per face)
  57224. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  57225. * @param onLoad defines an optional callback raised when the texture is loaded
  57226. * @param onError defines an optional callback raised if there is an issue to load the texture
  57227. * @param format defines the format of the data
  57228. * @param forcedExtension defines the extension to use to pick the right loader
  57229. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  57230. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  57231. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  57232. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  57233. * @returns the cube texture as an InternalTexture
  57234. */
  57235. 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;
  57236. createRenderTargetTexture(size: number | {
  57237. width: number;
  57238. height: number;
  57239. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  57240. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  57241. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  57242. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  57243. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  57244. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  57245. /**
  57246. * Updates a dynamic vertex buffer.
  57247. * @param vertexBuffer the vertex buffer to update
  57248. * @param data the data used to update the vertex buffer
  57249. * @param byteOffset the byte offset of the data (optional)
  57250. * @param byteLength the byte length of the data (optional)
  57251. */
  57252. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  57253. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  57254. private _updateAnisotropicLevel;
  57255. private _getAddressMode;
  57256. /** @hidden */
  57257. _bindTexture(channel: number, texture: InternalTexture): void;
  57258. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  57259. releaseEffects(): void;
  57260. /** @hidden */
  57261. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  57262. /** @hidden */
  57263. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  57264. /** @hidden */
  57265. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  57266. /** @hidden */
  57267. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  57268. private _getNativeSamplingMode;
  57269. private _getNativeTextureFormat;
  57270. private _getNativeAlphaMode;
  57271. private _getNativeAttribType;
  57272. }
  57273. }
  57274. declare module BABYLON {
  57275. /**
  57276. * Gather the list of clipboard event types as constants.
  57277. */
  57278. export class ClipboardEventTypes {
  57279. /**
  57280. * The clipboard event is fired when a copy command is active (pressed).
  57281. */
  57282. static readonly COPY: number;
  57283. /**
  57284. * The clipboard event is fired when a cut command is active (pressed).
  57285. */
  57286. static readonly CUT: number;
  57287. /**
  57288. * The clipboard event is fired when a paste command is active (pressed).
  57289. */
  57290. static readonly PASTE: number;
  57291. }
  57292. /**
  57293. * This class is used to store clipboard related info for the onClipboardObservable event.
  57294. */
  57295. export class ClipboardInfo {
  57296. /**
  57297. * Defines the type of event (BABYLON.ClipboardEventTypes)
  57298. */
  57299. type: number;
  57300. /**
  57301. * Defines the related dom event
  57302. */
  57303. event: ClipboardEvent;
  57304. /**
  57305. *Creates an instance of ClipboardInfo.
  57306. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  57307. * @param event Defines the related dom event
  57308. */
  57309. constructor(
  57310. /**
  57311. * Defines the type of event (BABYLON.ClipboardEventTypes)
  57312. */
  57313. type: number,
  57314. /**
  57315. * Defines the related dom event
  57316. */
  57317. event: ClipboardEvent);
  57318. /**
  57319. * Get the clipboard event's type from the keycode.
  57320. * @param keyCode Defines the keyCode for the current keyboard event.
  57321. * @return {number}
  57322. */
  57323. static GetTypeFromCharacter(keyCode: number): number;
  57324. }
  57325. }
  57326. declare module BABYLON {
  57327. /**
  57328. * Google Daydream controller
  57329. */
  57330. export class DaydreamController extends WebVRController {
  57331. /**
  57332. * Base Url for the controller model.
  57333. */
  57334. static MODEL_BASE_URL: string;
  57335. /**
  57336. * File name for the controller model.
  57337. */
  57338. static MODEL_FILENAME: string;
  57339. /**
  57340. * Gamepad Id prefix used to identify Daydream Controller.
  57341. */
  57342. static readonly GAMEPAD_ID_PREFIX: string;
  57343. /**
  57344. * Creates a new DaydreamController from a gamepad
  57345. * @param vrGamepad the gamepad that the controller should be created from
  57346. */
  57347. constructor(vrGamepad: any);
  57348. /**
  57349. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  57350. * @param scene scene in which to add meshes
  57351. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  57352. */
  57353. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  57354. /**
  57355. * Called once for each button that changed state since the last frame
  57356. * @param buttonIdx Which button index changed
  57357. * @param state New state of the button
  57358. * @param changes Which properties on the state changed since last frame
  57359. */
  57360. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  57361. }
  57362. }
  57363. declare module BABYLON {
  57364. /**
  57365. * Gear VR Controller
  57366. */
  57367. export class GearVRController extends WebVRController {
  57368. /**
  57369. * Base Url for the controller model.
  57370. */
  57371. static MODEL_BASE_URL: string;
  57372. /**
  57373. * File name for the controller model.
  57374. */
  57375. static MODEL_FILENAME: string;
  57376. /**
  57377. * Gamepad Id prefix used to identify this controller.
  57378. */
  57379. static readonly GAMEPAD_ID_PREFIX: string;
  57380. private readonly _buttonIndexToObservableNameMap;
  57381. /**
  57382. * Creates a new GearVRController from a gamepad
  57383. * @param vrGamepad the gamepad that the controller should be created from
  57384. */
  57385. constructor(vrGamepad: any);
  57386. /**
  57387. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  57388. * @param scene scene in which to add meshes
  57389. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  57390. */
  57391. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  57392. /**
  57393. * Called once for each button that changed state since the last frame
  57394. * @param buttonIdx Which button index changed
  57395. * @param state New state of the button
  57396. * @param changes Which properties on the state changed since last frame
  57397. */
  57398. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  57399. }
  57400. }
  57401. declare module BABYLON {
  57402. /**
  57403. * Generic Controller
  57404. */
  57405. export class GenericController extends WebVRController {
  57406. /**
  57407. * Base Url for the controller model.
  57408. */
  57409. static readonly MODEL_BASE_URL: string;
  57410. /**
  57411. * File name for the controller model.
  57412. */
  57413. static readonly MODEL_FILENAME: string;
  57414. /**
  57415. * Creates a new GenericController from a gamepad
  57416. * @param vrGamepad the gamepad that the controller should be created from
  57417. */
  57418. constructor(vrGamepad: any);
  57419. /**
  57420. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  57421. * @param scene scene in which to add meshes
  57422. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  57423. */
  57424. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  57425. /**
  57426. * Called once for each button that changed state since the last frame
  57427. * @param buttonIdx Which button index changed
  57428. * @param state New state of the button
  57429. * @param changes Which properties on the state changed since last frame
  57430. */
  57431. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  57432. }
  57433. }
  57434. declare module BABYLON {
  57435. /**
  57436. * Oculus Touch Controller
  57437. */
  57438. export class OculusTouchController extends WebVRController {
  57439. /**
  57440. * Base Url for the controller model.
  57441. */
  57442. static MODEL_BASE_URL: string;
  57443. /**
  57444. * File name for the left controller model.
  57445. */
  57446. static MODEL_LEFT_FILENAME: string;
  57447. /**
  57448. * File name for the right controller model.
  57449. */
  57450. static MODEL_RIGHT_FILENAME: string;
  57451. /**
  57452. * Base Url for the Quest controller model.
  57453. */
  57454. static QUEST_MODEL_BASE_URL: string;
  57455. /**
  57456. * @hidden
  57457. * If the controllers are running on a device that needs the updated Quest controller models
  57458. */
  57459. static _IsQuest: boolean;
  57460. /**
  57461. * Fired when the secondary trigger on this controller is modified
  57462. */
  57463. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  57464. /**
  57465. * Fired when the thumb rest on this controller is modified
  57466. */
  57467. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  57468. /**
  57469. * Creates a new OculusTouchController from a gamepad
  57470. * @param vrGamepad the gamepad that the controller should be created from
  57471. */
  57472. constructor(vrGamepad: any);
  57473. /**
  57474. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  57475. * @param scene scene in which to add meshes
  57476. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  57477. */
  57478. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  57479. /**
  57480. * Fired when the A button on this controller is modified
  57481. */
  57482. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  57483. /**
  57484. * Fired when the B button on this controller is modified
  57485. */
  57486. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  57487. /**
  57488. * Fired when the X button on this controller is modified
  57489. */
  57490. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  57491. /**
  57492. * Fired when the Y button on this controller is modified
  57493. */
  57494. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  57495. /**
  57496. * Called once for each button that changed state since the last frame
  57497. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  57498. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  57499. * 2) secondary trigger (same)
  57500. * 3) A (right) X (left), touch, pressed = value
  57501. * 4) B / Y
  57502. * 5) thumb rest
  57503. * @param buttonIdx Which button index changed
  57504. * @param state New state of the button
  57505. * @param changes Which properties on the state changed since last frame
  57506. */
  57507. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  57508. }
  57509. }
  57510. declare module BABYLON {
  57511. /**
  57512. * Vive Controller
  57513. */
  57514. export class ViveController extends WebVRController {
  57515. /**
  57516. * Base Url for the controller model.
  57517. */
  57518. static MODEL_BASE_URL: string;
  57519. /**
  57520. * File name for the controller model.
  57521. */
  57522. static MODEL_FILENAME: string;
  57523. /**
  57524. * Creates a new ViveController from a gamepad
  57525. * @param vrGamepad the gamepad that the controller should be created from
  57526. */
  57527. constructor(vrGamepad: any);
  57528. /**
  57529. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  57530. * @param scene scene in which to add meshes
  57531. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  57532. */
  57533. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  57534. /**
  57535. * Fired when the left button on this controller is modified
  57536. */
  57537. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  57538. /**
  57539. * Fired when the right button on this controller is modified
  57540. */
  57541. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  57542. /**
  57543. * Fired when the menu button on this controller is modified
  57544. */
  57545. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  57546. /**
  57547. * Called once for each button that changed state since the last frame
  57548. * Vive mapping:
  57549. * 0: touchpad
  57550. * 1: trigger
  57551. * 2: left AND right buttons
  57552. * 3: menu button
  57553. * @param buttonIdx Which button index changed
  57554. * @param state New state of the button
  57555. * @param changes Which properties on the state changed since last frame
  57556. */
  57557. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  57558. }
  57559. }
  57560. declare module BABYLON {
  57561. /**
  57562. * Defines the WindowsMotionController object that the state of the windows motion controller
  57563. */
  57564. export class WindowsMotionController extends WebVRController {
  57565. /**
  57566. * The base url used to load the left and right controller models
  57567. */
  57568. static MODEL_BASE_URL: string;
  57569. /**
  57570. * The name of the left controller model file
  57571. */
  57572. static MODEL_LEFT_FILENAME: string;
  57573. /**
  57574. * The name of the right controller model file
  57575. */
  57576. static MODEL_RIGHT_FILENAME: string;
  57577. /**
  57578. * The controller name prefix for this controller type
  57579. */
  57580. static readonly GAMEPAD_ID_PREFIX: string;
  57581. /**
  57582. * The controller id pattern for this controller type
  57583. */
  57584. private static readonly GAMEPAD_ID_PATTERN;
  57585. private _loadedMeshInfo;
  57586. protected readonly _mapping: {
  57587. buttons: string[];
  57588. buttonMeshNames: {
  57589. trigger: string;
  57590. menu: string;
  57591. grip: string;
  57592. thumbstick: string;
  57593. trackpad: string;
  57594. };
  57595. buttonObservableNames: {
  57596. trigger: string;
  57597. menu: string;
  57598. grip: string;
  57599. thumbstick: string;
  57600. trackpad: string;
  57601. };
  57602. axisMeshNames: string[];
  57603. pointingPoseMeshName: string;
  57604. };
  57605. /**
  57606. * Fired when the trackpad on this controller is clicked
  57607. */
  57608. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  57609. /**
  57610. * Fired when the trackpad on this controller is modified
  57611. */
  57612. onTrackpadValuesChangedObservable: Observable<StickValues>;
  57613. /**
  57614. * The current x and y values of this controller's trackpad
  57615. */
  57616. trackpad: StickValues;
  57617. /**
  57618. * Creates a new WindowsMotionController from a gamepad
  57619. * @param vrGamepad the gamepad that the controller should be created from
  57620. */
  57621. constructor(vrGamepad: any);
  57622. /**
  57623. * Fired when the trigger on this controller is modified
  57624. */
  57625. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  57626. /**
  57627. * Fired when the menu button on this controller is modified
  57628. */
  57629. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  57630. /**
  57631. * Fired when the grip button on this controller is modified
  57632. */
  57633. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  57634. /**
  57635. * Fired when the thumbstick button on this controller is modified
  57636. */
  57637. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  57638. /**
  57639. * Fired when the touchpad button on this controller is modified
  57640. */
  57641. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  57642. /**
  57643. * Fired when the touchpad values on this controller are modified
  57644. */
  57645. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  57646. protected _updateTrackpad(): void;
  57647. /**
  57648. * Called once per frame by the engine.
  57649. */
  57650. update(): void;
  57651. /**
  57652. * Called once for each button that changed state since the last frame
  57653. * @param buttonIdx Which button index changed
  57654. * @param state New state of the button
  57655. * @param changes Which properties on the state changed since last frame
  57656. */
  57657. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  57658. /**
  57659. * Moves the buttons on the controller mesh based on their current state
  57660. * @param buttonName the name of the button to move
  57661. * @param buttonValue the value of the button which determines the buttons new position
  57662. */
  57663. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  57664. /**
  57665. * Moves the axis on the controller mesh based on its current state
  57666. * @param axis the index of the axis
  57667. * @param axisValue the value of the axis which determines the meshes new position
  57668. * @hidden
  57669. */
  57670. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  57671. /**
  57672. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  57673. * @param scene scene in which to add meshes
  57674. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  57675. */
  57676. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  57677. /**
  57678. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  57679. * can be transformed by button presses and axes values, based on this._mapping.
  57680. *
  57681. * @param scene scene in which the meshes exist
  57682. * @param meshes list of meshes that make up the controller model to process
  57683. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  57684. */
  57685. private processModel;
  57686. private createMeshInfo;
  57687. /**
  57688. * Gets the ray of the controller in the direction the controller is pointing
  57689. * @param length the length the resulting ray should be
  57690. * @returns a ray in the direction the controller is pointing
  57691. */
  57692. getForwardRay(length?: number): Ray;
  57693. /**
  57694. * Disposes of the controller
  57695. */
  57696. dispose(): void;
  57697. }
  57698. /**
  57699. * This class represents a new windows motion controller in XR.
  57700. */
  57701. export class XRWindowsMotionController extends WindowsMotionController {
  57702. /**
  57703. * Changing the original WIndowsMotionController mapping to fir the new mapping
  57704. */
  57705. protected readonly _mapping: {
  57706. buttons: string[];
  57707. buttonMeshNames: {
  57708. trigger: string;
  57709. menu: string;
  57710. grip: string;
  57711. thumbstick: string;
  57712. trackpad: string;
  57713. };
  57714. buttonObservableNames: {
  57715. trigger: string;
  57716. menu: string;
  57717. grip: string;
  57718. thumbstick: string;
  57719. trackpad: string;
  57720. };
  57721. axisMeshNames: string[];
  57722. pointingPoseMeshName: string;
  57723. };
  57724. /**
  57725. * Construct a new XR-Based windows motion controller
  57726. *
  57727. * @param gamepadInfo the gamepad object from the browser
  57728. */
  57729. constructor(gamepadInfo: any);
  57730. /**
  57731. * holds the thumbstick values (X,Y)
  57732. */
  57733. thumbstickValues: StickValues;
  57734. /**
  57735. * Fired when the thumbstick on this controller is clicked
  57736. */
  57737. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  57738. /**
  57739. * Fired when the thumbstick on this controller is modified
  57740. */
  57741. onThumbstickValuesChangedObservable: Observable<StickValues>;
  57742. /**
  57743. * Fired when the touchpad button on this controller is modified
  57744. */
  57745. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  57746. /**
  57747. * Fired when the touchpad values on this controller are modified
  57748. */
  57749. onTrackpadValuesChangedObservable: Observable<StickValues>;
  57750. /**
  57751. * Fired when the thumbstick button on this controller is modified
  57752. * here to prevent breaking changes
  57753. */
  57754. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  57755. /**
  57756. * updating the thumbstick(!) and not the trackpad.
  57757. * This is named this way due to the difference between WebVR and XR and to avoid
  57758. * changing the parent class.
  57759. */
  57760. protected _updateTrackpad(): void;
  57761. /**
  57762. * Disposes the class with joy
  57763. */
  57764. dispose(): void;
  57765. }
  57766. }
  57767. declare module BABYLON {
  57768. /**
  57769. * A directional light is defined by a direction (what a surprise!).
  57770. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  57771. * 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.
  57772. * Documentation: https://doc.babylonjs.com/babylon101/lights
  57773. */
  57774. export class DirectionalLight extends ShadowLight {
  57775. private _shadowFrustumSize;
  57776. /**
  57777. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  57778. */
  57779. get shadowFrustumSize(): number;
  57780. /**
  57781. * Specifies a fix frustum size for the shadow generation.
  57782. */
  57783. set shadowFrustumSize(value: number);
  57784. private _shadowOrthoScale;
  57785. /**
  57786. * Gets the shadow projection scale against the optimal computed one.
  57787. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  57788. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  57789. */
  57790. get shadowOrthoScale(): number;
  57791. /**
  57792. * Sets the shadow projection scale against the optimal computed one.
  57793. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  57794. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  57795. */
  57796. set shadowOrthoScale(value: number);
  57797. /**
  57798. * Automatically compute the projection matrix to best fit (including all the casters)
  57799. * on each frame.
  57800. */
  57801. autoUpdateExtends: boolean;
  57802. /**
  57803. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  57804. * on each frame. autoUpdateExtends must be set to true for this to work
  57805. */
  57806. autoCalcShadowZBounds: boolean;
  57807. private _orthoLeft;
  57808. private _orthoRight;
  57809. private _orthoTop;
  57810. private _orthoBottom;
  57811. /**
  57812. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  57813. * The directional light is emitted from everywhere in the given direction.
  57814. * It can cast shadows.
  57815. * Documentation : https://doc.babylonjs.com/babylon101/lights
  57816. * @param name The friendly name of the light
  57817. * @param direction The direction of the light
  57818. * @param scene The scene the light belongs to
  57819. */
  57820. constructor(name: string, direction: Vector3, scene: Scene);
  57821. /**
  57822. * Returns the string "DirectionalLight".
  57823. * @return The class name
  57824. */
  57825. getClassName(): string;
  57826. /**
  57827. * Returns the integer 1.
  57828. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  57829. */
  57830. getTypeID(): number;
  57831. /**
  57832. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  57833. * Returns the DirectionalLight Shadow projection matrix.
  57834. */
  57835. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  57836. /**
  57837. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  57838. * Returns the DirectionalLight Shadow projection matrix.
  57839. */
  57840. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  57841. /**
  57842. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  57843. * Returns the DirectionalLight Shadow projection matrix.
  57844. */
  57845. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  57846. protected _buildUniformLayout(): void;
  57847. /**
  57848. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  57849. * @param effect The effect to update
  57850. * @param lightIndex The index of the light in the effect to update
  57851. * @returns The directional light
  57852. */
  57853. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  57854. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  57855. /**
  57856. * Gets the minZ used for shadow according to both the scene and the light.
  57857. *
  57858. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  57859. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  57860. * @param activeCamera The camera we are returning the min for
  57861. * @returns the depth min z
  57862. */
  57863. getDepthMinZ(activeCamera: Camera): number;
  57864. /**
  57865. * Gets the maxZ used for shadow according to both the scene and the light.
  57866. *
  57867. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  57868. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  57869. * @param activeCamera The camera we are returning the max for
  57870. * @returns the depth max z
  57871. */
  57872. getDepthMaxZ(activeCamera: Camera): number;
  57873. /**
  57874. * Prepares the list of defines specific to the light type.
  57875. * @param defines the list of defines
  57876. * @param lightIndex defines the index of the light for the effect
  57877. */
  57878. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  57879. }
  57880. }
  57881. declare module BABYLON {
  57882. /**
  57883. * Class containing static functions to help procedurally build meshes
  57884. */
  57885. export class HemisphereBuilder {
  57886. /**
  57887. * Creates a hemisphere mesh
  57888. * @param name defines the name of the mesh
  57889. * @param options defines the options used to create the mesh
  57890. * @param scene defines the hosting scene
  57891. * @returns the hemisphere mesh
  57892. */
  57893. static CreateHemisphere(name: string, options: {
  57894. segments?: number;
  57895. diameter?: number;
  57896. sideOrientation?: number;
  57897. }, scene: any): Mesh;
  57898. }
  57899. }
  57900. declare module BABYLON {
  57901. /**
  57902. * A spot light is defined by a position, a direction, an angle, and an exponent.
  57903. * These values define a cone of light starting from the position, emitting toward the direction.
  57904. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  57905. * and the exponent defines the speed of the decay of the light with distance (reach).
  57906. * Documentation: https://doc.babylonjs.com/babylon101/lights
  57907. */
  57908. export class SpotLight extends ShadowLight {
  57909. private _angle;
  57910. private _innerAngle;
  57911. private _cosHalfAngle;
  57912. private _lightAngleScale;
  57913. private _lightAngleOffset;
  57914. /**
  57915. * Gets the cone angle of the spot light in Radians.
  57916. */
  57917. get angle(): number;
  57918. /**
  57919. * Sets the cone angle of the spot light in Radians.
  57920. */
  57921. set angle(value: number);
  57922. /**
  57923. * Only used in gltf falloff mode, this defines the angle where
  57924. * the directional falloff will start before cutting at angle which could be seen
  57925. * as outer angle.
  57926. */
  57927. get innerAngle(): number;
  57928. /**
  57929. * Only used in gltf falloff mode, this defines the angle where
  57930. * the directional falloff will start before cutting at angle which could be seen
  57931. * as outer angle.
  57932. */
  57933. set innerAngle(value: number);
  57934. private _shadowAngleScale;
  57935. /**
  57936. * Allows scaling the angle of the light for shadow generation only.
  57937. */
  57938. get shadowAngleScale(): number;
  57939. /**
  57940. * Allows scaling the angle of the light for shadow generation only.
  57941. */
  57942. set shadowAngleScale(value: number);
  57943. /**
  57944. * The light decay speed with the distance from the emission spot.
  57945. */
  57946. exponent: number;
  57947. private _projectionTextureMatrix;
  57948. /**
  57949. * Allows reading the projecton texture
  57950. */
  57951. get projectionTextureMatrix(): Matrix;
  57952. protected _projectionTextureLightNear: number;
  57953. /**
  57954. * Gets the near clip of the Spotlight for texture projection.
  57955. */
  57956. get projectionTextureLightNear(): number;
  57957. /**
  57958. * Sets the near clip of the Spotlight for texture projection.
  57959. */
  57960. set projectionTextureLightNear(value: number);
  57961. protected _projectionTextureLightFar: number;
  57962. /**
  57963. * Gets the far clip of the Spotlight for texture projection.
  57964. */
  57965. get projectionTextureLightFar(): number;
  57966. /**
  57967. * Sets the far clip of the Spotlight for texture projection.
  57968. */
  57969. set projectionTextureLightFar(value: number);
  57970. protected _projectionTextureUpDirection: Vector3;
  57971. /**
  57972. * Gets the Up vector of the Spotlight for texture projection.
  57973. */
  57974. get projectionTextureUpDirection(): Vector3;
  57975. /**
  57976. * Sets the Up vector of the Spotlight for texture projection.
  57977. */
  57978. set projectionTextureUpDirection(value: Vector3);
  57979. private _projectionTexture;
  57980. /**
  57981. * Gets the projection texture of the light.
  57982. */
  57983. get projectionTexture(): Nullable<BaseTexture>;
  57984. /**
  57985. * Sets the projection texture of the light.
  57986. */
  57987. set projectionTexture(value: Nullable<BaseTexture>);
  57988. private static _IsProceduralTexture;
  57989. private static _IsTexture;
  57990. private _projectionTextureViewLightDirty;
  57991. private _projectionTextureProjectionLightDirty;
  57992. private _projectionTextureDirty;
  57993. private _projectionTextureViewTargetVector;
  57994. private _projectionTextureViewLightMatrix;
  57995. private _projectionTextureProjectionLightMatrix;
  57996. private _projectionTextureScalingMatrix;
  57997. /**
  57998. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  57999. * It can cast shadows.
  58000. * Documentation : https://doc.babylonjs.com/babylon101/lights
  58001. * @param name The light friendly name
  58002. * @param position The position of the spot light in the scene
  58003. * @param direction The direction of the light in the scene
  58004. * @param angle The cone angle of the light in Radians
  58005. * @param exponent The light decay speed with the distance from the emission spot
  58006. * @param scene The scene the lights belongs to
  58007. */
  58008. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  58009. /**
  58010. * Returns the string "SpotLight".
  58011. * @returns the class name
  58012. */
  58013. getClassName(): string;
  58014. /**
  58015. * Returns the integer 2.
  58016. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  58017. */
  58018. getTypeID(): number;
  58019. /**
  58020. * Overrides the direction setter to recompute the projection texture view light Matrix.
  58021. */
  58022. protected _setDirection(value: Vector3): void;
  58023. /**
  58024. * Overrides the position setter to recompute the projection texture view light Matrix.
  58025. */
  58026. protected _setPosition(value: Vector3): void;
  58027. /**
  58028. * 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.
  58029. * Returns the SpotLight.
  58030. */
  58031. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  58032. protected _computeProjectionTextureViewLightMatrix(): void;
  58033. protected _computeProjectionTextureProjectionLightMatrix(): void;
  58034. /**
  58035. * Main function for light texture projection matrix computing.
  58036. */
  58037. protected _computeProjectionTextureMatrix(): void;
  58038. protected _buildUniformLayout(): void;
  58039. private _computeAngleValues;
  58040. /**
  58041. * Sets the passed Effect "effect" with the Light textures.
  58042. * @param effect The effect to update
  58043. * @param lightIndex The index of the light in the effect to update
  58044. * @returns The light
  58045. */
  58046. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  58047. /**
  58048. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  58049. * @param effect The effect to update
  58050. * @param lightIndex The index of the light in the effect to update
  58051. * @returns The spot light
  58052. */
  58053. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  58054. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  58055. /**
  58056. * Disposes the light and the associated resources.
  58057. */
  58058. dispose(): void;
  58059. /**
  58060. * Prepares the list of defines specific to the light type.
  58061. * @param defines the list of defines
  58062. * @param lightIndex defines the index of the light for the effect
  58063. */
  58064. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  58065. }
  58066. }
  58067. declare module BABYLON {
  58068. /**
  58069. * Gizmo that enables viewing a light
  58070. */
  58071. export class LightGizmo extends Gizmo {
  58072. private _lightMesh;
  58073. private _material;
  58074. private _cachedPosition;
  58075. private _cachedForward;
  58076. private _attachedMeshParent;
  58077. private _pointerObserver;
  58078. /**
  58079. * Event that fires each time the gizmo is clicked
  58080. */
  58081. onClickedObservable: Observable<Light>;
  58082. /**
  58083. * Creates a LightGizmo
  58084. * @param gizmoLayer The utility layer the gizmo will be added to
  58085. */
  58086. constructor(gizmoLayer?: UtilityLayerRenderer);
  58087. private _light;
  58088. /**
  58089. * The light that the gizmo is attached to
  58090. */
  58091. set light(light: Nullable<Light>);
  58092. get light(): Nullable<Light>;
  58093. /**
  58094. * Gets the material used to render the light gizmo
  58095. */
  58096. get material(): StandardMaterial;
  58097. /**
  58098. * @hidden
  58099. * Updates the gizmo to match the attached mesh's position/rotation
  58100. */
  58101. protected _update(): void;
  58102. private static _Scale;
  58103. /**
  58104. * Creates the lines for a light mesh
  58105. */
  58106. private static _CreateLightLines;
  58107. /**
  58108. * Disposes of the light gizmo
  58109. */
  58110. dispose(): void;
  58111. private static _CreateHemisphericLightMesh;
  58112. private static _CreatePointLightMesh;
  58113. private static _CreateSpotLightMesh;
  58114. private static _CreateDirectionalLightMesh;
  58115. }
  58116. }
  58117. declare module BABYLON {
  58118. /**
  58119. * Gizmo that enables viewing a camera
  58120. */
  58121. export class CameraGizmo extends Gizmo {
  58122. private _cameraMesh;
  58123. private _cameraLinesMesh;
  58124. private _material;
  58125. private _pointerObserver;
  58126. /**
  58127. * Event that fires each time the gizmo is clicked
  58128. */
  58129. onClickedObservable: Observable<Camera>;
  58130. /**
  58131. * Creates a CameraGizmo
  58132. * @param gizmoLayer The utility layer the gizmo will be added to
  58133. */
  58134. constructor(gizmoLayer?: UtilityLayerRenderer);
  58135. private _camera;
  58136. /** Gets or sets a boolean indicating if frustum lines must be rendered (true by default)) */
  58137. get displayFrustum(): boolean;
  58138. set displayFrustum(value: boolean);
  58139. /**
  58140. * The camera that the gizmo is attached to
  58141. */
  58142. set camera(camera: Nullable<Camera>);
  58143. get camera(): Nullable<Camera>;
  58144. /**
  58145. * Gets the material used to render the camera gizmo
  58146. */
  58147. get material(): StandardMaterial;
  58148. /**
  58149. * @hidden
  58150. * Updates the gizmo to match the attached mesh's position/rotation
  58151. */
  58152. protected _update(): void;
  58153. private static _Scale;
  58154. private _invProjection;
  58155. /**
  58156. * Disposes of the camera gizmo
  58157. */
  58158. dispose(): void;
  58159. private static _CreateCameraMesh;
  58160. private static _CreateCameraFrustum;
  58161. }
  58162. }
  58163. declare module BABYLON {
  58164. /** @hidden */
  58165. export var backgroundFragmentDeclaration: {
  58166. name: string;
  58167. shader: string;
  58168. };
  58169. }
  58170. declare module BABYLON {
  58171. /** @hidden */
  58172. export var backgroundUboDeclaration: {
  58173. name: string;
  58174. shader: string;
  58175. };
  58176. }
  58177. declare module BABYLON {
  58178. /** @hidden */
  58179. export var backgroundPixelShader: {
  58180. name: string;
  58181. shader: string;
  58182. };
  58183. }
  58184. declare module BABYLON {
  58185. /** @hidden */
  58186. export var backgroundVertexDeclaration: {
  58187. name: string;
  58188. shader: string;
  58189. };
  58190. }
  58191. declare module BABYLON {
  58192. /** @hidden */
  58193. export var backgroundVertexShader: {
  58194. name: string;
  58195. shader: string;
  58196. };
  58197. }
  58198. declare module BABYLON {
  58199. /**
  58200. * Background material used to create an efficient environement around your scene.
  58201. */
  58202. export class BackgroundMaterial extends PushMaterial {
  58203. /**
  58204. * Standard reflectance value at parallel view angle.
  58205. */
  58206. static StandardReflectance0: number;
  58207. /**
  58208. * Standard reflectance value at grazing angle.
  58209. */
  58210. static StandardReflectance90: number;
  58211. protected _primaryColor: Color3;
  58212. /**
  58213. * Key light Color (multiply against the environement texture)
  58214. */
  58215. primaryColor: Color3;
  58216. protected __perceptualColor: Nullable<Color3>;
  58217. /**
  58218. * Experimental Internal Use Only.
  58219. *
  58220. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  58221. * This acts as a helper to set the primary color to a more "human friendly" value.
  58222. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  58223. * output color as close as possible from the chosen value.
  58224. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  58225. * part of lighting setup.)
  58226. */
  58227. get _perceptualColor(): Nullable<Color3>;
  58228. set _perceptualColor(value: Nullable<Color3>);
  58229. protected _primaryColorShadowLevel: float;
  58230. /**
  58231. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  58232. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  58233. */
  58234. get primaryColorShadowLevel(): float;
  58235. set primaryColorShadowLevel(value: float);
  58236. protected _primaryColorHighlightLevel: float;
  58237. /**
  58238. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  58239. * The primary color is used at the level chosen to define what the white area would look.
  58240. */
  58241. get primaryColorHighlightLevel(): float;
  58242. set primaryColorHighlightLevel(value: float);
  58243. protected _reflectionTexture: Nullable<BaseTexture>;
  58244. /**
  58245. * Reflection Texture used in the material.
  58246. * Should be author in a specific way for the best result (refer to the documentation).
  58247. */
  58248. reflectionTexture: Nullable<BaseTexture>;
  58249. protected _reflectionBlur: float;
  58250. /**
  58251. * Reflection Texture level of blur.
  58252. *
  58253. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  58254. * texture twice.
  58255. */
  58256. reflectionBlur: float;
  58257. protected _diffuseTexture: Nullable<BaseTexture>;
  58258. /**
  58259. * Diffuse Texture used in the material.
  58260. * Should be author in a specific way for the best result (refer to the documentation).
  58261. */
  58262. diffuseTexture: Nullable<BaseTexture>;
  58263. protected _shadowLights: Nullable<IShadowLight[]>;
  58264. /**
  58265. * Specify the list of lights casting shadow on the material.
  58266. * All scene shadow lights will be included if null.
  58267. */
  58268. shadowLights: Nullable<IShadowLight[]>;
  58269. protected _shadowLevel: float;
  58270. /**
  58271. * Helps adjusting the shadow to a softer level if required.
  58272. * 0 means black shadows and 1 means no shadows.
  58273. */
  58274. shadowLevel: float;
  58275. protected _sceneCenter: Vector3;
  58276. /**
  58277. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  58278. * It is usually zero but might be interesting to modify according to your setup.
  58279. */
  58280. sceneCenter: Vector3;
  58281. protected _opacityFresnel: boolean;
  58282. /**
  58283. * This helps specifying that the material is falling off to the sky box at grazing angle.
  58284. * This helps ensuring a nice transition when the camera goes under the ground.
  58285. */
  58286. opacityFresnel: boolean;
  58287. protected _reflectionFresnel: boolean;
  58288. /**
  58289. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  58290. * This helps adding a mirror texture on the ground.
  58291. */
  58292. reflectionFresnel: boolean;
  58293. protected _reflectionFalloffDistance: number;
  58294. /**
  58295. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  58296. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  58297. */
  58298. reflectionFalloffDistance: number;
  58299. protected _reflectionAmount: number;
  58300. /**
  58301. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  58302. */
  58303. reflectionAmount: number;
  58304. protected _reflectionReflectance0: number;
  58305. /**
  58306. * This specifies the weight of the reflection at grazing angle.
  58307. */
  58308. reflectionReflectance0: number;
  58309. protected _reflectionReflectance90: number;
  58310. /**
  58311. * This specifies the weight of the reflection at a perpendicular point of view.
  58312. */
  58313. reflectionReflectance90: number;
  58314. /**
  58315. * Sets the reflection reflectance fresnel values according to the default standard
  58316. * empirically know to work well :-)
  58317. */
  58318. set reflectionStandardFresnelWeight(value: number);
  58319. protected _useRGBColor: boolean;
  58320. /**
  58321. * Helps to directly use the maps channels instead of their level.
  58322. */
  58323. useRGBColor: boolean;
  58324. protected _enableNoise: boolean;
  58325. /**
  58326. * This helps reducing the banding effect that could occur on the background.
  58327. */
  58328. enableNoise: boolean;
  58329. /**
  58330. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  58331. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  58332. * Recommended to be keep at 1.0 except for special cases.
  58333. */
  58334. get fovMultiplier(): number;
  58335. set fovMultiplier(value: number);
  58336. private _fovMultiplier;
  58337. /**
  58338. * Enable the FOV adjustment feature controlled by fovMultiplier.
  58339. */
  58340. useEquirectangularFOV: boolean;
  58341. private _maxSimultaneousLights;
  58342. /**
  58343. * Number of Simultaneous lights allowed on the material.
  58344. */
  58345. maxSimultaneousLights: int;
  58346. private _shadowOnly;
  58347. /**
  58348. * Make the material only render shadows
  58349. */
  58350. shadowOnly: boolean;
  58351. /**
  58352. * Default configuration related to image processing available in the Background Material.
  58353. */
  58354. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  58355. /**
  58356. * Keep track of the image processing observer to allow dispose and replace.
  58357. */
  58358. private _imageProcessingObserver;
  58359. /**
  58360. * Attaches a new image processing configuration to the PBR Material.
  58361. * @param configuration (if null the scene configuration will be use)
  58362. */
  58363. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  58364. /**
  58365. * Gets the image processing configuration used either in this material.
  58366. */
  58367. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  58368. /**
  58369. * Sets the Default image processing configuration used either in the this material.
  58370. *
  58371. * If sets to null, the scene one is in use.
  58372. */
  58373. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  58374. /**
  58375. * Gets wether the color curves effect is enabled.
  58376. */
  58377. get cameraColorCurvesEnabled(): boolean;
  58378. /**
  58379. * Sets wether the color curves effect is enabled.
  58380. */
  58381. set cameraColorCurvesEnabled(value: boolean);
  58382. /**
  58383. * Gets wether the color grading effect is enabled.
  58384. */
  58385. get cameraColorGradingEnabled(): boolean;
  58386. /**
  58387. * Gets wether the color grading effect is enabled.
  58388. */
  58389. set cameraColorGradingEnabled(value: boolean);
  58390. /**
  58391. * Gets wether tonemapping is enabled or not.
  58392. */
  58393. get cameraToneMappingEnabled(): boolean;
  58394. /**
  58395. * Sets wether tonemapping is enabled or not
  58396. */
  58397. set cameraToneMappingEnabled(value: boolean);
  58398. /**
  58399. * The camera exposure used on this material.
  58400. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  58401. * This corresponds to a photographic exposure.
  58402. */
  58403. get cameraExposure(): float;
  58404. /**
  58405. * The camera exposure used on this material.
  58406. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  58407. * This corresponds to a photographic exposure.
  58408. */
  58409. set cameraExposure(value: float);
  58410. /**
  58411. * Gets The camera contrast used on this material.
  58412. */
  58413. get cameraContrast(): float;
  58414. /**
  58415. * Sets The camera contrast used on this material.
  58416. */
  58417. set cameraContrast(value: float);
  58418. /**
  58419. * Gets the Color Grading 2D Lookup Texture.
  58420. */
  58421. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  58422. /**
  58423. * Sets the Color Grading 2D Lookup Texture.
  58424. */
  58425. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  58426. /**
  58427. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  58428. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  58429. * 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;
  58430. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  58431. */
  58432. get cameraColorCurves(): Nullable<ColorCurves>;
  58433. /**
  58434. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  58435. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  58436. * 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;
  58437. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  58438. */
  58439. set cameraColorCurves(value: Nullable<ColorCurves>);
  58440. /**
  58441. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  58442. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  58443. */
  58444. switchToBGR: boolean;
  58445. private _renderTargets;
  58446. private _reflectionControls;
  58447. private _white;
  58448. private _primaryShadowColor;
  58449. private _primaryHighlightColor;
  58450. /**
  58451. * Instantiates a Background Material in the given scene
  58452. * @param name The friendly name of the material
  58453. * @param scene The scene to add the material to
  58454. */
  58455. constructor(name: string, scene: Scene);
  58456. /**
  58457. * Gets a boolean indicating that current material needs to register RTT
  58458. */
  58459. get hasRenderTargetTextures(): boolean;
  58460. /**
  58461. * The entire material has been created in order to prevent overdraw.
  58462. * @returns false
  58463. */
  58464. needAlphaTesting(): boolean;
  58465. /**
  58466. * The entire material has been created in order to prevent overdraw.
  58467. * @returns true if blending is enable
  58468. */
  58469. needAlphaBlending(): boolean;
  58470. /**
  58471. * Checks wether the material is ready to be rendered for a given mesh.
  58472. * @param mesh The mesh to render
  58473. * @param subMesh The submesh to check against
  58474. * @param useInstances Specify wether or not the material is used with instances
  58475. * @returns true if all the dependencies are ready (Textures, Effects...)
  58476. */
  58477. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  58478. /**
  58479. * Compute the primary color according to the chosen perceptual color.
  58480. */
  58481. private _computePrimaryColorFromPerceptualColor;
  58482. /**
  58483. * Compute the highlights and shadow colors according to their chosen levels.
  58484. */
  58485. private _computePrimaryColors;
  58486. /**
  58487. * Build the uniform buffer used in the material.
  58488. */
  58489. buildUniformLayout(): void;
  58490. /**
  58491. * Unbind the material.
  58492. */
  58493. unbind(): void;
  58494. /**
  58495. * Bind only the world matrix to the material.
  58496. * @param world The world matrix to bind.
  58497. */
  58498. bindOnlyWorldMatrix(world: Matrix): void;
  58499. /**
  58500. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  58501. * @param world The world matrix to bind.
  58502. * @param subMesh The submesh to bind for.
  58503. */
  58504. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  58505. /**
  58506. * Checks to see if a texture is used in the material.
  58507. * @param texture - Base texture to use.
  58508. * @returns - Boolean specifying if a texture is used in the material.
  58509. */
  58510. hasTexture(texture: BaseTexture): boolean;
  58511. /**
  58512. * Dispose the material.
  58513. * @param forceDisposeEffect Force disposal of the associated effect.
  58514. * @param forceDisposeTextures Force disposal of the associated textures.
  58515. */
  58516. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  58517. /**
  58518. * Clones the material.
  58519. * @param name The cloned name.
  58520. * @returns The cloned material.
  58521. */
  58522. clone(name: string): BackgroundMaterial;
  58523. /**
  58524. * Serializes the current material to its JSON representation.
  58525. * @returns The JSON representation.
  58526. */
  58527. serialize(): any;
  58528. /**
  58529. * Gets the class name of the material
  58530. * @returns "BackgroundMaterial"
  58531. */
  58532. getClassName(): string;
  58533. /**
  58534. * Parse a JSON input to create back a background material.
  58535. * @param source The JSON data to parse
  58536. * @param scene The scene to create the parsed material in
  58537. * @param rootUrl The root url of the assets the material depends upon
  58538. * @returns the instantiated BackgroundMaterial.
  58539. */
  58540. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  58541. }
  58542. }
  58543. declare module BABYLON {
  58544. /**
  58545. * Represents the different options available during the creation of
  58546. * a Environment helper.
  58547. *
  58548. * This can control the default ground, skybox and image processing setup of your scene.
  58549. */
  58550. export interface IEnvironmentHelperOptions {
  58551. /**
  58552. * Specifies whether or not to create a ground.
  58553. * True by default.
  58554. */
  58555. createGround: boolean;
  58556. /**
  58557. * Specifies the ground size.
  58558. * 15 by default.
  58559. */
  58560. groundSize: number;
  58561. /**
  58562. * The texture used on the ground for the main color.
  58563. * Comes from the BabylonJS CDN by default.
  58564. *
  58565. * Remarks: Can be either a texture or a url.
  58566. */
  58567. groundTexture: string | BaseTexture;
  58568. /**
  58569. * The color mixed in the ground texture by default.
  58570. * BabylonJS clearColor by default.
  58571. */
  58572. groundColor: Color3;
  58573. /**
  58574. * Specifies the ground opacity.
  58575. * 1 by default.
  58576. */
  58577. groundOpacity: number;
  58578. /**
  58579. * Enables the ground to receive shadows.
  58580. * True by default.
  58581. */
  58582. enableGroundShadow: boolean;
  58583. /**
  58584. * Helps preventing the shadow to be fully black on the ground.
  58585. * 0.5 by default.
  58586. */
  58587. groundShadowLevel: number;
  58588. /**
  58589. * Creates a mirror texture attach to the ground.
  58590. * false by default.
  58591. */
  58592. enableGroundMirror: boolean;
  58593. /**
  58594. * Specifies the ground mirror size ratio.
  58595. * 0.3 by default as the default kernel is 64.
  58596. */
  58597. groundMirrorSizeRatio: number;
  58598. /**
  58599. * Specifies the ground mirror blur kernel size.
  58600. * 64 by default.
  58601. */
  58602. groundMirrorBlurKernel: number;
  58603. /**
  58604. * Specifies the ground mirror visibility amount.
  58605. * 1 by default
  58606. */
  58607. groundMirrorAmount: number;
  58608. /**
  58609. * Specifies the ground mirror reflectance weight.
  58610. * This uses the standard weight of the background material to setup the fresnel effect
  58611. * of the mirror.
  58612. * 1 by default.
  58613. */
  58614. groundMirrorFresnelWeight: number;
  58615. /**
  58616. * Specifies the ground mirror Falloff distance.
  58617. * This can helps reducing the size of the reflection.
  58618. * 0 by Default.
  58619. */
  58620. groundMirrorFallOffDistance: number;
  58621. /**
  58622. * Specifies the ground mirror texture type.
  58623. * Unsigned Int by Default.
  58624. */
  58625. groundMirrorTextureType: number;
  58626. /**
  58627. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  58628. * the shown objects.
  58629. */
  58630. groundYBias: number;
  58631. /**
  58632. * Specifies whether or not to create a skybox.
  58633. * True by default.
  58634. */
  58635. createSkybox: boolean;
  58636. /**
  58637. * Specifies the skybox size.
  58638. * 20 by default.
  58639. */
  58640. skyboxSize: number;
  58641. /**
  58642. * The texture used on the skybox for the main color.
  58643. * Comes from the BabylonJS CDN by default.
  58644. *
  58645. * Remarks: Can be either a texture or a url.
  58646. */
  58647. skyboxTexture: string | BaseTexture;
  58648. /**
  58649. * The color mixed in the skybox texture by default.
  58650. * BabylonJS clearColor by default.
  58651. */
  58652. skyboxColor: Color3;
  58653. /**
  58654. * The background rotation around the Y axis of the scene.
  58655. * This helps aligning the key lights of your scene with the background.
  58656. * 0 by default.
  58657. */
  58658. backgroundYRotation: number;
  58659. /**
  58660. * Compute automatically the size of the elements to best fit with the scene.
  58661. */
  58662. sizeAuto: boolean;
  58663. /**
  58664. * Default position of the rootMesh if autoSize is not true.
  58665. */
  58666. rootPosition: Vector3;
  58667. /**
  58668. * Sets up the image processing in the scene.
  58669. * true by default.
  58670. */
  58671. setupImageProcessing: boolean;
  58672. /**
  58673. * The texture used as your environment texture in the scene.
  58674. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  58675. *
  58676. * Remarks: Can be either a texture or a url.
  58677. */
  58678. environmentTexture: string | BaseTexture;
  58679. /**
  58680. * The value of the exposure to apply to the scene.
  58681. * 0.6 by default if setupImageProcessing is true.
  58682. */
  58683. cameraExposure: number;
  58684. /**
  58685. * The value of the contrast to apply to the scene.
  58686. * 1.6 by default if setupImageProcessing is true.
  58687. */
  58688. cameraContrast: number;
  58689. /**
  58690. * Specifies whether or not tonemapping should be enabled in the scene.
  58691. * true by default if setupImageProcessing is true.
  58692. */
  58693. toneMappingEnabled: boolean;
  58694. }
  58695. /**
  58696. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  58697. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  58698. * It also helps with the default setup of your imageProcessing configuration.
  58699. */
  58700. export class EnvironmentHelper {
  58701. /**
  58702. * Default ground texture URL.
  58703. */
  58704. private static _groundTextureCDNUrl;
  58705. /**
  58706. * Default skybox texture URL.
  58707. */
  58708. private static _skyboxTextureCDNUrl;
  58709. /**
  58710. * Default environment texture URL.
  58711. */
  58712. private static _environmentTextureCDNUrl;
  58713. /**
  58714. * Creates the default options for the helper.
  58715. */
  58716. private static _getDefaultOptions;
  58717. private _rootMesh;
  58718. /**
  58719. * Gets the root mesh created by the helper.
  58720. */
  58721. get rootMesh(): Mesh;
  58722. private _skybox;
  58723. /**
  58724. * Gets the skybox created by the helper.
  58725. */
  58726. get skybox(): Nullable<Mesh>;
  58727. private _skyboxTexture;
  58728. /**
  58729. * Gets the skybox texture created by the helper.
  58730. */
  58731. get skyboxTexture(): Nullable<BaseTexture>;
  58732. private _skyboxMaterial;
  58733. /**
  58734. * Gets the skybox material created by the helper.
  58735. */
  58736. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  58737. private _ground;
  58738. /**
  58739. * Gets the ground mesh created by the helper.
  58740. */
  58741. get ground(): Nullable<Mesh>;
  58742. private _groundTexture;
  58743. /**
  58744. * Gets the ground texture created by the helper.
  58745. */
  58746. get groundTexture(): Nullable<BaseTexture>;
  58747. private _groundMirror;
  58748. /**
  58749. * Gets the ground mirror created by the helper.
  58750. */
  58751. get groundMirror(): Nullable<MirrorTexture>;
  58752. /**
  58753. * Gets the ground mirror render list to helps pushing the meshes
  58754. * you wish in the ground reflection.
  58755. */
  58756. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  58757. private _groundMaterial;
  58758. /**
  58759. * Gets the ground material created by the helper.
  58760. */
  58761. get groundMaterial(): Nullable<BackgroundMaterial>;
  58762. /**
  58763. * Stores the creation options.
  58764. */
  58765. private readonly _scene;
  58766. private _options;
  58767. /**
  58768. * This observable will be notified with any error during the creation of the environment,
  58769. * mainly texture creation errors.
  58770. */
  58771. onErrorObservable: Observable<{
  58772. message?: string;
  58773. exception?: any;
  58774. }>;
  58775. /**
  58776. * constructor
  58777. * @param options Defines the options we want to customize the helper
  58778. * @param scene The scene to add the material to
  58779. */
  58780. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  58781. /**
  58782. * Updates the background according to the new options
  58783. * @param options
  58784. */
  58785. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  58786. /**
  58787. * Sets the primary color of all the available elements.
  58788. * @param color the main color to affect to the ground and the background
  58789. */
  58790. setMainColor(color: Color3): void;
  58791. /**
  58792. * Setup the image processing according to the specified options.
  58793. */
  58794. private _setupImageProcessing;
  58795. /**
  58796. * Setup the environment texture according to the specified options.
  58797. */
  58798. private _setupEnvironmentTexture;
  58799. /**
  58800. * Setup the background according to the specified options.
  58801. */
  58802. private _setupBackground;
  58803. /**
  58804. * Get the scene sizes according to the setup.
  58805. */
  58806. private _getSceneSize;
  58807. /**
  58808. * Setup the ground according to the specified options.
  58809. */
  58810. private _setupGround;
  58811. /**
  58812. * Setup the ground material according to the specified options.
  58813. */
  58814. private _setupGroundMaterial;
  58815. /**
  58816. * Setup the ground diffuse texture according to the specified options.
  58817. */
  58818. private _setupGroundDiffuseTexture;
  58819. /**
  58820. * Setup the ground mirror texture according to the specified options.
  58821. */
  58822. private _setupGroundMirrorTexture;
  58823. /**
  58824. * Setup the ground to receive the mirror texture.
  58825. */
  58826. private _setupMirrorInGroundMaterial;
  58827. /**
  58828. * Setup the skybox according to the specified options.
  58829. */
  58830. private _setupSkybox;
  58831. /**
  58832. * Setup the skybox material according to the specified options.
  58833. */
  58834. private _setupSkyboxMaterial;
  58835. /**
  58836. * Setup the skybox reflection texture according to the specified options.
  58837. */
  58838. private _setupSkyboxReflectionTexture;
  58839. private _errorHandler;
  58840. /**
  58841. * Dispose all the elements created by the Helper.
  58842. */
  58843. dispose(): void;
  58844. }
  58845. }
  58846. declare module BABYLON {
  58847. /**
  58848. * Display a 360/180 degree texture on an approximately spherical surface, useful for VR applications or skyboxes.
  58849. * As a subclass of TransformNode, this allow parenting to the camera or multiple textures with different locations in the scene.
  58850. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  58851. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  58852. */
  58853. export abstract class TextureDome<T extends Texture> extends TransformNode {
  58854. protected onError: Nullable<(message?: string, exception?: any) => void>;
  58855. /**
  58856. * Define the source as a Monoscopic panoramic 360/180.
  58857. */
  58858. static readonly MODE_MONOSCOPIC: number;
  58859. /**
  58860. * Define the source as a Stereoscopic TopBottom/OverUnder panoramic 360/180.
  58861. */
  58862. static readonly MODE_TOPBOTTOM: number;
  58863. /**
  58864. * Define the source as a Stereoscopic Side by Side panoramic 360/180.
  58865. */
  58866. static readonly MODE_SIDEBYSIDE: number;
  58867. private _halfDome;
  58868. private _crossEye;
  58869. protected _useDirectMapping: boolean;
  58870. /**
  58871. * The texture being displayed on the sphere
  58872. */
  58873. protected _texture: T;
  58874. /**
  58875. * Gets the texture being displayed on the sphere
  58876. */
  58877. get texture(): T;
  58878. /**
  58879. * Sets the texture being displayed on the sphere
  58880. */
  58881. set texture(newTexture: T);
  58882. /**
  58883. * The skybox material
  58884. */
  58885. protected _material: BackgroundMaterial;
  58886. /**
  58887. * The surface used for the dome
  58888. */
  58889. protected _mesh: Mesh;
  58890. /**
  58891. * Gets the mesh used for the dome.
  58892. */
  58893. get mesh(): Mesh;
  58894. /**
  58895. * A mesh that will be used to mask the back of the dome in case it is a 180 degree movie.
  58896. */
  58897. private _halfDomeMask;
  58898. /**
  58899. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  58900. * Also see the options.resolution property.
  58901. */
  58902. get fovMultiplier(): number;
  58903. set fovMultiplier(value: number);
  58904. protected _textureMode: number;
  58905. /**
  58906. * Gets or set the current texture mode for the texture. It can be:
  58907. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  58908. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  58909. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  58910. */
  58911. get textureMode(): number;
  58912. /**
  58913. * Sets the current texture mode for the texture. It can be:
  58914. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  58915. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  58916. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  58917. */
  58918. set textureMode(value: number);
  58919. /**
  58920. * Is it a 180 degrees dome (half dome) or 360 texture (full dome)
  58921. */
  58922. get halfDome(): boolean;
  58923. /**
  58924. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  58925. */
  58926. set halfDome(enabled: boolean);
  58927. /**
  58928. * Set the cross-eye mode. If set, images that can be seen when crossing eyes will render correctly
  58929. */
  58930. set crossEye(enabled: boolean);
  58931. /**
  58932. * Is it a cross-eye texture?
  58933. */
  58934. get crossEye(): boolean;
  58935. /**
  58936. * The background material of this dome.
  58937. */
  58938. get material(): BackgroundMaterial;
  58939. /**
  58940. * Oberserver used in Stereoscopic VR Mode.
  58941. */
  58942. private _onBeforeCameraRenderObserver;
  58943. /**
  58944. * Observable raised when an error occured while loading the 360 image
  58945. */
  58946. onLoadErrorObservable: Observable<string>;
  58947. /**
  58948. * Create an instance of this class and pass through the parameters to the relevant classes- Texture, StandardMaterial, and Mesh.
  58949. * @param name Element's name, child elements will append suffixes for their own names.
  58950. * @param textureUrlOrElement defines the url(s) or the (video) HTML element to use
  58951. * @param options An object containing optional or exposed sub element properties
  58952. */
  58953. constructor(name: string, textureUrlOrElement: string | string[] | HTMLVideoElement, options: {
  58954. resolution?: number;
  58955. clickToPlay?: boolean;
  58956. autoPlay?: boolean;
  58957. loop?: boolean;
  58958. size?: number;
  58959. poster?: string;
  58960. faceForward?: boolean;
  58961. useDirectMapping?: boolean;
  58962. halfDomeMode?: boolean;
  58963. crossEyeMode?: boolean;
  58964. generateMipMaps?: boolean;
  58965. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  58966. protected abstract _initTexture(urlsOrElement: string | string[] | HTMLElement, scene: Scene, options: any): T;
  58967. protected _changeTextureMode(value: number): void;
  58968. /**
  58969. * Releases resources associated with this node.
  58970. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  58971. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  58972. */
  58973. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  58974. }
  58975. }
  58976. declare module BABYLON {
  58977. /**
  58978. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  58979. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  58980. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  58981. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  58982. */
  58983. export class PhotoDome extends TextureDome<Texture> {
  58984. /**
  58985. * Define the image as a Monoscopic panoramic 360 image.
  58986. */
  58987. static readonly MODE_MONOSCOPIC: number;
  58988. /**
  58989. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  58990. */
  58991. static readonly MODE_TOPBOTTOM: number;
  58992. /**
  58993. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  58994. */
  58995. static readonly MODE_SIDEBYSIDE: number;
  58996. /**
  58997. * Gets or sets the texture being displayed on the sphere
  58998. */
  58999. get photoTexture(): Texture;
  59000. /**
  59001. * sets the texture being displayed on the sphere
  59002. */
  59003. set photoTexture(value: Texture);
  59004. /**
  59005. * Gets the current video mode for the video. It can be:
  59006. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  59007. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  59008. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  59009. */
  59010. get imageMode(): number;
  59011. /**
  59012. * Sets the current video mode for the video. It can be:
  59013. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  59014. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  59015. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  59016. */
  59017. set imageMode(value: number);
  59018. protected _initTexture(urlsOrElement: string, scene: Scene, options: any): Texture;
  59019. }
  59020. }
  59021. declare module BABYLON {
  59022. /**
  59023. * Direct draw surface info
  59024. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  59025. */
  59026. export interface DDSInfo {
  59027. /**
  59028. * Width of the texture
  59029. */
  59030. width: number;
  59031. /**
  59032. * Width of the texture
  59033. */
  59034. height: number;
  59035. /**
  59036. * Number of Mipmaps for the texture
  59037. * @see https://en.wikipedia.org/wiki/Mipmap
  59038. */
  59039. mipmapCount: number;
  59040. /**
  59041. * If the textures format is a known fourCC format
  59042. * @see https://www.fourcc.org/
  59043. */
  59044. isFourCC: boolean;
  59045. /**
  59046. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  59047. */
  59048. isRGB: boolean;
  59049. /**
  59050. * If the texture is a lumincance format
  59051. */
  59052. isLuminance: boolean;
  59053. /**
  59054. * If this is a cube texture
  59055. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  59056. */
  59057. isCube: boolean;
  59058. /**
  59059. * If the texture is a compressed format eg. FOURCC_DXT1
  59060. */
  59061. isCompressed: boolean;
  59062. /**
  59063. * The dxgiFormat of the texture
  59064. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  59065. */
  59066. dxgiFormat: number;
  59067. /**
  59068. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  59069. */
  59070. textureType: number;
  59071. /**
  59072. * Sphericle polynomial created for the dds texture
  59073. */
  59074. sphericalPolynomial?: SphericalPolynomial;
  59075. }
  59076. /**
  59077. * Class used to provide DDS decompression tools
  59078. */
  59079. export class DDSTools {
  59080. /**
  59081. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  59082. */
  59083. static StoreLODInAlphaChannel: boolean;
  59084. /**
  59085. * Gets DDS information from an array buffer
  59086. * @param data defines the array buffer view to read data from
  59087. * @returns the DDS information
  59088. */
  59089. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  59090. private static _FloatView;
  59091. private static _Int32View;
  59092. private static _ToHalfFloat;
  59093. private static _FromHalfFloat;
  59094. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  59095. private static _GetHalfFloatRGBAArrayBuffer;
  59096. private static _GetFloatRGBAArrayBuffer;
  59097. private static _GetFloatAsUIntRGBAArrayBuffer;
  59098. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  59099. private static _GetRGBAArrayBuffer;
  59100. private static _ExtractLongWordOrder;
  59101. private static _GetRGBArrayBuffer;
  59102. private static _GetLuminanceArrayBuffer;
  59103. /**
  59104. * Uploads DDS Levels to a Babylon Texture
  59105. * @hidden
  59106. */
  59107. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  59108. }
  59109. interface ThinEngine {
  59110. /**
  59111. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  59112. * @param rootUrl defines the url where the file to load is located
  59113. * @param scene defines the current scene
  59114. * @param lodScale defines scale to apply to the mip map selection
  59115. * @param lodOffset defines offset to apply to the mip map selection
  59116. * @param onLoad defines an optional callback raised when the texture is loaded
  59117. * @param onError defines an optional callback raised if there is an issue to load the texture
  59118. * @param format defines the format of the data
  59119. * @param forcedExtension defines the extension to use to pick the right loader
  59120. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  59121. * @returns the cube texture as an InternalTexture
  59122. */
  59123. 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;
  59124. }
  59125. }
  59126. declare module BABYLON {
  59127. /**
  59128. * Implementation of the DDS Texture Loader.
  59129. * @hidden
  59130. */
  59131. export class _DDSTextureLoader implements IInternalTextureLoader {
  59132. /**
  59133. * Defines wether the loader supports cascade loading the different faces.
  59134. */
  59135. readonly supportCascades: boolean;
  59136. /**
  59137. * This returns if the loader support the current file information.
  59138. * @param extension defines the file extension of the file being loaded
  59139. * @returns true if the loader can load the specified file
  59140. */
  59141. canLoad(extension: string): boolean;
  59142. /**
  59143. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  59144. * @param data contains the texture data
  59145. * @param texture defines the BabylonJS internal texture
  59146. * @param createPolynomials will be true if polynomials have been requested
  59147. * @param onLoad defines the callback to trigger once the texture is ready
  59148. * @param onError defines the callback to trigger in case of error
  59149. */
  59150. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  59151. /**
  59152. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  59153. * @param data contains the texture data
  59154. * @param texture defines the BabylonJS internal texture
  59155. * @param callback defines the method to call once ready to upload
  59156. */
  59157. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  59158. }
  59159. }
  59160. declare module BABYLON {
  59161. /**
  59162. * Implementation of the ENV Texture Loader.
  59163. * @hidden
  59164. */
  59165. export class _ENVTextureLoader implements IInternalTextureLoader {
  59166. /**
  59167. * Defines wether the loader supports cascade loading the different faces.
  59168. */
  59169. readonly supportCascades: boolean;
  59170. /**
  59171. * This returns if the loader support the current file information.
  59172. * @param extension defines the file extension of the file being loaded
  59173. * @returns true if the loader can load the specified file
  59174. */
  59175. canLoad(extension: string): boolean;
  59176. /**
  59177. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  59178. * @param data contains the texture data
  59179. * @param texture defines the BabylonJS internal texture
  59180. * @param createPolynomials will be true if polynomials have been requested
  59181. * @param onLoad defines the callback to trigger once the texture is ready
  59182. * @param onError defines the callback to trigger in case of error
  59183. */
  59184. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  59185. /**
  59186. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  59187. * @param data contains the texture data
  59188. * @param texture defines the BabylonJS internal texture
  59189. * @param callback defines the method to call once ready to upload
  59190. */
  59191. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  59192. }
  59193. }
  59194. declare module BABYLON {
  59195. /**
  59196. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  59197. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  59198. */
  59199. export class KhronosTextureContainer {
  59200. /** contents of the KTX container file */
  59201. data: ArrayBufferView;
  59202. private static HEADER_LEN;
  59203. private static COMPRESSED_2D;
  59204. private static COMPRESSED_3D;
  59205. private static TEX_2D;
  59206. private static TEX_3D;
  59207. /**
  59208. * Gets the openGL type
  59209. */
  59210. glType: number;
  59211. /**
  59212. * Gets the openGL type size
  59213. */
  59214. glTypeSize: number;
  59215. /**
  59216. * Gets the openGL format
  59217. */
  59218. glFormat: number;
  59219. /**
  59220. * Gets the openGL internal format
  59221. */
  59222. glInternalFormat: number;
  59223. /**
  59224. * Gets the base internal format
  59225. */
  59226. glBaseInternalFormat: number;
  59227. /**
  59228. * Gets image width in pixel
  59229. */
  59230. pixelWidth: number;
  59231. /**
  59232. * Gets image height in pixel
  59233. */
  59234. pixelHeight: number;
  59235. /**
  59236. * Gets image depth in pixels
  59237. */
  59238. pixelDepth: number;
  59239. /**
  59240. * Gets the number of array elements
  59241. */
  59242. numberOfArrayElements: number;
  59243. /**
  59244. * Gets the number of faces
  59245. */
  59246. numberOfFaces: number;
  59247. /**
  59248. * Gets the number of mipmap levels
  59249. */
  59250. numberOfMipmapLevels: number;
  59251. /**
  59252. * Gets the bytes of key value data
  59253. */
  59254. bytesOfKeyValueData: number;
  59255. /**
  59256. * Gets the load type
  59257. */
  59258. loadType: number;
  59259. /**
  59260. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  59261. */
  59262. isInvalid: boolean;
  59263. /**
  59264. * Creates a new KhronosTextureContainer
  59265. * @param data contents of the KTX container file
  59266. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  59267. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  59268. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  59269. */
  59270. constructor(
  59271. /** contents of the KTX container file */
  59272. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  59273. /**
  59274. * Uploads KTX content to a Babylon Texture.
  59275. * It is assumed that the texture has already been created & is currently bound
  59276. * @hidden
  59277. */
  59278. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  59279. private _upload2DCompressedLevels;
  59280. /**
  59281. * Checks if the given data starts with a KTX file identifier.
  59282. * @param data the data to check
  59283. * @returns true if the data is a KTX file or false otherwise
  59284. */
  59285. static IsValid(data: ArrayBufferView): boolean;
  59286. }
  59287. }
  59288. declare module BABYLON {
  59289. /**
  59290. * Helper class to push actions to a pool of workers.
  59291. */
  59292. export class WorkerPool implements IDisposable {
  59293. private _workerInfos;
  59294. private _pendingActions;
  59295. /**
  59296. * Constructor
  59297. * @param workers Array of workers to use for actions
  59298. */
  59299. constructor(workers: Array<Worker>);
  59300. /**
  59301. * Terminates all workers and clears any pending actions.
  59302. */
  59303. dispose(): void;
  59304. /**
  59305. * Pushes an action to the worker pool. If all the workers are active, the action will be
  59306. * pended until a worker has completed its action.
  59307. * @param action The action to perform. Call onComplete when the action is complete.
  59308. */
  59309. push(action: (worker: Worker, onComplete: () => void) => void): void;
  59310. private _execute;
  59311. }
  59312. }
  59313. declare module BABYLON {
  59314. /**
  59315. * Class for loading KTX2 files
  59316. */
  59317. export class KhronosTextureContainer2 {
  59318. private static _WorkerPoolPromise?;
  59319. private static _Initialized;
  59320. private static _Ktx2Decoder;
  59321. /**
  59322. * URLs to use when loading the KTX2 decoder module as well as its dependencies
  59323. * If a url is null, the default url is used (pointing to https://preview.babylonjs.com)
  59324. * Note that jsDecoderModule can't be null and that the other dependencies will only be loaded if necessary
  59325. * Urls you can change:
  59326. * URLConfig.jsDecoderModule
  59327. * URLConfig.wasmUASTCToASTC
  59328. * URLConfig.wasmUASTCToBC7
  59329. * URLConfig.wasmUASTCToRGBA_UNORM
  59330. * URLConfig.wasmUASTCToRGBA_SRGB
  59331. * URLConfig.jsMSCTranscoder
  59332. * URLConfig.wasmMSCTranscoder
  59333. * You can see their default values in this PG: https://playground.babylonjs.com/#EIJH8L#9
  59334. */
  59335. static URLConfig: {
  59336. jsDecoderModule: string;
  59337. wasmUASTCToASTC: null;
  59338. wasmUASTCToBC7: null;
  59339. wasmUASTCToRGBA_UNORM: null;
  59340. wasmUASTCToRGBA_SRGB: null;
  59341. jsMSCTranscoder: null;
  59342. wasmMSCTranscoder: null;
  59343. };
  59344. /**
  59345. * Default number of workers used to handle data decoding
  59346. */
  59347. static DefaultNumWorkers: number;
  59348. private static GetDefaultNumWorkers;
  59349. private _engine;
  59350. private static _CreateWorkerPool;
  59351. /**
  59352. * Constructor
  59353. * @param engine The engine to use
  59354. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  59355. */
  59356. constructor(engine: ThinEngine, numWorkers?: number);
  59357. /** @hidden */
  59358. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture, options?: any): Promise<void>;
  59359. /**
  59360. * Stop all async operations and release resources.
  59361. */
  59362. dispose(): void;
  59363. protected _createTexture(data: any, internalTexture: InternalTexture, options?: any): void;
  59364. /**
  59365. * Checks if the given data starts with a KTX2 file identifier.
  59366. * @param data the data to check
  59367. * @returns true if the data is a KTX2 file or false otherwise
  59368. */
  59369. static IsValid(data: ArrayBufferView): boolean;
  59370. }
  59371. }
  59372. declare module BABYLON {
  59373. /**
  59374. * Implementation of the KTX Texture Loader.
  59375. * @hidden
  59376. */
  59377. export class _KTXTextureLoader implements IInternalTextureLoader {
  59378. /**
  59379. * Defines wether the loader supports cascade loading the different faces.
  59380. */
  59381. readonly supportCascades: boolean;
  59382. /**
  59383. * This returns if the loader support the current file information.
  59384. * @param extension defines the file extension of the file being loaded
  59385. * @param mimeType defines the optional mime type of the file being loaded
  59386. * @returns true if the loader can load the specified file
  59387. */
  59388. canLoad(extension: string, mimeType?: string): boolean;
  59389. /**
  59390. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  59391. * @param data contains the texture data
  59392. * @param texture defines the BabylonJS internal texture
  59393. * @param createPolynomials will be true if polynomials have been requested
  59394. * @param onLoad defines the callback to trigger once the texture is ready
  59395. * @param onError defines the callback to trigger in case of error
  59396. */
  59397. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  59398. /**
  59399. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  59400. * @param data contains the texture data
  59401. * @param texture defines the BabylonJS internal texture
  59402. * @param callback defines the method to call once ready to upload
  59403. */
  59404. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void, options?: any): void;
  59405. }
  59406. }
  59407. declare module BABYLON {
  59408. /** @hidden */
  59409. export var _forceSceneHelpersToBundle: boolean;
  59410. interface Scene {
  59411. /**
  59412. * Creates a default light for the scene.
  59413. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  59414. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  59415. */
  59416. createDefaultLight(replace?: boolean): void;
  59417. /**
  59418. * Creates a default camera for the scene.
  59419. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  59420. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  59421. * @param replace has default false, when true replaces the active camera in the scene
  59422. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  59423. */
  59424. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  59425. /**
  59426. * Creates a default camera and a default light.
  59427. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  59428. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  59429. * @param replace has the default false, when true replaces the active camera/light in the scene
  59430. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  59431. */
  59432. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  59433. /**
  59434. * Creates a new sky box
  59435. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  59436. * @param environmentTexture defines the texture to use as environment texture
  59437. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  59438. * @param scale defines the overall scale of the skybox
  59439. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  59440. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  59441. * @returns a new mesh holding the sky box
  59442. */
  59443. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  59444. /**
  59445. * Creates a new environment
  59446. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  59447. * @param options defines the options you can use to configure the environment
  59448. * @returns the new EnvironmentHelper
  59449. */
  59450. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  59451. /**
  59452. * Creates a new VREXperienceHelper
  59453. * @see https://doc.babylonjs.com/how_to/webvr_helper
  59454. * @param webVROptions defines the options used to create the new VREXperienceHelper
  59455. * @returns a new VREXperienceHelper
  59456. */
  59457. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  59458. /**
  59459. * Creates a new WebXRDefaultExperience
  59460. * @see https://doc.babylonjs.com/how_to/introduction_to_webxr
  59461. * @param options experience options
  59462. * @returns a promise for a new WebXRDefaultExperience
  59463. */
  59464. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  59465. }
  59466. }
  59467. declare module BABYLON {
  59468. /**
  59469. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  59470. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  59471. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  59472. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  59473. */
  59474. export class VideoDome extends TextureDome<VideoTexture> {
  59475. /**
  59476. * Define the video source as a Monoscopic panoramic 360 video.
  59477. */
  59478. static readonly MODE_MONOSCOPIC: number;
  59479. /**
  59480. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  59481. */
  59482. static readonly MODE_TOPBOTTOM: number;
  59483. /**
  59484. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  59485. */
  59486. static readonly MODE_SIDEBYSIDE: number;
  59487. /**
  59488. * Get the video texture associated with this video dome
  59489. */
  59490. get videoTexture(): VideoTexture;
  59491. /**
  59492. * Get the video mode of this dome
  59493. */
  59494. get videoMode(): number;
  59495. /**
  59496. * Set the video mode of this dome.
  59497. * @see textureMode
  59498. */
  59499. set videoMode(value: number);
  59500. protected _initTexture(urlsOrElement: string | string[] | HTMLVideoElement, scene: Scene, options: any): VideoTexture;
  59501. }
  59502. }
  59503. declare module BABYLON {
  59504. /**
  59505. * This class can be used to get instrumentation data from a Babylon engine
  59506. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  59507. */
  59508. export class EngineInstrumentation implements IDisposable {
  59509. /**
  59510. * Define the instrumented engine.
  59511. */
  59512. engine: Engine;
  59513. private _captureGPUFrameTime;
  59514. private _gpuFrameTimeToken;
  59515. private _gpuFrameTime;
  59516. private _captureShaderCompilationTime;
  59517. private _shaderCompilationTime;
  59518. private _onBeginFrameObserver;
  59519. private _onEndFrameObserver;
  59520. private _onBeforeShaderCompilationObserver;
  59521. private _onAfterShaderCompilationObserver;
  59522. /**
  59523. * Gets the perf counter used for GPU frame time
  59524. */
  59525. get gpuFrameTimeCounter(): PerfCounter;
  59526. /**
  59527. * Gets the GPU frame time capture status
  59528. */
  59529. get captureGPUFrameTime(): boolean;
  59530. /**
  59531. * Enable or disable the GPU frame time capture
  59532. */
  59533. set captureGPUFrameTime(value: boolean);
  59534. /**
  59535. * Gets the perf counter used for shader compilation time
  59536. */
  59537. get shaderCompilationTimeCounter(): PerfCounter;
  59538. /**
  59539. * Gets the shader compilation time capture status
  59540. */
  59541. get captureShaderCompilationTime(): boolean;
  59542. /**
  59543. * Enable or disable the shader compilation time capture
  59544. */
  59545. set captureShaderCompilationTime(value: boolean);
  59546. /**
  59547. * Instantiates a new engine instrumentation.
  59548. * This class can be used to get instrumentation data from a Babylon engine
  59549. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  59550. * @param engine Defines the engine to instrument
  59551. */
  59552. constructor(
  59553. /**
  59554. * Define the instrumented engine.
  59555. */
  59556. engine: Engine);
  59557. /**
  59558. * Dispose and release associated resources.
  59559. */
  59560. dispose(): void;
  59561. }
  59562. }
  59563. declare module BABYLON {
  59564. /**
  59565. * This class can be used to get instrumentation data from a Babylon engine
  59566. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  59567. */
  59568. export class SceneInstrumentation implements IDisposable {
  59569. /**
  59570. * Defines the scene to instrument
  59571. */
  59572. scene: Scene;
  59573. private _captureActiveMeshesEvaluationTime;
  59574. private _activeMeshesEvaluationTime;
  59575. private _captureRenderTargetsRenderTime;
  59576. private _renderTargetsRenderTime;
  59577. private _captureFrameTime;
  59578. private _frameTime;
  59579. private _captureRenderTime;
  59580. private _renderTime;
  59581. private _captureInterFrameTime;
  59582. private _interFrameTime;
  59583. private _captureParticlesRenderTime;
  59584. private _particlesRenderTime;
  59585. private _captureSpritesRenderTime;
  59586. private _spritesRenderTime;
  59587. private _capturePhysicsTime;
  59588. private _physicsTime;
  59589. private _captureAnimationsTime;
  59590. private _animationsTime;
  59591. private _captureCameraRenderTime;
  59592. private _cameraRenderTime;
  59593. private _onBeforeActiveMeshesEvaluationObserver;
  59594. private _onAfterActiveMeshesEvaluationObserver;
  59595. private _onBeforeRenderTargetsRenderObserver;
  59596. private _onAfterRenderTargetsRenderObserver;
  59597. private _onAfterRenderObserver;
  59598. private _onBeforeDrawPhaseObserver;
  59599. private _onAfterDrawPhaseObserver;
  59600. private _onBeforeAnimationsObserver;
  59601. private _onBeforeParticlesRenderingObserver;
  59602. private _onAfterParticlesRenderingObserver;
  59603. private _onBeforeSpritesRenderingObserver;
  59604. private _onAfterSpritesRenderingObserver;
  59605. private _onBeforePhysicsObserver;
  59606. private _onAfterPhysicsObserver;
  59607. private _onAfterAnimationsObserver;
  59608. private _onBeforeCameraRenderObserver;
  59609. private _onAfterCameraRenderObserver;
  59610. /**
  59611. * Gets the perf counter used for active meshes evaluation time
  59612. */
  59613. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  59614. /**
  59615. * Gets the active meshes evaluation time capture status
  59616. */
  59617. get captureActiveMeshesEvaluationTime(): boolean;
  59618. /**
  59619. * Enable or disable the active meshes evaluation time capture
  59620. */
  59621. set captureActiveMeshesEvaluationTime(value: boolean);
  59622. /**
  59623. * Gets the perf counter used for render targets render time
  59624. */
  59625. get renderTargetsRenderTimeCounter(): PerfCounter;
  59626. /**
  59627. * Gets the render targets render time capture status
  59628. */
  59629. get captureRenderTargetsRenderTime(): boolean;
  59630. /**
  59631. * Enable or disable the render targets render time capture
  59632. */
  59633. set captureRenderTargetsRenderTime(value: boolean);
  59634. /**
  59635. * Gets the perf counter used for particles render time
  59636. */
  59637. get particlesRenderTimeCounter(): PerfCounter;
  59638. /**
  59639. * Gets the particles render time capture status
  59640. */
  59641. get captureParticlesRenderTime(): boolean;
  59642. /**
  59643. * Enable or disable the particles render time capture
  59644. */
  59645. set captureParticlesRenderTime(value: boolean);
  59646. /**
  59647. * Gets the perf counter used for sprites render time
  59648. */
  59649. get spritesRenderTimeCounter(): PerfCounter;
  59650. /**
  59651. * Gets the sprites render time capture status
  59652. */
  59653. get captureSpritesRenderTime(): boolean;
  59654. /**
  59655. * Enable or disable the sprites render time capture
  59656. */
  59657. set captureSpritesRenderTime(value: boolean);
  59658. /**
  59659. * Gets the perf counter used for physics time
  59660. */
  59661. get physicsTimeCounter(): PerfCounter;
  59662. /**
  59663. * Gets the physics time capture status
  59664. */
  59665. get capturePhysicsTime(): boolean;
  59666. /**
  59667. * Enable or disable the physics time capture
  59668. */
  59669. set capturePhysicsTime(value: boolean);
  59670. /**
  59671. * Gets the perf counter used for animations time
  59672. */
  59673. get animationsTimeCounter(): PerfCounter;
  59674. /**
  59675. * Gets the animations time capture status
  59676. */
  59677. get captureAnimationsTime(): boolean;
  59678. /**
  59679. * Enable or disable the animations time capture
  59680. */
  59681. set captureAnimationsTime(value: boolean);
  59682. /**
  59683. * Gets the perf counter used for frame time capture
  59684. */
  59685. get frameTimeCounter(): PerfCounter;
  59686. /**
  59687. * Gets the frame time capture status
  59688. */
  59689. get captureFrameTime(): boolean;
  59690. /**
  59691. * Enable or disable the frame time capture
  59692. */
  59693. set captureFrameTime(value: boolean);
  59694. /**
  59695. * Gets the perf counter used for inter-frames time capture
  59696. */
  59697. get interFrameTimeCounter(): PerfCounter;
  59698. /**
  59699. * Gets the inter-frames time capture status
  59700. */
  59701. get captureInterFrameTime(): boolean;
  59702. /**
  59703. * Enable or disable the inter-frames time capture
  59704. */
  59705. set captureInterFrameTime(value: boolean);
  59706. /**
  59707. * Gets the perf counter used for render time capture
  59708. */
  59709. get renderTimeCounter(): PerfCounter;
  59710. /**
  59711. * Gets the render time capture status
  59712. */
  59713. get captureRenderTime(): boolean;
  59714. /**
  59715. * Enable or disable the render time capture
  59716. */
  59717. set captureRenderTime(value: boolean);
  59718. /**
  59719. * Gets the perf counter used for camera render time capture
  59720. */
  59721. get cameraRenderTimeCounter(): PerfCounter;
  59722. /**
  59723. * Gets the camera render time capture status
  59724. */
  59725. get captureCameraRenderTime(): boolean;
  59726. /**
  59727. * Enable or disable the camera render time capture
  59728. */
  59729. set captureCameraRenderTime(value: boolean);
  59730. /**
  59731. * Gets the perf counter used for draw calls
  59732. */
  59733. get drawCallsCounter(): PerfCounter;
  59734. /**
  59735. * Instantiates a new scene instrumentation.
  59736. * This class can be used to get instrumentation data from a Babylon engine
  59737. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  59738. * @param scene Defines the scene to instrument
  59739. */
  59740. constructor(
  59741. /**
  59742. * Defines the scene to instrument
  59743. */
  59744. scene: Scene);
  59745. /**
  59746. * Dispose and release associated resources.
  59747. */
  59748. dispose(): void;
  59749. }
  59750. }
  59751. declare module BABYLON {
  59752. /** @hidden */
  59753. export var glowMapGenerationPixelShader: {
  59754. name: string;
  59755. shader: string;
  59756. };
  59757. }
  59758. declare module BABYLON {
  59759. /** @hidden */
  59760. export var glowMapGenerationVertexShader: {
  59761. name: string;
  59762. shader: string;
  59763. };
  59764. }
  59765. declare module BABYLON {
  59766. /**
  59767. * Effect layer options. This helps customizing the behaviour
  59768. * of the effect layer.
  59769. */
  59770. export interface IEffectLayerOptions {
  59771. /**
  59772. * Multiplication factor apply to the canvas size to compute the render target size
  59773. * used to generated the objects (the smaller the faster).
  59774. */
  59775. mainTextureRatio: number;
  59776. /**
  59777. * Enforces a fixed size texture to ensure effect stability across devices.
  59778. */
  59779. mainTextureFixedSize?: number;
  59780. /**
  59781. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  59782. */
  59783. alphaBlendingMode: number;
  59784. /**
  59785. * The camera attached to the layer.
  59786. */
  59787. camera: Nullable<Camera>;
  59788. /**
  59789. * The rendering group to draw the layer in.
  59790. */
  59791. renderingGroupId: number;
  59792. }
  59793. /**
  59794. * The effect layer Helps adding post process effect blended with the main pass.
  59795. *
  59796. * This can be for instance use to generate glow or higlight effects on the scene.
  59797. *
  59798. * The effect layer class can not be used directly and is intented to inherited from to be
  59799. * customized per effects.
  59800. */
  59801. export abstract class EffectLayer {
  59802. private _vertexBuffers;
  59803. private _indexBuffer;
  59804. private _cachedDefines;
  59805. private _effectLayerMapGenerationEffect;
  59806. private _effectLayerOptions;
  59807. private _mergeEffect;
  59808. protected _scene: Scene;
  59809. protected _engine: Engine;
  59810. protected _maxSize: number;
  59811. protected _mainTextureDesiredSize: ISize;
  59812. protected _mainTexture: RenderTargetTexture;
  59813. protected _shouldRender: boolean;
  59814. protected _postProcesses: PostProcess[];
  59815. protected _textures: BaseTexture[];
  59816. protected _emissiveTextureAndColor: {
  59817. texture: Nullable<BaseTexture>;
  59818. color: Color4;
  59819. };
  59820. /**
  59821. * The name of the layer
  59822. */
  59823. name: string;
  59824. /**
  59825. * The clear color of the texture used to generate the glow map.
  59826. */
  59827. neutralColor: Color4;
  59828. /**
  59829. * Specifies whether the highlight layer is enabled or not.
  59830. */
  59831. isEnabled: boolean;
  59832. /**
  59833. * Gets the camera attached to the layer.
  59834. */
  59835. get camera(): Nullable<Camera>;
  59836. /**
  59837. * Gets the rendering group id the layer should render in.
  59838. */
  59839. get renderingGroupId(): number;
  59840. set renderingGroupId(renderingGroupId: number);
  59841. /**
  59842. * Specifies if the bounding boxes should be rendered normally or if they should undergo the effect of the layer
  59843. */
  59844. disableBoundingBoxesFromEffectLayer: boolean;
  59845. /**
  59846. * An event triggered when the effect layer has been disposed.
  59847. */
  59848. onDisposeObservable: Observable<EffectLayer>;
  59849. /**
  59850. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  59851. */
  59852. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  59853. /**
  59854. * An event triggered when the generated texture is being merged in the scene.
  59855. */
  59856. onBeforeComposeObservable: Observable<EffectLayer>;
  59857. /**
  59858. * An event triggered when the mesh is rendered into the effect render target.
  59859. */
  59860. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  59861. /**
  59862. * An event triggered after the mesh has been rendered into the effect render target.
  59863. */
  59864. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  59865. /**
  59866. * An event triggered when the generated texture has been merged in the scene.
  59867. */
  59868. onAfterComposeObservable: Observable<EffectLayer>;
  59869. /**
  59870. * An event triggered when the efffect layer changes its size.
  59871. */
  59872. onSizeChangedObservable: Observable<EffectLayer>;
  59873. /** @hidden */
  59874. static _SceneComponentInitialization: (scene: Scene) => void;
  59875. /**
  59876. * Instantiates a new effect Layer and references it in the scene.
  59877. * @param name The name of the layer
  59878. * @param scene The scene to use the layer in
  59879. */
  59880. constructor(
  59881. /** The Friendly of the effect in the scene */
  59882. name: string, scene: Scene);
  59883. /**
  59884. * Get the effect name of the layer.
  59885. * @return The effect name
  59886. */
  59887. abstract getEffectName(): string;
  59888. /**
  59889. * Checks for the readiness of the element composing the layer.
  59890. * @param subMesh the mesh to check for
  59891. * @param useInstances specify whether or not to use instances to render the mesh
  59892. * @return true if ready otherwise, false
  59893. */
  59894. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  59895. /**
  59896. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  59897. * @returns true if the effect requires stencil during the main canvas render pass.
  59898. */
  59899. abstract needStencil(): boolean;
  59900. /**
  59901. * Create the merge effect. This is the shader use to blit the information back
  59902. * to the main canvas at the end of the scene rendering.
  59903. * @returns The effect containing the shader used to merge the effect on the main canvas
  59904. */
  59905. protected abstract _createMergeEffect(): Effect;
  59906. /**
  59907. * Creates the render target textures and post processes used in the effect layer.
  59908. */
  59909. protected abstract _createTextureAndPostProcesses(): void;
  59910. /**
  59911. * Implementation specific of rendering the generating effect on the main canvas.
  59912. * @param effect The effect used to render through
  59913. */
  59914. protected abstract _internalRender(effect: Effect): void;
  59915. /**
  59916. * Sets the required values for both the emissive texture and and the main color.
  59917. */
  59918. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  59919. /**
  59920. * Free any resources and references associated to a mesh.
  59921. * Internal use
  59922. * @param mesh The mesh to free.
  59923. */
  59924. abstract _disposeMesh(mesh: Mesh): void;
  59925. /**
  59926. * Serializes this layer (Glow or Highlight for example)
  59927. * @returns a serialized layer object
  59928. */
  59929. abstract serialize?(): any;
  59930. /**
  59931. * Initializes the effect layer with the required options.
  59932. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  59933. */
  59934. protected _init(options: Partial<IEffectLayerOptions>): void;
  59935. /**
  59936. * Generates the index buffer of the full screen quad blending to the main canvas.
  59937. */
  59938. private _generateIndexBuffer;
  59939. /**
  59940. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  59941. */
  59942. private _generateVertexBuffer;
  59943. /**
  59944. * Sets the main texture desired size which is the closest power of two
  59945. * of the engine canvas size.
  59946. */
  59947. private _setMainTextureSize;
  59948. /**
  59949. * Creates the main texture for the effect layer.
  59950. */
  59951. protected _createMainTexture(): void;
  59952. /**
  59953. * Adds specific effects defines.
  59954. * @param defines The defines to add specifics to.
  59955. */
  59956. protected _addCustomEffectDefines(defines: string[]): void;
  59957. /**
  59958. * Checks for the readiness of the element composing the layer.
  59959. * @param subMesh the mesh to check for
  59960. * @param useInstances specify whether or not to use instances to render the mesh
  59961. * @param emissiveTexture the associated emissive texture used to generate the glow
  59962. * @return true if ready otherwise, false
  59963. */
  59964. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  59965. /**
  59966. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  59967. */
  59968. render(): void;
  59969. /**
  59970. * Determine if a given mesh will be used in the current effect.
  59971. * @param mesh mesh to test
  59972. * @returns true if the mesh will be used
  59973. */
  59974. hasMesh(mesh: AbstractMesh): boolean;
  59975. /**
  59976. * Returns true if the layer contains information to display, otherwise false.
  59977. * @returns true if the glow layer should be rendered
  59978. */
  59979. shouldRender(): boolean;
  59980. /**
  59981. * Returns true if the mesh should render, otherwise false.
  59982. * @param mesh The mesh to render
  59983. * @returns true if it should render otherwise false
  59984. */
  59985. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  59986. /**
  59987. * Returns true if the mesh can be rendered, otherwise false.
  59988. * @param mesh The mesh to render
  59989. * @param material The material used on the mesh
  59990. * @returns true if it can be rendered otherwise false
  59991. */
  59992. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  59993. /**
  59994. * Returns true if the mesh should render, otherwise false.
  59995. * @param mesh The mesh to render
  59996. * @returns true if it should render otherwise false
  59997. */
  59998. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  59999. /**
  60000. * Renders the submesh passed in parameter to the generation map.
  60001. */
  60002. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  60003. /**
  60004. * Defines whether the current material of the mesh should be use to render the effect.
  60005. * @param mesh defines the current mesh to render
  60006. */
  60007. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  60008. /**
  60009. * Rebuild the required buffers.
  60010. * @hidden Internal use only.
  60011. */
  60012. _rebuild(): void;
  60013. /**
  60014. * Dispose only the render target textures and post process.
  60015. */
  60016. private _disposeTextureAndPostProcesses;
  60017. /**
  60018. * Dispose the highlight layer and free resources.
  60019. */
  60020. dispose(): void;
  60021. /**
  60022. * Gets the class name of the effect layer
  60023. * @returns the string with the class name of the effect layer
  60024. */
  60025. getClassName(): string;
  60026. /**
  60027. * Creates an effect layer from parsed effect layer data
  60028. * @param parsedEffectLayer defines effect layer data
  60029. * @param scene defines the current scene
  60030. * @param rootUrl defines the root URL containing the effect layer information
  60031. * @returns a parsed effect Layer
  60032. */
  60033. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  60034. }
  60035. }
  60036. declare module BABYLON {
  60037. interface AbstractScene {
  60038. /**
  60039. * The list of effect layers (highlights/glow) added to the scene
  60040. * @see https://doc.babylonjs.com/how_to/highlight_layer
  60041. * @see https://doc.babylonjs.com/how_to/glow_layer
  60042. */
  60043. effectLayers: Array<EffectLayer>;
  60044. /**
  60045. * Removes the given effect layer from this scene.
  60046. * @param toRemove defines the effect layer to remove
  60047. * @returns the index of the removed effect layer
  60048. */
  60049. removeEffectLayer(toRemove: EffectLayer): number;
  60050. /**
  60051. * Adds the given effect layer to this scene
  60052. * @param newEffectLayer defines the effect layer to add
  60053. */
  60054. addEffectLayer(newEffectLayer: EffectLayer): void;
  60055. }
  60056. /**
  60057. * Defines the layer scene component responsible to manage any effect layers
  60058. * in a given scene.
  60059. */
  60060. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  60061. /**
  60062. * The component name helpfull to identify the component in the list of scene components.
  60063. */
  60064. readonly name: string;
  60065. /**
  60066. * The scene the component belongs to.
  60067. */
  60068. scene: Scene;
  60069. private _engine;
  60070. private _renderEffects;
  60071. private _needStencil;
  60072. private _previousStencilState;
  60073. /**
  60074. * Creates a new instance of the component for the given scene
  60075. * @param scene Defines the scene to register the component in
  60076. */
  60077. constructor(scene: Scene);
  60078. /**
  60079. * Registers the component in a given scene
  60080. */
  60081. register(): void;
  60082. /**
  60083. * Rebuilds the elements related to this component in case of
  60084. * context lost for instance.
  60085. */
  60086. rebuild(): void;
  60087. /**
  60088. * Serializes the component data to the specified json object
  60089. * @param serializationObject The object to serialize to
  60090. */
  60091. serialize(serializationObject: any): void;
  60092. /**
  60093. * Adds all the elements from the container to the scene
  60094. * @param container the container holding the elements
  60095. */
  60096. addFromContainer(container: AbstractScene): void;
  60097. /**
  60098. * Removes all the elements in the container from the scene
  60099. * @param container contains the elements to remove
  60100. * @param dispose if the removed element should be disposed (default: false)
  60101. */
  60102. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  60103. /**
  60104. * Disposes the component and the associated ressources.
  60105. */
  60106. dispose(): void;
  60107. private _isReadyForMesh;
  60108. private _renderMainTexture;
  60109. private _setStencil;
  60110. private _setStencilBack;
  60111. private _draw;
  60112. private _drawCamera;
  60113. private _drawRenderingGroup;
  60114. }
  60115. }
  60116. declare module BABYLON {
  60117. /** @hidden */
  60118. export var glowMapMergePixelShader: {
  60119. name: string;
  60120. shader: string;
  60121. };
  60122. }
  60123. declare module BABYLON {
  60124. /** @hidden */
  60125. export var glowMapMergeVertexShader: {
  60126. name: string;
  60127. shader: string;
  60128. };
  60129. }
  60130. declare module BABYLON {
  60131. interface AbstractScene {
  60132. /**
  60133. * Return a the first highlight layer of the scene with a given name.
  60134. * @param name The name of the highlight layer to look for.
  60135. * @return The highlight layer if found otherwise null.
  60136. */
  60137. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  60138. }
  60139. /**
  60140. * Glow layer options. This helps customizing the behaviour
  60141. * of the glow layer.
  60142. */
  60143. export interface IGlowLayerOptions {
  60144. /**
  60145. * Multiplication factor apply to the canvas size to compute the render target size
  60146. * used to generated the glowing objects (the smaller the faster).
  60147. */
  60148. mainTextureRatio: number;
  60149. /**
  60150. * Enforces a fixed size texture to ensure resize independant blur.
  60151. */
  60152. mainTextureFixedSize?: number;
  60153. /**
  60154. * How big is the kernel of the blur texture.
  60155. */
  60156. blurKernelSize: number;
  60157. /**
  60158. * The camera attached to the layer.
  60159. */
  60160. camera: Nullable<Camera>;
  60161. /**
  60162. * Enable MSAA by chosing the number of samples.
  60163. */
  60164. mainTextureSamples?: number;
  60165. /**
  60166. * The rendering group to draw the layer in.
  60167. */
  60168. renderingGroupId: number;
  60169. }
  60170. /**
  60171. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  60172. *
  60173. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  60174. *
  60175. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  60176. */
  60177. export class GlowLayer extends EffectLayer {
  60178. /**
  60179. * Effect Name of the layer.
  60180. */
  60181. static readonly EffectName: string;
  60182. /**
  60183. * The default blur kernel size used for the glow.
  60184. */
  60185. static DefaultBlurKernelSize: number;
  60186. /**
  60187. * The default texture size ratio used for the glow.
  60188. */
  60189. static DefaultTextureRatio: number;
  60190. /**
  60191. * Sets the kernel size of the blur.
  60192. */
  60193. set blurKernelSize(value: number);
  60194. /**
  60195. * Gets the kernel size of the blur.
  60196. */
  60197. get blurKernelSize(): number;
  60198. /**
  60199. * Sets the glow intensity.
  60200. */
  60201. set intensity(value: number);
  60202. /**
  60203. * Gets the glow intensity.
  60204. */
  60205. get intensity(): number;
  60206. private _options;
  60207. private _intensity;
  60208. private _horizontalBlurPostprocess1;
  60209. private _verticalBlurPostprocess1;
  60210. private _horizontalBlurPostprocess2;
  60211. private _verticalBlurPostprocess2;
  60212. private _blurTexture1;
  60213. private _blurTexture2;
  60214. private _postProcesses1;
  60215. private _postProcesses2;
  60216. private _includedOnlyMeshes;
  60217. private _excludedMeshes;
  60218. private _meshesUsingTheirOwnMaterials;
  60219. /**
  60220. * Callback used to let the user override the color selection on a per mesh basis
  60221. */
  60222. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  60223. /**
  60224. * Callback used to let the user override the texture selection on a per mesh basis
  60225. */
  60226. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  60227. /**
  60228. * Instantiates a new glow Layer and references it to the scene.
  60229. * @param name The name of the layer
  60230. * @param scene The scene to use the layer in
  60231. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  60232. */
  60233. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  60234. /**
  60235. * Get the effect name of the layer.
  60236. * @return The effect name
  60237. */
  60238. getEffectName(): string;
  60239. /**
  60240. * Create the merge effect. This is the shader use to blit the information back
  60241. * to the main canvas at the end of the scene rendering.
  60242. */
  60243. protected _createMergeEffect(): Effect;
  60244. /**
  60245. * Creates the render target textures and post processes used in the glow layer.
  60246. */
  60247. protected _createTextureAndPostProcesses(): void;
  60248. /**
  60249. * Checks for the readiness of the element composing the layer.
  60250. * @param subMesh the mesh to check for
  60251. * @param useInstances specify wether or not to use instances to render the mesh
  60252. * @param emissiveTexture the associated emissive texture used to generate the glow
  60253. * @return true if ready otherwise, false
  60254. */
  60255. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  60256. /**
  60257. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  60258. */
  60259. needStencil(): boolean;
  60260. /**
  60261. * Returns true if the mesh can be rendered, otherwise false.
  60262. * @param mesh The mesh to render
  60263. * @param material The material used on the mesh
  60264. * @returns true if it can be rendered otherwise false
  60265. */
  60266. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  60267. /**
  60268. * Implementation specific of rendering the generating effect on the main canvas.
  60269. * @param effect The effect used to render through
  60270. */
  60271. protected _internalRender(effect: Effect): void;
  60272. /**
  60273. * Sets the required values for both the emissive texture and and the main color.
  60274. */
  60275. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  60276. /**
  60277. * Returns true if the mesh should render, otherwise false.
  60278. * @param mesh The mesh to render
  60279. * @returns true if it should render otherwise false
  60280. */
  60281. protected _shouldRenderMesh(mesh: Mesh): boolean;
  60282. /**
  60283. * Adds specific effects defines.
  60284. * @param defines The defines to add specifics to.
  60285. */
  60286. protected _addCustomEffectDefines(defines: string[]): void;
  60287. /**
  60288. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  60289. * @param mesh The mesh to exclude from the glow layer
  60290. */
  60291. addExcludedMesh(mesh: Mesh): void;
  60292. /**
  60293. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  60294. * @param mesh The mesh to remove
  60295. */
  60296. removeExcludedMesh(mesh: Mesh): void;
  60297. /**
  60298. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  60299. * @param mesh The mesh to include in the glow layer
  60300. */
  60301. addIncludedOnlyMesh(mesh: Mesh): void;
  60302. /**
  60303. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  60304. * @param mesh The mesh to remove
  60305. */
  60306. removeIncludedOnlyMesh(mesh: Mesh): void;
  60307. /**
  60308. * Determine if a given mesh will be used in the glow layer
  60309. * @param mesh The mesh to test
  60310. * @returns true if the mesh will be highlighted by the current glow layer
  60311. */
  60312. hasMesh(mesh: AbstractMesh): boolean;
  60313. /**
  60314. * Defines whether the current material of the mesh should be use to render the effect.
  60315. * @param mesh defines the current mesh to render
  60316. */
  60317. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  60318. /**
  60319. * Add a mesh to be rendered through its own material and not with emissive only.
  60320. * @param mesh The mesh for which we need to use its material
  60321. */
  60322. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  60323. /**
  60324. * Remove a mesh from being rendered through its own material and not with emissive only.
  60325. * @param mesh The mesh for which we need to not use its material
  60326. */
  60327. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  60328. /**
  60329. * Free any resources and references associated to a mesh.
  60330. * Internal use
  60331. * @param mesh The mesh to free.
  60332. * @hidden
  60333. */
  60334. _disposeMesh(mesh: Mesh): void;
  60335. /**
  60336. * Gets the class name of the effect layer
  60337. * @returns the string with the class name of the effect layer
  60338. */
  60339. getClassName(): string;
  60340. /**
  60341. * Serializes this glow layer
  60342. * @returns a serialized glow layer object
  60343. */
  60344. serialize(): any;
  60345. /**
  60346. * Creates a Glow Layer from parsed glow layer data
  60347. * @param parsedGlowLayer defines glow layer data
  60348. * @param scene defines the current scene
  60349. * @param rootUrl defines the root URL containing the glow layer information
  60350. * @returns a parsed Glow Layer
  60351. */
  60352. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  60353. }
  60354. }
  60355. declare module BABYLON {
  60356. /** @hidden */
  60357. export var glowBlurPostProcessPixelShader: {
  60358. name: string;
  60359. shader: string;
  60360. };
  60361. }
  60362. declare module BABYLON {
  60363. interface AbstractScene {
  60364. /**
  60365. * Return a the first highlight layer of the scene with a given name.
  60366. * @param name The name of the highlight layer to look for.
  60367. * @return The highlight layer if found otherwise null.
  60368. */
  60369. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  60370. }
  60371. /**
  60372. * Highlight layer options. This helps customizing the behaviour
  60373. * of the highlight layer.
  60374. */
  60375. export interface IHighlightLayerOptions {
  60376. /**
  60377. * Multiplication factor apply to the canvas size to compute the render target size
  60378. * used to generated the glowing objects (the smaller the faster).
  60379. */
  60380. mainTextureRatio: number;
  60381. /**
  60382. * Enforces a fixed size texture to ensure resize independant blur.
  60383. */
  60384. mainTextureFixedSize?: number;
  60385. /**
  60386. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  60387. * of the picture to blur (the smaller the faster).
  60388. */
  60389. blurTextureSizeRatio: number;
  60390. /**
  60391. * How big in texel of the blur texture is the vertical blur.
  60392. */
  60393. blurVerticalSize: number;
  60394. /**
  60395. * How big in texel of the blur texture is the horizontal blur.
  60396. */
  60397. blurHorizontalSize: number;
  60398. /**
  60399. * Alpha blending mode used to apply the blur. Default is combine.
  60400. */
  60401. alphaBlendingMode: number;
  60402. /**
  60403. * The camera attached to the layer.
  60404. */
  60405. camera: Nullable<Camera>;
  60406. /**
  60407. * Should we display highlight as a solid stroke?
  60408. */
  60409. isStroke?: boolean;
  60410. /**
  60411. * The rendering group to draw the layer in.
  60412. */
  60413. renderingGroupId: number;
  60414. }
  60415. /**
  60416. * The highlight layer Helps adding a glow effect around a mesh.
  60417. *
  60418. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  60419. * glowy meshes to your scene.
  60420. *
  60421. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  60422. */
  60423. export class HighlightLayer extends EffectLayer {
  60424. name: string;
  60425. /**
  60426. * Effect Name of the highlight layer.
  60427. */
  60428. static readonly EffectName: string;
  60429. /**
  60430. * The neutral color used during the preparation of the glow effect.
  60431. * This is black by default as the blend operation is a blend operation.
  60432. */
  60433. static NeutralColor: Color4;
  60434. /**
  60435. * Stencil value used for glowing meshes.
  60436. */
  60437. static GlowingMeshStencilReference: number;
  60438. /**
  60439. * Stencil value used for the other meshes in the scene.
  60440. */
  60441. static NormalMeshStencilReference: number;
  60442. /**
  60443. * Specifies whether or not the inner glow is ACTIVE in the layer.
  60444. */
  60445. innerGlow: boolean;
  60446. /**
  60447. * Specifies whether or not the outer glow is ACTIVE in the layer.
  60448. */
  60449. outerGlow: boolean;
  60450. /**
  60451. * Specifies the horizontal size of the blur.
  60452. */
  60453. set blurHorizontalSize(value: number);
  60454. /**
  60455. * Specifies the vertical size of the blur.
  60456. */
  60457. set blurVerticalSize(value: number);
  60458. /**
  60459. * Gets the horizontal size of the blur.
  60460. */
  60461. get blurHorizontalSize(): number;
  60462. /**
  60463. * Gets the vertical size of the blur.
  60464. */
  60465. get blurVerticalSize(): number;
  60466. /**
  60467. * An event triggered when the highlight layer is being blurred.
  60468. */
  60469. onBeforeBlurObservable: Observable<HighlightLayer>;
  60470. /**
  60471. * An event triggered when the highlight layer has been blurred.
  60472. */
  60473. onAfterBlurObservable: Observable<HighlightLayer>;
  60474. private _instanceGlowingMeshStencilReference;
  60475. private _options;
  60476. private _downSamplePostprocess;
  60477. private _horizontalBlurPostprocess;
  60478. private _verticalBlurPostprocess;
  60479. private _blurTexture;
  60480. private _meshes;
  60481. private _excludedMeshes;
  60482. /**
  60483. * Instantiates a new highlight Layer and references it to the scene..
  60484. * @param name The name of the layer
  60485. * @param scene The scene to use the layer in
  60486. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  60487. */
  60488. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  60489. /**
  60490. * Get the effect name of the layer.
  60491. * @return The effect name
  60492. */
  60493. getEffectName(): string;
  60494. /**
  60495. * Create the merge effect. This is the shader use to blit the information back
  60496. * to the main canvas at the end of the scene rendering.
  60497. */
  60498. protected _createMergeEffect(): Effect;
  60499. /**
  60500. * Creates the render target textures and post processes used in the highlight layer.
  60501. */
  60502. protected _createTextureAndPostProcesses(): void;
  60503. /**
  60504. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  60505. */
  60506. needStencil(): boolean;
  60507. /**
  60508. * Checks for the readiness of the element composing the layer.
  60509. * @param subMesh the mesh to check for
  60510. * @param useInstances specify wether or not to use instances to render the mesh
  60511. * @param emissiveTexture the associated emissive texture used to generate the glow
  60512. * @return true if ready otherwise, false
  60513. */
  60514. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  60515. /**
  60516. * Implementation specific of rendering the generating effect on the main canvas.
  60517. * @param effect The effect used to render through
  60518. */
  60519. protected _internalRender(effect: Effect): void;
  60520. /**
  60521. * Returns true if the layer contains information to display, otherwise false.
  60522. */
  60523. shouldRender(): boolean;
  60524. /**
  60525. * Returns true if the mesh should render, otherwise false.
  60526. * @param mesh The mesh to render
  60527. * @returns true if it should render otherwise false
  60528. */
  60529. protected _shouldRenderMesh(mesh: Mesh): boolean;
  60530. /**
  60531. * Returns true if the mesh can be rendered, otherwise false.
  60532. * @param mesh The mesh to render
  60533. * @param material The material used on the mesh
  60534. * @returns true if it can be rendered otherwise false
  60535. */
  60536. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  60537. /**
  60538. * Adds specific effects defines.
  60539. * @param defines The defines to add specifics to.
  60540. */
  60541. protected _addCustomEffectDefines(defines: string[]): void;
  60542. /**
  60543. * Sets the required values for both the emissive texture and and the main color.
  60544. */
  60545. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  60546. /**
  60547. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  60548. * @param mesh The mesh to exclude from the highlight layer
  60549. */
  60550. addExcludedMesh(mesh: Mesh): void;
  60551. /**
  60552. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  60553. * @param mesh The mesh to highlight
  60554. */
  60555. removeExcludedMesh(mesh: Mesh): void;
  60556. /**
  60557. * Determine if a given mesh will be highlighted by the current HighlightLayer
  60558. * @param mesh mesh to test
  60559. * @returns true if the mesh will be highlighted by the current HighlightLayer
  60560. */
  60561. hasMesh(mesh: AbstractMesh): boolean;
  60562. /**
  60563. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  60564. * @param mesh The mesh to highlight
  60565. * @param color The color of the highlight
  60566. * @param glowEmissiveOnly Extract the glow from the emissive texture
  60567. */
  60568. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  60569. /**
  60570. * Remove a mesh from the highlight layer in order to make it stop glowing.
  60571. * @param mesh The mesh to highlight
  60572. */
  60573. removeMesh(mesh: Mesh): void;
  60574. /**
  60575. * Remove all the meshes currently referenced in the highlight layer
  60576. */
  60577. removeAllMeshes(): void;
  60578. /**
  60579. * Force the stencil to the normal expected value for none glowing parts
  60580. */
  60581. private _defaultStencilReference;
  60582. /**
  60583. * Free any resources and references associated to a mesh.
  60584. * Internal use
  60585. * @param mesh The mesh to free.
  60586. * @hidden
  60587. */
  60588. _disposeMesh(mesh: Mesh): void;
  60589. /**
  60590. * Dispose the highlight layer and free resources.
  60591. */
  60592. dispose(): void;
  60593. /**
  60594. * Gets the class name of the effect layer
  60595. * @returns the string with the class name of the effect layer
  60596. */
  60597. getClassName(): string;
  60598. /**
  60599. * Serializes this Highlight layer
  60600. * @returns a serialized Highlight layer object
  60601. */
  60602. serialize(): any;
  60603. /**
  60604. * Creates a Highlight layer from parsed Highlight layer data
  60605. * @param parsedHightlightLayer defines the Highlight layer data
  60606. * @param scene defines the current scene
  60607. * @param rootUrl defines the root URL containing the Highlight layer information
  60608. * @returns a parsed Highlight layer
  60609. */
  60610. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  60611. }
  60612. }
  60613. declare module BABYLON {
  60614. interface AbstractScene {
  60615. /**
  60616. * The list of layers (background and foreground) of the scene
  60617. */
  60618. layers: Array<Layer>;
  60619. }
  60620. /**
  60621. * Defines the layer scene component responsible to manage any layers
  60622. * in a given scene.
  60623. */
  60624. export class LayerSceneComponent implements ISceneComponent {
  60625. /**
  60626. * The component name helpfull to identify the component in the list of scene components.
  60627. */
  60628. readonly name: string;
  60629. /**
  60630. * The scene the component belongs to.
  60631. */
  60632. scene: Scene;
  60633. private _engine;
  60634. /**
  60635. * Creates a new instance of the component for the given scene
  60636. * @param scene Defines the scene to register the component in
  60637. */
  60638. constructor(scene: Scene);
  60639. /**
  60640. * Registers the component in a given scene
  60641. */
  60642. register(): void;
  60643. /**
  60644. * Rebuilds the elements related to this component in case of
  60645. * context lost for instance.
  60646. */
  60647. rebuild(): void;
  60648. /**
  60649. * Disposes the component and the associated ressources.
  60650. */
  60651. dispose(): void;
  60652. private _draw;
  60653. private _drawCameraPredicate;
  60654. private _drawCameraBackground;
  60655. private _drawCameraForeground;
  60656. private _drawRenderTargetPredicate;
  60657. private _drawRenderTargetBackground;
  60658. private _drawRenderTargetForeground;
  60659. /**
  60660. * Adds all the elements from the container to the scene
  60661. * @param container the container holding the elements
  60662. */
  60663. addFromContainer(container: AbstractScene): void;
  60664. /**
  60665. * Removes all the elements in the container from the scene
  60666. * @param container contains the elements to remove
  60667. * @param dispose if the removed element should be disposed (default: false)
  60668. */
  60669. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  60670. }
  60671. }
  60672. declare module BABYLON {
  60673. /** @hidden */
  60674. export var layerPixelShader: {
  60675. name: string;
  60676. shader: string;
  60677. };
  60678. }
  60679. declare module BABYLON {
  60680. /** @hidden */
  60681. export var layerVertexShader: {
  60682. name: string;
  60683. shader: string;
  60684. };
  60685. }
  60686. declare module BABYLON {
  60687. /**
  60688. * This represents a full screen 2d layer.
  60689. * This can be useful to display a picture in the background of your scene for instance.
  60690. * @see https://www.babylonjs-playground.com/#08A2BS#1
  60691. */
  60692. export class Layer {
  60693. /**
  60694. * Define the name of the layer.
  60695. */
  60696. name: string;
  60697. /**
  60698. * Define the texture the layer should display.
  60699. */
  60700. texture: Nullable<Texture>;
  60701. /**
  60702. * Is the layer in background or foreground.
  60703. */
  60704. isBackground: boolean;
  60705. /**
  60706. * Define the color of the layer (instead of texture).
  60707. */
  60708. color: Color4;
  60709. /**
  60710. * Define the scale of the layer in order to zoom in out of the texture.
  60711. */
  60712. scale: Vector2;
  60713. /**
  60714. * Define an offset for the layer in order to shift the texture.
  60715. */
  60716. offset: Vector2;
  60717. /**
  60718. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  60719. */
  60720. alphaBlendingMode: number;
  60721. /**
  60722. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  60723. * Alpha test will not mix with the background color in case of transparency.
  60724. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  60725. */
  60726. alphaTest: boolean;
  60727. /**
  60728. * Define a mask to restrict the layer to only some of the scene cameras.
  60729. */
  60730. layerMask: number;
  60731. /**
  60732. * Define the list of render target the layer is visible into.
  60733. */
  60734. renderTargetTextures: RenderTargetTexture[];
  60735. /**
  60736. * Define if the layer is only used in renderTarget or if it also
  60737. * renders in the main frame buffer of the canvas.
  60738. */
  60739. renderOnlyInRenderTargetTextures: boolean;
  60740. private _scene;
  60741. private _vertexBuffers;
  60742. private _indexBuffer;
  60743. private _effect;
  60744. private _previousDefines;
  60745. /**
  60746. * An event triggered when the layer is disposed.
  60747. */
  60748. onDisposeObservable: Observable<Layer>;
  60749. private _onDisposeObserver;
  60750. /**
  60751. * Back compatibility with callback before the onDisposeObservable existed.
  60752. * The set callback will be triggered when the layer has been disposed.
  60753. */
  60754. set onDispose(callback: () => void);
  60755. /**
  60756. * An event triggered before rendering the scene
  60757. */
  60758. onBeforeRenderObservable: Observable<Layer>;
  60759. private _onBeforeRenderObserver;
  60760. /**
  60761. * Back compatibility with callback before the onBeforeRenderObservable existed.
  60762. * The set callback will be triggered just before rendering the layer.
  60763. */
  60764. set onBeforeRender(callback: () => void);
  60765. /**
  60766. * An event triggered after rendering the scene
  60767. */
  60768. onAfterRenderObservable: Observable<Layer>;
  60769. private _onAfterRenderObserver;
  60770. /**
  60771. * Back compatibility with callback before the onAfterRenderObservable existed.
  60772. * The set callback will be triggered just after rendering the layer.
  60773. */
  60774. set onAfterRender(callback: () => void);
  60775. /**
  60776. * Instantiates a new layer.
  60777. * This represents a full screen 2d layer.
  60778. * This can be useful to display a picture in the background of your scene for instance.
  60779. * @see https://www.babylonjs-playground.com/#08A2BS#1
  60780. * @param name Define the name of the layer in the scene
  60781. * @param imgUrl Define the url of the texture to display in the layer
  60782. * @param scene Define the scene the layer belongs to
  60783. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  60784. * @param color Defines a color for the layer
  60785. */
  60786. constructor(
  60787. /**
  60788. * Define the name of the layer.
  60789. */
  60790. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  60791. private _createIndexBuffer;
  60792. /** @hidden */
  60793. _rebuild(): void;
  60794. /**
  60795. * Renders the layer in the scene.
  60796. */
  60797. render(): void;
  60798. /**
  60799. * Disposes and releases the associated ressources.
  60800. */
  60801. dispose(): void;
  60802. }
  60803. }
  60804. declare module BABYLON {
  60805. /** @hidden */
  60806. export var lensFlarePixelShader: {
  60807. name: string;
  60808. shader: string;
  60809. };
  60810. }
  60811. declare module BABYLON {
  60812. /** @hidden */
  60813. export var lensFlareVertexShader: {
  60814. name: string;
  60815. shader: string;
  60816. };
  60817. }
  60818. declare module BABYLON {
  60819. /**
  60820. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  60821. * It is usually composed of several `lensFlare`.
  60822. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60823. */
  60824. export class LensFlareSystem {
  60825. /**
  60826. * Define the name of the lens flare system
  60827. */
  60828. name: string;
  60829. /**
  60830. * List of lens flares used in this system.
  60831. */
  60832. lensFlares: LensFlare[];
  60833. /**
  60834. * Define a limit from the border the lens flare can be visible.
  60835. */
  60836. borderLimit: number;
  60837. /**
  60838. * Define a viewport border we do not want to see the lens flare in.
  60839. */
  60840. viewportBorder: number;
  60841. /**
  60842. * Define a predicate which could limit the list of meshes able to occlude the effect.
  60843. */
  60844. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  60845. /**
  60846. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  60847. */
  60848. layerMask: number;
  60849. /**
  60850. * Define the id of the lens flare system in the scene.
  60851. * (equal to name by default)
  60852. */
  60853. id: string;
  60854. private _scene;
  60855. private _emitter;
  60856. private _vertexBuffers;
  60857. private _indexBuffer;
  60858. private _effect;
  60859. private _positionX;
  60860. private _positionY;
  60861. private _isEnabled;
  60862. /** @hidden */
  60863. static _SceneComponentInitialization: (scene: Scene) => void;
  60864. /**
  60865. * Instantiates a lens flare system.
  60866. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  60867. * It is usually composed of several `lensFlare`.
  60868. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60869. * @param name Define the name of the lens flare system in the scene
  60870. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  60871. * @param scene Define the scene the lens flare system belongs to
  60872. */
  60873. constructor(
  60874. /**
  60875. * Define the name of the lens flare system
  60876. */
  60877. name: string, emitter: any, scene: Scene);
  60878. /**
  60879. * Define if the lens flare system is enabled.
  60880. */
  60881. get isEnabled(): boolean;
  60882. set isEnabled(value: boolean);
  60883. /**
  60884. * Get the scene the effects belongs to.
  60885. * @returns the scene holding the lens flare system
  60886. */
  60887. getScene(): Scene;
  60888. /**
  60889. * Get the emitter of the lens flare system.
  60890. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  60891. * @returns the emitter of the lens flare system
  60892. */
  60893. getEmitter(): any;
  60894. /**
  60895. * Set the emitter of the lens flare system.
  60896. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  60897. * @param newEmitter Define the new emitter of the system
  60898. */
  60899. setEmitter(newEmitter: any): void;
  60900. /**
  60901. * Get the lens flare system emitter position.
  60902. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  60903. * @returns the position
  60904. */
  60905. getEmitterPosition(): Vector3;
  60906. /**
  60907. * @hidden
  60908. */
  60909. computeEffectivePosition(globalViewport: Viewport): boolean;
  60910. /** @hidden */
  60911. _isVisible(): boolean;
  60912. /**
  60913. * @hidden
  60914. */
  60915. render(): boolean;
  60916. /**
  60917. * Dispose and release the lens flare with its associated resources.
  60918. */
  60919. dispose(): void;
  60920. /**
  60921. * Parse a lens flare system from a JSON repressentation
  60922. * @param parsedLensFlareSystem Define the JSON to parse
  60923. * @param scene Define the scene the parsed system should be instantiated in
  60924. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  60925. * @returns the parsed system
  60926. */
  60927. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  60928. /**
  60929. * Serialize the current Lens Flare System into a JSON representation.
  60930. * @returns the serialized JSON
  60931. */
  60932. serialize(): any;
  60933. }
  60934. }
  60935. declare module BABYLON {
  60936. /**
  60937. * This represents one of the lens effect in a `lensFlareSystem`.
  60938. * It controls one of the indiviual texture used in the effect.
  60939. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60940. */
  60941. export class LensFlare {
  60942. /**
  60943. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  60944. */
  60945. size: number;
  60946. /**
  60947. * 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.
  60948. */
  60949. position: number;
  60950. /**
  60951. * Define the lens color.
  60952. */
  60953. color: Color3;
  60954. /**
  60955. * Define the lens texture.
  60956. */
  60957. texture: Nullable<Texture>;
  60958. /**
  60959. * Define the alpha mode to render this particular lens.
  60960. */
  60961. alphaMode: number;
  60962. private _system;
  60963. /**
  60964. * Creates a new Lens Flare.
  60965. * This represents one of the lens effect in a `lensFlareSystem`.
  60966. * It controls one of the indiviual texture used in the effect.
  60967. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60968. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  60969. * @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.
  60970. * @param color Define the lens color
  60971. * @param imgUrl Define the lens texture url
  60972. * @param system Define the `lensFlareSystem` this flare is part of
  60973. * @returns The newly created Lens Flare
  60974. */
  60975. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  60976. /**
  60977. * Instantiates a new Lens Flare.
  60978. * This represents one of the lens effect in a `lensFlareSystem`.
  60979. * It controls one of the indiviual texture used in the effect.
  60980. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60981. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  60982. * @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.
  60983. * @param color Define the lens color
  60984. * @param imgUrl Define the lens texture url
  60985. * @param system Define the `lensFlareSystem` this flare is part of
  60986. */
  60987. constructor(
  60988. /**
  60989. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  60990. */
  60991. size: number,
  60992. /**
  60993. * 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.
  60994. */
  60995. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  60996. /**
  60997. * Dispose and release the lens flare with its associated resources.
  60998. */
  60999. dispose(): void;
  61000. }
  61001. }
  61002. declare module BABYLON {
  61003. interface AbstractScene {
  61004. /**
  61005. * The list of lens flare system added to the scene
  61006. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  61007. */
  61008. lensFlareSystems: Array<LensFlareSystem>;
  61009. /**
  61010. * Removes the given lens flare system from this scene.
  61011. * @param toRemove The lens flare system to remove
  61012. * @returns The index of the removed lens flare system
  61013. */
  61014. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  61015. /**
  61016. * Adds the given lens flare system to this scene
  61017. * @param newLensFlareSystem The lens flare system to add
  61018. */
  61019. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  61020. /**
  61021. * Gets a lens flare system using its name
  61022. * @param name defines the name to look for
  61023. * @returns the lens flare system or null if not found
  61024. */
  61025. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  61026. /**
  61027. * Gets a lens flare system using its id
  61028. * @param id defines the id to look for
  61029. * @returns the lens flare system or null if not found
  61030. */
  61031. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  61032. }
  61033. /**
  61034. * Defines the lens flare scene component responsible to manage any lens flares
  61035. * in a given scene.
  61036. */
  61037. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  61038. /**
  61039. * The component name helpfull to identify the component in the list of scene components.
  61040. */
  61041. readonly name: string;
  61042. /**
  61043. * The scene the component belongs to.
  61044. */
  61045. scene: Scene;
  61046. /**
  61047. * Creates a new instance of the component for the given scene
  61048. * @param scene Defines the scene to register the component in
  61049. */
  61050. constructor(scene: Scene);
  61051. /**
  61052. * Registers the component in a given scene
  61053. */
  61054. register(): void;
  61055. /**
  61056. * Rebuilds the elements related to this component in case of
  61057. * context lost for instance.
  61058. */
  61059. rebuild(): void;
  61060. /**
  61061. * Adds all the elements from the container to the scene
  61062. * @param container the container holding the elements
  61063. */
  61064. addFromContainer(container: AbstractScene): void;
  61065. /**
  61066. * Removes all the elements in the container from the scene
  61067. * @param container contains the elements to remove
  61068. * @param dispose if the removed element should be disposed (default: false)
  61069. */
  61070. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  61071. /**
  61072. * Serializes the component data to the specified json object
  61073. * @param serializationObject The object to serialize to
  61074. */
  61075. serialize(serializationObject: any): void;
  61076. /**
  61077. * Disposes the component and the associated ressources.
  61078. */
  61079. dispose(): void;
  61080. private _draw;
  61081. }
  61082. }
  61083. declare module BABYLON {
  61084. /** @hidden */
  61085. export var depthPixelShader: {
  61086. name: string;
  61087. shader: string;
  61088. };
  61089. }
  61090. declare module BABYLON {
  61091. /** @hidden */
  61092. export var depthVertexShader: {
  61093. name: string;
  61094. shader: string;
  61095. };
  61096. }
  61097. declare module BABYLON {
  61098. /**
  61099. * This represents a depth renderer in Babylon.
  61100. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  61101. */
  61102. export class DepthRenderer {
  61103. private _scene;
  61104. private _depthMap;
  61105. private _effect;
  61106. private readonly _storeNonLinearDepth;
  61107. private readonly _clearColor;
  61108. /** Get if the depth renderer is using packed depth or not */
  61109. readonly isPacked: boolean;
  61110. private _cachedDefines;
  61111. private _camera;
  61112. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  61113. enabled: boolean;
  61114. /**
  61115. * Specifiess that the depth renderer will only be used within
  61116. * the camera it is created for.
  61117. * This can help forcing its rendering during the camera processing.
  61118. */
  61119. useOnlyInActiveCamera: boolean;
  61120. /** @hidden */
  61121. static _SceneComponentInitialization: (scene: Scene) => void;
  61122. /**
  61123. * Instantiates a depth renderer
  61124. * @param scene The scene the renderer belongs to
  61125. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  61126. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  61127. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  61128. */
  61129. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  61130. /**
  61131. * Creates the depth rendering effect and checks if the effect is ready.
  61132. * @param subMesh The submesh to be used to render the depth map of
  61133. * @param useInstances If multiple world instances should be used
  61134. * @returns if the depth renderer is ready to render the depth map
  61135. */
  61136. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  61137. /**
  61138. * Gets the texture which the depth map will be written to.
  61139. * @returns The depth map texture
  61140. */
  61141. getDepthMap(): RenderTargetTexture;
  61142. /**
  61143. * Disposes of the depth renderer.
  61144. */
  61145. dispose(): void;
  61146. }
  61147. }
  61148. declare module BABYLON {
  61149. /** @hidden */
  61150. export var minmaxReduxPixelShader: {
  61151. name: string;
  61152. shader: string;
  61153. };
  61154. }
  61155. declare module BABYLON {
  61156. /**
  61157. * This class computes a min/max reduction from a texture: it means it computes the minimum
  61158. * and maximum values from all values of the texture.
  61159. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  61160. * The source values are read from the red channel of the texture.
  61161. */
  61162. export class MinMaxReducer {
  61163. /**
  61164. * Observable triggered when the computation has been performed
  61165. */
  61166. onAfterReductionPerformed: Observable<{
  61167. min: number;
  61168. max: number;
  61169. }>;
  61170. protected _camera: Camera;
  61171. protected _sourceTexture: Nullable<RenderTargetTexture>;
  61172. protected _reductionSteps: Nullable<Array<PostProcess>>;
  61173. protected _postProcessManager: PostProcessManager;
  61174. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  61175. protected _forceFullscreenViewport: boolean;
  61176. /**
  61177. * Creates a min/max reducer
  61178. * @param camera The camera to use for the post processes
  61179. */
  61180. constructor(camera: Camera);
  61181. /**
  61182. * Gets the texture used to read the values from.
  61183. */
  61184. get sourceTexture(): Nullable<RenderTargetTexture>;
  61185. /**
  61186. * Sets the source texture to read the values from.
  61187. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  61188. * because in such textures '1' value must not be taken into account to compute the maximum
  61189. * as this value is used to clear the texture.
  61190. * Note that the computation is not activated by calling this function, you must call activate() for that!
  61191. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  61192. * @param depthRedux Indicates if the texture is a depth texture or not
  61193. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  61194. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  61195. */
  61196. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  61197. /**
  61198. * Defines the refresh rate of the computation.
  61199. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  61200. */
  61201. get refreshRate(): number;
  61202. set refreshRate(value: number);
  61203. protected _activated: boolean;
  61204. /**
  61205. * Gets the activation status of the reducer
  61206. */
  61207. get activated(): boolean;
  61208. /**
  61209. * Activates the reduction computation.
  61210. * When activated, the observers registered in onAfterReductionPerformed are
  61211. * called after the compuation is performed
  61212. */
  61213. activate(): void;
  61214. /**
  61215. * Deactivates the reduction computation.
  61216. */
  61217. deactivate(): void;
  61218. /**
  61219. * Disposes the min/max reducer
  61220. * @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.
  61221. */
  61222. dispose(disposeAll?: boolean): void;
  61223. }
  61224. }
  61225. declare module BABYLON {
  61226. /**
  61227. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  61228. */
  61229. export class DepthReducer extends MinMaxReducer {
  61230. private _depthRenderer;
  61231. private _depthRendererId;
  61232. /**
  61233. * Gets the depth renderer used for the computation.
  61234. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  61235. */
  61236. get depthRenderer(): Nullable<DepthRenderer>;
  61237. /**
  61238. * Creates a depth reducer
  61239. * @param camera The camera used to render the depth texture
  61240. */
  61241. constructor(camera: Camera);
  61242. /**
  61243. * Sets the depth renderer to use to generate the depth map
  61244. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  61245. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  61246. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  61247. */
  61248. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  61249. /** @hidden */
  61250. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  61251. /**
  61252. * Activates the reduction computation.
  61253. * When activated, the observers registered in onAfterReductionPerformed are
  61254. * called after the compuation is performed
  61255. */
  61256. activate(): void;
  61257. /**
  61258. * Deactivates the reduction computation.
  61259. */
  61260. deactivate(): void;
  61261. /**
  61262. * Disposes the depth reducer
  61263. * @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.
  61264. */
  61265. dispose(disposeAll?: boolean): void;
  61266. }
  61267. }
  61268. declare module BABYLON {
  61269. /**
  61270. * A CSM implementation allowing casting shadows on large scenes.
  61271. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  61272. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  61273. */
  61274. export class CascadedShadowGenerator extends ShadowGenerator {
  61275. private static readonly frustumCornersNDCSpace;
  61276. /**
  61277. * Name of the CSM class
  61278. */
  61279. static CLASSNAME: string;
  61280. /**
  61281. * Defines the default number of cascades used by the CSM.
  61282. */
  61283. static readonly DEFAULT_CASCADES_COUNT: number;
  61284. /**
  61285. * Defines the minimum number of cascades used by the CSM.
  61286. */
  61287. static readonly MIN_CASCADES_COUNT: number;
  61288. /**
  61289. * Defines the maximum number of cascades used by the CSM.
  61290. */
  61291. static readonly MAX_CASCADES_COUNT: number;
  61292. protected _validateFilter(filter: number): number;
  61293. /**
  61294. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  61295. */
  61296. penumbraDarkness: number;
  61297. private _numCascades;
  61298. /**
  61299. * Gets or set the number of cascades used by the CSM.
  61300. */
  61301. get numCascades(): number;
  61302. set numCascades(value: number);
  61303. /**
  61304. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  61305. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  61306. */
  61307. stabilizeCascades: boolean;
  61308. private _freezeShadowCastersBoundingInfo;
  61309. private _freezeShadowCastersBoundingInfoObservable;
  61310. /**
  61311. * Enables or disables the shadow casters bounding info computation.
  61312. * If your shadow casters don't move, you can disable this feature.
  61313. * If it is enabled, the bounding box computation is done every frame.
  61314. */
  61315. get freezeShadowCastersBoundingInfo(): boolean;
  61316. set freezeShadowCastersBoundingInfo(freeze: boolean);
  61317. private _scbiMin;
  61318. private _scbiMax;
  61319. protected _computeShadowCastersBoundingInfo(): void;
  61320. protected _shadowCastersBoundingInfo: BoundingInfo;
  61321. /**
  61322. * Gets or sets the shadow casters bounding info.
  61323. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  61324. * so that the system won't overwrite the bounds you provide
  61325. */
  61326. get shadowCastersBoundingInfo(): BoundingInfo;
  61327. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  61328. protected _breaksAreDirty: boolean;
  61329. protected _minDistance: number;
  61330. protected _maxDistance: number;
  61331. /**
  61332. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  61333. *
  61334. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  61335. * If you don't know these values, simply leave them to their defaults and don't call this function.
  61336. * @param min minimal distance for the breaks (default to 0.)
  61337. * @param max maximal distance for the breaks (default to 1.)
  61338. */
  61339. setMinMaxDistance(min: number, max: number): void;
  61340. /** Gets the minimal distance used in the cascade break computation */
  61341. get minDistance(): number;
  61342. /** Gets the maximal distance used in the cascade break computation */
  61343. get maxDistance(): number;
  61344. /**
  61345. * Gets the class name of that object
  61346. * @returns "CascadedShadowGenerator"
  61347. */
  61348. getClassName(): string;
  61349. private _cascadeMinExtents;
  61350. private _cascadeMaxExtents;
  61351. /**
  61352. * Gets a cascade minimum extents
  61353. * @param cascadeIndex index of the cascade
  61354. * @returns the minimum cascade extents
  61355. */
  61356. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  61357. /**
  61358. * Gets a cascade maximum extents
  61359. * @param cascadeIndex index of the cascade
  61360. * @returns the maximum cascade extents
  61361. */
  61362. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  61363. private _cascades;
  61364. private _currentLayer;
  61365. private _viewSpaceFrustumsZ;
  61366. private _viewMatrices;
  61367. private _projectionMatrices;
  61368. private _transformMatrices;
  61369. private _transformMatricesAsArray;
  61370. private _frustumLengths;
  61371. private _lightSizeUVCorrection;
  61372. private _depthCorrection;
  61373. private _frustumCornersWorldSpace;
  61374. private _frustumCenter;
  61375. private _shadowCameraPos;
  61376. private _shadowMaxZ;
  61377. /**
  61378. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  61379. * It defaults to camera.maxZ
  61380. */
  61381. get shadowMaxZ(): number;
  61382. /**
  61383. * Sets the shadow max z distance.
  61384. */
  61385. set shadowMaxZ(value: number);
  61386. protected _debug: boolean;
  61387. /**
  61388. * Gets or sets the debug flag.
  61389. * When enabled, the cascades are materialized by different colors on the screen.
  61390. */
  61391. get debug(): boolean;
  61392. set debug(dbg: boolean);
  61393. private _depthClamp;
  61394. /**
  61395. * Gets or sets the depth clamping value.
  61396. *
  61397. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  61398. * to account for the shadow casters far away.
  61399. *
  61400. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  61401. */
  61402. get depthClamp(): boolean;
  61403. set depthClamp(value: boolean);
  61404. private _cascadeBlendPercentage;
  61405. /**
  61406. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  61407. * It defaults to 0.1 (10% blending).
  61408. */
  61409. get cascadeBlendPercentage(): number;
  61410. set cascadeBlendPercentage(value: number);
  61411. private _lambda;
  61412. /**
  61413. * Gets or set the lambda parameter.
  61414. * This parameter is used to split the camera frustum and create the cascades.
  61415. * 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.
  61416. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  61417. */
  61418. get lambda(): number;
  61419. set lambda(value: number);
  61420. /**
  61421. * Gets the view matrix corresponding to a given cascade
  61422. * @param cascadeNum cascade to retrieve the view matrix from
  61423. * @returns the cascade view matrix
  61424. */
  61425. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  61426. /**
  61427. * Gets the projection matrix corresponding to a given cascade
  61428. * @param cascadeNum cascade to retrieve the projection matrix from
  61429. * @returns the cascade projection matrix
  61430. */
  61431. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  61432. /**
  61433. * Gets the transformation matrix corresponding to a given cascade
  61434. * @param cascadeNum cascade to retrieve the transformation matrix from
  61435. * @returns the cascade transformation matrix
  61436. */
  61437. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  61438. private _depthRenderer;
  61439. /**
  61440. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  61441. *
  61442. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  61443. *
  61444. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  61445. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  61446. * @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
  61447. */
  61448. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  61449. private _depthReducer;
  61450. private _autoCalcDepthBounds;
  61451. /**
  61452. * Gets or sets the autoCalcDepthBounds property.
  61453. *
  61454. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  61455. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  61456. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  61457. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  61458. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  61459. */
  61460. get autoCalcDepthBounds(): boolean;
  61461. set autoCalcDepthBounds(value: boolean);
  61462. /**
  61463. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  61464. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  61465. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  61466. * for setting the refresh rate on the renderer yourself!
  61467. */
  61468. get autoCalcDepthBoundsRefreshRate(): number;
  61469. set autoCalcDepthBoundsRefreshRate(value: number);
  61470. /**
  61471. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  61472. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  61473. * you change the camera near/far planes!
  61474. */
  61475. splitFrustum(): void;
  61476. private _splitFrustum;
  61477. private _computeMatrices;
  61478. private _computeFrustumInWorldSpace;
  61479. private _computeCascadeFrustum;
  61480. /**
  61481. * Support test.
  61482. */
  61483. static get IsSupported(): boolean;
  61484. /** @hidden */
  61485. static _SceneComponentInitialization: (scene: Scene) => void;
  61486. /**
  61487. * Creates a Cascaded Shadow Generator object.
  61488. * A ShadowGenerator is the required tool to use the shadows.
  61489. * Each directional light casting shadows needs to use its own ShadowGenerator.
  61490. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  61491. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  61492. * @param light The directional light object generating the shadows.
  61493. * @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.
  61494. */
  61495. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  61496. protected _initializeGenerator(): void;
  61497. protected _createTargetRenderTexture(): void;
  61498. protected _initializeShadowMap(): void;
  61499. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  61500. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  61501. /**
  61502. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  61503. * @param defines Defines of the material we want to update
  61504. * @param lightIndex Index of the light in the enabled light list of the material
  61505. */
  61506. prepareDefines(defines: any, lightIndex: number): void;
  61507. /**
  61508. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  61509. * defined in the generator but impacting the effect).
  61510. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  61511. * @param effect The effect we are binfing the information for
  61512. */
  61513. bindShadowLight(lightIndex: string, effect: Effect): void;
  61514. /**
  61515. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  61516. * (eq to view projection * shadow projection matrices)
  61517. * @returns The transform matrix used to create the shadow map
  61518. */
  61519. getTransformMatrix(): Matrix;
  61520. /**
  61521. * Disposes the ShadowGenerator.
  61522. * Returns nothing.
  61523. */
  61524. dispose(): void;
  61525. /**
  61526. * Serializes the shadow generator setup to a json object.
  61527. * @returns The serialized JSON object
  61528. */
  61529. serialize(): any;
  61530. /**
  61531. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  61532. * @param parsedShadowGenerator The JSON object to parse
  61533. * @param scene The scene to create the shadow map for
  61534. * @returns The parsed shadow generator
  61535. */
  61536. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  61537. }
  61538. }
  61539. declare module BABYLON {
  61540. /**
  61541. * Defines the shadow generator component responsible to manage any shadow generators
  61542. * in a given scene.
  61543. */
  61544. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  61545. /**
  61546. * The component name helpfull to identify the component in the list of scene components.
  61547. */
  61548. readonly name: string;
  61549. /**
  61550. * The scene the component belongs to.
  61551. */
  61552. scene: Scene;
  61553. /**
  61554. * Creates a new instance of the component for the given scene
  61555. * @param scene Defines the scene to register the component in
  61556. */
  61557. constructor(scene: Scene);
  61558. /**
  61559. * Registers the component in a given scene
  61560. */
  61561. register(): void;
  61562. /**
  61563. * Rebuilds the elements related to this component in case of
  61564. * context lost for instance.
  61565. */
  61566. rebuild(): void;
  61567. /**
  61568. * Serializes the component data to the specified json object
  61569. * @param serializationObject The object to serialize to
  61570. */
  61571. serialize(serializationObject: any): void;
  61572. /**
  61573. * Adds all the elements from the container to the scene
  61574. * @param container the container holding the elements
  61575. */
  61576. addFromContainer(container: AbstractScene): void;
  61577. /**
  61578. * Removes all the elements in the container from the scene
  61579. * @param container contains the elements to remove
  61580. * @param dispose if the removed element should be disposed (default: false)
  61581. */
  61582. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  61583. /**
  61584. * Rebuilds the elements related to this component in case of
  61585. * context lost for instance.
  61586. */
  61587. dispose(): void;
  61588. private _gatherRenderTargets;
  61589. }
  61590. }
  61591. declare module BABYLON {
  61592. /**
  61593. * A point light is a light defined by an unique point in world space.
  61594. * The light is emitted in every direction from this point.
  61595. * A good example of a point light is a standard light bulb.
  61596. * Documentation: https://doc.babylonjs.com/babylon101/lights
  61597. */
  61598. export class PointLight extends ShadowLight {
  61599. private _shadowAngle;
  61600. /**
  61601. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  61602. * This specifies what angle the shadow will use to be created.
  61603. *
  61604. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  61605. */
  61606. get shadowAngle(): number;
  61607. /**
  61608. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  61609. * This specifies what angle the shadow will use to be created.
  61610. *
  61611. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  61612. */
  61613. set shadowAngle(value: number);
  61614. /**
  61615. * Gets the direction if it has been set.
  61616. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  61617. */
  61618. get direction(): Vector3;
  61619. /**
  61620. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  61621. */
  61622. set direction(value: Vector3);
  61623. /**
  61624. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  61625. * A PointLight emits the light in every direction.
  61626. * It can cast shadows.
  61627. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  61628. * ```javascript
  61629. * var pointLight = new PointLight("pl", camera.position, scene);
  61630. * ```
  61631. * Documentation : https://doc.babylonjs.com/babylon101/lights
  61632. * @param name The light friendly name
  61633. * @param position The position of the point light in the scene
  61634. * @param scene The scene the lights belongs to
  61635. */
  61636. constructor(name: string, position: Vector3, scene: Scene);
  61637. /**
  61638. * Returns the string "PointLight"
  61639. * @returns the class name
  61640. */
  61641. getClassName(): string;
  61642. /**
  61643. * Returns the integer 0.
  61644. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  61645. */
  61646. getTypeID(): number;
  61647. /**
  61648. * Specifies wether or not the shadowmap should be a cube texture.
  61649. * @returns true if the shadowmap needs to be a cube texture.
  61650. */
  61651. needCube(): boolean;
  61652. /**
  61653. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  61654. * @param faceIndex The index of the face we are computed the direction to generate shadow
  61655. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  61656. */
  61657. getShadowDirection(faceIndex?: number): Vector3;
  61658. /**
  61659. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  61660. * - fov = PI / 2
  61661. * - aspect ratio : 1.0
  61662. * - z-near and far equal to the active camera minZ and maxZ.
  61663. * Returns the PointLight.
  61664. */
  61665. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  61666. protected _buildUniformLayout(): void;
  61667. /**
  61668. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  61669. * @param effect The effect to update
  61670. * @param lightIndex The index of the light in the effect to update
  61671. * @returns The point light
  61672. */
  61673. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  61674. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  61675. /**
  61676. * Prepares the list of defines specific to the light type.
  61677. * @param defines the list of defines
  61678. * @param lightIndex defines the index of the light for the effect
  61679. */
  61680. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  61681. }
  61682. }
  61683. declare module BABYLON {
  61684. /**
  61685. * Header information of HDR texture files.
  61686. */
  61687. export interface HDRInfo {
  61688. /**
  61689. * The height of the texture in pixels.
  61690. */
  61691. height: number;
  61692. /**
  61693. * The width of the texture in pixels.
  61694. */
  61695. width: number;
  61696. /**
  61697. * The index of the beginning of the data in the binary file.
  61698. */
  61699. dataPosition: number;
  61700. }
  61701. /**
  61702. * This groups tools to convert HDR texture to native colors array.
  61703. */
  61704. export class HDRTools {
  61705. private static Ldexp;
  61706. private static Rgbe2float;
  61707. private static readStringLine;
  61708. /**
  61709. * Reads header information from an RGBE texture stored in a native array.
  61710. * More information on this format are available here:
  61711. * https://en.wikipedia.org/wiki/RGBE_image_format
  61712. *
  61713. * @param uint8array The binary file stored in native array.
  61714. * @return The header information.
  61715. */
  61716. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  61717. /**
  61718. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  61719. * This RGBE texture needs to store the information as a panorama.
  61720. *
  61721. * More information on this format are available here:
  61722. * https://en.wikipedia.org/wiki/RGBE_image_format
  61723. *
  61724. * @param buffer The binary file stored in an array buffer.
  61725. * @param size The expected size of the extracted cubemap.
  61726. * @return The Cube Map information.
  61727. */
  61728. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  61729. /**
  61730. * Returns the pixels data extracted from an RGBE texture.
  61731. * This pixels will be stored left to right up to down in the R G B order in one array.
  61732. *
  61733. * More information on this format are available here:
  61734. * https://en.wikipedia.org/wiki/RGBE_image_format
  61735. *
  61736. * @param uint8array The binary file stored in an array buffer.
  61737. * @param hdrInfo The header information of the file.
  61738. * @return The pixels data in RGB right to left up to down order.
  61739. */
  61740. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  61741. private static RGBE_ReadPixels_RLE;
  61742. private static RGBE_ReadPixels_NOT_RLE;
  61743. }
  61744. }
  61745. declare module BABYLON {
  61746. /**
  61747. * Effect Render Options
  61748. */
  61749. export interface IEffectRendererOptions {
  61750. /**
  61751. * Defines the vertices positions.
  61752. */
  61753. positions?: number[];
  61754. /**
  61755. * Defines the indices.
  61756. */
  61757. indices?: number[];
  61758. }
  61759. /**
  61760. * Helper class to render one or more effects.
  61761. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  61762. */
  61763. export class EffectRenderer {
  61764. private engine;
  61765. private static _DefaultOptions;
  61766. private _vertexBuffers;
  61767. private _indexBuffer;
  61768. private _fullscreenViewport;
  61769. /**
  61770. * Creates an effect renderer
  61771. * @param engine the engine to use for rendering
  61772. * @param options defines the options of the effect renderer
  61773. */
  61774. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  61775. /**
  61776. * Sets the current viewport in normalized coordinates 0-1
  61777. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  61778. */
  61779. setViewport(viewport?: Viewport): void;
  61780. /**
  61781. * Binds the embedded attributes buffer to the effect.
  61782. * @param effect Defines the effect to bind the attributes for
  61783. */
  61784. bindBuffers(effect: Effect): void;
  61785. /**
  61786. * Sets the current effect wrapper to use during draw.
  61787. * The effect needs to be ready before calling this api.
  61788. * This also sets the default full screen position attribute.
  61789. * @param effectWrapper Defines the effect to draw with
  61790. */
  61791. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  61792. /**
  61793. * Restores engine states
  61794. */
  61795. restoreStates(): void;
  61796. /**
  61797. * Draws a full screen quad.
  61798. */
  61799. draw(): void;
  61800. private isRenderTargetTexture;
  61801. /**
  61802. * renders one or more effects to a specified texture
  61803. * @param effectWrapper the effect to renderer
  61804. * @param outputTexture texture to draw to, if null it will render to the screen.
  61805. */
  61806. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  61807. /**
  61808. * Disposes of the effect renderer
  61809. */
  61810. dispose(): void;
  61811. }
  61812. /**
  61813. * Options to create an EffectWrapper
  61814. */
  61815. interface EffectWrapperCreationOptions {
  61816. /**
  61817. * Engine to use to create the effect
  61818. */
  61819. engine: ThinEngine;
  61820. /**
  61821. * Fragment shader for the effect
  61822. */
  61823. fragmentShader: string;
  61824. /**
  61825. * Use the shader store instead of direct source code
  61826. */
  61827. useShaderStore?: boolean;
  61828. /**
  61829. * Vertex shader for the effect
  61830. */
  61831. vertexShader?: string;
  61832. /**
  61833. * Attributes to use in the shader
  61834. */
  61835. attributeNames?: Array<string>;
  61836. /**
  61837. * Uniforms to use in the shader
  61838. */
  61839. uniformNames?: Array<string>;
  61840. /**
  61841. * Texture sampler names to use in the shader
  61842. */
  61843. samplerNames?: Array<string>;
  61844. /**
  61845. * Defines to use in the shader
  61846. */
  61847. defines?: Array<string>;
  61848. /**
  61849. * Callback when effect is compiled
  61850. */
  61851. onCompiled?: Nullable<(effect: Effect) => void>;
  61852. /**
  61853. * The friendly name of the effect displayed in Spector.
  61854. */
  61855. name?: string;
  61856. }
  61857. /**
  61858. * Wraps an effect to be used for rendering
  61859. */
  61860. export class EffectWrapper {
  61861. /**
  61862. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  61863. */
  61864. onApplyObservable: Observable<{}>;
  61865. /**
  61866. * The underlying effect
  61867. */
  61868. effect: Effect;
  61869. /**
  61870. * Creates an effect to be renderer
  61871. * @param creationOptions options to create the effect
  61872. */
  61873. constructor(creationOptions: EffectWrapperCreationOptions);
  61874. /**
  61875. * Disposes of the effect wrapper
  61876. */
  61877. dispose(): void;
  61878. }
  61879. }
  61880. declare module BABYLON {
  61881. /** @hidden */
  61882. export var hdrFilteringVertexShader: {
  61883. name: string;
  61884. shader: string;
  61885. };
  61886. }
  61887. declare module BABYLON {
  61888. /** @hidden */
  61889. export var hdrFilteringPixelShader: {
  61890. name: string;
  61891. shader: string;
  61892. };
  61893. }
  61894. declare module BABYLON {
  61895. /**
  61896. * Options for texture filtering
  61897. */
  61898. interface IHDRFilteringOptions {
  61899. /**
  61900. * Scales pixel intensity for the input HDR map.
  61901. */
  61902. hdrScale?: number;
  61903. /**
  61904. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  61905. */
  61906. quality?: number;
  61907. }
  61908. /**
  61909. * Filters HDR maps to get correct renderings of PBR reflections
  61910. */
  61911. export class HDRFiltering {
  61912. private _engine;
  61913. private _effectRenderer;
  61914. private _effectWrapper;
  61915. private _lodGenerationOffset;
  61916. private _lodGenerationScale;
  61917. /**
  61918. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  61919. * you care about baking speed.
  61920. */
  61921. quality: number;
  61922. /**
  61923. * Scales pixel intensity for the input HDR map.
  61924. */
  61925. hdrScale: number;
  61926. /**
  61927. * Instantiates HDR filter for reflection maps
  61928. *
  61929. * @param engine Thin engine
  61930. * @param options Options
  61931. */
  61932. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  61933. private _createRenderTarget;
  61934. private _prefilterInternal;
  61935. private _createEffect;
  61936. /**
  61937. * Get a value indicating if the filter is ready to be used
  61938. * @param texture Texture to filter
  61939. * @returns true if the filter is ready
  61940. */
  61941. isReady(texture: BaseTexture): boolean;
  61942. /**
  61943. * Prefilters a cube texture to have mipmap levels representing roughness values.
  61944. * Prefiltering will be invoked at the end of next rendering pass.
  61945. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  61946. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  61947. * @param texture Texture to filter
  61948. * @param onFinished Callback when filtering is done
  61949. * @return Promise called when prefiltering is done
  61950. */
  61951. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  61952. }
  61953. }
  61954. declare module BABYLON {
  61955. /**
  61956. * This represents a texture coming from an HDR input.
  61957. *
  61958. * The only supported format is currently panorama picture stored in RGBE format.
  61959. * Example of such files can be found on HDRLib: http://hdrlib.com/
  61960. */
  61961. export class HDRCubeTexture extends BaseTexture {
  61962. private static _facesMapping;
  61963. private _generateHarmonics;
  61964. private _noMipmap;
  61965. private _prefilterOnLoad;
  61966. private _textureMatrix;
  61967. private _size;
  61968. private _onLoad;
  61969. private _onError;
  61970. /**
  61971. * The texture URL.
  61972. */
  61973. url: string;
  61974. protected _isBlocking: boolean;
  61975. /**
  61976. * Sets wether or not the texture is blocking during loading.
  61977. */
  61978. set isBlocking(value: boolean);
  61979. /**
  61980. * Gets wether or not the texture is blocking during loading.
  61981. */
  61982. get isBlocking(): boolean;
  61983. protected _rotationY: number;
  61984. /**
  61985. * Sets texture matrix rotation angle around Y axis in radians.
  61986. */
  61987. set rotationY(value: number);
  61988. /**
  61989. * Gets texture matrix rotation angle around Y axis radians.
  61990. */
  61991. get rotationY(): number;
  61992. /**
  61993. * Gets or sets the center of the bounding box associated with the cube texture
  61994. * It must define where the camera used to render the texture was set
  61995. */
  61996. boundingBoxPosition: Vector3;
  61997. private _boundingBoxSize;
  61998. /**
  61999. * Gets or sets the size of the bounding box associated with the cube texture
  62000. * When defined, the cubemap will switch to local mode
  62001. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  62002. * @example https://www.babylonjs-playground.com/#RNASML
  62003. */
  62004. set boundingBoxSize(value: Vector3);
  62005. get boundingBoxSize(): Vector3;
  62006. /**
  62007. * Instantiates an HDRTexture from the following parameters.
  62008. *
  62009. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  62010. * @param sceneOrEngine The scene or engine the texture will be used in
  62011. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  62012. * @param noMipmap Forces to not generate the mipmap if true
  62013. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  62014. * @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)
  62015. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  62016. */
  62017. 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>);
  62018. /**
  62019. * Get the current class name of the texture useful for serialization or dynamic coding.
  62020. * @returns "HDRCubeTexture"
  62021. */
  62022. getClassName(): string;
  62023. /**
  62024. * Occurs when the file is raw .hdr file.
  62025. */
  62026. private loadTexture;
  62027. clone(): HDRCubeTexture;
  62028. delayLoad(): void;
  62029. /**
  62030. * Get the texture reflection matrix used to rotate/transform the reflection.
  62031. * @returns the reflection matrix
  62032. */
  62033. getReflectionTextureMatrix(): Matrix;
  62034. /**
  62035. * Set the texture reflection matrix used to rotate/transform the reflection.
  62036. * @param value Define the reflection matrix to set
  62037. */
  62038. setReflectionTextureMatrix(value: Matrix): void;
  62039. /**
  62040. * Parses a JSON representation of an HDR Texture in order to create the texture
  62041. * @param parsedTexture Define the JSON representation
  62042. * @param scene Define the scene the texture should be created in
  62043. * @param rootUrl Define the root url in case we need to load relative dependencies
  62044. * @returns the newly created texture after parsing
  62045. */
  62046. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  62047. serialize(): any;
  62048. }
  62049. }
  62050. declare module BABYLON {
  62051. /**
  62052. * Class used to control physics engine
  62053. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  62054. */
  62055. export class PhysicsEngine implements IPhysicsEngine {
  62056. private _physicsPlugin;
  62057. /**
  62058. * Global value used to control the smallest number supported by the simulation
  62059. */
  62060. static Epsilon: number;
  62061. private _impostors;
  62062. private _joints;
  62063. private _subTimeStep;
  62064. /**
  62065. * Gets the gravity vector used by the simulation
  62066. */
  62067. gravity: Vector3;
  62068. /**
  62069. * Factory used to create the default physics plugin.
  62070. * @returns The default physics plugin
  62071. */
  62072. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  62073. /**
  62074. * Creates a new Physics Engine
  62075. * @param gravity defines the gravity vector used by the simulation
  62076. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  62077. */
  62078. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  62079. /**
  62080. * Sets the gravity vector used by the simulation
  62081. * @param gravity defines the gravity vector to use
  62082. */
  62083. setGravity(gravity: Vector3): void;
  62084. /**
  62085. * Set the time step of the physics engine.
  62086. * Default is 1/60.
  62087. * To slow it down, enter 1/600 for example.
  62088. * To speed it up, 1/30
  62089. * @param newTimeStep defines the new timestep to apply to this world.
  62090. */
  62091. setTimeStep(newTimeStep?: number): void;
  62092. /**
  62093. * Get the time step of the physics engine.
  62094. * @returns the current time step
  62095. */
  62096. getTimeStep(): number;
  62097. /**
  62098. * Set the sub time step of the physics engine.
  62099. * Default is 0 meaning there is no sub steps
  62100. * To increase physics resolution precision, set a small value (like 1 ms)
  62101. * @param subTimeStep defines the new sub timestep used for physics resolution.
  62102. */
  62103. setSubTimeStep(subTimeStep?: number): void;
  62104. /**
  62105. * Get the sub time step of the physics engine.
  62106. * @returns the current sub time step
  62107. */
  62108. getSubTimeStep(): number;
  62109. /**
  62110. * Release all resources
  62111. */
  62112. dispose(): void;
  62113. /**
  62114. * Gets the name of the current physics plugin
  62115. * @returns the name of the plugin
  62116. */
  62117. getPhysicsPluginName(): string;
  62118. /**
  62119. * Adding a new impostor for the impostor tracking.
  62120. * This will be done by the impostor itself.
  62121. * @param impostor the impostor to add
  62122. */
  62123. addImpostor(impostor: PhysicsImpostor): void;
  62124. /**
  62125. * Remove an impostor from the engine.
  62126. * This impostor and its mesh will not longer be updated by the physics engine.
  62127. * @param impostor the impostor to remove
  62128. */
  62129. removeImpostor(impostor: PhysicsImpostor): void;
  62130. /**
  62131. * Add a joint to the physics engine
  62132. * @param mainImpostor defines the main impostor to which the joint is added.
  62133. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  62134. * @param joint defines the joint that will connect both impostors.
  62135. */
  62136. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  62137. /**
  62138. * Removes a joint from the simulation
  62139. * @param mainImpostor defines the impostor used with the joint
  62140. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  62141. * @param joint defines the joint to remove
  62142. */
  62143. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  62144. /**
  62145. * Called by the scene. No need to call it.
  62146. * @param delta defines the timespam between frames
  62147. */
  62148. _step(delta: number): void;
  62149. /**
  62150. * Gets the current plugin used to run the simulation
  62151. * @returns current plugin
  62152. */
  62153. getPhysicsPlugin(): IPhysicsEnginePlugin;
  62154. /**
  62155. * Gets the list of physic impostors
  62156. * @returns an array of PhysicsImpostor
  62157. */
  62158. getImpostors(): Array<PhysicsImpostor>;
  62159. /**
  62160. * Gets the impostor for a physics enabled object
  62161. * @param object defines the object impersonated by the impostor
  62162. * @returns the PhysicsImpostor or null if not found
  62163. */
  62164. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  62165. /**
  62166. * Gets the impostor for a physics body object
  62167. * @param body defines physics body used by the impostor
  62168. * @returns the PhysicsImpostor or null if not found
  62169. */
  62170. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  62171. /**
  62172. * Does a raycast in the physics world
  62173. * @param from when should the ray start?
  62174. * @param to when should the ray end?
  62175. * @returns PhysicsRaycastResult
  62176. */
  62177. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  62178. }
  62179. }
  62180. declare module BABYLON {
  62181. /** @hidden */
  62182. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  62183. private _useDeltaForWorldStep;
  62184. world: any;
  62185. name: string;
  62186. private _physicsMaterials;
  62187. private _fixedTimeStep;
  62188. private _cannonRaycastResult;
  62189. private _raycastResult;
  62190. private _physicsBodysToRemoveAfterStep;
  62191. private _firstFrame;
  62192. BJSCANNON: any;
  62193. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  62194. setGravity(gravity: Vector3): void;
  62195. setTimeStep(timeStep: number): void;
  62196. getTimeStep(): number;
  62197. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  62198. private _removeMarkedPhysicsBodiesFromWorld;
  62199. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  62200. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  62201. generatePhysicsBody(impostor: PhysicsImpostor): void;
  62202. private _processChildMeshes;
  62203. removePhysicsBody(impostor: PhysicsImpostor): void;
  62204. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  62205. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  62206. private _addMaterial;
  62207. private _checkWithEpsilon;
  62208. private _createShape;
  62209. private _createHeightmap;
  62210. private _minus90X;
  62211. private _plus90X;
  62212. private _tmpPosition;
  62213. private _tmpDeltaPosition;
  62214. private _tmpUnityRotation;
  62215. private _updatePhysicsBodyTransformation;
  62216. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  62217. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  62218. isSupported(): boolean;
  62219. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  62220. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  62221. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  62222. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  62223. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  62224. getBodyMass(impostor: PhysicsImpostor): number;
  62225. getBodyFriction(impostor: PhysicsImpostor): number;
  62226. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  62227. getBodyRestitution(impostor: PhysicsImpostor): number;
  62228. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  62229. sleepBody(impostor: PhysicsImpostor): void;
  62230. wakeUpBody(impostor: PhysicsImpostor): void;
  62231. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  62232. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  62233. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  62234. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  62235. getRadius(impostor: PhysicsImpostor): number;
  62236. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  62237. dispose(): void;
  62238. private _extendNamespace;
  62239. /**
  62240. * Does a raycast in the physics world
  62241. * @param from when should the ray start?
  62242. * @param to when should the ray end?
  62243. * @returns PhysicsRaycastResult
  62244. */
  62245. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  62246. }
  62247. }
  62248. declare module BABYLON {
  62249. /** @hidden */
  62250. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  62251. private _useDeltaForWorldStep;
  62252. world: any;
  62253. name: string;
  62254. BJSOIMO: any;
  62255. private _raycastResult;
  62256. private _fixedTimeStep;
  62257. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  62258. setGravity(gravity: Vector3): void;
  62259. setTimeStep(timeStep: number): void;
  62260. getTimeStep(): number;
  62261. private _tmpImpostorsArray;
  62262. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  62263. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  62264. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  62265. generatePhysicsBody(impostor: PhysicsImpostor): void;
  62266. private _tmpPositionVector;
  62267. removePhysicsBody(impostor: PhysicsImpostor): void;
  62268. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  62269. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  62270. isSupported(): boolean;
  62271. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  62272. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  62273. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  62274. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  62275. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  62276. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  62277. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  62278. getBodyMass(impostor: PhysicsImpostor): number;
  62279. getBodyFriction(impostor: PhysicsImpostor): number;
  62280. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  62281. getBodyRestitution(impostor: PhysicsImpostor): number;
  62282. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  62283. sleepBody(impostor: PhysicsImpostor): void;
  62284. wakeUpBody(impostor: PhysicsImpostor): void;
  62285. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  62286. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  62287. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  62288. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  62289. getRadius(impostor: PhysicsImpostor): number;
  62290. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  62291. dispose(): void;
  62292. /**
  62293. * Does a raycast in the physics world
  62294. * @param from when should the ray start?
  62295. * @param to when should the ray end?
  62296. * @returns PhysicsRaycastResult
  62297. */
  62298. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  62299. }
  62300. }
  62301. declare module BABYLON {
  62302. /**
  62303. * AmmoJS Physics plugin
  62304. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  62305. * @see https://github.com/kripken/ammo.js/
  62306. */
  62307. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  62308. private _useDeltaForWorldStep;
  62309. /**
  62310. * Reference to the Ammo library
  62311. */
  62312. bjsAMMO: any;
  62313. /**
  62314. * Created ammoJS world which physics bodies are added to
  62315. */
  62316. world: any;
  62317. /**
  62318. * Name of the plugin
  62319. */
  62320. name: string;
  62321. private _timeStep;
  62322. private _fixedTimeStep;
  62323. private _maxSteps;
  62324. private _tmpQuaternion;
  62325. private _tmpAmmoTransform;
  62326. private _tmpAmmoQuaternion;
  62327. private _tmpAmmoConcreteContactResultCallback;
  62328. private _collisionConfiguration;
  62329. private _dispatcher;
  62330. private _overlappingPairCache;
  62331. private _solver;
  62332. private _softBodySolver;
  62333. private _tmpAmmoVectorA;
  62334. private _tmpAmmoVectorB;
  62335. private _tmpAmmoVectorC;
  62336. private _tmpAmmoVectorD;
  62337. private _tmpContactCallbackResult;
  62338. private _tmpAmmoVectorRCA;
  62339. private _tmpAmmoVectorRCB;
  62340. private _raycastResult;
  62341. private _tmpContactPoint;
  62342. private static readonly DISABLE_COLLISION_FLAG;
  62343. private static readonly KINEMATIC_FLAG;
  62344. private static readonly DISABLE_DEACTIVATION_FLAG;
  62345. /**
  62346. * Initializes the ammoJS plugin
  62347. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  62348. * @param ammoInjection can be used to inject your own ammo reference
  62349. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  62350. */
  62351. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  62352. /**
  62353. * Sets the gravity of the physics world (m/(s^2))
  62354. * @param gravity Gravity to set
  62355. */
  62356. setGravity(gravity: Vector3): void;
  62357. /**
  62358. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  62359. * @param timeStep timestep to use in seconds
  62360. */
  62361. setTimeStep(timeStep: number): void;
  62362. /**
  62363. * 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)
  62364. * @param fixedTimeStep fixedTimeStep to use in seconds
  62365. */
  62366. setFixedTimeStep(fixedTimeStep: number): void;
  62367. /**
  62368. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  62369. * @param maxSteps the maximum number of steps by the physics engine per frame
  62370. */
  62371. setMaxSteps(maxSteps: number): void;
  62372. /**
  62373. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  62374. * @returns the current timestep in seconds
  62375. */
  62376. getTimeStep(): number;
  62377. /**
  62378. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  62379. */
  62380. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  62381. private _isImpostorInContact;
  62382. private _isImpostorPairInContact;
  62383. private _stepSimulation;
  62384. /**
  62385. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  62386. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  62387. * After the step the babylon meshes are set to the position of the physics imposters
  62388. * @param delta amount of time to step forward
  62389. * @param impostors array of imposters to update before/after the step
  62390. */
  62391. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  62392. /**
  62393. * Update babylon mesh to match physics world object
  62394. * @param impostor imposter to match
  62395. */
  62396. private _afterSoftStep;
  62397. /**
  62398. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  62399. * @param impostor imposter to match
  62400. */
  62401. private _ropeStep;
  62402. /**
  62403. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  62404. * @param impostor imposter to match
  62405. */
  62406. private _softbodyOrClothStep;
  62407. private _tmpMatrix;
  62408. /**
  62409. * Applies an impulse on the imposter
  62410. * @param impostor imposter to apply impulse to
  62411. * @param force amount of force to be applied to the imposter
  62412. * @param contactPoint the location to apply the impulse on the imposter
  62413. */
  62414. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  62415. /**
  62416. * Applies a force on the imposter
  62417. * @param impostor imposter to apply force
  62418. * @param force amount of force to be applied to the imposter
  62419. * @param contactPoint the location to apply the force on the imposter
  62420. */
  62421. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  62422. /**
  62423. * Creates a physics body using the plugin
  62424. * @param impostor the imposter to create the physics body on
  62425. */
  62426. generatePhysicsBody(impostor: PhysicsImpostor): void;
  62427. /**
  62428. * Removes the physics body from the imposter and disposes of the body's memory
  62429. * @param impostor imposter to remove the physics body from
  62430. */
  62431. removePhysicsBody(impostor: PhysicsImpostor): void;
  62432. /**
  62433. * Generates a joint
  62434. * @param impostorJoint the imposter joint to create the joint with
  62435. */
  62436. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  62437. /**
  62438. * Removes a joint
  62439. * @param impostorJoint the imposter joint to remove the joint from
  62440. */
  62441. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  62442. private _addMeshVerts;
  62443. /**
  62444. * Initialise the soft body vertices to match its object's (mesh) vertices
  62445. * Softbody vertices (nodes) are in world space and to match this
  62446. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  62447. * @param impostor to create the softbody for
  62448. */
  62449. private _softVertexData;
  62450. /**
  62451. * Create an impostor's soft body
  62452. * @param impostor to create the softbody for
  62453. */
  62454. private _createSoftbody;
  62455. /**
  62456. * Create cloth for an impostor
  62457. * @param impostor to create the softbody for
  62458. */
  62459. private _createCloth;
  62460. /**
  62461. * Create rope for an impostor
  62462. * @param impostor to create the softbody for
  62463. */
  62464. private _createRope;
  62465. /**
  62466. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  62467. * @param impostor to create the custom physics shape for
  62468. */
  62469. private _createCustom;
  62470. private _addHullVerts;
  62471. private _createShape;
  62472. /**
  62473. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  62474. * @param impostor imposter containing the physics body and babylon object
  62475. */
  62476. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  62477. /**
  62478. * Sets the babylon object's position/rotation from the physics body's position/rotation
  62479. * @param impostor imposter containing the physics body and babylon object
  62480. * @param newPosition new position
  62481. * @param newRotation new rotation
  62482. */
  62483. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  62484. /**
  62485. * If this plugin is supported
  62486. * @returns true if its supported
  62487. */
  62488. isSupported(): boolean;
  62489. /**
  62490. * Sets the linear velocity of the physics body
  62491. * @param impostor imposter to set the velocity on
  62492. * @param velocity velocity to set
  62493. */
  62494. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  62495. /**
  62496. * Sets the angular velocity of the physics body
  62497. * @param impostor imposter to set the velocity on
  62498. * @param velocity velocity to set
  62499. */
  62500. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  62501. /**
  62502. * gets the linear velocity
  62503. * @param impostor imposter to get linear velocity from
  62504. * @returns linear velocity
  62505. */
  62506. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  62507. /**
  62508. * gets the angular velocity
  62509. * @param impostor imposter to get angular velocity from
  62510. * @returns angular velocity
  62511. */
  62512. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  62513. /**
  62514. * Sets the mass of physics body
  62515. * @param impostor imposter to set the mass on
  62516. * @param mass mass to set
  62517. */
  62518. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  62519. /**
  62520. * Gets the mass of the physics body
  62521. * @param impostor imposter to get the mass from
  62522. * @returns mass
  62523. */
  62524. getBodyMass(impostor: PhysicsImpostor): number;
  62525. /**
  62526. * Gets friction of the impostor
  62527. * @param impostor impostor to get friction from
  62528. * @returns friction value
  62529. */
  62530. getBodyFriction(impostor: PhysicsImpostor): number;
  62531. /**
  62532. * Sets friction of the impostor
  62533. * @param impostor impostor to set friction on
  62534. * @param friction friction value
  62535. */
  62536. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  62537. /**
  62538. * Gets restitution of the impostor
  62539. * @param impostor impostor to get restitution from
  62540. * @returns restitution value
  62541. */
  62542. getBodyRestitution(impostor: PhysicsImpostor): number;
  62543. /**
  62544. * Sets resitution of the impostor
  62545. * @param impostor impostor to set resitution on
  62546. * @param restitution resitution value
  62547. */
  62548. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  62549. /**
  62550. * Gets pressure inside the impostor
  62551. * @param impostor impostor to get pressure from
  62552. * @returns pressure value
  62553. */
  62554. getBodyPressure(impostor: PhysicsImpostor): number;
  62555. /**
  62556. * Sets pressure inside a soft body impostor
  62557. * Cloth and rope must remain 0 pressure
  62558. * @param impostor impostor to set pressure on
  62559. * @param pressure pressure value
  62560. */
  62561. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  62562. /**
  62563. * Gets stiffness of the impostor
  62564. * @param impostor impostor to get stiffness from
  62565. * @returns pressure value
  62566. */
  62567. getBodyStiffness(impostor: PhysicsImpostor): number;
  62568. /**
  62569. * Sets stiffness of the impostor
  62570. * @param impostor impostor to set stiffness on
  62571. * @param stiffness stiffness value from 0 to 1
  62572. */
  62573. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  62574. /**
  62575. * Gets velocityIterations of the impostor
  62576. * @param impostor impostor to get velocity iterations from
  62577. * @returns velocityIterations value
  62578. */
  62579. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  62580. /**
  62581. * Sets velocityIterations of the impostor
  62582. * @param impostor impostor to set velocity iterations on
  62583. * @param velocityIterations velocityIterations value
  62584. */
  62585. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  62586. /**
  62587. * Gets positionIterations of the impostor
  62588. * @param impostor impostor to get position iterations from
  62589. * @returns positionIterations value
  62590. */
  62591. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  62592. /**
  62593. * Sets positionIterations of the impostor
  62594. * @param impostor impostor to set position on
  62595. * @param positionIterations positionIterations value
  62596. */
  62597. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  62598. /**
  62599. * Append an anchor to a cloth object
  62600. * @param impostor is the cloth impostor to add anchor to
  62601. * @param otherImpostor is the rigid impostor to anchor to
  62602. * @param width ratio across width from 0 to 1
  62603. * @param height ratio up height from 0 to 1
  62604. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  62605. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  62606. */
  62607. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  62608. /**
  62609. * Append an hook to a rope object
  62610. * @param impostor is the rope impostor to add hook to
  62611. * @param otherImpostor is the rigid impostor to hook to
  62612. * @param length ratio along the rope from 0 to 1
  62613. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  62614. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  62615. */
  62616. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  62617. /**
  62618. * Sleeps the physics body and stops it from being active
  62619. * @param impostor impostor to sleep
  62620. */
  62621. sleepBody(impostor: PhysicsImpostor): void;
  62622. /**
  62623. * Activates the physics body
  62624. * @param impostor impostor to activate
  62625. */
  62626. wakeUpBody(impostor: PhysicsImpostor): void;
  62627. /**
  62628. * Updates the distance parameters of the joint
  62629. * @param joint joint to update
  62630. * @param maxDistance maximum distance of the joint
  62631. * @param minDistance minimum distance of the joint
  62632. */
  62633. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  62634. /**
  62635. * Sets a motor on the joint
  62636. * @param joint joint to set motor on
  62637. * @param speed speed of the motor
  62638. * @param maxForce maximum force of the motor
  62639. * @param motorIndex index of the motor
  62640. */
  62641. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  62642. /**
  62643. * Sets the motors limit
  62644. * @param joint joint to set limit on
  62645. * @param upperLimit upper limit
  62646. * @param lowerLimit lower limit
  62647. */
  62648. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  62649. /**
  62650. * Syncs the position and rotation of a mesh with the impostor
  62651. * @param mesh mesh to sync
  62652. * @param impostor impostor to update the mesh with
  62653. */
  62654. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  62655. /**
  62656. * Gets the radius of the impostor
  62657. * @param impostor impostor to get radius from
  62658. * @returns the radius
  62659. */
  62660. getRadius(impostor: PhysicsImpostor): number;
  62661. /**
  62662. * Gets the box size of the impostor
  62663. * @param impostor impostor to get box size from
  62664. * @param result the resulting box size
  62665. */
  62666. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  62667. /**
  62668. * Disposes of the impostor
  62669. */
  62670. dispose(): void;
  62671. /**
  62672. * Does a raycast in the physics world
  62673. * @param from when should the ray start?
  62674. * @param to when should the ray end?
  62675. * @returns PhysicsRaycastResult
  62676. */
  62677. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  62678. }
  62679. }
  62680. declare module BABYLON {
  62681. interface AbstractScene {
  62682. /**
  62683. * The list of reflection probes added to the scene
  62684. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  62685. */
  62686. reflectionProbes: Array<ReflectionProbe>;
  62687. /**
  62688. * Removes the given reflection probe from this scene.
  62689. * @param toRemove The reflection probe to remove
  62690. * @returns The index of the removed reflection probe
  62691. */
  62692. removeReflectionProbe(toRemove: ReflectionProbe): number;
  62693. /**
  62694. * Adds the given reflection probe to this scene.
  62695. * @param newReflectionProbe The reflection probe to add
  62696. */
  62697. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  62698. }
  62699. /**
  62700. * Class used to generate realtime reflection / refraction cube textures
  62701. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  62702. */
  62703. export class ReflectionProbe {
  62704. /** defines the name of the probe */
  62705. name: string;
  62706. private _scene;
  62707. private _renderTargetTexture;
  62708. private _projectionMatrix;
  62709. private _viewMatrix;
  62710. private _target;
  62711. private _add;
  62712. private _attachedMesh;
  62713. private _invertYAxis;
  62714. /** Gets or sets probe position (center of the cube map) */
  62715. position: Vector3;
  62716. /**
  62717. * Creates a new reflection probe
  62718. * @param name defines the name of the probe
  62719. * @param size defines the texture resolution (for each face)
  62720. * @param scene defines the hosting scene
  62721. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  62722. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  62723. */
  62724. constructor(
  62725. /** defines the name of the probe */
  62726. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  62727. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  62728. get samples(): number;
  62729. set samples(value: number);
  62730. /** Gets or sets the refresh rate to use (on every frame by default) */
  62731. get refreshRate(): number;
  62732. set refreshRate(value: number);
  62733. /**
  62734. * Gets the hosting scene
  62735. * @returns a Scene
  62736. */
  62737. getScene(): Scene;
  62738. /** Gets the internal CubeTexture used to render to */
  62739. get cubeTexture(): RenderTargetTexture;
  62740. /** Gets the list of meshes to render */
  62741. get renderList(): Nullable<AbstractMesh[]>;
  62742. /**
  62743. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  62744. * @param mesh defines the mesh to attach to
  62745. */
  62746. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  62747. /**
  62748. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  62749. * @param renderingGroupId The rendering group id corresponding to its index
  62750. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  62751. */
  62752. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  62753. /**
  62754. * Clean all associated resources
  62755. */
  62756. dispose(): void;
  62757. /**
  62758. * Converts the reflection probe information to a readable string for debug purpose.
  62759. * @param fullDetails Supports for multiple levels of logging within scene loading
  62760. * @returns the human readable reflection probe info
  62761. */
  62762. toString(fullDetails?: boolean): string;
  62763. /**
  62764. * Get the class name of the relfection probe.
  62765. * @returns "ReflectionProbe"
  62766. */
  62767. getClassName(): string;
  62768. /**
  62769. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  62770. * @returns The JSON representation of the texture
  62771. */
  62772. serialize(): any;
  62773. /**
  62774. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  62775. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  62776. * @param scene Define the scene the parsed reflection probe should be instantiated in
  62777. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  62778. * @returns The parsed reflection probe if successful
  62779. */
  62780. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  62781. }
  62782. }
  62783. declare module BABYLON {
  62784. /** @hidden */
  62785. export var _BabylonLoaderRegistered: boolean;
  62786. /**
  62787. * Helps setting up some configuration for the babylon file loader.
  62788. */
  62789. export class BabylonFileLoaderConfiguration {
  62790. /**
  62791. * The loader does not allow injecting custom physix engine into the plugins.
  62792. * Unfortunately in ES6, we need to manually inject them into the plugin.
  62793. * So you could set this variable to your engine import to make it work.
  62794. */
  62795. static LoaderInjectedPhysicsEngine: any;
  62796. }
  62797. }
  62798. declare module BABYLON {
  62799. /**
  62800. * The Physically based simple base material of BJS.
  62801. *
  62802. * This enables better naming and convention enforcements on top of the pbrMaterial.
  62803. * It is used as the base class for both the specGloss and metalRough conventions.
  62804. */
  62805. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  62806. /**
  62807. * Number of Simultaneous lights allowed on the material.
  62808. */
  62809. maxSimultaneousLights: number;
  62810. /**
  62811. * If sets to true, disables all the lights affecting the material.
  62812. */
  62813. disableLighting: boolean;
  62814. /**
  62815. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  62816. */
  62817. environmentTexture: BaseTexture;
  62818. /**
  62819. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  62820. */
  62821. invertNormalMapX: boolean;
  62822. /**
  62823. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  62824. */
  62825. invertNormalMapY: boolean;
  62826. /**
  62827. * Normal map used in the model.
  62828. */
  62829. normalTexture: BaseTexture;
  62830. /**
  62831. * Emissivie color used to self-illuminate the model.
  62832. */
  62833. emissiveColor: Color3;
  62834. /**
  62835. * Emissivie texture used to self-illuminate the model.
  62836. */
  62837. emissiveTexture: BaseTexture;
  62838. /**
  62839. * Occlusion Channel Strenght.
  62840. */
  62841. occlusionStrength: number;
  62842. /**
  62843. * Occlusion Texture of the material (adding extra occlusion effects).
  62844. */
  62845. occlusionTexture: BaseTexture;
  62846. /**
  62847. * Defines the alpha limits in alpha test mode.
  62848. */
  62849. alphaCutOff: number;
  62850. /**
  62851. * Gets the current double sided mode.
  62852. */
  62853. get doubleSided(): boolean;
  62854. /**
  62855. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  62856. */
  62857. set doubleSided(value: boolean);
  62858. /**
  62859. * Stores the pre-calculated light information of a mesh in a texture.
  62860. */
  62861. lightmapTexture: BaseTexture;
  62862. /**
  62863. * If true, the light map contains occlusion information instead of lighting info.
  62864. */
  62865. useLightmapAsShadowmap: boolean;
  62866. /**
  62867. * Instantiates a new PBRMaterial instance.
  62868. *
  62869. * @param name The material name
  62870. * @param scene The scene the material will be use in.
  62871. */
  62872. constructor(name: string, scene: Scene);
  62873. getClassName(): string;
  62874. }
  62875. }
  62876. declare module BABYLON {
  62877. /**
  62878. * The PBR material of BJS following the metal roughness convention.
  62879. *
  62880. * This fits to the PBR convention in the GLTF definition:
  62881. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  62882. */
  62883. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  62884. /**
  62885. * The base color has two different interpretations depending on the value of metalness.
  62886. * When the material is a metal, the base color is the specific measured reflectance value
  62887. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  62888. * of the material.
  62889. */
  62890. baseColor: Color3;
  62891. /**
  62892. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  62893. * well as opacity information in the alpha channel.
  62894. */
  62895. baseTexture: BaseTexture;
  62896. /**
  62897. * Specifies the metallic scalar value of the material.
  62898. * Can also be used to scale the metalness values of the metallic texture.
  62899. */
  62900. metallic: number;
  62901. /**
  62902. * Specifies the roughness scalar value of the material.
  62903. * Can also be used to scale the roughness values of the metallic texture.
  62904. */
  62905. roughness: number;
  62906. /**
  62907. * Texture containing both the metallic value in the B channel and the
  62908. * roughness value in the G channel to keep better precision.
  62909. */
  62910. metallicRoughnessTexture: BaseTexture;
  62911. /**
  62912. * Instantiates a new PBRMetalRoughnessMaterial instance.
  62913. *
  62914. * @param name The material name
  62915. * @param scene The scene the material will be use in.
  62916. */
  62917. constructor(name: string, scene: Scene);
  62918. /**
  62919. * Return the currrent class name of the material.
  62920. */
  62921. getClassName(): string;
  62922. /**
  62923. * Makes a duplicate of the current material.
  62924. * @param name - name to use for the new material.
  62925. */
  62926. clone(name: string): PBRMetallicRoughnessMaterial;
  62927. /**
  62928. * Serialize the material to a parsable JSON object.
  62929. */
  62930. serialize(): any;
  62931. /**
  62932. * Parses a JSON object correponding to the serialize function.
  62933. */
  62934. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  62935. }
  62936. }
  62937. declare module BABYLON {
  62938. /**
  62939. * The PBR material of BJS following the specular glossiness convention.
  62940. *
  62941. * This fits to the PBR convention in the GLTF definition:
  62942. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  62943. */
  62944. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  62945. /**
  62946. * Specifies the diffuse color of the material.
  62947. */
  62948. diffuseColor: Color3;
  62949. /**
  62950. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  62951. * channel.
  62952. */
  62953. diffuseTexture: BaseTexture;
  62954. /**
  62955. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  62956. */
  62957. specularColor: Color3;
  62958. /**
  62959. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  62960. */
  62961. glossiness: number;
  62962. /**
  62963. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  62964. */
  62965. specularGlossinessTexture: BaseTexture;
  62966. /**
  62967. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  62968. *
  62969. * @param name The material name
  62970. * @param scene The scene the material will be use in.
  62971. */
  62972. constructor(name: string, scene: Scene);
  62973. /**
  62974. * Return the currrent class name of the material.
  62975. */
  62976. getClassName(): string;
  62977. /**
  62978. * Makes a duplicate of the current material.
  62979. * @param name - name to use for the new material.
  62980. */
  62981. clone(name: string): PBRSpecularGlossinessMaterial;
  62982. /**
  62983. * Serialize the material to a parsable JSON object.
  62984. */
  62985. serialize(): any;
  62986. /**
  62987. * Parses a JSON object correponding to the serialize function.
  62988. */
  62989. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  62990. }
  62991. }
  62992. declare module BABYLON {
  62993. /**
  62994. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  62995. * It can help converting any input color in a desired output one. This can then be used to create effects
  62996. * from sepia, black and white to sixties or futuristic rendering...
  62997. *
  62998. * The only supported format is currently 3dl.
  62999. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  63000. */
  63001. export class ColorGradingTexture extends BaseTexture {
  63002. /**
  63003. * The texture URL.
  63004. */
  63005. url: string;
  63006. /**
  63007. * Empty line regex stored for GC.
  63008. */
  63009. private static _noneEmptyLineRegex;
  63010. private _textureMatrix;
  63011. private _onLoad;
  63012. /**
  63013. * Instantiates a ColorGradingTexture from the following parameters.
  63014. *
  63015. * @param url The location of the color gradind data (currently only supporting 3dl)
  63016. * @param sceneOrEngine The scene or engine the texture will be used in
  63017. * @param onLoad defines a callback triggered when the texture has been loaded
  63018. */
  63019. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  63020. /**
  63021. * Fires the onload event from the constructor if requested.
  63022. */
  63023. private _triggerOnLoad;
  63024. /**
  63025. * Returns the texture matrix used in most of the material.
  63026. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  63027. */
  63028. getTextureMatrix(): Matrix;
  63029. /**
  63030. * Occurs when the file being loaded is a .3dl LUT file.
  63031. */
  63032. private load3dlTexture;
  63033. /**
  63034. * Starts the loading process of the texture.
  63035. */
  63036. private loadTexture;
  63037. /**
  63038. * Clones the color gradind texture.
  63039. */
  63040. clone(): ColorGradingTexture;
  63041. /**
  63042. * Called during delayed load for textures.
  63043. */
  63044. delayLoad(): void;
  63045. /**
  63046. * Parses a color grading texture serialized by Babylon.
  63047. * @param parsedTexture The texture information being parsedTexture
  63048. * @param scene The scene to load the texture in
  63049. * @param rootUrl The root url of the data assets to load
  63050. * @return A color gradind texture
  63051. */
  63052. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  63053. /**
  63054. * Serializes the LUT texture to json format.
  63055. */
  63056. serialize(): any;
  63057. }
  63058. }
  63059. declare module BABYLON {
  63060. /**
  63061. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  63062. */
  63063. export class EquiRectangularCubeTexture extends BaseTexture {
  63064. /** The six faces of the cube. */
  63065. private static _FacesMapping;
  63066. private _noMipmap;
  63067. private _onLoad;
  63068. private _onError;
  63069. /** The size of the cubemap. */
  63070. private _size;
  63071. /** The buffer of the image. */
  63072. private _buffer;
  63073. /** The width of the input image. */
  63074. private _width;
  63075. /** The height of the input image. */
  63076. private _height;
  63077. /** The URL to the image. */
  63078. url: string;
  63079. /**
  63080. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  63081. * @param url The location of the image
  63082. * @param scene The scene the texture will be used in
  63083. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  63084. * @param noMipmap Forces to not generate the mipmap if true
  63085. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  63086. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  63087. * @param onLoad — defines a callback called when texture is loaded
  63088. * @param onError — defines a callback called if there is an error
  63089. */
  63090. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  63091. /**
  63092. * Load the image data, by putting the image on a canvas and extracting its buffer.
  63093. */
  63094. private loadImage;
  63095. /**
  63096. * Convert the image buffer into a cubemap and create a CubeTexture.
  63097. */
  63098. private loadTexture;
  63099. /**
  63100. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  63101. * @param buffer The ArrayBuffer that should be converted.
  63102. * @returns The buffer as Float32Array.
  63103. */
  63104. private getFloat32ArrayFromArrayBuffer;
  63105. /**
  63106. * Get the current class name of the texture useful for serialization or dynamic coding.
  63107. * @returns "EquiRectangularCubeTexture"
  63108. */
  63109. getClassName(): string;
  63110. /**
  63111. * Create a clone of the current EquiRectangularCubeTexture and return it.
  63112. * @returns A clone of the current EquiRectangularCubeTexture.
  63113. */
  63114. clone(): EquiRectangularCubeTexture;
  63115. }
  63116. }
  63117. declare module BABYLON {
  63118. /**
  63119. * Defines the options related to the creation of an HtmlElementTexture
  63120. */
  63121. export interface IHtmlElementTextureOptions {
  63122. /**
  63123. * Defines wether mip maps should be created or not.
  63124. */
  63125. generateMipMaps?: boolean;
  63126. /**
  63127. * Defines the sampling mode of the texture.
  63128. */
  63129. samplingMode?: number;
  63130. /**
  63131. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  63132. */
  63133. engine: Nullable<ThinEngine>;
  63134. /**
  63135. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  63136. */
  63137. scene: Nullable<Scene>;
  63138. }
  63139. /**
  63140. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  63141. * To be as efficient as possible depending on your constraints nothing aside the first upload
  63142. * is automatically managed.
  63143. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  63144. * in your application.
  63145. *
  63146. * As the update is not automatic, you need to call them manually.
  63147. */
  63148. export class HtmlElementTexture extends BaseTexture {
  63149. /**
  63150. * The texture URL.
  63151. */
  63152. element: HTMLVideoElement | HTMLCanvasElement;
  63153. private static readonly DefaultOptions;
  63154. private _textureMatrix;
  63155. private _isVideo;
  63156. private _generateMipMaps;
  63157. private _samplingMode;
  63158. /**
  63159. * Instantiates a HtmlElementTexture from the following parameters.
  63160. *
  63161. * @param name Defines the name of the texture
  63162. * @param element Defines the video or canvas the texture is filled with
  63163. * @param options Defines the other none mandatory texture creation options
  63164. */
  63165. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  63166. private _createInternalTexture;
  63167. /**
  63168. * Returns the texture matrix used in most of the material.
  63169. */
  63170. getTextureMatrix(): Matrix;
  63171. /**
  63172. * Updates the content of the texture.
  63173. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  63174. */
  63175. update(invertY?: Nullable<boolean>): void;
  63176. }
  63177. }
  63178. declare module BABYLON {
  63179. /**
  63180. * Based on jsTGALoader - Javascript loader for TGA file
  63181. * By Vincent Thibault
  63182. * @see http://blog.robrowser.com/javascript-tga-loader.html
  63183. */
  63184. export class TGATools {
  63185. private static _TYPE_INDEXED;
  63186. private static _TYPE_RGB;
  63187. private static _TYPE_GREY;
  63188. private static _TYPE_RLE_INDEXED;
  63189. private static _TYPE_RLE_RGB;
  63190. private static _TYPE_RLE_GREY;
  63191. private static _ORIGIN_MASK;
  63192. private static _ORIGIN_SHIFT;
  63193. private static _ORIGIN_BL;
  63194. private static _ORIGIN_BR;
  63195. private static _ORIGIN_UL;
  63196. private static _ORIGIN_UR;
  63197. /**
  63198. * Gets the header of a TGA file
  63199. * @param data defines the TGA data
  63200. * @returns the header
  63201. */
  63202. static GetTGAHeader(data: Uint8Array): any;
  63203. /**
  63204. * Uploads TGA content to a Babylon Texture
  63205. * @hidden
  63206. */
  63207. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  63208. /** @hidden */
  63209. 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;
  63210. /** @hidden */
  63211. 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;
  63212. /** @hidden */
  63213. 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;
  63214. /** @hidden */
  63215. 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;
  63216. /** @hidden */
  63217. 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;
  63218. /** @hidden */
  63219. 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;
  63220. }
  63221. }
  63222. declare module BABYLON {
  63223. /**
  63224. * Implementation of the TGA Texture Loader.
  63225. * @hidden
  63226. */
  63227. export class _TGATextureLoader implements IInternalTextureLoader {
  63228. /**
  63229. * Defines wether the loader supports cascade loading the different faces.
  63230. */
  63231. readonly supportCascades: boolean;
  63232. /**
  63233. * This returns if the loader support the current file information.
  63234. * @param extension defines the file extension of the file being loaded
  63235. * @returns true if the loader can load the specified file
  63236. */
  63237. canLoad(extension: string): boolean;
  63238. /**
  63239. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  63240. * @param data contains the texture data
  63241. * @param texture defines the BabylonJS internal texture
  63242. * @param createPolynomials will be true if polynomials have been requested
  63243. * @param onLoad defines the callback to trigger once the texture is ready
  63244. * @param onError defines the callback to trigger in case of error
  63245. */
  63246. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  63247. /**
  63248. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  63249. * @param data contains the texture data
  63250. * @param texture defines the BabylonJS internal texture
  63251. * @param callback defines the method to call once ready to upload
  63252. */
  63253. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  63254. }
  63255. }
  63256. declare module BABYLON {
  63257. /**
  63258. * Info about the .basis files
  63259. */
  63260. class BasisFileInfo {
  63261. /**
  63262. * If the file has alpha
  63263. */
  63264. hasAlpha: boolean;
  63265. /**
  63266. * Info about each image of the basis file
  63267. */
  63268. images: Array<{
  63269. levels: Array<{
  63270. width: number;
  63271. height: number;
  63272. transcodedPixels: ArrayBufferView;
  63273. }>;
  63274. }>;
  63275. }
  63276. /**
  63277. * Result of transcoding a basis file
  63278. */
  63279. class TranscodeResult {
  63280. /**
  63281. * Info about the .basis file
  63282. */
  63283. fileInfo: BasisFileInfo;
  63284. /**
  63285. * Format to use when loading the file
  63286. */
  63287. format: number;
  63288. }
  63289. /**
  63290. * Configuration options for the Basis transcoder
  63291. */
  63292. export class BasisTranscodeConfiguration {
  63293. /**
  63294. * Supported compression formats used to determine the supported output format of the transcoder
  63295. */
  63296. supportedCompressionFormats?: {
  63297. /**
  63298. * etc1 compression format
  63299. */
  63300. etc1?: boolean;
  63301. /**
  63302. * s3tc compression format
  63303. */
  63304. s3tc?: boolean;
  63305. /**
  63306. * pvrtc compression format
  63307. */
  63308. pvrtc?: boolean;
  63309. /**
  63310. * etc2 compression format
  63311. */
  63312. etc2?: boolean;
  63313. };
  63314. /**
  63315. * If mipmap levels should be loaded for transcoded images (Default: true)
  63316. */
  63317. loadMipmapLevels?: boolean;
  63318. /**
  63319. * Index of a single image to load (Default: all images)
  63320. */
  63321. loadSingleImage?: number;
  63322. }
  63323. /**
  63324. * Used to load .Basis files
  63325. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  63326. */
  63327. export class BasisTools {
  63328. private static _IgnoreSupportedFormats;
  63329. /**
  63330. * URL to use when loading the basis transcoder
  63331. */
  63332. static JSModuleURL: string;
  63333. /**
  63334. * URL to use when loading the wasm module for the transcoder
  63335. */
  63336. static WasmModuleURL: string;
  63337. /**
  63338. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  63339. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  63340. * @returns internal format corresponding to the Basis format
  63341. */
  63342. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  63343. private static _WorkerPromise;
  63344. private static _Worker;
  63345. private static _actionId;
  63346. private static _CreateWorkerAsync;
  63347. /**
  63348. * Transcodes a loaded image file to compressed pixel data
  63349. * @param data image data to transcode
  63350. * @param config configuration options for the transcoding
  63351. * @returns a promise resulting in the transcoded image
  63352. */
  63353. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  63354. /**
  63355. * Loads a texture from the transcode result
  63356. * @param texture texture load to
  63357. * @param transcodeResult the result of transcoding the basis file to load from
  63358. */
  63359. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  63360. }
  63361. }
  63362. declare module BABYLON {
  63363. /**
  63364. * Loader for .basis file format
  63365. */
  63366. export class _BasisTextureLoader implements IInternalTextureLoader {
  63367. /**
  63368. * Defines whether the loader supports cascade loading the different faces.
  63369. */
  63370. readonly supportCascades: boolean;
  63371. /**
  63372. * This returns if the loader support the current file information.
  63373. * @param extension defines the file extension of the file being loaded
  63374. * @returns true if the loader can load the specified file
  63375. */
  63376. canLoad(extension: string): boolean;
  63377. /**
  63378. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  63379. * @param data contains the texture data
  63380. * @param texture defines the BabylonJS internal texture
  63381. * @param createPolynomials will be true if polynomials have been requested
  63382. * @param onLoad defines the callback to trigger once the texture is ready
  63383. * @param onError defines the callback to trigger in case of error
  63384. */
  63385. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  63386. /**
  63387. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  63388. * @param data contains the texture data
  63389. * @param texture defines the BabylonJS internal texture
  63390. * @param callback defines the method to call once ready to upload
  63391. */
  63392. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  63393. }
  63394. }
  63395. declare module BABYLON {
  63396. /**
  63397. * Defines the basic options interface of a TexturePacker Frame
  63398. */
  63399. export interface ITexturePackerFrame {
  63400. /**
  63401. * The frame ID
  63402. */
  63403. id: number;
  63404. /**
  63405. * The frames Scale
  63406. */
  63407. scale: Vector2;
  63408. /**
  63409. * The Frames offset
  63410. */
  63411. offset: Vector2;
  63412. }
  63413. /**
  63414. * This is a support class for frame Data on texture packer sets.
  63415. */
  63416. export class TexturePackerFrame implements ITexturePackerFrame {
  63417. /**
  63418. * The frame ID
  63419. */
  63420. id: number;
  63421. /**
  63422. * The frames Scale
  63423. */
  63424. scale: Vector2;
  63425. /**
  63426. * The Frames offset
  63427. */
  63428. offset: Vector2;
  63429. /**
  63430. * Initializes a texture package frame.
  63431. * @param id The numerical frame identifier
  63432. * @param scale Scalar Vector2 for UV frame
  63433. * @param offset Vector2 for the frame position in UV units.
  63434. * @returns TexturePackerFrame
  63435. */
  63436. constructor(id: number, scale: Vector2, offset: Vector2);
  63437. }
  63438. }
  63439. declare module BABYLON {
  63440. /**
  63441. * Defines the basic options interface of a TexturePacker
  63442. */
  63443. export interface ITexturePackerOptions {
  63444. /**
  63445. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  63446. */
  63447. map?: string[];
  63448. /**
  63449. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  63450. */
  63451. uvsIn?: string;
  63452. /**
  63453. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  63454. */
  63455. uvsOut?: string;
  63456. /**
  63457. * number representing the layout style. Defaults to LAYOUT_STRIP
  63458. */
  63459. layout?: number;
  63460. /**
  63461. * number of columns if using custom column count layout(2). This defaults to 4.
  63462. */
  63463. colnum?: number;
  63464. /**
  63465. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  63466. */
  63467. updateInputMeshes?: boolean;
  63468. /**
  63469. * boolean flag to dispose all the source textures. Defaults to true.
  63470. */
  63471. disposeSources?: boolean;
  63472. /**
  63473. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  63474. */
  63475. fillBlanks?: boolean;
  63476. /**
  63477. * string value representing the context fill style color. Defaults to 'black'.
  63478. */
  63479. customFillColor?: string;
  63480. /**
  63481. * Width and Height Value of each Frame in the TexturePacker Sets
  63482. */
  63483. frameSize?: number;
  63484. /**
  63485. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  63486. */
  63487. paddingRatio?: number;
  63488. /**
  63489. * Number that declares the fill method for the padding gutter.
  63490. */
  63491. paddingMode?: number;
  63492. /**
  63493. * If in SUBUV_COLOR padding mode what color to use.
  63494. */
  63495. paddingColor?: Color3 | Color4;
  63496. }
  63497. /**
  63498. * Defines the basic interface of a TexturePacker JSON File
  63499. */
  63500. export interface ITexturePackerJSON {
  63501. /**
  63502. * The frame ID
  63503. */
  63504. name: string;
  63505. /**
  63506. * The base64 channel data
  63507. */
  63508. sets: any;
  63509. /**
  63510. * The options of the Packer
  63511. */
  63512. options: ITexturePackerOptions;
  63513. /**
  63514. * The frame data of the Packer
  63515. */
  63516. frames: Array<number>;
  63517. }
  63518. /**
  63519. * This is a support class that generates a series of packed texture sets.
  63520. * @see https://doc.babylonjs.com/babylon101/materials
  63521. */
  63522. export class TexturePacker {
  63523. /** Packer Layout Constant 0 */
  63524. static readonly LAYOUT_STRIP: number;
  63525. /** Packer Layout Constant 1 */
  63526. static readonly LAYOUT_POWER2: number;
  63527. /** Packer Layout Constant 2 */
  63528. static readonly LAYOUT_COLNUM: number;
  63529. /** Packer Layout Constant 0 */
  63530. static readonly SUBUV_WRAP: number;
  63531. /** Packer Layout Constant 1 */
  63532. static readonly SUBUV_EXTEND: number;
  63533. /** Packer Layout Constant 2 */
  63534. static readonly SUBUV_COLOR: number;
  63535. /** The Name of the Texture Package */
  63536. name: string;
  63537. /** The scene scope of the TexturePacker */
  63538. scene: Scene;
  63539. /** The Meshes to target */
  63540. meshes: AbstractMesh[];
  63541. /** Arguments passed with the Constructor */
  63542. options: ITexturePackerOptions;
  63543. /** The promise that is started upon initialization */
  63544. promise: Nullable<Promise<TexturePacker | string>>;
  63545. /** The Container object for the channel sets that are generated */
  63546. sets: object;
  63547. /** The Container array for the frames that are generated */
  63548. frames: TexturePackerFrame[];
  63549. /** The expected number of textures the system is parsing. */
  63550. private _expecting;
  63551. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  63552. private _paddingValue;
  63553. /**
  63554. * Initializes a texture package series from an array of meshes or a single mesh.
  63555. * @param name The name of the package
  63556. * @param meshes The target meshes to compose the package from
  63557. * @param options The arguments that texture packer should follow while building.
  63558. * @param scene The scene which the textures are scoped to.
  63559. * @returns TexturePacker
  63560. */
  63561. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  63562. /**
  63563. * Starts the package process
  63564. * @param resolve The promises resolution function
  63565. * @returns TexturePacker
  63566. */
  63567. private _createFrames;
  63568. /**
  63569. * Calculates the Size of the Channel Sets
  63570. * @returns Vector2
  63571. */
  63572. private _calculateSize;
  63573. /**
  63574. * Calculates the UV data for the frames.
  63575. * @param baseSize the base frameSize
  63576. * @param padding the base frame padding
  63577. * @param dtSize size of the Dynamic Texture for that channel
  63578. * @param dtUnits is 1/dtSize
  63579. * @param update flag to update the input meshes
  63580. */
  63581. private _calculateMeshUVFrames;
  63582. /**
  63583. * Calculates the frames Offset.
  63584. * @param index of the frame
  63585. * @returns Vector2
  63586. */
  63587. private _getFrameOffset;
  63588. /**
  63589. * Updates a Mesh to the frame data
  63590. * @param mesh that is the target
  63591. * @param frameID or the frame index
  63592. */
  63593. private _updateMeshUV;
  63594. /**
  63595. * Updates a Meshes materials to use the texture packer channels
  63596. * @param m is the mesh to target
  63597. * @param force all channels on the packer to be set.
  63598. */
  63599. private _updateTextureReferences;
  63600. /**
  63601. * Public method to set a Mesh to a frame
  63602. * @param m that is the target
  63603. * @param frameID or the frame index
  63604. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  63605. */
  63606. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  63607. /**
  63608. * Starts the async promise to compile the texture packer.
  63609. * @returns Promise<void>
  63610. */
  63611. processAsync(): Promise<void>;
  63612. /**
  63613. * Disposes all textures associated with this packer
  63614. */
  63615. dispose(): void;
  63616. /**
  63617. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  63618. * @param imageType is the image type to use.
  63619. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  63620. */
  63621. download(imageType?: string, quality?: number): void;
  63622. /**
  63623. * Public method to load a texturePacker JSON file.
  63624. * @param data of the JSON file in string format.
  63625. */
  63626. updateFromJSON(data: string): void;
  63627. }
  63628. }
  63629. declare module BABYLON {
  63630. /**
  63631. * 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.
  63632. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  63633. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  63634. */
  63635. export class CustomProceduralTexture extends ProceduralTexture {
  63636. private _animate;
  63637. private _time;
  63638. private _config;
  63639. private _texturePath;
  63640. /**
  63641. * Instantiates a new Custom Procedural Texture.
  63642. * 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.
  63643. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  63644. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  63645. * @param name Define the name of the texture
  63646. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  63647. * @param size Define the size of the texture to create
  63648. * @param scene Define the scene the texture belongs to
  63649. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  63650. * @param generateMipMaps Define if the texture should creates mip maps or not
  63651. */
  63652. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  63653. private _loadJson;
  63654. /**
  63655. * Is the texture ready to be used ? (rendered at least once)
  63656. * @returns true if ready, otherwise, false.
  63657. */
  63658. isReady(): boolean;
  63659. /**
  63660. * Render the texture to its associated render target.
  63661. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  63662. */
  63663. render(useCameraPostProcess?: boolean): void;
  63664. /**
  63665. * Update the list of dependant textures samplers in the shader.
  63666. */
  63667. updateTextures(): void;
  63668. /**
  63669. * Update the uniform values of the procedural texture in the shader.
  63670. */
  63671. updateShaderUniforms(): void;
  63672. /**
  63673. * Define if the texture animates or not.
  63674. */
  63675. get animate(): boolean;
  63676. set animate(value: boolean);
  63677. }
  63678. }
  63679. declare module BABYLON {
  63680. /** @hidden */
  63681. export var noisePixelShader: {
  63682. name: string;
  63683. shader: string;
  63684. };
  63685. }
  63686. declare module BABYLON {
  63687. /**
  63688. * Class used to generate noise procedural textures
  63689. */
  63690. export class NoiseProceduralTexture extends ProceduralTexture {
  63691. /** Gets or sets the start time (default is 0) */
  63692. time: number;
  63693. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  63694. brightness: number;
  63695. /** Defines the number of octaves to process */
  63696. octaves: number;
  63697. /** Defines the level of persistence (0.8 by default) */
  63698. persistence: number;
  63699. /** Gets or sets animation speed factor (default is 1) */
  63700. animationSpeedFactor: number;
  63701. /**
  63702. * Creates a new NoiseProceduralTexture
  63703. * @param name defines the name fo the texture
  63704. * @param size defines the size of the texture (default is 256)
  63705. * @param scene defines the hosting scene
  63706. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  63707. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  63708. */
  63709. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  63710. private _updateShaderUniforms;
  63711. protected _getDefines(): string;
  63712. /** Generate the current state of the procedural texture */
  63713. render(useCameraPostProcess?: boolean): void;
  63714. /**
  63715. * Serializes this noise procedural texture
  63716. * @returns a serialized noise procedural texture object
  63717. */
  63718. serialize(): any;
  63719. /**
  63720. * Clone the texture.
  63721. * @returns the cloned texture
  63722. */
  63723. clone(): NoiseProceduralTexture;
  63724. /**
  63725. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  63726. * @param parsedTexture defines parsed texture data
  63727. * @param scene defines the current scene
  63728. * @param rootUrl defines the root URL containing noise procedural texture information
  63729. * @returns a parsed NoiseProceduralTexture
  63730. */
  63731. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  63732. }
  63733. }
  63734. declare module BABYLON {
  63735. /**
  63736. * Raw cube texture where the raw buffers are passed in
  63737. */
  63738. export class RawCubeTexture extends CubeTexture {
  63739. /**
  63740. * Creates a cube texture where the raw buffers are passed in.
  63741. * @param scene defines the scene the texture is attached to
  63742. * @param data defines the array of data to use to create each face
  63743. * @param size defines the size of the textures
  63744. * @param format defines the format of the data
  63745. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  63746. * @param generateMipMaps defines if the engine should generate the mip levels
  63747. * @param invertY defines if data must be stored with Y axis inverted
  63748. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  63749. * @param compression defines the compression used (null by default)
  63750. */
  63751. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  63752. /**
  63753. * Updates the raw cube texture.
  63754. * @param data defines the data to store
  63755. * @param format defines the data format
  63756. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  63757. * @param invertY defines if data must be stored with Y axis inverted
  63758. * @param compression defines the compression used (null by default)
  63759. * @param level defines which level of the texture to update
  63760. */
  63761. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  63762. /**
  63763. * Updates a raw cube texture with RGBD encoded data.
  63764. * @param data defines the array of data [mipmap][face] to use to create each face
  63765. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  63766. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  63767. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  63768. * @returns a promsie that resolves when the operation is complete
  63769. */
  63770. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  63771. /**
  63772. * Clones the raw cube texture.
  63773. * @return a new cube texture
  63774. */
  63775. clone(): CubeTexture;
  63776. /** @hidden */
  63777. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  63778. }
  63779. }
  63780. declare module BABYLON {
  63781. /**
  63782. * Class used to store 2D array textures containing user data
  63783. */
  63784. export class RawTexture2DArray extends Texture {
  63785. /** Gets or sets the texture format to use */
  63786. format: number;
  63787. /**
  63788. * Create a new RawTexture2DArray
  63789. * @param data defines the data of the texture
  63790. * @param width defines the width of the texture
  63791. * @param height defines the height of the texture
  63792. * @param depth defines the number of layers of the texture
  63793. * @param format defines the texture format to use
  63794. * @param scene defines the hosting scene
  63795. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  63796. * @param invertY defines if texture must be stored with Y axis inverted
  63797. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  63798. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  63799. */
  63800. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  63801. /** Gets or sets the texture format to use */
  63802. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  63803. /**
  63804. * Update the texture with new data
  63805. * @param data defines the data to store in the texture
  63806. */
  63807. update(data: ArrayBufferView): void;
  63808. }
  63809. }
  63810. declare module BABYLON {
  63811. /**
  63812. * Class used to store 3D textures containing user data
  63813. */
  63814. export class RawTexture3D extends Texture {
  63815. /** Gets or sets the texture format to use */
  63816. format: number;
  63817. /**
  63818. * Create a new RawTexture3D
  63819. * @param data defines the data of the texture
  63820. * @param width defines the width of the texture
  63821. * @param height defines the height of the texture
  63822. * @param depth defines the depth of the texture
  63823. * @param format defines the texture format to use
  63824. * @param scene defines the hosting scene
  63825. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  63826. * @param invertY defines if texture must be stored with Y axis inverted
  63827. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  63828. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  63829. */
  63830. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  63831. /** Gets or sets the texture format to use */
  63832. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  63833. /**
  63834. * Update the texture with new data
  63835. * @param data defines the data to store in the texture
  63836. */
  63837. update(data: ArrayBufferView): void;
  63838. }
  63839. }
  63840. declare module BABYLON {
  63841. /**
  63842. * Creates a refraction texture used by refraction channel of the standard material.
  63843. * It is like a mirror but to see through a material.
  63844. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  63845. */
  63846. export class RefractionTexture extends RenderTargetTexture {
  63847. /**
  63848. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  63849. * 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.
  63850. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  63851. */
  63852. refractionPlane: Plane;
  63853. /**
  63854. * Define how deep under the surface we should see.
  63855. */
  63856. depth: number;
  63857. /**
  63858. * Creates a refraction texture used by refraction channel of the standard material.
  63859. * It is like a mirror but to see through a material.
  63860. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  63861. * @param name Define the texture name
  63862. * @param size Define the size of the underlying texture
  63863. * @param scene Define the scene the refraction belongs to
  63864. * @param generateMipMaps Define if we need to generate mips level for the refraction
  63865. */
  63866. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  63867. /**
  63868. * Clone the refraction texture.
  63869. * @returns the cloned texture
  63870. */
  63871. clone(): RefractionTexture;
  63872. /**
  63873. * Serialize the texture to a JSON representation you could use in Parse later on
  63874. * @returns the serialized JSON representation
  63875. */
  63876. serialize(): any;
  63877. }
  63878. }
  63879. declare module BABYLON {
  63880. /**
  63881. * Block used to add support for vertex skinning (bones)
  63882. */
  63883. export class BonesBlock extends NodeMaterialBlock {
  63884. /**
  63885. * Creates a new BonesBlock
  63886. * @param name defines the block name
  63887. */
  63888. constructor(name: string);
  63889. /**
  63890. * Initialize the block and prepare the context for build
  63891. * @param state defines the state that will be used for the build
  63892. */
  63893. initialize(state: NodeMaterialBuildState): void;
  63894. /**
  63895. * Gets the current class name
  63896. * @returns the class name
  63897. */
  63898. getClassName(): string;
  63899. /**
  63900. * Gets the matrix indices input component
  63901. */
  63902. get matricesIndices(): NodeMaterialConnectionPoint;
  63903. /**
  63904. * Gets the matrix weights input component
  63905. */
  63906. get matricesWeights(): NodeMaterialConnectionPoint;
  63907. /**
  63908. * Gets the extra matrix indices input component
  63909. */
  63910. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  63911. /**
  63912. * Gets the extra matrix weights input component
  63913. */
  63914. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  63915. /**
  63916. * Gets the world input component
  63917. */
  63918. get world(): NodeMaterialConnectionPoint;
  63919. /**
  63920. * Gets the output component
  63921. */
  63922. get output(): NodeMaterialConnectionPoint;
  63923. autoConfigure(material: NodeMaterial): void;
  63924. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  63925. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63926. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63927. protected _buildBlock(state: NodeMaterialBuildState): this;
  63928. }
  63929. }
  63930. declare module BABYLON {
  63931. /**
  63932. * Block used to add support for instances
  63933. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  63934. */
  63935. export class InstancesBlock extends NodeMaterialBlock {
  63936. /**
  63937. * Creates a new InstancesBlock
  63938. * @param name defines the block name
  63939. */
  63940. constructor(name: string);
  63941. /**
  63942. * Gets the current class name
  63943. * @returns the class name
  63944. */
  63945. getClassName(): string;
  63946. /**
  63947. * Gets the first world row input component
  63948. */
  63949. get world0(): NodeMaterialConnectionPoint;
  63950. /**
  63951. * Gets the second world row input component
  63952. */
  63953. get world1(): NodeMaterialConnectionPoint;
  63954. /**
  63955. * Gets the third world row input component
  63956. */
  63957. get world2(): NodeMaterialConnectionPoint;
  63958. /**
  63959. * Gets the forth world row input component
  63960. */
  63961. get world3(): NodeMaterialConnectionPoint;
  63962. /**
  63963. * Gets the world input component
  63964. */
  63965. get world(): NodeMaterialConnectionPoint;
  63966. /**
  63967. * Gets the output component
  63968. */
  63969. get output(): NodeMaterialConnectionPoint;
  63970. /**
  63971. * Gets the isntanceID component
  63972. */
  63973. get instanceID(): NodeMaterialConnectionPoint;
  63974. autoConfigure(material: NodeMaterial): void;
  63975. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  63976. protected _buildBlock(state: NodeMaterialBuildState): this;
  63977. }
  63978. }
  63979. declare module BABYLON {
  63980. /**
  63981. * Block used to add morph targets support to vertex shader
  63982. */
  63983. export class MorphTargetsBlock extends NodeMaterialBlock {
  63984. private _repeatableContentAnchor;
  63985. /**
  63986. * Create a new MorphTargetsBlock
  63987. * @param name defines the block name
  63988. */
  63989. constructor(name: string);
  63990. /**
  63991. * Gets the current class name
  63992. * @returns the class name
  63993. */
  63994. getClassName(): string;
  63995. /**
  63996. * Gets the position input component
  63997. */
  63998. get position(): NodeMaterialConnectionPoint;
  63999. /**
  64000. * Gets the normal input component
  64001. */
  64002. get normal(): NodeMaterialConnectionPoint;
  64003. /**
  64004. * Gets the tangent input component
  64005. */
  64006. get tangent(): NodeMaterialConnectionPoint;
  64007. /**
  64008. * Gets the tangent input component
  64009. */
  64010. get uv(): NodeMaterialConnectionPoint;
  64011. /**
  64012. * Gets the position output component
  64013. */
  64014. get positionOutput(): NodeMaterialConnectionPoint;
  64015. /**
  64016. * Gets the normal output component
  64017. */
  64018. get normalOutput(): NodeMaterialConnectionPoint;
  64019. /**
  64020. * Gets the tangent output component
  64021. */
  64022. get tangentOutput(): NodeMaterialConnectionPoint;
  64023. /**
  64024. * Gets the tangent output component
  64025. */
  64026. get uvOutput(): NodeMaterialConnectionPoint;
  64027. initialize(state: NodeMaterialBuildState): void;
  64028. autoConfigure(material: NodeMaterial): void;
  64029. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64030. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64031. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  64032. protected _buildBlock(state: NodeMaterialBuildState): this;
  64033. }
  64034. }
  64035. declare module BABYLON {
  64036. /**
  64037. * Block used to get data information from a light
  64038. */
  64039. export class LightInformationBlock extends NodeMaterialBlock {
  64040. private _lightDataUniformName;
  64041. private _lightColorUniformName;
  64042. private _lightTypeDefineName;
  64043. /**
  64044. * Gets or sets the light associated with this block
  64045. */
  64046. light: Nullable<Light>;
  64047. /**
  64048. * Creates a new LightInformationBlock
  64049. * @param name defines the block name
  64050. */
  64051. constructor(name: string);
  64052. /**
  64053. * Gets the current class name
  64054. * @returns the class name
  64055. */
  64056. getClassName(): string;
  64057. /**
  64058. * Gets the world position input component
  64059. */
  64060. get worldPosition(): NodeMaterialConnectionPoint;
  64061. /**
  64062. * Gets the direction output component
  64063. */
  64064. get direction(): NodeMaterialConnectionPoint;
  64065. /**
  64066. * Gets the direction output component
  64067. */
  64068. get color(): NodeMaterialConnectionPoint;
  64069. /**
  64070. * Gets the direction output component
  64071. */
  64072. get intensity(): NodeMaterialConnectionPoint;
  64073. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64074. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64075. protected _buildBlock(state: NodeMaterialBuildState): this;
  64076. serialize(): any;
  64077. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64078. }
  64079. }
  64080. declare module BABYLON {
  64081. /**
  64082. * Block used to add image processing support to fragment shader
  64083. */
  64084. export class ImageProcessingBlock extends NodeMaterialBlock {
  64085. /**
  64086. * Create a new ImageProcessingBlock
  64087. * @param name defines the block name
  64088. */
  64089. constructor(name: string);
  64090. /**
  64091. * Gets the current class name
  64092. * @returns the class name
  64093. */
  64094. getClassName(): string;
  64095. /**
  64096. * Gets the color input component
  64097. */
  64098. get color(): NodeMaterialConnectionPoint;
  64099. /**
  64100. * Gets the output component
  64101. */
  64102. get output(): NodeMaterialConnectionPoint;
  64103. /**
  64104. * Initialize the block and prepare the context for build
  64105. * @param state defines the state that will be used for the build
  64106. */
  64107. initialize(state: NodeMaterialBuildState): void;
  64108. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  64109. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64110. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64111. protected _buildBlock(state: NodeMaterialBuildState): this;
  64112. }
  64113. }
  64114. declare module BABYLON {
  64115. /**
  64116. * Block used to pertub normals based on a normal map
  64117. */
  64118. export class PerturbNormalBlock extends NodeMaterialBlock {
  64119. private _tangentSpaceParameterName;
  64120. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  64121. invertX: boolean;
  64122. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  64123. invertY: boolean;
  64124. /**
  64125. * Create a new PerturbNormalBlock
  64126. * @param name defines the block name
  64127. */
  64128. constructor(name: string);
  64129. /**
  64130. * Gets the current class name
  64131. * @returns the class name
  64132. */
  64133. getClassName(): string;
  64134. /**
  64135. * Gets the world position input component
  64136. */
  64137. get worldPosition(): NodeMaterialConnectionPoint;
  64138. /**
  64139. * Gets the world normal input component
  64140. */
  64141. get worldNormal(): NodeMaterialConnectionPoint;
  64142. /**
  64143. * Gets the world tangent input component
  64144. */
  64145. get worldTangent(): NodeMaterialConnectionPoint;
  64146. /**
  64147. * Gets the uv input component
  64148. */
  64149. get uv(): NodeMaterialConnectionPoint;
  64150. /**
  64151. * Gets the normal map color input component
  64152. */
  64153. get normalMapColor(): NodeMaterialConnectionPoint;
  64154. /**
  64155. * Gets the strength input component
  64156. */
  64157. get strength(): NodeMaterialConnectionPoint;
  64158. /**
  64159. * Gets the output component
  64160. */
  64161. get output(): NodeMaterialConnectionPoint;
  64162. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64163. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64164. autoConfigure(material: NodeMaterial): void;
  64165. protected _buildBlock(state: NodeMaterialBuildState): this;
  64166. protected _dumpPropertiesCode(): string;
  64167. serialize(): any;
  64168. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64169. }
  64170. }
  64171. declare module BABYLON {
  64172. /**
  64173. * Block used to discard a pixel if a value is smaller than a cutoff
  64174. */
  64175. export class DiscardBlock extends NodeMaterialBlock {
  64176. /**
  64177. * Create a new DiscardBlock
  64178. * @param name defines the block name
  64179. */
  64180. constructor(name: string);
  64181. /**
  64182. * Gets the current class name
  64183. * @returns the class name
  64184. */
  64185. getClassName(): string;
  64186. /**
  64187. * Gets the color input component
  64188. */
  64189. get value(): NodeMaterialConnectionPoint;
  64190. /**
  64191. * Gets the cutoff input component
  64192. */
  64193. get cutoff(): NodeMaterialConnectionPoint;
  64194. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  64195. }
  64196. }
  64197. declare module BABYLON {
  64198. /**
  64199. * Block used to test if the fragment shader is front facing
  64200. */
  64201. export class FrontFacingBlock extends NodeMaterialBlock {
  64202. /**
  64203. * Creates a new FrontFacingBlock
  64204. * @param name defines the block name
  64205. */
  64206. constructor(name: string);
  64207. /**
  64208. * Gets the current class name
  64209. * @returns the class name
  64210. */
  64211. getClassName(): string;
  64212. /**
  64213. * Gets the output component
  64214. */
  64215. get output(): NodeMaterialConnectionPoint;
  64216. protected _buildBlock(state: NodeMaterialBuildState): this;
  64217. }
  64218. }
  64219. declare module BABYLON {
  64220. /**
  64221. * Block used to get the derivative value on x and y of a given input
  64222. */
  64223. export class DerivativeBlock extends NodeMaterialBlock {
  64224. /**
  64225. * Create a new DerivativeBlock
  64226. * @param name defines the block name
  64227. */
  64228. constructor(name: string);
  64229. /**
  64230. * Gets the current class name
  64231. * @returns the class name
  64232. */
  64233. getClassName(): string;
  64234. /**
  64235. * Gets the input component
  64236. */
  64237. get input(): NodeMaterialConnectionPoint;
  64238. /**
  64239. * Gets the derivative output on x
  64240. */
  64241. get dx(): NodeMaterialConnectionPoint;
  64242. /**
  64243. * Gets the derivative output on y
  64244. */
  64245. get dy(): NodeMaterialConnectionPoint;
  64246. protected _buildBlock(state: NodeMaterialBuildState): this;
  64247. }
  64248. }
  64249. declare module BABYLON {
  64250. /**
  64251. * Block used to make gl_FragCoord available
  64252. */
  64253. export class FragCoordBlock extends NodeMaterialBlock {
  64254. /**
  64255. * Creates a new FragCoordBlock
  64256. * @param name defines the block name
  64257. */
  64258. constructor(name: string);
  64259. /**
  64260. * Gets the current class name
  64261. * @returns the class name
  64262. */
  64263. getClassName(): string;
  64264. /**
  64265. * Gets the xy component
  64266. */
  64267. get xy(): NodeMaterialConnectionPoint;
  64268. /**
  64269. * Gets the xyz component
  64270. */
  64271. get xyz(): NodeMaterialConnectionPoint;
  64272. /**
  64273. * Gets the xyzw component
  64274. */
  64275. get xyzw(): NodeMaterialConnectionPoint;
  64276. /**
  64277. * Gets the x component
  64278. */
  64279. get x(): NodeMaterialConnectionPoint;
  64280. /**
  64281. * Gets the y component
  64282. */
  64283. get y(): NodeMaterialConnectionPoint;
  64284. /**
  64285. * Gets the z component
  64286. */
  64287. get z(): NodeMaterialConnectionPoint;
  64288. /**
  64289. * Gets the w component
  64290. */
  64291. get output(): NodeMaterialConnectionPoint;
  64292. protected writeOutputs(state: NodeMaterialBuildState): string;
  64293. protected _buildBlock(state: NodeMaterialBuildState): this;
  64294. }
  64295. }
  64296. declare module BABYLON {
  64297. /**
  64298. * Block used to get the screen sizes
  64299. */
  64300. export class ScreenSizeBlock extends NodeMaterialBlock {
  64301. private _varName;
  64302. private _scene;
  64303. /**
  64304. * Creates a new ScreenSizeBlock
  64305. * @param name defines the block name
  64306. */
  64307. constructor(name: string);
  64308. /**
  64309. * Gets the current class name
  64310. * @returns the class name
  64311. */
  64312. getClassName(): string;
  64313. /**
  64314. * Gets the xy component
  64315. */
  64316. get xy(): NodeMaterialConnectionPoint;
  64317. /**
  64318. * Gets the x component
  64319. */
  64320. get x(): NodeMaterialConnectionPoint;
  64321. /**
  64322. * Gets the y component
  64323. */
  64324. get y(): NodeMaterialConnectionPoint;
  64325. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64326. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  64327. protected _buildBlock(state: NodeMaterialBuildState): this;
  64328. }
  64329. }
  64330. declare module BABYLON {
  64331. /**
  64332. * Block used to add support for scene fog
  64333. */
  64334. export class FogBlock extends NodeMaterialBlock {
  64335. private _fogDistanceName;
  64336. private _fogParameters;
  64337. /**
  64338. * Create a new FogBlock
  64339. * @param name defines the block name
  64340. */
  64341. constructor(name: string);
  64342. /**
  64343. * Gets the current class name
  64344. * @returns the class name
  64345. */
  64346. getClassName(): string;
  64347. /**
  64348. * Gets the world position input component
  64349. */
  64350. get worldPosition(): NodeMaterialConnectionPoint;
  64351. /**
  64352. * Gets the view input component
  64353. */
  64354. get view(): NodeMaterialConnectionPoint;
  64355. /**
  64356. * Gets the color input component
  64357. */
  64358. get input(): NodeMaterialConnectionPoint;
  64359. /**
  64360. * Gets the fog color input component
  64361. */
  64362. get fogColor(): NodeMaterialConnectionPoint;
  64363. /**
  64364. * Gets the output component
  64365. */
  64366. get output(): NodeMaterialConnectionPoint;
  64367. autoConfigure(material: NodeMaterial): void;
  64368. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64369. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64370. protected _buildBlock(state: NodeMaterialBuildState): this;
  64371. }
  64372. }
  64373. declare module BABYLON {
  64374. /**
  64375. * Block used to add light in the fragment shader
  64376. */
  64377. export class LightBlock extends NodeMaterialBlock {
  64378. private _lightId;
  64379. /**
  64380. * Gets or sets the light associated with this block
  64381. */
  64382. light: Nullable<Light>;
  64383. /**
  64384. * Create a new LightBlock
  64385. * @param name defines the block name
  64386. */
  64387. constructor(name: string);
  64388. /**
  64389. * Gets the current class name
  64390. * @returns the class name
  64391. */
  64392. getClassName(): string;
  64393. /**
  64394. * Gets the world position input component
  64395. */
  64396. get worldPosition(): NodeMaterialConnectionPoint;
  64397. /**
  64398. * Gets the world normal input component
  64399. */
  64400. get worldNormal(): NodeMaterialConnectionPoint;
  64401. /**
  64402. * Gets the camera (or eye) position component
  64403. */
  64404. get cameraPosition(): NodeMaterialConnectionPoint;
  64405. /**
  64406. * Gets the glossiness component
  64407. */
  64408. get glossiness(): NodeMaterialConnectionPoint;
  64409. /**
  64410. * Gets the glossinness power component
  64411. */
  64412. get glossPower(): NodeMaterialConnectionPoint;
  64413. /**
  64414. * Gets the diffuse color component
  64415. */
  64416. get diffuseColor(): NodeMaterialConnectionPoint;
  64417. /**
  64418. * Gets the specular color component
  64419. */
  64420. get specularColor(): NodeMaterialConnectionPoint;
  64421. /**
  64422. * Gets the view matrix component
  64423. */
  64424. get view(): NodeMaterialConnectionPoint;
  64425. /**
  64426. * Gets the diffuse output component
  64427. */
  64428. get diffuseOutput(): NodeMaterialConnectionPoint;
  64429. /**
  64430. * Gets the specular output component
  64431. */
  64432. get specularOutput(): NodeMaterialConnectionPoint;
  64433. /**
  64434. * Gets the shadow output component
  64435. */
  64436. get shadow(): NodeMaterialConnectionPoint;
  64437. autoConfigure(material: NodeMaterial): void;
  64438. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64439. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  64440. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64441. private _injectVertexCode;
  64442. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  64443. serialize(): any;
  64444. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64445. }
  64446. }
  64447. declare module BABYLON {
  64448. /**
  64449. * Block used to read a reflection texture from a sampler
  64450. */
  64451. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  64452. /**
  64453. * Create a new ReflectionTextureBlock
  64454. * @param name defines the block name
  64455. */
  64456. constructor(name: string);
  64457. /**
  64458. * Gets the current class name
  64459. * @returns the class name
  64460. */
  64461. getClassName(): string;
  64462. /**
  64463. * Gets the world position input component
  64464. */
  64465. get position(): NodeMaterialConnectionPoint;
  64466. /**
  64467. * Gets the world position input component
  64468. */
  64469. get worldPosition(): NodeMaterialConnectionPoint;
  64470. /**
  64471. * Gets the world normal input component
  64472. */
  64473. get worldNormal(): NodeMaterialConnectionPoint;
  64474. /**
  64475. * Gets the world input component
  64476. */
  64477. get world(): NodeMaterialConnectionPoint;
  64478. /**
  64479. * Gets the camera (or eye) position component
  64480. */
  64481. get cameraPosition(): NodeMaterialConnectionPoint;
  64482. /**
  64483. * Gets the view input component
  64484. */
  64485. get view(): NodeMaterialConnectionPoint;
  64486. /**
  64487. * Gets the rgb output component
  64488. */
  64489. get rgb(): NodeMaterialConnectionPoint;
  64490. /**
  64491. * Gets the rgba output component
  64492. */
  64493. get rgba(): NodeMaterialConnectionPoint;
  64494. /**
  64495. * Gets the r output component
  64496. */
  64497. get r(): NodeMaterialConnectionPoint;
  64498. /**
  64499. * Gets the g output component
  64500. */
  64501. get g(): NodeMaterialConnectionPoint;
  64502. /**
  64503. * Gets the b output component
  64504. */
  64505. get b(): NodeMaterialConnectionPoint;
  64506. /**
  64507. * Gets the a output component
  64508. */
  64509. get a(): NodeMaterialConnectionPoint;
  64510. autoConfigure(material: NodeMaterial): void;
  64511. protected _buildBlock(state: NodeMaterialBuildState): this;
  64512. }
  64513. }
  64514. declare module BABYLON {
  64515. /**
  64516. * Block used to add 2 vectors
  64517. */
  64518. export class AddBlock extends NodeMaterialBlock {
  64519. /**
  64520. * Creates a new AddBlock
  64521. * @param name defines the block name
  64522. */
  64523. constructor(name: string);
  64524. /**
  64525. * Gets the current class name
  64526. * @returns the class name
  64527. */
  64528. getClassName(): string;
  64529. /**
  64530. * Gets the left operand input component
  64531. */
  64532. get left(): NodeMaterialConnectionPoint;
  64533. /**
  64534. * Gets the right operand input component
  64535. */
  64536. get right(): NodeMaterialConnectionPoint;
  64537. /**
  64538. * Gets the output component
  64539. */
  64540. get output(): NodeMaterialConnectionPoint;
  64541. protected _buildBlock(state: NodeMaterialBuildState): this;
  64542. }
  64543. }
  64544. declare module BABYLON {
  64545. /**
  64546. * Block used to scale a vector by a float
  64547. */
  64548. export class ScaleBlock extends NodeMaterialBlock {
  64549. /**
  64550. * Creates a new ScaleBlock
  64551. * @param name defines the block name
  64552. */
  64553. constructor(name: string);
  64554. /**
  64555. * Gets the current class name
  64556. * @returns the class name
  64557. */
  64558. getClassName(): string;
  64559. /**
  64560. * Gets the input component
  64561. */
  64562. get input(): NodeMaterialConnectionPoint;
  64563. /**
  64564. * Gets the factor input component
  64565. */
  64566. get factor(): NodeMaterialConnectionPoint;
  64567. /**
  64568. * Gets the output component
  64569. */
  64570. get output(): NodeMaterialConnectionPoint;
  64571. protected _buildBlock(state: NodeMaterialBuildState): this;
  64572. }
  64573. }
  64574. declare module BABYLON {
  64575. /**
  64576. * Block used to clamp a float
  64577. */
  64578. export class ClampBlock extends NodeMaterialBlock {
  64579. /** Gets or sets the minimum range */
  64580. minimum: number;
  64581. /** Gets or sets the maximum range */
  64582. maximum: number;
  64583. /**
  64584. * Creates a new ClampBlock
  64585. * @param name defines the block name
  64586. */
  64587. constructor(name: string);
  64588. /**
  64589. * Gets the current class name
  64590. * @returns the class name
  64591. */
  64592. getClassName(): string;
  64593. /**
  64594. * Gets the value input component
  64595. */
  64596. get value(): NodeMaterialConnectionPoint;
  64597. /**
  64598. * Gets the output component
  64599. */
  64600. get output(): NodeMaterialConnectionPoint;
  64601. protected _buildBlock(state: NodeMaterialBuildState): this;
  64602. protected _dumpPropertiesCode(): string;
  64603. serialize(): any;
  64604. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64605. }
  64606. }
  64607. declare module BABYLON {
  64608. /**
  64609. * Block used to apply a cross product between 2 vectors
  64610. */
  64611. export class CrossBlock extends NodeMaterialBlock {
  64612. /**
  64613. * Creates a new CrossBlock
  64614. * @param name defines the block name
  64615. */
  64616. constructor(name: string);
  64617. /**
  64618. * Gets the current class name
  64619. * @returns the class name
  64620. */
  64621. getClassName(): string;
  64622. /**
  64623. * Gets the left operand input component
  64624. */
  64625. get left(): NodeMaterialConnectionPoint;
  64626. /**
  64627. * Gets the right operand input component
  64628. */
  64629. get right(): NodeMaterialConnectionPoint;
  64630. /**
  64631. * Gets the output component
  64632. */
  64633. get output(): NodeMaterialConnectionPoint;
  64634. protected _buildBlock(state: NodeMaterialBuildState): this;
  64635. }
  64636. }
  64637. declare module BABYLON {
  64638. /**
  64639. * Block used to apply a dot product between 2 vectors
  64640. */
  64641. export class DotBlock extends NodeMaterialBlock {
  64642. /**
  64643. * Creates a new DotBlock
  64644. * @param name defines the block name
  64645. */
  64646. constructor(name: string);
  64647. /**
  64648. * Gets the current class name
  64649. * @returns the class name
  64650. */
  64651. getClassName(): string;
  64652. /**
  64653. * Gets the left operand input component
  64654. */
  64655. get left(): NodeMaterialConnectionPoint;
  64656. /**
  64657. * Gets the right operand input component
  64658. */
  64659. get right(): NodeMaterialConnectionPoint;
  64660. /**
  64661. * Gets the output component
  64662. */
  64663. get output(): NodeMaterialConnectionPoint;
  64664. protected _buildBlock(state: NodeMaterialBuildState): this;
  64665. }
  64666. }
  64667. declare module BABYLON {
  64668. /**
  64669. * Block used to normalize a vector
  64670. */
  64671. export class NormalizeBlock extends NodeMaterialBlock {
  64672. /**
  64673. * Creates a new NormalizeBlock
  64674. * @param name defines the block name
  64675. */
  64676. constructor(name: string);
  64677. /**
  64678. * Gets the current class name
  64679. * @returns the class name
  64680. */
  64681. getClassName(): string;
  64682. /**
  64683. * Gets the input component
  64684. */
  64685. get input(): NodeMaterialConnectionPoint;
  64686. /**
  64687. * Gets the output component
  64688. */
  64689. get output(): NodeMaterialConnectionPoint;
  64690. protected _buildBlock(state: NodeMaterialBuildState): this;
  64691. }
  64692. }
  64693. declare module BABYLON {
  64694. /**
  64695. * Block used to create a Color3/4 out of individual inputs (one for each component)
  64696. */
  64697. export class ColorMergerBlock extends NodeMaterialBlock {
  64698. /**
  64699. * Create a new ColorMergerBlock
  64700. * @param name defines the block name
  64701. */
  64702. constructor(name: string);
  64703. /**
  64704. * Gets the current class name
  64705. * @returns the class name
  64706. */
  64707. getClassName(): string;
  64708. /**
  64709. * Gets the rgb component (input)
  64710. */
  64711. get rgbIn(): NodeMaterialConnectionPoint;
  64712. /**
  64713. * Gets the r component (input)
  64714. */
  64715. get r(): NodeMaterialConnectionPoint;
  64716. /**
  64717. * Gets the g component (input)
  64718. */
  64719. get g(): NodeMaterialConnectionPoint;
  64720. /**
  64721. * Gets the b component (input)
  64722. */
  64723. get b(): NodeMaterialConnectionPoint;
  64724. /**
  64725. * Gets the a component (input)
  64726. */
  64727. get a(): NodeMaterialConnectionPoint;
  64728. /**
  64729. * Gets the rgba component (output)
  64730. */
  64731. get rgba(): NodeMaterialConnectionPoint;
  64732. /**
  64733. * Gets the rgb component (output)
  64734. */
  64735. get rgbOut(): NodeMaterialConnectionPoint;
  64736. /**
  64737. * Gets the rgb component (output)
  64738. * @deprecated Please use rgbOut instead.
  64739. */
  64740. get rgb(): NodeMaterialConnectionPoint;
  64741. protected _buildBlock(state: NodeMaterialBuildState): this;
  64742. }
  64743. }
  64744. declare module BABYLON {
  64745. /**
  64746. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  64747. */
  64748. export class VectorSplitterBlock extends NodeMaterialBlock {
  64749. /**
  64750. * Create a new VectorSplitterBlock
  64751. * @param name defines the block name
  64752. */
  64753. constructor(name: string);
  64754. /**
  64755. * Gets the current class name
  64756. * @returns the class name
  64757. */
  64758. getClassName(): string;
  64759. /**
  64760. * Gets the xyzw component (input)
  64761. */
  64762. get xyzw(): NodeMaterialConnectionPoint;
  64763. /**
  64764. * Gets the xyz component (input)
  64765. */
  64766. get xyzIn(): NodeMaterialConnectionPoint;
  64767. /**
  64768. * Gets the xy component (input)
  64769. */
  64770. get xyIn(): NodeMaterialConnectionPoint;
  64771. /**
  64772. * Gets the xyz component (output)
  64773. */
  64774. get xyzOut(): NodeMaterialConnectionPoint;
  64775. /**
  64776. * Gets the xy component (output)
  64777. */
  64778. get xyOut(): NodeMaterialConnectionPoint;
  64779. /**
  64780. * Gets the x component (output)
  64781. */
  64782. get x(): NodeMaterialConnectionPoint;
  64783. /**
  64784. * Gets the y component (output)
  64785. */
  64786. get y(): NodeMaterialConnectionPoint;
  64787. /**
  64788. * Gets the z component (output)
  64789. */
  64790. get z(): NodeMaterialConnectionPoint;
  64791. /**
  64792. * Gets the w component (output)
  64793. */
  64794. get w(): NodeMaterialConnectionPoint;
  64795. protected _inputRename(name: string): string;
  64796. protected _outputRename(name: string): string;
  64797. protected _buildBlock(state: NodeMaterialBuildState): this;
  64798. }
  64799. }
  64800. declare module BABYLON {
  64801. /**
  64802. * Block used to lerp between 2 values
  64803. */
  64804. export class LerpBlock extends NodeMaterialBlock {
  64805. /**
  64806. * Creates a new LerpBlock
  64807. * @param name defines the block name
  64808. */
  64809. constructor(name: string);
  64810. /**
  64811. * Gets the current class name
  64812. * @returns the class name
  64813. */
  64814. getClassName(): string;
  64815. /**
  64816. * Gets the left operand input component
  64817. */
  64818. get left(): NodeMaterialConnectionPoint;
  64819. /**
  64820. * Gets the right operand input component
  64821. */
  64822. get right(): NodeMaterialConnectionPoint;
  64823. /**
  64824. * Gets the gradient operand input component
  64825. */
  64826. get gradient(): NodeMaterialConnectionPoint;
  64827. /**
  64828. * Gets the output component
  64829. */
  64830. get output(): NodeMaterialConnectionPoint;
  64831. protected _buildBlock(state: NodeMaterialBuildState): this;
  64832. }
  64833. }
  64834. declare module BABYLON {
  64835. /**
  64836. * Block used to divide 2 vectors
  64837. */
  64838. export class DivideBlock extends NodeMaterialBlock {
  64839. /**
  64840. * Creates a new DivideBlock
  64841. * @param name defines the block name
  64842. */
  64843. constructor(name: string);
  64844. /**
  64845. * Gets the current class name
  64846. * @returns the class name
  64847. */
  64848. getClassName(): string;
  64849. /**
  64850. * Gets the left operand input component
  64851. */
  64852. get left(): NodeMaterialConnectionPoint;
  64853. /**
  64854. * Gets the right operand input component
  64855. */
  64856. get right(): NodeMaterialConnectionPoint;
  64857. /**
  64858. * Gets the output component
  64859. */
  64860. get output(): NodeMaterialConnectionPoint;
  64861. protected _buildBlock(state: NodeMaterialBuildState): this;
  64862. }
  64863. }
  64864. declare module BABYLON {
  64865. /**
  64866. * Block used to subtract 2 vectors
  64867. */
  64868. export class SubtractBlock extends NodeMaterialBlock {
  64869. /**
  64870. * Creates a new SubtractBlock
  64871. * @param name defines the block name
  64872. */
  64873. constructor(name: string);
  64874. /**
  64875. * Gets the current class name
  64876. * @returns the class name
  64877. */
  64878. getClassName(): string;
  64879. /**
  64880. * Gets the left operand input component
  64881. */
  64882. get left(): NodeMaterialConnectionPoint;
  64883. /**
  64884. * Gets the right operand input component
  64885. */
  64886. get right(): NodeMaterialConnectionPoint;
  64887. /**
  64888. * Gets the output component
  64889. */
  64890. get output(): NodeMaterialConnectionPoint;
  64891. protected _buildBlock(state: NodeMaterialBuildState): this;
  64892. }
  64893. }
  64894. declare module BABYLON {
  64895. /**
  64896. * Block used to step a value
  64897. */
  64898. export class StepBlock extends NodeMaterialBlock {
  64899. /**
  64900. * Creates a new StepBlock
  64901. * @param name defines the block name
  64902. */
  64903. constructor(name: string);
  64904. /**
  64905. * Gets the current class name
  64906. * @returns the class name
  64907. */
  64908. getClassName(): string;
  64909. /**
  64910. * Gets the value operand input component
  64911. */
  64912. get value(): NodeMaterialConnectionPoint;
  64913. /**
  64914. * Gets the edge operand input component
  64915. */
  64916. get edge(): NodeMaterialConnectionPoint;
  64917. /**
  64918. * Gets the output component
  64919. */
  64920. get output(): NodeMaterialConnectionPoint;
  64921. protected _buildBlock(state: NodeMaterialBuildState): this;
  64922. }
  64923. }
  64924. declare module BABYLON {
  64925. /**
  64926. * Block used to get the opposite (1 - x) of a value
  64927. */
  64928. export class OneMinusBlock extends NodeMaterialBlock {
  64929. /**
  64930. * Creates a new OneMinusBlock
  64931. * @param name defines the block name
  64932. */
  64933. constructor(name: string);
  64934. /**
  64935. * Gets the current class name
  64936. * @returns the class name
  64937. */
  64938. getClassName(): string;
  64939. /**
  64940. * Gets the input component
  64941. */
  64942. get input(): NodeMaterialConnectionPoint;
  64943. /**
  64944. * Gets the output component
  64945. */
  64946. get output(): NodeMaterialConnectionPoint;
  64947. protected _buildBlock(state: NodeMaterialBuildState): this;
  64948. }
  64949. }
  64950. declare module BABYLON {
  64951. /**
  64952. * Block used to get the view direction
  64953. */
  64954. export class ViewDirectionBlock extends NodeMaterialBlock {
  64955. /**
  64956. * Creates a new ViewDirectionBlock
  64957. * @param name defines the block name
  64958. */
  64959. constructor(name: string);
  64960. /**
  64961. * Gets the current class name
  64962. * @returns the class name
  64963. */
  64964. getClassName(): string;
  64965. /**
  64966. * Gets the world position component
  64967. */
  64968. get worldPosition(): NodeMaterialConnectionPoint;
  64969. /**
  64970. * Gets the camera position component
  64971. */
  64972. get cameraPosition(): NodeMaterialConnectionPoint;
  64973. /**
  64974. * Gets the output component
  64975. */
  64976. get output(): NodeMaterialConnectionPoint;
  64977. autoConfigure(material: NodeMaterial): void;
  64978. protected _buildBlock(state: NodeMaterialBuildState): this;
  64979. }
  64980. }
  64981. declare module BABYLON {
  64982. /**
  64983. * Block used to compute fresnel value
  64984. */
  64985. export class FresnelBlock extends NodeMaterialBlock {
  64986. /**
  64987. * Create a new FresnelBlock
  64988. * @param name defines the block name
  64989. */
  64990. constructor(name: string);
  64991. /**
  64992. * Gets the current class name
  64993. * @returns the class name
  64994. */
  64995. getClassName(): string;
  64996. /**
  64997. * Gets the world normal input component
  64998. */
  64999. get worldNormal(): NodeMaterialConnectionPoint;
  65000. /**
  65001. * Gets the view direction input component
  65002. */
  65003. get viewDirection(): NodeMaterialConnectionPoint;
  65004. /**
  65005. * Gets the bias input component
  65006. */
  65007. get bias(): NodeMaterialConnectionPoint;
  65008. /**
  65009. * Gets the camera (or eye) position component
  65010. */
  65011. get power(): NodeMaterialConnectionPoint;
  65012. /**
  65013. * Gets the fresnel output component
  65014. */
  65015. get fresnel(): NodeMaterialConnectionPoint;
  65016. autoConfigure(material: NodeMaterial): void;
  65017. protected _buildBlock(state: NodeMaterialBuildState): this;
  65018. }
  65019. }
  65020. declare module BABYLON {
  65021. /**
  65022. * Block used to get the max of 2 values
  65023. */
  65024. export class MaxBlock extends NodeMaterialBlock {
  65025. /**
  65026. * Creates a new MaxBlock
  65027. * @param name defines the block name
  65028. */
  65029. constructor(name: string);
  65030. /**
  65031. * Gets the current class name
  65032. * @returns the class name
  65033. */
  65034. getClassName(): string;
  65035. /**
  65036. * Gets the left operand input component
  65037. */
  65038. get left(): NodeMaterialConnectionPoint;
  65039. /**
  65040. * Gets the right operand input component
  65041. */
  65042. get right(): NodeMaterialConnectionPoint;
  65043. /**
  65044. * Gets the output component
  65045. */
  65046. get output(): NodeMaterialConnectionPoint;
  65047. protected _buildBlock(state: NodeMaterialBuildState): this;
  65048. }
  65049. }
  65050. declare module BABYLON {
  65051. /**
  65052. * Block used to get the min of 2 values
  65053. */
  65054. export class MinBlock extends NodeMaterialBlock {
  65055. /**
  65056. * Creates a new MinBlock
  65057. * @param name defines the block name
  65058. */
  65059. constructor(name: string);
  65060. /**
  65061. * Gets the current class name
  65062. * @returns the class name
  65063. */
  65064. getClassName(): string;
  65065. /**
  65066. * Gets the left operand input component
  65067. */
  65068. get left(): NodeMaterialConnectionPoint;
  65069. /**
  65070. * Gets the right operand input component
  65071. */
  65072. get right(): NodeMaterialConnectionPoint;
  65073. /**
  65074. * Gets the output component
  65075. */
  65076. get output(): NodeMaterialConnectionPoint;
  65077. protected _buildBlock(state: NodeMaterialBuildState): this;
  65078. }
  65079. }
  65080. declare module BABYLON {
  65081. /**
  65082. * Block used to get the distance between 2 values
  65083. */
  65084. export class DistanceBlock extends NodeMaterialBlock {
  65085. /**
  65086. * Creates a new DistanceBlock
  65087. * @param name defines the block name
  65088. */
  65089. constructor(name: string);
  65090. /**
  65091. * Gets the current class name
  65092. * @returns the class name
  65093. */
  65094. getClassName(): string;
  65095. /**
  65096. * Gets the left operand input component
  65097. */
  65098. get left(): NodeMaterialConnectionPoint;
  65099. /**
  65100. * Gets the right operand input component
  65101. */
  65102. get right(): NodeMaterialConnectionPoint;
  65103. /**
  65104. * Gets the output component
  65105. */
  65106. get output(): NodeMaterialConnectionPoint;
  65107. protected _buildBlock(state: NodeMaterialBuildState): this;
  65108. }
  65109. }
  65110. declare module BABYLON {
  65111. /**
  65112. * Block used to get the length of a vector
  65113. */
  65114. export class LengthBlock extends NodeMaterialBlock {
  65115. /**
  65116. * Creates a new LengthBlock
  65117. * @param name defines the block name
  65118. */
  65119. constructor(name: string);
  65120. /**
  65121. * Gets the current class name
  65122. * @returns the class name
  65123. */
  65124. getClassName(): string;
  65125. /**
  65126. * Gets the value input component
  65127. */
  65128. get value(): NodeMaterialConnectionPoint;
  65129. /**
  65130. * Gets the output component
  65131. */
  65132. get output(): NodeMaterialConnectionPoint;
  65133. protected _buildBlock(state: NodeMaterialBuildState): this;
  65134. }
  65135. }
  65136. declare module BABYLON {
  65137. /**
  65138. * Block used to get negative version of a value (i.e. x * -1)
  65139. */
  65140. export class NegateBlock extends NodeMaterialBlock {
  65141. /**
  65142. * Creates a new NegateBlock
  65143. * @param name defines the block name
  65144. */
  65145. constructor(name: string);
  65146. /**
  65147. * Gets the current class name
  65148. * @returns the class name
  65149. */
  65150. getClassName(): string;
  65151. /**
  65152. * Gets the value input component
  65153. */
  65154. get value(): NodeMaterialConnectionPoint;
  65155. /**
  65156. * Gets the output component
  65157. */
  65158. get output(): NodeMaterialConnectionPoint;
  65159. protected _buildBlock(state: NodeMaterialBuildState): this;
  65160. }
  65161. }
  65162. declare module BABYLON {
  65163. /**
  65164. * Block used to get the value of the first parameter raised to the power of the second
  65165. */
  65166. export class PowBlock extends NodeMaterialBlock {
  65167. /**
  65168. * Creates a new PowBlock
  65169. * @param name defines the block name
  65170. */
  65171. constructor(name: string);
  65172. /**
  65173. * Gets the current class name
  65174. * @returns the class name
  65175. */
  65176. getClassName(): string;
  65177. /**
  65178. * Gets the value operand input component
  65179. */
  65180. get value(): NodeMaterialConnectionPoint;
  65181. /**
  65182. * Gets the power operand input component
  65183. */
  65184. get power(): NodeMaterialConnectionPoint;
  65185. /**
  65186. * Gets the output component
  65187. */
  65188. get output(): NodeMaterialConnectionPoint;
  65189. protected _buildBlock(state: NodeMaterialBuildState): this;
  65190. }
  65191. }
  65192. declare module BABYLON {
  65193. /**
  65194. * Block used to get a random number
  65195. */
  65196. export class RandomNumberBlock extends NodeMaterialBlock {
  65197. /**
  65198. * Creates a new RandomNumberBlock
  65199. * @param name defines the block name
  65200. */
  65201. constructor(name: string);
  65202. /**
  65203. * Gets the current class name
  65204. * @returns the class name
  65205. */
  65206. getClassName(): string;
  65207. /**
  65208. * Gets the seed input component
  65209. */
  65210. get seed(): NodeMaterialConnectionPoint;
  65211. /**
  65212. * Gets the output component
  65213. */
  65214. get output(): NodeMaterialConnectionPoint;
  65215. protected _buildBlock(state: NodeMaterialBuildState): this;
  65216. }
  65217. }
  65218. declare module BABYLON {
  65219. /**
  65220. * Block used to compute arc tangent of 2 values
  65221. */
  65222. export class ArcTan2Block extends NodeMaterialBlock {
  65223. /**
  65224. * Creates a new ArcTan2Block
  65225. * @param name defines the block name
  65226. */
  65227. constructor(name: string);
  65228. /**
  65229. * Gets the current class name
  65230. * @returns the class name
  65231. */
  65232. getClassName(): string;
  65233. /**
  65234. * Gets the x operand input component
  65235. */
  65236. get x(): NodeMaterialConnectionPoint;
  65237. /**
  65238. * Gets the y operand input component
  65239. */
  65240. get y(): NodeMaterialConnectionPoint;
  65241. /**
  65242. * Gets the output component
  65243. */
  65244. get output(): NodeMaterialConnectionPoint;
  65245. protected _buildBlock(state: NodeMaterialBuildState): this;
  65246. }
  65247. }
  65248. declare module BABYLON {
  65249. /**
  65250. * Block used to smooth step a value
  65251. */
  65252. export class SmoothStepBlock extends NodeMaterialBlock {
  65253. /**
  65254. * Creates a new SmoothStepBlock
  65255. * @param name defines the block name
  65256. */
  65257. constructor(name: string);
  65258. /**
  65259. * Gets the current class name
  65260. * @returns the class name
  65261. */
  65262. getClassName(): string;
  65263. /**
  65264. * Gets the value operand input component
  65265. */
  65266. get value(): NodeMaterialConnectionPoint;
  65267. /**
  65268. * Gets the first edge operand input component
  65269. */
  65270. get edge0(): NodeMaterialConnectionPoint;
  65271. /**
  65272. * Gets the second edge operand input component
  65273. */
  65274. get edge1(): NodeMaterialConnectionPoint;
  65275. /**
  65276. * Gets the output component
  65277. */
  65278. get output(): NodeMaterialConnectionPoint;
  65279. protected _buildBlock(state: NodeMaterialBuildState): this;
  65280. }
  65281. }
  65282. declare module BABYLON {
  65283. /**
  65284. * Block used to get the reciprocal (1 / x) of a value
  65285. */
  65286. export class ReciprocalBlock extends NodeMaterialBlock {
  65287. /**
  65288. * Creates a new ReciprocalBlock
  65289. * @param name defines the block name
  65290. */
  65291. constructor(name: string);
  65292. /**
  65293. * Gets the current class name
  65294. * @returns the class name
  65295. */
  65296. getClassName(): string;
  65297. /**
  65298. * Gets the input component
  65299. */
  65300. get input(): NodeMaterialConnectionPoint;
  65301. /**
  65302. * Gets the output component
  65303. */
  65304. get output(): NodeMaterialConnectionPoint;
  65305. protected _buildBlock(state: NodeMaterialBuildState): this;
  65306. }
  65307. }
  65308. declare module BABYLON {
  65309. /**
  65310. * Block used to replace a color by another one
  65311. */
  65312. export class ReplaceColorBlock extends NodeMaterialBlock {
  65313. /**
  65314. * Creates a new ReplaceColorBlock
  65315. * @param name defines the block name
  65316. */
  65317. constructor(name: string);
  65318. /**
  65319. * Gets the current class name
  65320. * @returns the class name
  65321. */
  65322. getClassName(): string;
  65323. /**
  65324. * Gets the value input component
  65325. */
  65326. get value(): NodeMaterialConnectionPoint;
  65327. /**
  65328. * Gets the reference input component
  65329. */
  65330. get reference(): NodeMaterialConnectionPoint;
  65331. /**
  65332. * Gets the distance input component
  65333. */
  65334. get distance(): NodeMaterialConnectionPoint;
  65335. /**
  65336. * Gets the replacement input component
  65337. */
  65338. get replacement(): NodeMaterialConnectionPoint;
  65339. /**
  65340. * Gets the output component
  65341. */
  65342. get output(): NodeMaterialConnectionPoint;
  65343. protected _buildBlock(state: NodeMaterialBuildState): this;
  65344. }
  65345. }
  65346. declare module BABYLON {
  65347. /**
  65348. * Block used to posterize a value
  65349. * @see https://en.wikipedia.org/wiki/Posterization
  65350. */
  65351. export class PosterizeBlock extends NodeMaterialBlock {
  65352. /**
  65353. * Creates a new PosterizeBlock
  65354. * @param name defines the block name
  65355. */
  65356. constructor(name: string);
  65357. /**
  65358. * Gets the current class name
  65359. * @returns the class name
  65360. */
  65361. getClassName(): string;
  65362. /**
  65363. * Gets the value input component
  65364. */
  65365. get value(): NodeMaterialConnectionPoint;
  65366. /**
  65367. * Gets the steps input component
  65368. */
  65369. get steps(): NodeMaterialConnectionPoint;
  65370. /**
  65371. * Gets the output component
  65372. */
  65373. get output(): NodeMaterialConnectionPoint;
  65374. protected _buildBlock(state: NodeMaterialBuildState): this;
  65375. }
  65376. }
  65377. declare module BABYLON {
  65378. /**
  65379. * Operations supported by the Wave block
  65380. */
  65381. export enum WaveBlockKind {
  65382. /** SawTooth */
  65383. SawTooth = 0,
  65384. /** Square */
  65385. Square = 1,
  65386. /** Triangle */
  65387. Triangle = 2
  65388. }
  65389. /**
  65390. * Block used to apply wave operation to floats
  65391. */
  65392. export class WaveBlock extends NodeMaterialBlock {
  65393. /**
  65394. * Gets or sets the kibnd of wave to be applied by the block
  65395. */
  65396. kind: WaveBlockKind;
  65397. /**
  65398. * Creates a new WaveBlock
  65399. * @param name defines the block name
  65400. */
  65401. constructor(name: string);
  65402. /**
  65403. * Gets the current class name
  65404. * @returns the class name
  65405. */
  65406. getClassName(): string;
  65407. /**
  65408. * Gets the input component
  65409. */
  65410. get input(): NodeMaterialConnectionPoint;
  65411. /**
  65412. * Gets the output component
  65413. */
  65414. get output(): NodeMaterialConnectionPoint;
  65415. protected _buildBlock(state: NodeMaterialBuildState): this;
  65416. serialize(): any;
  65417. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65418. }
  65419. }
  65420. declare module BABYLON {
  65421. /**
  65422. * Class used to store a color step for the GradientBlock
  65423. */
  65424. export class GradientBlockColorStep {
  65425. private _step;
  65426. /**
  65427. * Gets value indicating which step this color is associated with (between 0 and 1)
  65428. */
  65429. get step(): number;
  65430. /**
  65431. * Sets a value indicating which step this color is associated with (between 0 and 1)
  65432. */
  65433. set step(val: number);
  65434. private _color;
  65435. /**
  65436. * Gets the color associated with this step
  65437. */
  65438. get color(): Color3;
  65439. /**
  65440. * Sets the color associated with this step
  65441. */
  65442. set color(val: Color3);
  65443. /**
  65444. * Creates a new GradientBlockColorStep
  65445. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  65446. * @param color defines the color associated with this step
  65447. */
  65448. constructor(step: number, color: Color3);
  65449. }
  65450. /**
  65451. * Block used to return a color from a gradient based on an input value between 0 and 1
  65452. */
  65453. export class GradientBlock extends NodeMaterialBlock {
  65454. /**
  65455. * Gets or sets the list of color steps
  65456. */
  65457. colorSteps: GradientBlockColorStep[];
  65458. /** Gets an observable raised when the value is changed */
  65459. onValueChangedObservable: Observable<GradientBlock>;
  65460. /** calls observable when the value is changed*/
  65461. colorStepsUpdated(): void;
  65462. /**
  65463. * Creates a new GradientBlock
  65464. * @param name defines the block name
  65465. */
  65466. constructor(name: string);
  65467. /**
  65468. * Gets the current class name
  65469. * @returns the class name
  65470. */
  65471. getClassName(): string;
  65472. /**
  65473. * Gets the gradient input component
  65474. */
  65475. get gradient(): NodeMaterialConnectionPoint;
  65476. /**
  65477. * Gets the output component
  65478. */
  65479. get output(): NodeMaterialConnectionPoint;
  65480. private _writeColorConstant;
  65481. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  65482. serialize(): any;
  65483. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65484. protected _dumpPropertiesCode(): string;
  65485. }
  65486. }
  65487. declare module BABYLON {
  65488. /**
  65489. * Block used to normalize lerp between 2 values
  65490. */
  65491. export class NLerpBlock extends NodeMaterialBlock {
  65492. /**
  65493. * Creates a new NLerpBlock
  65494. * @param name defines the block name
  65495. */
  65496. constructor(name: string);
  65497. /**
  65498. * Gets the current class name
  65499. * @returns the class name
  65500. */
  65501. getClassName(): string;
  65502. /**
  65503. * Gets the left operand input component
  65504. */
  65505. get left(): NodeMaterialConnectionPoint;
  65506. /**
  65507. * Gets the right operand input component
  65508. */
  65509. get right(): NodeMaterialConnectionPoint;
  65510. /**
  65511. * Gets the gradient operand input component
  65512. */
  65513. get gradient(): NodeMaterialConnectionPoint;
  65514. /**
  65515. * Gets the output component
  65516. */
  65517. get output(): NodeMaterialConnectionPoint;
  65518. protected _buildBlock(state: NodeMaterialBuildState): this;
  65519. }
  65520. }
  65521. declare module BABYLON {
  65522. /**
  65523. * block used to Generate a Worley Noise 3D Noise Pattern
  65524. */
  65525. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  65526. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  65527. manhattanDistance: boolean;
  65528. /**
  65529. * Creates a new WorleyNoise3DBlock
  65530. * @param name defines the block name
  65531. */
  65532. constructor(name: string);
  65533. /**
  65534. * Gets the current class name
  65535. * @returns the class name
  65536. */
  65537. getClassName(): string;
  65538. /**
  65539. * Gets the seed input component
  65540. */
  65541. get seed(): NodeMaterialConnectionPoint;
  65542. /**
  65543. * Gets the jitter input component
  65544. */
  65545. get jitter(): NodeMaterialConnectionPoint;
  65546. /**
  65547. * Gets the output component
  65548. */
  65549. get output(): NodeMaterialConnectionPoint;
  65550. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  65551. /**
  65552. * Exposes the properties to the UI?
  65553. */
  65554. protected _dumpPropertiesCode(): string;
  65555. /**
  65556. * Exposes the properties to the Seralize?
  65557. */
  65558. serialize(): any;
  65559. /**
  65560. * Exposes the properties to the deseralize?
  65561. */
  65562. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65563. }
  65564. }
  65565. declare module BABYLON {
  65566. /**
  65567. * block used to Generate a Simplex Perlin 3d Noise Pattern
  65568. */
  65569. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  65570. /**
  65571. * Creates a new SimplexPerlin3DBlock
  65572. * @param name defines the block name
  65573. */
  65574. constructor(name: string);
  65575. /**
  65576. * Gets the current class name
  65577. * @returns the class name
  65578. */
  65579. getClassName(): string;
  65580. /**
  65581. * Gets the seed operand input component
  65582. */
  65583. get seed(): NodeMaterialConnectionPoint;
  65584. /**
  65585. * Gets the output component
  65586. */
  65587. get output(): NodeMaterialConnectionPoint;
  65588. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  65589. }
  65590. }
  65591. declare module BABYLON {
  65592. /**
  65593. * Block used to blend normals
  65594. */
  65595. export class NormalBlendBlock extends NodeMaterialBlock {
  65596. /**
  65597. * Creates a new NormalBlendBlock
  65598. * @param name defines the block name
  65599. */
  65600. constructor(name: string);
  65601. /**
  65602. * Gets the current class name
  65603. * @returns the class name
  65604. */
  65605. getClassName(): string;
  65606. /**
  65607. * Gets the first input component
  65608. */
  65609. get normalMap0(): NodeMaterialConnectionPoint;
  65610. /**
  65611. * Gets the second input component
  65612. */
  65613. get normalMap1(): NodeMaterialConnectionPoint;
  65614. /**
  65615. * Gets the output component
  65616. */
  65617. get output(): NodeMaterialConnectionPoint;
  65618. protected _buildBlock(state: NodeMaterialBuildState): this;
  65619. }
  65620. }
  65621. declare module BABYLON {
  65622. /**
  65623. * Block used to rotate a 2d vector by a given angle
  65624. */
  65625. export class Rotate2dBlock extends NodeMaterialBlock {
  65626. /**
  65627. * Creates a new Rotate2dBlock
  65628. * @param name defines the block name
  65629. */
  65630. constructor(name: string);
  65631. /**
  65632. * Gets the current class name
  65633. * @returns the class name
  65634. */
  65635. getClassName(): string;
  65636. /**
  65637. * Gets the input vector
  65638. */
  65639. get input(): NodeMaterialConnectionPoint;
  65640. /**
  65641. * Gets the input angle
  65642. */
  65643. get angle(): NodeMaterialConnectionPoint;
  65644. /**
  65645. * Gets the output component
  65646. */
  65647. get output(): NodeMaterialConnectionPoint;
  65648. autoConfigure(material: NodeMaterial): void;
  65649. protected _buildBlock(state: NodeMaterialBuildState): this;
  65650. }
  65651. }
  65652. declare module BABYLON {
  65653. /**
  65654. * Block used to get the reflected vector from a direction and a normal
  65655. */
  65656. export class ReflectBlock extends NodeMaterialBlock {
  65657. /**
  65658. * Creates a new ReflectBlock
  65659. * @param name defines the block name
  65660. */
  65661. constructor(name: string);
  65662. /**
  65663. * Gets the current class name
  65664. * @returns the class name
  65665. */
  65666. getClassName(): string;
  65667. /**
  65668. * Gets the incident component
  65669. */
  65670. get incident(): NodeMaterialConnectionPoint;
  65671. /**
  65672. * Gets the normal component
  65673. */
  65674. get normal(): NodeMaterialConnectionPoint;
  65675. /**
  65676. * Gets the output component
  65677. */
  65678. get output(): NodeMaterialConnectionPoint;
  65679. protected _buildBlock(state: NodeMaterialBuildState): this;
  65680. }
  65681. }
  65682. declare module BABYLON {
  65683. /**
  65684. * Block used to get the refracted vector from a direction and a normal
  65685. */
  65686. export class RefractBlock extends NodeMaterialBlock {
  65687. /**
  65688. * Creates a new RefractBlock
  65689. * @param name defines the block name
  65690. */
  65691. constructor(name: string);
  65692. /**
  65693. * Gets the current class name
  65694. * @returns the class name
  65695. */
  65696. getClassName(): string;
  65697. /**
  65698. * Gets the incident component
  65699. */
  65700. get incident(): NodeMaterialConnectionPoint;
  65701. /**
  65702. * Gets the normal component
  65703. */
  65704. get normal(): NodeMaterialConnectionPoint;
  65705. /**
  65706. * Gets the index of refraction component
  65707. */
  65708. get ior(): NodeMaterialConnectionPoint;
  65709. /**
  65710. * Gets the output component
  65711. */
  65712. get output(): NodeMaterialConnectionPoint;
  65713. protected _buildBlock(state: NodeMaterialBuildState): this;
  65714. }
  65715. }
  65716. declare module BABYLON {
  65717. /**
  65718. * Block used to desaturate a color
  65719. */
  65720. export class DesaturateBlock extends NodeMaterialBlock {
  65721. /**
  65722. * Creates a new DesaturateBlock
  65723. * @param name defines the block name
  65724. */
  65725. constructor(name: string);
  65726. /**
  65727. * Gets the current class name
  65728. * @returns the class name
  65729. */
  65730. getClassName(): string;
  65731. /**
  65732. * Gets the color operand input component
  65733. */
  65734. get color(): NodeMaterialConnectionPoint;
  65735. /**
  65736. * Gets the level operand input component
  65737. */
  65738. get level(): NodeMaterialConnectionPoint;
  65739. /**
  65740. * Gets the output component
  65741. */
  65742. get output(): NodeMaterialConnectionPoint;
  65743. protected _buildBlock(state: NodeMaterialBuildState): this;
  65744. }
  65745. }
  65746. declare module BABYLON {
  65747. /**
  65748. * Block used to implement the reflection module of the PBR material
  65749. */
  65750. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  65751. /** @hidden */
  65752. _defineLODReflectionAlpha: string;
  65753. /** @hidden */
  65754. _defineLinearSpecularReflection: string;
  65755. private _vEnvironmentIrradianceName;
  65756. /** @hidden */
  65757. _vReflectionMicrosurfaceInfosName: string;
  65758. /** @hidden */
  65759. _vReflectionInfosName: string;
  65760. /** @hidden */
  65761. _vReflectionFilteringInfoName: string;
  65762. private _scene;
  65763. /**
  65764. * The properties below are set by the main PBR block prior to calling methods of this class.
  65765. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  65766. * It's less burden on the user side in the editor part.
  65767. */
  65768. /** @hidden */
  65769. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  65770. /** @hidden */
  65771. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  65772. /** @hidden */
  65773. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  65774. /** @hidden */
  65775. viewConnectionPoint: NodeMaterialConnectionPoint;
  65776. /**
  65777. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  65778. * diffuse part of the IBL.
  65779. */
  65780. useSphericalHarmonics: boolean;
  65781. /**
  65782. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  65783. */
  65784. forceIrradianceInFragment: boolean;
  65785. /**
  65786. * Create a new ReflectionBlock
  65787. * @param name defines the block name
  65788. */
  65789. constructor(name: string);
  65790. /**
  65791. * Gets the current class name
  65792. * @returns the class name
  65793. */
  65794. getClassName(): string;
  65795. /**
  65796. * Gets the position input component
  65797. */
  65798. get position(): NodeMaterialConnectionPoint;
  65799. /**
  65800. * Gets the world position input component
  65801. */
  65802. get worldPosition(): NodeMaterialConnectionPoint;
  65803. /**
  65804. * Gets the world normal input component
  65805. */
  65806. get worldNormal(): NodeMaterialConnectionPoint;
  65807. /**
  65808. * Gets the world input component
  65809. */
  65810. get world(): NodeMaterialConnectionPoint;
  65811. /**
  65812. * Gets the camera (or eye) position component
  65813. */
  65814. get cameraPosition(): NodeMaterialConnectionPoint;
  65815. /**
  65816. * Gets the view input component
  65817. */
  65818. get view(): NodeMaterialConnectionPoint;
  65819. /**
  65820. * Gets the color input component
  65821. */
  65822. get color(): NodeMaterialConnectionPoint;
  65823. /**
  65824. * Gets the reflection object output component
  65825. */
  65826. get reflection(): NodeMaterialConnectionPoint;
  65827. /**
  65828. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  65829. */
  65830. get hasTexture(): boolean;
  65831. /**
  65832. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  65833. */
  65834. get reflectionColor(): string;
  65835. protected _getTexture(): Nullable<BaseTexture>;
  65836. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65837. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  65838. /**
  65839. * Gets the code to inject in the vertex shader
  65840. * @param state current state of the node material building
  65841. * @returns the shader code
  65842. */
  65843. handleVertexSide(state: NodeMaterialBuildState): string;
  65844. /**
  65845. * Gets the main code of the block (fragment side)
  65846. * @param state current state of the node material building
  65847. * @param normalVarName name of the existing variable corresponding to the normal
  65848. * @returns the shader code
  65849. */
  65850. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  65851. protected _buildBlock(state: NodeMaterialBuildState): this;
  65852. protected _dumpPropertiesCode(): string;
  65853. serialize(): any;
  65854. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65855. }
  65856. }
  65857. declare module BABYLON {
  65858. /**
  65859. * Block used to implement the sheen module of the PBR material
  65860. */
  65861. export class SheenBlock extends NodeMaterialBlock {
  65862. /**
  65863. * Create a new SheenBlock
  65864. * @param name defines the block name
  65865. */
  65866. constructor(name: string);
  65867. /**
  65868. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  65869. * It allows the strength of the sheen effect to not depend on the base color of the material,
  65870. * making it easier to setup and tweak the effect
  65871. */
  65872. albedoScaling: boolean;
  65873. /**
  65874. * Defines if the sheen is linked to the sheen color.
  65875. */
  65876. linkSheenWithAlbedo: boolean;
  65877. /**
  65878. * Initialize the block and prepare the context for build
  65879. * @param state defines the state that will be used for the build
  65880. */
  65881. initialize(state: NodeMaterialBuildState): void;
  65882. /**
  65883. * Gets the current class name
  65884. * @returns the class name
  65885. */
  65886. getClassName(): string;
  65887. /**
  65888. * Gets the intensity input component
  65889. */
  65890. get intensity(): NodeMaterialConnectionPoint;
  65891. /**
  65892. * Gets the color input component
  65893. */
  65894. get color(): NodeMaterialConnectionPoint;
  65895. /**
  65896. * Gets the roughness input component
  65897. */
  65898. get roughness(): NodeMaterialConnectionPoint;
  65899. /**
  65900. * Gets the sheen object output component
  65901. */
  65902. get sheen(): NodeMaterialConnectionPoint;
  65903. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65904. /**
  65905. * Gets the main code of the block (fragment side)
  65906. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  65907. * @returns the shader code
  65908. */
  65909. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  65910. protected _buildBlock(state: NodeMaterialBuildState): this;
  65911. protected _dumpPropertiesCode(): string;
  65912. serialize(): any;
  65913. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65914. }
  65915. }
  65916. declare module BABYLON {
  65917. /**
  65918. * Block used to implement the anisotropy module of the PBR material
  65919. */
  65920. export class AnisotropyBlock extends NodeMaterialBlock {
  65921. /**
  65922. * The two properties below are set by the main PBR block prior to calling methods of this class.
  65923. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  65924. * It's less burden on the user side in the editor part.
  65925. */
  65926. /** @hidden */
  65927. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  65928. /** @hidden */
  65929. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  65930. /**
  65931. * Create a new AnisotropyBlock
  65932. * @param name defines the block name
  65933. */
  65934. constructor(name: string);
  65935. /**
  65936. * Initialize the block and prepare the context for build
  65937. * @param state defines the state that will be used for the build
  65938. */
  65939. initialize(state: NodeMaterialBuildState): void;
  65940. /**
  65941. * Gets the current class name
  65942. * @returns the class name
  65943. */
  65944. getClassName(): string;
  65945. /**
  65946. * Gets the intensity input component
  65947. */
  65948. get intensity(): NodeMaterialConnectionPoint;
  65949. /**
  65950. * Gets the direction input component
  65951. */
  65952. get direction(): NodeMaterialConnectionPoint;
  65953. /**
  65954. * Gets the uv input component
  65955. */
  65956. get uv(): NodeMaterialConnectionPoint;
  65957. /**
  65958. * Gets the worldTangent input component
  65959. */
  65960. get worldTangent(): NodeMaterialConnectionPoint;
  65961. /**
  65962. * Gets the anisotropy object output component
  65963. */
  65964. get anisotropy(): NodeMaterialConnectionPoint;
  65965. private _generateTBNSpace;
  65966. /**
  65967. * Gets the main code of the block (fragment side)
  65968. * @param state current state of the node material building
  65969. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  65970. * @returns the shader code
  65971. */
  65972. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  65973. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65974. protected _buildBlock(state: NodeMaterialBuildState): this;
  65975. }
  65976. }
  65977. declare module BABYLON {
  65978. /**
  65979. * Block used to implement the clear coat module of the PBR material
  65980. */
  65981. export class ClearCoatBlock extends NodeMaterialBlock {
  65982. private _scene;
  65983. /**
  65984. * Create a new ClearCoatBlock
  65985. * @param name defines the block name
  65986. */
  65987. constructor(name: string);
  65988. /**
  65989. * Defines if the F0 value should be remapped to account for the interface change in the material.
  65990. */
  65991. remapF0OnInterfaceChange: boolean;
  65992. /**
  65993. * Initialize the block and prepare the context for build
  65994. * @param state defines the state that will be used for the build
  65995. */
  65996. initialize(state: NodeMaterialBuildState): void;
  65997. /**
  65998. * Gets the current class name
  65999. * @returns the class name
  66000. */
  66001. getClassName(): string;
  66002. /**
  66003. * Gets the intensity input component
  66004. */
  66005. get intensity(): NodeMaterialConnectionPoint;
  66006. /**
  66007. * Gets the roughness input component
  66008. */
  66009. get roughness(): NodeMaterialConnectionPoint;
  66010. /**
  66011. * Gets the ior input component
  66012. */
  66013. get indexOfRefraction(): NodeMaterialConnectionPoint;
  66014. /**
  66015. * Gets the bump texture input component
  66016. */
  66017. get normalMapColor(): NodeMaterialConnectionPoint;
  66018. /**
  66019. * Gets the uv input component
  66020. */
  66021. get uv(): NodeMaterialConnectionPoint;
  66022. /**
  66023. * Gets the tint color input component
  66024. */
  66025. get tintColor(): NodeMaterialConnectionPoint;
  66026. /**
  66027. * Gets the tint "at distance" input component
  66028. */
  66029. get tintAtDistance(): NodeMaterialConnectionPoint;
  66030. /**
  66031. * Gets the tint thickness input component
  66032. */
  66033. get tintThickness(): NodeMaterialConnectionPoint;
  66034. /**
  66035. * Gets the world tangent input component
  66036. */
  66037. get worldTangent(): NodeMaterialConnectionPoint;
  66038. /**
  66039. * Gets the clear coat object output component
  66040. */
  66041. get clearcoat(): NodeMaterialConnectionPoint;
  66042. autoConfigure(material: NodeMaterial): void;
  66043. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66044. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  66045. private _generateTBNSpace;
  66046. /**
  66047. * Gets the main code of the block (fragment side)
  66048. * @param state current state of the node material building
  66049. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  66050. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  66051. * @param worldPosVarName name of the variable holding the world position
  66052. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  66053. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  66054. * @param worldNormalVarName name of the variable holding the world normal
  66055. * @returns the shader code
  66056. */
  66057. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  66058. protected _buildBlock(state: NodeMaterialBuildState): this;
  66059. protected _dumpPropertiesCode(): string;
  66060. serialize(): any;
  66061. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66062. }
  66063. }
  66064. declare module BABYLON {
  66065. /**
  66066. * Block used to implement the sub surface module of the PBR material
  66067. */
  66068. export class SubSurfaceBlock extends NodeMaterialBlock {
  66069. /**
  66070. * Create a new SubSurfaceBlock
  66071. * @param name defines the block name
  66072. */
  66073. constructor(name: string);
  66074. /**
  66075. * Initialize the block and prepare the context for build
  66076. * @param state defines the state that will be used for the build
  66077. */
  66078. initialize(state: NodeMaterialBuildState): void;
  66079. /**
  66080. * Gets the current class name
  66081. * @returns the class name
  66082. */
  66083. getClassName(): string;
  66084. /**
  66085. * Gets the thickness component
  66086. */
  66087. get thickness(): NodeMaterialConnectionPoint;
  66088. /**
  66089. * Gets the tint color input component
  66090. */
  66091. get tintColor(): NodeMaterialConnectionPoint;
  66092. /**
  66093. * Gets the translucency intensity input component
  66094. */
  66095. get translucencyIntensity(): NodeMaterialConnectionPoint;
  66096. /**
  66097. * Gets the translucency diffusion distance input component
  66098. */
  66099. get translucencyDiffusionDist(): NodeMaterialConnectionPoint;
  66100. /**
  66101. * Gets the refraction object parameters
  66102. */
  66103. get refraction(): NodeMaterialConnectionPoint;
  66104. /**
  66105. * Gets the sub surface object output component
  66106. */
  66107. get subsurface(): NodeMaterialConnectionPoint;
  66108. autoConfigure(material: NodeMaterial): void;
  66109. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66110. /**
  66111. * Gets the main code of the block (fragment side)
  66112. * @param state current state of the node material building
  66113. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  66114. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  66115. * @param worldPosVarName name of the variable holding the world position
  66116. * @returns the shader code
  66117. */
  66118. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  66119. protected _buildBlock(state: NodeMaterialBuildState): this;
  66120. }
  66121. }
  66122. declare module BABYLON {
  66123. /**
  66124. * Block used to implement the PBR metallic/roughness model
  66125. */
  66126. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  66127. /**
  66128. * Gets or sets the light associated with this block
  66129. */
  66130. light: Nullable<Light>;
  66131. private _lightId;
  66132. private _scene;
  66133. private _environmentBRDFTexture;
  66134. private _environmentBrdfSamplerName;
  66135. private _vNormalWName;
  66136. private _invertNormalName;
  66137. private _metallicReflectanceColor;
  66138. private _metallicF0Factor;
  66139. private _vMetallicReflectanceFactorsName;
  66140. /**
  66141. * Create a new ReflectionBlock
  66142. * @param name defines the block name
  66143. */
  66144. constructor(name: string);
  66145. /**
  66146. * Intensity of the direct lights e.g. the four lights available in your scene.
  66147. * This impacts both the direct diffuse and specular highlights.
  66148. */
  66149. directIntensity: number;
  66150. /**
  66151. * Intensity of the environment e.g. how much the environment will light the object
  66152. * either through harmonics for rough material or through the refelction for shiny ones.
  66153. */
  66154. environmentIntensity: number;
  66155. /**
  66156. * This is a special control allowing the reduction of the specular highlights coming from the
  66157. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  66158. */
  66159. specularIntensity: number;
  66160. /**
  66161. * Defines the falloff type used in this material.
  66162. * It by default is Physical.
  66163. */
  66164. lightFalloff: number;
  66165. /**
  66166. * Specifies that alpha test should be used
  66167. */
  66168. useAlphaTest: boolean;
  66169. /**
  66170. * Defines the alpha limits in alpha test mode.
  66171. */
  66172. alphaTestCutoff: number;
  66173. /**
  66174. * Specifies that alpha blending should be used
  66175. */
  66176. useAlphaBlending: boolean;
  66177. /**
  66178. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  66179. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  66180. */
  66181. useRadianceOverAlpha: boolean;
  66182. /**
  66183. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  66184. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  66185. */
  66186. useSpecularOverAlpha: boolean;
  66187. /**
  66188. * Enables specular anti aliasing in the PBR shader.
  66189. * It will both interacts on the Geometry for analytical and IBL lighting.
  66190. * It also prefilter the roughness map based on the bump values.
  66191. */
  66192. enableSpecularAntiAliasing: boolean;
  66193. /**
  66194. * Enables realtime filtering on the texture.
  66195. */
  66196. realTimeFiltering: boolean;
  66197. /**
  66198. * Quality switch for realtime filtering
  66199. */
  66200. realTimeFilteringQuality: number;
  66201. /**
  66202. * Defines if the material uses energy conservation.
  66203. */
  66204. useEnergyConservation: boolean;
  66205. /**
  66206. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  66207. * too much the area relying on ambient texture to define their ambient occlusion.
  66208. */
  66209. useRadianceOcclusion: boolean;
  66210. /**
  66211. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  66212. * makes the reflect vector face the model (under horizon).
  66213. */
  66214. useHorizonOcclusion: boolean;
  66215. /**
  66216. * If set to true, no lighting calculations will be applied.
  66217. */
  66218. unlit: boolean;
  66219. /**
  66220. * Force normal to face away from face.
  66221. */
  66222. forceNormalForward: boolean;
  66223. /**
  66224. * Defines the material debug mode.
  66225. * It helps seeing only some components of the material while troubleshooting.
  66226. */
  66227. debugMode: number;
  66228. /**
  66229. * Specify from where on screen the debug mode should start.
  66230. * The value goes from -1 (full screen) to 1 (not visible)
  66231. * It helps with side by side comparison against the final render
  66232. * This defaults to 0
  66233. */
  66234. debugLimit: number;
  66235. /**
  66236. * As the default viewing range might not be enough (if the ambient is really small for instance)
  66237. * You can use the factor to better multiply the final value.
  66238. */
  66239. debugFactor: number;
  66240. /**
  66241. * Initialize the block and prepare the context for build
  66242. * @param state defines the state that will be used for the build
  66243. */
  66244. initialize(state: NodeMaterialBuildState): void;
  66245. /**
  66246. * Gets the current class name
  66247. * @returns the class name
  66248. */
  66249. getClassName(): string;
  66250. /**
  66251. * Gets the world position input component
  66252. */
  66253. get worldPosition(): NodeMaterialConnectionPoint;
  66254. /**
  66255. * Gets the world normal input component
  66256. */
  66257. get worldNormal(): NodeMaterialConnectionPoint;
  66258. /**
  66259. * Gets the view matrix parameter
  66260. */
  66261. get view(): NodeMaterialConnectionPoint;
  66262. /**
  66263. * Gets the camera position input component
  66264. */
  66265. get cameraPosition(): NodeMaterialConnectionPoint;
  66266. /**
  66267. * Gets the perturbed normal input component
  66268. */
  66269. get perturbedNormal(): NodeMaterialConnectionPoint;
  66270. /**
  66271. * Gets the base color input component
  66272. */
  66273. get baseColor(): NodeMaterialConnectionPoint;
  66274. /**
  66275. * Gets the metallic input component
  66276. */
  66277. get metallic(): NodeMaterialConnectionPoint;
  66278. /**
  66279. * Gets the roughness input component
  66280. */
  66281. get roughness(): NodeMaterialConnectionPoint;
  66282. /**
  66283. * Gets the ambient occlusion input component
  66284. */
  66285. get ambientOcc(): NodeMaterialConnectionPoint;
  66286. /**
  66287. * Gets the opacity input component
  66288. */
  66289. get opacity(): NodeMaterialConnectionPoint;
  66290. /**
  66291. * Gets the index of refraction input component
  66292. */
  66293. get indexOfRefraction(): NodeMaterialConnectionPoint;
  66294. /**
  66295. * Gets the ambient color input component
  66296. */
  66297. get ambientColor(): NodeMaterialConnectionPoint;
  66298. /**
  66299. * Gets the reflection object parameters
  66300. */
  66301. get reflection(): NodeMaterialConnectionPoint;
  66302. /**
  66303. * Gets the clear coat object parameters
  66304. */
  66305. get clearcoat(): NodeMaterialConnectionPoint;
  66306. /**
  66307. * Gets the sheen object parameters
  66308. */
  66309. get sheen(): NodeMaterialConnectionPoint;
  66310. /**
  66311. * Gets the sub surface object parameters
  66312. */
  66313. get subsurface(): NodeMaterialConnectionPoint;
  66314. /**
  66315. * Gets the anisotropy object parameters
  66316. */
  66317. get anisotropy(): NodeMaterialConnectionPoint;
  66318. /**
  66319. * Gets the ambient output component
  66320. */
  66321. get ambientClr(): NodeMaterialConnectionPoint;
  66322. /**
  66323. * Gets the diffuse output component
  66324. */
  66325. get diffuseDir(): NodeMaterialConnectionPoint;
  66326. /**
  66327. * Gets the specular output component
  66328. */
  66329. get specularDir(): NodeMaterialConnectionPoint;
  66330. /**
  66331. * Gets the clear coat output component
  66332. */
  66333. get clearcoatDir(): NodeMaterialConnectionPoint;
  66334. /**
  66335. * Gets the sheen output component
  66336. */
  66337. get sheenDir(): NodeMaterialConnectionPoint;
  66338. /**
  66339. * Gets the indirect diffuse output component
  66340. */
  66341. get diffuseIndirect(): NodeMaterialConnectionPoint;
  66342. /**
  66343. * Gets the indirect specular output component
  66344. */
  66345. get specularIndirect(): NodeMaterialConnectionPoint;
  66346. /**
  66347. * Gets the indirect clear coat output component
  66348. */
  66349. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  66350. /**
  66351. * Gets the indirect sheen output component
  66352. */
  66353. get sheenIndirect(): NodeMaterialConnectionPoint;
  66354. /**
  66355. * Gets the refraction output component
  66356. */
  66357. get refraction(): NodeMaterialConnectionPoint;
  66358. /**
  66359. * Gets the global lighting output component
  66360. */
  66361. get lighting(): NodeMaterialConnectionPoint;
  66362. /**
  66363. * Gets the shadow output component
  66364. */
  66365. get shadow(): NodeMaterialConnectionPoint;
  66366. /**
  66367. * Gets the alpha output component
  66368. */
  66369. get alpha(): NodeMaterialConnectionPoint;
  66370. autoConfigure(material: NodeMaterial): void;
  66371. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66372. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  66373. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  66374. private _injectVertexCode;
  66375. private _getAlbedoOpacityCode;
  66376. private _getAmbientOcclusionCode;
  66377. private _getReflectivityCode;
  66378. protected _buildBlock(state: NodeMaterialBuildState): this;
  66379. protected _dumpPropertiesCode(): string;
  66380. serialize(): any;
  66381. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66382. }
  66383. }
  66384. declare module BABYLON {
  66385. /**
  66386. * Block used to compute value of one parameter modulo another
  66387. */
  66388. export class ModBlock extends NodeMaterialBlock {
  66389. /**
  66390. * Creates a new ModBlock
  66391. * @param name defines the block name
  66392. */
  66393. constructor(name: string);
  66394. /**
  66395. * Gets the current class name
  66396. * @returns the class name
  66397. */
  66398. getClassName(): string;
  66399. /**
  66400. * Gets the left operand input component
  66401. */
  66402. get left(): NodeMaterialConnectionPoint;
  66403. /**
  66404. * Gets the right operand input component
  66405. */
  66406. get right(): NodeMaterialConnectionPoint;
  66407. /**
  66408. * Gets the output component
  66409. */
  66410. get output(): NodeMaterialConnectionPoint;
  66411. protected _buildBlock(state: NodeMaterialBuildState): this;
  66412. }
  66413. }
  66414. declare module BABYLON {
  66415. /**
  66416. * Configuration for Draco compression
  66417. */
  66418. export interface IDracoCompressionConfiguration {
  66419. /**
  66420. * Configuration for the decoder.
  66421. */
  66422. decoder: {
  66423. /**
  66424. * The url to the WebAssembly module.
  66425. */
  66426. wasmUrl?: string;
  66427. /**
  66428. * The url to the WebAssembly binary.
  66429. */
  66430. wasmBinaryUrl?: string;
  66431. /**
  66432. * The url to the fallback JavaScript module.
  66433. */
  66434. fallbackUrl?: string;
  66435. };
  66436. }
  66437. /**
  66438. * Draco compression (https://google.github.io/draco/)
  66439. *
  66440. * This class wraps the Draco module.
  66441. *
  66442. * **Encoder**
  66443. *
  66444. * The encoder is not currently implemented.
  66445. *
  66446. * **Decoder**
  66447. *
  66448. * 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.
  66449. *
  66450. * To update the configuration, use the following code:
  66451. * ```javascript
  66452. * DracoCompression.Configuration = {
  66453. * decoder: {
  66454. * wasmUrl: "<url to the WebAssembly library>",
  66455. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  66456. * fallbackUrl: "<url to the fallback JavaScript library>",
  66457. * }
  66458. * };
  66459. * ```
  66460. *
  66461. * 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.
  66462. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  66463. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  66464. *
  66465. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  66466. * ```javascript
  66467. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  66468. * ```
  66469. *
  66470. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  66471. */
  66472. export class DracoCompression implements IDisposable {
  66473. private _workerPoolPromise?;
  66474. private _decoderModulePromise?;
  66475. /**
  66476. * The configuration. Defaults to the following urls:
  66477. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  66478. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  66479. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  66480. */
  66481. static Configuration: IDracoCompressionConfiguration;
  66482. /**
  66483. * Returns true if the decoder configuration is available.
  66484. */
  66485. static get DecoderAvailable(): boolean;
  66486. /**
  66487. * Default number of workers to create when creating the draco compression object.
  66488. */
  66489. static DefaultNumWorkers: number;
  66490. private static GetDefaultNumWorkers;
  66491. private static _Default;
  66492. /**
  66493. * Default instance for the draco compression object.
  66494. */
  66495. static get Default(): DracoCompression;
  66496. /**
  66497. * Constructor
  66498. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  66499. */
  66500. constructor(numWorkers?: number);
  66501. /**
  66502. * Stop all async operations and release resources.
  66503. */
  66504. dispose(): void;
  66505. /**
  66506. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  66507. * @returns a promise that resolves when ready
  66508. */
  66509. whenReadyAsync(): Promise<void>;
  66510. /**
  66511. * Decode Draco compressed mesh data to vertex data.
  66512. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  66513. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  66514. * @returns A promise that resolves with the decoded vertex data
  66515. */
  66516. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  66517. [kind: string]: number;
  66518. }): Promise<VertexData>;
  66519. }
  66520. }
  66521. declare module BABYLON {
  66522. /**
  66523. * Class for building Constructive Solid Geometry
  66524. */
  66525. export class CSG {
  66526. private polygons;
  66527. /**
  66528. * The world matrix
  66529. */
  66530. matrix: Matrix;
  66531. /**
  66532. * Stores the position
  66533. */
  66534. position: Vector3;
  66535. /**
  66536. * Stores the rotation
  66537. */
  66538. rotation: Vector3;
  66539. /**
  66540. * Stores the rotation quaternion
  66541. */
  66542. rotationQuaternion: Nullable<Quaternion>;
  66543. /**
  66544. * Stores the scaling vector
  66545. */
  66546. scaling: Vector3;
  66547. /**
  66548. * Convert the Mesh to CSG
  66549. * @param mesh The Mesh to convert to CSG
  66550. * @returns A new CSG from the Mesh
  66551. */
  66552. static FromMesh(mesh: Mesh): CSG;
  66553. /**
  66554. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  66555. * @param polygons Polygons used to construct a CSG solid
  66556. */
  66557. private static FromPolygons;
  66558. /**
  66559. * Clones, or makes a deep copy, of the CSG
  66560. * @returns A new CSG
  66561. */
  66562. clone(): CSG;
  66563. /**
  66564. * Unions this CSG with another CSG
  66565. * @param csg The CSG to union against this CSG
  66566. * @returns The unioned CSG
  66567. */
  66568. union(csg: CSG): CSG;
  66569. /**
  66570. * Unions this CSG with another CSG in place
  66571. * @param csg The CSG to union against this CSG
  66572. */
  66573. unionInPlace(csg: CSG): void;
  66574. /**
  66575. * Subtracts this CSG with another CSG
  66576. * @param csg The CSG to subtract against this CSG
  66577. * @returns A new CSG
  66578. */
  66579. subtract(csg: CSG): CSG;
  66580. /**
  66581. * Subtracts this CSG with another CSG in place
  66582. * @param csg The CSG to subtact against this CSG
  66583. */
  66584. subtractInPlace(csg: CSG): void;
  66585. /**
  66586. * Intersect this CSG with another CSG
  66587. * @param csg The CSG to intersect against this CSG
  66588. * @returns A new CSG
  66589. */
  66590. intersect(csg: CSG): CSG;
  66591. /**
  66592. * Intersects this CSG with another CSG in place
  66593. * @param csg The CSG to intersect against this CSG
  66594. */
  66595. intersectInPlace(csg: CSG): void;
  66596. /**
  66597. * Return a new CSG solid with solid and empty space switched. This solid is
  66598. * not modified.
  66599. * @returns A new CSG solid with solid and empty space switched
  66600. */
  66601. inverse(): CSG;
  66602. /**
  66603. * Inverses the CSG in place
  66604. */
  66605. inverseInPlace(): void;
  66606. /**
  66607. * This is used to keep meshes transformations so they can be restored
  66608. * when we build back a Babylon Mesh
  66609. * NB : All CSG operations are performed in world coordinates
  66610. * @param csg The CSG to copy the transform attributes from
  66611. * @returns This CSG
  66612. */
  66613. copyTransformAttributes(csg: CSG): CSG;
  66614. /**
  66615. * Build Raw mesh from CSG
  66616. * Coordinates here are in world space
  66617. * @param name The name of the mesh geometry
  66618. * @param scene The Scene
  66619. * @param keepSubMeshes Specifies if the submeshes should be kept
  66620. * @returns A new Mesh
  66621. */
  66622. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  66623. /**
  66624. * Build Mesh from CSG taking material and transforms into account
  66625. * @param name The name of the Mesh
  66626. * @param material The material of the Mesh
  66627. * @param scene The Scene
  66628. * @param keepSubMeshes Specifies if submeshes should be kept
  66629. * @returns The new Mesh
  66630. */
  66631. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  66632. }
  66633. }
  66634. declare module BABYLON {
  66635. /**
  66636. * Class used to create a trail following a mesh
  66637. */
  66638. export class TrailMesh extends Mesh {
  66639. private _generator;
  66640. private _autoStart;
  66641. private _running;
  66642. private _diameter;
  66643. private _length;
  66644. private _sectionPolygonPointsCount;
  66645. private _sectionVectors;
  66646. private _sectionNormalVectors;
  66647. private _beforeRenderObserver;
  66648. /**
  66649. * @constructor
  66650. * @param name The value used by scene.getMeshByName() to do a lookup.
  66651. * @param generator The mesh or transform node to generate a trail.
  66652. * @param scene The scene to add this mesh to.
  66653. * @param diameter Diameter of trailing mesh. Default is 1.
  66654. * @param length Length of trailing mesh. Default is 60.
  66655. * @param autoStart Automatically start trailing mesh. Default true.
  66656. */
  66657. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  66658. /**
  66659. * "TrailMesh"
  66660. * @returns "TrailMesh"
  66661. */
  66662. getClassName(): string;
  66663. private _createMesh;
  66664. /**
  66665. * Start trailing mesh.
  66666. */
  66667. start(): void;
  66668. /**
  66669. * Stop trailing mesh.
  66670. */
  66671. stop(): void;
  66672. /**
  66673. * Update trailing mesh geometry.
  66674. */
  66675. update(): void;
  66676. /**
  66677. * Returns a new TrailMesh object.
  66678. * @param name is a string, the name given to the new mesh
  66679. * @param newGenerator use new generator object for cloned trail mesh
  66680. * @returns a new mesh
  66681. */
  66682. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  66683. /**
  66684. * Serializes this trail mesh
  66685. * @param serializationObject object to write serialization to
  66686. */
  66687. serialize(serializationObject: any): void;
  66688. /**
  66689. * Parses a serialized trail mesh
  66690. * @param parsedMesh the serialized mesh
  66691. * @param scene the scene to create the trail mesh in
  66692. * @returns the created trail mesh
  66693. */
  66694. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  66695. }
  66696. }
  66697. declare module BABYLON {
  66698. /**
  66699. * Class containing static functions to help procedurally build meshes
  66700. */
  66701. export class TiledBoxBuilder {
  66702. /**
  66703. * Creates a box mesh
  66704. * 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)
  66705. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  66706. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66707. * * 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
  66708. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66709. * @param name defines the name of the mesh
  66710. * @param options defines the options used to create the mesh
  66711. * @param scene defines the hosting scene
  66712. * @returns the box mesh
  66713. */
  66714. static CreateTiledBox(name: string, options: {
  66715. pattern?: number;
  66716. width?: number;
  66717. height?: number;
  66718. depth?: number;
  66719. tileSize?: number;
  66720. tileWidth?: number;
  66721. tileHeight?: number;
  66722. alignHorizontal?: number;
  66723. alignVertical?: number;
  66724. faceUV?: Vector4[];
  66725. faceColors?: Color4[];
  66726. sideOrientation?: number;
  66727. updatable?: boolean;
  66728. }, scene?: Nullable<Scene>): Mesh;
  66729. }
  66730. }
  66731. declare module BABYLON {
  66732. /**
  66733. * Class containing static functions to help procedurally build meshes
  66734. */
  66735. export class TorusKnotBuilder {
  66736. /**
  66737. * Creates a torus knot mesh
  66738. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  66739. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  66740. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  66741. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  66742. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66743. * * 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
  66744. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  66745. * @param name defines the name of the mesh
  66746. * @param options defines the options used to create the mesh
  66747. * @param scene defines the hosting scene
  66748. * @returns the torus knot mesh
  66749. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  66750. */
  66751. static CreateTorusKnot(name: string, options: {
  66752. radius?: number;
  66753. tube?: number;
  66754. radialSegments?: number;
  66755. tubularSegments?: number;
  66756. p?: number;
  66757. q?: number;
  66758. updatable?: boolean;
  66759. sideOrientation?: number;
  66760. frontUVs?: Vector4;
  66761. backUVs?: Vector4;
  66762. }, scene: any): Mesh;
  66763. }
  66764. }
  66765. declare module BABYLON {
  66766. /**
  66767. * Polygon
  66768. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  66769. */
  66770. export class Polygon {
  66771. /**
  66772. * Creates a rectangle
  66773. * @param xmin bottom X coord
  66774. * @param ymin bottom Y coord
  66775. * @param xmax top X coord
  66776. * @param ymax top Y coord
  66777. * @returns points that make the resulting rectation
  66778. */
  66779. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  66780. /**
  66781. * Creates a circle
  66782. * @param radius radius of circle
  66783. * @param cx scale in x
  66784. * @param cy scale in y
  66785. * @param numberOfSides number of sides that make up the circle
  66786. * @returns points that make the resulting circle
  66787. */
  66788. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  66789. /**
  66790. * Creates a polygon from input string
  66791. * @param input Input polygon data
  66792. * @returns the parsed points
  66793. */
  66794. static Parse(input: string): Vector2[];
  66795. /**
  66796. * Starts building a polygon from x and y coordinates
  66797. * @param x x coordinate
  66798. * @param y y coordinate
  66799. * @returns the started path2
  66800. */
  66801. static StartingAt(x: number, y: number): Path2;
  66802. }
  66803. /**
  66804. * Builds a polygon
  66805. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  66806. */
  66807. export class PolygonMeshBuilder {
  66808. private _points;
  66809. private _outlinepoints;
  66810. private _holes;
  66811. private _name;
  66812. private _scene;
  66813. private _epoints;
  66814. private _eholes;
  66815. private _addToepoint;
  66816. /**
  66817. * Babylon reference to the earcut plugin.
  66818. */
  66819. bjsEarcut: any;
  66820. /**
  66821. * Creates a PolygonMeshBuilder
  66822. * @param name name of the builder
  66823. * @param contours Path of the polygon
  66824. * @param scene scene to add to when creating the mesh
  66825. * @param earcutInjection can be used to inject your own earcut reference
  66826. */
  66827. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  66828. /**
  66829. * Adds a whole within the polygon
  66830. * @param hole Array of points defining the hole
  66831. * @returns this
  66832. */
  66833. addHole(hole: Vector2[]): PolygonMeshBuilder;
  66834. /**
  66835. * Creates the polygon
  66836. * @param updatable If the mesh should be updatable
  66837. * @param depth The depth of the mesh created
  66838. * @returns the created mesh
  66839. */
  66840. build(updatable?: boolean, depth?: number): Mesh;
  66841. /**
  66842. * Creates the polygon
  66843. * @param depth The depth of the mesh created
  66844. * @returns the created VertexData
  66845. */
  66846. buildVertexData(depth?: number): VertexData;
  66847. /**
  66848. * Adds a side to the polygon
  66849. * @param positions points that make the polygon
  66850. * @param normals normals of the polygon
  66851. * @param uvs uvs of the polygon
  66852. * @param indices indices of the polygon
  66853. * @param bounds bounds of the polygon
  66854. * @param points points of the polygon
  66855. * @param depth depth of the polygon
  66856. * @param flip flip of the polygon
  66857. */
  66858. private addSide;
  66859. }
  66860. }
  66861. declare module BABYLON {
  66862. /**
  66863. * Class containing static functions to help procedurally build meshes
  66864. */
  66865. export class PolygonBuilder {
  66866. /**
  66867. * Creates a polygon mesh
  66868. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  66869. * * 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
  66870. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  66871. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66872. * * 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)
  66873. * * Remember you can only change the shape positions, not their number when updating a polygon
  66874. * @param name defines the name of the mesh
  66875. * @param options defines the options used to create the mesh
  66876. * @param scene defines the hosting scene
  66877. * @param earcutInjection can be used to inject your own earcut reference
  66878. * @returns the polygon mesh
  66879. */
  66880. static CreatePolygon(name: string, options: {
  66881. shape: Vector3[];
  66882. holes?: Vector3[][];
  66883. depth?: number;
  66884. faceUV?: Vector4[];
  66885. faceColors?: Color4[];
  66886. updatable?: boolean;
  66887. sideOrientation?: number;
  66888. frontUVs?: Vector4;
  66889. backUVs?: Vector4;
  66890. wrap?: boolean;
  66891. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  66892. /**
  66893. * Creates an extruded polygon mesh, with depth in the Y direction.
  66894. * * 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)
  66895. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  66896. * @param name defines the name of the mesh
  66897. * @param options defines the options used to create the mesh
  66898. * @param scene defines the hosting scene
  66899. * @param earcutInjection can be used to inject your own earcut reference
  66900. * @returns the polygon mesh
  66901. */
  66902. static ExtrudePolygon(name: string, options: {
  66903. shape: Vector3[];
  66904. holes?: Vector3[][];
  66905. depth?: number;
  66906. faceUV?: Vector4[];
  66907. faceColors?: Color4[];
  66908. updatable?: boolean;
  66909. sideOrientation?: number;
  66910. frontUVs?: Vector4;
  66911. backUVs?: Vector4;
  66912. wrap?: boolean;
  66913. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  66914. }
  66915. }
  66916. declare module BABYLON {
  66917. /**
  66918. * Class containing static functions to help procedurally build meshes
  66919. */
  66920. export class LatheBuilder {
  66921. /**
  66922. * Creates lathe mesh.
  66923. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  66924. * * 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
  66925. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  66926. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  66927. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  66928. * * 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
  66929. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  66930. * * 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
  66931. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66932. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  66933. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  66934. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66935. * @param name defines the name of the mesh
  66936. * @param options defines the options used to create the mesh
  66937. * @param scene defines the hosting scene
  66938. * @returns the lathe mesh
  66939. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  66940. */
  66941. static CreateLathe(name: string, options: {
  66942. shape: Vector3[];
  66943. radius?: number;
  66944. tessellation?: number;
  66945. clip?: number;
  66946. arc?: number;
  66947. closed?: boolean;
  66948. updatable?: boolean;
  66949. sideOrientation?: number;
  66950. frontUVs?: Vector4;
  66951. backUVs?: Vector4;
  66952. cap?: number;
  66953. invertUV?: boolean;
  66954. }, scene?: Nullable<Scene>): Mesh;
  66955. }
  66956. }
  66957. declare module BABYLON {
  66958. /**
  66959. * Class containing static functions to help procedurally build meshes
  66960. */
  66961. export class TiledPlaneBuilder {
  66962. /**
  66963. * Creates a tiled plane mesh
  66964. * * The parameter `pattern` will, depending on value, do nothing or
  66965. * * * flip (reflect about central vertical) alternate tiles across and up
  66966. * * * flip every tile on alternate rows
  66967. * * * rotate (180 degs) alternate tiles across and up
  66968. * * * rotate every tile on alternate rows
  66969. * * * flip and rotate alternate tiles across and up
  66970. * * * flip and rotate every tile on alternate rows
  66971. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  66972. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  66973. * * 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
  66974. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  66975. * * 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)
  66976. * * 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)
  66977. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  66978. * @param name defines the name of the mesh
  66979. * @param options defines the options used to create the mesh
  66980. * @param scene defines the hosting scene
  66981. * @returns the box mesh
  66982. */
  66983. static CreateTiledPlane(name: string, options: {
  66984. pattern?: number;
  66985. tileSize?: number;
  66986. tileWidth?: number;
  66987. tileHeight?: number;
  66988. size?: number;
  66989. width?: number;
  66990. height?: number;
  66991. alignHorizontal?: number;
  66992. alignVertical?: number;
  66993. sideOrientation?: number;
  66994. frontUVs?: Vector4;
  66995. backUVs?: Vector4;
  66996. updatable?: boolean;
  66997. }, scene?: Nullable<Scene>): Mesh;
  66998. }
  66999. }
  67000. declare module BABYLON {
  67001. /**
  67002. * Class containing static functions to help procedurally build meshes
  67003. */
  67004. export class TubeBuilder {
  67005. /**
  67006. * Creates a tube mesh.
  67007. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  67008. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  67009. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  67010. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  67011. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  67012. * * 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)
  67013. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  67014. * * 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
  67015. * * 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
  67016. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67017. * * 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
  67018. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  67019. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67020. * @param name defines the name of the mesh
  67021. * @param options defines the options used to create the mesh
  67022. * @param scene defines the hosting scene
  67023. * @returns the tube mesh
  67024. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  67025. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  67026. */
  67027. static CreateTube(name: string, options: {
  67028. path: Vector3[];
  67029. radius?: number;
  67030. tessellation?: number;
  67031. radiusFunction?: {
  67032. (i: number, distance: number): number;
  67033. };
  67034. cap?: number;
  67035. arc?: number;
  67036. updatable?: boolean;
  67037. sideOrientation?: number;
  67038. frontUVs?: Vector4;
  67039. backUVs?: Vector4;
  67040. instance?: Mesh;
  67041. invertUV?: boolean;
  67042. }, scene?: Nullable<Scene>): Mesh;
  67043. }
  67044. }
  67045. declare module BABYLON {
  67046. /**
  67047. * Class containing static functions to help procedurally build meshes
  67048. */
  67049. export class IcoSphereBuilder {
  67050. /**
  67051. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  67052. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  67053. * * 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`)
  67054. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  67055. * * 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
  67056. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67057. * * 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
  67058. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67059. * @param name defines the name of the mesh
  67060. * @param options defines the options used to create the mesh
  67061. * @param scene defines the hosting scene
  67062. * @returns the icosahedron mesh
  67063. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  67064. */
  67065. static CreateIcoSphere(name: string, options: {
  67066. radius?: number;
  67067. radiusX?: number;
  67068. radiusY?: number;
  67069. radiusZ?: number;
  67070. flat?: boolean;
  67071. subdivisions?: number;
  67072. sideOrientation?: number;
  67073. frontUVs?: Vector4;
  67074. backUVs?: Vector4;
  67075. updatable?: boolean;
  67076. }, scene?: Nullable<Scene>): Mesh;
  67077. }
  67078. }
  67079. declare module BABYLON {
  67080. /**
  67081. * Class containing static functions to help procedurally build meshes
  67082. */
  67083. export class DecalBuilder {
  67084. /**
  67085. * Creates a decal mesh.
  67086. * 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
  67087. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  67088. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  67089. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  67090. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  67091. * @param name defines the name of the mesh
  67092. * @param sourceMesh defines the mesh where the decal must be applied
  67093. * @param options defines the options used to create the mesh
  67094. * @param scene defines the hosting scene
  67095. * @returns the decal mesh
  67096. * @see https://doc.babylonjs.com/how_to/decals
  67097. */
  67098. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  67099. position?: Vector3;
  67100. normal?: Vector3;
  67101. size?: Vector3;
  67102. angle?: number;
  67103. }): Mesh;
  67104. }
  67105. }
  67106. declare module BABYLON {
  67107. /**
  67108. * Class containing static functions to help procedurally build meshes
  67109. */
  67110. export class MeshBuilder {
  67111. /**
  67112. * Creates a box mesh
  67113. * * The parameter `size` sets the size (float) of each box side (default 1)
  67114. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  67115. * * 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)
  67116. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  67117. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67118. * * 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
  67119. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67120. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  67121. * @param name defines the name of the mesh
  67122. * @param options defines the options used to create the mesh
  67123. * @param scene defines the hosting scene
  67124. * @returns the box mesh
  67125. */
  67126. static CreateBox(name: string, options: {
  67127. size?: number;
  67128. width?: number;
  67129. height?: number;
  67130. depth?: number;
  67131. faceUV?: Vector4[];
  67132. faceColors?: Color4[];
  67133. sideOrientation?: number;
  67134. frontUVs?: Vector4;
  67135. backUVs?: Vector4;
  67136. wrap?: boolean;
  67137. topBaseAt?: number;
  67138. bottomBaseAt?: number;
  67139. updatable?: boolean;
  67140. }, scene?: Nullable<Scene>): Mesh;
  67141. /**
  67142. * Creates a tiled box mesh
  67143. * * faceTiles sets the pattern, tile size and number of tiles for a face
  67144. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67145. * @param name defines the name of the mesh
  67146. * @param options defines the options used to create the mesh
  67147. * @param scene defines the hosting scene
  67148. * @returns the tiled box mesh
  67149. */
  67150. static CreateTiledBox(name: string, options: {
  67151. pattern?: number;
  67152. size?: number;
  67153. width?: number;
  67154. height?: number;
  67155. depth: number;
  67156. tileSize?: number;
  67157. tileWidth?: number;
  67158. tileHeight?: number;
  67159. faceUV?: Vector4[];
  67160. faceColors?: Color4[];
  67161. alignHorizontal?: number;
  67162. alignVertical?: number;
  67163. sideOrientation?: number;
  67164. updatable?: boolean;
  67165. }, scene?: Nullable<Scene>): Mesh;
  67166. /**
  67167. * Creates a sphere mesh
  67168. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  67169. * * 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`)
  67170. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  67171. * * 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
  67172. * * 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)
  67173. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67174. * * 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
  67175. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67176. * @param name defines the name of the mesh
  67177. * @param options defines the options used to create the mesh
  67178. * @param scene defines the hosting scene
  67179. * @returns the sphere mesh
  67180. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  67181. */
  67182. static CreateSphere(name: string, options: {
  67183. segments?: number;
  67184. diameter?: number;
  67185. diameterX?: number;
  67186. diameterY?: number;
  67187. diameterZ?: number;
  67188. arc?: number;
  67189. slice?: number;
  67190. sideOrientation?: number;
  67191. frontUVs?: Vector4;
  67192. backUVs?: Vector4;
  67193. updatable?: boolean;
  67194. }, scene?: Nullable<Scene>): Mesh;
  67195. /**
  67196. * Creates a plane polygonal mesh. By default, this is a disc
  67197. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  67198. * * 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
  67199. * * 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
  67200. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67201. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  67202. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67203. * @param name defines the name of the mesh
  67204. * @param options defines the options used to create the mesh
  67205. * @param scene defines the hosting scene
  67206. * @returns the plane polygonal mesh
  67207. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  67208. */
  67209. static CreateDisc(name: string, options: {
  67210. radius?: number;
  67211. tessellation?: number;
  67212. arc?: number;
  67213. updatable?: boolean;
  67214. sideOrientation?: number;
  67215. frontUVs?: Vector4;
  67216. backUVs?: Vector4;
  67217. }, scene?: Nullable<Scene>): Mesh;
  67218. /**
  67219. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  67220. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  67221. * * 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`)
  67222. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  67223. * * 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
  67224. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67225. * * 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
  67226. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67227. * @param name defines the name of the mesh
  67228. * @param options defines the options used to create the mesh
  67229. * @param scene defines the hosting scene
  67230. * @returns the icosahedron mesh
  67231. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  67232. */
  67233. static CreateIcoSphere(name: string, options: {
  67234. radius?: number;
  67235. radiusX?: number;
  67236. radiusY?: number;
  67237. radiusZ?: number;
  67238. flat?: boolean;
  67239. subdivisions?: number;
  67240. sideOrientation?: number;
  67241. frontUVs?: Vector4;
  67242. backUVs?: Vector4;
  67243. updatable?: boolean;
  67244. }, scene?: Nullable<Scene>): Mesh;
  67245. /**
  67246. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  67247. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  67248. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  67249. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  67250. * * 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
  67251. * * 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
  67252. * * 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
  67253. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67254. * * 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
  67255. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  67256. * * 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
  67257. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  67258. * * 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
  67259. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  67260. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67261. * @param name defines the name of the mesh
  67262. * @param options defines the options used to create the mesh
  67263. * @param scene defines the hosting scene
  67264. * @returns the ribbon mesh
  67265. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  67266. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  67267. */
  67268. static CreateRibbon(name: string, options: {
  67269. pathArray: Vector3[][];
  67270. closeArray?: boolean;
  67271. closePath?: boolean;
  67272. offset?: number;
  67273. updatable?: boolean;
  67274. sideOrientation?: number;
  67275. frontUVs?: Vector4;
  67276. backUVs?: Vector4;
  67277. instance?: Mesh;
  67278. invertUV?: boolean;
  67279. uvs?: Vector2[];
  67280. colors?: Color4[];
  67281. }, scene?: Nullable<Scene>): Mesh;
  67282. /**
  67283. * Creates a cylinder or a cone mesh
  67284. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  67285. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  67286. * * 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.
  67287. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  67288. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  67289. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  67290. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  67291. * * 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).
  67292. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  67293. * * 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).
  67294. * * 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
  67295. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  67296. * * 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
  67297. * * 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.
  67298. * * If `enclose` is false, a ring surface is one element.
  67299. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  67300. * * 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
  67301. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67302. * * 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
  67303. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  67304. * @param name defines the name of the mesh
  67305. * @param options defines the options used to create the mesh
  67306. * @param scene defines the hosting scene
  67307. * @returns the cylinder mesh
  67308. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  67309. */
  67310. static CreateCylinder(name: string, options: {
  67311. height?: number;
  67312. diameterTop?: number;
  67313. diameterBottom?: number;
  67314. diameter?: number;
  67315. tessellation?: number;
  67316. subdivisions?: number;
  67317. arc?: number;
  67318. faceColors?: Color4[];
  67319. faceUV?: Vector4[];
  67320. updatable?: boolean;
  67321. hasRings?: boolean;
  67322. enclose?: boolean;
  67323. cap?: number;
  67324. sideOrientation?: number;
  67325. frontUVs?: Vector4;
  67326. backUVs?: Vector4;
  67327. }, scene?: Nullable<Scene>): Mesh;
  67328. /**
  67329. * Creates a torus mesh
  67330. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  67331. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  67332. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  67333. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67334. * * 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
  67335. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  67336. * @param name defines the name of the mesh
  67337. * @param options defines the options used to create the mesh
  67338. * @param scene defines the hosting scene
  67339. * @returns the torus mesh
  67340. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  67341. */
  67342. static CreateTorus(name: string, options: {
  67343. diameter?: number;
  67344. thickness?: number;
  67345. tessellation?: number;
  67346. updatable?: boolean;
  67347. sideOrientation?: number;
  67348. frontUVs?: Vector4;
  67349. backUVs?: Vector4;
  67350. }, scene?: Nullable<Scene>): Mesh;
  67351. /**
  67352. * Creates a torus knot mesh
  67353. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  67354. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  67355. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  67356. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  67357. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67358. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  67359. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  67360. * @param name defines the name of the mesh
  67361. * @param options defines the options used to create the mesh
  67362. * @param scene defines the hosting scene
  67363. * @returns the torus knot mesh
  67364. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  67365. */
  67366. static CreateTorusKnot(name: string, options: {
  67367. radius?: number;
  67368. tube?: number;
  67369. radialSegments?: number;
  67370. tubularSegments?: number;
  67371. p?: number;
  67372. q?: number;
  67373. updatable?: boolean;
  67374. sideOrientation?: number;
  67375. frontUVs?: Vector4;
  67376. backUVs?: Vector4;
  67377. }, scene?: Nullable<Scene>): Mesh;
  67378. /**
  67379. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  67380. * * 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
  67381. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  67382. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  67383. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  67384. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  67385. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  67386. * * 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
  67387. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  67388. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67389. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  67390. * @param name defines the name of the new line system
  67391. * @param options defines the options used to create the line system
  67392. * @param scene defines the hosting scene
  67393. * @returns a new line system mesh
  67394. */
  67395. static CreateLineSystem(name: string, options: {
  67396. lines: Vector3[][];
  67397. updatable?: boolean;
  67398. instance?: Nullable<LinesMesh>;
  67399. colors?: Nullable<Color4[][]>;
  67400. useVertexAlpha?: boolean;
  67401. }, scene: Nullable<Scene>): LinesMesh;
  67402. /**
  67403. * Creates a line mesh
  67404. * 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
  67405. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  67406. * * The parameter `points` is an array successive Vector3
  67407. * * 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
  67408. * * The optional parameter `colors` is an array of successive Color4, one per line point
  67409. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  67410. * * When updating an instance, remember that only point positions can change, not the number of points
  67411. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67412. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  67413. * @param name defines the name of the new line system
  67414. * @param options defines the options used to create the line system
  67415. * @param scene defines the hosting scene
  67416. * @returns a new line mesh
  67417. */
  67418. static CreateLines(name: string, options: {
  67419. points: Vector3[];
  67420. updatable?: boolean;
  67421. instance?: Nullable<LinesMesh>;
  67422. colors?: Color4[];
  67423. useVertexAlpha?: boolean;
  67424. }, scene?: Nullable<Scene>): LinesMesh;
  67425. /**
  67426. * Creates a dashed line mesh
  67427. * * 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
  67428. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  67429. * * The parameter `points` is an array successive Vector3
  67430. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  67431. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  67432. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  67433. * * 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
  67434. * * When updating an instance, remember that only point positions can change, not the number of points
  67435. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67436. * @param name defines the name of the mesh
  67437. * @param options defines the options used to create the mesh
  67438. * @param scene defines the hosting scene
  67439. * @returns the dashed line mesh
  67440. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  67441. */
  67442. static CreateDashedLines(name: string, options: {
  67443. points: Vector3[];
  67444. dashSize?: number;
  67445. gapSize?: number;
  67446. dashNb?: number;
  67447. updatable?: boolean;
  67448. instance?: LinesMesh;
  67449. }, scene?: Nullable<Scene>): LinesMesh;
  67450. /**
  67451. * 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.
  67452. * * 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.
  67453. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  67454. * * 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.
  67455. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  67456. * * 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
  67457. * * 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
  67458. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  67459. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67460. * * 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
  67461. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  67462. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  67463. * @param name defines the name of the mesh
  67464. * @param options defines the options used to create the mesh
  67465. * @param scene defines the hosting scene
  67466. * @returns the extruded shape mesh
  67467. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  67468. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  67469. */
  67470. static ExtrudeShape(name: string, options: {
  67471. shape: Vector3[];
  67472. path: Vector3[];
  67473. scale?: number;
  67474. rotation?: number;
  67475. cap?: number;
  67476. updatable?: boolean;
  67477. sideOrientation?: number;
  67478. frontUVs?: Vector4;
  67479. backUVs?: Vector4;
  67480. instance?: Mesh;
  67481. invertUV?: boolean;
  67482. }, scene?: Nullable<Scene>): Mesh;
  67483. /**
  67484. * Creates an custom extruded shape mesh.
  67485. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  67486. * * 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.
  67487. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  67488. * * 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
  67489. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  67490. * * 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
  67491. * * It must returns a float value that will be the scale value applied to the shape on each path point
  67492. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  67493. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  67494. * * 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
  67495. * * 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
  67496. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  67497. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67498. * * 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
  67499. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  67500. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67501. * @param name defines the name of the mesh
  67502. * @param options defines the options used to create the mesh
  67503. * @param scene defines the hosting scene
  67504. * @returns the custom extruded shape mesh
  67505. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  67506. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  67507. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  67508. */
  67509. static ExtrudeShapeCustom(name: string, options: {
  67510. shape: Vector3[];
  67511. path: Vector3[];
  67512. scaleFunction?: any;
  67513. rotationFunction?: any;
  67514. ribbonCloseArray?: boolean;
  67515. ribbonClosePath?: boolean;
  67516. cap?: number;
  67517. updatable?: boolean;
  67518. sideOrientation?: number;
  67519. frontUVs?: Vector4;
  67520. backUVs?: Vector4;
  67521. instance?: Mesh;
  67522. invertUV?: boolean;
  67523. }, scene?: Nullable<Scene>): Mesh;
  67524. /**
  67525. * Creates lathe mesh.
  67526. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  67527. * * 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
  67528. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  67529. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  67530. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  67531. * * 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
  67532. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  67533. * * 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
  67534. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67535. * * 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
  67536. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  67537. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67538. * @param name defines the name of the mesh
  67539. * @param options defines the options used to create the mesh
  67540. * @param scene defines the hosting scene
  67541. * @returns the lathe mesh
  67542. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  67543. */
  67544. static CreateLathe(name: string, options: {
  67545. shape: Vector3[];
  67546. radius?: number;
  67547. tessellation?: number;
  67548. clip?: number;
  67549. arc?: number;
  67550. closed?: boolean;
  67551. updatable?: boolean;
  67552. sideOrientation?: number;
  67553. frontUVs?: Vector4;
  67554. backUVs?: Vector4;
  67555. cap?: number;
  67556. invertUV?: boolean;
  67557. }, scene?: Nullable<Scene>): Mesh;
  67558. /**
  67559. * Creates a tiled plane mesh
  67560. * * You can set a limited pattern arrangement with the tiles
  67561. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67562. * * 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
  67563. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67564. * @param name defines the name of the mesh
  67565. * @param options defines the options used to create the mesh
  67566. * @param scene defines the hosting scene
  67567. * @returns the plane mesh
  67568. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  67569. */
  67570. static CreateTiledPlane(name: string, options: {
  67571. pattern?: number;
  67572. tileSize?: number;
  67573. tileWidth?: number;
  67574. tileHeight?: number;
  67575. size?: number;
  67576. width?: number;
  67577. height?: number;
  67578. alignHorizontal?: number;
  67579. alignVertical?: number;
  67580. sideOrientation?: number;
  67581. frontUVs?: Vector4;
  67582. backUVs?: Vector4;
  67583. updatable?: boolean;
  67584. }, scene?: Nullable<Scene>): Mesh;
  67585. /**
  67586. * Creates a plane mesh
  67587. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  67588. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  67589. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  67590. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67591. * * 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
  67592. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67593. * @param name defines the name of the mesh
  67594. * @param options defines the options used to create the mesh
  67595. * @param scene defines the hosting scene
  67596. * @returns the plane mesh
  67597. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  67598. */
  67599. static CreatePlane(name: string, options: {
  67600. size?: number;
  67601. width?: number;
  67602. height?: number;
  67603. sideOrientation?: number;
  67604. frontUVs?: Vector4;
  67605. backUVs?: Vector4;
  67606. updatable?: boolean;
  67607. sourcePlane?: Plane;
  67608. }, scene?: Nullable<Scene>): Mesh;
  67609. /**
  67610. * Creates a ground mesh
  67611. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  67612. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  67613. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67614. * @param name defines the name of the mesh
  67615. * @param options defines the options used to create the mesh
  67616. * @param scene defines the hosting scene
  67617. * @returns the ground mesh
  67618. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  67619. */
  67620. static CreateGround(name: string, options: {
  67621. width?: number;
  67622. height?: number;
  67623. subdivisions?: number;
  67624. subdivisionsX?: number;
  67625. subdivisionsY?: number;
  67626. updatable?: boolean;
  67627. }, scene?: Nullable<Scene>): Mesh;
  67628. /**
  67629. * Creates a tiled ground mesh
  67630. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  67631. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  67632. * * 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
  67633. * * 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
  67634. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  67635. * @param name defines the name of the mesh
  67636. * @param options defines the options used to create the mesh
  67637. * @param scene defines the hosting scene
  67638. * @returns the tiled ground mesh
  67639. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  67640. */
  67641. static CreateTiledGround(name: string, options: {
  67642. xmin: number;
  67643. zmin: number;
  67644. xmax: number;
  67645. zmax: number;
  67646. subdivisions?: {
  67647. w: number;
  67648. h: number;
  67649. };
  67650. precision?: {
  67651. w: number;
  67652. h: number;
  67653. };
  67654. updatable?: boolean;
  67655. }, scene?: Nullable<Scene>): Mesh;
  67656. /**
  67657. * Creates a ground mesh from a height map
  67658. * * The parameter `url` sets the URL of the height map image resource.
  67659. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  67660. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  67661. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  67662. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  67663. * * 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.
  67664. * * 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).
  67665. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  67666. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  67667. * @param name defines the name of the mesh
  67668. * @param url defines the url to the height map
  67669. * @param options defines the options used to create the mesh
  67670. * @param scene defines the hosting scene
  67671. * @returns the ground mesh
  67672. * @see https://doc.babylonjs.com/babylon101/height_map
  67673. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  67674. */
  67675. static CreateGroundFromHeightMap(name: string, url: string, options: {
  67676. width?: number;
  67677. height?: number;
  67678. subdivisions?: number;
  67679. minHeight?: number;
  67680. maxHeight?: number;
  67681. colorFilter?: Color3;
  67682. alphaFilter?: number;
  67683. updatable?: boolean;
  67684. onReady?: (mesh: GroundMesh) => void;
  67685. }, scene?: Nullable<Scene>): GroundMesh;
  67686. /**
  67687. * Creates a polygon mesh
  67688. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  67689. * * 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
  67690. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  67691. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67692. * * 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)
  67693. * * Remember you can only change the shape positions, not their number when updating a polygon
  67694. * @param name defines the name of the mesh
  67695. * @param options defines the options used to create the mesh
  67696. * @param scene defines the hosting scene
  67697. * @param earcutInjection can be used to inject your own earcut reference
  67698. * @returns the polygon mesh
  67699. */
  67700. static CreatePolygon(name: string, options: {
  67701. shape: Vector3[];
  67702. holes?: Vector3[][];
  67703. depth?: number;
  67704. faceUV?: Vector4[];
  67705. faceColors?: Color4[];
  67706. updatable?: boolean;
  67707. sideOrientation?: number;
  67708. frontUVs?: Vector4;
  67709. backUVs?: Vector4;
  67710. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  67711. /**
  67712. * Creates an extruded polygon mesh, with depth in the Y direction.
  67713. * * 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)
  67714. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  67715. * @param name defines the name of the mesh
  67716. * @param options defines the options used to create the mesh
  67717. * @param scene defines the hosting scene
  67718. * @param earcutInjection can be used to inject your own earcut reference
  67719. * @returns the polygon mesh
  67720. */
  67721. static ExtrudePolygon(name: string, options: {
  67722. shape: Vector3[];
  67723. holes?: Vector3[][];
  67724. depth?: number;
  67725. faceUV?: Vector4[];
  67726. faceColors?: Color4[];
  67727. updatable?: boolean;
  67728. sideOrientation?: number;
  67729. frontUVs?: Vector4;
  67730. backUVs?: Vector4;
  67731. wrap?: boolean;
  67732. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  67733. /**
  67734. * Creates a tube mesh.
  67735. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  67736. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  67737. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  67738. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  67739. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  67740. * * 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)
  67741. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  67742. * * 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
  67743. * * 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
  67744. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67745. * * 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
  67746. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  67747. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67748. * @param name defines the name of the mesh
  67749. * @param options defines the options used to create the mesh
  67750. * @param scene defines the hosting scene
  67751. * @returns the tube mesh
  67752. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  67753. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  67754. */
  67755. static CreateTube(name: string, options: {
  67756. path: Vector3[];
  67757. radius?: number;
  67758. tessellation?: number;
  67759. radiusFunction?: {
  67760. (i: number, distance: number): number;
  67761. };
  67762. cap?: number;
  67763. arc?: number;
  67764. updatable?: boolean;
  67765. sideOrientation?: number;
  67766. frontUVs?: Vector4;
  67767. backUVs?: Vector4;
  67768. instance?: Mesh;
  67769. invertUV?: boolean;
  67770. }, scene?: Nullable<Scene>): Mesh;
  67771. /**
  67772. * Creates a polyhedron mesh
  67773. * * 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
  67774. * * The parameter `size` (positive float, default 1) sets the polygon size
  67775. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  67776. * * 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`
  67777. * * 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
  67778. * * 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)`)
  67779. * * 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
  67780. * * 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
  67781. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67782. * * 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
  67783. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67784. * @param name defines the name of the mesh
  67785. * @param options defines the options used to create the mesh
  67786. * @param scene defines the hosting scene
  67787. * @returns the polyhedron mesh
  67788. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  67789. */
  67790. static CreatePolyhedron(name: string, options: {
  67791. type?: number;
  67792. size?: number;
  67793. sizeX?: number;
  67794. sizeY?: number;
  67795. sizeZ?: number;
  67796. custom?: any;
  67797. faceUV?: Vector4[];
  67798. faceColors?: Color4[];
  67799. flat?: boolean;
  67800. updatable?: boolean;
  67801. sideOrientation?: number;
  67802. frontUVs?: Vector4;
  67803. backUVs?: Vector4;
  67804. }, scene?: Nullable<Scene>): Mesh;
  67805. /**
  67806. * Creates a decal mesh.
  67807. * 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
  67808. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  67809. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  67810. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  67811. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  67812. * @param name defines the name of the mesh
  67813. * @param sourceMesh defines the mesh where the decal must be applied
  67814. * @param options defines the options used to create the mesh
  67815. * @param scene defines the hosting scene
  67816. * @returns the decal mesh
  67817. * @see https://doc.babylonjs.com/how_to/decals
  67818. */
  67819. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  67820. position?: Vector3;
  67821. normal?: Vector3;
  67822. size?: Vector3;
  67823. angle?: number;
  67824. }): Mesh;
  67825. /**
  67826. * Creates a Capsule Mesh
  67827. * @param name defines the name of the mesh.
  67828. * @param options the constructors options used to shape the mesh.
  67829. * @param scene defines the scene the mesh is scoped to.
  67830. * @returns the capsule mesh
  67831. * @see https://doc.babylonjs.com/how_to/capsule_shape
  67832. */
  67833. static CreateCapsule(name: string, options?: ICreateCapsuleOptions, scene?: Nullable<Scene>): Mesh;
  67834. }
  67835. }
  67836. declare module BABYLON {
  67837. /**
  67838. * A simplifier interface for future simplification implementations
  67839. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  67840. */
  67841. export interface ISimplifier {
  67842. /**
  67843. * Simplification of a given mesh according to the given settings.
  67844. * Since this requires computation, it is assumed that the function runs async.
  67845. * @param settings The settings of the simplification, including quality and distance
  67846. * @param successCallback A callback that will be called after the mesh was simplified.
  67847. * @param errorCallback in case of an error, this callback will be called. optional.
  67848. */
  67849. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  67850. }
  67851. /**
  67852. * Expected simplification settings.
  67853. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  67854. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  67855. */
  67856. export interface ISimplificationSettings {
  67857. /**
  67858. * Gets or sets the expected quality
  67859. */
  67860. quality: number;
  67861. /**
  67862. * Gets or sets the distance when this optimized version should be used
  67863. */
  67864. distance: number;
  67865. /**
  67866. * Gets an already optimized mesh
  67867. */
  67868. optimizeMesh?: boolean;
  67869. }
  67870. /**
  67871. * Class used to specify simplification options
  67872. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  67873. */
  67874. export class SimplificationSettings implements ISimplificationSettings {
  67875. /** expected quality */
  67876. quality: number;
  67877. /** distance when this optimized version should be used */
  67878. distance: number;
  67879. /** already optimized mesh */
  67880. optimizeMesh?: boolean | undefined;
  67881. /**
  67882. * Creates a SimplificationSettings
  67883. * @param quality expected quality
  67884. * @param distance distance when this optimized version should be used
  67885. * @param optimizeMesh already optimized mesh
  67886. */
  67887. constructor(
  67888. /** expected quality */
  67889. quality: number,
  67890. /** distance when this optimized version should be used */
  67891. distance: number,
  67892. /** already optimized mesh */
  67893. optimizeMesh?: boolean | undefined);
  67894. }
  67895. /**
  67896. * Interface used to define a simplification task
  67897. */
  67898. export interface ISimplificationTask {
  67899. /**
  67900. * Array of settings
  67901. */
  67902. settings: Array<ISimplificationSettings>;
  67903. /**
  67904. * Simplification type
  67905. */
  67906. simplificationType: SimplificationType;
  67907. /**
  67908. * Mesh to simplify
  67909. */
  67910. mesh: Mesh;
  67911. /**
  67912. * Callback called on success
  67913. */
  67914. successCallback?: () => void;
  67915. /**
  67916. * Defines if parallel processing can be used
  67917. */
  67918. parallelProcessing: boolean;
  67919. }
  67920. /**
  67921. * Queue used to order the simplification tasks
  67922. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  67923. */
  67924. export class SimplificationQueue {
  67925. private _simplificationArray;
  67926. /**
  67927. * Gets a boolean indicating that the process is still running
  67928. */
  67929. running: boolean;
  67930. /**
  67931. * Creates a new queue
  67932. */
  67933. constructor();
  67934. /**
  67935. * Adds a new simplification task
  67936. * @param task defines a task to add
  67937. */
  67938. addTask(task: ISimplificationTask): void;
  67939. /**
  67940. * Execute next task
  67941. */
  67942. executeNext(): void;
  67943. /**
  67944. * Execute a simplification task
  67945. * @param task defines the task to run
  67946. */
  67947. runSimplification(task: ISimplificationTask): void;
  67948. private getSimplifier;
  67949. }
  67950. /**
  67951. * The implemented types of simplification
  67952. * At the moment only Quadratic Error Decimation is implemented
  67953. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  67954. */
  67955. export enum SimplificationType {
  67956. /** Quadratic error decimation */
  67957. QUADRATIC = 0
  67958. }
  67959. /**
  67960. * An implementation of the Quadratic Error simplification algorithm.
  67961. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  67962. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  67963. * @author RaananW
  67964. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  67965. */
  67966. export class QuadraticErrorSimplification implements ISimplifier {
  67967. private _mesh;
  67968. private triangles;
  67969. private vertices;
  67970. private references;
  67971. private _reconstructedMesh;
  67972. /** Gets or sets the number pf sync interations */
  67973. syncIterations: number;
  67974. /** Gets or sets the aggressiveness of the simplifier */
  67975. aggressiveness: number;
  67976. /** Gets or sets the number of allowed iterations for decimation */
  67977. decimationIterations: number;
  67978. /** Gets or sets the espilon to use for bounding box computation */
  67979. boundingBoxEpsilon: number;
  67980. /**
  67981. * Creates a new QuadraticErrorSimplification
  67982. * @param _mesh defines the target mesh
  67983. */
  67984. constructor(_mesh: Mesh);
  67985. /**
  67986. * Simplification of a given mesh according to the given settings.
  67987. * Since this requires computation, it is assumed that the function runs async.
  67988. * @param settings The settings of the simplification, including quality and distance
  67989. * @param successCallback A callback that will be called after the mesh was simplified.
  67990. */
  67991. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  67992. private runDecimation;
  67993. private initWithMesh;
  67994. private init;
  67995. private reconstructMesh;
  67996. private initDecimatedMesh;
  67997. private isFlipped;
  67998. private updateTriangles;
  67999. private identifyBorder;
  68000. private updateMesh;
  68001. private vertexError;
  68002. private calculateError;
  68003. }
  68004. }
  68005. declare module BABYLON {
  68006. interface Scene {
  68007. /** @hidden (Backing field) */
  68008. _simplificationQueue: SimplificationQueue;
  68009. /**
  68010. * Gets or sets the simplification queue attached to the scene
  68011. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  68012. */
  68013. simplificationQueue: SimplificationQueue;
  68014. }
  68015. interface Mesh {
  68016. /**
  68017. * Simplify the mesh according to the given array of settings.
  68018. * Function will return immediately and will simplify async
  68019. * @param settings a collection of simplification settings
  68020. * @param parallelProcessing should all levels calculate parallel or one after the other
  68021. * @param simplificationType the type of simplification to run
  68022. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  68023. * @returns the current mesh
  68024. */
  68025. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  68026. }
  68027. /**
  68028. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  68029. * created in a scene
  68030. */
  68031. export class SimplicationQueueSceneComponent implements ISceneComponent {
  68032. /**
  68033. * The component name helpfull to identify the component in the list of scene components.
  68034. */
  68035. readonly name: string;
  68036. /**
  68037. * The scene the component belongs to.
  68038. */
  68039. scene: Scene;
  68040. /**
  68041. * Creates a new instance of the component for the given scene
  68042. * @param scene Defines the scene to register the component in
  68043. */
  68044. constructor(scene: Scene);
  68045. /**
  68046. * Registers the component in a given scene
  68047. */
  68048. register(): void;
  68049. /**
  68050. * Rebuilds the elements related to this component in case of
  68051. * context lost for instance.
  68052. */
  68053. rebuild(): void;
  68054. /**
  68055. * Disposes the component and the associated ressources
  68056. */
  68057. dispose(): void;
  68058. private _beforeCameraUpdate;
  68059. }
  68060. }
  68061. declare module BABYLON {
  68062. interface Mesh {
  68063. /**
  68064. * Gets or sets a boolean defining if we want picking to pick thin instances as well
  68065. */
  68066. thinInstanceEnablePicking: boolean;
  68067. /**
  68068. * Creates a new thin instance
  68069. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  68070. * @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
  68071. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  68072. */
  68073. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  68074. /**
  68075. * Adds the transformation (matrix) of the current mesh as a thin instance
  68076. * @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
  68077. * @returns the thin instance index number
  68078. */
  68079. thinInstanceAddSelf(refresh: boolean): number;
  68080. /**
  68081. * Registers a custom attribute to be used with thin instances
  68082. * @param kind name of the attribute
  68083. * @param stride size in floats of the attribute
  68084. */
  68085. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  68086. /**
  68087. * Sets the matrix of a thin instance
  68088. * @param index index of the thin instance
  68089. * @param matrix matrix to set
  68090. * @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
  68091. */
  68092. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  68093. /**
  68094. * Sets the value of a custom attribute for a thin instance
  68095. * @param kind name of the attribute
  68096. * @param index index of the thin instance
  68097. * @param value value to set
  68098. * @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
  68099. */
  68100. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  68101. /**
  68102. * 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.
  68103. */
  68104. thinInstanceCount: number;
  68105. /**
  68106. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  68107. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  68108. * @param buffer buffer to set
  68109. * @param stride size in floats of each value of the buffer
  68110. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  68111. */
  68112. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  68113. /**
  68114. * Gets the list of world matrices
  68115. * @return an array containing all the world matrices from the thin instances
  68116. */
  68117. thinInstanceGetWorldMatrices(): Matrix[];
  68118. /**
  68119. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  68120. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  68121. */
  68122. thinInstanceBufferUpdated(kind: string): void;
  68123. /**
  68124. * Applies a partial update to a buffer directly on the GPU
  68125. * 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
  68126. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  68127. * @param data the data to set in the GPU buffer
  68128. * @param offset the offset in the GPU buffer where to update the data
  68129. */
  68130. thinInstancePartialBufferUpdate(kind: string, data: Float32Array, offset: number): void;
  68131. /**
  68132. * Refreshes the bounding info, taking into account all the thin instances defined
  68133. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  68134. */
  68135. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  68136. /** @hidden */
  68137. _thinInstanceInitializeUserStorage(): void;
  68138. /** @hidden */
  68139. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  68140. /** @hidden */
  68141. _userThinInstanceBuffersStorage: {
  68142. data: {
  68143. [key: string]: Float32Array;
  68144. };
  68145. sizes: {
  68146. [key: string]: number;
  68147. };
  68148. vertexBuffers: {
  68149. [key: string]: Nullable<VertexBuffer>;
  68150. };
  68151. strides: {
  68152. [key: string]: number;
  68153. };
  68154. };
  68155. }
  68156. }
  68157. declare module BABYLON {
  68158. /**
  68159. * Navigation plugin interface to add navigation constrained by a navigation mesh
  68160. */
  68161. export interface INavigationEnginePlugin {
  68162. /**
  68163. * plugin name
  68164. */
  68165. name: string;
  68166. /**
  68167. * Creates a navigation mesh
  68168. * @param meshes array of all the geometry used to compute the navigatio mesh
  68169. * @param parameters bunch of parameters used to filter geometry
  68170. */
  68171. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  68172. /**
  68173. * Create a navigation mesh debug mesh
  68174. * @param scene is where the mesh will be added
  68175. * @returns debug display mesh
  68176. */
  68177. createDebugNavMesh(scene: Scene): Mesh;
  68178. /**
  68179. * Get a navigation mesh constrained position, closest to the parameter position
  68180. * @param position world position
  68181. * @returns the closest point to position constrained by the navigation mesh
  68182. */
  68183. getClosestPoint(position: Vector3): Vector3;
  68184. /**
  68185. * Get a navigation mesh constrained position, closest to the parameter position
  68186. * @param position world position
  68187. * @param result output the closest point to position constrained by the navigation mesh
  68188. */
  68189. getClosestPointToRef(position: Vector3, result: Vector3): void;
  68190. /**
  68191. * Get a navigation mesh constrained position, within a particular radius
  68192. * @param position world position
  68193. * @param maxRadius the maximum distance to the constrained world position
  68194. * @returns the closest point to position constrained by the navigation mesh
  68195. */
  68196. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  68197. /**
  68198. * Get a navigation mesh constrained position, within a particular radius
  68199. * @param position world position
  68200. * @param maxRadius the maximum distance to the constrained world position
  68201. * @param result output the closest point to position constrained by the navigation mesh
  68202. */
  68203. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  68204. /**
  68205. * Compute the final position from a segment made of destination-position
  68206. * @param position world position
  68207. * @param destination world position
  68208. * @returns the resulting point along the navmesh
  68209. */
  68210. moveAlong(position: Vector3, destination: Vector3): Vector3;
  68211. /**
  68212. * Compute the final position from a segment made of destination-position
  68213. * @param position world position
  68214. * @param destination world position
  68215. * @param result output the resulting point along the navmesh
  68216. */
  68217. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  68218. /**
  68219. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  68220. * @param start world position
  68221. * @param end world position
  68222. * @returns array containing world position composing the path
  68223. */
  68224. computePath(start: Vector3, end: Vector3): Vector3[];
  68225. /**
  68226. * If this plugin is supported
  68227. * @returns true if plugin is supported
  68228. */
  68229. isSupported(): boolean;
  68230. /**
  68231. * Create a new Crowd so you can add agents
  68232. * @param maxAgents the maximum agent count in the crowd
  68233. * @param maxAgentRadius the maximum radius an agent can have
  68234. * @param scene to attach the crowd to
  68235. * @returns the crowd you can add agents to
  68236. */
  68237. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  68238. /**
  68239. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  68240. * The queries will try to find a solution within those bounds
  68241. * default is (1,1,1)
  68242. * @param extent x,y,z value that define the extent around the queries point of reference
  68243. */
  68244. setDefaultQueryExtent(extent: Vector3): void;
  68245. /**
  68246. * Get the Bounding box extent specified by setDefaultQueryExtent
  68247. * @returns the box extent values
  68248. */
  68249. getDefaultQueryExtent(): Vector3;
  68250. /**
  68251. * build the navmesh from a previously saved state using getNavmeshData
  68252. * @param data the Uint8Array returned by getNavmeshData
  68253. */
  68254. buildFromNavmeshData(data: Uint8Array): void;
  68255. /**
  68256. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  68257. * @returns data the Uint8Array that can be saved and reused
  68258. */
  68259. getNavmeshData(): Uint8Array;
  68260. /**
  68261. * Get the Bounding box extent result specified by setDefaultQueryExtent
  68262. * @param result output the box extent values
  68263. */
  68264. getDefaultQueryExtentToRef(result: Vector3): void;
  68265. /**
  68266. * Release all resources
  68267. */
  68268. dispose(): void;
  68269. }
  68270. /**
  68271. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  68272. */
  68273. export interface ICrowd {
  68274. /**
  68275. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  68276. * You can attach anything to that node. The node position is updated in the scene update tick.
  68277. * @param pos world position that will be constrained by the navigation mesh
  68278. * @param parameters agent parameters
  68279. * @param transform hooked to the agent that will be update by the scene
  68280. * @returns agent index
  68281. */
  68282. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  68283. /**
  68284. * Returns the agent position in world space
  68285. * @param index agent index returned by addAgent
  68286. * @returns world space position
  68287. */
  68288. getAgentPosition(index: number): Vector3;
  68289. /**
  68290. * Gets the agent position result in world space
  68291. * @param index agent index returned by addAgent
  68292. * @param result output world space position
  68293. */
  68294. getAgentPositionToRef(index: number, result: Vector3): void;
  68295. /**
  68296. * Gets the agent velocity in world space
  68297. * @param index agent index returned by addAgent
  68298. * @returns world space velocity
  68299. */
  68300. getAgentVelocity(index: number): Vector3;
  68301. /**
  68302. * Gets the agent velocity result in world space
  68303. * @param index agent index returned by addAgent
  68304. * @param result output world space velocity
  68305. */
  68306. getAgentVelocityToRef(index: number, result: Vector3): void;
  68307. /**
  68308. * Gets the agent next target point on the path
  68309. * @param index agent index returned by addAgent
  68310. * @returns world space position
  68311. */
  68312. getAgentNextTargetPath(index: number): Vector3;
  68313. /**
  68314. * Gets the agent state
  68315. * @param index agent index returned by addAgent
  68316. * @returns agent state
  68317. */
  68318. getAgentState(index: number): number;
  68319. /**
  68320. * returns true if the agent in over an off mesh link connection
  68321. * @param index agent index returned by addAgent
  68322. * @returns true if over an off mesh link connection
  68323. */
  68324. overOffmeshConnection(index: number): boolean;
  68325. /**
  68326. * Gets the agent next target point on the path
  68327. * @param index agent index returned by addAgent
  68328. * @param result output world space position
  68329. */
  68330. getAgentNextTargetPathToRef(index: number, result: Vector3): void;
  68331. /**
  68332. * remove a particular agent previously created
  68333. * @param index agent index returned by addAgent
  68334. */
  68335. removeAgent(index: number): void;
  68336. /**
  68337. * get the list of all agents attached to this crowd
  68338. * @returns list of agent indices
  68339. */
  68340. getAgents(): number[];
  68341. /**
  68342. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  68343. * @param deltaTime in seconds
  68344. */
  68345. update(deltaTime: number): void;
  68346. /**
  68347. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  68348. * @param index agent index returned by addAgent
  68349. * @param destination targeted world position
  68350. */
  68351. agentGoto(index: number, destination: Vector3): void;
  68352. /**
  68353. * Teleport the agent to a new position
  68354. * @param index agent index returned by addAgent
  68355. * @param destination targeted world position
  68356. */
  68357. agentTeleport(index: number, destination: Vector3): void;
  68358. /**
  68359. * Update agent parameters
  68360. * @param index agent index returned by addAgent
  68361. * @param parameters agent parameters
  68362. */
  68363. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  68364. /**
  68365. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  68366. * The queries will try to find a solution within those bounds
  68367. * default is (1,1,1)
  68368. * @param extent x,y,z value that define the extent around the queries point of reference
  68369. */
  68370. setDefaultQueryExtent(extent: Vector3): void;
  68371. /**
  68372. * Get the Bounding box extent specified by setDefaultQueryExtent
  68373. * @returns the box extent values
  68374. */
  68375. getDefaultQueryExtent(): Vector3;
  68376. /**
  68377. * Get the Bounding box extent result specified by setDefaultQueryExtent
  68378. * @param result output the box extent values
  68379. */
  68380. getDefaultQueryExtentToRef(result: Vector3): void;
  68381. /**
  68382. * Release all resources
  68383. */
  68384. dispose(): void;
  68385. }
  68386. /**
  68387. * Configures an agent
  68388. */
  68389. export interface IAgentParameters {
  68390. /**
  68391. * Agent radius. [Limit: >= 0]
  68392. */
  68393. radius: number;
  68394. /**
  68395. * Agent height. [Limit: > 0]
  68396. */
  68397. height: number;
  68398. /**
  68399. * Maximum allowed acceleration. [Limit: >= 0]
  68400. */
  68401. maxAcceleration: number;
  68402. /**
  68403. * Maximum allowed speed. [Limit: >= 0]
  68404. */
  68405. maxSpeed: number;
  68406. /**
  68407. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  68408. */
  68409. collisionQueryRange: number;
  68410. /**
  68411. * The path visibility optimization range. [Limit: > 0]
  68412. */
  68413. pathOptimizationRange: number;
  68414. /**
  68415. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  68416. */
  68417. separationWeight: number;
  68418. }
  68419. /**
  68420. * Configures the navigation mesh creation
  68421. */
  68422. export interface INavMeshParameters {
  68423. /**
  68424. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  68425. */
  68426. cs: number;
  68427. /**
  68428. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  68429. */
  68430. ch: number;
  68431. /**
  68432. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  68433. */
  68434. walkableSlopeAngle: number;
  68435. /**
  68436. * Minimum floor to 'ceiling' height that will still allow the floor area to
  68437. * be considered walkable. [Limit: >= 3] [Units: vx]
  68438. */
  68439. walkableHeight: number;
  68440. /**
  68441. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  68442. */
  68443. walkableClimb: number;
  68444. /**
  68445. * The distance to erode/shrink the walkable area of the heightfield away from
  68446. * obstructions. [Limit: >=0] [Units: vx]
  68447. */
  68448. walkableRadius: number;
  68449. /**
  68450. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  68451. */
  68452. maxEdgeLen: number;
  68453. /**
  68454. * The maximum distance a simplfied contour's border edges should deviate
  68455. * the original raw contour. [Limit: >=0] [Units: vx]
  68456. */
  68457. maxSimplificationError: number;
  68458. /**
  68459. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  68460. */
  68461. minRegionArea: number;
  68462. /**
  68463. * Any regions with a span count smaller than this value will, if possible,
  68464. * be merged with larger regions. [Limit: >=0] [Units: vx]
  68465. */
  68466. mergeRegionArea: number;
  68467. /**
  68468. * The maximum number of vertices allowed for polygons generated during the
  68469. * contour to polygon conversion process. [Limit: >= 3]
  68470. */
  68471. maxVertsPerPoly: number;
  68472. /**
  68473. * Sets the sampling distance to use when generating the detail mesh.
  68474. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  68475. */
  68476. detailSampleDist: number;
  68477. /**
  68478. * The maximum distance the detail mesh surface should deviate from heightfield
  68479. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  68480. */
  68481. detailSampleMaxError: number;
  68482. }
  68483. }
  68484. declare module BABYLON {
  68485. /**
  68486. * RecastJS navigation plugin
  68487. */
  68488. export class RecastJSPlugin implements INavigationEnginePlugin {
  68489. /**
  68490. * Reference to the Recast library
  68491. */
  68492. bjsRECAST: any;
  68493. /**
  68494. * plugin name
  68495. */
  68496. name: string;
  68497. /**
  68498. * the first navmesh created. We might extend this to support multiple navmeshes
  68499. */
  68500. navMesh: any;
  68501. /**
  68502. * Initializes the recastJS plugin
  68503. * @param recastInjection can be used to inject your own recast reference
  68504. */
  68505. constructor(recastInjection?: any);
  68506. /**
  68507. * Creates a navigation mesh
  68508. * @param meshes array of all the geometry used to compute the navigatio mesh
  68509. * @param parameters bunch of parameters used to filter geometry
  68510. */
  68511. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  68512. /**
  68513. * Create a navigation mesh debug mesh
  68514. * @param scene is where the mesh will be added
  68515. * @returns debug display mesh
  68516. */
  68517. createDebugNavMesh(scene: Scene): Mesh;
  68518. /**
  68519. * Get a navigation mesh constrained position, closest to the parameter position
  68520. * @param position world position
  68521. * @returns the closest point to position constrained by the navigation mesh
  68522. */
  68523. getClosestPoint(position: Vector3): Vector3;
  68524. /**
  68525. * Get a navigation mesh constrained position, closest to the parameter position
  68526. * @param position world position
  68527. * @param result output the closest point to position constrained by the navigation mesh
  68528. */
  68529. getClosestPointToRef(position: Vector3, result: Vector3): void;
  68530. /**
  68531. * Get a navigation mesh constrained position, within a particular radius
  68532. * @param position world position
  68533. * @param maxRadius the maximum distance to the constrained world position
  68534. * @returns the closest point to position constrained by the navigation mesh
  68535. */
  68536. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  68537. /**
  68538. * Get a navigation mesh constrained position, within a particular radius
  68539. * @param position world position
  68540. * @param maxRadius the maximum distance to the constrained world position
  68541. * @param result output the closest point to position constrained by the navigation mesh
  68542. */
  68543. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  68544. /**
  68545. * Compute the final position from a segment made of destination-position
  68546. * @param position world position
  68547. * @param destination world position
  68548. * @returns the resulting point along the navmesh
  68549. */
  68550. moveAlong(position: Vector3, destination: Vector3): Vector3;
  68551. /**
  68552. * Compute the final position from a segment made of destination-position
  68553. * @param position world position
  68554. * @param destination world position
  68555. * @param result output the resulting point along the navmesh
  68556. */
  68557. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  68558. /**
  68559. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  68560. * @param start world position
  68561. * @param end world position
  68562. * @returns array containing world position composing the path
  68563. */
  68564. computePath(start: Vector3, end: Vector3): Vector3[];
  68565. /**
  68566. * Create a new Crowd so you can add agents
  68567. * @param maxAgents the maximum agent count in the crowd
  68568. * @param maxAgentRadius the maximum radius an agent can have
  68569. * @param scene to attach the crowd to
  68570. * @returns the crowd you can add agents to
  68571. */
  68572. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  68573. /**
  68574. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  68575. * The queries will try to find a solution within those bounds
  68576. * default is (1,1,1)
  68577. * @param extent x,y,z value that define the extent around the queries point of reference
  68578. */
  68579. setDefaultQueryExtent(extent: Vector3): void;
  68580. /**
  68581. * Get the Bounding box extent specified by setDefaultQueryExtent
  68582. * @returns the box extent values
  68583. */
  68584. getDefaultQueryExtent(): Vector3;
  68585. /**
  68586. * build the navmesh from a previously saved state using getNavmeshData
  68587. * @param data the Uint8Array returned by getNavmeshData
  68588. */
  68589. buildFromNavmeshData(data: Uint8Array): void;
  68590. /**
  68591. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  68592. * @returns data the Uint8Array that can be saved and reused
  68593. */
  68594. getNavmeshData(): Uint8Array;
  68595. /**
  68596. * Get the Bounding box extent result specified by setDefaultQueryExtent
  68597. * @param result output the box extent values
  68598. */
  68599. getDefaultQueryExtentToRef(result: Vector3): void;
  68600. /**
  68601. * Disposes
  68602. */
  68603. dispose(): void;
  68604. /**
  68605. * If this plugin is supported
  68606. * @returns true if plugin is supported
  68607. */
  68608. isSupported(): boolean;
  68609. }
  68610. /**
  68611. * Recast detour crowd implementation
  68612. */
  68613. export class RecastJSCrowd implements ICrowd {
  68614. /**
  68615. * Recast/detour plugin
  68616. */
  68617. bjsRECASTPlugin: RecastJSPlugin;
  68618. /**
  68619. * Link to the detour crowd
  68620. */
  68621. recastCrowd: any;
  68622. /**
  68623. * One transform per agent
  68624. */
  68625. transforms: TransformNode[];
  68626. /**
  68627. * All agents created
  68628. */
  68629. agents: number[];
  68630. /**
  68631. * Link to the scene is kept to unregister the crowd from the scene
  68632. */
  68633. private _scene;
  68634. /**
  68635. * Observer for crowd updates
  68636. */
  68637. private _onBeforeAnimationsObserver;
  68638. /**
  68639. * Constructor
  68640. * @param plugin recastJS plugin
  68641. * @param maxAgents the maximum agent count in the crowd
  68642. * @param maxAgentRadius the maximum radius an agent can have
  68643. * @param scene to attach the crowd to
  68644. * @returns the crowd you can add agents to
  68645. */
  68646. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  68647. /**
  68648. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  68649. * You can attach anything to that node. The node position is updated in the scene update tick.
  68650. * @param pos world position that will be constrained by the navigation mesh
  68651. * @param parameters agent parameters
  68652. * @param transform hooked to the agent that will be update by the scene
  68653. * @returns agent index
  68654. */
  68655. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  68656. /**
  68657. * Returns the agent position in world space
  68658. * @param index agent index returned by addAgent
  68659. * @returns world space position
  68660. */
  68661. getAgentPosition(index: number): Vector3;
  68662. /**
  68663. * Returns the agent position result in world space
  68664. * @param index agent index returned by addAgent
  68665. * @param result output world space position
  68666. */
  68667. getAgentPositionToRef(index: number, result: Vector3): void;
  68668. /**
  68669. * Returns the agent velocity in world space
  68670. * @param index agent index returned by addAgent
  68671. * @returns world space velocity
  68672. */
  68673. getAgentVelocity(index: number): Vector3;
  68674. /**
  68675. * Returns the agent velocity result in world space
  68676. * @param index agent index returned by addAgent
  68677. * @param result output world space velocity
  68678. */
  68679. getAgentVelocityToRef(index: number, result: Vector3): void;
  68680. /**
  68681. * Returns the agent next target point on the path
  68682. * @param index agent index returned by addAgent
  68683. * @returns world space position
  68684. */
  68685. getAgentNextTargetPath(index: number): Vector3;
  68686. /**
  68687. * Returns the agent next target point on the path
  68688. * @param index agent index returned by addAgent
  68689. * @param result output world space position
  68690. */
  68691. getAgentNextTargetPathToRef(index: number, result: Vector3): void;
  68692. /**
  68693. * Gets the agent state
  68694. * @param index agent index returned by addAgent
  68695. * @returns agent state
  68696. */
  68697. getAgentState(index: number): number;
  68698. /**
  68699. * returns true if the agent in over an off mesh link connection
  68700. * @param index agent index returned by addAgent
  68701. * @returns true if over an off mesh link connection
  68702. */
  68703. overOffmeshConnection(index: number): boolean;
  68704. /**
  68705. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  68706. * @param index agent index returned by addAgent
  68707. * @param destination targeted world position
  68708. */
  68709. agentGoto(index: number, destination: Vector3): void;
  68710. /**
  68711. * Teleport the agent to a new position
  68712. * @param index agent index returned by addAgent
  68713. * @param destination targeted world position
  68714. */
  68715. agentTeleport(index: number, destination: Vector3): void;
  68716. /**
  68717. * Update agent parameters
  68718. * @param index agent index returned by addAgent
  68719. * @param parameters agent parameters
  68720. */
  68721. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  68722. /**
  68723. * remove a particular agent previously created
  68724. * @param index agent index returned by addAgent
  68725. */
  68726. removeAgent(index: number): void;
  68727. /**
  68728. * get the list of all agents attached to this crowd
  68729. * @returns list of agent indices
  68730. */
  68731. getAgents(): number[];
  68732. /**
  68733. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  68734. * @param deltaTime in seconds
  68735. */
  68736. update(deltaTime: number): void;
  68737. /**
  68738. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  68739. * The queries will try to find a solution within those bounds
  68740. * default is (1,1,1)
  68741. * @param extent x,y,z value that define the extent around the queries point of reference
  68742. */
  68743. setDefaultQueryExtent(extent: Vector3): void;
  68744. /**
  68745. * Get the Bounding box extent specified by setDefaultQueryExtent
  68746. * @returns the box extent values
  68747. */
  68748. getDefaultQueryExtent(): Vector3;
  68749. /**
  68750. * Get the Bounding box extent result specified by setDefaultQueryExtent
  68751. * @param result output the box extent values
  68752. */
  68753. getDefaultQueryExtentToRef(result: Vector3): void;
  68754. /**
  68755. * Release all resources
  68756. */
  68757. dispose(): void;
  68758. }
  68759. }
  68760. declare module BABYLON {
  68761. /**
  68762. * Class used to enable access to IndexedDB
  68763. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  68764. */
  68765. export class Database implements IOfflineProvider {
  68766. private _callbackManifestChecked;
  68767. private _currentSceneUrl;
  68768. private _db;
  68769. private _enableSceneOffline;
  68770. private _enableTexturesOffline;
  68771. private _manifestVersionFound;
  68772. private _mustUpdateRessources;
  68773. private _hasReachedQuota;
  68774. private _isSupported;
  68775. private _idbFactory;
  68776. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  68777. private static IsUASupportingBlobStorage;
  68778. /**
  68779. * Gets a boolean indicating if Database storate is enabled (off by default)
  68780. */
  68781. static IDBStorageEnabled: boolean;
  68782. /**
  68783. * Gets a boolean indicating if scene must be saved in the database
  68784. */
  68785. get enableSceneOffline(): boolean;
  68786. /**
  68787. * Gets a boolean indicating if textures must be saved in the database
  68788. */
  68789. get enableTexturesOffline(): boolean;
  68790. /**
  68791. * Creates a new Database
  68792. * @param urlToScene defines the url to load the scene
  68793. * @param callbackManifestChecked defines the callback to use when manifest is checked
  68794. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  68795. */
  68796. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  68797. private static _ParseURL;
  68798. private static _ReturnFullUrlLocation;
  68799. private _checkManifestFile;
  68800. /**
  68801. * Open the database and make it available
  68802. * @param successCallback defines the callback to call on success
  68803. * @param errorCallback defines the callback to call on error
  68804. */
  68805. open(successCallback: () => void, errorCallback: () => void): void;
  68806. /**
  68807. * Loads an image from the database
  68808. * @param url defines the url to load from
  68809. * @param image defines the target DOM image
  68810. */
  68811. loadImage(url: string, image: HTMLImageElement): void;
  68812. private _loadImageFromDBAsync;
  68813. private _saveImageIntoDBAsync;
  68814. private _checkVersionFromDB;
  68815. private _loadVersionFromDBAsync;
  68816. private _saveVersionIntoDBAsync;
  68817. /**
  68818. * Loads a file from database
  68819. * @param url defines the URL to load from
  68820. * @param sceneLoaded defines a callback to call on success
  68821. * @param progressCallBack defines a callback to call when progress changed
  68822. * @param errorCallback defines a callback to call on error
  68823. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  68824. */
  68825. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  68826. private _loadFileAsync;
  68827. private _saveFileAsync;
  68828. /**
  68829. * Validates if xhr data is correct
  68830. * @param xhr defines the request to validate
  68831. * @param dataType defines the expected data type
  68832. * @returns true if data is correct
  68833. */
  68834. private static _ValidateXHRData;
  68835. }
  68836. }
  68837. declare module BABYLON {
  68838. /** @hidden */
  68839. export var gpuUpdateParticlesPixelShader: {
  68840. name: string;
  68841. shader: string;
  68842. };
  68843. }
  68844. declare module BABYLON {
  68845. /** @hidden */
  68846. export var gpuUpdateParticlesVertexShader: {
  68847. name: string;
  68848. shader: string;
  68849. };
  68850. }
  68851. declare module BABYLON {
  68852. /** @hidden */
  68853. export var clipPlaneFragmentDeclaration2: {
  68854. name: string;
  68855. shader: string;
  68856. };
  68857. }
  68858. declare module BABYLON {
  68859. /** @hidden */
  68860. export var gpuRenderParticlesPixelShader: {
  68861. name: string;
  68862. shader: string;
  68863. };
  68864. }
  68865. declare module BABYLON {
  68866. /** @hidden */
  68867. export var clipPlaneVertexDeclaration2: {
  68868. name: string;
  68869. shader: string;
  68870. };
  68871. }
  68872. declare module BABYLON {
  68873. /** @hidden */
  68874. export var gpuRenderParticlesVertexShader: {
  68875. name: string;
  68876. shader: string;
  68877. };
  68878. }
  68879. declare module BABYLON {
  68880. /**
  68881. * This represents a GPU particle system in Babylon
  68882. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  68883. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  68884. */
  68885. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  68886. /**
  68887. * The layer mask we are rendering the particles through.
  68888. */
  68889. layerMask: number;
  68890. private _capacity;
  68891. private _activeCount;
  68892. private _currentActiveCount;
  68893. private _accumulatedCount;
  68894. private _renderEffect;
  68895. private _updateEffect;
  68896. private _buffer0;
  68897. private _buffer1;
  68898. private _spriteBuffer;
  68899. private _updateVAO;
  68900. private _renderVAO;
  68901. private _targetIndex;
  68902. private _sourceBuffer;
  68903. private _targetBuffer;
  68904. private _currentRenderId;
  68905. private _started;
  68906. private _stopped;
  68907. private _timeDelta;
  68908. private _randomTexture;
  68909. private _randomTexture2;
  68910. private _attributesStrideSize;
  68911. private _updateEffectOptions;
  68912. private _randomTextureSize;
  68913. private _actualFrame;
  68914. private _customEffect;
  68915. private readonly _rawTextureWidth;
  68916. /**
  68917. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  68918. */
  68919. static get IsSupported(): boolean;
  68920. /**
  68921. * An event triggered when the system is disposed.
  68922. */
  68923. onDisposeObservable: Observable<IParticleSystem>;
  68924. /**
  68925. * An event triggered when the system is stopped
  68926. */
  68927. onStoppedObservable: Observable<IParticleSystem>;
  68928. /**
  68929. * Gets the maximum number of particles active at the same time.
  68930. * @returns The max number of active particles.
  68931. */
  68932. getCapacity(): number;
  68933. /**
  68934. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  68935. * to override the particles.
  68936. */
  68937. forceDepthWrite: boolean;
  68938. /**
  68939. * Gets or set the number of active particles
  68940. */
  68941. get activeParticleCount(): number;
  68942. set activeParticleCount(value: number);
  68943. private _preWarmDone;
  68944. /**
  68945. * Specifies if the particles are updated in emitter local space or world space.
  68946. */
  68947. isLocal: boolean;
  68948. /** Gets or sets a matrix to use to compute projection */
  68949. defaultProjectionMatrix: Matrix;
  68950. /**
  68951. * Is this system ready to be used/rendered
  68952. * @return true if the system is ready
  68953. */
  68954. isReady(): boolean;
  68955. /**
  68956. * Gets if the system has been started. (Note: this will still be true after stop is called)
  68957. * @returns True if it has been started, otherwise false.
  68958. */
  68959. isStarted(): boolean;
  68960. /**
  68961. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  68962. * @returns True if it has been stopped, otherwise false.
  68963. */
  68964. isStopped(): boolean;
  68965. /**
  68966. * Gets a boolean indicating that the system is stopping
  68967. * @returns true if the system is currently stopping
  68968. */
  68969. isStopping(): boolean;
  68970. /**
  68971. * Gets the number of particles active at the same time.
  68972. * @returns The number of active particles.
  68973. */
  68974. getActiveCount(): number;
  68975. /**
  68976. * Starts the particle system and begins to emit
  68977. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  68978. */
  68979. start(delay?: number): void;
  68980. /**
  68981. * Stops the particle system.
  68982. */
  68983. stop(): void;
  68984. /**
  68985. * Remove all active particles
  68986. */
  68987. reset(): void;
  68988. /**
  68989. * Returns the string "GPUParticleSystem"
  68990. * @returns a string containing the class name
  68991. */
  68992. getClassName(): string;
  68993. /**
  68994. * Gets the custom effect used to render the particles
  68995. * @param blendMode Blend mode for which the effect should be retrieved
  68996. * @returns The effect
  68997. */
  68998. getCustomEffect(blendMode?: number): Nullable<Effect>;
  68999. /**
  69000. * Sets the custom effect used to render the particles
  69001. * @param effect The effect to set
  69002. * @param blendMode Blend mode for which the effect should be set
  69003. */
  69004. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  69005. /** @hidden */
  69006. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  69007. /**
  69008. * Observable that will be called just before the particles are drawn
  69009. */
  69010. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  69011. /**
  69012. * Gets the name of the particle vertex shader
  69013. */
  69014. get vertexShaderName(): string;
  69015. private _colorGradientsTexture;
  69016. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  69017. /**
  69018. * Adds a new color gradient
  69019. * @param gradient defines the gradient to use (between 0 and 1)
  69020. * @param color1 defines the color to affect to the specified gradient
  69021. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  69022. * @returns the current particle system
  69023. */
  69024. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  69025. private _refreshColorGradient;
  69026. /** Force the system to rebuild all gradients that need to be resync */
  69027. forceRefreshGradients(): void;
  69028. /**
  69029. * Remove a specific color gradient
  69030. * @param gradient defines the gradient to remove
  69031. * @returns the current particle system
  69032. */
  69033. removeColorGradient(gradient: number): GPUParticleSystem;
  69034. private _angularSpeedGradientsTexture;
  69035. private _sizeGradientsTexture;
  69036. private _velocityGradientsTexture;
  69037. private _limitVelocityGradientsTexture;
  69038. private _dragGradientsTexture;
  69039. private _addFactorGradient;
  69040. /**
  69041. * Adds a new size gradient
  69042. * @param gradient defines the gradient to use (between 0 and 1)
  69043. * @param factor defines the size factor to affect to the specified gradient
  69044. * @returns the current particle system
  69045. */
  69046. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  69047. /**
  69048. * Remove a specific size gradient
  69049. * @param gradient defines the gradient to remove
  69050. * @returns the current particle system
  69051. */
  69052. removeSizeGradient(gradient: number): GPUParticleSystem;
  69053. private _refreshFactorGradient;
  69054. /**
  69055. * Adds a new angular speed gradient
  69056. * @param gradient defines the gradient to use (between 0 and 1)
  69057. * @param factor defines the angular speed to affect to the specified gradient
  69058. * @returns the current particle system
  69059. */
  69060. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  69061. /**
  69062. * Remove a specific angular speed gradient
  69063. * @param gradient defines the gradient to remove
  69064. * @returns the current particle system
  69065. */
  69066. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  69067. /**
  69068. * Adds a new velocity gradient
  69069. * @param gradient defines the gradient to use (between 0 and 1)
  69070. * @param factor defines the velocity to affect to the specified gradient
  69071. * @returns the current particle system
  69072. */
  69073. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  69074. /**
  69075. * Remove a specific velocity gradient
  69076. * @param gradient defines the gradient to remove
  69077. * @returns the current particle system
  69078. */
  69079. removeVelocityGradient(gradient: number): GPUParticleSystem;
  69080. /**
  69081. * Adds a new limit velocity gradient
  69082. * @param gradient defines the gradient to use (between 0 and 1)
  69083. * @param factor defines the limit velocity value to affect to the specified gradient
  69084. * @returns the current particle system
  69085. */
  69086. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  69087. /**
  69088. * Remove a specific limit velocity gradient
  69089. * @param gradient defines the gradient to remove
  69090. * @returns the current particle system
  69091. */
  69092. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  69093. /**
  69094. * Adds a new drag gradient
  69095. * @param gradient defines the gradient to use (between 0 and 1)
  69096. * @param factor defines the drag value to affect to the specified gradient
  69097. * @returns the current particle system
  69098. */
  69099. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  69100. /**
  69101. * Remove a specific drag gradient
  69102. * @param gradient defines the gradient to remove
  69103. * @returns the current particle system
  69104. */
  69105. removeDragGradient(gradient: number): GPUParticleSystem;
  69106. /**
  69107. * Not supported by GPUParticleSystem
  69108. * @param gradient defines the gradient to use (between 0 and 1)
  69109. * @param factor defines the emit rate value to affect to the specified gradient
  69110. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  69111. * @returns the current particle system
  69112. */
  69113. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  69114. /**
  69115. * Not supported by GPUParticleSystem
  69116. * @param gradient defines the gradient to remove
  69117. * @returns the current particle system
  69118. */
  69119. removeEmitRateGradient(gradient: number): IParticleSystem;
  69120. /**
  69121. * Not supported by GPUParticleSystem
  69122. * @param gradient defines the gradient to use (between 0 and 1)
  69123. * @param factor defines the start size value to affect to the specified gradient
  69124. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  69125. * @returns the current particle system
  69126. */
  69127. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  69128. /**
  69129. * Not supported by GPUParticleSystem
  69130. * @param gradient defines the gradient to remove
  69131. * @returns the current particle system
  69132. */
  69133. removeStartSizeGradient(gradient: number): IParticleSystem;
  69134. /**
  69135. * Not supported by GPUParticleSystem
  69136. * @param gradient defines the gradient to use (between 0 and 1)
  69137. * @param min defines the color remap minimal range
  69138. * @param max defines the color remap maximal range
  69139. * @returns the current particle system
  69140. */
  69141. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  69142. /**
  69143. * Not supported by GPUParticleSystem
  69144. * @param gradient defines the gradient to remove
  69145. * @returns the current particle system
  69146. */
  69147. removeColorRemapGradient(): IParticleSystem;
  69148. /**
  69149. * Not supported by GPUParticleSystem
  69150. * @param gradient defines the gradient to use (between 0 and 1)
  69151. * @param min defines the alpha remap minimal range
  69152. * @param max defines the alpha remap maximal range
  69153. * @returns the current particle system
  69154. */
  69155. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  69156. /**
  69157. * Not supported by GPUParticleSystem
  69158. * @param gradient defines the gradient to remove
  69159. * @returns the current particle system
  69160. */
  69161. removeAlphaRemapGradient(): IParticleSystem;
  69162. /**
  69163. * Not supported by GPUParticleSystem
  69164. * @param gradient defines the gradient to use (between 0 and 1)
  69165. * @param color defines the color to affect to the specified gradient
  69166. * @returns the current particle system
  69167. */
  69168. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  69169. /**
  69170. * Not supported by GPUParticleSystem
  69171. * @param gradient defines the gradient to remove
  69172. * @returns the current particle system
  69173. */
  69174. removeRampGradient(): IParticleSystem;
  69175. /**
  69176. * Not supported by GPUParticleSystem
  69177. * @returns the list of ramp gradients
  69178. */
  69179. getRampGradients(): Nullable<Array<Color3Gradient>>;
  69180. /**
  69181. * Not supported by GPUParticleSystem
  69182. * Gets or sets a boolean indicating that ramp gradients must be used
  69183. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  69184. */
  69185. get useRampGradients(): boolean;
  69186. set useRampGradients(value: boolean);
  69187. /**
  69188. * Not supported by GPUParticleSystem
  69189. * @param gradient defines the gradient to use (between 0 and 1)
  69190. * @param factor defines the life time factor to affect to the specified gradient
  69191. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  69192. * @returns the current particle system
  69193. */
  69194. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  69195. /**
  69196. * Not supported by GPUParticleSystem
  69197. * @param gradient defines the gradient to remove
  69198. * @returns the current particle system
  69199. */
  69200. removeLifeTimeGradient(gradient: number): IParticleSystem;
  69201. /**
  69202. * Instantiates a GPU particle system.
  69203. * 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.
  69204. * @param name The name of the particle system
  69205. * @param options The options used to create the system
  69206. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  69207. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  69208. * @param customEffect a custom effect used to change the way particles are rendered by default
  69209. */
  69210. constructor(name: string, options: Partial<{
  69211. capacity: number;
  69212. randomTextureSize: number;
  69213. }>, sceneOrEngine: Scene | ThinEngine, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  69214. protected _reset(): void;
  69215. private _createUpdateVAO;
  69216. private _createRenderVAO;
  69217. private _initialize;
  69218. /** @hidden */
  69219. _recreateUpdateEffect(): void;
  69220. private _getEffect;
  69221. /**
  69222. * Fill the defines array according to the current settings of the particle system
  69223. * @param defines Array to be updated
  69224. * @param blendMode blend mode to take into account when updating the array
  69225. */
  69226. fillDefines(defines: Array<string>, blendMode?: number): void;
  69227. /**
  69228. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  69229. * @param uniforms Uniforms array to fill
  69230. * @param attributes Attributes array to fill
  69231. * @param samplers Samplers array to fill
  69232. */
  69233. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  69234. /** @hidden */
  69235. _recreateRenderEffect(): Effect;
  69236. /**
  69237. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  69238. * @param preWarm defines if we are in the pre-warmimg phase
  69239. */
  69240. animate(preWarm?: boolean): void;
  69241. private _createFactorGradientTexture;
  69242. private _createSizeGradientTexture;
  69243. private _createAngularSpeedGradientTexture;
  69244. private _createVelocityGradientTexture;
  69245. private _createLimitVelocityGradientTexture;
  69246. private _createDragGradientTexture;
  69247. private _createColorGradientTexture;
  69248. /**
  69249. * Renders the particle system in its current state
  69250. * @param preWarm defines if the system should only update the particles but not render them
  69251. * @returns the current number of particles
  69252. */
  69253. render(preWarm?: boolean): number;
  69254. /**
  69255. * Rebuilds the particle system
  69256. */
  69257. rebuild(): void;
  69258. private _releaseBuffers;
  69259. private _releaseVAOs;
  69260. /**
  69261. * Disposes the particle system and free the associated resources
  69262. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  69263. */
  69264. dispose(disposeTexture?: boolean): void;
  69265. /**
  69266. * Clones the particle system.
  69267. * @param name The name of the cloned object
  69268. * @param newEmitter The new emitter to use
  69269. * @returns the cloned particle system
  69270. */
  69271. clone(name: string, newEmitter: any): GPUParticleSystem;
  69272. /**
  69273. * Serializes the particle system to a JSON object
  69274. * @param serializeTexture defines if the texture must be serialized as well
  69275. * @returns the JSON object
  69276. */
  69277. serialize(serializeTexture?: boolean): any;
  69278. /**
  69279. * Parses a JSON object to create a GPU particle system.
  69280. * @param parsedParticleSystem The JSON object to parse
  69281. * @param sceneOrEngine The scene or the engine to create the particle system in
  69282. * @param rootUrl The root url to use to load external dependencies like texture
  69283. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  69284. * @returns the parsed GPU particle system
  69285. */
  69286. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  69287. }
  69288. }
  69289. declare module BABYLON {
  69290. /**
  69291. * Represents a set of particle systems working together to create a specific effect
  69292. */
  69293. export class ParticleSystemSet implements IDisposable {
  69294. /**
  69295. * Gets or sets base Assets URL
  69296. */
  69297. static BaseAssetsUrl: string;
  69298. private _emitterCreationOptions;
  69299. private _emitterNode;
  69300. /**
  69301. * Gets the particle system list
  69302. */
  69303. systems: IParticleSystem[];
  69304. /**
  69305. * Gets the emitter node used with this set
  69306. */
  69307. get emitterNode(): Nullable<TransformNode>;
  69308. /**
  69309. * Creates a new emitter mesh as a sphere
  69310. * @param options defines the options used to create the sphere
  69311. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  69312. * @param scene defines the hosting scene
  69313. */
  69314. setEmitterAsSphere(options: {
  69315. diameter: number;
  69316. segments: number;
  69317. color: Color3;
  69318. }, renderingGroupId: number, scene: Scene): void;
  69319. /**
  69320. * Starts all particle systems of the set
  69321. * @param emitter defines an optional mesh to use as emitter for the particle systems
  69322. */
  69323. start(emitter?: AbstractMesh): void;
  69324. /**
  69325. * Release all associated resources
  69326. */
  69327. dispose(): void;
  69328. /**
  69329. * Serialize the set into a JSON compatible object
  69330. * @param serializeTexture defines if the texture must be serialized as well
  69331. * @returns a JSON compatible representation of the set
  69332. */
  69333. serialize(serializeTexture?: boolean): any;
  69334. /**
  69335. * Parse a new ParticleSystemSet from a serialized source
  69336. * @param data defines a JSON compatible representation of the set
  69337. * @param scene defines the hosting scene
  69338. * @param gpu defines if we want GPU particles or CPU particles
  69339. * @returns a new ParticleSystemSet
  69340. */
  69341. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  69342. }
  69343. }
  69344. declare module BABYLON {
  69345. /**
  69346. * This class is made for on one-liner static method to help creating particle system set.
  69347. */
  69348. export class ParticleHelper {
  69349. /**
  69350. * Gets or sets base Assets URL
  69351. */
  69352. static BaseAssetsUrl: string;
  69353. /** Define the Url to load snippets */
  69354. static SnippetUrl: string;
  69355. /**
  69356. * Create a default particle system that you can tweak
  69357. * @param emitter defines the emitter to use
  69358. * @param capacity defines the system capacity (default is 500 particles)
  69359. * @param scene defines the hosting scene
  69360. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  69361. * @returns the new Particle system
  69362. */
  69363. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  69364. /**
  69365. * This is the main static method (one-liner) of this helper to create different particle systems
  69366. * @param type This string represents the type to the particle system to create
  69367. * @param scene The scene where the particle system should live
  69368. * @param gpu If the system will use gpu
  69369. * @returns the ParticleSystemSet created
  69370. */
  69371. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  69372. /**
  69373. * Static function used to export a particle system to a ParticleSystemSet variable.
  69374. * Please note that the emitter shape is not exported
  69375. * @param systems defines the particle systems to export
  69376. * @returns the created particle system set
  69377. */
  69378. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  69379. /**
  69380. * Creates a particle system from a snippet saved in a remote file
  69381. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  69382. * @param url defines the url to load from
  69383. * @param scene defines the hosting scene
  69384. * @param gpu If the system will use gpu
  69385. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  69386. * @returns a promise that will resolve to the new particle system
  69387. */
  69388. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  69389. /**
  69390. * Creates a particle system from a snippet saved by the particle system editor
  69391. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  69392. * @param scene defines the hosting scene
  69393. * @param gpu If the system will use gpu
  69394. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  69395. * @returns a promise that will resolve to the new particle system
  69396. */
  69397. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  69398. }
  69399. }
  69400. declare module BABYLON {
  69401. interface Engine {
  69402. /**
  69403. * Create an effect to use with particle systems.
  69404. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  69405. * the particle system for which you want to create a custom effect in the last parameter
  69406. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  69407. * @param uniformsNames defines a list of attribute names
  69408. * @param samplers defines an array of string used to represent textures
  69409. * @param defines defines the string containing the defines to use to compile the shaders
  69410. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  69411. * @param onCompiled defines a function to call when the effect creation is successful
  69412. * @param onError defines a function to call when the effect creation has failed
  69413. * @param particleSystem the particle system you want to create the effect for
  69414. * @returns the new Effect
  69415. */
  69416. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  69417. }
  69418. interface Mesh {
  69419. /**
  69420. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  69421. * @returns an array of IParticleSystem
  69422. */
  69423. getEmittedParticleSystems(): IParticleSystem[];
  69424. /**
  69425. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  69426. * @returns an array of IParticleSystem
  69427. */
  69428. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  69429. }
  69430. }
  69431. declare module BABYLON {
  69432. /** Defines the 4 color options */
  69433. export enum PointColor {
  69434. /** color value */
  69435. Color = 2,
  69436. /** uv value */
  69437. UV = 1,
  69438. /** random value */
  69439. Random = 0,
  69440. /** stated value */
  69441. Stated = 3
  69442. }
  69443. /**
  69444. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  69445. * 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.
  69446. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  69447. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  69448. *
  69449. * Full documentation here : TO BE ENTERED
  69450. */
  69451. export class PointsCloudSystem implements IDisposable {
  69452. /**
  69453. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  69454. * Example : var p = SPS.particles[i];
  69455. */
  69456. particles: CloudPoint[];
  69457. /**
  69458. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  69459. */
  69460. nbParticles: number;
  69461. /**
  69462. * This a counter for your own usage. It's not set by any SPS functions.
  69463. */
  69464. counter: number;
  69465. /**
  69466. * The PCS name. This name is also given to the underlying mesh.
  69467. */
  69468. name: string;
  69469. /**
  69470. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  69471. */
  69472. mesh: Mesh;
  69473. /**
  69474. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  69475. * Please read :
  69476. */
  69477. vars: any;
  69478. /**
  69479. * @hidden
  69480. */
  69481. _size: number;
  69482. private _scene;
  69483. private _promises;
  69484. private _positions;
  69485. private _indices;
  69486. private _normals;
  69487. private _colors;
  69488. private _uvs;
  69489. private _indices32;
  69490. private _positions32;
  69491. private _colors32;
  69492. private _uvs32;
  69493. private _updatable;
  69494. private _isVisibilityBoxLocked;
  69495. private _alwaysVisible;
  69496. private _groups;
  69497. private _groupCounter;
  69498. private _computeParticleColor;
  69499. private _computeParticleTexture;
  69500. private _computeParticleRotation;
  69501. private _computeBoundingBox;
  69502. private _isReady;
  69503. /**
  69504. * Creates a PCS (Points Cloud System) object
  69505. * @param name (String) is the PCS name, this will be the underlying mesh name
  69506. * @param pointSize (number) is the size for each point
  69507. * @param scene (Scene) is the scene in which the PCS is added
  69508. * @param options defines the options of the PCS e.g.
  69509. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  69510. */
  69511. constructor(name: string, pointSize: number, scene: Scene, options?: {
  69512. updatable?: boolean;
  69513. });
  69514. /**
  69515. * Builds the PCS underlying mesh. Returns a standard Mesh.
  69516. * If no points were added to the PCS, the returned mesh is just a single point.
  69517. * @returns a promise for the created mesh
  69518. */
  69519. buildMeshAsync(): Promise<Mesh>;
  69520. /**
  69521. * @hidden
  69522. */
  69523. private _buildMesh;
  69524. private _addParticle;
  69525. private _randomUnitVector;
  69526. private _getColorIndicesForCoord;
  69527. private _setPointsColorOrUV;
  69528. private _colorFromTexture;
  69529. private _calculateDensity;
  69530. /**
  69531. * Adds points to the PCS in random positions within a unit sphere
  69532. * @param nb (positive integer) the number of particles to be created from this model
  69533. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  69534. * @returns the number of groups in the system
  69535. */
  69536. addPoints(nb: number, pointFunction?: any): number;
  69537. /**
  69538. * Adds points to the PCS from the surface of the model shape
  69539. * @param mesh is any Mesh object that will be used as a surface model for the points
  69540. * @param nb (positive integer) the number of particles to be created from this model
  69541. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  69542. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  69543. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  69544. * @returns the number of groups in the system
  69545. */
  69546. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  69547. /**
  69548. * Adds points to the PCS inside the model shape
  69549. * @param mesh is any Mesh object that will be used as a surface model for the points
  69550. * @param nb (positive integer) the number of particles to be created from this model
  69551. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  69552. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  69553. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  69554. * @returns the number of groups in the system
  69555. */
  69556. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  69557. /**
  69558. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  69559. * This method calls `updateParticle()` for each particle of the SPS.
  69560. * For an animated SPS, it is usually called within the render loop.
  69561. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  69562. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  69563. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  69564. * @returns the PCS.
  69565. */
  69566. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  69567. /**
  69568. * Disposes the PCS.
  69569. */
  69570. dispose(): void;
  69571. /**
  69572. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  69573. * doc :
  69574. * @returns the PCS.
  69575. */
  69576. refreshVisibleSize(): PointsCloudSystem;
  69577. /**
  69578. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  69579. * @param size the size (float) of the visibility box
  69580. * note : this doesn't lock the PCS mesh bounding box.
  69581. * doc :
  69582. */
  69583. setVisibilityBox(size: number): void;
  69584. /**
  69585. * Gets whether the PCS is always visible or not
  69586. * doc :
  69587. */
  69588. get isAlwaysVisible(): boolean;
  69589. /**
  69590. * Sets the PCS as always visible or not
  69591. * doc :
  69592. */
  69593. set isAlwaysVisible(val: boolean);
  69594. /**
  69595. * Tells to `setParticles()` to compute the particle rotations or not
  69596. * Default value : false. The PCS is faster when it's set to false
  69597. * Note : particle rotations are only applied to parent particles
  69598. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  69599. */
  69600. set computeParticleRotation(val: boolean);
  69601. /**
  69602. * Tells to `setParticles()` to compute the particle colors or not.
  69603. * Default value : true. The PCS is faster when it's set to false.
  69604. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  69605. */
  69606. set computeParticleColor(val: boolean);
  69607. set computeParticleTexture(val: boolean);
  69608. /**
  69609. * Gets if `setParticles()` computes the particle colors or not.
  69610. * Default value : false. The PCS is faster when it's set to false.
  69611. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  69612. */
  69613. get computeParticleColor(): boolean;
  69614. /**
  69615. * Gets if `setParticles()` computes the particle textures or not.
  69616. * Default value : false. The PCS is faster when it's set to false.
  69617. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  69618. */
  69619. get computeParticleTexture(): boolean;
  69620. /**
  69621. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  69622. */
  69623. set computeBoundingBox(val: boolean);
  69624. /**
  69625. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  69626. */
  69627. get computeBoundingBox(): boolean;
  69628. /**
  69629. * This function does nothing. It may be overwritten to set all the particle first values.
  69630. * The PCS doesn't call this function, you may have to call it by your own.
  69631. * doc :
  69632. */
  69633. initParticles(): void;
  69634. /**
  69635. * This function does nothing. It may be overwritten to recycle a particle
  69636. * The PCS doesn't call this function, you can to call it
  69637. * doc :
  69638. * @param particle The particle to recycle
  69639. * @returns the recycled particle
  69640. */
  69641. recycleParticle(particle: CloudPoint): CloudPoint;
  69642. /**
  69643. * Updates a particle : this function should be overwritten by the user.
  69644. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  69645. * doc :
  69646. * @example : just set a particle position or velocity and recycle conditions
  69647. * @param particle The particle to update
  69648. * @returns the updated particle
  69649. */
  69650. updateParticle(particle: CloudPoint): CloudPoint;
  69651. /**
  69652. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  69653. * This does nothing and may be overwritten by the user.
  69654. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  69655. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  69656. * @param update the boolean update value actually passed to setParticles()
  69657. */
  69658. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  69659. /**
  69660. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  69661. * This will be passed three parameters.
  69662. * This does nothing and may be overwritten by the user.
  69663. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  69664. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  69665. * @param update the boolean update value actually passed to setParticles()
  69666. */
  69667. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  69668. }
  69669. }
  69670. declare module BABYLON {
  69671. /**
  69672. * Represents one particle of a points cloud system.
  69673. */
  69674. export class CloudPoint {
  69675. /**
  69676. * particle global index
  69677. */
  69678. idx: number;
  69679. /**
  69680. * The color of the particle
  69681. */
  69682. color: Nullable<Color4>;
  69683. /**
  69684. * The world space position of the particle.
  69685. */
  69686. position: Vector3;
  69687. /**
  69688. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  69689. */
  69690. rotation: Vector3;
  69691. /**
  69692. * The world space rotation quaternion of the particle.
  69693. */
  69694. rotationQuaternion: Nullable<Quaternion>;
  69695. /**
  69696. * The uv of the particle.
  69697. */
  69698. uv: Nullable<Vector2>;
  69699. /**
  69700. * The current speed of the particle.
  69701. */
  69702. velocity: Vector3;
  69703. /**
  69704. * The pivot point in the particle local space.
  69705. */
  69706. pivot: Vector3;
  69707. /**
  69708. * Must the particle be translated from its pivot point in its local space ?
  69709. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  69710. * Default : false
  69711. */
  69712. translateFromPivot: boolean;
  69713. /**
  69714. * Index of this particle in the global "positions" array (Internal use)
  69715. * @hidden
  69716. */
  69717. _pos: number;
  69718. /**
  69719. * @hidden Index of this particle in the global "indices" array (Internal use)
  69720. */
  69721. _ind: number;
  69722. /**
  69723. * Group this particle belongs to
  69724. */
  69725. _group: PointsGroup;
  69726. /**
  69727. * Group id of this particle
  69728. */
  69729. groupId: number;
  69730. /**
  69731. * Index of the particle in its group id (Internal use)
  69732. */
  69733. idxInGroup: number;
  69734. /**
  69735. * @hidden Particle BoundingInfo object (Internal use)
  69736. */
  69737. _boundingInfo: BoundingInfo;
  69738. /**
  69739. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  69740. */
  69741. _pcs: PointsCloudSystem;
  69742. /**
  69743. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  69744. */
  69745. _stillInvisible: boolean;
  69746. /**
  69747. * @hidden Last computed particle rotation matrix
  69748. */
  69749. _rotationMatrix: number[];
  69750. /**
  69751. * Parent particle Id, if any.
  69752. * Default null.
  69753. */
  69754. parentId: Nullable<number>;
  69755. /**
  69756. * @hidden Internal global position in the PCS.
  69757. */
  69758. _globalPosition: Vector3;
  69759. /**
  69760. * Creates a Point Cloud object.
  69761. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  69762. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  69763. * @param group (PointsGroup) is the group the particle belongs to
  69764. * @param groupId (integer) is the group identifier in the PCS.
  69765. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  69766. * @param pcs defines the PCS it is associated to
  69767. */
  69768. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  69769. /**
  69770. * get point size
  69771. */
  69772. get size(): Vector3;
  69773. /**
  69774. * Set point size
  69775. */
  69776. set size(scale: Vector3);
  69777. /**
  69778. * Legacy support, changed quaternion to rotationQuaternion
  69779. */
  69780. get quaternion(): Nullable<Quaternion>;
  69781. /**
  69782. * Legacy support, changed quaternion to rotationQuaternion
  69783. */
  69784. set quaternion(q: Nullable<Quaternion>);
  69785. /**
  69786. * Returns a boolean. True if the particle intersects a mesh, else false
  69787. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  69788. * @param target is the object (point or mesh) what the intersection is computed against
  69789. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  69790. * @returns true if it intersects
  69791. */
  69792. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  69793. /**
  69794. * get the rotation matrix of the particle
  69795. * @hidden
  69796. */
  69797. getRotationMatrix(m: Matrix): void;
  69798. }
  69799. /**
  69800. * Represents a group of points in a points cloud system
  69801. * * PCS internal tool, don't use it manually.
  69802. */
  69803. export class PointsGroup {
  69804. /**
  69805. * The group id
  69806. * @hidden
  69807. */
  69808. groupID: number;
  69809. /**
  69810. * image data for group (internal use)
  69811. * @hidden
  69812. */
  69813. _groupImageData: Nullable<ArrayBufferView>;
  69814. /**
  69815. * Image Width (internal use)
  69816. * @hidden
  69817. */
  69818. _groupImgWidth: number;
  69819. /**
  69820. * Image Height (internal use)
  69821. * @hidden
  69822. */
  69823. _groupImgHeight: number;
  69824. /**
  69825. * Custom position function (internal use)
  69826. * @hidden
  69827. */
  69828. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  69829. /**
  69830. * density per facet for surface points
  69831. * @hidden
  69832. */
  69833. _groupDensity: number[];
  69834. /**
  69835. * Only when points are colored by texture carries pointer to texture list array
  69836. * @hidden
  69837. */
  69838. _textureNb: number;
  69839. /**
  69840. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  69841. * PCS internal tool, don't use it manually.
  69842. * @hidden
  69843. */
  69844. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  69845. }
  69846. }
  69847. declare module BABYLON {
  69848. interface Scene {
  69849. /** @hidden (Backing field) */
  69850. _physicsEngine: Nullable<IPhysicsEngine>;
  69851. /** @hidden */
  69852. _physicsTimeAccumulator: number;
  69853. /**
  69854. * Gets the current physics engine
  69855. * @returns a IPhysicsEngine or null if none attached
  69856. */
  69857. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  69858. /**
  69859. * Enables physics to the current scene
  69860. * @param gravity defines the scene's gravity for the physics engine
  69861. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  69862. * @return a boolean indicating if the physics engine was initialized
  69863. */
  69864. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  69865. /**
  69866. * Disables and disposes the physics engine associated with the scene
  69867. */
  69868. disablePhysicsEngine(): void;
  69869. /**
  69870. * Gets a boolean indicating if there is an active physics engine
  69871. * @returns a boolean indicating if there is an active physics engine
  69872. */
  69873. isPhysicsEnabled(): boolean;
  69874. /**
  69875. * Deletes a physics compound impostor
  69876. * @param compound defines the compound to delete
  69877. */
  69878. deleteCompoundImpostor(compound: any): void;
  69879. /**
  69880. * An event triggered when physic simulation is about to be run
  69881. */
  69882. onBeforePhysicsObservable: Observable<Scene>;
  69883. /**
  69884. * An event triggered when physic simulation has been done
  69885. */
  69886. onAfterPhysicsObservable: Observable<Scene>;
  69887. }
  69888. interface AbstractMesh {
  69889. /** @hidden */
  69890. _physicsImpostor: Nullable<PhysicsImpostor>;
  69891. /**
  69892. * Gets or sets impostor used for physic simulation
  69893. * @see https://doc.babylonjs.com/features/physics_engine
  69894. */
  69895. physicsImpostor: Nullable<PhysicsImpostor>;
  69896. /**
  69897. * Gets the current physics impostor
  69898. * @see https://doc.babylonjs.com/features/physics_engine
  69899. * @returns a physics impostor or null
  69900. */
  69901. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  69902. /** Apply a physic impulse to the mesh
  69903. * @param force defines the force to apply
  69904. * @param contactPoint defines where to apply the force
  69905. * @returns the current mesh
  69906. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  69907. */
  69908. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  69909. /**
  69910. * Creates a physic joint between two meshes
  69911. * @param otherMesh defines the other mesh to use
  69912. * @param pivot1 defines the pivot to use on this mesh
  69913. * @param pivot2 defines the pivot to use on the other mesh
  69914. * @param options defines additional options (can be plugin dependent)
  69915. * @returns the current mesh
  69916. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  69917. */
  69918. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  69919. /** @hidden */
  69920. _disposePhysicsObserver: Nullable<Observer<Node>>;
  69921. }
  69922. /**
  69923. * Defines the physics engine scene component responsible to manage a physics engine
  69924. */
  69925. export class PhysicsEngineSceneComponent implements ISceneComponent {
  69926. /**
  69927. * The component name helpful to identify the component in the list of scene components.
  69928. */
  69929. readonly name: string;
  69930. /**
  69931. * The scene the component belongs to.
  69932. */
  69933. scene: Scene;
  69934. /**
  69935. * Creates a new instance of the component for the given scene
  69936. * @param scene Defines the scene to register the component in
  69937. */
  69938. constructor(scene: Scene);
  69939. /**
  69940. * Registers the component in a given scene
  69941. */
  69942. register(): void;
  69943. /**
  69944. * Rebuilds the elements related to this component in case of
  69945. * context lost for instance.
  69946. */
  69947. rebuild(): void;
  69948. /**
  69949. * Disposes the component and the associated ressources
  69950. */
  69951. dispose(): void;
  69952. }
  69953. }
  69954. declare module BABYLON {
  69955. /**
  69956. * A helper for physics simulations
  69957. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69958. */
  69959. export class PhysicsHelper {
  69960. private _scene;
  69961. private _physicsEngine;
  69962. /**
  69963. * Initializes the Physics helper
  69964. * @param scene Babylon.js scene
  69965. */
  69966. constructor(scene: Scene);
  69967. /**
  69968. * Applies a radial explosion impulse
  69969. * @param origin the origin of the explosion
  69970. * @param radiusOrEventOptions the radius or the options of radial explosion
  69971. * @param strength the explosion strength
  69972. * @param falloff possible options: Constant & Linear. Defaults to Constant
  69973. * @returns A physics radial explosion event, or null
  69974. */
  69975. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  69976. /**
  69977. * Applies a radial explosion force
  69978. * @param origin the origin of the explosion
  69979. * @param radiusOrEventOptions the radius or the options of radial explosion
  69980. * @param strength the explosion strength
  69981. * @param falloff possible options: Constant & Linear. Defaults to Constant
  69982. * @returns A physics radial explosion event, or null
  69983. */
  69984. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  69985. /**
  69986. * Creates a gravitational field
  69987. * @param origin the origin of the explosion
  69988. * @param radiusOrEventOptions the radius or the options of radial explosion
  69989. * @param strength the explosion strength
  69990. * @param falloff possible options: Constant & Linear. Defaults to Constant
  69991. * @returns A physics gravitational field event, or null
  69992. */
  69993. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  69994. /**
  69995. * Creates a physics updraft event
  69996. * @param origin the origin of the updraft
  69997. * @param radiusOrEventOptions the radius or the options of the updraft
  69998. * @param strength the strength of the updraft
  69999. * @param height the height of the updraft
  70000. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  70001. * @returns A physics updraft event, or null
  70002. */
  70003. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  70004. /**
  70005. * Creates a physics vortex event
  70006. * @param origin the of the vortex
  70007. * @param radiusOrEventOptions the radius or the options of the vortex
  70008. * @param strength the strength of the vortex
  70009. * @param height the height of the vortex
  70010. * @returns a Physics vortex event, or null
  70011. * A physics vortex event or null
  70012. */
  70013. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  70014. }
  70015. /**
  70016. * Represents a physics radial explosion event
  70017. */
  70018. class PhysicsRadialExplosionEvent {
  70019. private _scene;
  70020. private _options;
  70021. private _sphere;
  70022. private _dataFetched;
  70023. /**
  70024. * Initializes a radial explosioin event
  70025. * @param _scene BabylonJS scene
  70026. * @param _options The options for the vortex event
  70027. */
  70028. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  70029. /**
  70030. * Returns the data related to the radial explosion event (sphere).
  70031. * @returns The radial explosion event data
  70032. */
  70033. getData(): PhysicsRadialExplosionEventData;
  70034. /**
  70035. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  70036. * @param impostor A physics imposter
  70037. * @param origin the origin of the explosion
  70038. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  70039. */
  70040. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  70041. /**
  70042. * Triggers affecterd impostors callbacks
  70043. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  70044. */
  70045. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  70046. /**
  70047. * Disposes the sphere.
  70048. * @param force Specifies if the sphere should be disposed by force
  70049. */
  70050. dispose(force?: boolean): void;
  70051. /*** Helpers ***/
  70052. private _prepareSphere;
  70053. private _intersectsWithSphere;
  70054. }
  70055. /**
  70056. * Represents a gravitational field event
  70057. */
  70058. class PhysicsGravitationalFieldEvent {
  70059. private _physicsHelper;
  70060. private _scene;
  70061. private _origin;
  70062. private _options;
  70063. private _tickCallback;
  70064. private _sphere;
  70065. private _dataFetched;
  70066. /**
  70067. * Initializes the physics gravitational field event
  70068. * @param _physicsHelper A physics helper
  70069. * @param _scene BabylonJS scene
  70070. * @param _origin The origin position of the gravitational field event
  70071. * @param _options The options for the vortex event
  70072. */
  70073. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  70074. /**
  70075. * Returns the data related to the gravitational field event (sphere).
  70076. * @returns A gravitational field event
  70077. */
  70078. getData(): PhysicsGravitationalFieldEventData;
  70079. /**
  70080. * Enables the gravitational field.
  70081. */
  70082. enable(): void;
  70083. /**
  70084. * Disables the gravitational field.
  70085. */
  70086. disable(): void;
  70087. /**
  70088. * Disposes the sphere.
  70089. * @param force The force to dispose from the gravitational field event
  70090. */
  70091. dispose(force?: boolean): void;
  70092. private _tick;
  70093. }
  70094. /**
  70095. * Represents a physics updraft event
  70096. */
  70097. class PhysicsUpdraftEvent {
  70098. private _scene;
  70099. private _origin;
  70100. private _options;
  70101. private _physicsEngine;
  70102. private _originTop;
  70103. private _originDirection;
  70104. private _tickCallback;
  70105. private _cylinder;
  70106. private _cylinderPosition;
  70107. private _dataFetched;
  70108. /**
  70109. * Initializes the physics updraft event
  70110. * @param _scene BabylonJS scene
  70111. * @param _origin The origin position of the updraft
  70112. * @param _options The options for the updraft event
  70113. */
  70114. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  70115. /**
  70116. * Returns the data related to the updraft event (cylinder).
  70117. * @returns A physics updraft event
  70118. */
  70119. getData(): PhysicsUpdraftEventData;
  70120. /**
  70121. * Enables the updraft.
  70122. */
  70123. enable(): void;
  70124. /**
  70125. * Disables the updraft.
  70126. */
  70127. disable(): void;
  70128. /**
  70129. * Disposes the cylinder.
  70130. * @param force Specifies if the updraft should be disposed by force
  70131. */
  70132. dispose(force?: boolean): void;
  70133. private getImpostorHitData;
  70134. private _tick;
  70135. /*** Helpers ***/
  70136. private _prepareCylinder;
  70137. private _intersectsWithCylinder;
  70138. }
  70139. /**
  70140. * Represents a physics vortex event
  70141. */
  70142. class PhysicsVortexEvent {
  70143. private _scene;
  70144. private _origin;
  70145. private _options;
  70146. private _physicsEngine;
  70147. private _originTop;
  70148. private _tickCallback;
  70149. private _cylinder;
  70150. private _cylinderPosition;
  70151. private _dataFetched;
  70152. /**
  70153. * Initializes the physics vortex event
  70154. * @param _scene The BabylonJS scene
  70155. * @param _origin The origin position of the vortex
  70156. * @param _options The options for the vortex event
  70157. */
  70158. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  70159. /**
  70160. * Returns the data related to the vortex event (cylinder).
  70161. * @returns The physics vortex event data
  70162. */
  70163. getData(): PhysicsVortexEventData;
  70164. /**
  70165. * Enables the vortex.
  70166. */
  70167. enable(): void;
  70168. /**
  70169. * Disables the cortex.
  70170. */
  70171. disable(): void;
  70172. /**
  70173. * Disposes the sphere.
  70174. * @param force
  70175. */
  70176. dispose(force?: boolean): void;
  70177. private getImpostorHitData;
  70178. private _tick;
  70179. /*** Helpers ***/
  70180. private _prepareCylinder;
  70181. private _intersectsWithCylinder;
  70182. }
  70183. /**
  70184. * Options fot the radial explosion event
  70185. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70186. */
  70187. export class PhysicsRadialExplosionEventOptions {
  70188. /**
  70189. * The radius of the sphere for the radial explosion.
  70190. */
  70191. radius: number;
  70192. /**
  70193. * The strenth of the explosion.
  70194. */
  70195. strength: number;
  70196. /**
  70197. * The strenght of the force in correspondence to the distance of the affected object
  70198. */
  70199. falloff: PhysicsRadialImpulseFalloff;
  70200. /**
  70201. * Sphere options for the radial explosion.
  70202. */
  70203. sphere: {
  70204. segments: number;
  70205. diameter: number;
  70206. };
  70207. /**
  70208. * Sphere options for the radial explosion.
  70209. */
  70210. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  70211. }
  70212. /**
  70213. * Options fot the updraft event
  70214. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70215. */
  70216. export class PhysicsUpdraftEventOptions {
  70217. /**
  70218. * The radius of the cylinder for the vortex
  70219. */
  70220. radius: number;
  70221. /**
  70222. * The strenth of the updraft.
  70223. */
  70224. strength: number;
  70225. /**
  70226. * The height of the cylinder for the updraft.
  70227. */
  70228. height: number;
  70229. /**
  70230. * The mode for the the updraft.
  70231. */
  70232. updraftMode: PhysicsUpdraftMode;
  70233. }
  70234. /**
  70235. * Options fot the vortex event
  70236. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70237. */
  70238. export class PhysicsVortexEventOptions {
  70239. /**
  70240. * The radius of the cylinder for the vortex
  70241. */
  70242. radius: number;
  70243. /**
  70244. * The strenth of the vortex.
  70245. */
  70246. strength: number;
  70247. /**
  70248. * The height of the cylinder for the vortex.
  70249. */
  70250. height: number;
  70251. /**
  70252. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  70253. */
  70254. centripetalForceThreshold: number;
  70255. /**
  70256. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  70257. */
  70258. centripetalForceMultiplier: number;
  70259. /**
  70260. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  70261. */
  70262. centrifugalForceMultiplier: number;
  70263. /**
  70264. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  70265. */
  70266. updraftForceMultiplier: number;
  70267. }
  70268. /**
  70269. * The strenght of the force in correspondence to the distance of the affected object
  70270. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70271. */
  70272. export enum PhysicsRadialImpulseFalloff {
  70273. /** Defines that impulse is constant in strength across it's whole radius */
  70274. Constant = 0,
  70275. /** Defines that impulse gets weaker if it's further from the origin */
  70276. Linear = 1
  70277. }
  70278. /**
  70279. * The strength of the force in correspondence to the distance of the affected object
  70280. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70281. */
  70282. export enum PhysicsUpdraftMode {
  70283. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  70284. Center = 0,
  70285. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  70286. Perpendicular = 1
  70287. }
  70288. /**
  70289. * Interface for a physics hit data
  70290. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70291. */
  70292. export interface PhysicsHitData {
  70293. /**
  70294. * The force applied at the contact point
  70295. */
  70296. force: Vector3;
  70297. /**
  70298. * The contact point
  70299. */
  70300. contactPoint: Vector3;
  70301. /**
  70302. * The distance from the origin to the contact point
  70303. */
  70304. distanceFromOrigin: number;
  70305. }
  70306. /**
  70307. * Interface for radial explosion event data
  70308. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70309. */
  70310. export interface PhysicsRadialExplosionEventData {
  70311. /**
  70312. * A sphere used for the radial explosion event
  70313. */
  70314. sphere: Mesh;
  70315. }
  70316. /**
  70317. * Interface for gravitational field event data
  70318. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70319. */
  70320. export interface PhysicsGravitationalFieldEventData {
  70321. /**
  70322. * A sphere mesh used for the gravitational field event
  70323. */
  70324. sphere: Mesh;
  70325. }
  70326. /**
  70327. * Interface for updraft event data
  70328. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70329. */
  70330. export interface PhysicsUpdraftEventData {
  70331. /**
  70332. * A cylinder used for the updraft event
  70333. */
  70334. cylinder: Mesh;
  70335. }
  70336. /**
  70337. * Interface for vortex event data
  70338. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70339. */
  70340. export interface PhysicsVortexEventData {
  70341. /**
  70342. * A cylinder used for the vortex event
  70343. */
  70344. cylinder: Mesh;
  70345. }
  70346. /**
  70347. * Interface for an affected physics impostor
  70348. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70349. */
  70350. export interface PhysicsAffectedImpostorWithData {
  70351. /**
  70352. * The impostor affected by the effect
  70353. */
  70354. impostor: PhysicsImpostor;
  70355. /**
  70356. * The data about the hit/horce from the explosion
  70357. */
  70358. hitData: PhysicsHitData;
  70359. }
  70360. }
  70361. declare module BABYLON {
  70362. /** @hidden */
  70363. export var blackAndWhitePixelShader: {
  70364. name: string;
  70365. shader: string;
  70366. };
  70367. }
  70368. declare module BABYLON {
  70369. /**
  70370. * Post process used to render in black and white
  70371. */
  70372. export class BlackAndWhitePostProcess extends PostProcess {
  70373. /**
  70374. * Linear about to convert he result to black and white (default: 1)
  70375. */
  70376. degree: number;
  70377. /**
  70378. * Gets a string identifying the name of the class
  70379. * @returns "BlackAndWhitePostProcess" string
  70380. */
  70381. getClassName(): string;
  70382. /**
  70383. * Creates a black and white post process
  70384. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  70385. * @param name The name of the effect.
  70386. * @param options The required width/height ratio to downsize to before computing the render pass.
  70387. * @param camera The camera to apply the render pass to.
  70388. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70389. * @param engine The engine which the post process will be applied. (default: current engine)
  70390. * @param reusable If the post process can be reused on the same frame. (default: false)
  70391. */
  70392. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  70393. /** @hidden */
  70394. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlackAndWhitePostProcess>;
  70395. }
  70396. }
  70397. declare module BABYLON {
  70398. /**
  70399. * This represents a set of one or more post processes in Babylon.
  70400. * A post process can be used to apply a shader to a texture after it is rendered.
  70401. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  70402. */
  70403. export class PostProcessRenderEffect {
  70404. private _postProcesses;
  70405. private _getPostProcesses;
  70406. private _singleInstance;
  70407. private _cameras;
  70408. private _indicesForCamera;
  70409. /**
  70410. * Name of the effect
  70411. * @hidden
  70412. */
  70413. _name: string;
  70414. /**
  70415. * Instantiates a post process render effect.
  70416. * A post process can be used to apply a shader to a texture after it is rendered.
  70417. * @param engine The engine the effect is tied to
  70418. * @param name The name of the effect
  70419. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  70420. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  70421. */
  70422. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  70423. /**
  70424. * Checks if all the post processes in the effect are supported.
  70425. */
  70426. get isSupported(): boolean;
  70427. /**
  70428. * Updates the current state of the effect
  70429. * @hidden
  70430. */
  70431. _update(): void;
  70432. /**
  70433. * Attaches the effect on cameras
  70434. * @param cameras The camera to attach to.
  70435. * @hidden
  70436. */
  70437. _attachCameras(cameras: Camera): void;
  70438. /**
  70439. * Attaches the effect on cameras
  70440. * @param cameras The camera to attach to.
  70441. * @hidden
  70442. */
  70443. _attachCameras(cameras: Camera[]): void;
  70444. /**
  70445. * Detaches the effect on cameras
  70446. * @param cameras The camera to detatch from.
  70447. * @hidden
  70448. */
  70449. _detachCameras(cameras: Camera): void;
  70450. /**
  70451. * Detatches the effect on cameras
  70452. * @param cameras The camera to detatch from.
  70453. * @hidden
  70454. */
  70455. _detachCameras(cameras: Camera[]): void;
  70456. /**
  70457. * Enables the effect on given cameras
  70458. * @param cameras The camera to enable.
  70459. * @hidden
  70460. */
  70461. _enable(cameras: Camera): void;
  70462. /**
  70463. * Enables the effect on given cameras
  70464. * @param cameras The camera to enable.
  70465. * @hidden
  70466. */
  70467. _enable(cameras: Nullable<Camera[]>): void;
  70468. /**
  70469. * Disables the effect on the given cameras
  70470. * @param cameras The camera to disable.
  70471. * @hidden
  70472. */
  70473. _disable(cameras: Camera): void;
  70474. /**
  70475. * Disables the effect on the given cameras
  70476. * @param cameras The camera to disable.
  70477. * @hidden
  70478. */
  70479. _disable(cameras: Nullable<Camera[]>): void;
  70480. /**
  70481. * Gets a list of the post processes contained in the effect.
  70482. * @param camera The camera to get the post processes on.
  70483. * @returns The list of the post processes in the effect.
  70484. */
  70485. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  70486. }
  70487. }
  70488. declare module BABYLON {
  70489. /** @hidden */
  70490. export var extractHighlightsPixelShader: {
  70491. name: string;
  70492. shader: string;
  70493. };
  70494. }
  70495. declare module BABYLON {
  70496. /**
  70497. * 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.
  70498. */
  70499. export class ExtractHighlightsPostProcess extends PostProcess {
  70500. /**
  70501. * The luminance threshold, pixels below this value will be set to black.
  70502. */
  70503. threshold: number;
  70504. /** @hidden */
  70505. _exposure: number;
  70506. /**
  70507. * Post process which has the input texture to be used when performing highlight extraction
  70508. * @hidden
  70509. */
  70510. _inputPostProcess: Nullable<PostProcess>;
  70511. /**
  70512. * Gets a string identifying the name of the class
  70513. * @returns "ExtractHighlightsPostProcess" string
  70514. */
  70515. getClassName(): string;
  70516. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  70517. }
  70518. }
  70519. declare module BABYLON {
  70520. /** @hidden */
  70521. export var bloomMergePixelShader: {
  70522. name: string;
  70523. shader: string;
  70524. };
  70525. }
  70526. declare module BABYLON {
  70527. /**
  70528. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  70529. */
  70530. export class BloomMergePostProcess extends PostProcess {
  70531. /** Weight of the bloom to be added to the original input. */
  70532. weight: number;
  70533. /**
  70534. * Gets a string identifying the name of the class
  70535. * @returns "BloomMergePostProcess" string
  70536. */
  70537. getClassName(): string;
  70538. /**
  70539. * Creates a new instance of @see BloomMergePostProcess
  70540. * @param name The name of the effect.
  70541. * @param originalFromInput Post process which's input will be used for the merge.
  70542. * @param blurred Blurred highlights post process which's output will be used.
  70543. * @param weight Weight of the bloom to be added to the original input.
  70544. * @param options The required width/height ratio to downsize to before computing the render pass.
  70545. * @param camera The camera to apply the render pass to.
  70546. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70547. * @param engine The engine which the post process will be applied. (default: current engine)
  70548. * @param reusable If the post process can be reused on the same frame. (default: false)
  70549. * @param textureType Type of textures used when performing the post process. (default: 0)
  70550. * @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)
  70551. */
  70552. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  70553. /** Weight of the bloom to be added to the original input. */
  70554. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  70555. }
  70556. }
  70557. declare module BABYLON {
  70558. /**
  70559. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  70560. */
  70561. export class BloomEffect extends PostProcessRenderEffect {
  70562. private bloomScale;
  70563. /**
  70564. * @hidden Internal
  70565. */
  70566. _effects: Array<PostProcess>;
  70567. /**
  70568. * @hidden Internal
  70569. */
  70570. _downscale: ExtractHighlightsPostProcess;
  70571. private _blurX;
  70572. private _blurY;
  70573. private _merge;
  70574. /**
  70575. * The luminance threshold to find bright areas of the image to bloom.
  70576. */
  70577. get threshold(): number;
  70578. set threshold(value: number);
  70579. /**
  70580. * The strength of the bloom.
  70581. */
  70582. get weight(): number;
  70583. set weight(value: number);
  70584. /**
  70585. * Specifies the size of the bloom blur kernel, relative to the final output size
  70586. */
  70587. get kernel(): number;
  70588. set kernel(value: number);
  70589. /**
  70590. * Creates a new instance of @see BloomEffect
  70591. * @param scene The scene the effect belongs to.
  70592. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  70593. * @param bloomKernel The size of the kernel to be used when applying the blur.
  70594. * @param bloomWeight The the strength of bloom.
  70595. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  70596. * @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)
  70597. */
  70598. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  70599. /**
  70600. * Disposes each of the internal effects for a given camera.
  70601. * @param camera The camera to dispose the effect on.
  70602. */
  70603. disposeEffects(camera: Camera): void;
  70604. /**
  70605. * @hidden Internal
  70606. */
  70607. _updateEffects(): void;
  70608. /**
  70609. * Internal
  70610. * @returns if all the contained post processes are ready.
  70611. * @hidden
  70612. */
  70613. _isReady(): boolean;
  70614. }
  70615. }
  70616. declare module BABYLON {
  70617. /** @hidden */
  70618. export var chromaticAberrationPixelShader: {
  70619. name: string;
  70620. shader: string;
  70621. };
  70622. }
  70623. declare module BABYLON {
  70624. /**
  70625. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  70626. */
  70627. export class ChromaticAberrationPostProcess extends PostProcess {
  70628. /**
  70629. * The amount of seperation of rgb channels (default: 30)
  70630. */
  70631. aberrationAmount: number;
  70632. /**
  70633. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  70634. */
  70635. radialIntensity: number;
  70636. /**
  70637. * 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))
  70638. */
  70639. direction: Vector2;
  70640. /**
  70641. * 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))
  70642. */
  70643. centerPosition: Vector2;
  70644. /** The width of the screen to apply the effect on */
  70645. screenWidth: number;
  70646. /** The height of the screen to apply the effect on */
  70647. screenHeight: number;
  70648. /**
  70649. * Gets a string identifying the name of the class
  70650. * @returns "ChromaticAberrationPostProcess" string
  70651. */
  70652. getClassName(): string;
  70653. /**
  70654. * Creates a new instance ChromaticAberrationPostProcess
  70655. * @param name The name of the effect.
  70656. * @param screenWidth The width of the screen to apply the effect on.
  70657. * @param screenHeight The height of the screen to apply the effect on.
  70658. * @param options The required width/height ratio to downsize to before computing the render pass.
  70659. * @param camera The camera to apply the render pass to.
  70660. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70661. * @param engine The engine which the post process will be applied. (default: current engine)
  70662. * @param reusable If the post process can be reused on the same frame. (default: false)
  70663. * @param textureType Type of textures used when performing the post process. (default: 0)
  70664. * @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)
  70665. */
  70666. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  70667. /** @hidden */
  70668. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ChromaticAberrationPostProcess>;
  70669. }
  70670. }
  70671. declare module BABYLON {
  70672. /** @hidden */
  70673. export var circleOfConfusionPixelShader: {
  70674. name: string;
  70675. shader: string;
  70676. };
  70677. }
  70678. declare module BABYLON {
  70679. /**
  70680. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  70681. */
  70682. export class CircleOfConfusionPostProcess extends PostProcess {
  70683. /**
  70684. * 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.
  70685. */
  70686. lensSize: number;
  70687. /**
  70688. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  70689. */
  70690. fStop: number;
  70691. /**
  70692. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  70693. */
  70694. focusDistance: number;
  70695. /**
  70696. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  70697. */
  70698. focalLength: number;
  70699. /**
  70700. * Gets a string identifying the name of the class
  70701. * @returns "CircleOfConfusionPostProcess" string
  70702. */
  70703. getClassName(): string;
  70704. private _depthTexture;
  70705. /**
  70706. * Creates a new instance CircleOfConfusionPostProcess
  70707. * @param name The name of the effect.
  70708. * @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.
  70709. * @param options The required width/height ratio to downsize to before computing the render pass.
  70710. * @param camera The camera to apply the render pass to.
  70711. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70712. * @param engine The engine which the post process will be applied. (default: current engine)
  70713. * @param reusable If the post process can be reused on the same frame. (default: false)
  70714. * @param textureType Type of textures used when performing the post process. (default: 0)
  70715. * @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)
  70716. */
  70717. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  70718. /**
  70719. * 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.
  70720. */
  70721. set depthTexture(value: RenderTargetTexture);
  70722. }
  70723. }
  70724. declare module BABYLON {
  70725. /** @hidden */
  70726. export var colorCorrectionPixelShader: {
  70727. name: string;
  70728. shader: string;
  70729. };
  70730. }
  70731. declare module BABYLON {
  70732. /**
  70733. *
  70734. * This post-process allows the modification of rendered colors by using
  70735. * a 'look-up table' (LUT). This effect is also called Color Grading.
  70736. *
  70737. * The object needs to be provided an url to a texture containing the color
  70738. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  70739. * Use an image editing software to tweak the LUT to match your needs.
  70740. *
  70741. * For an example of a color LUT, see here:
  70742. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  70743. * For explanations on color grading, see here:
  70744. * @see http://udn.epicgames.com/Three/ColorGrading.html
  70745. *
  70746. */
  70747. export class ColorCorrectionPostProcess extends PostProcess {
  70748. private _colorTableTexture;
  70749. /**
  70750. * Gets the color table url used to create the LUT texture
  70751. */
  70752. colorTableUrl: string;
  70753. /**
  70754. * Gets a string identifying the name of the class
  70755. * @returns "ColorCorrectionPostProcess" string
  70756. */
  70757. getClassName(): string;
  70758. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  70759. /** @hidden */
  70760. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ColorCorrectionPostProcess>;
  70761. }
  70762. }
  70763. declare module BABYLON {
  70764. /** @hidden */
  70765. export var convolutionPixelShader: {
  70766. name: string;
  70767. shader: string;
  70768. };
  70769. }
  70770. declare module BABYLON {
  70771. /**
  70772. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  70773. * input texture to perform effects such as edge detection or sharpening
  70774. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  70775. */
  70776. export class ConvolutionPostProcess extends PostProcess {
  70777. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  70778. kernel: number[];
  70779. /**
  70780. * Gets a string identifying the name of the class
  70781. * @returns "ConvolutionPostProcess" string
  70782. */
  70783. getClassName(): string;
  70784. /**
  70785. * Creates a new instance ConvolutionPostProcess
  70786. * @param name The name of the effect.
  70787. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  70788. * @param options The required width/height ratio to downsize to before computing the render pass.
  70789. * @param camera The camera to apply the render pass to.
  70790. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70791. * @param engine The engine which the post process will be applied. (default: current engine)
  70792. * @param reusable If the post process can be reused on the same frame. (default: false)
  70793. * @param textureType Type of textures used when performing the post process. (default: 0)
  70794. */
  70795. constructor(name: string, kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  70796. /** @hidden */
  70797. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ConvolutionPostProcess>;
  70798. /**
  70799. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  70800. */
  70801. static EdgeDetect0Kernel: number[];
  70802. /**
  70803. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  70804. */
  70805. static EdgeDetect1Kernel: number[];
  70806. /**
  70807. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  70808. */
  70809. static EdgeDetect2Kernel: number[];
  70810. /**
  70811. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  70812. */
  70813. static SharpenKernel: number[];
  70814. /**
  70815. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  70816. */
  70817. static EmbossKernel: number[];
  70818. /**
  70819. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  70820. */
  70821. static GaussianKernel: number[];
  70822. }
  70823. }
  70824. declare module BABYLON {
  70825. /**
  70826. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  70827. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  70828. * based on samples that have a large difference in distance than the center pixel.
  70829. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  70830. */
  70831. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  70832. /**
  70833. * The direction the blur should be applied
  70834. */
  70835. direction: Vector2;
  70836. /**
  70837. * Gets a string identifying the name of the class
  70838. * @returns "DepthOfFieldBlurPostProcess" string
  70839. */
  70840. getClassName(): string;
  70841. /**
  70842. * Creates a new instance CircleOfConfusionPostProcess
  70843. * @param name The name of the effect.
  70844. * @param scene The scene the effect belongs to.
  70845. * @param direction The direction the blur should be applied.
  70846. * @param kernel The size of the kernel used to blur.
  70847. * @param options The required width/height ratio to downsize to before computing the render pass.
  70848. * @param camera The camera to apply the render pass to.
  70849. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  70850. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  70851. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70852. * @param engine The engine which the post process will be applied. (default: current engine)
  70853. * @param reusable If the post process can be reused on the same frame. (default: false)
  70854. * @param textureType Type of textures used when performing the post process. (default: 0)
  70855. * @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)
  70856. */
  70857. 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);
  70858. }
  70859. }
  70860. declare module BABYLON {
  70861. /** @hidden */
  70862. export var depthOfFieldMergePixelShader: {
  70863. name: string;
  70864. shader: string;
  70865. };
  70866. }
  70867. declare module BABYLON {
  70868. /**
  70869. * Options to be set when merging outputs from the default pipeline.
  70870. */
  70871. export class DepthOfFieldMergePostProcessOptions {
  70872. /**
  70873. * The original image to merge on top of
  70874. */
  70875. originalFromInput: PostProcess;
  70876. /**
  70877. * Parameters to perform the merge of the depth of field effect
  70878. */
  70879. depthOfField?: {
  70880. circleOfConfusion: PostProcess;
  70881. blurSteps: Array<PostProcess>;
  70882. };
  70883. /**
  70884. * Parameters to perform the merge of bloom effect
  70885. */
  70886. bloom?: {
  70887. blurred: PostProcess;
  70888. weight: number;
  70889. };
  70890. }
  70891. /**
  70892. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  70893. */
  70894. export class DepthOfFieldMergePostProcess extends PostProcess {
  70895. private blurSteps;
  70896. /**
  70897. * Gets a string identifying the name of the class
  70898. * @returns "DepthOfFieldMergePostProcess" string
  70899. */
  70900. getClassName(): string;
  70901. /**
  70902. * Creates a new instance of DepthOfFieldMergePostProcess
  70903. * @param name The name of the effect.
  70904. * @param originalFromInput Post process which's input will be used for the merge.
  70905. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  70906. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  70907. * @param options The required width/height ratio to downsize to before computing the render pass.
  70908. * @param camera The camera to apply the render pass to.
  70909. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70910. * @param engine The engine which the post process will be applied. (default: current engine)
  70911. * @param reusable If the post process can be reused on the same frame. (default: false)
  70912. * @param textureType Type of textures used when performing the post process. (default: 0)
  70913. * @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)
  70914. */
  70915. 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);
  70916. /**
  70917. * Updates the effect with the current post process compile time values and recompiles the shader.
  70918. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  70919. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  70920. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  70921. * @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
  70922. * @param onCompiled Called when the shader has been compiled.
  70923. * @param onError Called if there is an error when compiling a shader.
  70924. */
  70925. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  70926. }
  70927. }
  70928. declare module BABYLON {
  70929. /**
  70930. * Specifies the level of max blur that should be applied when using the depth of field effect
  70931. */
  70932. export enum DepthOfFieldEffectBlurLevel {
  70933. /**
  70934. * Subtle blur
  70935. */
  70936. Low = 0,
  70937. /**
  70938. * Medium blur
  70939. */
  70940. Medium = 1,
  70941. /**
  70942. * Large blur
  70943. */
  70944. High = 2
  70945. }
  70946. /**
  70947. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  70948. */
  70949. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  70950. private _circleOfConfusion;
  70951. /**
  70952. * @hidden Internal, blurs from high to low
  70953. */
  70954. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  70955. private _depthOfFieldBlurY;
  70956. private _dofMerge;
  70957. /**
  70958. * @hidden Internal post processes in depth of field effect
  70959. */
  70960. _effects: Array<PostProcess>;
  70961. /**
  70962. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  70963. */
  70964. set focalLength(value: number);
  70965. get focalLength(): number;
  70966. /**
  70967. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  70968. */
  70969. set fStop(value: number);
  70970. get fStop(): number;
  70971. /**
  70972. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  70973. */
  70974. set focusDistance(value: number);
  70975. get focusDistance(): number;
  70976. /**
  70977. * 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.
  70978. */
  70979. set lensSize(value: number);
  70980. get lensSize(): number;
  70981. /**
  70982. * Creates a new instance DepthOfFieldEffect
  70983. * @param scene The scene the effect belongs to.
  70984. * @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.
  70985. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  70986. * @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)
  70987. */
  70988. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  70989. /**
  70990. * Get the current class name of the current effet
  70991. * @returns "DepthOfFieldEffect"
  70992. */
  70993. getClassName(): string;
  70994. /**
  70995. * 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.
  70996. */
  70997. set depthTexture(value: RenderTargetTexture);
  70998. /**
  70999. * Disposes each of the internal effects for a given camera.
  71000. * @param camera The camera to dispose the effect on.
  71001. */
  71002. disposeEffects(camera: Camera): void;
  71003. /**
  71004. * @hidden Internal
  71005. */
  71006. _updateEffects(): void;
  71007. /**
  71008. * Internal
  71009. * @returns if all the contained post processes are ready.
  71010. * @hidden
  71011. */
  71012. _isReady(): boolean;
  71013. }
  71014. }
  71015. declare module BABYLON {
  71016. /** @hidden */
  71017. export var displayPassPixelShader: {
  71018. name: string;
  71019. shader: string;
  71020. };
  71021. }
  71022. declare module BABYLON {
  71023. /**
  71024. * DisplayPassPostProcess which produces an output the same as it's input
  71025. */
  71026. export class DisplayPassPostProcess extends PostProcess {
  71027. /**
  71028. * Gets a string identifying the name of the class
  71029. * @returns "DisplayPassPostProcess" string
  71030. */
  71031. getClassName(): string;
  71032. /**
  71033. * Creates the DisplayPassPostProcess
  71034. * @param name The name of the effect.
  71035. * @param options The required width/height ratio to downsize to before computing the render pass.
  71036. * @param camera The camera to apply the render pass to.
  71037. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71038. * @param engine The engine which the post process will be applied. (default: current engine)
  71039. * @param reusable If the post process can be reused on the same frame. (default: false)
  71040. */
  71041. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  71042. /** @hidden */
  71043. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<DisplayPassPostProcess>;
  71044. }
  71045. }
  71046. declare module BABYLON {
  71047. /** @hidden */
  71048. export var filterPixelShader: {
  71049. name: string;
  71050. shader: string;
  71051. };
  71052. }
  71053. declare module BABYLON {
  71054. /**
  71055. * Applies a kernel filter to the image
  71056. */
  71057. export class FilterPostProcess extends PostProcess {
  71058. /** The matrix to be applied to the image */
  71059. kernelMatrix: Matrix;
  71060. /**
  71061. * Gets a string identifying the name of the class
  71062. * @returns "FilterPostProcess" string
  71063. */
  71064. getClassName(): string;
  71065. /**
  71066. *
  71067. * @param name The name of the effect.
  71068. * @param kernelMatrix The matrix to be applied to the image
  71069. * @param options The required width/height ratio to downsize to before computing the render pass.
  71070. * @param camera The camera to apply the render pass to.
  71071. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71072. * @param engine The engine which the post process will be applied. (default: current engine)
  71073. * @param reusable If the post process can be reused on the same frame. (default: false)
  71074. */
  71075. constructor(name: string, kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  71076. /** @hidden */
  71077. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<FilterPostProcess>;
  71078. }
  71079. }
  71080. declare module BABYLON {
  71081. /** @hidden */
  71082. export var fxaaPixelShader: {
  71083. name: string;
  71084. shader: string;
  71085. };
  71086. }
  71087. declare module BABYLON {
  71088. /** @hidden */
  71089. export var fxaaVertexShader: {
  71090. name: string;
  71091. shader: string;
  71092. };
  71093. }
  71094. declare module BABYLON {
  71095. /**
  71096. * Fxaa post process
  71097. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  71098. */
  71099. export class FxaaPostProcess extends PostProcess {
  71100. /**
  71101. * Gets a string identifying the name of the class
  71102. * @returns "FxaaPostProcess" string
  71103. */
  71104. getClassName(): string;
  71105. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  71106. private _getDefines;
  71107. /** @hidden */
  71108. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): FxaaPostProcess;
  71109. }
  71110. }
  71111. declare module BABYLON {
  71112. /** @hidden */
  71113. export var grainPixelShader: {
  71114. name: string;
  71115. shader: string;
  71116. };
  71117. }
  71118. declare module BABYLON {
  71119. /**
  71120. * The GrainPostProcess adds noise to the image at mid luminance levels
  71121. */
  71122. export class GrainPostProcess extends PostProcess {
  71123. /**
  71124. * The intensity of the grain added (default: 30)
  71125. */
  71126. intensity: number;
  71127. /**
  71128. * If the grain should be randomized on every frame
  71129. */
  71130. animated: boolean;
  71131. /**
  71132. * Gets a string identifying the name of the class
  71133. * @returns "GrainPostProcess" string
  71134. */
  71135. getClassName(): string;
  71136. /**
  71137. * Creates a new instance of @see GrainPostProcess
  71138. * @param name The name of the effect.
  71139. * @param options The required width/height ratio to downsize to before computing the render pass.
  71140. * @param camera The camera to apply the render pass to.
  71141. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71142. * @param engine The engine which the post process will be applied. (default: current engine)
  71143. * @param reusable If the post process can be reused on the same frame. (default: false)
  71144. * @param textureType Type of textures used when performing the post process. (default: 0)
  71145. * @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)
  71146. */
  71147. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  71148. /** @hidden */
  71149. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): GrainPostProcess;
  71150. }
  71151. }
  71152. declare module BABYLON {
  71153. /** @hidden */
  71154. export var highlightsPixelShader: {
  71155. name: string;
  71156. shader: string;
  71157. };
  71158. }
  71159. declare module BABYLON {
  71160. /**
  71161. * Extracts highlights from the image
  71162. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  71163. */
  71164. export class HighlightsPostProcess extends PostProcess {
  71165. /**
  71166. * Gets a string identifying the name of the class
  71167. * @returns "HighlightsPostProcess" string
  71168. */
  71169. getClassName(): string;
  71170. /**
  71171. * Extracts highlights from the image
  71172. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  71173. * @param name The name of the effect.
  71174. * @param options The required width/height ratio to downsize to before computing the render pass.
  71175. * @param camera The camera to apply the render pass to.
  71176. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71177. * @param engine The engine which the post process will be applied. (default: current engine)
  71178. * @param reusable If the post process can be reused on the same frame. (default: false)
  71179. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  71180. */
  71181. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  71182. }
  71183. }
  71184. declare module BABYLON {
  71185. /**
  71186. * Contains all parameters needed for the prepass to perform
  71187. * motion blur
  71188. */
  71189. export class MotionBlurConfiguration implements PrePassEffectConfiguration {
  71190. /**
  71191. * Is motion blur enabled
  71192. */
  71193. enabled: boolean;
  71194. /**
  71195. * Name of the configuration
  71196. */
  71197. name: string;
  71198. /**
  71199. * Textures that should be present in the MRT for this effect to work
  71200. */
  71201. readonly texturesRequired: number[];
  71202. }
  71203. }
  71204. declare module BABYLON {
  71205. interface Scene {
  71206. /** @hidden (Backing field) */
  71207. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  71208. /**
  71209. * Gets or Sets the current geometry buffer associated to the scene.
  71210. */
  71211. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  71212. /**
  71213. * Enables a GeometryBufferRender and associates it with the scene
  71214. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  71215. * @returns the GeometryBufferRenderer
  71216. */
  71217. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  71218. /**
  71219. * Disables the GeometryBufferRender associated with the scene
  71220. */
  71221. disableGeometryBufferRenderer(): void;
  71222. }
  71223. /**
  71224. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  71225. * in several rendering techniques.
  71226. */
  71227. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  71228. /**
  71229. * The component name helpful to identify the component in the list of scene components.
  71230. */
  71231. readonly name: string;
  71232. /**
  71233. * The scene the component belongs to.
  71234. */
  71235. scene: Scene;
  71236. /**
  71237. * Creates a new instance of the component for the given scene
  71238. * @param scene Defines the scene to register the component in
  71239. */
  71240. constructor(scene: Scene);
  71241. /**
  71242. * Registers the component in a given scene
  71243. */
  71244. register(): void;
  71245. /**
  71246. * Rebuilds the elements related to this component in case of
  71247. * context lost for instance.
  71248. */
  71249. rebuild(): void;
  71250. /**
  71251. * Disposes the component and the associated ressources
  71252. */
  71253. dispose(): void;
  71254. private _gatherRenderTargets;
  71255. }
  71256. }
  71257. declare module BABYLON {
  71258. /** @hidden */
  71259. export var motionBlurPixelShader: {
  71260. name: string;
  71261. shader: string;
  71262. };
  71263. }
  71264. declare module BABYLON {
  71265. /**
  71266. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  71267. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  71268. * As an example, all you have to do is to create the post-process:
  71269. * var mb = new BABYLON.MotionBlurPostProcess(
  71270. * 'mb', // The name of the effect.
  71271. * scene, // The scene containing the objects to blur according to their velocity.
  71272. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  71273. * camera // The camera to apply the render pass to.
  71274. * );
  71275. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  71276. */
  71277. export class MotionBlurPostProcess extends PostProcess {
  71278. /**
  71279. * Defines how much the image is blurred by the movement. Default value is equal to 1
  71280. */
  71281. motionStrength: number;
  71282. /**
  71283. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  71284. */
  71285. get motionBlurSamples(): number;
  71286. /**
  71287. * Sets the number of iterations to be used for motion blur quality
  71288. */
  71289. set motionBlurSamples(samples: number);
  71290. private _motionBlurSamples;
  71291. private _forceGeometryBuffer;
  71292. private _geometryBufferRenderer;
  71293. private _prePassRenderer;
  71294. /**
  71295. * Gets a string identifying the name of the class
  71296. * @returns "MotionBlurPostProcess" string
  71297. */
  71298. getClassName(): string;
  71299. /**
  71300. * Creates a new instance MotionBlurPostProcess
  71301. * @param name The name of the effect.
  71302. * @param scene The scene containing the objects to blur according to their velocity.
  71303. * @param options The required width/height ratio to downsize to before computing the render pass.
  71304. * @param camera The camera to apply the render pass to.
  71305. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71306. * @param engine The engine which the post process will be applied. (default: current engine)
  71307. * @param reusable If the post process can be reused on the same frame. (default: false)
  71308. * @param textureType Type of textures used when performing the post process. (default: 0)
  71309. * @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)
  71310. * @param forceGeometryBuffer If this post process should use geometry buffer instead of prepass (default: false)
  71311. */
  71312. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean, forceGeometryBuffer?: boolean);
  71313. /**
  71314. * Excludes the given skinned mesh from computing bones velocities.
  71315. * 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.
  71316. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  71317. */
  71318. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  71319. /**
  71320. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  71321. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  71322. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  71323. */
  71324. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  71325. /**
  71326. * Disposes the post process.
  71327. * @param camera The camera to dispose the post process on.
  71328. */
  71329. dispose(camera?: Camera): void;
  71330. /** @hidden */
  71331. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<MotionBlurPostProcess>;
  71332. }
  71333. }
  71334. declare module BABYLON {
  71335. /** @hidden */
  71336. export var refractionPixelShader: {
  71337. name: string;
  71338. shader: string;
  71339. };
  71340. }
  71341. declare module BABYLON {
  71342. /**
  71343. * Post process which applies a refractin texture
  71344. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  71345. */
  71346. export class RefractionPostProcess extends PostProcess {
  71347. private _refTexture;
  71348. private _ownRefractionTexture;
  71349. /** the base color of the refraction (used to taint the rendering) */
  71350. color: Color3;
  71351. /** simulated refraction depth */
  71352. depth: number;
  71353. /** the coefficient of the base color (0 to remove base color tainting) */
  71354. colorLevel: number;
  71355. /** Gets the url used to load the refraction texture */
  71356. refractionTextureUrl: string;
  71357. /**
  71358. * Gets or sets the refraction texture
  71359. * Please note that you are responsible for disposing the texture if you set it manually
  71360. */
  71361. get refractionTexture(): Texture;
  71362. set refractionTexture(value: Texture);
  71363. /**
  71364. * Gets a string identifying the name of the class
  71365. * @returns "RefractionPostProcess" string
  71366. */
  71367. getClassName(): string;
  71368. /**
  71369. * Initializes the RefractionPostProcess
  71370. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  71371. * @param name The name of the effect.
  71372. * @param refractionTextureUrl Url of the refraction texture to use
  71373. * @param color the base color of the refraction (used to taint the rendering)
  71374. * @param depth simulated refraction depth
  71375. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  71376. * @param camera The camera to apply the render pass to.
  71377. * @param options The required width/height ratio to downsize to before computing the render pass.
  71378. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71379. * @param engine The engine which the post process will be applied. (default: current engine)
  71380. * @param reusable If the post process can be reused on the same frame. (default: false)
  71381. */
  71382. constructor(name: string, refractionTextureUrl: string, color: Color3, depth: number, colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  71383. /**
  71384. * Disposes of the post process
  71385. * @param camera Camera to dispose post process on
  71386. */
  71387. dispose(camera: Camera): void;
  71388. /** @hidden */
  71389. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): RefractionPostProcess;
  71390. }
  71391. }
  71392. declare module BABYLON {
  71393. /** @hidden */
  71394. export var sharpenPixelShader: {
  71395. name: string;
  71396. shader: string;
  71397. };
  71398. }
  71399. declare module BABYLON {
  71400. /**
  71401. * The SharpenPostProcess applies a sharpen kernel to every pixel
  71402. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  71403. */
  71404. export class SharpenPostProcess extends PostProcess {
  71405. /**
  71406. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  71407. */
  71408. colorAmount: number;
  71409. /**
  71410. * How much sharpness should be applied (default: 0.3)
  71411. */
  71412. edgeAmount: number;
  71413. /**
  71414. * Gets a string identifying the name of the class
  71415. * @returns "SharpenPostProcess" string
  71416. */
  71417. getClassName(): string;
  71418. /**
  71419. * Creates a new instance ConvolutionPostProcess
  71420. * @param name The name of the effect.
  71421. * @param options The required width/height ratio to downsize to before computing the render pass.
  71422. * @param camera The camera to apply the render pass to.
  71423. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71424. * @param engine The engine which the post process will be applied. (default: current engine)
  71425. * @param reusable If the post process can be reused on the same frame. (default: false)
  71426. * @param textureType Type of textures used when performing the post process. (default: 0)
  71427. * @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)
  71428. */
  71429. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  71430. /** @hidden */
  71431. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): SharpenPostProcess;
  71432. }
  71433. }
  71434. declare module BABYLON {
  71435. /**
  71436. * PostProcessRenderPipeline
  71437. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  71438. */
  71439. export class PostProcessRenderPipeline {
  71440. private engine;
  71441. private _renderEffects;
  71442. private _renderEffectsForIsolatedPass;
  71443. /**
  71444. * List of inspectable custom properties (used by the Inspector)
  71445. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  71446. */
  71447. inspectableCustomProperties: IInspectable[];
  71448. /**
  71449. * @hidden
  71450. */
  71451. protected _cameras: Camera[];
  71452. /** @hidden */
  71453. _name: string;
  71454. /**
  71455. * Gets pipeline name
  71456. */
  71457. get name(): string;
  71458. /** Gets the list of attached cameras */
  71459. get cameras(): Camera[];
  71460. /**
  71461. * Initializes a PostProcessRenderPipeline
  71462. * @param engine engine to add the pipeline to
  71463. * @param name name of the pipeline
  71464. */
  71465. constructor(engine: Engine, name: string);
  71466. /**
  71467. * Gets the class name
  71468. * @returns "PostProcessRenderPipeline"
  71469. */
  71470. getClassName(): string;
  71471. /**
  71472. * If all the render effects in the pipeline are supported
  71473. */
  71474. get isSupported(): boolean;
  71475. /**
  71476. * Adds an effect to the pipeline
  71477. * @param renderEffect the effect to add
  71478. */
  71479. addEffect(renderEffect: PostProcessRenderEffect): void;
  71480. /** @hidden */
  71481. _rebuild(): void;
  71482. /** @hidden */
  71483. _enableEffect(renderEffectName: string, cameras: Camera): void;
  71484. /** @hidden */
  71485. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  71486. /** @hidden */
  71487. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  71488. /** @hidden */
  71489. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  71490. /** @hidden */
  71491. _attachCameras(cameras: Camera, unique: boolean): void;
  71492. /** @hidden */
  71493. _attachCameras(cameras: Camera[], unique: boolean): void;
  71494. /** @hidden */
  71495. _detachCameras(cameras: Camera): void;
  71496. /** @hidden */
  71497. _detachCameras(cameras: Nullable<Camera[]>): void;
  71498. /** @hidden */
  71499. _update(): void;
  71500. /** @hidden */
  71501. _reset(): void;
  71502. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  71503. /**
  71504. * Sets the required values to the prepass renderer.
  71505. * @param prePassRenderer defines the prepass renderer to setup.
  71506. * @returns true if the pre pass is needed.
  71507. */
  71508. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  71509. /**
  71510. * Disposes of the pipeline
  71511. */
  71512. dispose(): void;
  71513. }
  71514. }
  71515. declare module BABYLON {
  71516. /**
  71517. * PostProcessRenderPipelineManager class
  71518. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  71519. */
  71520. export class PostProcessRenderPipelineManager {
  71521. private _renderPipelines;
  71522. /**
  71523. * Initializes a PostProcessRenderPipelineManager
  71524. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  71525. */
  71526. constructor();
  71527. /**
  71528. * Gets the list of supported render pipelines
  71529. */
  71530. get supportedPipelines(): PostProcessRenderPipeline[];
  71531. /**
  71532. * Adds a pipeline to the manager
  71533. * @param renderPipeline The pipeline to add
  71534. */
  71535. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  71536. /**
  71537. * Attaches a camera to the pipeline
  71538. * @param renderPipelineName The name of the pipeline to attach to
  71539. * @param cameras the camera to attach
  71540. * @param unique if the camera can be attached multiple times to the pipeline
  71541. */
  71542. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  71543. /**
  71544. * Detaches a camera from the pipeline
  71545. * @param renderPipelineName The name of the pipeline to detach from
  71546. * @param cameras the camera to detach
  71547. */
  71548. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  71549. /**
  71550. * Enables an effect by name on a pipeline
  71551. * @param renderPipelineName the name of the pipeline to enable the effect in
  71552. * @param renderEffectName the name of the effect to enable
  71553. * @param cameras the cameras that the effect should be enabled on
  71554. */
  71555. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  71556. /**
  71557. * Disables an effect by name on a pipeline
  71558. * @param renderPipelineName the name of the pipeline to disable the effect in
  71559. * @param renderEffectName the name of the effect to disable
  71560. * @param cameras the cameras that the effect should be disabled on
  71561. */
  71562. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  71563. /**
  71564. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  71565. */
  71566. update(): void;
  71567. /** @hidden */
  71568. _rebuild(): void;
  71569. /**
  71570. * Disposes of the manager and pipelines
  71571. */
  71572. dispose(): void;
  71573. }
  71574. }
  71575. declare module BABYLON {
  71576. interface Scene {
  71577. /** @hidden (Backing field) */
  71578. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  71579. /**
  71580. * Gets the postprocess render pipeline manager
  71581. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  71582. * @see https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  71583. */
  71584. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  71585. }
  71586. /**
  71587. * Defines the Render Pipeline scene component responsible to rendering pipelines
  71588. */
  71589. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  71590. /**
  71591. * The component name helpfull to identify the component in the list of scene components.
  71592. */
  71593. readonly name: string;
  71594. /**
  71595. * The scene the component belongs to.
  71596. */
  71597. scene: Scene;
  71598. /**
  71599. * Creates a new instance of the component for the given scene
  71600. * @param scene Defines the scene to register the component in
  71601. */
  71602. constructor(scene: Scene);
  71603. /**
  71604. * Registers the component in a given scene
  71605. */
  71606. register(): void;
  71607. /**
  71608. * Rebuilds the elements related to this component in case of
  71609. * context lost for instance.
  71610. */
  71611. rebuild(): void;
  71612. /**
  71613. * Disposes the component and the associated ressources
  71614. */
  71615. dispose(): void;
  71616. private _gatherRenderTargets;
  71617. }
  71618. }
  71619. declare module BABYLON {
  71620. /**
  71621. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  71622. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  71623. */
  71624. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  71625. private _scene;
  71626. private _camerasToBeAttached;
  71627. /**
  71628. * ID of the sharpen post process,
  71629. */
  71630. private readonly SharpenPostProcessId;
  71631. /**
  71632. * @ignore
  71633. * ID of the image processing post process;
  71634. */
  71635. readonly ImageProcessingPostProcessId: string;
  71636. /**
  71637. * @ignore
  71638. * ID of the Fast Approximate Anti-Aliasing post process;
  71639. */
  71640. readonly FxaaPostProcessId: string;
  71641. /**
  71642. * ID of the chromatic aberration post process,
  71643. */
  71644. private readonly ChromaticAberrationPostProcessId;
  71645. /**
  71646. * ID of the grain post process
  71647. */
  71648. private readonly GrainPostProcessId;
  71649. /**
  71650. * Sharpen post process which will apply a sharpen convolution to enhance edges
  71651. */
  71652. sharpen: SharpenPostProcess;
  71653. private _sharpenEffect;
  71654. private bloom;
  71655. /**
  71656. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  71657. */
  71658. depthOfField: DepthOfFieldEffect;
  71659. /**
  71660. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  71661. */
  71662. fxaa: FxaaPostProcess;
  71663. /**
  71664. * Image post processing pass used to perform operations such as tone mapping or color grading.
  71665. */
  71666. imageProcessing: ImageProcessingPostProcess;
  71667. /**
  71668. * Chromatic aberration post process which will shift rgb colors in the image
  71669. */
  71670. chromaticAberration: ChromaticAberrationPostProcess;
  71671. private _chromaticAberrationEffect;
  71672. /**
  71673. * Grain post process which add noise to the image
  71674. */
  71675. grain: GrainPostProcess;
  71676. private _grainEffect;
  71677. /**
  71678. * Glow post process which adds a glow to emissive areas of the image
  71679. */
  71680. private _glowLayer;
  71681. /**
  71682. * Animations which can be used to tweak settings over a period of time
  71683. */
  71684. animations: Animation[];
  71685. private _imageProcessingConfigurationObserver;
  71686. private _sharpenEnabled;
  71687. private _bloomEnabled;
  71688. private _depthOfFieldEnabled;
  71689. private _depthOfFieldBlurLevel;
  71690. private _fxaaEnabled;
  71691. private _imageProcessingEnabled;
  71692. private _defaultPipelineTextureType;
  71693. private _bloomScale;
  71694. private _chromaticAberrationEnabled;
  71695. private _grainEnabled;
  71696. private _buildAllowed;
  71697. /**
  71698. * This is triggered each time the pipeline has been built.
  71699. */
  71700. onBuildObservable: Observable<DefaultRenderingPipeline>;
  71701. /**
  71702. * Gets active scene
  71703. */
  71704. get scene(): Scene;
  71705. /**
  71706. * Enable or disable the sharpen process from the pipeline
  71707. */
  71708. set sharpenEnabled(enabled: boolean);
  71709. get sharpenEnabled(): boolean;
  71710. private _resizeObserver;
  71711. private _hardwareScaleLevel;
  71712. private _bloomKernel;
  71713. /**
  71714. * Specifies the size of the bloom blur kernel, relative to the final output size
  71715. */
  71716. get bloomKernel(): number;
  71717. set bloomKernel(value: number);
  71718. /**
  71719. * Specifies the weight of the bloom in the final rendering
  71720. */
  71721. private _bloomWeight;
  71722. /**
  71723. * Specifies the luma threshold for the area that will be blurred by the bloom
  71724. */
  71725. private _bloomThreshold;
  71726. private _hdr;
  71727. /**
  71728. * The strength of the bloom.
  71729. */
  71730. set bloomWeight(value: number);
  71731. get bloomWeight(): number;
  71732. /**
  71733. * The strength of the bloom.
  71734. */
  71735. set bloomThreshold(value: number);
  71736. get bloomThreshold(): number;
  71737. /**
  71738. * The scale of the bloom, lower value will provide better performance.
  71739. */
  71740. set bloomScale(value: number);
  71741. get bloomScale(): number;
  71742. /**
  71743. * Enable or disable the bloom from the pipeline
  71744. */
  71745. set bloomEnabled(enabled: boolean);
  71746. get bloomEnabled(): boolean;
  71747. private _rebuildBloom;
  71748. /**
  71749. * If the depth of field is enabled.
  71750. */
  71751. get depthOfFieldEnabled(): boolean;
  71752. set depthOfFieldEnabled(enabled: boolean);
  71753. /**
  71754. * Blur level of the depth of field effect. (Higher blur will effect performance)
  71755. */
  71756. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  71757. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  71758. /**
  71759. * If the anti aliasing is enabled.
  71760. */
  71761. set fxaaEnabled(enabled: boolean);
  71762. get fxaaEnabled(): boolean;
  71763. private _samples;
  71764. /**
  71765. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  71766. */
  71767. set samples(sampleCount: number);
  71768. get samples(): number;
  71769. /**
  71770. * If image processing is enabled.
  71771. */
  71772. set imageProcessingEnabled(enabled: boolean);
  71773. get imageProcessingEnabled(): boolean;
  71774. /**
  71775. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  71776. */
  71777. set glowLayerEnabled(enabled: boolean);
  71778. get glowLayerEnabled(): boolean;
  71779. /**
  71780. * Gets the glow layer (or null if not defined)
  71781. */
  71782. get glowLayer(): Nullable<GlowLayer>;
  71783. /**
  71784. * Enable or disable the chromaticAberration process from the pipeline
  71785. */
  71786. set chromaticAberrationEnabled(enabled: boolean);
  71787. get chromaticAberrationEnabled(): boolean;
  71788. /**
  71789. * Enable or disable the grain process from the pipeline
  71790. */
  71791. set grainEnabled(enabled: boolean);
  71792. get grainEnabled(): boolean;
  71793. /**
  71794. * @constructor
  71795. * @param name - The rendering pipeline name (default: "")
  71796. * @param hdr - If high dynamic range textures should be used (default: true)
  71797. * @param scene - The scene linked to this pipeline (default: the last created scene)
  71798. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  71799. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  71800. */
  71801. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  71802. /**
  71803. * Get the class name
  71804. * @returns "DefaultRenderingPipeline"
  71805. */
  71806. getClassName(): string;
  71807. /**
  71808. * Force the compilation of the entire pipeline.
  71809. */
  71810. prepare(): void;
  71811. private _hasCleared;
  71812. private _prevPostProcess;
  71813. private _prevPrevPostProcess;
  71814. private _setAutoClearAndTextureSharing;
  71815. private _depthOfFieldSceneObserver;
  71816. private _buildPipeline;
  71817. private _disposePostProcesses;
  71818. /**
  71819. * Adds a camera to the pipeline
  71820. * @param camera the camera to be added
  71821. */
  71822. addCamera(camera: Camera): void;
  71823. /**
  71824. * Removes a camera from the pipeline
  71825. * @param camera the camera to remove
  71826. */
  71827. removeCamera(camera: Camera): void;
  71828. /**
  71829. * Dispose of the pipeline and stop all post processes
  71830. */
  71831. dispose(): void;
  71832. /**
  71833. * Serialize the rendering pipeline (Used when exporting)
  71834. * @returns the serialized object
  71835. */
  71836. serialize(): any;
  71837. /**
  71838. * Parse the serialized pipeline
  71839. * @param source Source pipeline.
  71840. * @param scene The scene to load the pipeline to.
  71841. * @param rootUrl The URL of the serialized pipeline.
  71842. * @returns An instantiated pipeline from the serialized object.
  71843. */
  71844. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  71845. }
  71846. }
  71847. declare module BABYLON {
  71848. /** @hidden */
  71849. export var lensHighlightsPixelShader: {
  71850. name: string;
  71851. shader: string;
  71852. };
  71853. }
  71854. declare module BABYLON {
  71855. /** @hidden */
  71856. export var depthOfFieldPixelShader: {
  71857. name: string;
  71858. shader: string;
  71859. };
  71860. }
  71861. declare module BABYLON {
  71862. /**
  71863. * BABYLON.JS Chromatic Aberration GLSL Shader
  71864. * Author: Olivier Guyot
  71865. * Separates very slightly R, G and B colors on the edges of the screen
  71866. * Inspired by Francois Tarlier & Martins Upitis
  71867. */
  71868. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  71869. /**
  71870. * @ignore
  71871. * The chromatic aberration PostProcess id in the pipeline
  71872. */
  71873. LensChromaticAberrationEffect: string;
  71874. /**
  71875. * @ignore
  71876. * The highlights enhancing PostProcess id in the pipeline
  71877. */
  71878. HighlightsEnhancingEffect: string;
  71879. /**
  71880. * @ignore
  71881. * The depth-of-field PostProcess id in the pipeline
  71882. */
  71883. LensDepthOfFieldEffect: string;
  71884. private _scene;
  71885. private _depthTexture;
  71886. private _grainTexture;
  71887. private _chromaticAberrationPostProcess;
  71888. private _highlightsPostProcess;
  71889. private _depthOfFieldPostProcess;
  71890. private _edgeBlur;
  71891. private _grainAmount;
  71892. private _chromaticAberration;
  71893. private _distortion;
  71894. private _highlightsGain;
  71895. private _highlightsThreshold;
  71896. private _dofDistance;
  71897. private _dofAperture;
  71898. private _dofDarken;
  71899. private _dofPentagon;
  71900. private _blurNoise;
  71901. /**
  71902. * @constructor
  71903. *
  71904. * Effect parameters are as follow:
  71905. * {
  71906. * chromatic_aberration: number; // from 0 to x (1 for realism)
  71907. * edge_blur: number; // from 0 to x (1 for realism)
  71908. * distortion: number; // from 0 to x (1 for realism)
  71909. * grain_amount: number; // from 0 to 1
  71910. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  71911. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  71912. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  71913. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  71914. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  71915. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  71916. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  71917. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  71918. * }
  71919. * Note: if an effect parameter is unset, effect is disabled
  71920. *
  71921. * @param name The rendering pipeline name
  71922. * @param parameters - An object containing all parameters (see above)
  71923. * @param scene The scene linked to this pipeline
  71924. * @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)
  71925. * @param cameras The array of cameras that the rendering pipeline will be attached to
  71926. */
  71927. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  71928. /**
  71929. * Get the class name
  71930. * @returns "LensRenderingPipeline"
  71931. */
  71932. getClassName(): string;
  71933. /**
  71934. * Gets associated scene
  71935. */
  71936. get scene(): Scene;
  71937. /**
  71938. * Gets or sets the edge blur
  71939. */
  71940. get edgeBlur(): number;
  71941. set edgeBlur(value: number);
  71942. /**
  71943. * Gets or sets the grain amount
  71944. */
  71945. get grainAmount(): number;
  71946. set grainAmount(value: number);
  71947. /**
  71948. * Gets or sets the chromatic aberration amount
  71949. */
  71950. get chromaticAberration(): number;
  71951. set chromaticAberration(value: number);
  71952. /**
  71953. * Gets or sets the depth of field aperture
  71954. */
  71955. get dofAperture(): number;
  71956. set dofAperture(value: number);
  71957. /**
  71958. * Gets or sets the edge distortion
  71959. */
  71960. get edgeDistortion(): number;
  71961. set edgeDistortion(value: number);
  71962. /**
  71963. * Gets or sets the depth of field distortion
  71964. */
  71965. get dofDistortion(): number;
  71966. set dofDistortion(value: number);
  71967. /**
  71968. * Gets or sets the darken out of focus amount
  71969. */
  71970. get darkenOutOfFocus(): number;
  71971. set darkenOutOfFocus(value: number);
  71972. /**
  71973. * Gets or sets a boolean indicating if blur noise is enabled
  71974. */
  71975. get blurNoise(): boolean;
  71976. set blurNoise(value: boolean);
  71977. /**
  71978. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  71979. */
  71980. get pentagonBokeh(): boolean;
  71981. set pentagonBokeh(value: boolean);
  71982. /**
  71983. * Gets or sets the highlight grain amount
  71984. */
  71985. get highlightsGain(): number;
  71986. set highlightsGain(value: number);
  71987. /**
  71988. * Gets or sets the highlight threshold
  71989. */
  71990. get highlightsThreshold(): number;
  71991. set highlightsThreshold(value: number);
  71992. /**
  71993. * Sets the amount of blur at the edges
  71994. * @param amount blur amount
  71995. */
  71996. setEdgeBlur(amount: number): void;
  71997. /**
  71998. * Sets edge blur to 0
  71999. */
  72000. disableEdgeBlur(): void;
  72001. /**
  72002. * Sets the amout of grain
  72003. * @param amount Amount of grain
  72004. */
  72005. setGrainAmount(amount: number): void;
  72006. /**
  72007. * Set grain amount to 0
  72008. */
  72009. disableGrain(): void;
  72010. /**
  72011. * Sets the chromatic aberration amount
  72012. * @param amount amount of chromatic aberration
  72013. */
  72014. setChromaticAberration(amount: number): void;
  72015. /**
  72016. * Sets chromatic aberration amount to 0
  72017. */
  72018. disableChromaticAberration(): void;
  72019. /**
  72020. * Sets the EdgeDistortion amount
  72021. * @param amount amount of EdgeDistortion
  72022. */
  72023. setEdgeDistortion(amount: number): void;
  72024. /**
  72025. * Sets edge distortion to 0
  72026. */
  72027. disableEdgeDistortion(): void;
  72028. /**
  72029. * Sets the FocusDistance amount
  72030. * @param amount amount of FocusDistance
  72031. */
  72032. setFocusDistance(amount: number): void;
  72033. /**
  72034. * Disables depth of field
  72035. */
  72036. disableDepthOfField(): void;
  72037. /**
  72038. * Sets the Aperture amount
  72039. * @param amount amount of Aperture
  72040. */
  72041. setAperture(amount: number): void;
  72042. /**
  72043. * Sets the DarkenOutOfFocus amount
  72044. * @param amount amount of DarkenOutOfFocus
  72045. */
  72046. setDarkenOutOfFocus(amount: number): void;
  72047. private _pentagonBokehIsEnabled;
  72048. /**
  72049. * Creates a pentagon bokeh effect
  72050. */
  72051. enablePentagonBokeh(): void;
  72052. /**
  72053. * Disables the pentagon bokeh effect
  72054. */
  72055. disablePentagonBokeh(): void;
  72056. /**
  72057. * Enables noise blur
  72058. */
  72059. enableNoiseBlur(): void;
  72060. /**
  72061. * Disables noise blur
  72062. */
  72063. disableNoiseBlur(): void;
  72064. /**
  72065. * Sets the HighlightsGain amount
  72066. * @param amount amount of HighlightsGain
  72067. */
  72068. setHighlightsGain(amount: number): void;
  72069. /**
  72070. * Sets the HighlightsThreshold amount
  72071. * @param amount amount of HighlightsThreshold
  72072. */
  72073. setHighlightsThreshold(amount: number): void;
  72074. /**
  72075. * Disables highlights
  72076. */
  72077. disableHighlights(): void;
  72078. /**
  72079. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  72080. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  72081. */
  72082. dispose(disableDepthRender?: boolean): void;
  72083. private _createChromaticAberrationPostProcess;
  72084. private _createHighlightsPostProcess;
  72085. private _createDepthOfFieldPostProcess;
  72086. private _createGrainTexture;
  72087. }
  72088. }
  72089. declare module BABYLON {
  72090. /**
  72091. * Contains all parameters needed for the prepass to perform
  72092. * screen space subsurface scattering
  72093. */
  72094. export class SSAO2Configuration implements PrePassEffectConfiguration {
  72095. /**
  72096. * Is subsurface enabled
  72097. */
  72098. enabled: boolean;
  72099. /**
  72100. * Name of the configuration
  72101. */
  72102. name: string;
  72103. /**
  72104. * Textures that should be present in the MRT for this effect to work
  72105. */
  72106. readonly texturesRequired: number[];
  72107. }
  72108. }
  72109. declare module BABYLON {
  72110. /** @hidden */
  72111. export var ssao2PixelShader: {
  72112. name: string;
  72113. shader: string;
  72114. };
  72115. }
  72116. declare module BABYLON {
  72117. /** @hidden */
  72118. export var ssaoCombinePixelShader: {
  72119. name: string;
  72120. shader: string;
  72121. };
  72122. }
  72123. declare module BABYLON {
  72124. /**
  72125. * Render pipeline to produce ssao effect
  72126. */
  72127. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  72128. /**
  72129. * @ignore
  72130. * The PassPostProcess id in the pipeline that contains the original scene color
  72131. */
  72132. SSAOOriginalSceneColorEffect: string;
  72133. /**
  72134. * @ignore
  72135. * The SSAO PostProcess id in the pipeline
  72136. */
  72137. SSAORenderEffect: string;
  72138. /**
  72139. * @ignore
  72140. * The horizontal blur PostProcess id in the pipeline
  72141. */
  72142. SSAOBlurHRenderEffect: string;
  72143. /**
  72144. * @ignore
  72145. * The vertical blur PostProcess id in the pipeline
  72146. */
  72147. SSAOBlurVRenderEffect: string;
  72148. /**
  72149. * @ignore
  72150. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  72151. */
  72152. SSAOCombineRenderEffect: string;
  72153. /**
  72154. * The output strength of the SSAO post-process. Default value is 1.0.
  72155. */
  72156. totalStrength: number;
  72157. /**
  72158. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  72159. */
  72160. maxZ: number;
  72161. /**
  72162. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  72163. */
  72164. minZAspect: number;
  72165. private _samples;
  72166. /**
  72167. * Number of samples used for the SSAO calculations. Default value is 8
  72168. */
  72169. set samples(n: number);
  72170. get samples(): number;
  72171. private _textureSamples;
  72172. /**
  72173. * Number of samples to use for antialiasing
  72174. */
  72175. set textureSamples(n: number);
  72176. get textureSamples(): number;
  72177. /**
  72178. * Force rendering the geometry through geometry buffer
  72179. */
  72180. private _forceGeometryBuffer;
  72181. /**
  72182. * Ratio object used for SSAO ratio and blur ratio
  72183. */
  72184. private _ratio;
  72185. /**
  72186. * Dynamically generated sphere sampler.
  72187. */
  72188. private _sampleSphere;
  72189. /**
  72190. * Blur filter offsets
  72191. */
  72192. private _samplerOffsets;
  72193. private _expensiveBlur;
  72194. /**
  72195. * If bilateral blur should be used
  72196. */
  72197. set expensiveBlur(b: boolean);
  72198. get expensiveBlur(): boolean;
  72199. /**
  72200. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  72201. */
  72202. radius: number;
  72203. /**
  72204. * The base color of the SSAO post-process
  72205. * The final result is "base + ssao" between [0, 1]
  72206. */
  72207. base: number;
  72208. /**
  72209. * Support test.
  72210. */
  72211. static get IsSupported(): boolean;
  72212. private _scene;
  72213. private _randomTexture;
  72214. private _originalColorPostProcess;
  72215. private _ssaoPostProcess;
  72216. private _blurHPostProcess;
  72217. private _blurVPostProcess;
  72218. private _ssaoCombinePostProcess;
  72219. private _prePassRenderer;
  72220. /**
  72221. * Gets active scene
  72222. */
  72223. get scene(): Scene;
  72224. /**
  72225. * @constructor
  72226. * @param name The rendering pipeline name
  72227. * @param scene The scene linked to this pipeline
  72228. * @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 }
  72229. * @param cameras The array of cameras that the rendering pipeline will be attached to
  72230. * @param forceGeometryBuffer Set to true if you want to use the legacy geometry buffer renderer
  72231. */
  72232. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[], forceGeometryBuffer?: boolean);
  72233. /**
  72234. * Get the class name
  72235. * @returns "SSAO2RenderingPipeline"
  72236. */
  72237. getClassName(): string;
  72238. /**
  72239. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  72240. */
  72241. dispose(disableGeometryBufferRenderer?: boolean): void;
  72242. private _createBlurPostProcess;
  72243. /** @hidden */
  72244. _rebuild(): void;
  72245. private _bits;
  72246. private _radicalInverse_VdC;
  72247. private _hammersley;
  72248. private _hemisphereSample_uniform;
  72249. private _generateHemisphere;
  72250. private _getDefinesForSSAO;
  72251. private _createSSAOPostProcess;
  72252. private _createSSAOCombinePostProcess;
  72253. private _createRandomTexture;
  72254. /**
  72255. * Serialize the rendering pipeline (Used when exporting)
  72256. * @returns the serialized object
  72257. */
  72258. serialize(): any;
  72259. /**
  72260. * Parse the serialized pipeline
  72261. * @param source Source pipeline.
  72262. * @param scene The scene to load the pipeline to.
  72263. * @param rootUrl The URL of the serialized pipeline.
  72264. * @returns An instantiated pipeline from the serialized object.
  72265. */
  72266. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  72267. }
  72268. }
  72269. declare module BABYLON {
  72270. /** @hidden */
  72271. export var ssaoPixelShader: {
  72272. name: string;
  72273. shader: string;
  72274. };
  72275. }
  72276. declare module BABYLON {
  72277. /**
  72278. * Render pipeline to produce ssao effect
  72279. */
  72280. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  72281. /**
  72282. * @ignore
  72283. * The PassPostProcess id in the pipeline that contains the original scene color
  72284. */
  72285. SSAOOriginalSceneColorEffect: string;
  72286. /**
  72287. * @ignore
  72288. * The SSAO PostProcess id in the pipeline
  72289. */
  72290. SSAORenderEffect: string;
  72291. /**
  72292. * @ignore
  72293. * The horizontal blur PostProcess id in the pipeline
  72294. */
  72295. SSAOBlurHRenderEffect: string;
  72296. /**
  72297. * @ignore
  72298. * The vertical blur PostProcess id in the pipeline
  72299. */
  72300. SSAOBlurVRenderEffect: string;
  72301. /**
  72302. * @ignore
  72303. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  72304. */
  72305. SSAOCombineRenderEffect: string;
  72306. /**
  72307. * The output strength of the SSAO post-process. Default value is 1.0.
  72308. */
  72309. totalStrength: number;
  72310. /**
  72311. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  72312. */
  72313. radius: number;
  72314. /**
  72315. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  72316. * Must not be equal to fallOff and superior to fallOff.
  72317. * Default value is 0.0075
  72318. */
  72319. area: number;
  72320. /**
  72321. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  72322. * Must not be equal to area and inferior to area.
  72323. * Default value is 0.000001
  72324. */
  72325. fallOff: number;
  72326. /**
  72327. * The base color of the SSAO post-process
  72328. * The final result is "base + ssao" between [0, 1]
  72329. */
  72330. base: number;
  72331. private _scene;
  72332. private _depthTexture;
  72333. private _randomTexture;
  72334. private _originalColorPostProcess;
  72335. private _ssaoPostProcess;
  72336. private _blurHPostProcess;
  72337. private _blurVPostProcess;
  72338. private _ssaoCombinePostProcess;
  72339. private _firstUpdate;
  72340. /**
  72341. * Gets active scene
  72342. */
  72343. get scene(): Scene;
  72344. /**
  72345. * @constructor
  72346. * @param name - The rendering pipeline name
  72347. * @param scene - The scene linked to this pipeline
  72348. * @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 }
  72349. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  72350. */
  72351. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  72352. /**
  72353. * Get the class name
  72354. * @returns "SSAORenderingPipeline"
  72355. */
  72356. getClassName(): string;
  72357. /**
  72358. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  72359. */
  72360. dispose(disableDepthRender?: boolean): void;
  72361. private _createBlurPostProcess;
  72362. /** @hidden */
  72363. _rebuild(): void;
  72364. private _createSSAOPostProcess;
  72365. private _createSSAOCombinePostProcess;
  72366. private _createRandomTexture;
  72367. }
  72368. }
  72369. declare module BABYLON {
  72370. /**
  72371. * Contains all parameters needed for the prepass to perform
  72372. * screen space reflections
  72373. */
  72374. export class ScreenSpaceReflectionsConfiguration implements PrePassEffectConfiguration {
  72375. /**
  72376. * Is ssr enabled
  72377. */
  72378. enabled: boolean;
  72379. /**
  72380. * Name of the configuration
  72381. */
  72382. name: string;
  72383. /**
  72384. * Textures that should be present in the MRT for this effect to work
  72385. */
  72386. readonly texturesRequired: number[];
  72387. }
  72388. }
  72389. declare module BABYLON {
  72390. /** @hidden */
  72391. export var screenSpaceReflectionPixelShader: {
  72392. name: string;
  72393. shader: string;
  72394. };
  72395. }
  72396. declare module BABYLON {
  72397. /**
  72398. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  72399. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  72400. */
  72401. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  72402. /**
  72403. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  72404. */
  72405. threshold: number;
  72406. /**
  72407. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  72408. */
  72409. strength: number;
  72410. /**
  72411. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  72412. */
  72413. reflectionSpecularFalloffExponent: number;
  72414. /**
  72415. * 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]
  72416. */
  72417. step: number;
  72418. /**
  72419. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  72420. */
  72421. roughnessFactor: number;
  72422. private _forceGeometryBuffer;
  72423. private _geometryBufferRenderer;
  72424. private _prePassRenderer;
  72425. private _enableSmoothReflections;
  72426. private _reflectionSamples;
  72427. private _smoothSteps;
  72428. /**
  72429. * Gets a string identifying the name of the class
  72430. * @returns "ScreenSpaceReflectionPostProcess" string
  72431. */
  72432. getClassName(): string;
  72433. /**
  72434. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  72435. * @param name The name of the effect.
  72436. * @param scene The scene containing the objects to calculate reflections.
  72437. * @param options The required width/height ratio to downsize to before computing the render pass.
  72438. * @param camera The camera to apply the render pass to.
  72439. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72440. * @param engine The engine which the post process will be applied. (default: current engine)
  72441. * @param reusable If the post process can be reused on the same frame. (default: false)
  72442. * @param textureType Type of textures used when performing the post process. (default: 0)
  72443. * @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)
  72444. * @param forceGeometryBuffer If this post process should use geometry buffer instead of prepass (default: false)
  72445. */
  72446. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean, forceGeometryBuffer?: boolean);
  72447. /**
  72448. * Gets wether or not smoothing reflections is enabled.
  72449. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  72450. */
  72451. get enableSmoothReflections(): boolean;
  72452. /**
  72453. * Sets wether or not smoothing reflections is enabled.
  72454. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  72455. */
  72456. set enableSmoothReflections(enabled: boolean);
  72457. /**
  72458. * Gets the number of samples taken while computing reflections. More samples count is high,
  72459. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  72460. */
  72461. get reflectionSamples(): number;
  72462. /**
  72463. * Sets the number of samples taken while computing reflections. More samples count is high,
  72464. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  72465. */
  72466. set reflectionSamples(samples: number);
  72467. /**
  72468. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  72469. * more the post-process will require GPU power and can generate a drop in FPS.
  72470. * Default value (5.0) work pretty well in all cases but can be adjusted.
  72471. */
  72472. get smoothSteps(): number;
  72473. set smoothSteps(steps: number);
  72474. private _updateEffectDefines;
  72475. /** @hidden */
  72476. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceReflectionPostProcess;
  72477. }
  72478. }
  72479. declare module BABYLON {
  72480. /** @hidden */
  72481. export var standardPixelShader: {
  72482. name: string;
  72483. shader: string;
  72484. };
  72485. }
  72486. declare module BABYLON {
  72487. /**
  72488. * Standard rendering pipeline
  72489. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  72490. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  72491. */
  72492. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  72493. /**
  72494. * Public members
  72495. */
  72496. /**
  72497. * Post-process which contains the original scene color before the pipeline applies all the effects
  72498. */
  72499. originalPostProcess: Nullable<PostProcess>;
  72500. /**
  72501. * Post-process used to down scale an image x4
  72502. */
  72503. downSampleX4PostProcess: Nullable<PostProcess>;
  72504. /**
  72505. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  72506. */
  72507. brightPassPostProcess: Nullable<PostProcess>;
  72508. /**
  72509. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  72510. */
  72511. blurHPostProcesses: PostProcess[];
  72512. /**
  72513. * Post-process array storing all the vertical blur post-processes used by the pipeline
  72514. */
  72515. blurVPostProcesses: PostProcess[];
  72516. /**
  72517. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  72518. */
  72519. textureAdderPostProcess: Nullable<PostProcess>;
  72520. /**
  72521. * Post-process used to create volumetric lighting effect
  72522. */
  72523. volumetricLightPostProcess: Nullable<PostProcess>;
  72524. /**
  72525. * Post-process used to smooth the previous volumetric light post-process on the X axis
  72526. */
  72527. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  72528. /**
  72529. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  72530. */
  72531. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  72532. /**
  72533. * Post-process used to merge the volumetric light effect and the real scene color
  72534. */
  72535. volumetricLightMergePostProces: Nullable<PostProcess>;
  72536. /**
  72537. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  72538. */
  72539. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  72540. /**
  72541. * Base post-process used to calculate the average luminance of the final image for HDR
  72542. */
  72543. luminancePostProcess: Nullable<PostProcess>;
  72544. /**
  72545. * Post-processes used to create down sample post-processes in order to get
  72546. * the average luminance of the final image for HDR
  72547. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  72548. */
  72549. luminanceDownSamplePostProcesses: PostProcess[];
  72550. /**
  72551. * Post-process used to create a HDR effect (light adaptation)
  72552. */
  72553. hdrPostProcess: Nullable<PostProcess>;
  72554. /**
  72555. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  72556. */
  72557. textureAdderFinalPostProcess: Nullable<PostProcess>;
  72558. /**
  72559. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  72560. */
  72561. lensFlareFinalPostProcess: Nullable<PostProcess>;
  72562. /**
  72563. * Post-process used to merge the final HDR post-process and the real scene color
  72564. */
  72565. hdrFinalPostProcess: Nullable<PostProcess>;
  72566. /**
  72567. * Post-process used to create a lens flare effect
  72568. */
  72569. lensFlarePostProcess: Nullable<PostProcess>;
  72570. /**
  72571. * Post-process that merges the result of the lens flare post-process and the real scene color
  72572. */
  72573. lensFlareComposePostProcess: Nullable<PostProcess>;
  72574. /**
  72575. * Post-process used to create a motion blur effect
  72576. */
  72577. motionBlurPostProcess: Nullable<PostProcess>;
  72578. /**
  72579. * Post-process used to create a depth of field effect
  72580. */
  72581. depthOfFieldPostProcess: Nullable<PostProcess>;
  72582. /**
  72583. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  72584. */
  72585. fxaaPostProcess: Nullable<FxaaPostProcess>;
  72586. /**
  72587. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  72588. */
  72589. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  72590. /**
  72591. * Represents the brightness threshold in order to configure the illuminated surfaces
  72592. */
  72593. brightThreshold: number;
  72594. /**
  72595. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  72596. */
  72597. blurWidth: number;
  72598. /**
  72599. * Sets if the blur for highlighted surfaces must be only horizontal
  72600. */
  72601. horizontalBlur: boolean;
  72602. /**
  72603. * Gets the overall exposure used by the pipeline
  72604. */
  72605. get exposure(): number;
  72606. /**
  72607. * Sets the overall exposure used by the pipeline
  72608. */
  72609. set exposure(value: number);
  72610. /**
  72611. * Texture used typically to simulate "dirty" on camera lens
  72612. */
  72613. lensTexture: Nullable<Texture>;
  72614. /**
  72615. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  72616. */
  72617. volumetricLightCoefficient: number;
  72618. /**
  72619. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  72620. */
  72621. volumetricLightPower: number;
  72622. /**
  72623. * Used the set the blur intensity to smooth the volumetric lights
  72624. */
  72625. volumetricLightBlurScale: number;
  72626. /**
  72627. * Light (spot or directional) used to generate the volumetric lights rays
  72628. * The source light must have a shadow generate so the pipeline can get its
  72629. * depth map
  72630. */
  72631. sourceLight: Nullable<SpotLight | DirectionalLight>;
  72632. /**
  72633. * For eye adaptation, represents the minimum luminance the eye can see
  72634. */
  72635. hdrMinimumLuminance: number;
  72636. /**
  72637. * For eye adaptation, represents the decrease luminance speed
  72638. */
  72639. hdrDecreaseRate: number;
  72640. /**
  72641. * For eye adaptation, represents the increase luminance speed
  72642. */
  72643. hdrIncreaseRate: number;
  72644. /**
  72645. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  72646. */
  72647. get hdrAutoExposure(): boolean;
  72648. /**
  72649. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  72650. */
  72651. set hdrAutoExposure(value: boolean);
  72652. /**
  72653. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  72654. */
  72655. lensColorTexture: Nullable<Texture>;
  72656. /**
  72657. * The overall strengh for the lens flare effect
  72658. */
  72659. lensFlareStrength: number;
  72660. /**
  72661. * Dispersion coefficient for lens flare ghosts
  72662. */
  72663. lensFlareGhostDispersal: number;
  72664. /**
  72665. * Main lens flare halo width
  72666. */
  72667. lensFlareHaloWidth: number;
  72668. /**
  72669. * Based on the lens distortion effect, defines how much the lens flare result
  72670. * is distorted
  72671. */
  72672. lensFlareDistortionStrength: number;
  72673. /**
  72674. * Configures the blur intensity used for for lens flare (halo)
  72675. */
  72676. lensFlareBlurWidth: number;
  72677. /**
  72678. * Lens star texture must be used to simulate rays on the flares and is available
  72679. * in the documentation
  72680. */
  72681. lensStarTexture: Nullable<Texture>;
  72682. /**
  72683. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  72684. * flare effect by taking account of the dirt texture
  72685. */
  72686. lensFlareDirtTexture: Nullable<Texture>;
  72687. /**
  72688. * Represents the focal length for the depth of field effect
  72689. */
  72690. depthOfFieldDistance: number;
  72691. /**
  72692. * Represents the blur intensity for the blurred part of the depth of field effect
  72693. */
  72694. depthOfFieldBlurWidth: number;
  72695. /**
  72696. * Gets how much the image is blurred by the movement while using the motion blur post-process
  72697. */
  72698. get motionStrength(): number;
  72699. /**
  72700. * Sets how much the image is blurred by the movement while using the motion blur post-process
  72701. */
  72702. set motionStrength(strength: number);
  72703. /**
  72704. * Gets wether or not the motion blur post-process is object based or screen based.
  72705. */
  72706. get objectBasedMotionBlur(): boolean;
  72707. /**
  72708. * Sets wether or not the motion blur post-process should be object based or screen based
  72709. */
  72710. set objectBasedMotionBlur(value: boolean);
  72711. /**
  72712. * List of animations for the pipeline (IAnimatable implementation)
  72713. */
  72714. animations: Animation[];
  72715. /**
  72716. * Private members
  72717. */
  72718. private _scene;
  72719. private _currentDepthOfFieldSource;
  72720. private _basePostProcess;
  72721. private _fixedExposure;
  72722. private _currentExposure;
  72723. private _hdrAutoExposure;
  72724. private _hdrCurrentLuminance;
  72725. private _motionStrength;
  72726. private _isObjectBasedMotionBlur;
  72727. private _floatTextureType;
  72728. private _camerasToBeAttached;
  72729. private _ratio;
  72730. private _bloomEnabled;
  72731. private _depthOfFieldEnabled;
  72732. private _vlsEnabled;
  72733. private _lensFlareEnabled;
  72734. private _hdrEnabled;
  72735. private _motionBlurEnabled;
  72736. private _fxaaEnabled;
  72737. private _screenSpaceReflectionsEnabled;
  72738. private _motionBlurSamples;
  72739. private _volumetricLightStepsCount;
  72740. private _samples;
  72741. /**
  72742. * @ignore
  72743. * Specifies if the bloom pipeline is enabled
  72744. */
  72745. get BloomEnabled(): boolean;
  72746. set BloomEnabled(enabled: boolean);
  72747. /**
  72748. * @ignore
  72749. * Specifies if the depth of field pipeline is enabed
  72750. */
  72751. get DepthOfFieldEnabled(): boolean;
  72752. set DepthOfFieldEnabled(enabled: boolean);
  72753. /**
  72754. * @ignore
  72755. * Specifies if the lens flare pipeline is enabed
  72756. */
  72757. get LensFlareEnabled(): boolean;
  72758. set LensFlareEnabled(enabled: boolean);
  72759. /**
  72760. * @ignore
  72761. * Specifies if the HDR pipeline is enabled
  72762. */
  72763. get HDREnabled(): boolean;
  72764. set HDREnabled(enabled: boolean);
  72765. /**
  72766. * @ignore
  72767. * Specifies if the volumetric lights scattering effect is enabled
  72768. */
  72769. get VLSEnabled(): boolean;
  72770. set VLSEnabled(enabled: boolean);
  72771. /**
  72772. * @ignore
  72773. * Specifies if the motion blur effect is enabled
  72774. */
  72775. get MotionBlurEnabled(): boolean;
  72776. set MotionBlurEnabled(enabled: boolean);
  72777. /**
  72778. * Specifies if anti-aliasing is enabled
  72779. */
  72780. get fxaaEnabled(): boolean;
  72781. set fxaaEnabled(enabled: boolean);
  72782. /**
  72783. * Specifies if screen space reflections are enabled.
  72784. */
  72785. get screenSpaceReflectionsEnabled(): boolean;
  72786. set screenSpaceReflectionsEnabled(enabled: boolean);
  72787. /**
  72788. * Specifies the number of steps used to calculate the volumetric lights
  72789. * Typically in interval [50, 200]
  72790. */
  72791. get volumetricLightStepsCount(): number;
  72792. set volumetricLightStepsCount(count: number);
  72793. /**
  72794. * Specifies the number of samples used for the motion blur effect
  72795. * Typically in interval [16, 64]
  72796. */
  72797. get motionBlurSamples(): number;
  72798. set motionBlurSamples(samples: number);
  72799. /**
  72800. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  72801. */
  72802. get samples(): number;
  72803. set samples(sampleCount: number);
  72804. /**
  72805. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  72806. * @constructor
  72807. * @param name The rendering pipeline name
  72808. * @param scene The scene linked to this pipeline
  72809. * @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)
  72810. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  72811. * @param cameras The array of cameras that the rendering pipeline will be attached to
  72812. */
  72813. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  72814. private _buildPipeline;
  72815. private _createDownSampleX4PostProcess;
  72816. private _createBrightPassPostProcess;
  72817. private _createBlurPostProcesses;
  72818. private _createTextureAdderPostProcess;
  72819. private _createVolumetricLightPostProcess;
  72820. private _createLuminancePostProcesses;
  72821. private _createHdrPostProcess;
  72822. private _createLensFlarePostProcess;
  72823. private _createDepthOfFieldPostProcess;
  72824. private _createMotionBlurPostProcess;
  72825. private _getDepthTexture;
  72826. private _disposePostProcesses;
  72827. /**
  72828. * Dispose of the pipeline and stop all post processes
  72829. */
  72830. dispose(): void;
  72831. /**
  72832. * Serialize the rendering pipeline (Used when exporting)
  72833. * @returns the serialized object
  72834. */
  72835. serialize(): any;
  72836. /**
  72837. * Parse the serialized pipeline
  72838. * @param source Source pipeline.
  72839. * @param scene The scene to load the pipeline to.
  72840. * @param rootUrl The URL of the serialized pipeline.
  72841. * @returns An instantiated pipeline from the serialized object.
  72842. */
  72843. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  72844. /**
  72845. * Luminance steps
  72846. */
  72847. static LuminanceSteps: number;
  72848. }
  72849. }
  72850. declare module BABYLON {
  72851. /** @hidden */
  72852. export var stereoscopicInterlacePixelShader: {
  72853. name: string;
  72854. shader: string;
  72855. };
  72856. }
  72857. declare module BABYLON {
  72858. /**
  72859. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  72860. */
  72861. export class StereoscopicInterlacePostProcessI extends PostProcess {
  72862. private _stepSize;
  72863. private _passedProcess;
  72864. /**
  72865. * Gets a string identifying the name of the class
  72866. * @returns "StereoscopicInterlacePostProcessI" string
  72867. */
  72868. getClassName(): string;
  72869. /**
  72870. * Initializes a StereoscopicInterlacePostProcessI
  72871. * @param name The name of the effect.
  72872. * @param rigCameras The rig cameras to be appled to the post process
  72873. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  72874. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  72875. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72876. * @param engine The engine which the post process will be applied. (default: current engine)
  72877. * @param reusable If the post process can be reused on the same frame. (default: false)
  72878. */
  72879. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  72880. }
  72881. /**
  72882. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  72883. */
  72884. export class StereoscopicInterlacePostProcess extends PostProcess {
  72885. private _stepSize;
  72886. private _passedProcess;
  72887. /**
  72888. * Gets a string identifying the name of the class
  72889. * @returns "StereoscopicInterlacePostProcess" string
  72890. */
  72891. getClassName(): string;
  72892. /**
  72893. * Initializes a StereoscopicInterlacePostProcess
  72894. * @param name The name of the effect.
  72895. * @param rigCameras The rig cameras to be appled to the post process
  72896. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  72897. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72898. * @param engine The engine which the post process will be applied. (default: current engine)
  72899. * @param reusable If the post process can be reused on the same frame. (default: false)
  72900. */
  72901. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  72902. }
  72903. }
  72904. declare module BABYLON {
  72905. /** @hidden */
  72906. export var tonemapPixelShader: {
  72907. name: string;
  72908. shader: string;
  72909. };
  72910. }
  72911. declare module BABYLON {
  72912. /** Defines operator used for tonemapping */
  72913. export enum TonemappingOperator {
  72914. /** Hable */
  72915. Hable = 0,
  72916. /** Reinhard */
  72917. Reinhard = 1,
  72918. /** HejiDawson */
  72919. HejiDawson = 2,
  72920. /** Photographic */
  72921. Photographic = 3
  72922. }
  72923. /**
  72924. * Defines a post process to apply tone mapping
  72925. */
  72926. export class TonemapPostProcess extends PostProcess {
  72927. private _operator;
  72928. /** Defines the required exposure adjustement */
  72929. exposureAdjustment: number;
  72930. /**
  72931. * Gets a string identifying the name of the class
  72932. * @returns "TonemapPostProcess" string
  72933. */
  72934. getClassName(): string;
  72935. /**
  72936. * Creates a new TonemapPostProcess
  72937. * @param name defines the name of the postprocess
  72938. * @param _operator defines the operator to use
  72939. * @param exposureAdjustment defines the required exposure adjustement
  72940. * @param camera defines the camera to use (can be null)
  72941. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  72942. * @param engine defines the hosting engine (can be ignore if camera is set)
  72943. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  72944. */
  72945. constructor(name: string, _operator: TonemappingOperator,
  72946. /** Defines the required exposure adjustement */
  72947. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  72948. }
  72949. }
  72950. declare module BABYLON {
  72951. /** @hidden */
  72952. export var volumetricLightScatteringPixelShader: {
  72953. name: string;
  72954. shader: string;
  72955. };
  72956. }
  72957. declare module BABYLON {
  72958. /** @hidden */
  72959. export var volumetricLightScatteringPassVertexShader: {
  72960. name: string;
  72961. shader: string;
  72962. };
  72963. }
  72964. declare module BABYLON {
  72965. /** @hidden */
  72966. export var volumetricLightScatteringPassPixelShader: {
  72967. name: string;
  72968. shader: string;
  72969. };
  72970. }
  72971. declare module BABYLON {
  72972. /**
  72973. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  72974. */
  72975. export class VolumetricLightScatteringPostProcess extends PostProcess {
  72976. private _volumetricLightScatteringPass;
  72977. private _volumetricLightScatteringRTT;
  72978. private _viewPort;
  72979. private _screenCoordinates;
  72980. private _cachedDefines;
  72981. /**
  72982. * If not undefined, the mesh position is computed from the attached node position
  72983. */
  72984. attachedNode: {
  72985. position: Vector3;
  72986. };
  72987. /**
  72988. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  72989. */
  72990. customMeshPosition: Vector3;
  72991. /**
  72992. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  72993. */
  72994. useCustomMeshPosition: boolean;
  72995. /**
  72996. * If the post-process should inverse the light scattering direction
  72997. */
  72998. invert: boolean;
  72999. /**
  73000. * The internal mesh used by the post-process
  73001. */
  73002. mesh: Mesh;
  73003. /**
  73004. * @hidden
  73005. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  73006. */
  73007. get useDiffuseColor(): boolean;
  73008. set useDiffuseColor(useDiffuseColor: boolean);
  73009. /**
  73010. * Array containing the excluded meshes not rendered in the internal pass
  73011. */
  73012. excludedMeshes: AbstractMesh[];
  73013. /**
  73014. * Controls the overall intensity of the post-process
  73015. */
  73016. exposure: number;
  73017. /**
  73018. * Dissipates each sample's contribution in range [0, 1]
  73019. */
  73020. decay: number;
  73021. /**
  73022. * Controls the overall intensity of each sample
  73023. */
  73024. weight: number;
  73025. /**
  73026. * Controls the density of each sample
  73027. */
  73028. density: number;
  73029. /**
  73030. * @constructor
  73031. * @param name The post-process name
  73032. * @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)
  73033. * @param camera The camera that the post-process will be attached to
  73034. * @param mesh The mesh used to create the light scattering
  73035. * @param samples The post-process quality, default 100
  73036. * @param samplingModeThe post-process filtering mode
  73037. * @param engine The babylon engine
  73038. * @param reusable If the post-process is reusable
  73039. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  73040. */
  73041. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  73042. /**
  73043. * Returns the string "VolumetricLightScatteringPostProcess"
  73044. * @returns "VolumetricLightScatteringPostProcess"
  73045. */
  73046. getClassName(): string;
  73047. private _isReady;
  73048. /**
  73049. * Sets the new light position for light scattering effect
  73050. * @param position The new custom light position
  73051. */
  73052. setCustomMeshPosition(position: Vector3): void;
  73053. /**
  73054. * Returns the light position for light scattering effect
  73055. * @return Vector3 The custom light position
  73056. */
  73057. getCustomMeshPosition(): Vector3;
  73058. /**
  73059. * Disposes the internal assets and detaches the post-process from the camera
  73060. */
  73061. dispose(camera: Camera): void;
  73062. /**
  73063. * Returns the render target texture used by the post-process
  73064. * @return the render target texture used by the post-process
  73065. */
  73066. getPass(): RenderTargetTexture;
  73067. private _meshExcluded;
  73068. private _createPass;
  73069. private _updateMeshScreenCoordinates;
  73070. /**
  73071. * Creates a default mesh for the Volumeric Light Scattering post-process
  73072. * @param name The mesh name
  73073. * @param scene The scene where to create the mesh
  73074. * @return the default mesh
  73075. */
  73076. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  73077. }
  73078. }
  73079. declare module BABYLON {
  73080. /** @hidden */
  73081. export var screenSpaceCurvaturePixelShader: {
  73082. name: string;
  73083. shader: string;
  73084. };
  73085. }
  73086. declare module BABYLON {
  73087. /**
  73088. * The Screen Space curvature effect can help highlighting ridge and valley of a model.
  73089. */
  73090. export class ScreenSpaceCurvaturePostProcess extends PostProcess {
  73091. /**
  73092. * Defines how much ridge the curvature effect displays.
  73093. */
  73094. ridge: number;
  73095. /**
  73096. * Defines how much valley the curvature effect displays.
  73097. */
  73098. valley: number;
  73099. private _geometryBufferRenderer;
  73100. /**
  73101. * Gets a string identifying the name of the class
  73102. * @returns "ScreenSpaceCurvaturePostProcess" string
  73103. */
  73104. getClassName(): string;
  73105. /**
  73106. * Creates a new instance ScreenSpaceCurvaturePostProcess
  73107. * @param name The name of the effect.
  73108. * @param scene The scene containing the objects to blur according to their velocity.
  73109. * @param options The required width/height ratio to downsize to before computing the render pass.
  73110. * @param camera The camera to apply the render pass to.
  73111. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73112. * @param engine The engine which the post process will be applied. (default: current engine)
  73113. * @param reusable If the post process can be reused on the same frame. (default: false)
  73114. * @param textureType Type of textures used when performing the post process. (default: 0)
  73115. * @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)
  73116. */
  73117. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73118. /**
  73119. * Support test.
  73120. */
  73121. static get IsSupported(): boolean;
  73122. /** @hidden */
  73123. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceCurvaturePostProcess;
  73124. }
  73125. }
  73126. declare module BABYLON {
  73127. interface Scene {
  73128. /** @hidden (Backing field) */
  73129. _boundingBoxRenderer: BoundingBoxRenderer;
  73130. /** @hidden (Backing field) */
  73131. _forceShowBoundingBoxes: boolean;
  73132. /**
  73133. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  73134. */
  73135. forceShowBoundingBoxes: boolean;
  73136. /**
  73137. * Gets the bounding box renderer associated with the scene
  73138. * @returns a BoundingBoxRenderer
  73139. */
  73140. getBoundingBoxRenderer(): BoundingBoxRenderer;
  73141. }
  73142. interface AbstractMesh {
  73143. /** @hidden (Backing field) */
  73144. _showBoundingBox: boolean;
  73145. /**
  73146. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  73147. */
  73148. showBoundingBox: boolean;
  73149. }
  73150. /**
  73151. * Component responsible of rendering the bounding box of the meshes in a scene.
  73152. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  73153. */
  73154. export class BoundingBoxRenderer implements ISceneComponent {
  73155. /**
  73156. * The component name helpfull to identify the component in the list of scene components.
  73157. */
  73158. readonly name: string;
  73159. /**
  73160. * The scene the component belongs to.
  73161. */
  73162. scene: Scene;
  73163. /**
  73164. * Color of the bounding box lines placed in front of an object
  73165. */
  73166. frontColor: Color3;
  73167. /**
  73168. * Color of the bounding box lines placed behind an object
  73169. */
  73170. backColor: Color3;
  73171. /**
  73172. * Defines if the renderer should show the back lines or not
  73173. */
  73174. showBackLines: boolean;
  73175. /**
  73176. * Observable raised before rendering a bounding box
  73177. */
  73178. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  73179. /**
  73180. * Observable raised after rendering a bounding box
  73181. */
  73182. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  73183. /**
  73184. * Observable raised after resources are created
  73185. */
  73186. onResourcesReadyObservable: Observable<BoundingBoxRenderer>;
  73187. /**
  73188. * When false, no bounding boxes will be rendered
  73189. */
  73190. enabled: boolean;
  73191. /**
  73192. * @hidden
  73193. */
  73194. renderList: SmartArray<BoundingBox>;
  73195. private _colorShader;
  73196. private _vertexBuffers;
  73197. private _indexBuffer;
  73198. private _fillIndexBuffer;
  73199. private _fillIndexData;
  73200. /**
  73201. * Instantiates a new bounding box renderer in a scene.
  73202. * @param scene the scene the renderer renders in
  73203. */
  73204. constructor(scene: Scene);
  73205. /**
  73206. * Registers the component in a given scene
  73207. */
  73208. register(): void;
  73209. private _evaluateSubMesh;
  73210. private _preActiveMesh;
  73211. private _prepareResources;
  73212. private _createIndexBuffer;
  73213. /**
  73214. * Rebuilds the elements related to this component in case of
  73215. * context lost for instance.
  73216. */
  73217. rebuild(): void;
  73218. /**
  73219. * @hidden
  73220. */
  73221. reset(): void;
  73222. /**
  73223. * Render the bounding boxes of a specific rendering group
  73224. * @param renderingGroupId defines the rendering group to render
  73225. */
  73226. render(renderingGroupId: number): void;
  73227. /**
  73228. * In case of occlusion queries, we can render the occlusion bounding box through this method
  73229. * @param mesh Define the mesh to render the occlusion bounding box for
  73230. */
  73231. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  73232. /**
  73233. * Dispose and release the resources attached to this renderer.
  73234. */
  73235. dispose(): void;
  73236. }
  73237. }
  73238. declare module BABYLON {
  73239. interface Scene {
  73240. /** @hidden (Backing field) */
  73241. _depthRenderer: {
  73242. [id: string]: DepthRenderer;
  73243. };
  73244. /**
  73245. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  73246. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  73247. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  73248. * @param force32bitsFloat Forces 32 bits float when supported (else 16 bits float is prioritized over 32 bits float if supported)
  73249. * @returns the created depth renderer
  73250. */
  73251. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean, force32bitsFloat?: boolean): DepthRenderer;
  73252. /**
  73253. * Disables a depth renderer for a given camera
  73254. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  73255. */
  73256. disableDepthRenderer(camera?: Nullable<Camera>): void;
  73257. }
  73258. /**
  73259. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  73260. * in several rendering techniques.
  73261. */
  73262. export class DepthRendererSceneComponent implements ISceneComponent {
  73263. /**
  73264. * The component name helpfull to identify the component in the list of scene components.
  73265. */
  73266. readonly name: string;
  73267. /**
  73268. * The scene the component belongs to.
  73269. */
  73270. scene: Scene;
  73271. /**
  73272. * Creates a new instance of the component for the given scene
  73273. * @param scene Defines the scene to register the component in
  73274. */
  73275. constructor(scene: Scene);
  73276. /**
  73277. * Registers the component in a given scene
  73278. */
  73279. register(): void;
  73280. /**
  73281. * Rebuilds the elements related to this component in case of
  73282. * context lost for instance.
  73283. */
  73284. rebuild(): void;
  73285. /**
  73286. * Disposes the component and the associated ressources
  73287. */
  73288. dispose(): void;
  73289. private _gatherRenderTargets;
  73290. private _gatherActiveCameraRenderTargets;
  73291. }
  73292. }
  73293. declare module BABYLON {
  73294. interface AbstractScene {
  73295. /** @hidden (Backing field) */
  73296. _prePassRenderer: Nullable<PrePassRenderer>;
  73297. /**
  73298. * Gets or Sets the current prepass renderer associated to the scene.
  73299. */
  73300. prePassRenderer: Nullable<PrePassRenderer>;
  73301. /**
  73302. * Enables the prepass and associates it with the scene
  73303. * @returns the PrePassRenderer
  73304. */
  73305. enablePrePassRenderer(): Nullable<PrePassRenderer>;
  73306. /**
  73307. * Disables the prepass associated with the scene
  73308. */
  73309. disablePrePassRenderer(): void;
  73310. }
  73311. /**
  73312. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  73313. * in several rendering techniques.
  73314. */
  73315. export class PrePassRendererSceneComponent implements ISceneComponent {
  73316. /**
  73317. * The component name helpful to identify the component in the list of scene components.
  73318. */
  73319. readonly name: string;
  73320. /**
  73321. * The scene the component belongs to.
  73322. */
  73323. scene: Scene;
  73324. /**
  73325. * Creates a new instance of the component for the given scene
  73326. * @param scene Defines the scene to register the component in
  73327. */
  73328. constructor(scene: Scene);
  73329. /**
  73330. * Registers the component in a given scene
  73331. */
  73332. register(): void;
  73333. private _beforeCameraDraw;
  73334. private _afterCameraDraw;
  73335. private _beforeClearStage;
  73336. /**
  73337. * Rebuilds the elements related to this component in case of
  73338. * context lost for instance.
  73339. */
  73340. rebuild(): void;
  73341. /**
  73342. * Disposes the component and the associated ressources
  73343. */
  73344. dispose(): void;
  73345. }
  73346. }
  73347. declare module BABYLON {
  73348. /** @hidden */
  73349. export var fibonacci: {
  73350. name: string;
  73351. shader: string;
  73352. };
  73353. }
  73354. declare module BABYLON {
  73355. /** @hidden */
  73356. export var diffusionProfile: {
  73357. name: string;
  73358. shader: string;
  73359. };
  73360. }
  73361. declare module BABYLON {
  73362. /** @hidden */
  73363. export var subSurfaceScatteringPixelShader: {
  73364. name: string;
  73365. shader: string;
  73366. };
  73367. }
  73368. declare module BABYLON {
  73369. /**
  73370. * Sub surface scattering post process
  73371. */
  73372. export class SubSurfaceScatteringPostProcess extends PostProcess {
  73373. /**
  73374. * Gets a string identifying the name of the class
  73375. * @returns "SubSurfaceScatteringPostProcess" string
  73376. */
  73377. getClassName(): string;
  73378. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  73379. }
  73380. }
  73381. declare module BABYLON {
  73382. /**
  73383. * Contains all parameters needed for the prepass to perform
  73384. * screen space subsurface scattering
  73385. */
  73386. export class SubSurfaceConfiguration implements PrePassEffectConfiguration {
  73387. /** @hidden */
  73388. static _SceneComponentInitialization: (scene: Scene) => void;
  73389. private _ssDiffusionS;
  73390. private _ssFilterRadii;
  73391. private _ssDiffusionD;
  73392. /**
  73393. * Post process to attach for screen space subsurface scattering
  73394. */
  73395. postProcess: SubSurfaceScatteringPostProcess;
  73396. /**
  73397. * Diffusion profile color for subsurface scattering
  73398. */
  73399. get ssDiffusionS(): number[];
  73400. /**
  73401. * Diffusion profile max color channel value for subsurface scattering
  73402. */
  73403. get ssDiffusionD(): number[];
  73404. /**
  73405. * Diffusion profile filter radius for subsurface scattering
  73406. */
  73407. get ssFilterRadii(): number[];
  73408. /**
  73409. * Is subsurface enabled
  73410. */
  73411. enabled: boolean;
  73412. /**
  73413. * Name of the configuration
  73414. */
  73415. name: string;
  73416. /**
  73417. * Diffusion profile colors for subsurface scattering
  73418. * You can add one diffusion color using `addDiffusionProfile` on `scene.prePassRenderer`
  73419. * See ...
  73420. * Note that you can only store up to 5 of them
  73421. */
  73422. ssDiffusionProfileColors: Color3[];
  73423. /**
  73424. * Defines the ratio real world => scene units.
  73425. * Used for subsurface scattering
  73426. */
  73427. metersPerUnit: number;
  73428. /**
  73429. * Textures that should be present in the MRT for this effect to work
  73430. */
  73431. readonly texturesRequired: number[];
  73432. private _scene;
  73433. /**
  73434. * Builds a subsurface configuration object
  73435. * @param scene The scene
  73436. */
  73437. constructor(scene: Scene);
  73438. /**
  73439. * Adds a new diffusion profile.
  73440. * Useful for more realistic subsurface scattering on diverse materials.
  73441. * @param color The color of the diffusion profile. Should be the average color of the material.
  73442. * @return The index of the diffusion profile for the material subsurface configuration
  73443. */
  73444. addDiffusionProfile(color: Color3): number;
  73445. /**
  73446. * Creates the sss post process
  73447. * @return The created post process
  73448. */
  73449. createPostProcess(): SubSurfaceScatteringPostProcess;
  73450. /**
  73451. * Deletes all diffusion profiles.
  73452. * Note that in order to render subsurface scattering, you should have at least 1 diffusion profile.
  73453. */
  73454. clearAllDiffusionProfiles(): void;
  73455. /**
  73456. * Disposes this object
  73457. */
  73458. dispose(): void;
  73459. /**
  73460. * @hidden
  73461. * https://zero-radiance.github.io/post/sampling-diffusion/
  73462. *
  73463. * Importance sample the normalized diffuse reflectance profile for the computed value of 's'.
  73464. * ------------------------------------------------------------------------------------
  73465. * R[r, phi, s] = s * (Exp[-r * s] + Exp[-r * s / 3]) / (8 * Pi * r)
  73466. * PDF[r, phi, s] = r * R[r, phi, s]
  73467. * CDF[r, s] = 1 - 1/4 * Exp[-r * s] - 3/4 * Exp[-r * s / 3]
  73468. * ------------------------------------------------------------------------------------
  73469. * We importance sample the color channel with the widest scattering distance.
  73470. */
  73471. getDiffusionProfileParameters(color: Color3): number;
  73472. /**
  73473. * Performs sampling of a Normalized Burley diffusion profile in polar coordinates.
  73474. * 'u' is the random number (the value of the CDF): [0, 1).
  73475. * rcp(s) = 1 / ShapeParam = ScatteringDistance.
  73476. * Returns the sampled radial distance, s.t. (u = 0 -> r = 0) and (u = 1 -> r = Inf).
  73477. */
  73478. private _sampleBurleyDiffusionProfile;
  73479. }
  73480. }
  73481. declare module BABYLON {
  73482. interface AbstractScene {
  73483. /** @hidden (Backing field) */
  73484. _subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  73485. /**
  73486. * Gets or Sets the current prepass renderer associated to the scene.
  73487. */
  73488. subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  73489. /**
  73490. * Enables the subsurface effect for prepass
  73491. * @returns the SubSurfaceConfiguration
  73492. */
  73493. enableSubSurfaceForPrePass(): Nullable<SubSurfaceConfiguration>;
  73494. /**
  73495. * Disables the subsurface effect for prepass
  73496. */
  73497. disableSubSurfaceForPrePass(): void;
  73498. }
  73499. /**
  73500. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  73501. * in several rendering techniques.
  73502. */
  73503. export class SubSurfaceSceneComponent implements ISceneSerializableComponent {
  73504. /**
  73505. * The component name helpful to identify the component in the list of scene components.
  73506. */
  73507. readonly name: string;
  73508. /**
  73509. * The scene the component belongs to.
  73510. */
  73511. scene: Scene;
  73512. /**
  73513. * Creates a new instance of the component for the given scene
  73514. * @param scene Defines the scene to register the component in
  73515. */
  73516. constructor(scene: Scene);
  73517. /**
  73518. * Registers the component in a given scene
  73519. */
  73520. register(): void;
  73521. /**
  73522. * Serializes the component data to the specified json object
  73523. * @param serializationObject The object to serialize to
  73524. */
  73525. serialize(serializationObject: any): void;
  73526. /**
  73527. * Adds all the elements from the container to the scene
  73528. * @param container the container holding the elements
  73529. */
  73530. addFromContainer(container: AbstractScene): void;
  73531. /**
  73532. * Removes all the elements in the container from the scene
  73533. * @param container contains the elements to remove
  73534. * @param dispose if the removed element should be disposed (default: false)
  73535. */
  73536. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  73537. /**
  73538. * Rebuilds the elements related to this component in case of
  73539. * context lost for instance.
  73540. */
  73541. rebuild(): void;
  73542. /**
  73543. * Disposes the component and the associated ressources
  73544. */
  73545. dispose(): void;
  73546. }
  73547. }
  73548. declare module BABYLON {
  73549. /** @hidden */
  73550. export var outlinePixelShader: {
  73551. name: string;
  73552. shader: string;
  73553. };
  73554. }
  73555. declare module BABYLON {
  73556. /** @hidden */
  73557. export var outlineVertexShader: {
  73558. name: string;
  73559. shader: string;
  73560. };
  73561. }
  73562. declare module BABYLON {
  73563. interface Scene {
  73564. /** @hidden */
  73565. _outlineRenderer: OutlineRenderer;
  73566. /**
  73567. * Gets the outline renderer associated with the scene
  73568. * @returns a OutlineRenderer
  73569. */
  73570. getOutlineRenderer(): OutlineRenderer;
  73571. }
  73572. interface AbstractMesh {
  73573. /** @hidden (Backing field) */
  73574. _renderOutline: boolean;
  73575. /**
  73576. * Gets or sets a boolean indicating if the outline must be rendered as well
  73577. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  73578. */
  73579. renderOutline: boolean;
  73580. /** @hidden (Backing field) */
  73581. _renderOverlay: boolean;
  73582. /**
  73583. * Gets or sets a boolean indicating if the overlay must be rendered as well
  73584. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  73585. */
  73586. renderOverlay: boolean;
  73587. }
  73588. /**
  73589. * This class is responsible to draw bothe outline/overlay of meshes.
  73590. * It should not be used directly but through the available method on mesh.
  73591. */
  73592. export class OutlineRenderer implements ISceneComponent {
  73593. /**
  73594. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  73595. */
  73596. private static _StencilReference;
  73597. /**
  73598. * The name of the component. Each component must have a unique name.
  73599. */
  73600. name: string;
  73601. /**
  73602. * The scene the component belongs to.
  73603. */
  73604. scene: Scene;
  73605. /**
  73606. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  73607. */
  73608. zOffset: number;
  73609. private _engine;
  73610. private _effect;
  73611. private _cachedDefines;
  73612. private _savedDepthWrite;
  73613. /**
  73614. * Instantiates a new outline renderer. (There could be only one per scene).
  73615. * @param scene Defines the scene it belongs to
  73616. */
  73617. constructor(scene: Scene);
  73618. /**
  73619. * Register the component to one instance of a scene.
  73620. */
  73621. register(): void;
  73622. /**
  73623. * Rebuilds the elements related to this component in case of
  73624. * context lost for instance.
  73625. */
  73626. rebuild(): void;
  73627. /**
  73628. * Disposes the component and the associated ressources.
  73629. */
  73630. dispose(): void;
  73631. /**
  73632. * Renders the outline in the canvas.
  73633. * @param subMesh Defines the sumesh to render
  73634. * @param batch Defines the batch of meshes in case of instances
  73635. * @param useOverlay Defines if the rendering is for the overlay or the outline
  73636. */
  73637. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  73638. /**
  73639. * Returns whether or not the outline renderer is ready for a given submesh.
  73640. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  73641. * @param subMesh Defines the submesh to check readyness for
  73642. * @param useInstances Defines wheter wee are trying to render instances or not
  73643. * @returns true if ready otherwise false
  73644. */
  73645. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  73646. private _beforeRenderingMesh;
  73647. private _afterRenderingMesh;
  73648. }
  73649. }
  73650. declare module BABYLON {
  73651. /**
  73652. * Defines the basic options interface of a Sprite Frame Source Size.
  73653. */
  73654. export interface ISpriteJSONSpriteSourceSize {
  73655. /**
  73656. * number of the original width of the Frame
  73657. */
  73658. w: number;
  73659. /**
  73660. * number of the original height of the Frame
  73661. */
  73662. h: number;
  73663. }
  73664. /**
  73665. * Defines the basic options interface of a Sprite Frame Data.
  73666. */
  73667. export interface ISpriteJSONSpriteFrameData {
  73668. /**
  73669. * number of the x offset of the Frame
  73670. */
  73671. x: number;
  73672. /**
  73673. * number of the y offset of the Frame
  73674. */
  73675. y: number;
  73676. /**
  73677. * number of the width of the Frame
  73678. */
  73679. w: number;
  73680. /**
  73681. * number of the height of the Frame
  73682. */
  73683. h: number;
  73684. }
  73685. /**
  73686. * Defines the basic options interface of a JSON Sprite.
  73687. */
  73688. export interface ISpriteJSONSprite {
  73689. /**
  73690. * string name of the Frame
  73691. */
  73692. filename: string;
  73693. /**
  73694. * ISpriteJSONSpriteFrame basic object of the frame data
  73695. */
  73696. frame: ISpriteJSONSpriteFrameData;
  73697. /**
  73698. * boolean to flag is the frame was rotated.
  73699. */
  73700. rotated: boolean;
  73701. /**
  73702. * boolean to flag is the frame was trimmed.
  73703. */
  73704. trimmed: boolean;
  73705. /**
  73706. * ISpriteJSONSpriteFrame basic object of the source data
  73707. */
  73708. spriteSourceSize: ISpriteJSONSpriteFrameData;
  73709. /**
  73710. * ISpriteJSONSpriteFrame basic object of the source data
  73711. */
  73712. sourceSize: ISpriteJSONSpriteSourceSize;
  73713. }
  73714. /**
  73715. * Defines the basic options interface of a JSON atlas.
  73716. */
  73717. export interface ISpriteJSONAtlas {
  73718. /**
  73719. * Array of objects that contain the frame data.
  73720. */
  73721. frames: Array<ISpriteJSONSprite>;
  73722. /**
  73723. * object basic object containing the sprite meta data.
  73724. */
  73725. meta?: object;
  73726. }
  73727. }
  73728. declare module BABYLON {
  73729. /** @hidden */
  73730. export var spriteMapPixelShader: {
  73731. name: string;
  73732. shader: string;
  73733. };
  73734. }
  73735. declare module BABYLON {
  73736. /** @hidden */
  73737. export var spriteMapVertexShader: {
  73738. name: string;
  73739. shader: string;
  73740. };
  73741. }
  73742. declare module BABYLON {
  73743. /**
  73744. * Defines the basic options interface of a SpriteMap
  73745. */
  73746. export interface ISpriteMapOptions {
  73747. /**
  73748. * Vector2 of the number of cells in the grid.
  73749. */
  73750. stageSize?: Vector2;
  73751. /**
  73752. * Vector2 of the size of the output plane in World Units.
  73753. */
  73754. outputSize?: Vector2;
  73755. /**
  73756. * Vector3 of the position of the output plane in World Units.
  73757. */
  73758. outputPosition?: Vector3;
  73759. /**
  73760. * Vector3 of the rotation of the output plane.
  73761. */
  73762. outputRotation?: Vector3;
  73763. /**
  73764. * number of layers that the system will reserve in resources.
  73765. */
  73766. layerCount?: number;
  73767. /**
  73768. * number of max animation frames a single cell will reserve in resources.
  73769. */
  73770. maxAnimationFrames?: number;
  73771. /**
  73772. * number cell index of the base tile when the system compiles.
  73773. */
  73774. baseTile?: number;
  73775. /**
  73776. * boolean flip the sprite after its been repositioned by the framing data.
  73777. */
  73778. flipU?: boolean;
  73779. /**
  73780. * Vector3 scalar of the global RGB values of the SpriteMap.
  73781. */
  73782. colorMultiply?: Vector3;
  73783. }
  73784. /**
  73785. * Defines the IDisposable interface in order to be cleanable from resources.
  73786. */
  73787. export interface ISpriteMap extends IDisposable {
  73788. /**
  73789. * String name of the SpriteMap.
  73790. */
  73791. name: string;
  73792. /**
  73793. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  73794. */
  73795. atlasJSON: ISpriteJSONAtlas;
  73796. /**
  73797. * Texture of the SpriteMap.
  73798. */
  73799. spriteSheet: Texture;
  73800. /**
  73801. * The parameters to initialize the SpriteMap with.
  73802. */
  73803. options: ISpriteMapOptions;
  73804. }
  73805. /**
  73806. * Class used to manage a grid restricted sprite deployment on an Output plane.
  73807. */
  73808. export class SpriteMap implements ISpriteMap {
  73809. /** The Name of the spriteMap */
  73810. name: string;
  73811. /** The JSON file with the frame and meta data */
  73812. atlasJSON: ISpriteJSONAtlas;
  73813. /** The systems Sprite Sheet Texture */
  73814. spriteSheet: Texture;
  73815. /** Arguments passed with the Constructor */
  73816. options: ISpriteMapOptions;
  73817. /** Public Sprite Storage array, parsed from atlasJSON */
  73818. sprites: Array<ISpriteJSONSprite>;
  73819. /** Returns the Number of Sprites in the System */
  73820. get spriteCount(): number;
  73821. /** Returns the Position of Output Plane*/
  73822. get position(): Vector3;
  73823. /** Returns the Position of Output Plane*/
  73824. set position(v: Vector3);
  73825. /** Returns the Rotation of Output Plane*/
  73826. get rotation(): Vector3;
  73827. /** Returns the Rotation of Output Plane*/
  73828. set rotation(v: Vector3);
  73829. /** Sets the AnimationMap*/
  73830. get animationMap(): RawTexture;
  73831. /** Sets the AnimationMap*/
  73832. set animationMap(v: RawTexture);
  73833. /** Scene that the SpriteMap was created in */
  73834. private _scene;
  73835. /** Texture Buffer of Float32 that holds tile frame data*/
  73836. private _frameMap;
  73837. /** Texture Buffers of Float32 that holds tileMap data*/
  73838. private _tileMaps;
  73839. /** Texture Buffer of Float32 that holds Animation Data*/
  73840. private _animationMap;
  73841. /** Custom ShaderMaterial Central to the System*/
  73842. private _material;
  73843. /** Custom ShaderMaterial Central to the System*/
  73844. private _output;
  73845. /** Systems Time Ticker*/
  73846. private _time;
  73847. /**
  73848. * Creates a new SpriteMap
  73849. * @param name defines the SpriteMaps Name
  73850. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  73851. * @param spriteSheet is the Texture that the Sprites are on.
  73852. * @param options a basic deployment configuration
  73853. * @param scene The Scene that the map is deployed on
  73854. */
  73855. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  73856. /**
  73857. * Returns tileID location
  73858. * @returns Vector2 the cell position ID
  73859. */
  73860. getTileID(): Vector2;
  73861. /**
  73862. * Gets the UV location of the mouse over the SpriteMap.
  73863. * @returns Vector2 the UV position of the mouse interaction
  73864. */
  73865. getMousePosition(): Vector2;
  73866. /**
  73867. * Creates the "frame" texture Buffer
  73868. * -------------------------------------
  73869. * Structure of frames
  73870. * "filename": "Falling-Water-2.png",
  73871. * "frame": {"x":69,"y":103,"w":24,"h":32},
  73872. * "rotated": true,
  73873. * "trimmed": true,
  73874. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  73875. * "sourceSize": {"w":32,"h":32}
  73876. * @returns RawTexture of the frameMap
  73877. */
  73878. private _createFrameBuffer;
  73879. /**
  73880. * Creates the tileMap texture Buffer
  73881. * @param buffer normally and array of numbers, or a false to generate from scratch
  73882. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  73883. * @returns RawTexture of the tileMap
  73884. */
  73885. private _createTileBuffer;
  73886. /**
  73887. * Modifies the data of the tileMaps
  73888. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  73889. * @param pos is the iVector2 Coordinates of the Tile
  73890. * @param tile The SpriteIndex of the new Tile
  73891. */
  73892. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  73893. /**
  73894. * Creates the animationMap texture Buffer
  73895. * @param buffer normally and array of numbers, or a false to generate from scratch
  73896. * @returns RawTexture of the animationMap
  73897. */
  73898. private _createTileAnimationBuffer;
  73899. /**
  73900. * Modifies the data of the animationMap
  73901. * @param cellID is the Index of the Sprite
  73902. * @param _frame is the target Animation frame
  73903. * @param toCell is the Target Index of the next frame of the animation
  73904. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  73905. * @param speed is a global scalar of the time variable on the map.
  73906. */
  73907. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  73908. /**
  73909. * Exports the .tilemaps file
  73910. */
  73911. saveTileMaps(): void;
  73912. /**
  73913. * Imports the .tilemaps file
  73914. * @param url of the .tilemaps file
  73915. */
  73916. loadTileMaps(url: string): void;
  73917. /**
  73918. * Release associated resources
  73919. */
  73920. dispose(): void;
  73921. }
  73922. }
  73923. declare module BABYLON {
  73924. /**
  73925. * Class used to manage multiple sprites of different sizes on the same spritesheet
  73926. * @see https://doc.babylonjs.com/babylon101/sprites
  73927. */
  73928. export class SpritePackedManager extends SpriteManager {
  73929. /** defines the packed manager's name */
  73930. name: string;
  73931. /**
  73932. * Creates a new sprite manager from a packed sprite sheet
  73933. * @param name defines the manager's name
  73934. * @param imgUrl defines the sprite sheet url
  73935. * @param capacity defines the maximum allowed number of sprites
  73936. * @param scene defines the hosting scene
  73937. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  73938. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  73939. * @param samplingMode defines the smapling mode to use with spritesheet
  73940. * @param fromPacked set to true; do not alter
  73941. */
  73942. constructor(
  73943. /** defines the packed manager's name */
  73944. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  73945. }
  73946. }
  73947. declare module BABYLON {
  73948. /**
  73949. * Defines the list of states available for a task inside a AssetsManager
  73950. */
  73951. export enum AssetTaskState {
  73952. /**
  73953. * Initialization
  73954. */
  73955. INIT = 0,
  73956. /**
  73957. * Running
  73958. */
  73959. RUNNING = 1,
  73960. /**
  73961. * Done
  73962. */
  73963. DONE = 2,
  73964. /**
  73965. * Error
  73966. */
  73967. ERROR = 3
  73968. }
  73969. /**
  73970. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  73971. */
  73972. export abstract class AbstractAssetTask {
  73973. /**
  73974. * Task name
  73975. */ name: string;
  73976. /**
  73977. * Callback called when the task is successful
  73978. */
  73979. onSuccess: (task: any) => void;
  73980. /**
  73981. * Callback called when the task is not successful
  73982. */
  73983. onError: (task: any, message?: string, exception?: any) => void;
  73984. /**
  73985. * Creates a new AssetsManager
  73986. * @param name defines the name of the task
  73987. */
  73988. constructor(
  73989. /**
  73990. * Task name
  73991. */ name: string);
  73992. private _isCompleted;
  73993. private _taskState;
  73994. private _errorObject;
  73995. /**
  73996. * Get if the task is completed
  73997. */
  73998. get isCompleted(): boolean;
  73999. /**
  74000. * Gets the current state of the task
  74001. */
  74002. get taskState(): AssetTaskState;
  74003. /**
  74004. * Gets the current error object (if task is in error)
  74005. */
  74006. get errorObject(): {
  74007. message?: string;
  74008. exception?: any;
  74009. };
  74010. /**
  74011. * Internal only
  74012. * @hidden
  74013. */
  74014. _setErrorObject(message?: string, exception?: any): void;
  74015. /**
  74016. * Execute the current task
  74017. * @param scene defines the scene where you want your assets to be loaded
  74018. * @param onSuccess is a callback called when the task is successfully executed
  74019. * @param onError is a callback called if an error occurs
  74020. */
  74021. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74022. /**
  74023. * Execute the current task
  74024. * @param scene defines the scene where you want your assets to be loaded
  74025. * @param onSuccess is a callback called when the task is successfully executed
  74026. * @param onError is a callback called if an error occurs
  74027. */
  74028. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74029. /**
  74030. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  74031. * This can be used with failed tasks that have the reason for failure fixed.
  74032. */
  74033. reset(): void;
  74034. private onErrorCallback;
  74035. private onDoneCallback;
  74036. }
  74037. /**
  74038. * Define the interface used by progress events raised during assets loading
  74039. */
  74040. export interface IAssetsProgressEvent {
  74041. /**
  74042. * Defines the number of remaining tasks to process
  74043. */
  74044. remainingCount: number;
  74045. /**
  74046. * Defines the total number of tasks
  74047. */
  74048. totalCount: number;
  74049. /**
  74050. * Defines the task that was just processed
  74051. */
  74052. task: AbstractAssetTask;
  74053. }
  74054. /**
  74055. * Class used to share progress information about assets loading
  74056. */
  74057. export class AssetsProgressEvent implements IAssetsProgressEvent {
  74058. /**
  74059. * Defines the number of remaining tasks to process
  74060. */
  74061. remainingCount: number;
  74062. /**
  74063. * Defines the total number of tasks
  74064. */
  74065. totalCount: number;
  74066. /**
  74067. * Defines the task that was just processed
  74068. */
  74069. task: AbstractAssetTask;
  74070. /**
  74071. * Creates a AssetsProgressEvent
  74072. * @param remainingCount defines the number of remaining tasks to process
  74073. * @param totalCount defines the total number of tasks
  74074. * @param task defines the task that was just processed
  74075. */
  74076. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  74077. }
  74078. /**
  74079. * Define a task used by AssetsManager to load assets into a container
  74080. */
  74081. export class ContainerAssetTask extends AbstractAssetTask {
  74082. /**
  74083. * Defines the name of the task
  74084. */
  74085. name: string;
  74086. /**
  74087. * Defines the list of mesh's names you want to load
  74088. */
  74089. meshesNames: any;
  74090. /**
  74091. * Defines the root url to use as a base to load your meshes and associated resources
  74092. */
  74093. rootUrl: string;
  74094. /**
  74095. * Defines the filename or File of the scene to load from
  74096. */
  74097. sceneFilename: string | File;
  74098. /**
  74099. * Get the loaded asset container
  74100. */
  74101. loadedContainer: AssetContainer;
  74102. /**
  74103. * Gets the list of loaded meshes
  74104. */
  74105. loadedMeshes: Array<AbstractMesh>;
  74106. /**
  74107. * Gets the list of loaded particle systems
  74108. */
  74109. loadedParticleSystems: Array<IParticleSystem>;
  74110. /**
  74111. * Gets the list of loaded skeletons
  74112. */
  74113. loadedSkeletons: Array<Skeleton>;
  74114. /**
  74115. * Gets the list of loaded animation groups
  74116. */
  74117. loadedAnimationGroups: Array<AnimationGroup>;
  74118. /**
  74119. * Callback called when the task is successful
  74120. */
  74121. onSuccess: (task: ContainerAssetTask) => void;
  74122. /**
  74123. * Callback called when the task is successful
  74124. */
  74125. onError: (task: ContainerAssetTask, message?: string, exception?: any) => void;
  74126. /**
  74127. * Creates a new ContainerAssetTask
  74128. * @param name defines the name of the task
  74129. * @param meshesNames defines the list of mesh's names you want to load
  74130. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  74131. * @param sceneFilename defines the filename or File of the scene to load from
  74132. */
  74133. constructor(
  74134. /**
  74135. * Defines the name of the task
  74136. */
  74137. name: string,
  74138. /**
  74139. * Defines the list of mesh's names you want to load
  74140. */
  74141. meshesNames: any,
  74142. /**
  74143. * Defines the root url to use as a base to load your meshes and associated resources
  74144. */
  74145. rootUrl: string,
  74146. /**
  74147. * Defines the filename or File of the scene to load from
  74148. */
  74149. sceneFilename: string | File);
  74150. /**
  74151. * Execute the current task
  74152. * @param scene defines the scene where you want your assets to be loaded
  74153. * @param onSuccess is a callback called when the task is successfully executed
  74154. * @param onError is a callback called if an error occurs
  74155. */
  74156. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74157. }
  74158. /**
  74159. * Define a task used by AssetsManager to load meshes
  74160. */
  74161. export class MeshAssetTask extends AbstractAssetTask {
  74162. /**
  74163. * Defines the name of the task
  74164. */
  74165. name: string;
  74166. /**
  74167. * Defines the list of mesh's names you want to load
  74168. */
  74169. meshesNames: any;
  74170. /**
  74171. * Defines the root url to use as a base to load your meshes and associated resources
  74172. */
  74173. rootUrl: string;
  74174. /**
  74175. * Defines the filename or File of the scene to load from
  74176. */
  74177. sceneFilename: string | File;
  74178. /**
  74179. * Gets the list of loaded meshes
  74180. */
  74181. loadedMeshes: Array<AbstractMesh>;
  74182. /**
  74183. * Gets the list of loaded particle systems
  74184. */
  74185. loadedParticleSystems: Array<IParticleSystem>;
  74186. /**
  74187. * Gets the list of loaded skeletons
  74188. */
  74189. loadedSkeletons: Array<Skeleton>;
  74190. /**
  74191. * Gets the list of loaded animation groups
  74192. */
  74193. loadedAnimationGroups: Array<AnimationGroup>;
  74194. /**
  74195. * Callback called when the task is successful
  74196. */
  74197. onSuccess: (task: MeshAssetTask) => void;
  74198. /**
  74199. * Callback called when the task is successful
  74200. */
  74201. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  74202. /**
  74203. * Creates a new MeshAssetTask
  74204. * @param name defines the name of the task
  74205. * @param meshesNames defines the list of mesh's names you want to load
  74206. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  74207. * @param sceneFilename defines the filename or File of the scene to load from
  74208. */
  74209. constructor(
  74210. /**
  74211. * Defines the name of the task
  74212. */
  74213. name: string,
  74214. /**
  74215. * Defines the list of mesh's names you want to load
  74216. */
  74217. meshesNames: any,
  74218. /**
  74219. * Defines the root url to use as a base to load your meshes and associated resources
  74220. */
  74221. rootUrl: string,
  74222. /**
  74223. * Defines the filename or File of the scene to load from
  74224. */
  74225. sceneFilename: string | File);
  74226. /**
  74227. * Execute the current task
  74228. * @param scene defines the scene where you want your assets to be loaded
  74229. * @param onSuccess is a callback called when the task is successfully executed
  74230. * @param onError is a callback called if an error occurs
  74231. */
  74232. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74233. }
  74234. /**
  74235. * Define a task used by AssetsManager to load text content
  74236. */
  74237. export class TextFileAssetTask extends AbstractAssetTask {
  74238. /**
  74239. * Defines the name of the task
  74240. */
  74241. name: string;
  74242. /**
  74243. * Defines the location of the file to load
  74244. */
  74245. url: string;
  74246. /**
  74247. * Gets the loaded text string
  74248. */
  74249. text: string;
  74250. /**
  74251. * Callback called when the task is successful
  74252. */
  74253. onSuccess: (task: TextFileAssetTask) => void;
  74254. /**
  74255. * Callback called when the task is successful
  74256. */
  74257. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  74258. /**
  74259. * Creates a new TextFileAssetTask object
  74260. * @param name defines the name of the task
  74261. * @param url defines the location of the file to load
  74262. */
  74263. constructor(
  74264. /**
  74265. * Defines the name of the task
  74266. */
  74267. name: string,
  74268. /**
  74269. * Defines the location of the file to load
  74270. */
  74271. url: string);
  74272. /**
  74273. * Execute the current task
  74274. * @param scene defines the scene where you want your assets to be loaded
  74275. * @param onSuccess is a callback called when the task is successfully executed
  74276. * @param onError is a callback called if an error occurs
  74277. */
  74278. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74279. }
  74280. /**
  74281. * Define a task used by AssetsManager to load binary data
  74282. */
  74283. export class BinaryFileAssetTask extends AbstractAssetTask {
  74284. /**
  74285. * Defines the name of the task
  74286. */
  74287. name: string;
  74288. /**
  74289. * Defines the location of the file to load
  74290. */
  74291. url: string;
  74292. /**
  74293. * Gets the lodaded data (as an array buffer)
  74294. */
  74295. data: ArrayBuffer;
  74296. /**
  74297. * Callback called when the task is successful
  74298. */
  74299. onSuccess: (task: BinaryFileAssetTask) => void;
  74300. /**
  74301. * Callback called when the task is successful
  74302. */
  74303. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  74304. /**
  74305. * Creates a new BinaryFileAssetTask object
  74306. * @param name defines the name of the new task
  74307. * @param url defines the location of the file to load
  74308. */
  74309. constructor(
  74310. /**
  74311. * Defines the name of the task
  74312. */
  74313. name: string,
  74314. /**
  74315. * Defines the location of the file to load
  74316. */
  74317. url: string);
  74318. /**
  74319. * Execute the current task
  74320. * @param scene defines the scene where you want your assets to be loaded
  74321. * @param onSuccess is a callback called when the task is successfully executed
  74322. * @param onError is a callback called if an error occurs
  74323. */
  74324. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74325. }
  74326. /**
  74327. * Define a task used by AssetsManager to load images
  74328. */
  74329. export class ImageAssetTask extends AbstractAssetTask {
  74330. /**
  74331. * Defines the name of the task
  74332. */
  74333. name: string;
  74334. /**
  74335. * Defines the location of the image to load
  74336. */
  74337. url: string;
  74338. /**
  74339. * Gets the loaded images
  74340. */
  74341. image: HTMLImageElement;
  74342. /**
  74343. * Callback called when the task is successful
  74344. */
  74345. onSuccess: (task: ImageAssetTask) => void;
  74346. /**
  74347. * Callback called when the task is successful
  74348. */
  74349. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  74350. /**
  74351. * Creates a new ImageAssetTask
  74352. * @param name defines the name of the task
  74353. * @param url defines the location of the image to load
  74354. */
  74355. constructor(
  74356. /**
  74357. * Defines the name of the task
  74358. */
  74359. name: string,
  74360. /**
  74361. * Defines the location of the image to load
  74362. */
  74363. url: string);
  74364. /**
  74365. * Execute the current task
  74366. * @param scene defines the scene where you want your assets to be loaded
  74367. * @param onSuccess is a callback called when the task is successfully executed
  74368. * @param onError is a callback called if an error occurs
  74369. */
  74370. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74371. }
  74372. /**
  74373. * Defines the interface used by texture loading tasks
  74374. */
  74375. export interface ITextureAssetTask<TEX extends BaseTexture> {
  74376. /**
  74377. * Gets the loaded texture
  74378. */
  74379. texture: TEX;
  74380. }
  74381. /**
  74382. * Define a task used by AssetsManager to load 2D textures
  74383. */
  74384. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  74385. /**
  74386. * Defines the name of the task
  74387. */
  74388. name: string;
  74389. /**
  74390. * Defines the location of the file to load
  74391. */
  74392. url: string;
  74393. /**
  74394. * Defines if mipmap should not be generated (default is false)
  74395. */
  74396. noMipmap?: boolean | undefined;
  74397. /**
  74398. * Defines if texture must be inverted on Y axis (default is true)
  74399. */
  74400. invertY: boolean;
  74401. /**
  74402. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  74403. */
  74404. samplingMode: number;
  74405. /**
  74406. * Gets the loaded texture
  74407. */
  74408. texture: Texture;
  74409. /**
  74410. * Callback called when the task is successful
  74411. */
  74412. onSuccess: (task: TextureAssetTask) => void;
  74413. /**
  74414. * Callback called when the task is successful
  74415. */
  74416. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  74417. /**
  74418. * Creates a new TextureAssetTask object
  74419. * @param name defines the name of the task
  74420. * @param url defines the location of the file to load
  74421. * @param noMipmap defines if mipmap should not be generated (default is false)
  74422. * @param invertY defines if texture must be inverted on Y axis (default is true)
  74423. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  74424. */
  74425. constructor(
  74426. /**
  74427. * Defines the name of the task
  74428. */
  74429. name: string,
  74430. /**
  74431. * Defines the location of the file to load
  74432. */
  74433. url: string,
  74434. /**
  74435. * Defines if mipmap should not be generated (default is false)
  74436. */
  74437. noMipmap?: boolean | undefined,
  74438. /**
  74439. * Defines if texture must be inverted on Y axis (default is true)
  74440. */
  74441. invertY?: boolean,
  74442. /**
  74443. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  74444. */
  74445. samplingMode?: number);
  74446. /**
  74447. * Execute the current task
  74448. * @param scene defines the scene where you want your assets to be loaded
  74449. * @param onSuccess is a callback called when the task is successfully executed
  74450. * @param onError is a callback called if an error occurs
  74451. */
  74452. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74453. }
  74454. /**
  74455. * Define a task used by AssetsManager to load cube textures
  74456. */
  74457. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  74458. /**
  74459. * Defines the name of the task
  74460. */
  74461. name: string;
  74462. /**
  74463. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  74464. */
  74465. url: string;
  74466. /**
  74467. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  74468. */
  74469. extensions?: string[] | undefined;
  74470. /**
  74471. * Defines if mipmaps should not be generated (default is false)
  74472. */
  74473. noMipmap?: boolean | undefined;
  74474. /**
  74475. * Defines the explicit list of files (undefined by default)
  74476. */
  74477. files?: string[] | undefined;
  74478. /**
  74479. * Gets the loaded texture
  74480. */
  74481. texture: CubeTexture;
  74482. /**
  74483. * Callback called when the task is successful
  74484. */
  74485. onSuccess: (task: CubeTextureAssetTask) => void;
  74486. /**
  74487. * Callback called when the task is successful
  74488. */
  74489. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  74490. /**
  74491. * Creates a new CubeTextureAssetTask
  74492. * @param name defines the name of the task
  74493. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  74494. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  74495. * @param noMipmap defines if mipmaps should not be generated (default is false)
  74496. * @param files defines the explicit list of files (undefined by default)
  74497. */
  74498. constructor(
  74499. /**
  74500. * Defines the name of the task
  74501. */
  74502. name: string,
  74503. /**
  74504. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  74505. */
  74506. url: string,
  74507. /**
  74508. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  74509. */
  74510. extensions?: string[] | undefined,
  74511. /**
  74512. * Defines if mipmaps should not be generated (default is false)
  74513. */
  74514. noMipmap?: boolean | undefined,
  74515. /**
  74516. * Defines the explicit list of files (undefined by default)
  74517. */
  74518. files?: string[] | undefined);
  74519. /**
  74520. * Execute the current task
  74521. * @param scene defines the scene where you want your assets to be loaded
  74522. * @param onSuccess is a callback called when the task is successfully executed
  74523. * @param onError is a callback called if an error occurs
  74524. */
  74525. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74526. }
  74527. /**
  74528. * Define a task used by AssetsManager to load HDR cube textures
  74529. */
  74530. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  74531. /**
  74532. * Defines the name of the task
  74533. */
  74534. name: string;
  74535. /**
  74536. * Defines the location of the file to load
  74537. */
  74538. url: string;
  74539. /**
  74540. * Defines the desired size (the more it increases the longer the generation will be)
  74541. */
  74542. size: number;
  74543. /**
  74544. * Defines if mipmaps should not be generated (default is false)
  74545. */
  74546. noMipmap: boolean;
  74547. /**
  74548. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  74549. */
  74550. generateHarmonics: boolean;
  74551. /**
  74552. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space) (default is false)
  74553. */
  74554. gammaSpace: boolean;
  74555. /**
  74556. * Internal Use Only
  74557. */
  74558. reserved: boolean;
  74559. /**
  74560. * Gets the loaded texture
  74561. */
  74562. texture: HDRCubeTexture;
  74563. /**
  74564. * Callback called when the task is successful
  74565. */
  74566. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  74567. /**
  74568. * Callback called when the task is successful
  74569. */
  74570. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  74571. /**
  74572. * Creates a new HDRCubeTextureAssetTask object
  74573. * @param name defines the name of the task
  74574. * @param url defines the location of the file to load
  74575. * @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.
  74576. * @param noMipmap defines if mipmaps should not be generated (default is false)
  74577. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  74578. * @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)
  74579. * @param reserved Internal use only
  74580. */
  74581. constructor(
  74582. /**
  74583. * Defines the name of the task
  74584. */
  74585. name: string,
  74586. /**
  74587. * Defines the location of the file to load
  74588. */
  74589. url: string,
  74590. /**
  74591. * Defines the desired size (the more it increases the longer the generation will be)
  74592. */
  74593. size: number,
  74594. /**
  74595. * Defines if mipmaps should not be generated (default is false)
  74596. */
  74597. noMipmap?: boolean,
  74598. /**
  74599. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  74600. */
  74601. generateHarmonics?: boolean,
  74602. /**
  74603. * 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)
  74604. */
  74605. gammaSpace?: boolean,
  74606. /**
  74607. * Internal Use Only
  74608. */
  74609. reserved?: boolean);
  74610. /**
  74611. * Execute the current task
  74612. * @param scene defines the scene where you want your assets to be loaded
  74613. * @param onSuccess is a callback called when the task is successfully executed
  74614. * @param onError is a callback called if an error occurs
  74615. */
  74616. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74617. }
  74618. /**
  74619. * Define a task used by AssetsManager to load Equirectangular cube textures
  74620. */
  74621. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  74622. /**
  74623. * Defines the name of the task
  74624. */
  74625. name: string;
  74626. /**
  74627. * Defines the location of the file to load
  74628. */
  74629. url: string;
  74630. /**
  74631. * Defines the desired size (the more it increases the longer the generation will be)
  74632. */
  74633. size: number;
  74634. /**
  74635. * Defines if mipmaps should not be generated (default is false)
  74636. */
  74637. noMipmap: boolean;
  74638. /**
  74639. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  74640. * but the standard material would require them in Gamma space) (default is true)
  74641. */
  74642. gammaSpace: boolean;
  74643. /**
  74644. * Gets the loaded texture
  74645. */
  74646. texture: EquiRectangularCubeTexture;
  74647. /**
  74648. * Callback called when the task is successful
  74649. */
  74650. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  74651. /**
  74652. * Callback called when the task is successful
  74653. */
  74654. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  74655. /**
  74656. * Creates a new EquiRectangularCubeTextureAssetTask object
  74657. * @param name defines the name of the task
  74658. * @param url defines the location of the file to load
  74659. * @param size defines the desired size (the more it increases the longer the generation will be)
  74660. * If the size is omitted this implies you are using a preprocessed cubemap.
  74661. * @param noMipmap defines if mipmaps should not be generated (default is false)
  74662. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  74663. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  74664. * (default is true)
  74665. */
  74666. constructor(
  74667. /**
  74668. * Defines the name of the task
  74669. */
  74670. name: string,
  74671. /**
  74672. * Defines the location of the file to load
  74673. */
  74674. url: string,
  74675. /**
  74676. * Defines the desired size (the more it increases the longer the generation will be)
  74677. */
  74678. size: number,
  74679. /**
  74680. * Defines if mipmaps should not be generated (default is false)
  74681. */
  74682. noMipmap?: boolean,
  74683. /**
  74684. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  74685. * but the standard material would require them in Gamma space) (default is true)
  74686. */
  74687. gammaSpace?: boolean);
  74688. /**
  74689. * Execute the current task
  74690. * @param scene defines the scene where you want your assets to be loaded
  74691. * @param onSuccess is a callback called when the task is successfully executed
  74692. * @param onError is a callback called if an error occurs
  74693. */
  74694. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74695. }
  74696. /**
  74697. * This class can be used to easily import assets into a scene
  74698. * @see https://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  74699. */
  74700. export class AssetsManager {
  74701. private _scene;
  74702. private _isLoading;
  74703. protected _tasks: AbstractAssetTask[];
  74704. protected _waitingTasksCount: number;
  74705. protected _totalTasksCount: number;
  74706. /**
  74707. * Callback called when all tasks are processed
  74708. */
  74709. onFinish: (tasks: AbstractAssetTask[]) => void;
  74710. /**
  74711. * Callback called when a task is successful
  74712. */
  74713. onTaskSuccess: (task: AbstractAssetTask) => void;
  74714. /**
  74715. * Callback called when a task had an error
  74716. */
  74717. onTaskError: (task: AbstractAssetTask) => void;
  74718. /**
  74719. * Callback called when a task is done (whatever the result is)
  74720. */
  74721. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  74722. /**
  74723. * Observable called when all tasks are processed
  74724. */
  74725. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  74726. /**
  74727. * Observable called when a task had an error
  74728. */
  74729. onTaskErrorObservable: Observable<AbstractAssetTask>;
  74730. /**
  74731. * Observable called when all tasks were executed
  74732. */
  74733. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  74734. /**
  74735. * Observable called when a task is done (whatever the result is)
  74736. */
  74737. onProgressObservable: Observable<IAssetsProgressEvent>;
  74738. /**
  74739. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  74740. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  74741. */
  74742. useDefaultLoadingScreen: boolean;
  74743. /**
  74744. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  74745. * when all assets have been downloaded.
  74746. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  74747. */
  74748. autoHideLoadingUI: boolean;
  74749. /**
  74750. * Creates a new AssetsManager
  74751. * @param scene defines the scene to work on
  74752. */
  74753. constructor(scene: Scene);
  74754. /**
  74755. * Add a ContainerAssetTask to the list of active tasks
  74756. * @param taskName defines the name of the new task
  74757. * @param meshesNames defines the name of meshes to load
  74758. * @param rootUrl defines the root url to use to locate files
  74759. * @param sceneFilename defines the filename of the scene file
  74760. * @returns a new ContainerAssetTask object
  74761. */
  74762. addContainerTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): ContainerAssetTask;
  74763. /**
  74764. * Add a MeshAssetTask to the list of active tasks
  74765. * @param taskName defines the name of the new task
  74766. * @param meshesNames defines the name of meshes to load
  74767. * @param rootUrl defines the root url to use to locate files
  74768. * @param sceneFilename defines the filename of the scene file
  74769. * @returns a new MeshAssetTask object
  74770. */
  74771. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  74772. /**
  74773. * Add a TextFileAssetTask to the list of active tasks
  74774. * @param taskName defines the name of the new task
  74775. * @param url defines the url of the file to load
  74776. * @returns a new TextFileAssetTask object
  74777. */
  74778. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  74779. /**
  74780. * Add a BinaryFileAssetTask to the list of active tasks
  74781. * @param taskName defines the name of the new task
  74782. * @param url defines the url of the file to load
  74783. * @returns a new BinaryFileAssetTask object
  74784. */
  74785. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  74786. /**
  74787. * Add a ImageAssetTask to the list of active tasks
  74788. * @param taskName defines the name of the new task
  74789. * @param url defines the url of the file to load
  74790. * @returns a new ImageAssetTask object
  74791. */
  74792. addImageTask(taskName: string, url: string): ImageAssetTask;
  74793. /**
  74794. * Add a TextureAssetTask to the list of active tasks
  74795. * @param taskName defines the name of the new task
  74796. * @param url defines the url of the file to load
  74797. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  74798. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  74799. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  74800. * @returns a new TextureAssetTask object
  74801. */
  74802. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  74803. /**
  74804. * Add a CubeTextureAssetTask to the list of active tasks
  74805. * @param taskName defines the name of the new task
  74806. * @param url defines the url of the file to load
  74807. * @param extensions defines the extension to use to load the cube map (can be null)
  74808. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  74809. * @param files defines the list of files to load (can be null)
  74810. * @returns a new CubeTextureAssetTask object
  74811. */
  74812. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  74813. /**
  74814. *
  74815. * Add a HDRCubeTextureAssetTask to the list of active tasks
  74816. * @param taskName defines the name of the new task
  74817. * @param url defines the url of the file to load
  74818. * @param size defines the size you want for the cubemap (can be null)
  74819. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  74820. * @param generateHarmonics defines if you want to automatically generate (true by default)
  74821. * @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)
  74822. * @param reserved Internal use only
  74823. * @returns a new HDRCubeTextureAssetTask object
  74824. */
  74825. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  74826. /**
  74827. *
  74828. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  74829. * @param taskName defines the name of the new task
  74830. * @param url defines the url of the file to load
  74831. * @param size defines the size you want for the cubemap (can be null)
  74832. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  74833. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  74834. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  74835. * @returns a new EquiRectangularCubeTextureAssetTask object
  74836. */
  74837. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  74838. /**
  74839. * Remove a task from the assets manager.
  74840. * @param task the task to remove
  74841. */
  74842. removeTask(task: AbstractAssetTask): void;
  74843. private _decreaseWaitingTasksCount;
  74844. private _runTask;
  74845. /**
  74846. * Reset the AssetsManager and remove all tasks
  74847. * @return the current instance of the AssetsManager
  74848. */
  74849. reset(): AssetsManager;
  74850. /**
  74851. * Start the loading process
  74852. * @return the current instance of the AssetsManager
  74853. */
  74854. load(): AssetsManager;
  74855. /**
  74856. * Start the loading process as an async operation
  74857. * @return a promise returning the list of failed tasks
  74858. */
  74859. loadAsync(): Promise<void>;
  74860. }
  74861. }
  74862. declare module BABYLON {
  74863. /**
  74864. * Wrapper class for promise with external resolve and reject.
  74865. */
  74866. export class Deferred<T> {
  74867. /**
  74868. * The promise associated with this deferred object.
  74869. */
  74870. readonly promise: Promise<T>;
  74871. private _resolve;
  74872. private _reject;
  74873. /**
  74874. * The resolve method of the promise associated with this deferred object.
  74875. */
  74876. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  74877. /**
  74878. * The reject method of the promise associated with this deferred object.
  74879. */
  74880. get reject(): (reason?: any) => void;
  74881. /**
  74882. * Constructor for this deferred object.
  74883. */
  74884. constructor();
  74885. }
  74886. }
  74887. declare module BABYLON {
  74888. /**
  74889. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  74890. */
  74891. export class MeshExploder {
  74892. private _centerMesh;
  74893. private _meshes;
  74894. private _meshesOrigins;
  74895. private _toCenterVectors;
  74896. private _scaledDirection;
  74897. private _newPosition;
  74898. private _centerPosition;
  74899. /**
  74900. * Explodes meshes from a center mesh.
  74901. * @param meshes The meshes to explode.
  74902. * @param centerMesh The mesh to be center of explosion.
  74903. */
  74904. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  74905. private _setCenterMesh;
  74906. /**
  74907. * Get class name
  74908. * @returns "MeshExploder"
  74909. */
  74910. getClassName(): string;
  74911. /**
  74912. * "Exploded meshes"
  74913. * @returns Array of meshes with the centerMesh at index 0.
  74914. */
  74915. getMeshes(): Array<Mesh>;
  74916. /**
  74917. * Explodes meshes giving a specific direction
  74918. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  74919. */
  74920. explode(direction?: number): void;
  74921. }
  74922. }
  74923. declare module BABYLON {
  74924. /**
  74925. * Class used to help managing file picking and drag'n'drop
  74926. */
  74927. export class FilesInput {
  74928. /**
  74929. * List of files ready to be loaded
  74930. */
  74931. static get FilesToLoad(): {
  74932. [key: string]: File;
  74933. };
  74934. /**
  74935. * Callback called when a file is processed
  74936. */
  74937. onProcessFileCallback: (file: File, name: string, extension: string) => boolean;
  74938. private _engine;
  74939. private _currentScene;
  74940. private _sceneLoadedCallback;
  74941. private _progressCallback;
  74942. private _additionalRenderLoopLogicCallback;
  74943. private _textureLoadingCallback;
  74944. private _startingProcessingFilesCallback;
  74945. private _onReloadCallback;
  74946. private _errorCallback;
  74947. private _elementToMonitor;
  74948. private _sceneFileToLoad;
  74949. private _filesToLoad;
  74950. /**
  74951. * Creates a new FilesInput
  74952. * @param engine defines the rendering engine
  74953. * @param scene defines the hosting scene
  74954. * @param sceneLoadedCallback callback called when scene is loaded
  74955. * @param progressCallback callback called to track progress
  74956. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  74957. * @param textureLoadingCallback callback called when a texture is loading
  74958. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  74959. * @param onReloadCallback callback called when a reload is requested
  74960. * @param errorCallback callback call if an error occurs
  74961. */
  74962. 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>);
  74963. private _dragEnterHandler;
  74964. private _dragOverHandler;
  74965. private _dropHandler;
  74966. /**
  74967. * Calls this function to listen to drag'n'drop events on a specific DOM element
  74968. * @param elementToMonitor defines the DOM element to track
  74969. */
  74970. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  74971. /** Gets the current list of files to load */
  74972. get filesToLoad(): File[];
  74973. /**
  74974. * Release all associated resources
  74975. */
  74976. dispose(): void;
  74977. private renderFunction;
  74978. private drag;
  74979. private drop;
  74980. private _traverseFolder;
  74981. private _processFiles;
  74982. /**
  74983. * Load files from a drop event
  74984. * @param event defines the drop event to use as source
  74985. */
  74986. loadFiles(event: any): void;
  74987. private _processReload;
  74988. /**
  74989. * Reload the current scene from the loaded files
  74990. */
  74991. reload(): void;
  74992. }
  74993. }
  74994. declare module BABYLON {
  74995. /**
  74996. * Defines the root class used to create scene optimization to use with SceneOptimizer
  74997. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74998. */
  74999. export class SceneOptimization {
  75000. /**
  75001. * Defines the priority of this optimization (0 by default which means first in the list)
  75002. */
  75003. priority: number;
  75004. /**
  75005. * Gets a string describing the action executed by the current optimization
  75006. * @returns description string
  75007. */
  75008. getDescription(): string;
  75009. /**
  75010. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  75011. * @param scene defines the current scene where to apply this optimization
  75012. * @param optimizer defines the current optimizer
  75013. * @returns true if everything that can be done was applied
  75014. */
  75015. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  75016. /**
  75017. * Creates the SceneOptimization object
  75018. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  75019. * @param desc defines the description associated with the optimization
  75020. */
  75021. constructor(
  75022. /**
  75023. * Defines the priority of this optimization (0 by default which means first in the list)
  75024. */
  75025. priority?: number);
  75026. }
  75027. /**
  75028. * Defines an optimization used to reduce the size of render target textures
  75029. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75030. */
  75031. export class TextureOptimization extends SceneOptimization {
  75032. /**
  75033. * Defines the priority of this optimization (0 by default which means first in the list)
  75034. */
  75035. priority: number;
  75036. /**
  75037. * 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
  75038. */
  75039. maximumSize: number;
  75040. /**
  75041. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  75042. */
  75043. step: number;
  75044. /**
  75045. * Gets a string describing the action executed by the current optimization
  75046. * @returns description string
  75047. */
  75048. getDescription(): string;
  75049. /**
  75050. * Creates the TextureOptimization object
  75051. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  75052. * @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
  75053. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  75054. */
  75055. constructor(
  75056. /**
  75057. * Defines the priority of this optimization (0 by default which means first in the list)
  75058. */
  75059. priority?: number,
  75060. /**
  75061. * 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
  75062. */
  75063. maximumSize?: number,
  75064. /**
  75065. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  75066. */
  75067. step?: number);
  75068. /**
  75069. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  75070. * @param scene defines the current scene where to apply this optimization
  75071. * @param optimizer defines the current optimizer
  75072. * @returns true if everything that can be done was applied
  75073. */
  75074. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  75075. }
  75076. /**
  75077. * Defines an optimization used to increase or decrease the rendering resolution
  75078. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75079. */
  75080. export class HardwareScalingOptimization extends SceneOptimization {
  75081. /**
  75082. * Defines the priority of this optimization (0 by default which means first in the list)
  75083. */
  75084. priority: number;
  75085. /**
  75086. * Defines the maximum scale to use (2 by default)
  75087. */
  75088. maximumScale: number;
  75089. /**
  75090. * Defines the step to use between two passes (0.5 by default)
  75091. */
  75092. step: number;
  75093. private _currentScale;
  75094. private _directionOffset;
  75095. /**
  75096. * Gets a string describing the action executed by the current optimization
  75097. * @return description string
  75098. */
  75099. getDescription(): string;
  75100. /**
  75101. * Creates the HardwareScalingOptimization object
  75102. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  75103. * @param maximumScale defines the maximum scale to use (2 by default)
  75104. * @param step defines the step to use between two passes (0.5 by default)
  75105. */
  75106. constructor(
  75107. /**
  75108. * Defines the priority of this optimization (0 by default which means first in the list)
  75109. */
  75110. priority?: number,
  75111. /**
  75112. * Defines the maximum scale to use (2 by default)
  75113. */
  75114. maximumScale?: number,
  75115. /**
  75116. * Defines the step to use between two passes (0.5 by default)
  75117. */
  75118. step?: number);
  75119. /**
  75120. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  75121. * @param scene defines the current scene where to apply this optimization
  75122. * @param optimizer defines the current optimizer
  75123. * @returns true if everything that can be done was applied
  75124. */
  75125. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  75126. }
  75127. /**
  75128. * Defines an optimization used to remove shadows
  75129. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75130. */
  75131. export class ShadowsOptimization extends SceneOptimization {
  75132. /**
  75133. * Gets a string describing the action executed by the current optimization
  75134. * @return description string
  75135. */
  75136. getDescription(): string;
  75137. /**
  75138. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  75139. * @param scene defines the current scene where to apply this optimization
  75140. * @param optimizer defines the current optimizer
  75141. * @returns true if everything that can be done was applied
  75142. */
  75143. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  75144. }
  75145. /**
  75146. * Defines an optimization used to turn post-processes off
  75147. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75148. */
  75149. export class PostProcessesOptimization extends SceneOptimization {
  75150. /**
  75151. * Gets a string describing the action executed by the current optimization
  75152. * @return description string
  75153. */
  75154. getDescription(): string;
  75155. /**
  75156. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  75157. * @param scene defines the current scene where to apply this optimization
  75158. * @param optimizer defines the current optimizer
  75159. * @returns true if everything that can be done was applied
  75160. */
  75161. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  75162. }
  75163. /**
  75164. * Defines an optimization used to turn lens flares off
  75165. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75166. */
  75167. export class LensFlaresOptimization extends SceneOptimization {
  75168. /**
  75169. * Gets a string describing the action executed by the current optimization
  75170. * @return description string
  75171. */
  75172. getDescription(): string;
  75173. /**
  75174. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  75175. * @param scene defines the current scene where to apply this optimization
  75176. * @param optimizer defines the current optimizer
  75177. * @returns true if everything that can be done was applied
  75178. */
  75179. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  75180. }
  75181. /**
  75182. * Defines an optimization based on user defined callback.
  75183. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75184. */
  75185. export class CustomOptimization extends SceneOptimization {
  75186. /**
  75187. * Callback called to apply the custom optimization.
  75188. */
  75189. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  75190. /**
  75191. * Callback called to get custom description
  75192. */
  75193. onGetDescription: () => string;
  75194. /**
  75195. * Gets a string describing the action executed by the current optimization
  75196. * @returns description string
  75197. */
  75198. getDescription(): string;
  75199. /**
  75200. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  75201. * @param scene defines the current scene where to apply this optimization
  75202. * @param optimizer defines the current optimizer
  75203. * @returns true if everything that can be done was applied
  75204. */
  75205. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  75206. }
  75207. /**
  75208. * Defines an optimization used to turn particles off
  75209. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75210. */
  75211. export class ParticlesOptimization extends SceneOptimization {
  75212. /**
  75213. * Gets a string describing the action executed by the current optimization
  75214. * @return description string
  75215. */
  75216. getDescription(): string;
  75217. /**
  75218. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  75219. * @param scene defines the current scene where to apply this optimization
  75220. * @param optimizer defines the current optimizer
  75221. * @returns true if everything that can be done was applied
  75222. */
  75223. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  75224. }
  75225. /**
  75226. * Defines an optimization used to turn render targets off
  75227. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75228. */
  75229. export class RenderTargetsOptimization extends SceneOptimization {
  75230. /**
  75231. * Gets a string describing the action executed by the current optimization
  75232. * @return description string
  75233. */
  75234. getDescription(): string;
  75235. /**
  75236. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  75237. * @param scene defines the current scene where to apply this optimization
  75238. * @param optimizer defines the current optimizer
  75239. * @returns true if everything that can be done was applied
  75240. */
  75241. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  75242. }
  75243. /**
  75244. * Defines an optimization used to merge meshes with compatible materials
  75245. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75246. */
  75247. export class MergeMeshesOptimization extends SceneOptimization {
  75248. private static _UpdateSelectionTree;
  75249. /**
  75250. * Gets or sets a boolean which defines if optimization octree has to be updated
  75251. */
  75252. static get UpdateSelectionTree(): boolean;
  75253. /**
  75254. * Gets or sets a boolean which defines if optimization octree has to be updated
  75255. */
  75256. static set UpdateSelectionTree(value: boolean);
  75257. /**
  75258. * Gets a string describing the action executed by the current optimization
  75259. * @return description string
  75260. */
  75261. getDescription(): string;
  75262. private _canBeMerged;
  75263. /**
  75264. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  75265. * @param scene defines the current scene where to apply this optimization
  75266. * @param optimizer defines the current optimizer
  75267. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  75268. * @returns true if everything that can be done was applied
  75269. */
  75270. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  75271. }
  75272. /**
  75273. * Defines a list of options used by SceneOptimizer
  75274. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75275. */
  75276. export class SceneOptimizerOptions {
  75277. /**
  75278. * Defines the target frame rate to reach (60 by default)
  75279. */
  75280. targetFrameRate: number;
  75281. /**
  75282. * Defines the interval between two checkes (2000ms by default)
  75283. */
  75284. trackerDuration: number;
  75285. /**
  75286. * Gets the list of optimizations to apply
  75287. */
  75288. optimizations: SceneOptimization[];
  75289. /**
  75290. * Creates a new list of options used by SceneOptimizer
  75291. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  75292. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  75293. */
  75294. constructor(
  75295. /**
  75296. * Defines the target frame rate to reach (60 by default)
  75297. */
  75298. targetFrameRate?: number,
  75299. /**
  75300. * Defines the interval between two checkes (2000ms by default)
  75301. */
  75302. trackerDuration?: number);
  75303. /**
  75304. * Add a new optimization
  75305. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  75306. * @returns the current SceneOptimizerOptions
  75307. */
  75308. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  75309. /**
  75310. * Add a new custom optimization
  75311. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  75312. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  75313. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  75314. * @returns the current SceneOptimizerOptions
  75315. */
  75316. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  75317. /**
  75318. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  75319. * @param targetFrameRate defines the target frame rate (60 by default)
  75320. * @returns a SceneOptimizerOptions object
  75321. */
  75322. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  75323. /**
  75324. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  75325. * @param targetFrameRate defines the target frame rate (60 by default)
  75326. * @returns a SceneOptimizerOptions object
  75327. */
  75328. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  75329. /**
  75330. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  75331. * @param targetFrameRate defines the target frame rate (60 by default)
  75332. * @returns a SceneOptimizerOptions object
  75333. */
  75334. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  75335. }
  75336. /**
  75337. * Class used to run optimizations in order to reach a target frame rate
  75338. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75339. */
  75340. export class SceneOptimizer implements IDisposable {
  75341. private _isRunning;
  75342. private _options;
  75343. private _scene;
  75344. private _currentPriorityLevel;
  75345. private _targetFrameRate;
  75346. private _trackerDuration;
  75347. private _currentFrameRate;
  75348. private _sceneDisposeObserver;
  75349. private _improvementMode;
  75350. /**
  75351. * Defines an observable called when the optimizer reaches the target frame rate
  75352. */
  75353. onSuccessObservable: Observable<SceneOptimizer>;
  75354. /**
  75355. * Defines an observable called when the optimizer enables an optimization
  75356. */
  75357. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  75358. /**
  75359. * Defines an observable called when the optimizer is not able to reach the target frame rate
  75360. */
  75361. onFailureObservable: Observable<SceneOptimizer>;
  75362. /**
  75363. * Gets a boolean indicating if the optimizer is in improvement mode
  75364. */
  75365. get isInImprovementMode(): boolean;
  75366. /**
  75367. * Gets the current priority level (0 at start)
  75368. */
  75369. get currentPriorityLevel(): number;
  75370. /**
  75371. * Gets the current frame rate checked by the SceneOptimizer
  75372. */
  75373. get currentFrameRate(): number;
  75374. /**
  75375. * Gets or sets the current target frame rate (60 by default)
  75376. */
  75377. get targetFrameRate(): number;
  75378. /**
  75379. * Gets or sets the current target frame rate (60 by default)
  75380. */
  75381. set targetFrameRate(value: number);
  75382. /**
  75383. * Gets or sets the current interval between two checks (every 2000ms by default)
  75384. */
  75385. get trackerDuration(): number;
  75386. /**
  75387. * Gets or sets the current interval between two checks (every 2000ms by default)
  75388. */
  75389. set trackerDuration(value: number);
  75390. /**
  75391. * Gets the list of active optimizations
  75392. */
  75393. get optimizations(): SceneOptimization[];
  75394. /**
  75395. * Creates a new SceneOptimizer
  75396. * @param scene defines the scene to work on
  75397. * @param options defines the options to use with the SceneOptimizer
  75398. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  75399. * @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)
  75400. */
  75401. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  75402. /**
  75403. * Stops the current optimizer
  75404. */
  75405. stop(): void;
  75406. /**
  75407. * Reset the optimizer to initial step (current priority level = 0)
  75408. */
  75409. reset(): void;
  75410. /**
  75411. * Start the optimizer. By default it will try to reach a specific framerate
  75412. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  75413. */
  75414. start(): void;
  75415. private _checkCurrentState;
  75416. /**
  75417. * Release all resources
  75418. */
  75419. dispose(): void;
  75420. /**
  75421. * Helper function to create a SceneOptimizer with one single line of code
  75422. * @param scene defines the scene to work on
  75423. * @param options defines the options to use with the SceneOptimizer
  75424. * @param onSuccess defines a callback to call on success
  75425. * @param onFailure defines a callback to call on failure
  75426. * @returns the new SceneOptimizer object
  75427. */
  75428. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  75429. }
  75430. }
  75431. declare module BABYLON {
  75432. /**
  75433. * Class used to serialize a scene into a string
  75434. */
  75435. export class SceneSerializer {
  75436. /**
  75437. * Clear cache used by a previous serialization
  75438. */
  75439. static ClearCache(): void;
  75440. /**
  75441. * Serialize a scene into a JSON compatible object
  75442. * @param scene defines the scene to serialize
  75443. * @returns a JSON compatible object
  75444. */
  75445. static Serialize(scene: Scene): any;
  75446. /**
  75447. * Serialize a mesh into a JSON compatible object
  75448. * @param toSerialize defines the mesh to serialize
  75449. * @param withParents defines if parents must be serialized as well
  75450. * @param withChildren defines if children must be serialized as well
  75451. * @returns a JSON compatible object
  75452. */
  75453. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  75454. }
  75455. }
  75456. declare module BABYLON {
  75457. /**
  75458. * Class used to host texture specific utilities
  75459. */
  75460. export class TextureTools {
  75461. /**
  75462. * Uses the GPU to create a copy texture rescaled at a given size
  75463. * @param texture Texture to copy from
  75464. * @param width defines the desired width
  75465. * @param height defines the desired height
  75466. * @param useBilinearMode defines if bilinear mode has to be used
  75467. * @return the generated texture
  75468. */
  75469. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  75470. }
  75471. }
  75472. declare module BABYLON {
  75473. /**
  75474. * This represents the different options available for the video capture.
  75475. */
  75476. export interface VideoRecorderOptions {
  75477. /** Defines the mime type of the video. */
  75478. mimeType: string;
  75479. /** Defines the FPS the video should be recorded at. */
  75480. fps: number;
  75481. /** Defines the chunk size for the recording data. */
  75482. recordChunckSize: number;
  75483. /** The audio tracks to attach to the recording. */
  75484. audioTracks?: MediaStreamTrack[];
  75485. }
  75486. /**
  75487. * This can help with recording videos from BabylonJS.
  75488. * This is based on the available WebRTC functionalities of the browser.
  75489. *
  75490. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_video
  75491. */
  75492. export class VideoRecorder {
  75493. private static readonly _defaultOptions;
  75494. /**
  75495. * Returns whether or not the VideoRecorder is available in your browser.
  75496. * @param engine Defines the Babylon Engine.
  75497. * @returns true if supported otherwise false.
  75498. */
  75499. static IsSupported(engine: Engine): boolean;
  75500. private readonly _options;
  75501. private _canvas;
  75502. private _mediaRecorder;
  75503. private _recordedChunks;
  75504. private _fileName;
  75505. private _resolve;
  75506. private _reject;
  75507. /**
  75508. * True when a recording is already in progress.
  75509. */
  75510. get isRecording(): boolean;
  75511. /**
  75512. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  75513. * @param engine Defines the BabylonJS Engine you wish to record.
  75514. * @param options Defines options that can be used to customize the capture.
  75515. */
  75516. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  75517. /**
  75518. * Stops the current recording before the default capture timeout passed in the startRecording function.
  75519. */
  75520. stopRecording(): void;
  75521. /**
  75522. * Starts recording the canvas for a max duration specified in parameters.
  75523. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  75524. * If null no automatic download will start and you can rely on the promise to get the data back.
  75525. * @param maxDuration Defines the maximum recording time in seconds.
  75526. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  75527. * @return A promise callback at the end of the recording with the video data in Blob.
  75528. */
  75529. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  75530. /**
  75531. * Releases internal resources used during the recording.
  75532. */
  75533. dispose(): void;
  75534. private _handleDataAvailable;
  75535. private _handleError;
  75536. private _handleStop;
  75537. }
  75538. }
  75539. declare module BABYLON {
  75540. /**
  75541. * Class containing a set of static utilities functions for screenshots
  75542. */
  75543. export class ScreenshotTools {
  75544. /**
  75545. * Captures a screenshot of the current rendering
  75546. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  75547. * @param engine defines the rendering engine
  75548. * @param camera defines the source camera
  75549. * @param size This parameter can be set to a single number or to an object with the
  75550. * following (optional) properties: precision, width, height. If a single number is passed,
  75551. * it will be used for both width and height. If an object is passed, the screenshot size
  75552. * will be derived from the parameters. The precision property is a multiplier allowing
  75553. * rendering at a higher or lower resolution
  75554. * @param successCallback defines the callback receives a single parameter which contains the
  75555. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  75556. * src parameter of an <img> to display it
  75557. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  75558. * Check your browser for supported MIME types
  75559. */
  75560. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  75561. /**
  75562. * Captures a screenshot of the current rendering
  75563. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  75564. * @param engine defines the rendering engine
  75565. * @param camera defines the source camera
  75566. * @param size This parameter can be set to a single number or to an object with the
  75567. * following (optional) properties: precision, width, height. If a single number is passed,
  75568. * it will be used for both width and height. If an object is passed, the screenshot size
  75569. * will be derived from the parameters. The precision property is a multiplier allowing
  75570. * rendering at a higher or lower resolution
  75571. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  75572. * Check your browser for supported MIME types
  75573. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  75574. * to the src parameter of an <img> to display it
  75575. */
  75576. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  75577. /**
  75578. * Generates an image screenshot from the specified camera.
  75579. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  75580. * @param engine The engine to use for rendering
  75581. * @param camera The camera to use for rendering
  75582. * @param size This parameter can be set to a single number or to an object with the
  75583. * following (optional) properties: precision, width, height. If a single number is passed,
  75584. * it will be used for both width and height. If an object is passed, the screenshot size
  75585. * will be derived from the parameters. The precision property is a multiplier allowing
  75586. * rendering at a higher or lower resolution
  75587. * @param successCallback The callback receives a single parameter which contains the
  75588. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  75589. * src parameter of an <img> to display it
  75590. * @param mimeType The MIME type of the screenshot image (default: image/png).
  75591. * Check your browser for supported MIME types
  75592. * @param samples Texture samples (default: 1)
  75593. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  75594. * @param fileName A name for for the downloaded file.
  75595. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  75596. * @param enableStencilBuffer Whether the stencil buffer should be enabled or not (default: false)
  75597. */
  75598. 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;
  75599. /**
  75600. * Generates an image screenshot from the specified camera.
  75601. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  75602. * @param engine The engine to use for rendering
  75603. * @param camera The camera to use for rendering
  75604. * @param size This parameter can be set to a single number or to an object with the
  75605. * following (optional) properties: precision, width, height. If a single number is passed,
  75606. * it will be used for both width and height. If an object is passed, the screenshot size
  75607. * will be derived from the parameters. The precision property is a multiplier allowing
  75608. * rendering at a higher or lower resolution
  75609. * @param mimeType The MIME type of the screenshot image (default: image/png).
  75610. * Check your browser for supported MIME types
  75611. * @param samples Texture samples (default: 1)
  75612. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  75613. * @param fileName A name for for the downloaded file.
  75614. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  75615. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  75616. * to the src parameter of an <img> to display it
  75617. */
  75618. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  75619. /**
  75620. * Gets height and width for screenshot size
  75621. * @private
  75622. */
  75623. private static _getScreenshotSize;
  75624. }
  75625. }
  75626. declare module BABYLON {
  75627. /**
  75628. * Interface for a data buffer
  75629. */
  75630. export interface IDataBuffer {
  75631. /**
  75632. * Reads bytes from the data buffer.
  75633. * @param byteOffset The byte offset to read
  75634. * @param byteLength The byte length to read
  75635. * @returns A promise that resolves when the bytes are read
  75636. */
  75637. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  75638. /**
  75639. * The byte length of the buffer.
  75640. */
  75641. readonly byteLength: number;
  75642. }
  75643. /**
  75644. * Utility class for reading from a data buffer
  75645. */
  75646. export class DataReader {
  75647. /**
  75648. * The data buffer associated with this data reader.
  75649. */
  75650. readonly buffer: IDataBuffer;
  75651. /**
  75652. * The current byte offset from the beginning of the data buffer.
  75653. */
  75654. byteOffset: number;
  75655. private _dataView;
  75656. private _dataByteOffset;
  75657. /**
  75658. * Constructor
  75659. * @param buffer The buffer to read
  75660. */
  75661. constructor(buffer: IDataBuffer);
  75662. /**
  75663. * Loads the given byte length.
  75664. * @param byteLength The byte length to load
  75665. * @returns A promise that resolves when the load is complete
  75666. */
  75667. loadAsync(byteLength: number): Promise<void>;
  75668. /**
  75669. * Read a unsigned 32-bit integer from the currently loaded data range.
  75670. * @returns The 32-bit integer read
  75671. */
  75672. readUint32(): number;
  75673. /**
  75674. * Read a byte array from the currently loaded data range.
  75675. * @param byteLength The byte length to read
  75676. * @returns The byte array read
  75677. */
  75678. readUint8Array(byteLength: number): Uint8Array;
  75679. /**
  75680. * Read a string from the currently loaded data range.
  75681. * @param byteLength The byte length to read
  75682. * @returns The string read
  75683. */
  75684. readString(byteLength: number): string;
  75685. /**
  75686. * Skips the given byte length the currently loaded data range.
  75687. * @param byteLength The byte length to skip
  75688. */
  75689. skipBytes(byteLength: number): void;
  75690. }
  75691. }
  75692. declare module BABYLON {
  75693. /**
  75694. * Class for storing data to local storage if available or in-memory storage otherwise
  75695. */
  75696. export class DataStorage {
  75697. private static _Storage;
  75698. private static _GetStorage;
  75699. /**
  75700. * Reads a string from the data storage
  75701. * @param key The key to read
  75702. * @param defaultValue The value if the key doesn't exist
  75703. * @returns The string value
  75704. */
  75705. static ReadString(key: string, defaultValue: string): string;
  75706. /**
  75707. * Writes a string to the data storage
  75708. * @param key The key to write
  75709. * @param value The value to write
  75710. */
  75711. static WriteString(key: string, value: string): void;
  75712. /**
  75713. * Reads a boolean from the data storage
  75714. * @param key The key to read
  75715. * @param defaultValue The value if the key doesn't exist
  75716. * @returns The boolean value
  75717. */
  75718. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  75719. /**
  75720. * Writes a boolean to the data storage
  75721. * @param key The key to write
  75722. * @param value The value to write
  75723. */
  75724. static WriteBoolean(key: string, value: boolean): void;
  75725. /**
  75726. * Reads a number from the data storage
  75727. * @param key The key to read
  75728. * @param defaultValue The value if the key doesn't exist
  75729. * @returns The number value
  75730. */
  75731. static ReadNumber(key: string, defaultValue: number): number;
  75732. /**
  75733. * Writes a number to the data storage
  75734. * @param key The key to write
  75735. * @param value The value to write
  75736. */
  75737. static WriteNumber(key: string, value: number): void;
  75738. }
  75739. }
  75740. declare module BABYLON {
  75741. /**
  75742. * Class used to record delta files between 2 scene states
  75743. */
  75744. export class SceneRecorder {
  75745. private _trackedScene;
  75746. private _savedJSON;
  75747. /**
  75748. * Track a given scene. This means the current scene state will be considered the original state
  75749. * @param scene defines the scene to track
  75750. */
  75751. track(scene: Scene): void;
  75752. /**
  75753. * Get the delta between current state and original state
  75754. * @returns a string containing the delta
  75755. */
  75756. getDelta(): any;
  75757. private _compareArray;
  75758. private _compareObjects;
  75759. private _compareCollections;
  75760. private static GetShadowGeneratorById;
  75761. /**
  75762. * Apply a given delta to a given scene
  75763. * @param deltaJSON defines the JSON containing the delta
  75764. * @param scene defines the scene to apply the delta to
  75765. */
  75766. static ApplyDelta(deltaJSON: any | string, scene: Scene): void;
  75767. private static _ApplyPropertiesToEntity;
  75768. private static _ApplyDeltaForEntity;
  75769. }
  75770. }
  75771. declare module BABYLON {
  75772. /**
  75773. * A 3D trajectory consisting of an order list of vectors describing a
  75774. * path of motion through 3D space.
  75775. */
  75776. export class Trajectory {
  75777. private _points;
  75778. private readonly _segmentLength;
  75779. /**
  75780. * Serialize to JSON.
  75781. * @returns serialized JSON string
  75782. */
  75783. serialize(): string;
  75784. /**
  75785. * Deserialize from JSON.
  75786. * @param json serialized JSON string
  75787. * @returns deserialized Trajectory
  75788. */
  75789. static Deserialize(json: string): Trajectory;
  75790. /**
  75791. * Create a new empty Trajectory.
  75792. * @param segmentLength radius of discretization for Trajectory points
  75793. */
  75794. constructor(segmentLength?: number);
  75795. /**
  75796. * Get the length of the Trajectory.
  75797. * @returns length of the Trajectory
  75798. */
  75799. getLength(): number;
  75800. /**
  75801. * Append a new point to the Trajectory.
  75802. * NOTE: This implementation has many allocations.
  75803. * @param point point to append to the Trajectory
  75804. */
  75805. add(point: DeepImmutable<Vector3>): void;
  75806. /**
  75807. * Create a new Trajectory with a segment length chosen to make it
  75808. * probable that the new Trajectory will have a specified number of
  75809. * segments. This operation is imprecise.
  75810. * @param targetResolution number of segments desired
  75811. * @returns new Trajectory with approximately the requested number of segments
  75812. */
  75813. resampleAtTargetResolution(targetResolution: number): Trajectory;
  75814. /**
  75815. * Convert Trajectory segments into tokenized representation. This
  75816. * representation is an array of numbers where each nth number is the
  75817. * index of the token which is most similar to the nth segment of the
  75818. * Trajectory.
  75819. * @param tokens list of vectors which serve as discrete tokens
  75820. * @returns list of indices of most similar token per segment
  75821. */
  75822. tokenize(tokens: DeepImmutable<Vector3[]>): number[];
  75823. private static _forwardDir;
  75824. private static _inverseFromVec;
  75825. private static _upDir;
  75826. private static _fromToVec;
  75827. private static _lookMatrix;
  75828. /**
  75829. * Transform the rotation (i.e., direction) of a segment to isolate
  75830. * the relative transformation represented by the segment. This operation
  75831. * may or may not succeed due to singularities in the equations that define
  75832. * motion relativity in this context.
  75833. * @param priorVec the origin of the prior segment
  75834. * @param fromVec the origin of the current segment
  75835. * @param toVec the destination of the current segment
  75836. * @param result reference to output variable
  75837. * @returns whether or not transformation was successful
  75838. */
  75839. private static _transformSegmentDirToRef;
  75840. private static _bestMatch;
  75841. private static _score;
  75842. private static _bestScore;
  75843. /**
  75844. * Determine which token vector is most similar to the
  75845. * segment vector.
  75846. * @param segment segment vector
  75847. * @param tokens token vector list
  75848. * @returns index of the most similar token to the segment
  75849. */
  75850. private static _tokenizeSegment;
  75851. }
  75852. /**
  75853. * Class representing a set of known, named trajectories to which Trajectories can be
  75854. * added and using which Trajectories can be recognized.
  75855. */
  75856. export class TrajectoryClassifier {
  75857. private _maximumAllowableMatchCost;
  75858. private _vector3Alphabet;
  75859. private _levenshteinAlphabet;
  75860. private _nameToDescribedTrajectory;
  75861. /**
  75862. * Serialize to JSON.
  75863. * @returns JSON serialization
  75864. */
  75865. serialize(): string;
  75866. /**
  75867. * Deserialize from JSON.
  75868. * @param json JSON serialization
  75869. * @returns deserialized TrajectorySet
  75870. */
  75871. static Deserialize(json: string): TrajectoryClassifier;
  75872. /**
  75873. * Initialize a new empty TrajectorySet with auto-generated Alphabets.
  75874. * VERY naive, need to be generating these things from known
  75875. * sets. Better version later, probably eliminating this one.
  75876. * @returns auto-generated TrajectorySet
  75877. */
  75878. static Generate(): TrajectoryClassifier;
  75879. private constructor();
  75880. /**
  75881. * Add a new Trajectory to the set with a given name.
  75882. * @param trajectory new Trajectory to be added
  75883. * @param classification name to which to add the Trajectory
  75884. */
  75885. addTrajectoryToClassification(trajectory: Trajectory, classification: string): void;
  75886. /**
  75887. * Remove a known named trajectory and all Trajectories associated with it.
  75888. * @param classification name to remove
  75889. * @returns whether anything was removed
  75890. */
  75891. deleteClassification(classification: string): boolean;
  75892. /**
  75893. * Attempt to recognize a Trajectory from among all the classifications
  75894. * already known to the classifier.
  75895. * @param trajectory Trajectory to be recognized
  75896. * @returns classification of Trajectory if recognized, null otherwise
  75897. */
  75898. classifyTrajectory(trajectory: Trajectory): Nullable<string>;
  75899. }
  75900. }
  75901. declare module BABYLON {
  75902. /**
  75903. * An interface for all Hit test features
  75904. */
  75905. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  75906. /**
  75907. * Triggered when new babylon (transformed) hit test results are available
  75908. */
  75909. onHitTestResultObservable: Observable<T[]>;
  75910. }
  75911. /**
  75912. * Options used for hit testing
  75913. */
  75914. export interface IWebXRLegacyHitTestOptions {
  75915. /**
  75916. * Only test when user interacted with the scene. Default - hit test every frame
  75917. */
  75918. testOnPointerDownOnly?: boolean;
  75919. /**
  75920. * The node to use to transform the local results to world coordinates
  75921. */
  75922. worldParentNode?: TransformNode;
  75923. }
  75924. /**
  75925. * Interface defining the babylon result of raycasting/hit-test
  75926. */
  75927. export interface IWebXRLegacyHitResult {
  75928. /**
  75929. * Transformation matrix that can be applied to a node that will put it in the hit point location
  75930. */
  75931. transformationMatrix: Matrix;
  75932. /**
  75933. * The native hit test result
  75934. */
  75935. xrHitResult: XRHitResult | XRHitTestResult;
  75936. }
  75937. /**
  75938. * The currently-working hit-test module.
  75939. * Hit test (or Ray-casting) is used to interact with the real world.
  75940. * For further information read here - https://github.com/immersive-web/hit-test
  75941. */
  75942. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  75943. /**
  75944. * options to use when constructing this feature
  75945. */
  75946. readonly options: IWebXRLegacyHitTestOptions;
  75947. private _direction;
  75948. private _mat;
  75949. private _onSelectEnabled;
  75950. private _origin;
  75951. /**
  75952. * The module's name
  75953. */
  75954. static readonly Name: string;
  75955. /**
  75956. * The (Babylon) version of this module.
  75957. * This is an integer representing the implementation version.
  75958. * This number does not correspond to the WebXR specs version
  75959. */
  75960. static readonly Version: number;
  75961. /**
  75962. * Populated with the last native XR Hit Results
  75963. */
  75964. lastNativeXRHitResults: XRHitResult[];
  75965. /**
  75966. * Triggered when new babylon (transformed) hit test results are available
  75967. */
  75968. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  75969. /**
  75970. * Creates a new instance of the (legacy version) hit test feature
  75971. * @param _xrSessionManager an instance of WebXRSessionManager
  75972. * @param options options to use when constructing this feature
  75973. */
  75974. constructor(_xrSessionManager: WebXRSessionManager,
  75975. /**
  75976. * options to use when constructing this feature
  75977. */
  75978. options?: IWebXRLegacyHitTestOptions);
  75979. /**
  75980. * execute a hit test with an XR Ray
  75981. *
  75982. * @param xrSession a native xrSession that will execute this hit test
  75983. * @param xrRay the ray (position and direction) to use for ray-casting
  75984. * @param referenceSpace native XR reference space to use for the hit-test
  75985. * @param filter filter function that will filter the results
  75986. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  75987. */
  75988. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  75989. /**
  75990. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  75991. * @param event the (select) event to use to select with
  75992. * @param referenceSpace the reference space to use for this hit test
  75993. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  75994. */
  75995. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  75996. /**
  75997. * attach this feature
  75998. * Will usually be called by the features manager
  75999. *
  76000. * @returns true if successful.
  76001. */
  76002. attach(): boolean;
  76003. /**
  76004. * detach this feature.
  76005. * Will usually be called by the features manager
  76006. *
  76007. * @returns true if successful.
  76008. */
  76009. detach(): boolean;
  76010. /**
  76011. * Dispose this feature and all of the resources attached
  76012. */
  76013. dispose(): void;
  76014. protected _onXRFrame(frame: XRFrame): void;
  76015. private _onHitTestResults;
  76016. private _onSelect;
  76017. }
  76018. }
  76019. declare module BABYLON {
  76020. /**
  76021. * Options used for hit testing (version 2)
  76022. */
  76023. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  76024. /**
  76025. * Do not create a permanent hit test. Will usually be used when only
  76026. * transient inputs are needed.
  76027. */
  76028. disablePermanentHitTest?: boolean;
  76029. /**
  76030. * Enable transient (for example touch-based) hit test inspections
  76031. */
  76032. enableTransientHitTest?: boolean;
  76033. /**
  76034. * Offset ray for the permanent hit test
  76035. */
  76036. offsetRay?: Vector3;
  76037. /**
  76038. * Offset ray for the transient hit test
  76039. */
  76040. transientOffsetRay?: Vector3;
  76041. /**
  76042. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  76043. */
  76044. useReferenceSpace?: boolean;
  76045. /**
  76046. * Override the default entity type(s) of the hit-test result
  76047. */
  76048. entityTypes?: XRHitTestTrackableType[];
  76049. }
  76050. /**
  76051. * Interface defining the babylon result of hit-test
  76052. */
  76053. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  76054. /**
  76055. * The input source that generated this hit test (if transient)
  76056. */
  76057. inputSource?: XRInputSource;
  76058. /**
  76059. * Is this a transient hit test
  76060. */
  76061. isTransient?: boolean;
  76062. /**
  76063. * Position of the hit test result
  76064. */
  76065. position: Vector3;
  76066. /**
  76067. * Rotation of the hit test result
  76068. */
  76069. rotationQuaternion: Quaternion;
  76070. /**
  76071. * The native hit test result
  76072. */
  76073. xrHitResult: XRHitTestResult;
  76074. }
  76075. /**
  76076. * The currently-working hit-test module.
  76077. * Hit test (or Ray-casting) is used to interact with the real world.
  76078. * For further information read here - https://github.com/immersive-web/hit-test
  76079. *
  76080. * Tested on chrome (mobile) 80.
  76081. */
  76082. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  76083. /**
  76084. * options to use when constructing this feature
  76085. */
  76086. readonly options: IWebXRHitTestOptions;
  76087. private _tmpMat;
  76088. private _tmpPos;
  76089. private _tmpQuat;
  76090. private _transientXrHitTestSource;
  76091. private _xrHitTestSource;
  76092. private initHitTestSource;
  76093. /**
  76094. * The module's name
  76095. */
  76096. static readonly Name: string;
  76097. /**
  76098. * The (Babylon) version of this module.
  76099. * This is an integer representing the implementation version.
  76100. * This number does not correspond to the WebXR specs version
  76101. */
  76102. static readonly Version: number;
  76103. /**
  76104. * When set to true, each hit test will have its own position/rotation objects
  76105. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  76106. * the developers will clone them or copy them as they see fit.
  76107. */
  76108. autoCloneTransformation: boolean;
  76109. /**
  76110. * Triggered when new babylon (transformed) hit test results are available
  76111. * Note - this will be called when results come back from the device. It can be an empty array!!
  76112. */
  76113. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  76114. /**
  76115. * Use this to temporarily pause hit test checks.
  76116. */
  76117. paused: boolean;
  76118. /**
  76119. * Creates a new instance of the hit test feature
  76120. * @param _xrSessionManager an instance of WebXRSessionManager
  76121. * @param options options to use when constructing this feature
  76122. */
  76123. constructor(_xrSessionManager: WebXRSessionManager,
  76124. /**
  76125. * options to use when constructing this feature
  76126. */
  76127. options?: IWebXRHitTestOptions);
  76128. /**
  76129. * attach this feature
  76130. * Will usually be called by the features manager
  76131. *
  76132. * @returns true if successful.
  76133. */
  76134. attach(): boolean;
  76135. /**
  76136. * detach this feature.
  76137. * Will usually be called by the features manager
  76138. *
  76139. * @returns true if successful.
  76140. */
  76141. detach(): boolean;
  76142. /**
  76143. * Dispose this feature and all of the resources attached
  76144. */
  76145. dispose(): void;
  76146. protected _onXRFrame(frame: XRFrame): void;
  76147. private _processWebXRHitTestResult;
  76148. }
  76149. }
  76150. declare module BABYLON {
  76151. /**
  76152. * Configuration options of the anchor system
  76153. */
  76154. export interface IWebXRAnchorSystemOptions {
  76155. /**
  76156. * a node that will be used to convert local to world coordinates
  76157. */
  76158. worldParentNode?: TransformNode;
  76159. /**
  76160. * If set to true a reference of the created anchors will be kept until the next session starts
  76161. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  76162. */
  76163. doNotRemoveAnchorsOnSessionEnded?: boolean;
  76164. }
  76165. /**
  76166. * A babylon container for an XR Anchor
  76167. */
  76168. export interface IWebXRAnchor {
  76169. /**
  76170. * A babylon-assigned ID for this anchor
  76171. */
  76172. id: number;
  76173. /**
  76174. * Transformation matrix to apply to an object attached to this anchor
  76175. */
  76176. transformationMatrix: Matrix;
  76177. /**
  76178. * The native anchor object
  76179. */
  76180. xrAnchor: XRAnchor;
  76181. /**
  76182. * if defined, this object will be constantly updated by the anchor's position and rotation
  76183. */
  76184. attachedNode?: TransformNode;
  76185. /**
  76186. * Remove this anchor from the scene
  76187. */
  76188. remove(): void;
  76189. }
  76190. /**
  76191. * An implementation of the anchor system for WebXR.
  76192. * For further information see https://github.com/immersive-web/anchors/
  76193. */
  76194. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  76195. private _options;
  76196. private _lastFrameDetected;
  76197. private _trackedAnchors;
  76198. private _referenceSpaceForFrameAnchors;
  76199. private _futureAnchors;
  76200. /**
  76201. * The module's name
  76202. */
  76203. static readonly Name: string;
  76204. /**
  76205. * The (Babylon) version of this module.
  76206. * This is an integer representing the implementation version.
  76207. * This number does not correspond to the WebXR specs version
  76208. */
  76209. static readonly Version: number;
  76210. /**
  76211. * Observers registered here will be executed when a new anchor was added to the session
  76212. */
  76213. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  76214. /**
  76215. * Observers registered here will be executed when an anchor was removed from the session
  76216. */
  76217. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  76218. /**
  76219. * Observers registered here will be executed when an existing anchor updates
  76220. * This can execute N times every frame
  76221. */
  76222. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  76223. /**
  76224. * Set the reference space to use for anchor creation, when not using a hit test.
  76225. * Will default to the session's reference space if not defined
  76226. */
  76227. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  76228. /**
  76229. * constructs a new anchor system
  76230. * @param _xrSessionManager an instance of WebXRSessionManager
  76231. * @param _options configuration object for this feature
  76232. */
  76233. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  76234. private _tmpVector;
  76235. private _tmpQuaternion;
  76236. private _populateTmpTransformation;
  76237. /**
  76238. * Create a new anchor point using a hit test result at a specific point in the scene
  76239. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  76240. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  76241. *
  76242. * @param hitTestResult The hit test result to use for this anchor creation
  76243. * @param position an optional position offset for this anchor
  76244. * @param rotationQuaternion an optional rotation offset for this anchor
  76245. * @returns A promise that fulfills when babylon has created the corresponding WebXRAnchor object and tracking has begun
  76246. */
  76247. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<IWebXRAnchor>;
  76248. /**
  76249. * Add a new anchor at a specific position and rotation
  76250. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  76251. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  76252. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  76253. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  76254. *
  76255. * @param position the position in which to add an anchor
  76256. * @param rotationQuaternion an optional rotation for the anchor transformation
  76257. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  76258. * @returns A promise that fulfills when babylon has created the corresponding WebXRAnchor object and tracking has begun
  76259. */
  76260. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<IWebXRAnchor>;
  76261. /**
  76262. * Get the list of anchors currently being tracked by the system
  76263. */
  76264. get anchors(): IWebXRAnchor[];
  76265. /**
  76266. * detach this feature.
  76267. * Will usually be called by the features manager
  76268. *
  76269. * @returns true if successful.
  76270. */
  76271. detach(): boolean;
  76272. /**
  76273. * Dispose this feature and all of the resources attached
  76274. */
  76275. dispose(): void;
  76276. protected _onXRFrame(frame: XRFrame): void;
  76277. /**
  76278. * avoiding using Array.find for global support.
  76279. * @param xrAnchor the plane to find in the array
  76280. */
  76281. private _findIndexInAnchorArray;
  76282. private _updateAnchorWithXRFrame;
  76283. private _createAnchorAtTransformation;
  76284. }
  76285. }
  76286. declare module BABYLON {
  76287. /**
  76288. * Options used in the plane detector module
  76289. */
  76290. export interface IWebXRPlaneDetectorOptions {
  76291. /**
  76292. * The node to use to transform the local results to world coordinates
  76293. */
  76294. worldParentNode?: TransformNode;
  76295. /**
  76296. * If set to true a reference of the created planes will be kept until the next session starts
  76297. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  76298. */
  76299. doNotRemovePlanesOnSessionEnded?: boolean;
  76300. }
  76301. /**
  76302. * A babylon interface for a WebXR plane.
  76303. * A Plane is actually a polygon, built from N points in space
  76304. *
  76305. * Supported in chrome 79, not supported in canary 81 ATM
  76306. */
  76307. export interface IWebXRPlane {
  76308. /**
  76309. * a babylon-assigned ID for this polygon
  76310. */
  76311. id: number;
  76312. /**
  76313. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  76314. */
  76315. polygonDefinition: Array<Vector3>;
  76316. /**
  76317. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  76318. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  76319. */
  76320. transformationMatrix: Matrix;
  76321. /**
  76322. * the native xr-plane object
  76323. */
  76324. xrPlane: XRPlane;
  76325. }
  76326. /**
  76327. * The plane detector is used to detect planes in the real world when in AR
  76328. * For more information see https://github.com/immersive-web/real-world-geometry/
  76329. */
  76330. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  76331. private _options;
  76332. private _detectedPlanes;
  76333. private _enabled;
  76334. private _lastFrameDetected;
  76335. /**
  76336. * The module's name
  76337. */
  76338. static readonly Name: string;
  76339. /**
  76340. * The (Babylon) version of this module.
  76341. * This is an integer representing the implementation version.
  76342. * This number does not correspond to the WebXR specs version
  76343. */
  76344. static readonly Version: number;
  76345. /**
  76346. * Observers registered here will be executed when a new plane was added to the session
  76347. */
  76348. onPlaneAddedObservable: Observable<IWebXRPlane>;
  76349. /**
  76350. * Observers registered here will be executed when a plane is no longer detected in the session
  76351. */
  76352. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  76353. /**
  76354. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  76355. * This can execute N times every frame
  76356. */
  76357. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  76358. /**
  76359. * construct a new Plane Detector
  76360. * @param _xrSessionManager an instance of xr Session manager
  76361. * @param _options configuration to use when constructing this feature
  76362. */
  76363. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  76364. /**
  76365. * detach this feature.
  76366. * Will usually be called by the features manager
  76367. *
  76368. * @returns true if successful.
  76369. */
  76370. detach(): boolean;
  76371. /**
  76372. * Dispose this feature and all of the resources attached
  76373. */
  76374. dispose(): void;
  76375. /**
  76376. * Check if the needed objects are defined.
  76377. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  76378. */
  76379. isCompatible(): boolean;
  76380. protected _onXRFrame(frame: XRFrame): void;
  76381. private _init;
  76382. private _updatePlaneWithXRPlane;
  76383. /**
  76384. * avoiding using Array.find for global support.
  76385. * @param xrPlane the plane to find in the array
  76386. */
  76387. private findIndexInPlaneArray;
  76388. }
  76389. }
  76390. declare module BABYLON {
  76391. /**
  76392. * Options interface for the background remover plugin
  76393. */
  76394. export interface IWebXRBackgroundRemoverOptions {
  76395. /**
  76396. * Further background meshes to disable when entering AR
  76397. */
  76398. backgroundMeshes?: AbstractMesh[];
  76399. /**
  76400. * flags to configure the removal of the environment helper.
  76401. * If not set, the entire background will be removed. If set, flags should be set as well.
  76402. */
  76403. environmentHelperRemovalFlags?: {
  76404. /**
  76405. * Should the skybox be removed (default false)
  76406. */
  76407. skyBox?: boolean;
  76408. /**
  76409. * Should the ground be removed (default false)
  76410. */
  76411. ground?: boolean;
  76412. };
  76413. /**
  76414. * don't disable the environment helper
  76415. */
  76416. ignoreEnvironmentHelper?: boolean;
  76417. }
  76418. /**
  76419. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  76420. */
  76421. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  76422. /**
  76423. * read-only options to be used in this module
  76424. */
  76425. readonly options: IWebXRBackgroundRemoverOptions;
  76426. /**
  76427. * The module's name
  76428. */
  76429. static readonly Name: string;
  76430. /**
  76431. * The (Babylon) version of this module.
  76432. * This is an integer representing the implementation version.
  76433. * This number does not correspond to the WebXR specs version
  76434. */
  76435. static readonly Version: number;
  76436. /**
  76437. * registered observers will be triggered when the background state changes
  76438. */
  76439. onBackgroundStateChangedObservable: Observable<boolean>;
  76440. /**
  76441. * constructs a new background remover module
  76442. * @param _xrSessionManager the session manager for this module
  76443. * @param options read-only options to be used in this module
  76444. */
  76445. constructor(_xrSessionManager: WebXRSessionManager,
  76446. /**
  76447. * read-only options to be used in this module
  76448. */
  76449. options?: IWebXRBackgroundRemoverOptions);
  76450. /**
  76451. * attach this feature
  76452. * Will usually be called by the features manager
  76453. *
  76454. * @returns true if successful.
  76455. */
  76456. attach(): boolean;
  76457. /**
  76458. * detach this feature.
  76459. * Will usually be called by the features manager
  76460. *
  76461. * @returns true if successful.
  76462. */
  76463. detach(): boolean;
  76464. /**
  76465. * Dispose this feature and all of the resources attached
  76466. */
  76467. dispose(): void;
  76468. protected _onXRFrame(_xrFrame: XRFrame): void;
  76469. private _setBackgroundState;
  76470. }
  76471. }
  76472. declare module BABYLON {
  76473. /**
  76474. * Options for the controller physics feature
  76475. */
  76476. export class IWebXRControllerPhysicsOptions {
  76477. /**
  76478. * Should the headset get its own impostor
  76479. */
  76480. enableHeadsetImpostor?: boolean;
  76481. /**
  76482. * Optional parameters for the headset impostor
  76483. */
  76484. headsetImpostorParams?: {
  76485. /**
  76486. * The type of impostor to create. Default is sphere
  76487. */
  76488. impostorType: number;
  76489. /**
  76490. * the size of the impostor. Defaults to 10cm
  76491. */
  76492. impostorSize?: number | {
  76493. width: number;
  76494. height: number;
  76495. depth: number;
  76496. };
  76497. /**
  76498. * Friction definitions
  76499. */
  76500. friction?: number;
  76501. /**
  76502. * Restitution
  76503. */
  76504. restitution?: number;
  76505. };
  76506. /**
  76507. * The physics properties of the future impostors
  76508. */
  76509. physicsProperties?: {
  76510. /**
  76511. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  76512. * Note that this requires a physics engine that supports mesh impostors!
  76513. */
  76514. useControllerMesh?: boolean;
  76515. /**
  76516. * The type of impostor to create. Default is sphere
  76517. */
  76518. impostorType?: number;
  76519. /**
  76520. * the size of the impostor. Defaults to 10cm
  76521. */
  76522. impostorSize?: number | {
  76523. width: number;
  76524. height: number;
  76525. depth: number;
  76526. };
  76527. /**
  76528. * Friction definitions
  76529. */
  76530. friction?: number;
  76531. /**
  76532. * Restitution
  76533. */
  76534. restitution?: number;
  76535. };
  76536. /**
  76537. * the xr input to use with this pointer selection
  76538. */
  76539. xrInput: WebXRInput;
  76540. }
  76541. /**
  76542. * Add physics impostor to your webxr controllers,
  76543. * including naive calculation of their linear and angular velocity
  76544. */
  76545. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  76546. private readonly _options;
  76547. private _attachController;
  76548. private _controllers;
  76549. private _debugMode;
  76550. private _delta;
  76551. private _headsetImpostor?;
  76552. private _headsetMesh?;
  76553. private _lastTimestamp;
  76554. private _tmpQuaternion;
  76555. private _tmpVector;
  76556. /**
  76557. * The module's name
  76558. */
  76559. static readonly Name: string;
  76560. /**
  76561. * The (Babylon) version of this module.
  76562. * This is an integer representing the implementation version.
  76563. * This number does not correspond to the webxr specs version
  76564. */
  76565. static readonly Version: number;
  76566. /**
  76567. * Construct a new Controller Physics Feature
  76568. * @param _xrSessionManager the corresponding xr session manager
  76569. * @param _options options to create this feature with
  76570. */
  76571. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  76572. /**
  76573. * @hidden
  76574. * enable debugging - will show console outputs and the impostor mesh
  76575. */
  76576. _enablePhysicsDebug(): void;
  76577. /**
  76578. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  76579. * @param xrController the controller to add
  76580. */
  76581. addController(xrController: WebXRInputSource): void;
  76582. /**
  76583. * attach this feature
  76584. * Will usually be called by the features manager
  76585. *
  76586. * @returns true if successful.
  76587. */
  76588. attach(): boolean;
  76589. /**
  76590. * detach this feature.
  76591. * Will usually be called by the features manager
  76592. *
  76593. * @returns true if successful.
  76594. */
  76595. detach(): boolean;
  76596. /**
  76597. * Get the headset impostor, if enabled
  76598. * @returns the impostor
  76599. */
  76600. getHeadsetImpostor(): PhysicsImpostor | undefined;
  76601. /**
  76602. * Get the physics impostor of a specific controller.
  76603. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  76604. * @param controller the controller or the controller id of which to get the impostor
  76605. * @returns the impostor or null
  76606. */
  76607. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  76608. /**
  76609. * Update the physics properties provided in the constructor
  76610. * @param newProperties the new properties object
  76611. */
  76612. setPhysicsProperties(newProperties: {
  76613. impostorType?: number;
  76614. impostorSize?: number | {
  76615. width: number;
  76616. height: number;
  76617. depth: number;
  76618. };
  76619. friction?: number;
  76620. restitution?: number;
  76621. }): void;
  76622. protected _onXRFrame(_xrFrame: any): void;
  76623. private _detachController;
  76624. }
  76625. }
  76626. declare module BABYLON {
  76627. /**
  76628. * A babylon interface for a "WebXR" feature point.
  76629. * Represents the position and confidence value of a given feature point.
  76630. */
  76631. export interface IWebXRFeaturePoint {
  76632. /**
  76633. * Represents the position of the feature point in world space.
  76634. */
  76635. position: Vector3;
  76636. /**
  76637. * Represents the confidence value of the feature point in world space. 0 being least confident, and 1 being most confident.
  76638. */
  76639. confidenceValue: number;
  76640. }
  76641. /**
  76642. * The feature point system is used to detect feature points from real world geometry.
  76643. * This feature is currently experimental and only supported on BabylonNative, and should not be used in the browser.
  76644. * The newly introduced API can be seen in webxr.nativeextensions.d.ts and described in FeaturePoints.md.
  76645. */
  76646. export class WebXRFeaturePointSystem extends WebXRAbstractFeature {
  76647. private _enabled;
  76648. private _featurePointCloud;
  76649. /**
  76650. * The module's name
  76651. */
  76652. static readonly Name: string;
  76653. /**
  76654. * The (Babylon) version of this module.
  76655. * This is an integer representing the implementation version.
  76656. * This number does not correspond to the WebXR specs version
  76657. */
  76658. static readonly Version: number;
  76659. /**
  76660. * Observers registered here will be executed whenever new feature points are added (on XRFrame while the session is tracking).
  76661. * Will notify the observers about which feature points have been added.
  76662. */
  76663. readonly onFeaturePointsAddedObservable: Observable<number[]>;
  76664. /**
  76665. * Observers registered here will be executed whenever a feature point has been updated (on XRFrame while the session is tracking).
  76666. * Will notify the observers about which feature points have been updated.
  76667. */
  76668. readonly onFeaturePointsUpdatedObservable: Observable<number[]>;
  76669. /**
  76670. * The current feature point cloud maintained across frames.
  76671. */
  76672. get featurePointCloud(): Array<IWebXRFeaturePoint>;
  76673. /**
  76674. * construct the feature point system
  76675. * @param _xrSessionManager an instance of xr Session manager
  76676. */
  76677. constructor(_xrSessionManager: WebXRSessionManager);
  76678. /**
  76679. * Detach this feature.
  76680. * Will usually be called by the features manager
  76681. *
  76682. * @returns true if successful.
  76683. */
  76684. detach(): boolean;
  76685. /**
  76686. * Dispose this feature and all of the resources attached
  76687. */
  76688. dispose(): void;
  76689. /**
  76690. * On receiving a new XR frame if this feature is attached notify observers new feature point data is available.
  76691. */
  76692. protected _onXRFrame(frame: XRFrame): void;
  76693. /**
  76694. * Initializes the feature. If the feature point feature is not available for this environment do not mark the feature as enabled.
  76695. */
  76696. private _init;
  76697. }
  76698. }
  76699. declare module BABYLON {
  76700. /**
  76701. * Configuration interface for the hand tracking feature
  76702. */
  76703. export interface IWebXRHandTrackingOptions {
  76704. /**
  76705. * The xrInput that will be used as source for new hands
  76706. */
  76707. xrInput: WebXRInput;
  76708. /**
  76709. * Configuration object for the joint meshes
  76710. */
  76711. jointMeshes?: {
  76712. /**
  76713. * Should the meshes created be invisible (defaults to false)
  76714. */
  76715. invisible?: boolean;
  76716. /**
  76717. * A source mesh to be used to create instances. Defaults to a sphere.
  76718. * This mesh will be the source for all other (25) meshes.
  76719. * It should have the general size of a single unit, as the instances will be scaled according to the provided radius
  76720. */
  76721. sourceMesh?: Mesh;
  76722. /**
  76723. * This function will be called after a mesh was created for a specific joint.
  76724. * Using this function you can either manipulate the instance or return a new mesh.
  76725. * When returning a new mesh the instance created before will be disposed
  76726. */
  76727. onHandJointMeshGenerated?: (meshInstance: InstancedMesh, jointId: number, controllerId: string) => Mesh | undefined;
  76728. /**
  76729. * Should the source mesh stay visible. Defaults to false
  76730. */
  76731. keepOriginalVisible?: boolean;
  76732. /**
  76733. * Scale factor for all instances (defaults to 2)
  76734. */
  76735. scaleFactor?: number;
  76736. /**
  76737. * Should each instance have its own physics impostor
  76738. */
  76739. enablePhysics?: boolean;
  76740. /**
  76741. * If enabled, override default physics properties
  76742. */
  76743. physicsProps?: {
  76744. friction?: number;
  76745. restitution?: number;
  76746. impostorType?: number;
  76747. };
  76748. /**
  76749. * For future use - a single hand-mesh that will be updated according to the XRHand data provided
  76750. */
  76751. handMesh?: AbstractMesh;
  76752. };
  76753. }
  76754. /**
  76755. * Parts of the hands divided to writs and finger names
  76756. */
  76757. export const enum HandPart {
  76758. /**
  76759. * HandPart - Wrist
  76760. */
  76761. WRIST = "wrist",
  76762. /**
  76763. * HandPart - The THumb
  76764. */
  76765. THUMB = "thumb",
  76766. /**
  76767. * HandPart - Index finger
  76768. */
  76769. INDEX = "index",
  76770. /**
  76771. * HandPart - Middle finger
  76772. */
  76773. MIDDLE = "middle",
  76774. /**
  76775. * HandPart - Ring finger
  76776. */
  76777. RING = "ring",
  76778. /**
  76779. * HandPart - Little finger
  76780. */
  76781. LITTLE = "little"
  76782. }
  76783. /**
  76784. * Representing a single hand (with its corresponding native XRHand object)
  76785. */
  76786. export class WebXRHand implements IDisposable {
  76787. /** the controller to which the hand correlates */
  76788. readonly xrController: WebXRInputSource;
  76789. /** the meshes to be used to track the hand joints */
  76790. readonly trackedMeshes: AbstractMesh[];
  76791. /**
  76792. * Hand-parts definition (key is HandPart)
  76793. */
  76794. handPartsDefinition: {
  76795. [key: string]: number[];
  76796. };
  76797. /**
  76798. * Populate the HandPartsDefinition object.
  76799. * This is called as a side effect since certain browsers don't have XRHand defined.
  76800. */
  76801. private generateHandPartsDefinition;
  76802. /**
  76803. * Construct a new hand object
  76804. * @param xrController the controller to which the hand correlates
  76805. * @param trackedMeshes the meshes to be used to track the hand joints
  76806. */
  76807. constructor(
  76808. /** the controller to which the hand correlates */
  76809. xrController: WebXRInputSource,
  76810. /** the meshes to be used to track the hand joints */
  76811. trackedMeshes: AbstractMesh[]);
  76812. /**
  76813. * Update this hand from the latest xr frame
  76814. * @param xrFrame xrFrame to update from
  76815. * @param referenceSpace The current viewer reference space
  76816. * @param scaleFactor optional scale factor for the meshes
  76817. */
  76818. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace, scaleFactor?: number): void;
  76819. /**
  76820. * Get meshes of part of the hand
  76821. * @param part the part of hand to get
  76822. * @returns An array of meshes that correlate to the hand part requested
  76823. */
  76824. getHandPartMeshes(part: HandPart): AbstractMesh[];
  76825. /**
  76826. * Dispose this Hand object
  76827. */
  76828. dispose(): void;
  76829. }
  76830. /**
  76831. * WebXR Hand Joint tracking feature, available for selected browsers and devices
  76832. */
  76833. export class WebXRHandTracking extends WebXRAbstractFeature {
  76834. /**
  76835. * options to use when constructing this feature
  76836. */
  76837. readonly options: IWebXRHandTrackingOptions;
  76838. private static _idCounter;
  76839. /**
  76840. * The module's name
  76841. */
  76842. static readonly Name: string;
  76843. /**
  76844. * The (Babylon) version of this module.
  76845. * This is an integer representing the implementation version.
  76846. * This number does not correspond to the WebXR specs version
  76847. */
  76848. static readonly Version: number;
  76849. /**
  76850. * This observable will notify registered observers when a new hand object was added and initialized
  76851. */
  76852. onHandAddedObservable: Observable<WebXRHand>;
  76853. /**
  76854. * This observable will notify its observers right before the hand object is disposed
  76855. */
  76856. onHandRemovedObservable: Observable<WebXRHand>;
  76857. private _hands;
  76858. /**
  76859. * Creates a new instance of the hit test feature
  76860. * @param _xrSessionManager an instance of WebXRSessionManager
  76861. * @param options options to use when constructing this feature
  76862. */
  76863. constructor(_xrSessionManager: WebXRSessionManager,
  76864. /**
  76865. * options to use when constructing this feature
  76866. */
  76867. options: IWebXRHandTrackingOptions);
  76868. /**
  76869. * Check if the needed objects are defined.
  76870. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  76871. */
  76872. isCompatible(): boolean;
  76873. /**
  76874. * attach this feature
  76875. * Will usually be called by the features manager
  76876. *
  76877. * @returns true if successful.
  76878. */
  76879. attach(): boolean;
  76880. /**
  76881. * detach this feature.
  76882. * Will usually be called by the features manager
  76883. *
  76884. * @returns true if successful.
  76885. */
  76886. detach(): boolean;
  76887. /**
  76888. * Dispose this feature and all of the resources attached
  76889. */
  76890. dispose(): void;
  76891. /**
  76892. * Get the hand object according to the controller id
  76893. * @param controllerId the controller id to which we want to get the hand
  76894. * @returns null if not found or the WebXRHand object if found
  76895. */
  76896. getHandByControllerId(controllerId: string): Nullable<WebXRHand>;
  76897. /**
  76898. * Get a hand object according to the requested handedness
  76899. * @param handedness the handedness to request
  76900. * @returns null if not found or the WebXRHand object if found
  76901. */
  76902. getHandByHandedness(handedness: XRHandedness): Nullable<WebXRHand>;
  76903. protected _onXRFrame(_xrFrame: XRFrame): void;
  76904. private _attachHand;
  76905. private _detachHand;
  76906. }
  76907. }
  76908. declare module BABYLON {
  76909. /**
  76910. * The motion controller class for all microsoft mixed reality controllers
  76911. */
  76912. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  76913. protected readonly _mapping: {
  76914. defaultButton: {
  76915. valueNodeName: string;
  76916. unpressedNodeName: string;
  76917. pressedNodeName: string;
  76918. };
  76919. defaultAxis: {
  76920. valueNodeName: string;
  76921. minNodeName: string;
  76922. maxNodeName: string;
  76923. };
  76924. buttons: {
  76925. "xr-standard-trigger": {
  76926. rootNodeName: string;
  76927. componentProperty: string;
  76928. states: string[];
  76929. };
  76930. "xr-standard-squeeze": {
  76931. rootNodeName: string;
  76932. componentProperty: string;
  76933. states: string[];
  76934. };
  76935. "xr-standard-touchpad": {
  76936. rootNodeName: string;
  76937. labelAnchorNodeName: string;
  76938. touchPointNodeName: string;
  76939. };
  76940. "xr-standard-thumbstick": {
  76941. rootNodeName: string;
  76942. componentProperty: string;
  76943. states: string[];
  76944. };
  76945. };
  76946. axes: {
  76947. "xr-standard-touchpad": {
  76948. "x-axis": {
  76949. rootNodeName: string;
  76950. };
  76951. "y-axis": {
  76952. rootNodeName: string;
  76953. };
  76954. };
  76955. "xr-standard-thumbstick": {
  76956. "x-axis": {
  76957. rootNodeName: string;
  76958. };
  76959. "y-axis": {
  76960. rootNodeName: string;
  76961. };
  76962. };
  76963. };
  76964. };
  76965. /**
  76966. * The base url used to load the left and right controller models
  76967. */
  76968. static MODEL_BASE_URL: string;
  76969. /**
  76970. * The name of the left controller model file
  76971. */
  76972. static MODEL_LEFT_FILENAME: string;
  76973. /**
  76974. * The name of the right controller model file
  76975. */
  76976. static MODEL_RIGHT_FILENAME: string;
  76977. profileId: string;
  76978. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  76979. protected _getFilenameAndPath(): {
  76980. filename: string;
  76981. path: string;
  76982. };
  76983. protected _getModelLoadingConstraints(): boolean;
  76984. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  76985. protected _setRootMesh(meshes: AbstractMesh[]): void;
  76986. protected _updateModel(): void;
  76987. }
  76988. }
  76989. declare module BABYLON {
  76990. /**
  76991. * The motion controller class for oculus touch (quest, rift).
  76992. * This class supports legacy mapping as well the standard xr mapping
  76993. */
  76994. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  76995. private _forceLegacyControllers;
  76996. private _modelRootNode;
  76997. /**
  76998. * The base url used to load the left and right controller models
  76999. */
  77000. static MODEL_BASE_URL: string;
  77001. /**
  77002. * The name of the left controller model file
  77003. */
  77004. static MODEL_LEFT_FILENAME: string;
  77005. /**
  77006. * The name of the right controller model file
  77007. */
  77008. static MODEL_RIGHT_FILENAME: string;
  77009. /**
  77010. * Base Url for the Quest controller model.
  77011. */
  77012. static QUEST_MODEL_BASE_URL: string;
  77013. profileId: string;
  77014. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  77015. protected _getFilenameAndPath(): {
  77016. filename: string;
  77017. path: string;
  77018. };
  77019. protected _getModelLoadingConstraints(): boolean;
  77020. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  77021. protected _setRootMesh(meshes: AbstractMesh[]): void;
  77022. protected _updateModel(): void;
  77023. /**
  77024. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  77025. * between the touch and touch 2.
  77026. */
  77027. private _isQuest;
  77028. }
  77029. }
  77030. declare module BABYLON {
  77031. /**
  77032. * The motion controller class for the standard HTC-Vive controllers
  77033. */
  77034. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  77035. private _modelRootNode;
  77036. /**
  77037. * The base url used to load the left and right controller models
  77038. */
  77039. static MODEL_BASE_URL: string;
  77040. /**
  77041. * File name for the controller model.
  77042. */
  77043. static MODEL_FILENAME: string;
  77044. profileId: string;
  77045. /**
  77046. * Create a new Vive motion controller object
  77047. * @param scene the scene to use to create this controller
  77048. * @param gamepadObject the corresponding gamepad object
  77049. * @param handedness the handedness of the controller
  77050. */
  77051. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  77052. protected _getFilenameAndPath(): {
  77053. filename: string;
  77054. path: string;
  77055. };
  77056. protected _getModelLoadingConstraints(): boolean;
  77057. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  77058. protected _setRootMesh(meshes: AbstractMesh[]): void;
  77059. protected _updateModel(): void;
  77060. }
  77061. }
  77062. declare module BABYLON {
  77063. /**
  77064. * A cursor which tracks a point on a path
  77065. */
  77066. export class PathCursor {
  77067. private path;
  77068. /**
  77069. * Stores path cursor callbacks for when an onchange event is triggered
  77070. */
  77071. private _onchange;
  77072. /**
  77073. * The value of the path cursor
  77074. */
  77075. value: number;
  77076. /**
  77077. * The animation array of the path cursor
  77078. */
  77079. animations: Animation[];
  77080. /**
  77081. * Initializes the path cursor
  77082. * @param path The path to track
  77083. */
  77084. constructor(path: Path2);
  77085. /**
  77086. * Gets the cursor point on the path
  77087. * @returns A point on the path cursor at the cursor location
  77088. */
  77089. getPoint(): Vector3;
  77090. /**
  77091. * Moves the cursor ahead by the step amount
  77092. * @param step The amount to move the cursor forward
  77093. * @returns This path cursor
  77094. */
  77095. moveAhead(step?: number): PathCursor;
  77096. /**
  77097. * Moves the cursor behind by the step amount
  77098. * @param step The amount to move the cursor back
  77099. * @returns This path cursor
  77100. */
  77101. moveBack(step?: number): PathCursor;
  77102. /**
  77103. * Moves the cursor by the step amount
  77104. * If the step amount is greater than one, an exception is thrown
  77105. * @param step The amount to move the cursor
  77106. * @returns This path cursor
  77107. */
  77108. move(step: number): PathCursor;
  77109. /**
  77110. * Ensures that the value is limited between zero and one
  77111. * @returns This path cursor
  77112. */
  77113. private ensureLimits;
  77114. /**
  77115. * Runs onchange callbacks on change (used by the animation engine)
  77116. * @returns This path cursor
  77117. */
  77118. private raiseOnChange;
  77119. /**
  77120. * Executes a function on change
  77121. * @param f A path cursor onchange callback
  77122. * @returns This path cursor
  77123. */
  77124. onchange(f: (cursor: PathCursor) => void): PathCursor;
  77125. }
  77126. }
  77127. declare module BABYLON {
  77128. /** @hidden */
  77129. export var blurPixelShader: {
  77130. name: string;
  77131. shader: string;
  77132. };
  77133. }
  77134. declare module BABYLON {
  77135. /** @hidden */
  77136. export var pointCloudVertexDeclaration: {
  77137. name: string;
  77138. shader: string;
  77139. };
  77140. }
  77141. // Mixins
  77142. interface Window {
  77143. mozIndexedDB: IDBFactory;
  77144. webkitIndexedDB: IDBFactory;
  77145. msIndexedDB: IDBFactory;
  77146. webkitURL: typeof URL;
  77147. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  77148. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  77149. WebGLRenderingContext: WebGLRenderingContext;
  77150. MSGesture: MSGesture;
  77151. CANNON: any;
  77152. AudioContext: AudioContext;
  77153. webkitAudioContext: AudioContext;
  77154. PointerEvent: any;
  77155. Math: Math;
  77156. Uint8Array: Uint8ArrayConstructor;
  77157. Float32Array: Float32ArrayConstructor;
  77158. mozURL: typeof URL;
  77159. msURL: typeof URL;
  77160. VRFrameData: any; // WebVR, from specs 1.1
  77161. DracoDecoderModule: any;
  77162. setImmediate(handler: (...args: any[]) => void): number;
  77163. }
  77164. interface HTMLCanvasElement {
  77165. requestPointerLock(): void;
  77166. msRequestPointerLock?(): void;
  77167. mozRequestPointerLock?(): void;
  77168. webkitRequestPointerLock?(): void;
  77169. /** Track wether a record is in progress */
  77170. isRecording: boolean;
  77171. /** Capture Stream method defined by some browsers */
  77172. captureStream(fps?: number): MediaStream;
  77173. }
  77174. interface CanvasRenderingContext2D {
  77175. msImageSmoothingEnabled: boolean;
  77176. }
  77177. interface MouseEvent {
  77178. mozMovementX: number;
  77179. mozMovementY: number;
  77180. webkitMovementX: number;
  77181. webkitMovementY: number;
  77182. msMovementX: number;
  77183. msMovementY: number;
  77184. }
  77185. interface Navigator {
  77186. mozGetVRDevices: (any: any) => any;
  77187. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  77188. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  77189. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  77190. webkitGetGamepads(): Gamepad[];
  77191. msGetGamepads(): Gamepad[];
  77192. webkitGamepads(): Gamepad[];
  77193. }
  77194. interface HTMLVideoElement {
  77195. mozSrcObject: any;
  77196. }
  77197. interface Math {
  77198. fround(x: number): number;
  77199. imul(a: number, b: number): number;
  77200. }
  77201. interface WebGLRenderingContext {
  77202. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  77203. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  77204. vertexAttribDivisor(index: number, divisor: number): void;
  77205. createVertexArray(): any;
  77206. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  77207. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  77208. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  77209. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  77210. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  77211. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  77212. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  77213. // Queries
  77214. createQuery(): WebGLQuery;
  77215. deleteQuery(query: WebGLQuery): void;
  77216. beginQuery(target: number, query: WebGLQuery): void;
  77217. endQuery(target: number): void;
  77218. getQueryParameter(query: WebGLQuery, pname: number): any;
  77219. getQuery(target: number, pname: number): any;
  77220. MAX_SAMPLES: number;
  77221. RGBA8: number;
  77222. READ_FRAMEBUFFER: number;
  77223. DRAW_FRAMEBUFFER: number;
  77224. UNIFORM_BUFFER: number;
  77225. HALF_FLOAT_OES: number;
  77226. RGBA16F: number;
  77227. RGBA32F: number;
  77228. R32F: number;
  77229. RG32F: number;
  77230. RGB32F: number;
  77231. R16F: number;
  77232. RG16F: number;
  77233. RGB16F: number;
  77234. RED: number;
  77235. RG: number;
  77236. R8: number;
  77237. RG8: number;
  77238. UNSIGNED_INT_24_8: number;
  77239. DEPTH24_STENCIL8: number;
  77240. MIN: number;
  77241. MAX: number;
  77242. /* Multiple Render Targets */
  77243. drawBuffers(buffers: number[]): void;
  77244. readBuffer(src: number): void;
  77245. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  77246. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  77247. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  77248. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  77249. // Occlusion Query
  77250. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  77251. ANY_SAMPLES_PASSED: number;
  77252. QUERY_RESULT_AVAILABLE: number;
  77253. QUERY_RESULT: number;
  77254. }
  77255. interface WebGLProgram {
  77256. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  77257. }
  77258. interface EXT_disjoint_timer_query {
  77259. QUERY_COUNTER_BITS_EXT: number;
  77260. TIME_ELAPSED_EXT: number;
  77261. TIMESTAMP_EXT: number;
  77262. GPU_DISJOINT_EXT: number;
  77263. QUERY_RESULT_EXT: number;
  77264. QUERY_RESULT_AVAILABLE_EXT: number;
  77265. queryCounterEXT(query: WebGLQuery, target: number): void;
  77266. createQueryEXT(): WebGLQuery;
  77267. beginQueryEXT(target: number, query: WebGLQuery): void;
  77268. endQueryEXT(target: number): void;
  77269. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  77270. deleteQueryEXT(query: WebGLQuery): void;
  77271. }
  77272. interface WebGLUniformLocation {
  77273. _currentState: any;
  77274. }
  77275. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  77276. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  77277. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  77278. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  77279. interface WebGLRenderingContext {
  77280. readonly RASTERIZER_DISCARD: number;
  77281. readonly DEPTH_COMPONENT24: number;
  77282. readonly TEXTURE_3D: number;
  77283. readonly TEXTURE_2D_ARRAY: number;
  77284. readonly TEXTURE_COMPARE_FUNC: number;
  77285. readonly TEXTURE_COMPARE_MODE: number;
  77286. readonly COMPARE_REF_TO_TEXTURE: number;
  77287. readonly TEXTURE_WRAP_R: number;
  77288. readonly HALF_FLOAT: number;
  77289. readonly RGB8: number;
  77290. readonly RED_INTEGER: number;
  77291. readonly RG_INTEGER: number;
  77292. readonly RGB_INTEGER: number;
  77293. readonly RGBA_INTEGER: number;
  77294. readonly R8_SNORM: number;
  77295. readonly RG8_SNORM: number;
  77296. readonly RGB8_SNORM: number;
  77297. readonly RGBA8_SNORM: number;
  77298. readonly R8I: number;
  77299. readonly RG8I: number;
  77300. readonly RGB8I: number;
  77301. readonly RGBA8I: number;
  77302. readonly R8UI: number;
  77303. readonly RG8UI: number;
  77304. readonly RGB8UI: number;
  77305. readonly RGBA8UI: number;
  77306. readonly R16I: number;
  77307. readonly RG16I: number;
  77308. readonly RGB16I: number;
  77309. readonly RGBA16I: number;
  77310. readonly R16UI: number;
  77311. readonly RG16UI: number;
  77312. readonly RGB16UI: number;
  77313. readonly RGBA16UI: number;
  77314. readonly R32I: number;
  77315. readonly RG32I: number;
  77316. readonly RGB32I: number;
  77317. readonly RGBA32I: number;
  77318. readonly R32UI: number;
  77319. readonly RG32UI: number;
  77320. readonly RGB32UI: number;
  77321. readonly RGBA32UI: number;
  77322. readonly RGB10_A2UI: number;
  77323. readonly R11F_G11F_B10F: number;
  77324. readonly RGB9_E5: number;
  77325. readonly RGB10_A2: number;
  77326. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  77327. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  77328. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  77329. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  77330. readonly DEPTH_COMPONENT32F: number;
  77331. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  77332. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  77333. 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;
  77334. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  77335. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  77336. readonly TRANSFORM_FEEDBACK: number;
  77337. readonly INTERLEAVED_ATTRIBS: number;
  77338. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  77339. createTransformFeedback(): WebGLTransformFeedback;
  77340. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  77341. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  77342. beginTransformFeedback(primitiveMode: number): void;
  77343. endTransformFeedback(): void;
  77344. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  77345. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  77346. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  77347. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  77348. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  77349. }
  77350. interface ImageBitmap {
  77351. readonly width: number;
  77352. readonly height: number;
  77353. close(): void;
  77354. }
  77355. interface WebGLQuery extends WebGLObject {
  77356. }
  77357. declare var WebGLQuery: {
  77358. prototype: WebGLQuery;
  77359. new(): WebGLQuery;
  77360. };
  77361. interface WebGLSampler extends WebGLObject {
  77362. }
  77363. declare var WebGLSampler: {
  77364. prototype: WebGLSampler;
  77365. new(): WebGLSampler;
  77366. };
  77367. interface WebGLSync extends WebGLObject {
  77368. }
  77369. declare var WebGLSync: {
  77370. prototype: WebGLSync;
  77371. new(): WebGLSync;
  77372. };
  77373. interface WebGLTransformFeedback extends WebGLObject {
  77374. }
  77375. declare var WebGLTransformFeedback: {
  77376. prototype: WebGLTransformFeedback;
  77377. new(): WebGLTransformFeedback;
  77378. };
  77379. interface WebGLVertexArrayObject extends WebGLObject {
  77380. }
  77381. declare var WebGLVertexArrayObject: {
  77382. prototype: WebGLVertexArrayObject;
  77383. new(): WebGLVertexArrayObject;
  77384. };
  77385. // Type definitions for WebVR API
  77386. // Project: https://w3c.github.io/webvr/
  77387. // Definitions by: six a <https://github.com/lostfictions>
  77388. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  77389. interface VRDisplay extends EventTarget {
  77390. /**
  77391. * Dictionary of capabilities describing the VRDisplay.
  77392. */
  77393. readonly capabilities: VRDisplayCapabilities;
  77394. /**
  77395. * z-depth defining the far plane of the eye view frustum
  77396. * enables mapping of values in the render target depth
  77397. * attachment to scene coordinates. Initially set to 10000.0.
  77398. */
  77399. depthFar: number;
  77400. /**
  77401. * z-depth defining the near plane of the eye view frustum
  77402. * enables mapping of values in the render target depth
  77403. * attachment to scene coordinates. Initially set to 0.01.
  77404. */
  77405. depthNear: number;
  77406. /**
  77407. * An identifier for this distinct VRDisplay. Used as an
  77408. * association point in the Gamepad API.
  77409. */
  77410. readonly displayId: number;
  77411. /**
  77412. * A display name, a user-readable name identifying it.
  77413. */
  77414. readonly displayName: string;
  77415. readonly isConnected: boolean;
  77416. readonly isPresenting: boolean;
  77417. /**
  77418. * If this VRDisplay supports room-scale experiences, the optional
  77419. * stage attribute contains details on the room-scale parameters.
  77420. */
  77421. readonly stageParameters: VRStageParameters | null;
  77422. /**
  77423. * Passing the value returned by `requestAnimationFrame` to
  77424. * `cancelAnimationFrame` will unregister the callback.
  77425. * @param handle Define the hanle of the request to cancel
  77426. */
  77427. cancelAnimationFrame(handle: number): void;
  77428. /**
  77429. * Stops presenting to the VRDisplay.
  77430. * @returns a promise to know when it stopped
  77431. */
  77432. exitPresent(): Promise<void>;
  77433. /**
  77434. * Return the current VREyeParameters for the given eye.
  77435. * @param whichEye Define the eye we want the parameter for
  77436. * @returns the eye parameters
  77437. */
  77438. getEyeParameters(whichEye: string): VREyeParameters;
  77439. /**
  77440. * Populates the passed VRFrameData with the information required to render
  77441. * the current frame.
  77442. * @param frameData Define the data structure to populate
  77443. * @returns true if ok otherwise false
  77444. */
  77445. getFrameData(frameData: VRFrameData): boolean;
  77446. /**
  77447. * Get the layers currently being presented.
  77448. * @returns the list of VR layers
  77449. */
  77450. getLayers(): VRLayer[];
  77451. /**
  77452. * Return a VRPose containing the future predicted pose of the VRDisplay
  77453. * when the current frame will be presented. The value returned will not
  77454. * change until JavaScript has returned control to the browser.
  77455. *
  77456. * The VRPose will contain the position, orientation, velocity,
  77457. * and acceleration of each of these properties.
  77458. * @returns the pose object
  77459. */
  77460. getPose(): VRPose;
  77461. /**
  77462. * Return the current instantaneous pose of the VRDisplay, with no
  77463. * prediction applied.
  77464. * @returns the current instantaneous pose
  77465. */
  77466. getImmediatePose(): VRPose;
  77467. /**
  77468. * The callback passed to `requestAnimationFrame` will be called
  77469. * any time a new frame should be rendered. When the VRDisplay is
  77470. * presenting the callback will be called at the native refresh
  77471. * rate of the HMD. When not presenting this function acts
  77472. * identically to how window.requestAnimationFrame acts. Content should
  77473. * make no assumptions of frame rate or vsync behavior as the HMD runs
  77474. * asynchronously from other displays and at differing refresh rates.
  77475. * @param callback Define the eaction to run next frame
  77476. * @returns the request handle it
  77477. */
  77478. requestAnimationFrame(callback: FrameRequestCallback): number;
  77479. /**
  77480. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  77481. * Repeat calls while already presenting will update the VRLayers being displayed.
  77482. * @param layers Define the list of layer to present
  77483. * @returns a promise to know when the request has been fulfilled
  77484. */
  77485. requestPresent(layers: VRLayer[]): Promise<void>;
  77486. /**
  77487. * Reset the pose for this display, treating its current position and
  77488. * orientation as the "origin/zero" values. VRPose.position,
  77489. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  77490. * updated when calling resetPose(). This should be called in only
  77491. * sitting-space experiences.
  77492. */
  77493. resetPose(): void;
  77494. /**
  77495. * The VRLayer provided to the VRDisplay will be captured and presented
  77496. * in the HMD. Calling this function has the same effect on the source
  77497. * canvas as any other operation that uses its source image, and canvases
  77498. * created without preserveDrawingBuffer set to true will be cleared.
  77499. * @param pose Define the pose to submit
  77500. */
  77501. submitFrame(pose?: VRPose): void;
  77502. }
  77503. declare var VRDisplay: {
  77504. prototype: VRDisplay;
  77505. new(): VRDisplay;
  77506. };
  77507. interface VRLayer {
  77508. leftBounds?: number[] | Float32Array | null;
  77509. rightBounds?: number[] | Float32Array | null;
  77510. source?: HTMLCanvasElement | null;
  77511. }
  77512. interface VRDisplayCapabilities {
  77513. readonly canPresent: boolean;
  77514. readonly hasExternalDisplay: boolean;
  77515. readonly hasOrientation: boolean;
  77516. readonly hasPosition: boolean;
  77517. readonly maxLayers: number;
  77518. }
  77519. interface VREyeParameters {
  77520. /** @deprecated */
  77521. readonly fieldOfView: VRFieldOfView;
  77522. readonly offset: Float32Array;
  77523. readonly renderHeight: number;
  77524. readonly renderWidth: number;
  77525. }
  77526. interface VRFieldOfView {
  77527. readonly downDegrees: number;
  77528. readonly leftDegrees: number;
  77529. readonly rightDegrees: number;
  77530. readonly upDegrees: number;
  77531. }
  77532. interface VRFrameData {
  77533. readonly leftProjectionMatrix: Float32Array;
  77534. readonly leftViewMatrix: Float32Array;
  77535. readonly pose: VRPose;
  77536. readonly rightProjectionMatrix: Float32Array;
  77537. readonly rightViewMatrix: Float32Array;
  77538. readonly timestamp: number;
  77539. }
  77540. interface VRPose {
  77541. readonly angularAcceleration: Float32Array | null;
  77542. readonly angularVelocity: Float32Array | null;
  77543. readonly linearAcceleration: Float32Array | null;
  77544. readonly linearVelocity: Float32Array | null;
  77545. readonly orientation: Float32Array | null;
  77546. readonly position: Float32Array | null;
  77547. readonly timestamp: number;
  77548. }
  77549. interface VRStageParameters {
  77550. sittingToStandingTransform?: Float32Array;
  77551. sizeX?: number;
  77552. sizeY?: number;
  77553. }
  77554. interface Navigator {
  77555. getVRDisplays(): Promise<VRDisplay[]>;
  77556. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  77557. }
  77558. interface Window {
  77559. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  77560. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  77561. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  77562. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  77563. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  77564. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  77565. }
  77566. interface Gamepad {
  77567. readonly displayId: number;
  77568. }
  77569. /**
  77570. * Available session modes
  77571. */
  77572. type XRSessionMode = "inline" | "immersive-vr" | "immersive-ar";
  77573. /**
  77574. * Reference space types
  77575. */
  77576. type XRReferenceSpaceType = "viewer" | "local" | "local-floor" | "bounded-floor" | "unbounded";
  77577. type XREnvironmentBlendMode = "opaque" | "additive" | "alpha-blend";
  77578. type XRVisibilityState = "visible" | "visible-blurred" | "hidden";
  77579. /**
  77580. * Handedness types
  77581. */
  77582. type XRHandedness = "none" | "left" | "right";
  77583. /**
  77584. * InputSource target ray modes
  77585. */
  77586. type XRTargetRayMode = "gaze" | "tracked-pointer" | "screen";
  77587. /**
  77588. * Eye types
  77589. */
  77590. type XREye = "none" | "left" | "right";
  77591. /**
  77592. * Type of XR events available
  77593. */
  77594. type XREventType = "devicechange" | "visibilitychange" | "end" | "inputsourceschange" | "select" | "selectstart" | "selectend" | "squeeze" | "squeezestart" | "squeezeend" | "reset";
  77595. type XRFrameRequestCallback = (time: DOMHighResTimeStamp, frame: XRFrame) => void;
  77596. type XRPlaneSet = Set<XRPlane>;
  77597. type XRAnchorSet = Set<XRAnchor>;
  77598. type XREventHandler = (callback: any) => void;
  77599. interface XRLayer extends EventTarget {}
  77600. interface XRSessionInit {
  77601. optionalFeatures?: string[];
  77602. requiredFeatures?: string[];
  77603. }
  77604. interface XRSessionEvent extends Event {
  77605. readonly session: XRSession;
  77606. }
  77607. interface XRSystem {
  77608. isSessionSupported: (sessionMode: XRSessionMode) => Promise<boolean>;
  77609. requestSession: (sessionMode: XRSessionMode, sessionInit?: any) => Promise<XRSession>;
  77610. }
  77611. interface XRViewport {
  77612. readonly x: number;
  77613. readonly y: number;
  77614. readonly width: number;
  77615. readonly height: number;
  77616. }
  77617. interface XRWebGLLayerInit {
  77618. antialias?: boolean;
  77619. depth?: boolean;
  77620. stencil?: boolean;
  77621. alpha?: boolean;
  77622. multiview?: boolean;
  77623. framebufferScaleFactor?: number;
  77624. }
  77625. declare class XRWebGLLayer {
  77626. static getNativeFramebufferScaleFactor(session: XRSession): number;
  77627. constructor(session: XRSession, context: WebGLRenderingContext | WebGL2RenderingContext, layerInit?: XRWebGLLayerInit);
  77628. readonly antialias: boolean;
  77629. readonly framebuffer: WebGLFramebuffer;
  77630. readonly framebufferWidth: number;
  77631. readonly framebufferHeight: number;
  77632. readonly ignoreDepthValues: boolean;
  77633. getViewport: (view: XRView) => XRViewport;
  77634. }
  77635. // tslint:disable-next-line no-empty-interface
  77636. interface XRSpace extends EventTarget {}
  77637. interface XRRenderState {
  77638. readonly baseLayer?: XRWebGLLayer;
  77639. readonly depthFar: number;
  77640. readonly depthNear: number;
  77641. readonly inlineVerticalFieldOfView?: number;
  77642. }
  77643. interface XRRenderStateInit extends XRRenderState {
  77644. baseLayer: XRWebGLLayer;
  77645. depthFar: number;
  77646. depthNear: number;
  77647. inlineVerticalFieldOfView?: number;
  77648. layers?: XRLayer[];
  77649. }
  77650. interface XRReferenceSpace extends XRSpace {
  77651. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  77652. onreset: XREventHandler;
  77653. }
  77654. interface XRBoundedReferenceSpace extends XRSpace {
  77655. readonly boundsGeometry: DOMPointReadOnly[];
  77656. }
  77657. interface XRInputSource {
  77658. readonly handedness: XRHandedness;
  77659. readonly targetRayMode: XRTargetRayMode;
  77660. readonly targetRaySpace: XRSpace;
  77661. readonly gripSpace?: XRSpace;
  77662. readonly gamepad?: Gamepad;
  77663. readonly profiles: Array<string>;
  77664. readonly hand?: XRHand;
  77665. }
  77666. interface XRPose {
  77667. readonly transform: XRRigidTransform;
  77668. readonly emulatedPosition: boolean;
  77669. }
  77670. interface XRFrame {
  77671. readonly session: XRSession;
  77672. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  77673. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  77674. // AR
  77675. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult>;
  77676. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  77677. // Anchors
  77678. trackedAnchors?: XRAnchorSet;
  77679. createAnchor?(pose: XRRigidTransform, space: XRSpace): Promise<XRAnchor>;
  77680. // Planes
  77681. worldInformation?: {
  77682. detectedPlanes?: XRPlaneSet;
  77683. };
  77684. // Hand tracking
  77685. getJointPose?(joint: XRJointSpace, baseSpace: XRSpace): XRJointPose;
  77686. }
  77687. interface XRInputSourceEvent extends Event {
  77688. readonly frame: XRFrame;
  77689. readonly inputSource: XRInputSource;
  77690. }
  77691. type XRInputSourceArray = XRInputSource[];
  77692. interface XRSession {
  77693. addEventListener(type: XREventType, listener: XREventHandler, options?: boolean | AddEventListenerOptions): void;
  77694. removeEventListener(type: XREventType, listener: XREventHandler, options?: boolean | EventListenerOptions): void;
  77695. /**
  77696. * Returns a list of this session's XRInputSources, each representing an input device
  77697. * used to control the camera and/or scene.
  77698. */
  77699. readonly inputSources: Array<XRInputSource>;
  77700. /**
  77701. * object which contains options affecting how the imagery is rendered.
  77702. * This includes things such as the near and far clipping planes
  77703. */
  77704. readonly renderState: XRRenderState;
  77705. readonly visibilityState: XRVisibilityState;
  77706. /**
  77707. * Removes a callback from the animation frame painting callback from
  77708. * XRSession's set of animation frame rendering callbacks, given the
  77709. * identifying handle returned by a previous call to requestAnimationFrame().
  77710. */
  77711. cancelAnimationFrame: (handle: number) => void;
  77712. /**
  77713. * Ends the WebXR session. Returns a promise which resolves when the
  77714. * session has been shut down.
  77715. */
  77716. end(): Promise<void>;
  77717. /**
  77718. * Schedules the specified method to be called the next time the user agent
  77719. * is working on rendering an animation frame for the WebXR device. Returns an
  77720. * integer value which can be used to identify the request for the purposes of
  77721. * canceling the callback using cancelAnimationFrame(). This method is comparable
  77722. * to the Window.requestAnimationFrame() method.
  77723. */
  77724. requestAnimationFrame: XRFrameRequestCallback;
  77725. /**
  77726. * Requests that a new XRReferenceSpace of the specified type be created.
  77727. * Returns a promise which resolves with the XRReferenceSpace or
  77728. * XRBoundedReferenceSpace which was requested, or throws a NotSupportedError if
  77729. * the requested space type isn't supported by the device.
  77730. */
  77731. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace | XRBoundedReferenceSpace>;
  77732. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  77733. onend: XREventHandler;
  77734. oninputsourceschange: XREventHandler;
  77735. onselect: XREventHandler;
  77736. onselectstart: XREventHandler;
  77737. onselectend: XREventHandler;
  77738. onsqueeze: XREventHandler;
  77739. onsqueezestart: XREventHandler;
  77740. onsqueezeend: XREventHandler;
  77741. onvisibilitychange: XREventHandler;
  77742. // hit test
  77743. requestHitTestSource?(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  77744. requestHitTestSourceForTransientInput?(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  77745. // legacy AR hit test
  77746. requestHitTest?(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  77747. // legacy plane detection
  77748. updateWorldTrackingState?(options: { planeDetectionState?: { enabled: boolean } }): void;
  77749. }
  77750. interface XRViewerPose extends XRPose {
  77751. readonly views: Array<XRView>;
  77752. }
  77753. declare class XRRigidTransform {
  77754. constructor(position?: DOMPointInit, direction?: DOMPointInit);
  77755. position: DOMPointReadOnly;
  77756. orientation: DOMPointReadOnly;
  77757. matrix: Float32Array;
  77758. inverse: XRRigidTransform;
  77759. }
  77760. interface XRView {
  77761. readonly eye: XREye;
  77762. readonly projectionMatrix: Float32Array;
  77763. readonly transform: XRRigidTransform;
  77764. readonly recommendedViewportScale?: number;
  77765. requestViewportScale(scale: number): void;
  77766. }
  77767. interface XRInputSourceChangeEvent extends Event {
  77768. session: XRSession;
  77769. removed: Array<XRInputSource>;
  77770. added: Array<XRInputSource>;
  77771. }
  77772. // Experimental/Draft features
  77773. declare class XRRay {
  77774. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  77775. origin: DOMPointReadOnly;
  77776. direction: DOMPointReadOnly;
  77777. matrix: Float32Array;
  77778. }
  77779. declare enum XRHitTestTrackableType {
  77780. "point",
  77781. "plane",
  77782. "mesh",
  77783. }
  77784. interface XRHitResult {
  77785. hitMatrix: Float32Array;
  77786. }
  77787. interface XRTransientInputHitTestResult {
  77788. readonly inputSource: XRInputSource;
  77789. readonly results: Array<XRHitTestResult>;
  77790. }
  77791. interface XRHitTestResult {
  77792. getPose(baseSpace: XRSpace): XRPose | undefined;
  77793. // When anchor system is enabled
  77794. createAnchor?(pose: XRRigidTransform): Promise<XRAnchor>;
  77795. }
  77796. interface XRHitTestSource {
  77797. cancel(): void;
  77798. }
  77799. interface XRTransientInputHitTestSource {
  77800. cancel(): void;
  77801. }
  77802. interface XRHitTestOptionsInit {
  77803. space: XRSpace;
  77804. entityTypes?: Array<XRHitTestTrackableType>;
  77805. offsetRay?: XRRay;
  77806. }
  77807. interface XRTransientInputHitTestOptionsInit {
  77808. profile: string;
  77809. entityTypes?: Array<XRHitTestTrackableType>;
  77810. offsetRay?: XRRay;
  77811. }
  77812. interface XRAnchor {
  77813. anchorSpace: XRSpace;
  77814. delete(): void;
  77815. }
  77816. interface XRPlane {
  77817. orientation: "Horizontal" | "Vertical";
  77818. planeSpace: XRSpace;
  77819. polygon: Array<DOMPointReadOnly>;
  77820. lastChangedTime: number;
  77821. }
  77822. interface XRJointSpace extends XRSpace {}
  77823. interface XRJointPose extends XRPose {
  77824. radius: number | undefined;
  77825. }
  77826. interface XRHand extends Iterable<XRJointSpace> {
  77827. readonly length: number;
  77828. [index: number]: XRJointSpace;
  77829. readonly WRIST: number;
  77830. readonly THUMB_METACARPAL: number;
  77831. readonly THUMB_PHALANX_PROXIMAL: number;
  77832. readonly THUMB_PHALANX_DISTAL: number;
  77833. readonly THUMB_PHALANX_TIP: number;
  77834. readonly INDEX_METACARPAL: number;
  77835. readonly INDEX_PHALANX_PROXIMAL: number;
  77836. readonly INDEX_PHALANX_INTERMEDIATE: number;
  77837. readonly INDEX_PHALANX_DISTAL: number;
  77838. readonly INDEX_PHALANX_TIP: number;
  77839. readonly MIDDLE_METACARPAL: number;
  77840. readonly MIDDLE_PHALANX_PROXIMAL: number;
  77841. readonly MIDDLE_PHALANX_INTERMEDIATE: number;
  77842. readonly MIDDLE_PHALANX_DISTAL: number;
  77843. readonly MIDDLE_PHALANX_TIP: number;
  77844. readonly RING_METACARPAL: number;
  77845. readonly RING_PHALANX_PROXIMAL: number;
  77846. readonly RING_PHALANX_INTERMEDIATE: number;
  77847. readonly RING_PHALANX_DISTAL: number;
  77848. readonly RING_PHALANX_TIP: number;
  77849. readonly LITTLE_METACARPAL: number;
  77850. readonly LITTLE_PHALANX_PROXIMAL: number;
  77851. readonly LITTLE_PHALANX_INTERMEDIATE: number;
  77852. readonly LITTLE_PHALANX_DISTAL: number;
  77853. readonly LITTLE_PHALANX_TIP: number;
  77854. }
  77855. // This file contains native only extensions for WebXR These APIs are not supported in the browser yet.
  77856. // They are intended for use with either Babylon Native https://github.com/BabylonJS/BabylonNative or
  77857. // Babylon React Native: https://github.com/BabylonJS/BabylonReactNative
  77858. interface XRSession {
  77859. trySetFeaturePointCloudEnabled(enabled: boolean): boolean;
  77860. }
  77861. interface XRFrame {
  77862. featurePointCloud? : Array<number>;
  77863. }
  77864. /**
  77865. * @ignore
  77866. */
  77867. declare module BABYLON.GLTF2.Exporter {
  77868. }
  77869. /**
  77870. * @ignore
  77871. */
  77872. declare module BABYLON.GLTF1 {
  77873. }
  77874. declare module BABYLON.GUI {
  77875. /**
  77876. * Class used to specific a value and its associated unit
  77877. */
  77878. export class ValueAndUnit {
  77879. /** defines the unit to store */
  77880. unit: number;
  77881. /** defines a boolean indicating if the value can be negative */
  77882. negativeValueAllowed: boolean;
  77883. private _value;
  77884. private _originalUnit;
  77885. /**
  77886. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  77887. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  77888. */
  77889. ignoreAdaptiveScaling: boolean;
  77890. /**
  77891. * Creates a new ValueAndUnit
  77892. * @param value defines the value to store
  77893. * @param unit defines the unit to store
  77894. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  77895. */
  77896. constructor(value: number,
  77897. /** defines the unit to store */
  77898. unit?: number,
  77899. /** defines a boolean indicating if the value can be negative */
  77900. negativeValueAllowed?: boolean);
  77901. /** Gets a boolean indicating if the value is a percentage */
  77902. get isPercentage(): boolean;
  77903. /** Gets a boolean indicating if the value is store as pixel */
  77904. get isPixel(): boolean;
  77905. /** Gets direct internal value */
  77906. get internalValue(): number;
  77907. /**
  77908. * Gets value as pixel
  77909. * @param host defines the root host
  77910. * @param refValue defines the reference value for percentages
  77911. * @returns the value as pixel
  77912. */
  77913. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  77914. /**
  77915. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  77916. * @param value defines the value to store
  77917. * @param unit defines the unit to store
  77918. * @returns the current ValueAndUnit
  77919. */
  77920. updateInPlace(value: number, unit?: number): ValueAndUnit;
  77921. /**
  77922. * Gets the value accordingly to its unit
  77923. * @param host defines the root host
  77924. * @returns the value
  77925. */
  77926. getValue(host: AdvancedDynamicTexture): number;
  77927. /**
  77928. * Gets a string representation of the value
  77929. * @param host defines the root host
  77930. * @param decimals defines an optional number of decimals to display
  77931. * @returns a string
  77932. */
  77933. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  77934. /**
  77935. * Store a value parsed from a string
  77936. * @param source defines the source string
  77937. * @returns true if the value was successfully parsed
  77938. */
  77939. fromString(source: string | number): boolean;
  77940. private static _Regex;
  77941. private static _UNITMODE_PERCENTAGE;
  77942. private static _UNITMODE_PIXEL;
  77943. /** UNITMODE_PERCENTAGE */
  77944. static get UNITMODE_PERCENTAGE(): number;
  77945. /** UNITMODE_PIXEL */
  77946. static get UNITMODE_PIXEL(): number;
  77947. }
  77948. }
  77949. declare module BABYLON.GUI {
  77950. /**
  77951. * Define a style used by control to automatically setup properties based on a template.
  77952. * Only support font related properties so far
  77953. */
  77954. export class Style implements BABYLON.IDisposable {
  77955. private _fontFamily;
  77956. private _fontStyle;
  77957. private _fontWeight;
  77958. /** @hidden */
  77959. _host: AdvancedDynamicTexture;
  77960. /** @hidden */
  77961. _fontSize: ValueAndUnit;
  77962. /**
  77963. * BABYLON.Observable raised when the style values are changed
  77964. */
  77965. onChangedObservable: BABYLON.Observable<Style>;
  77966. /**
  77967. * Creates a new style object
  77968. * @param host defines the AdvancedDynamicTexture which hosts this style
  77969. */
  77970. constructor(host: AdvancedDynamicTexture);
  77971. /**
  77972. * Gets or sets the font size
  77973. */
  77974. get fontSize(): string | number;
  77975. set fontSize(value: string | number);
  77976. /**
  77977. * Gets or sets the font family
  77978. */
  77979. get fontFamily(): string;
  77980. set fontFamily(value: string);
  77981. /**
  77982. * Gets or sets the font style
  77983. */
  77984. get fontStyle(): string;
  77985. set fontStyle(value: string);
  77986. /** Gets or sets font weight */
  77987. get fontWeight(): string;
  77988. set fontWeight(value: string);
  77989. /** Dispose all associated resources */
  77990. dispose(): void;
  77991. }
  77992. }
  77993. declare module BABYLON.GUI {
  77994. /**
  77995. * Class used to transport BABYLON.Vector2 information for pointer events
  77996. */
  77997. export class Vector2WithInfo extends BABYLON.Vector2 {
  77998. /** defines the current mouse button index */
  77999. buttonIndex: number;
  78000. /**
  78001. * Creates a new Vector2WithInfo
  78002. * @param source defines the vector2 data to transport
  78003. * @param buttonIndex defines the current mouse button index
  78004. */
  78005. constructor(source: BABYLON.Vector2,
  78006. /** defines the current mouse button index */
  78007. buttonIndex?: number);
  78008. }
  78009. /** Class used to provide 2D matrix features */
  78010. export class Matrix2D {
  78011. /** Gets the internal array of 6 floats used to store matrix data */
  78012. m: Float32Array;
  78013. /**
  78014. * Creates a new matrix
  78015. * @param m00 defines value for (0, 0)
  78016. * @param m01 defines value for (0, 1)
  78017. * @param m10 defines value for (1, 0)
  78018. * @param m11 defines value for (1, 1)
  78019. * @param m20 defines value for (2, 0)
  78020. * @param m21 defines value for (2, 1)
  78021. */
  78022. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  78023. /**
  78024. * Fills the matrix from direct values
  78025. * @param m00 defines value for (0, 0)
  78026. * @param m01 defines value for (0, 1)
  78027. * @param m10 defines value for (1, 0)
  78028. * @param m11 defines value for (1, 1)
  78029. * @param m20 defines value for (2, 0)
  78030. * @param m21 defines value for (2, 1)
  78031. * @returns the current modified matrix
  78032. */
  78033. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  78034. /**
  78035. * Gets matrix determinant
  78036. * @returns the determinant
  78037. */
  78038. determinant(): number;
  78039. /**
  78040. * Inverses the matrix and stores it in a target matrix
  78041. * @param result defines the target matrix
  78042. * @returns the current matrix
  78043. */
  78044. invertToRef(result: Matrix2D): Matrix2D;
  78045. /**
  78046. * Multiplies the current matrix with another one
  78047. * @param other defines the second operand
  78048. * @param result defines the target matrix
  78049. * @returns the current matrix
  78050. */
  78051. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  78052. /**
  78053. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  78054. * @param x defines the x coordinate to transform
  78055. * @param y defines the x coordinate to transform
  78056. * @param result defines the target vector2
  78057. * @returns the current matrix
  78058. */
  78059. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  78060. /**
  78061. * Creates an identity matrix
  78062. * @returns a new matrix
  78063. */
  78064. static Identity(): Matrix2D;
  78065. /**
  78066. * Creates a translation matrix and stores it in a target matrix
  78067. * @param x defines the x coordinate of the translation
  78068. * @param y defines the y coordinate of the translation
  78069. * @param result defines the target matrix
  78070. */
  78071. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  78072. /**
  78073. * Creates a scaling matrix and stores it in a target matrix
  78074. * @param x defines the x coordinate of the scaling
  78075. * @param y defines the y coordinate of the scaling
  78076. * @param result defines the target matrix
  78077. */
  78078. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  78079. /**
  78080. * Creates a rotation matrix and stores it in a target matrix
  78081. * @param angle defines the rotation angle
  78082. * @param result defines the target matrix
  78083. */
  78084. static RotationToRef(angle: number, result: Matrix2D): void;
  78085. private static _TempPreTranslationMatrix;
  78086. private static _TempPostTranslationMatrix;
  78087. private static _TempRotationMatrix;
  78088. private static _TempScalingMatrix;
  78089. private static _TempCompose0;
  78090. private static _TempCompose1;
  78091. private static _TempCompose2;
  78092. /**
  78093. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  78094. * @param tx defines the x coordinate of the translation
  78095. * @param ty defines the y coordinate of the translation
  78096. * @param angle defines the rotation angle
  78097. * @param scaleX defines the x coordinate of the scaling
  78098. * @param scaleY defines the y coordinate of the scaling
  78099. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  78100. * @param result defines the target matrix
  78101. */
  78102. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  78103. }
  78104. }
  78105. declare module BABYLON.GUI {
  78106. /**
  78107. * Class used to store 2D control sizes
  78108. */
  78109. export class Measure {
  78110. /** defines left coordinate */
  78111. left: number;
  78112. /** defines top coordinate */
  78113. top: number;
  78114. /** defines width dimension */
  78115. width: number;
  78116. /** defines height dimension */
  78117. height: number;
  78118. /**
  78119. * Creates a new measure
  78120. * @param left defines left coordinate
  78121. * @param top defines top coordinate
  78122. * @param width defines width dimension
  78123. * @param height defines height dimension
  78124. */
  78125. constructor(
  78126. /** defines left coordinate */
  78127. left: number,
  78128. /** defines top coordinate */
  78129. top: number,
  78130. /** defines width dimension */
  78131. width: number,
  78132. /** defines height dimension */
  78133. height: number);
  78134. /**
  78135. * Copy from another measure
  78136. * @param other defines the other measure to copy from
  78137. */
  78138. copyFrom(other: Measure): void;
  78139. /**
  78140. * Copy from a group of 4 floats
  78141. * @param left defines left coordinate
  78142. * @param top defines top coordinate
  78143. * @param width defines width dimension
  78144. * @param height defines height dimension
  78145. */
  78146. copyFromFloats(left: number, top: number, width: number, height: number): void;
  78147. /**
  78148. * Computes the axis aligned bounding box measure for two given measures
  78149. * @param a Input measure
  78150. * @param b Input measure
  78151. * @param result the resulting bounding measure
  78152. */
  78153. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  78154. /**
  78155. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  78156. * @param transform the matrix to transform the measure before computing the AABB
  78157. * @param addX number to add to left
  78158. * @param addY number to add to top
  78159. * @param addWidth number to add to width
  78160. * @param addHeight number to add to height
  78161. * @param result the resulting AABB
  78162. */
  78163. addAndTransformToRef(transform: Matrix2D, addX: number, addY: number, addWidth: number, addHeight: number, result: Measure): void;
  78164. /**
  78165. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  78166. * @param transform the matrix to transform the measure before computing the AABB
  78167. * @param result the resulting AABB
  78168. */
  78169. transformToRef(transform: Matrix2D, result: Measure): void;
  78170. /**
  78171. * Check equality between this measure and another one
  78172. * @param other defines the other measures
  78173. * @returns true if both measures are equals
  78174. */
  78175. isEqualsTo(other: Measure): boolean;
  78176. /**
  78177. * Creates an empty measure
  78178. * @returns a new measure
  78179. */
  78180. static Empty(): Measure;
  78181. }
  78182. }
  78183. declare module BABYLON.GUI {
  78184. /**
  78185. * Interface used to define a control that can receive focus
  78186. */
  78187. export interface IFocusableControl {
  78188. /**
  78189. * Function called when the control receives the focus
  78190. */
  78191. onFocus(): void;
  78192. /**
  78193. * Function called when the control loses the focus
  78194. */
  78195. onBlur(): void;
  78196. /**
  78197. * Function called to let the control handle keyboard events
  78198. * @param evt defines the current keyboard event
  78199. */
  78200. processKeyboard(evt: KeyboardEvent): void;
  78201. /**
  78202. * Function called to get the list of controls that should not steal the focus from this control
  78203. * @returns an array of controls
  78204. */
  78205. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  78206. }
  78207. /**
  78208. * Class used to create texture to support 2D GUI elements
  78209. * @see https://doc.babylonjs.com/how_to/gui
  78210. */
  78211. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  78212. private _isDirty;
  78213. private _renderObserver;
  78214. private _resizeObserver;
  78215. private _preKeyboardObserver;
  78216. private _pointerMoveObserver;
  78217. private _pointerObserver;
  78218. private _canvasPointerOutObserver;
  78219. private _canvasBlurObserver;
  78220. private _background;
  78221. /** @hidden */
  78222. _rootContainer: Container;
  78223. /** @hidden */
  78224. _lastPickedControl: Control;
  78225. /** @hidden */
  78226. _lastControlOver: {
  78227. [pointerId: number]: Control;
  78228. };
  78229. /** @hidden */
  78230. _lastControlDown: {
  78231. [pointerId: number]: Control;
  78232. };
  78233. /** @hidden */
  78234. _capturingControl: {
  78235. [pointerId: number]: Control;
  78236. };
  78237. /** @hidden */
  78238. _shouldBlockPointer: boolean;
  78239. /** @hidden */
  78240. _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  78241. /** @hidden */
  78242. _linkedControls: Control[];
  78243. private _isFullscreen;
  78244. private _fullscreenViewport;
  78245. private _idealWidth;
  78246. private _idealHeight;
  78247. private _useSmallestIdeal;
  78248. private _renderAtIdealSize;
  78249. private _focusedControl;
  78250. private _blockNextFocusCheck;
  78251. private _renderScale;
  78252. private _rootElement;
  78253. private _cursorChanged;
  78254. private _defaultMousePointerId;
  78255. /** @hidden */
  78256. _numLayoutCalls: number;
  78257. /** Gets the number of layout calls made the last time the ADT has been rendered */
  78258. get numLayoutCalls(): number;
  78259. /** @hidden */
  78260. _numRenderCalls: number;
  78261. /** Gets the number of render calls made the last time the ADT has been rendered */
  78262. get numRenderCalls(): number;
  78263. /**
  78264. * Define type to string to ensure compatibility across browsers
  78265. * Safari doesn't support DataTransfer constructor
  78266. */
  78267. private _clipboardData;
  78268. /**
  78269. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  78270. */
  78271. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  78272. /**
  78273. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  78274. */
  78275. onControlPickedObservable: BABYLON.Observable<Control>;
  78276. /**
  78277. * BABYLON.Observable event triggered before layout is evaluated
  78278. */
  78279. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  78280. /**
  78281. * BABYLON.Observable event triggered after the layout was evaluated
  78282. */
  78283. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  78284. /**
  78285. * BABYLON.Observable event triggered before the texture is rendered
  78286. */
  78287. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  78288. /**
  78289. * BABYLON.Observable event triggered after the texture was rendered
  78290. */
  78291. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  78292. /**
  78293. * Gets or sets a boolean defining if alpha is stored as premultiplied
  78294. */
  78295. premulAlpha: boolean;
  78296. /**
  78297. * Gets or sets a boolean indicating that the canvas must be reverted on Y when updating the texture
  78298. */
  78299. applyYInversionOnUpdate: boolean;
  78300. /**
  78301. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  78302. * Useful when you want more antialiasing
  78303. */
  78304. get renderScale(): number;
  78305. set renderScale(value: number);
  78306. /** Gets or sets the background color */
  78307. get background(): string;
  78308. set background(value: string);
  78309. /**
  78310. * Gets or sets the ideal width used to design controls.
  78311. * The GUI will then rescale everything accordingly
  78312. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  78313. */
  78314. get idealWidth(): number;
  78315. set idealWidth(value: number);
  78316. /**
  78317. * Gets or sets the ideal height used to design controls.
  78318. * The GUI will then rescale everything accordingly
  78319. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  78320. */
  78321. get idealHeight(): number;
  78322. set idealHeight(value: number);
  78323. /**
  78324. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  78325. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  78326. */
  78327. get useSmallestIdeal(): boolean;
  78328. set useSmallestIdeal(value: boolean);
  78329. /**
  78330. * Gets or sets a boolean indicating if adaptive scaling must be used
  78331. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  78332. */
  78333. get renderAtIdealSize(): boolean;
  78334. set renderAtIdealSize(value: boolean);
  78335. /**
  78336. * Gets the ratio used when in "ideal mode"
  78337. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  78338. * */
  78339. get idealRatio(): number;
  78340. /**
  78341. * Gets the underlying layer used to render the texture when in fullscreen mode
  78342. */
  78343. get layer(): BABYLON.Nullable<BABYLON.Layer>;
  78344. /**
  78345. * Gets the root container control
  78346. */
  78347. get rootContainer(): Container;
  78348. /**
  78349. * Returns an array containing the root container.
  78350. * This is mostly used to let the Inspector introspects the ADT
  78351. * @returns an array containing the rootContainer
  78352. */
  78353. getChildren(): Array<Container>;
  78354. /**
  78355. * Will return all controls that are inside this texture
  78356. * @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
  78357. * @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
  78358. * @return all child controls
  78359. */
  78360. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  78361. /**
  78362. * Gets or sets the current focused control
  78363. */
  78364. get focusedControl(): BABYLON.Nullable<IFocusableControl>;
  78365. set focusedControl(control: BABYLON.Nullable<IFocusableControl>);
  78366. /**
  78367. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  78368. */
  78369. get isForeground(): boolean;
  78370. set isForeground(value: boolean);
  78371. /**
  78372. * Gets or set information about clipboardData
  78373. */
  78374. get clipboardData(): string;
  78375. set clipboardData(value: string);
  78376. /**
  78377. * Creates a new AdvancedDynamicTexture
  78378. * @param name defines the name of the texture
  78379. * @param width defines the width of the texture
  78380. * @param height defines the height of the texture
  78381. * @param scene defines the hosting scene
  78382. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  78383. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  78384. * @param invertY defines if the texture needs to be inverted on the y axis during loading (true by default)
  78385. */
  78386. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number, invertY?: boolean);
  78387. /**
  78388. * Get the current class name of the texture useful for serialization or dynamic coding.
  78389. * @returns "AdvancedDynamicTexture"
  78390. */
  78391. getClassName(): string;
  78392. /**
  78393. * Function used to execute a function on all controls
  78394. * @param func defines the function to execute
  78395. * @param container defines the container where controls belong. If null the root container will be used
  78396. */
  78397. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  78398. private _useInvalidateRectOptimization;
  78399. /**
  78400. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  78401. */
  78402. get useInvalidateRectOptimization(): boolean;
  78403. set useInvalidateRectOptimization(value: boolean);
  78404. private _invalidatedRectangle;
  78405. /**
  78406. * Invalidates a rectangle area on the gui texture
  78407. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  78408. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  78409. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  78410. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  78411. */
  78412. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  78413. /**
  78414. * Marks the texture as dirty forcing a complete update
  78415. */
  78416. markAsDirty(): void;
  78417. /**
  78418. * Helper function used to create a new style
  78419. * @returns a new style
  78420. * @see https://doc.babylonjs.com/how_to/gui#styles
  78421. */
  78422. createStyle(): Style;
  78423. /**
  78424. * Adds a new control to the root container
  78425. * @param control defines the control to add
  78426. * @returns the current texture
  78427. */
  78428. addControl(control: Control): AdvancedDynamicTexture;
  78429. /**
  78430. * Removes a control from the root container
  78431. * @param control defines the control to remove
  78432. * @returns the current texture
  78433. */
  78434. removeControl(control: Control): AdvancedDynamicTexture;
  78435. /**
  78436. * Release all resources
  78437. */
  78438. dispose(): void;
  78439. private _onResize;
  78440. /** @hidden */
  78441. _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  78442. /**
  78443. * Get screen coordinates for a vector3
  78444. * @param position defines the position to project
  78445. * @param worldMatrix defines the world matrix to use
  78446. * @returns the projected position
  78447. */
  78448. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  78449. /**
  78450. * Get screen coordinates for a vector3
  78451. * @param position defines the position to project
  78452. * @param worldMatrix defines the world matrix to use
  78453. * @returns the projected position with Z
  78454. */
  78455. getProjectedPositionWithZ(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector3;
  78456. private _checkUpdate;
  78457. private _clearMeasure;
  78458. private _render;
  78459. /** @hidden */
  78460. _changeCursor(cursor: string): void;
  78461. /** @hidden */
  78462. _registerLastControlDown(control: Control, pointerId: number): void;
  78463. private _doPicking;
  78464. /** @hidden */
  78465. _cleanControlAfterRemovalFromList(list: {
  78466. [pointerId: number]: Control;
  78467. }, control: Control): void;
  78468. /** @hidden */
  78469. _cleanControlAfterRemoval(control: Control): void;
  78470. /** Attach to all scene events required to support pointer events */
  78471. attach(): void;
  78472. /** @hidden */
  78473. private onClipboardCopy;
  78474. /** @hidden */
  78475. private onClipboardCut;
  78476. /** @hidden */
  78477. private onClipboardPaste;
  78478. /**
  78479. * Register the clipboard Events onto the canvas
  78480. */
  78481. registerClipboardEvents(): void;
  78482. /**
  78483. * Unregister the clipboard Events from the canvas
  78484. */
  78485. unRegisterClipboardEvents(): void;
  78486. /**
  78487. * Connect the texture to a hosting mesh to enable interactions
  78488. * @param mesh defines the mesh to attach to
  78489. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  78490. */
  78491. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  78492. /**
  78493. * Move the focus to a specific control
  78494. * @param control defines the control which will receive the focus
  78495. */
  78496. moveFocusToControl(control: IFocusableControl): void;
  78497. private _manageFocus;
  78498. private _attachToOnPointerOut;
  78499. private _attachToOnBlur;
  78500. /**
  78501. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  78502. * @param mesh defines the mesh which will receive the texture
  78503. * @param width defines the texture width (1024 by default)
  78504. * @param height defines the texture height (1024 by default)
  78505. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  78506. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  78507. * @param invertY defines if the texture needs to be inverted on the y axis during loading (true by default)
  78508. * @returns a new AdvancedDynamicTexture
  78509. */
  78510. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean, invertY?: boolean): AdvancedDynamicTexture;
  78511. /**
  78512. * 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
  78513. * @param mesh defines the mesh which will receive the texture
  78514. * @param width defines the texture width (1024 by default)
  78515. * @param height defines the texture height (1024 by default)
  78516. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  78517. * @param invertY defines if the texture needs to be inverted on the y axis during loading (true by default)
  78518. * @returns a new AdvancedDynamicTexture
  78519. */
  78520. static CreateForMeshTexture(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, invertY?: boolean): AdvancedDynamicTexture;
  78521. /**
  78522. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  78523. * In this mode the texture will rely on a layer for its rendering.
  78524. * This allows it to be treated like any other layer.
  78525. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  78526. * LayerMask is set through advancedTexture.layer.layerMask
  78527. * @param name defines name for the texture
  78528. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  78529. * @param scene defines the hsoting scene
  78530. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  78531. * @returns a new AdvancedDynamicTexture
  78532. */
  78533. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  78534. }
  78535. }
  78536. declare module BABYLON.GUI {
  78537. /**
  78538. * Root class used for all 2D controls
  78539. * @see https://doc.babylonjs.com/how_to/gui#controls
  78540. */
  78541. export class Control {
  78542. /** defines the name of the control */
  78543. name?: string | undefined;
  78544. /**
  78545. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  78546. */
  78547. static AllowAlphaInheritance: boolean;
  78548. private _alpha;
  78549. private _alphaSet;
  78550. private _zIndex;
  78551. /** @hidden */
  78552. _host: AdvancedDynamicTexture;
  78553. /** Gets or sets the control parent */
  78554. parent: BABYLON.Nullable<Container>;
  78555. /** @hidden */
  78556. _currentMeasure: Measure;
  78557. private _fontFamily;
  78558. private _fontStyle;
  78559. private _fontWeight;
  78560. private _fontSize;
  78561. private _font;
  78562. /** @hidden */
  78563. _width: ValueAndUnit;
  78564. /** @hidden */
  78565. _height: ValueAndUnit;
  78566. /** @hidden */
  78567. protected _fontOffset: {
  78568. ascent: number;
  78569. height: number;
  78570. descent: number;
  78571. };
  78572. private _color;
  78573. private _style;
  78574. private _styleObserver;
  78575. /** @hidden */
  78576. protected _horizontalAlignment: number;
  78577. /** @hidden */
  78578. protected _verticalAlignment: number;
  78579. /** @hidden */
  78580. protected _isDirty: boolean;
  78581. /** @hidden */
  78582. protected _wasDirty: boolean;
  78583. /** @hidden */
  78584. _tempParentMeasure: Measure;
  78585. /** @hidden */
  78586. _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  78587. /** @hidden */
  78588. protected _cachedParentMeasure: Measure;
  78589. private _paddingLeft;
  78590. private _paddingRight;
  78591. private _paddingTop;
  78592. private _paddingBottom;
  78593. /** @hidden */
  78594. _left: ValueAndUnit;
  78595. /** @hidden */
  78596. _top: ValueAndUnit;
  78597. private _scaleX;
  78598. private _scaleY;
  78599. private _rotation;
  78600. private _transformCenterX;
  78601. private _transformCenterY;
  78602. /** @hidden */
  78603. _transformMatrix: Matrix2D;
  78604. /** @hidden */
  78605. protected _invertTransformMatrix: Matrix2D;
  78606. /** @hidden */
  78607. protected _transformedPosition: BABYLON.Vector2;
  78608. private _isMatrixDirty;
  78609. private _cachedOffsetX;
  78610. private _cachedOffsetY;
  78611. private _isVisible;
  78612. private _isHighlighted;
  78613. /** @hidden */
  78614. _linkedMesh: BABYLON.Nullable<BABYLON.TransformNode>;
  78615. private _fontSet;
  78616. private _dummyVector2;
  78617. private _downCount;
  78618. private _enterCount;
  78619. private _doNotRender;
  78620. private _downPointerIds;
  78621. protected _isEnabled: boolean;
  78622. protected _disabledColor: string;
  78623. protected _disabledColorItem: string;
  78624. /** @hidden */
  78625. protected _rebuildLayout: boolean;
  78626. /** @hidden */
  78627. _customData: any;
  78628. /** @hidden */
  78629. _isClipped: boolean;
  78630. /** @hidden */
  78631. _automaticSize: boolean;
  78632. /** @hidden */
  78633. _tag: any;
  78634. /**
  78635. * 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
  78636. */
  78637. uniqueId: number;
  78638. /**
  78639. * Gets or sets an object used to store user defined information for the node
  78640. */
  78641. metadata: any;
  78642. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  78643. isHitTestVisible: boolean;
  78644. /** Gets or sets a boolean indicating if the control can block pointer events */
  78645. isPointerBlocker: boolean;
  78646. /** Gets or sets a boolean indicating if the control can be focusable */
  78647. isFocusInvisible: boolean;
  78648. /**
  78649. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  78650. * 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
  78651. */
  78652. clipChildren: boolean;
  78653. /**
  78654. * Gets or sets a boolean indicating that control content must be clipped
  78655. * 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
  78656. */
  78657. clipContent: boolean;
  78658. /**
  78659. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  78660. */
  78661. useBitmapCache: boolean;
  78662. private _cacheData;
  78663. private _shadowOffsetX;
  78664. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  78665. get shadowOffsetX(): number;
  78666. set shadowOffsetX(value: number);
  78667. private _shadowOffsetY;
  78668. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  78669. get shadowOffsetY(): number;
  78670. set shadowOffsetY(value: number);
  78671. private _shadowBlur;
  78672. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  78673. get shadowBlur(): number;
  78674. set shadowBlur(value: number);
  78675. private _shadowColor;
  78676. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  78677. get shadowColor(): string;
  78678. set shadowColor(value: string);
  78679. /** Gets or sets the cursor to use when the control is hovered */
  78680. hoverCursor: string;
  78681. /** @hidden */
  78682. protected _linkOffsetX: ValueAndUnit;
  78683. /** @hidden */
  78684. protected _linkOffsetY: ValueAndUnit;
  78685. /** Gets the control type name */
  78686. get typeName(): string;
  78687. /**
  78688. * Get the current class name of the control.
  78689. * @returns current class name
  78690. */
  78691. getClassName(): string;
  78692. /**
  78693. * An event triggered when pointer wheel is scrolled
  78694. */
  78695. onWheelObservable: BABYLON.Observable<BABYLON.Vector2>;
  78696. /**
  78697. * An event triggered when the pointer move over the control.
  78698. */
  78699. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  78700. /**
  78701. * An event triggered when the pointer move out of the control.
  78702. */
  78703. onPointerOutObservable: BABYLON.Observable<Control>;
  78704. /**
  78705. * An event triggered when the pointer taps the control
  78706. */
  78707. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  78708. /**
  78709. * An event triggered when pointer up
  78710. */
  78711. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  78712. /**
  78713. * An event triggered when a control is clicked on
  78714. */
  78715. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  78716. /**
  78717. * An event triggered when pointer enters the control
  78718. */
  78719. onPointerEnterObservable: BABYLON.Observable<Control>;
  78720. /**
  78721. * An event triggered when the control is marked as dirty
  78722. */
  78723. onDirtyObservable: BABYLON.Observable<Control>;
  78724. /**
  78725. * An event triggered before drawing the control
  78726. */
  78727. onBeforeDrawObservable: BABYLON.Observable<Control>;
  78728. /**
  78729. * An event triggered after the control was drawn
  78730. */
  78731. onAfterDrawObservable: BABYLON.Observable<Control>;
  78732. /**
  78733. * An event triggered when the control has been disposed
  78734. */
  78735. onDisposeObservable: BABYLON.Observable<Control>;
  78736. /**
  78737. * Get the hosting AdvancedDynamicTexture
  78738. */
  78739. get host(): AdvancedDynamicTexture;
  78740. /** Gets or set information about font offsets (used to render and align text) */
  78741. get fontOffset(): {
  78742. ascent: number;
  78743. height: number;
  78744. descent: number;
  78745. };
  78746. set fontOffset(offset: {
  78747. ascent: number;
  78748. height: number;
  78749. descent: number;
  78750. });
  78751. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  78752. get alpha(): number;
  78753. set alpha(value: number);
  78754. /**
  78755. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  78756. */
  78757. get isHighlighted(): boolean;
  78758. set isHighlighted(value: boolean);
  78759. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  78760. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  78761. */
  78762. get scaleX(): number;
  78763. set scaleX(value: number);
  78764. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  78765. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  78766. */
  78767. get scaleY(): number;
  78768. set scaleY(value: number);
  78769. /** Gets or sets the rotation angle (0 by default)
  78770. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  78771. */
  78772. get rotation(): number;
  78773. set rotation(value: number);
  78774. /** Gets or sets the transformation center on Y axis (0 by default)
  78775. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  78776. */
  78777. get transformCenterY(): number;
  78778. set transformCenterY(value: number);
  78779. /** Gets or sets the transformation center on X axis (0 by default)
  78780. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  78781. */
  78782. get transformCenterX(): number;
  78783. set transformCenterX(value: number);
  78784. /**
  78785. * Gets or sets the horizontal alignment
  78786. * @see https://doc.babylonjs.com/how_to/gui#alignments
  78787. */
  78788. get horizontalAlignment(): number;
  78789. set horizontalAlignment(value: number);
  78790. /**
  78791. * Gets or sets the vertical alignment
  78792. * @see https://doc.babylonjs.com/how_to/gui#alignments
  78793. */
  78794. get verticalAlignment(): number;
  78795. set verticalAlignment(value: number);
  78796. /**
  78797. * Gets or sets a fixed ratio for this control.
  78798. * When different from 0, the ratio is used to compute the "second" dimension.
  78799. * The first dimension used in the computation is the last one set (by setting width / widthInPixels or height / heightInPixels), and the
  78800. * second dimension is computed as first dimension * fixedRatio
  78801. */
  78802. fixedRatio: number;
  78803. private _fixedRatioMasterIsWidth;
  78804. /**
  78805. * Gets or sets control width
  78806. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78807. */
  78808. get width(): string | number;
  78809. set width(value: string | number);
  78810. /**
  78811. * Gets or sets the control width in pixel
  78812. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78813. */
  78814. get widthInPixels(): number;
  78815. set widthInPixels(value: number);
  78816. /**
  78817. * Gets or sets control height
  78818. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78819. */
  78820. get height(): string | number;
  78821. set height(value: string | number);
  78822. /**
  78823. * Gets or sets control height in pixel
  78824. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78825. */
  78826. get heightInPixels(): number;
  78827. set heightInPixels(value: number);
  78828. /** Gets or set font family */
  78829. get fontFamily(): string;
  78830. set fontFamily(value: string);
  78831. /** Gets or sets font style */
  78832. get fontStyle(): string;
  78833. set fontStyle(value: string);
  78834. /** Gets or sets font weight */
  78835. get fontWeight(): string;
  78836. set fontWeight(value: string);
  78837. /**
  78838. * Gets or sets style
  78839. * @see https://doc.babylonjs.com/how_to/gui#styles
  78840. */
  78841. get style(): BABYLON.Nullable<Style>;
  78842. set style(value: BABYLON.Nullable<Style>);
  78843. /** @hidden */
  78844. get _isFontSizeInPercentage(): boolean;
  78845. /** Gets or sets font size in pixels */
  78846. get fontSizeInPixels(): number;
  78847. set fontSizeInPixels(value: number);
  78848. /** Gets or sets font size */
  78849. get fontSize(): string | number;
  78850. set fontSize(value: string | number);
  78851. /** Gets or sets foreground color */
  78852. get color(): string;
  78853. set color(value: string);
  78854. /** Gets or sets z index which is used to reorder controls on the z axis */
  78855. get zIndex(): number;
  78856. set zIndex(value: number);
  78857. /** Gets or sets a boolean indicating if the control can be rendered */
  78858. get notRenderable(): boolean;
  78859. set notRenderable(value: boolean);
  78860. /** Gets or sets a boolean indicating if the control is visible */
  78861. get isVisible(): boolean;
  78862. set isVisible(value: boolean);
  78863. /** Gets a boolean indicating that the control needs to update its rendering */
  78864. get isDirty(): boolean;
  78865. /**
  78866. * Gets the current linked mesh (or null if none)
  78867. */
  78868. get linkedMesh(): BABYLON.Nullable<BABYLON.TransformNode>;
  78869. /**
  78870. * Gets or sets a value indicating the padding to use on the left of the control
  78871. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78872. */
  78873. get paddingLeft(): string | number;
  78874. set paddingLeft(value: string | number);
  78875. /**
  78876. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  78877. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78878. */
  78879. get paddingLeftInPixels(): number;
  78880. set paddingLeftInPixels(value: number);
  78881. /**
  78882. * Gets or sets a value indicating the padding to use on the right of the control
  78883. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78884. */
  78885. get paddingRight(): string | number;
  78886. set paddingRight(value: string | number);
  78887. /**
  78888. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  78889. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78890. */
  78891. get paddingRightInPixels(): number;
  78892. set paddingRightInPixels(value: number);
  78893. /**
  78894. * Gets or sets a value indicating the padding to use on the top of the control
  78895. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78896. */
  78897. get paddingTop(): string | number;
  78898. set paddingTop(value: string | number);
  78899. /**
  78900. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  78901. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78902. */
  78903. get paddingTopInPixels(): number;
  78904. set paddingTopInPixels(value: number);
  78905. /**
  78906. * Gets or sets a value indicating the padding to use on the bottom of the control
  78907. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78908. */
  78909. get paddingBottom(): string | number;
  78910. set paddingBottom(value: string | number);
  78911. /**
  78912. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  78913. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78914. */
  78915. get paddingBottomInPixels(): number;
  78916. set paddingBottomInPixels(value: number);
  78917. /**
  78918. * Gets or sets a value indicating the left coordinate of the control
  78919. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78920. */
  78921. get left(): string | number;
  78922. set left(value: string | number);
  78923. /**
  78924. * Gets or sets a value indicating the left coordinate in pixels of the control
  78925. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78926. */
  78927. get leftInPixels(): number;
  78928. set leftInPixels(value: number);
  78929. /**
  78930. * Gets or sets a value indicating the top coordinate of the control
  78931. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78932. */
  78933. get top(): string | number;
  78934. set top(value: string | number);
  78935. /**
  78936. * Gets or sets a value indicating the top coordinate in pixels of the control
  78937. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78938. */
  78939. get topInPixels(): number;
  78940. set topInPixels(value: number);
  78941. /**
  78942. * Gets or sets a value indicating the offset on X axis to the linked mesh
  78943. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  78944. */
  78945. get linkOffsetX(): string | number;
  78946. set linkOffsetX(value: string | number);
  78947. /**
  78948. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  78949. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  78950. */
  78951. get linkOffsetXInPixels(): number;
  78952. set linkOffsetXInPixels(value: number);
  78953. /**
  78954. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  78955. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  78956. */
  78957. get linkOffsetY(): string | number;
  78958. set linkOffsetY(value: string | number);
  78959. /**
  78960. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  78961. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  78962. */
  78963. get linkOffsetYInPixels(): number;
  78964. set linkOffsetYInPixels(value: number);
  78965. /** Gets the center coordinate on X axis */
  78966. get centerX(): number;
  78967. /** Gets the center coordinate on Y axis */
  78968. get centerY(): number;
  78969. /** Gets or sets if control is Enabled*/
  78970. get isEnabled(): boolean;
  78971. set isEnabled(value: boolean);
  78972. /** Gets or sets background color of control if it's disabled*/
  78973. get disabledColor(): string;
  78974. set disabledColor(value: string);
  78975. /** Gets or sets front color of control if it's disabled*/
  78976. get disabledColorItem(): string;
  78977. set disabledColorItem(value: string);
  78978. /**
  78979. * Creates a new control
  78980. * @param name defines the name of the control
  78981. */
  78982. constructor(
  78983. /** defines the name of the control */
  78984. name?: string | undefined);
  78985. /** @hidden */
  78986. protected _getTypeName(): string;
  78987. /**
  78988. * Gets the first ascendant in the hierarchy of the given type
  78989. * @param className defines the required type
  78990. * @returns the ascendant or null if not found
  78991. */
  78992. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  78993. /** @hidden */
  78994. _resetFontCache(): void;
  78995. /**
  78996. * Determines if a container is an ascendant of the current control
  78997. * @param container defines the container to look for
  78998. * @returns true if the container is one of the ascendant of the control
  78999. */
  79000. isAscendant(container: Control): boolean;
  79001. /**
  79002. * Gets coordinates in local control space
  79003. * @param globalCoordinates defines the coordinates to transform
  79004. * @returns the new coordinates in local space
  79005. */
  79006. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  79007. /**
  79008. * Gets coordinates in local control space
  79009. * @param globalCoordinates defines the coordinates to transform
  79010. * @param result defines the target vector2 where to store the result
  79011. * @returns the current control
  79012. */
  79013. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  79014. /**
  79015. * Gets coordinates in parent local control space
  79016. * @param globalCoordinates defines the coordinates to transform
  79017. * @returns the new coordinates in parent local space
  79018. */
  79019. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  79020. /**
  79021. * Move the current control to a vector3 position projected onto the screen.
  79022. * @param position defines the target position
  79023. * @param scene defines the hosting scene
  79024. */
  79025. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  79026. /**
  79027. * Will store all controls that have this control as ascendant in a given array
  79028. * @param results defines the array where to store the descendants
  79029. * @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
  79030. * @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
  79031. */
  79032. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  79033. /**
  79034. * Will return all controls that have this control as ascendant
  79035. * @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
  79036. * @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
  79037. * @return all child controls
  79038. */
  79039. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  79040. /**
  79041. * Link current control with a target mesh
  79042. * @param mesh defines the mesh to link with
  79043. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  79044. */
  79045. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.TransformNode>): void;
  79046. /** @hidden */
  79047. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  79048. /** @hidden */
  79049. _offsetLeft(offset: number): void;
  79050. /** @hidden */
  79051. _offsetTop(offset: number): void;
  79052. /** @hidden */
  79053. _markMatrixAsDirty(): void;
  79054. /** @hidden */
  79055. _flagDescendantsAsMatrixDirty(): void;
  79056. /** @hidden */
  79057. _intersectsRect(rect: Measure): boolean;
  79058. /** @hidden */
  79059. protected invalidateRect(): void;
  79060. /** @hidden */
  79061. _markAsDirty(force?: boolean): void;
  79062. /** @hidden */
  79063. _markAllAsDirty(): void;
  79064. /** @hidden */
  79065. _link(host: AdvancedDynamicTexture): void;
  79066. /** @hidden */
  79067. protected _transform(context?: CanvasRenderingContext2D): void;
  79068. /** @hidden */
  79069. _renderHighlight(context: CanvasRenderingContext2D): void;
  79070. /** @hidden */
  79071. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  79072. /** @hidden */
  79073. protected _applyStates(context: CanvasRenderingContext2D): void;
  79074. /** @hidden */
  79075. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  79076. /** @hidden */
  79077. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79078. protected _evaluateClippingState(parentMeasure: Measure): void;
  79079. /** @hidden */
  79080. _measure(): void;
  79081. /** @hidden */
  79082. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79083. /** @hidden */
  79084. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79085. /** @hidden */
  79086. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79087. /** @hidden */
  79088. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  79089. private static _ClipMeasure;
  79090. private _tmpMeasureA;
  79091. private _clip;
  79092. /** @hidden */
  79093. _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  79094. /** @hidden */
  79095. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  79096. /**
  79097. * Tests if a given coordinates belong to the current control
  79098. * @param x defines x coordinate to test
  79099. * @param y defines y coordinate to test
  79100. * @returns true if the coordinates are inside the control
  79101. */
  79102. contains(x: number, y: number): boolean;
  79103. /** @hidden */
  79104. _processPicking(x: number, y: number, pi: BABYLON.PointerInfoBase, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  79105. /** @hidden */
  79106. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number, pi: BABYLON.PointerInfoBase): void;
  79107. /** @hidden */
  79108. _onPointerEnter(target: Control, pi: BABYLON.PointerInfoBase): boolean;
  79109. /** @hidden */
  79110. _onPointerOut(target: Control, pi: BABYLON.Nullable<BABYLON.PointerInfoBase>, force?: boolean): void;
  79111. /** @hidden */
  79112. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  79113. /** @hidden */
  79114. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean, pi?: BABYLON.PointerInfoBase): void;
  79115. /** @hidden */
  79116. _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  79117. /** @hidden */
  79118. _onWheelScroll(deltaX?: number, deltaY?: number): void;
  79119. /** @hidden */
  79120. _onCanvasBlur(): void;
  79121. /** @hidden */
  79122. _processObservables(type: number, x: number, y: number, pi: BABYLON.PointerInfoBase, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  79123. private _prepareFont;
  79124. /** Releases associated resources */
  79125. dispose(): void;
  79126. private static _HORIZONTAL_ALIGNMENT_LEFT;
  79127. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  79128. private static _HORIZONTAL_ALIGNMENT_CENTER;
  79129. private static _VERTICAL_ALIGNMENT_TOP;
  79130. private static _VERTICAL_ALIGNMENT_BOTTOM;
  79131. private static _VERTICAL_ALIGNMENT_CENTER;
  79132. /** HORIZONTAL_ALIGNMENT_LEFT */
  79133. static get HORIZONTAL_ALIGNMENT_LEFT(): number;
  79134. /** HORIZONTAL_ALIGNMENT_RIGHT */
  79135. static get HORIZONTAL_ALIGNMENT_RIGHT(): number;
  79136. /** HORIZONTAL_ALIGNMENT_CENTER */
  79137. static get HORIZONTAL_ALIGNMENT_CENTER(): number;
  79138. /** VERTICAL_ALIGNMENT_TOP */
  79139. static get VERTICAL_ALIGNMENT_TOP(): number;
  79140. /** VERTICAL_ALIGNMENT_BOTTOM */
  79141. static get VERTICAL_ALIGNMENT_BOTTOM(): number;
  79142. /** VERTICAL_ALIGNMENT_CENTER */
  79143. static get VERTICAL_ALIGNMENT_CENTER(): number;
  79144. private static _FontHeightSizes;
  79145. /** @hidden */
  79146. static _GetFontOffset(font: string): {
  79147. ascent: number;
  79148. height: number;
  79149. descent: number;
  79150. };
  79151. /**
  79152. * Creates a stack panel that can be used to render headers
  79153. * @param control defines the control to associate with the header
  79154. * @param text defines the text of the header
  79155. * @param size defines the size of the header
  79156. * @param options defines options used to configure the header
  79157. * @returns a new StackPanel
  79158. * @ignore
  79159. * @hidden
  79160. */
  79161. static AddHeader: (control: Control, text: string, size: string | number, options: {
  79162. isHorizontal: boolean;
  79163. controlFirst: boolean;
  79164. }) => any;
  79165. /** @hidden */
  79166. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  79167. }
  79168. }
  79169. declare module BABYLON.GUI {
  79170. /**
  79171. * Root class for 2D containers
  79172. * @see https://doc.babylonjs.com/how_to/gui#containers
  79173. */
  79174. export class Container extends Control {
  79175. name?: string | undefined;
  79176. /** @hidden */
  79177. _children: Control[];
  79178. /** @hidden */
  79179. protected _measureForChildren: Measure;
  79180. /** @hidden */
  79181. protected _background: string;
  79182. /** @hidden */
  79183. protected _adaptWidthToChildren: boolean;
  79184. /** @hidden */
  79185. protected _adaptHeightToChildren: boolean;
  79186. /**
  79187. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  79188. */
  79189. logLayoutCycleErrors: boolean;
  79190. /**
  79191. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  79192. */
  79193. maxLayoutCycle: number;
  79194. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  79195. get adaptHeightToChildren(): boolean;
  79196. set adaptHeightToChildren(value: boolean);
  79197. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  79198. get adaptWidthToChildren(): boolean;
  79199. set adaptWidthToChildren(value: boolean);
  79200. /** Gets or sets background color */
  79201. get background(): string;
  79202. set background(value: string);
  79203. /** Gets the list of children */
  79204. get children(): Control[];
  79205. /**
  79206. * Creates a new Container
  79207. * @param name defines the name of the container
  79208. */
  79209. constructor(name?: string | undefined);
  79210. protected _getTypeName(): string;
  79211. _flagDescendantsAsMatrixDirty(): void;
  79212. /**
  79213. * Gets a child using its name
  79214. * @param name defines the child name to look for
  79215. * @returns the child control if found
  79216. */
  79217. getChildByName(name: string): BABYLON.Nullable<Control>;
  79218. /**
  79219. * Gets a child using its type and its name
  79220. * @param name defines the child name to look for
  79221. * @param type defines the child type to look for
  79222. * @returns the child control if found
  79223. */
  79224. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  79225. /**
  79226. * Search for a specific control in children
  79227. * @param control defines the control to look for
  79228. * @returns true if the control is in child list
  79229. */
  79230. containsControl(control: Control): boolean;
  79231. /**
  79232. * Adds a new control to the current container
  79233. * @param control defines the control to add
  79234. * @returns the current container
  79235. */
  79236. addControl(control: BABYLON.Nullable<Control>): Container;
  79237. /**
  79238. * Removes all controls from the current container
  79239. * @returns the current container
  79240. */
  79241. clearControls(): Container;
  79242. /**
  79243. * Removes a control from the current container
  79244. * @param control defines the control to remove
  79245. * @returns the current container
  79246. */
  79247. removeControl(control: Control): Container;
  79248. /** @hidden */
  79249. _reOrderControl(control: Control): void;
  79250. /** @hidden */
  79251. _offsetLeft(offset: number): void;
  79252. /** @hidden */
  79253. _offsetTop(offset: number): void;
  79254. /** @hidden */
  79255. _markAllAsDirty(): void;
  79256. /** @hidden */
  79257. protected _localDraw(context: CanvasRenderingContext2D): void;
  79258. /** @hidden */
  79259. _link(host: AdvancedDynamicTexture): void;
  79260. /** @hidden */
  79261. protected _beforeLayout(): void;
  79262. /** @hidden */
  79263. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79264. /** @hidden */
  79265. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  79266. protected _postMeasure(): void;
  79267. /** @hidden */
  79268. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  79269. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  79270. /** @hidden */
  79271. _processPicking(x: number, y: number, pi: BABYLON.PointerInfoBase, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  79272. /** @hidden */
  79273. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79274. /** Releases associated resources */
  79275. dispose(): void;
  79276. }
  79277. }
  79278. declare module BABYLON.GUI {
  79279. /** Class used to create rectangle container */
  79280. export class Rectangle extends Container {
  79281. name?: string | undefined;
  79282. private _thickness;
  79283. private _cornerRadius;
  79284. /** Gets or sets border thickness */
  79285. get thickness(): number;
  79286. set thickness(value: number);
  79287. /** Gets or sets the corner radius angle */
  79288. get cornerRadius(): number;
  79289. set cornerRadius(value: number);
  79290. /**
  79291. * Creates a new Rectangle
  79292. * @param name defines the control name
  79293. */
  79294. constructor(name?: string | undefined);
  79295. protected _getTypeName(): string;
  79296. protected _localDraw(context: CanvasRenderingContext2D): void;
  79297. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79298. private _drawRoundedRect;
  79299. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  79300. }
  79301. }
  79302. declare module BABYLON.GUI {
  79303. /**
  79304. * Enum that determines the text-wrapping mode to use.
  79305. */
  79306. export enum TextWrapping {
  79307. /**
  79308. * Clip the text when it's larger than Control.width; this is the default mode.
  79309. */
  79310. Clip = 0,
  79311. /**
  79312. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  79313. */
  79314. WordWrap = 1,
  79315. /**
  79316. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  79317. */
  79318. Ellipsis = 2
  79319. }
  79320. /**
  79321. * Class used to create text block control
  79322. */
  79323. export class TextBlock extends Control {
  79324. /**
  79325. * Defines the name of the control
  79326. */
  79327. name?: string | undefined;
  79328. private _text;
  79329. private _textWrapping;
  79330. private _textHorizontalAlignment;
  79331. private _textVerticalAlignment;
  79332. private _lines;
  79333. private _resizeToFit;
  79334. private _lineSpacing;
  79335. private _outlineWidth;
  79336. private _outlineColor;
  79337. private _underline;
  79338. private _lineThrough;
  79339. /**
  79340. * An event triggered after the text is changed
  79341. */
  79342. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  79343. /**
  79344. * An event triggered after the text was broken up into lines
  79345. */
  79346. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  79347. /**
  79348. * Function used to split a string into words. By default, a string is split at each space character found
  79349. */
  79350. wordSplittingFunction: BABYLON.Nullable<(line: string) => string[]>;
  79351. /**
  79352. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  79353. */
  79354. get lines(): any[];
  79355. /**
  79356. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  79357. */
  79358. get resizeToFit(): boolean;
  79359. /**
  79360. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  79361. */
  79362. set resizeToFit(value: boolean);
  79363. /**
  79364. * Gets or sets a boolean indicating if text must be wrapped
  79365. */
  79366. get textWrapping(): TextWrapping | boolean;
  79367. /**
  79368. * Gets or sets a boolean indicating if text must be wrapped
  79369. */
  79370. set textWrapping(value: TextWrapping | boolean);
  79371. /**
  79372. * Gets or sets text to display
  79373. */
  79374. get text(): string;
  79375. /**
  79376. * Gets or sets text to display
  79377. */
  79378. set text(value: string);
  79379. /**
  79380. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  79381. */
  79382. get textHorizontalAlignment(): number;
  79383. /**
  79384. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  79385. */
  79386. set textHorizontalAlignment(value: number);
  79387. /**
  79388. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  79389. */
  79390. get textVerticalAlignment(): number;
  79391. /**
  79392. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  79393. */
  79394. set textVerticalAlignment(value: number);
  79395. /**
  79396. * Gets or sets line spacing value
  79397. */
  79398. set lineSpacing(value: string | number);
  79399. /**
  79400. * Gets or sets line spacing value
  79401. */
  79402. get lineSpacing(): string | number;
  79403. /**
  79404. * Gets or sets outlineWidth of the text to display
  79405. */
  79406. get outlineWidth(): number;
  79407. /**
  79408. * Gets or sets outlineWidth of the text to display
  79409. */
  79410. set outlineWidth(value: number);
  79411. /**
  79412. * Gets or sets a boolean indicating that text must have underline
  79413. */
  79414. get underline(): boolean;
  79415. /**
  79416. * Gets or sets a boolean indicating that text must have underline
  79417. */
  79418. set underline(value: boolean);
  79419. /**
  79420. * Gets or sets an boolean indicating that text must be crossed out
  79421. */
  79422. get lineThrough(): boolean;
  79423. /**
  79424. * Gets or sets an boolean indicating that text must be crossed out
  79425. */
  79426. set lineThrough(value: boolean);
  79427. /**
  79428. * Gets or sets outlineColor of the text to display
  79429. */
  79430. get outlineColor(): string;
  79431. /**
  79432. * Gets or sets outlineColor of the text to display
  79433. */
  79434. set outlineColor(value: string);
  79435. /**
  79436. * Creates a new TextBlock object
  79437. * @param name defines the name of the control
  79438. * @param text defines the text to display (emptry string by default)
  79439. */
  79440. constructor(
  79441. /**
  79442. * Defines the name of the control
  79443. */
  79444. name?: string | undefined, text?: string);
  79445. protected _getTypeName(): string;
  79446. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79447. private _drawText;
  79448. /** @hidden */
  79449. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  79450. protected _applyStates(context: CanvasRenderingContext2D): void;
  79451. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  79452. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  79453. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  79454. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  79455. protected _renderLines(context: CanvasRenderingContext2D): void;
  79456. /**
  79457. * Given a width constraint applied on the text block, find the expected height
  79458. * @returns expected height
  79459. */
  79460. computeExpectedHeight(): number;
  79461. dispose(): void;
  79462. }
  79463. }
  79464. declare module BABYLON.GUI {
  79465. /**
  79466. * Class used to create 2D images
  79467. */
  79468. export class Image extends Control {
  79469. name?: string | undefined;
  79470. private _workingCanvas;
  79471. private _domImage;
  79472. private _imageWidth;
  79473. private _imageHeight;
  79474. private _loaded;
  79475. private _stretch;
  79476. private _source;
  79477. private _autoScale;
  79478. private _sourceLeft;
  79479. private _sourceTop;
  79480. private _sourceWidth;
  79481. private _sourceHeight;
  79482. private _svgAttributesComputationCompleted;
  79483. private _isSVG;
  79484. private _cellWidth;
  79485. private _cellHeight;
  79486. private _cellId;
  79487. private _populateNinePatchSlicesFromImage;
  79488. private _sliceLeft;
  79489. private _sliceRight;
  79490. private _sliceTop;
  79491. private _sliceBottom;
  79492. private _detectPointerOnOpaqueOnly;
  79493. private _imageDataCache;
  79494. /**
  79495. * BABYLON.Observable notified when the content is loaded
  79496. */
  79497. onImageLoadedObservable: BABYLON.Observable<Image>;
  79498. /**
  79499. * BABYLON.Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  79500. */
  79501. onSVGAttributesComputedObservable: BABYLON.Observable<Image>;
  79502. /**
  79503. * Gets a boolean indicating that the content is loaded
  79504. */
  79505. get isLoaded(): boolean;
  79506. /**
  79507. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  79508. */
  79509. get populateNinePatchSlicesFromImage(): boolean;
  79510. set populateNinePatchSlicesFromImage(value: boolean);
  79511. /**
  79512. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  79513. * Beware using this as this will comsume more memory as the image has to be stored twice
  79514. */
  79515. get detectPointerOnOpaqueOnly(): boolean;
  79516. set detectPointerOnOpaqueOnly(value: boolean);
  79517. /**
  79518. * Gets or sets the left value for slicing (9-patch)
  79519. */
  79520. get sliceLeft(): number;
  79521. set sliceLeft(value: number);
  79522. /**
  79523. * Gets or sets the right value for slicing (9-patch)
  79524. */
  79525. get sliceRight(): number;
  79526. set sliceRight(value: number);
  79527. /**
  79528. * Gets or sets the top value for slicing (9-patch)
  79529. */
  79530. get sliceTop(): number;
  79531. set sliceTop(value: number);
  79532. /**
  79533. * Gets or sets the bottom value for slicing (9-patch)
  79534. */
  79535. get sliceBottom(): number;
  79536. set sliceBottom(value: number);
  79537. /**
  79538. * Gets or sets the left coordinate in the source image
  79539. */
  79540. get sourceLeft(): number;
  79541. set sourceLeft(value: number);
  79542. /**
  79543. * Gets or sets the top coordinate in the source image
  79544. */
  79545. get sourceTop(): number;
  79546. set sourceTop(value: number);
  79547. /**
  79548. * Gets or sets the width to capture in the source image
  79549. */
  79550. get sourceWidth(): number;
  79551. set sourceWidth(value: number);
  79552. /**
  79553. * Gets or sets the height to capture in the source image
  79554. */
  79555. get sourceHeight(): number;
  79556. set sourceHeight(value: number);
  79557. /** Indicates if the format of the image is SVG */
  79558. get isSVG(): boolean;
  79559. /** Gets the status of the SVG attributes computation (sourceLeft, sourceTop, sourceWidth, sourceHeight) */
  79560. get svgAttributesComputationCompleted(): boolean;
  79561. /**
  79562. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  79563. * @see https://doc.babylonjs.com/how_to/gui#image
  79564. */
  79565. get autoScale(): boolean;
  79566. set autoScale(value: boolean);
  79567. /** Gets or sets the streching mode used by the image */
  79568. get stretch(): number;
  79569. set stretch(value: number);
  79570. /** @hidden */
  79571. _rotate90(n: number, preserveProperties?: boolean): Image;
  79572. private _handleRotationForSVGImage;
  79573. private _rotate90SourceProperties;
  79574. /**
  79575. * Gets or sets the internal DOM image used to render the control
  79576. */
  79577. set domImage(value: HTMLImageElement);
  79578. get domImage(): HTMLImageElement;
  79579. private _onImageLoaded;
  79580. private _extractNinePatchSliceDataFromImage;
  79581. /**
  79582. * Gets or sets image source url
  79583. */
  79584. set source(value: BABYLON.Nullable<string>);
  79585. /**
  79586. * Checks for svg document with icon id present
  79587. */
  79588. private _svgCheck;
  79589. /**
  79590. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  79591. * given external svg file and icon id
  79592. */
  79593. private _getSVGAttribs;
  79594. /**
  79595. * Gets or sets the cell width to use when animation sheet is enabled
  79596. * @see https://doc.babylonjs.com/how_to/gui#image
  79597. */
  79598. get cellWidth(): number;
  79599. set cellWidth(value: number);
  79600. /**
  79601. * Gets or sets the cell height to use when animation sheet is enabled
  79602. * @see https://doc.babylonjs.com/how_to/gui#image
  79603. */
  79604. get cellHeight(): number;
  79605. set cellHeight(value: number);
  79606. /**
  79607. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  79608. * @see https://doc.babylonjs.com/how_to/gui#image
  79609. */
  79610. get cellId(): number;
  79611. set cellId(value: number);
  79612. /**
  79613. * Creates a new Image
  79614. * @param name defines the control name
  79615. * @param url defines the image url
  79616. */
  79617. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  79618. /**
  79619. * Tests if a given coordinates belong to the current control
  79620. * @param x defines x coordinate to test
  79621. * @param y defines y coordinate to test
  79622. * @returns true if the coordinates are inside the control
  79623. */
  79624. contains(x: number, y: number): boolean;
  79625. protected _getTypeName(): string;
  79626. /** Force the control to synchronize with its content */
  79627. synchronizeSizeWithContent(): void;
  79628. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79629. private _prepareWorkingCanvasForOpaqueDetection;
  79630. private _drawImage;
  79631. _draw(context: CanvasRenderingContext2D): void;
  79632. private _renderCornerPatch;
  79633. private _renderNinePatch;
  79634. dispose(): void;
  79635. /** STRETCH_NONE */
  79636. static readonly STRETCH_NONE: number;
  79637. /** STRETCH_FILL */
  79638. static readonly STRETCH_FILL: number;
  79639. /** STRETCH_UNIFORM */
  79640. static readonly STRETCH_UNIFORM: number;
  79641. /** STRETCH_EXTEND */
  79642. static readonly STRETCH_EXTEND: number;
  79643. /** NINE_PATCH */
  79644. static readonly STRETCH_NINE_PATCH: number;
  79645. }
  79646. }
  79647. declare module BABYLON.GUI {
  79648. /**
  79649. * Class used to create 2D buttons
  79650. */
  79651. export class Button extends Rectangle {
  79652. name?: string | undefined;
  79653. /**
  79654. * Function called to generate a pointer enter animation
  79655. */
  79656. pointerEnterAnimation: () => void;
  79657. /**
  79658. * Function called to generate a pointer out animation
  79659. */
  79660. pointerOutAnimation: () => void;
  79661. /**
  79662. * Function called to generate a pointer down animation
  79663. */
  79664. pointerDownAnimation: () => void;
  79665. /**
  79666. * Function called to generate a pointer up animation
  79667. */
  79668. pointerUpAnimation: () => void;
  79669. /**
  79670. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  79671. */
  79672. delegatePickingToChildren: boolean;
  79673. private _image;
  79674. /**
  79675. * Returns the image part of the button (if any)
  79676. */
  79677. get image(): BABYLON.Nullable<Image>;
  79678. private _textBlock;
  79679. /**
  79680. * Returns the image part of the button (if any)
  79681. */
  79682. get textBlock(): BABYLON.Nullable<TextBlock>;
  79683. /**
  79684. * Creates a new Button
  79685. * @param name defines the name of the button
  79686. */
  79687. constructor(name?: string | undefined);
  79688. protected _getTypeName(): string;
  79689. /** @hidden */
  79690. _processPicking(x: number, y: number, pi: BABYLON.PointerInfoBase, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  79691. /** @hidden */
  79692. _onPointerEnter(target: Control, pi: BABYLON.PointerInfoBase): boolean;
  79693. /** @hidden */
  79694. _onPointerOut(target: Control, pi: BABYLON.PointerInfoBase, force?: boolean): void;
  79695. /** @hidden */
  79696. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  79697. /** @hidden */
  79698. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean, pi: BABYLON.PointerInfoBase): void;
  79699. /**
  79700. * Creates a new button made with an image and a text
  79701. * @param name defines the name of the button
  79702. * @param text defines the text of the button
  79703. * @param imageUrl defines the url of the image
  79704. * @returns a new Button
  79705. */
  79706. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  79707. /**
  79708. * Creates a new button made with an image
  79709. * @param name defines the name of the button
  79710. * @param imageUrl defines the url of the image
  79711. * @returns a new Button
  79712. */
  79713. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  79714. /**
  79715. * Creates a new button made with a text
  79716. * @param name defines the name of the button
  79717. * @param text defines the text of the button
  79718. * @returns a new Button
  79719. */
  79720. static CreateSimpleButton(name: string, text: string): Button;
  79721. /**
  79722. * Creates a new button made with an image and a centered text
  79723. * @param name defines the name of the button
  79724. * @param text defines the text of the button
  79725. * @param imageUrl defines the url of the image
  79726. * @returns a new Button
  79727. */
  79728. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  79729. }
  79730. }
  79731. declare module BABYLON.GUI {
  79732. /**
  79733. * Class used to create a 2D stack panel container
  79734. */
  79735. export class StackPanel extends Container {
  79736. name?: string | undefined;
  79737. private _isVertical;
  79738. private _manualWidth;
  79739. private _manualHeight;
  79740. private _doNotTrackManualChanges;
  79741. /**
  79742. * Gets or sets a boolean indicating that layou warnings should be ignored
  79743. */
  79744. ignoreLayoutWarnings: boolean;
  79745. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  79746. get isVertical(): boolean;
  79747. set isVertical(value: boolean);
  79748. /**
  79749. * Gets or sets panel width.
  79750. * This value should not be set when in horizontal mode as it will be computed automatically
  79751. */
  79752. set width(value: string | number);
  79753. get width(): string | number;
  79754. /**
  79755. * Gets or sets panel height.
  79756. * This value should not be set when in vertical mode as it will be computed automatically
  79757. */
  79758. set height(value: string | number);
  79759. get height(): string | number;
  79760. /**
  79761. * Creates a new StackPanel
  79762. * @param name defines control name
  79763. */
  79764. constructor(name?: string | undefined);
  79765. protected _getTypeName(): string;
  79766. /** @hidden */
  79767. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79768. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79769. protected _postMeasure(): void;
  79770. }
  79771. }
  79772. declare module BABYLON.GUI {
  79773. /**
  79774. * Class used to represent a 2D checkbox
  79775. */
  79776. export class Checkbox extends Control {
  79777. name?: string | undefined;
  79778. private _isChecked;
  79779. private _background;
  79780. private _checkSizeRatio;
  79781. private _thickness;
  79782. /** Gets or sets border thickness */
  79783. get thickness(): number;
  79784. set thickness(value: number);
  79785. /**
  79786. * BABYLON.Observable raised when isChecked property changes
  79787. */
  79788. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  79789. /** Gets or sets a value indicating the ratio between overall size and check size */
  79790. get checkSizeRatio(): number;
  79791. set checkSizeRatio(value: number);
  79792. /** Gets or sets background color */
  79793. get background(): string;
  79794. set background(value: string);
  79795. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  79796. get isChecked(): boolean;
  79797. set isChecked(value: boolean);
  79798. /**
  79799. * Creates a new CheckBox
  79800. * @param name defines the control name
  79801. */
  79802. constructor(name?: string | undefined);
  79803. protected _getTypeName(): string;
  79804. /** @hidden */
  79805. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  79806. /** @hidden */
  79807. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  79808. /**
  79809. * Utility function to easily create a checkbox with a header
  79810. * @param title defines the label to use for the header
  79811. * @param onValueChanged defines the callback to call when value changes
  79812. * @returns a StackPanel containing the checkbox and a textBlock
  79813. */
  79814. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  79815. }
  79816. }
  79817. declare module BABYLON.GUI {
  79818. /**
  79819. * Class used to store key control properties
  79820. */
  79821. export class KeyPropertySet {
  79822. /** Width */
  79823. width?: string;
  79824. /** Height */
  79825. height?: string;
  79826. /** Left padding */
  79827. paddingLeft?: string;
  79828. /** Right padding */
  79829. paddingRight?: string;
  79830. /** Top padding */
  79831. paddingTop?: string;
  79832. /** Bottom padding */
  79833. paddingBottom?: string;
  79834. /** Foreground color */
  79835. color?: string;
  79836. /** Background color */
  79837. background?: string;
  79838. }
  79839. /**
  79840. * Class used to create virtual keyboard
  79841. */
  79842. export class VirtualKeyboard extends StackPanel {
  79843. /** BABYLON.Observable raised when a key is pressed */
  79844. onKeyPressObservable: BABYLON.Observable<string>;
  79845. /** Gets or sets default key button width */
  79846. defaultButtonWidth: string;
  79847. /** Gets or sets default key button height */
  79848. defaultButtonHeight: string;
  79849. /** Gets or sets default key button left padding */
  79850. defaultButtonPaddingLeft: string;
  79851. /** Gets or sets default key button right padding */
  79852. defaultButtonPaddingRight: string;
  79853. /** Gets or sets default key button top padding */
  79854. defaultButtonPaddingTop: string;
  79855. /** Gets or sets default key button bottom padding */
  79856. defaultButtonPaddingBottom: string;
  79857. /** Gets or sets default key button foreground color */
  79858. defaultButtonColor: string;
  79859. /** Gets or sets default key button background color */
  79860. defaultButtonBackground: string;
  79861. /** Gets or sets shift button foreground color */
  79862. shiftButtonColor: string;
  79863. /** Gets or sets shift button thickness*/
  79864. selectedShiftThickness: number;
  79865. /** Gets shift key state */
  79866. shiftState: number;
  79867. protected _getTypeName(): string;
  79868. private _createKey;
  79869. /**
  79870. * Adds a new row of keys
  79871. * @param keys defines the list of keys to add
  79872. * @param propertySets defines the associated property sets
  79873. */
  79874. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  79875. /**
  79876. * Set the shift key to a specific state
  79877. * @param shiftState defines the new shift state
  79878. */
  79879. applyShiftState(shiftState: number): void;
  79880. private _currentlyConnectedInputText;
  79881. private _connectedInputTexts;
  79882. private _onKeyPressObserver;
  79883. /** Gets the input text control currently attached to the keyboard */
  79884. get connectedInputText(): BABYLON.Nullable<InputText>;
  79885. /**
  79886. * Connects the keyboard with an input text control
  79887. *
  79888. * @param input defines the target control
  79889. */
  79890. connect(input: InputText): void;
  79891. /**
  79892. * Disconnects the keyboard from connected InputText controls
  79893. *
  79894. * @param input optionally defines a target control, otherwise all are disconnected
  79895. */
  79896. disconnect(input?: InputText): void;
  79897. private _removeConnectedInputObservables;
  79898. /**
  79899. * Release all resources
  79900. */
  79901. dispose(): void;
  79902. /**
  79903. * Creates a new keyboard using a default layout
  79904. *
  79905. * @param name defines control name
  79906. * @returns a new VirtualKeyboard
  79907. */
  79908. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  79909. }
  79910. }
  79911. declare module BABYLON.GUI {
  79912. /** @hidden */
  79913. export class TextWrapper {
  79914. private _text;
  79915. private _characters;
  79916. get text(): string;
  79917. set text(txt: string);
  79918. get length(): number;
  79919. removePart(idxStart: number, idxEnd: number, insertTxt?: string): void;
  79920. charAt(idx: number): string;
  79921. substr(from: number, length?: number): string;
  79922. substring(from: number, to?: number): string;
  79923. isWord(index: number): boolean;
  79924. }
  79925. }
  79926. declare module BABYLON.GUI {
  79927. /**
  79928. * Class used to create input text control
  79929. */
  79930. export class InputText extends Control implements IFocusableControl {
  79931. name?: string | undefined;
  79932. private _textWrapper;
  79933. private _placeholderText;
  79934. private _background;
  79935. private _focusedBackground;
  79936. private _focusedColor;
  79937. private _placeholderColor;
  79938. private _thickness;
  79939. private _margin;
  79940. private _autoStretchWidth;
  79941. private _maxWidth;
  79942. private _isFocused;
  79943. private _blinkTimeout;
  79944. private _blinkIsEven;
  79945. private _cursorOffset;
  79946. private _scrollLeft;
  79947. private _textWidth;
  79948. private _clickedCoordinate;
  79949. private _deadKey;
  79950. private _addKey;
  79951. private _currentKey;
  79952. private _isTextHighlightOn;
  79953. private _textHighlightColor;
  79954. private _highligherOpacity;
  79955. private _highlightedText;
  79956. private _startHighlightIndex;
  79957. private _endHighlightIndex;
  79958. private _cursorIndex;
  79959. private _onFocusSelectAll;
  79960. private _isPointerDown;
  79961. private _onClipboardObserver;
  79962. private _onPointerDblTapObserver;
  79963. /** @hidden */
  79964. _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  79965. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  79966. promptMessage: string;
  79967. /** Force disable prompt on mobile device */
  79968. disableMobilePrompt: boolean;
  79969. /** BABYLON.Observable raised when the text changes */
  79970. onTextChangedObservable: BABYLON.Observable<InputText>;
  79971. /** BABYLON.Observable raised just before an entered character is to be added */
  79972. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  79973. /** BABYLON.Observable raised when the control gets the focus */
  79974. onFocusObservable: BABYLON.Observable<InputText>;
  79975. /** BABYLON.Observable raised when the control loses the focus */
  79976. onBlurObservable: BABYLON.Observable<InputText>;
  79977. /**Observable raised when the text is highlighted */
  79978. onTextHighlightObservable: BABYLON.Observable<InputText>;
  79979. /**Observable raised when copy event is triggered */
  79980. onTextCopyObservable: BABYLON.Observable<InputText>;
  79981. /** BABYLON.Observable raised when cut event is triggered */
  79982. onTextCutObservable: BABYLON.Observable<InputText>;
  79983. /** BABYLON.Observable raised when paste event is triggered */
  79984. onTextPasteObservable: BABYLON.Observable<InputText>;
  79985. /** BABYLON.Observable raised when a key event was processed */
  79986. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  79987. /** Gets or sets the maximum width allowed by the control */
  79988. get maxWidth(): string | number;
  79989. /** Gets the maximum width allowed by the control in pixels */
  79990. get maxWidthInPixels(): number;
  79991. set maxWidth(value: string | number);
  79992. /** Gets or sets the text highlighter transparency; default: 0.4 */
  79993. get highligherOpacity(): number;
  79994. set highligherOpacity(value: number);
  79995. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  79996. get onFocusSelectAll(): boolean;
  79997. set onFocusSelectAll(value: boolean);
  79998. /** Gets or sets the text hightlight color */
  79999. get textHighlightColor(): string;
  80000. set textHighlightColor(value: string);
  80001. /** Gets or sets control margin */
  80002. get margin(): string;
  80003. /** Gets control margin in pixels */
  80004. get marginInPixels(): number;
  80005. set margin(value: string);
  80006. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  80007. get autoStretchWidth(): boolean;
  80008. set autoStretchWidth(value: boolean);
  80009. /** Gets or sets border thickness */
  80010. get thickness(): number;
  80011. set thickness(value: number);
  80012. /** Gets or sets the background color when focused */
  80013. get focusedBackground(): string;
  80014. set focusedBackground(value: string);
  80015. /** Gets or sets the background color when focused */
  80016. get focusedColor(): string;
  80017. set focusedColor(value: string);
  80018. /** Gets or sets the background color */
  80019. get background(): string;
  80020. set background(value: string);
  80021. /** Gets or sets the placeholder color */
  80022. get placeholderColor(): string;
  80023. set placeholderColor(value: string);
  80024. /** Gets or sets the text displayed when the control is empty */
  80025. get placeholderText(): string;
  80026. set placeholderText(value: string);
  80027. /** Gets or sets the dead key flag */
  80028. get deadKey(): boolean;
  80029. set deadKey(flag: boolean);
  80030. /** Gets or sets the highlight text */
  80031. get highlightedText(): string;
  80032. set highlightedText(text: string);
  80033. /** Gets or sets if the current key should be added */
  80034. get addKey(): boolean;
  80035. set addKey(flag: boolean);
  80036. /** Gets or sets the value of the current key being entered */
  80037. get currentKey(): string;
  80038. set currentKey(key: string);
  80039. /** Gets or sets the text displayed in the control */
  80040. get text(): string;
  80041. set text(value: string);
  80042. private _textHasChanged;
  80043. /** Gets or sets control width */
  80044. get width(): string | number;
  80045. set width(value: string | number);
  80046. /**
  80047. * Creates a new InputText
  80048. * @param name defines the control name
  80049. * @param text defines the text of the control
  80050. */
  80051. constructor(name?: string | undefined, text?: string);
  80052. /** @hidden */
  80053. onBlur(): void;
  80054. /** @hidden */
  80055. onFocus(): void;
  80056. protected _getTypeName(): string;
  80057. /**
  80058. * Function called to get the list of controls that should not steal the focus from this control
  80059. * @returns an array of controls
  80060. */
  80061. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  80062. /** @hidden */
  80063. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  80064. /** @hidden */
  80065. private _updateValueFromCursorIndex;
  80066. /** @hidden */
  80067. private _processDblClick;
  80068. /** @hidden */
  80069. private _selectAllText;
  80070. /**
  80071. * Handles the keyboard event
  80072. * @param evt Defines the KeyboardEvent
  80073. */
  80074. processKeyboard(evt: KeyboardEvent): void;
  80075. /** @hidden */
  80076. private _onCopyText;
  80077. /** @hidden */
  80078. private _onCutText;
  80079. /** @hidden */
  80080. private _onPasteText;
  80081. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  80082. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  80083. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number, pi: BABYLON.PointerInfoBase): void;
  80084. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  80085. protected _beforeRenderText(textWrapper: TextWrapper): TextWrapper;
  80086. dispose(): void;
  80087. }
  80088. }
  80089. declare module BABYLON.GUI {
  80090. /**
  80091. * Class used to create a 2D grid container
  80092. */
  80093. export class Grid extends Container {
  80094. name?: string | undefined;
  80095. private _rowDefinitions;
  80096. private _columnDefinitions;
  80097. private _cells;
  80098. private _childControls;
  80099. /**
  80100. * Gets the number of columns
  80101. */
  80102. get columnCount(): number;
  80103. /**
  80104. * Gets the number of rows
  80105. */
  80106. get rowCount(): number;
  80107. /** Gets the list of children */
  80108. get children(): Control[];
  80109. /** Gets the list of cells (e.g. the containers) */
  80110. get cells(): {
  80111. [key: string]: Container;
  80112. };
  80113. /**
  80114. * Gets the definition of a specific row
  80115. * @param index defines the index of the row
  80116. * @returns the row definition
  80117. */
  80118. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  80119. /**
  80120. * Gets the definition of a specific column
  80121. * @param index defines the index of the column
  80122. * @returns the column definition
  80123. */
  80124. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  80125. /**
  80126. * Adds a new row to the grid
  80127. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  80128. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  80129. * @returns the current grid
  80130. */
  80131. addRowDefinition(height: number, isPixel?: boolean): Grid;
  80132. /**
  80133. * Adds a new column to the grid
  80134. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  80135. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  80136. * @returns the current grid
  80137. */
  80138. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  80139. /**
  80140. * Update a row definition
  80141. * @param index defines the index of the row to update
  80142. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  80143. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  80144. * @returns the current grid
  80145. */
  80146. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  80147. /**
  80148. * Update a column definition
  80149. * @param index defines the index of the column to update
  80150. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  80151. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  80152. * @returns the current grid
  80153. */
  80154. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  80155. /**
  80156. * Gets the list of children stored in a specific cell
  80157. * @param row defines the row to check
  80158. * @param column defines the column to check
  80159. * @returns the list of controls
  80160. */
  80161. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  80162. /**
  80163. * Gets a string representing the child cell info (row x column)
  80164. * @param child defines the control to get info from
  80165. * @returns a string containing the child cell info (row x column)
  80166. */
  80167. getChildCellInfo(child: Control): string;
  80168. private _removeCell;
  80169. private _offsetCell;
  80170. /**
  80171. * Remove a column definition at specified index
  80172. * @param index defines the index of the column to remove
  80173. * @returns the current grid
  80174. */
  80175. removeColumnDefinition(index: number): Grid;
  80176. /**
  80177. * Remove a row definition at specified index
  80178. * @param index defines the index of the row to remove
  80179. * @returns the current grid
  80180. */
  80181. removeRowDefinition(index: number): Grid;
  80182. /**
  80183. * Adds a new control to the current grid
  80184. * @param control defines the control to add
  80185. * @param row defines the row where to add the control (0 by default)
  80186. * @param column defines the column where to add the control (0 by default)
  80187. * @returns the current grid
  80188. */
  80189. addControl(control: Control, row?: number, column?: number): Grid;
  80190. /**
  80191. * Removes a control from the current container
  80192. * @param control defines the control to remove
  80193. * @returns the current container
  80194. */
  80195. removeControl(control: Control): Container;
  80196. /**
  80197. * Creates a new Grid
  80198. * @param name defines control name
  80199. */
  80200. constructor(name?: string | undefined);
  80201. protected _getTypeName(): string;
  80202. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  80203. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  80204. _flagDescendantsAsMatrixDirty(): void;
  80205. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  80206. /** Releases associated resources */
  80207. dispose(): void;
  80208. }
  80209. }
  80210. declare module BABYLON.GUI {
  80211. /** Class used to create color pickers */
  80212. export class ColorPicker extends Control {
  80213. name?: string | undefined;
  80214. private static _Epsilon;
  80215. private _colorWheelCanvas;
  80216. private _value;
  80217. private _tmpColor;
  80218. private _pointerStartedOnSquare;
  80219. private _pointerStartedOnWheel;
  80220. private _squareLeft;
  80221. private _squareTop;
  80222. private _squareSize;
  80223. private _h;
  80224. private _s;
  80225. private _v;
  80226. private _lastPointerDownID;
  80227. /**
  80228. * BABYLON.Observable raised when the value changes
  80229. */
  80230. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  80231. /** Gets or sets the color of the color picker */
  80232. get value(): BABYLON.Color3;
  80233. set value(value: BABYLON.Color3);
  80234. /**
  80235. * Gets or sets control width
  80236. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  80237. */
  80238. get width(): string | number;
  80239. set width(value: string | number);
  80240. /**
  80241. * Gets or sets control height
  80242. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  80243. */
  80244. get height(): string | number;
  80245. /** Gets or sets control height */
  80246. set height(value: string | number);
  80247. /** Gets or sets control size */
  80248. get size(): string | number;
  80249. set size(value: string | number);
  80250. /**
  80251. * Creates a new ColorPicker
  80252. * @param name defines the control name
  80253. */
  80254. constructor(name?: string | undefined);
  80255. protected _getTypeName(): string;
  80256. /** @hidden */
  80257. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  80258. private _updateSquareProps;
  80259. private _drawGradientSquare;
  80260. private _drawCircle;
  80261. private _createColorWheelCanvas;
  80262. /** @hidden */
  80263. _draw(context: CanvasRenderingContext2D): void;
  80264. private _pointerIsDown;
  80265. private _updateValueFromPointer;
  80266. private _isPointOnSquare;
  80267. private _isPointOnWheel;
  80268. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  80269. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number, pi: BABYLON.PointerInfoBase): void;
  80270. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean, pi: BABYLON.PointerInfoBase): void;
  80271. _onCanvasBlur(): void;
  80272. /**
  80273. * This function expands the color picker by creating a color picker dialog with manual
  80274. * color value input and the ability to save colors into an array to be used later in
  80275. * subsequent launches of the dialogue.
  80276. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  80277. * @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.
  80278. * @returns picked color as a hex string and the saved colors array as hex strings.
  80279. */
  80280. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  80281. pickerWidth?: string;
  80282. pickerHeight?: string;
  80283. headerHeight?: string;
  80284. lastColor?: string;
  80285. swatchLimit?: number;
  80286. numSwatchesPerLine?: number;
  80287. savedColors?: Array<string>;
  80288. }): Promise<{
  80289. savedColors?: string[];
  80290. pickedColor: string;
  80291. }>;
  80292. }
  80293. }
  80294. declare module BABYLON.GUI {
  80295. /** Class used to create 2D ellipse containers */
  80296. export class Ellipse extends Container {
  80297. name?: string | undefined;
  80298. private _thickness;
  80299. /** Gets or sets border thickness */
  80300. get thickness(): number;
  80301. set thickness(value: number);
  80302. /**
  80303. * Creates a new Ellipse
  80304. * @param name defines the control name
  80305. */
  80306. constructor(name?: string | undefined);
  80307. protected _getTypeName(): string;
  80308. protected _localDraw(context: CanvasRenderingContext2D): void;
  80309. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  80310. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  80311. }
  80312. }
  80313. declare module BABYLON.GUI {
  80314. /**
  80315. * Class used to create a password control
  80316. */
  80317. export class InputPassword extends InputText {
  80318. protected _beforeRenderText(textWrapper: TextWrapper): TextWrapper;
  80319. }
  80320. }
  80321. declare module BABYLON.GUI {
  80322. /** Class used to render 2D lines */
  80323. export class Line extends Control {
  80324. name?: string | undefined;
  80325. private _lineWidth;
  80326. private _x1;
  80327. private _y1;
  80328. private _x2;
  80329. private _y2;
  80330. private _dash;
  80331. private _connectedControl;
  80332. private _connectedControlDirtyObserver;
  80333. /** Gets or sets the dash pattern */
  80334. get dash(): Array<number>;
  80335. set dash(value: Array<number>);
  80336. /** Gets or sets the control connected with the line end */
  80337. get connectedControl(): Control;
  80338. set connectedControl(value: Control);
  80339. /** Gets or sets start coordinates on X axis */
  80340. get x1(): string | number;
  80341. set x1(value: string | number);
  80342. /** Gets or sets start coordinates on Y axis */
  80343. get y1(): string | number;
  80344. set y1(value: string | number);
  80345. /** Gets or sets end coordinates on X axis */
  80346. get x2(): string | number;
  80347. set x2(value: string | number);
  80348. /** Gets or sets end coordinates on Y axis */
  80349. get y2(): string | number;
  80350. set y2(value: string | number);
  80351. /** Gets or sets line width */
  80352. get lineWidth(): number;
  80353. set lineWidth(value: number);
  80354. /** Gets or sets horizontal alignment */
  80355. set horizontalAlignment(value: number);
  80356. /** Gets or sets vertical alignment */
  80357. set verticalAlignment(value: number);
  80358. private get _effectiveX2();
  80359. private get _effectiveY2();
  80360. /**
  80361. * Creates a new Line
  80362. * @param name defines the control name
  80363. */
  80364. constructor(name?: string | undefined);
  80365. protected _getTypeName(): string;
  80366. _draw(context: CanvasRenderingContext2D): void;
  80367. _measure(): void;
  80368. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  80369. /**
  80370. * Move one end of the line given 3D cartesian coordinates.
  80371. * @param position Targeted world position
  80372. * @param scene BABYLON.Scene
  80373. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  80374. */
  80375. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  80376. /**
  80377. * Move one end of the line to a position in screen absolute space.
  80378. * @param projectedPosition Position in screen absolute space (X, Y)
  80379. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  80380. */
  80381. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  80382. }
  80383. }
  80384. declare module BABYLON.GUI {
  80385. /**
  80386. * Class used to store a point for a MultiLine object.
  80387. * The point can be pure 2D coordinates, a mesh or a control
  80388. */
  80389. export class MultiLinePoint {
  80390. private _multiLine;
  80391. private _x;
  80392. private _y;
  80393. private _control;
  80394. private _mesh;
  80395. private _controlObserver;
  80396. private _meshObserver;
  80397. /** @hidden */
  80398. _point: BABYLON.Vector3;
  80399. /**
  80400. * Creates a new MultiLinePoint
  80401. * @param multiLine defines the source MultiLine object
  80402. */
  80403. constructor(multiLine: MultiLine);
  80404. /** Gets or sets x coordinate */
  80405. get x(): string | number;
  80406. set x(value: string | number);
  80407. /** Gets or sets y coordinate */
  80408. get y(): string | number;
  80409. set y(value: string | number);
  80410. /** Gets or sets the control associated with this point */
  80411. get control(): BABYLON.Nullable<Control>;
  80412. set control(value: BABYLON.Nullable<Control>);
  80413. /** Gets or sets the mesh associated with this point */
  80414. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  80415. set mesh(value: BABYLON.Nullable<BABYLON.AbstractMesh>);
  80416. /** Resets links */
  80417. resetLinks(): void;
  80418. /**
  80419. * Gets a translation vector with Z component
  80420. * @returns the translation vector
  80421. */
  80422. translate(): BABYLON.Vector3;
  80423. private _translatePoint;
  80424. /** Release associated resources */
  80425. dispose(): void;
  80426. }
  80427. }
  80428. declare module BABYLON.GUI {
  80429. /**
  80430. * Class used to create multi line control
  80431. */
  80432. export class MultiLine extends Control {
  80433. name?: string | undefined;
  80434. private _lineWidth;
  80435. private _dash;
  80436. private _points;
  80437. private _minX;
  80438. private _minY;
  80439. private _maxX;
  80440. private _maxY;
  80441. /**
  80442. * Creates a new MultiLine
  80443. * @param name defines the control name
  80444. */
  80445. constructor(name?: string | undefined);
  80446. /** Gets or sets dash pattern */
  80447. get dash(): Array<number>;
  80448. set dash(value: Array<number>);
  80449. /**
  80450. * Gets point stored at specified index
  80451. * @param index defines the index to look for
  80452. * @returns the requested point if found
  80453. */
  80454. getAt(index: number): MultiLinePoint;
  80455. /** Function called when a point is updated */
  80456. onPointUpdate: () => void;
  80457. /**
  80458. * Adds new points to the point collection
  80459. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  80460. * @returns the list of created MultiLinePoint
  80461. */
  80462. add(...items: (AbstractMesh | Control | {
  80463. x: string | number;
  80464. y: string | number;
  80465. })[]): MultiLinePoint[];
  80466. /**
  80467. * Adds a new point to the point collection
  80468. * @param item defines the item (mesh, control or 2d coordiantes) to add
  80469. * @returns the created MultiLinePoint
  80470. */
  80471. push(item?: (AbstractMesh | Control | {
  80472. x: string | number;
  80473. y: string | number;
  80474. })): MultiLinePoint;
  80475. /**
  80476. * Remove a specific value or point from the active point collection
  80477. * @param value defines the value or point to remove
  80478. */
  80479. remove(value: number | MultiLinePoint): void;
  80480. /**
  80481. * Resets this object to initial state (no point)
  80482. */
  80483. reset(): void;
  80484. /**
  80485. * Resets all links
  80486. */
  80487. resetLinks(): void;
  80488. /** Gets or sets line width */
  80489. get lineWidth(): number;
  80490. set lineWidth(value: number);
  80491. set horizontalAlignment(value: number);
  80492. set verticalAlignment(value: number);
  80493. protected _getTypeName(): string;
  80494. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  80495. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  80496. _measure(): void;
  80497. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  80498. dispose(): void;
  80499. }
  80500. }
  80501. declare module BABYLON.GUI {
  80502. /**
  80503. * Class used to create radio button controls
  80504. */
  80505. export class RadioButton extends Control {
  80506. name?: string | undefined;
  80507. private _isChecked;
  80508. private _background;
  80509. private _checkSizeRatio;
  80510. private _thickness;
  80511. /** Gets or sets border thickness */
  80512. get thickness(): number;
  80513. set thickness(value: number);
  80514. /** Gets or sets group name */
  80515. group: string;
  80516. /** BABYLON.Observable raised when isChecked is changed */
  80517. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  80518. /** Gets or sets a value indicating the ratio between overall size and check size */
  80519. get checkSizeRatio(): number;
  80520. set checkSizeRatio(value: number);
  80521. /** Gets or sets background color */
  80522. get background(): string;
  80523. set background(value: string);
  80524. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  80525. get isChecked(): boolean;
  80526. set isChecked(value: boolean);
  80527. /**
  80528. * Creates a new RadioButton
  80529. * @param name defines the control name
  80530. */
  80531. constructor(name?: string | undefined);
  80532. protected _getTypeName(): string;
  80533. _draw(context: CanvasRenderingContext2D): void;
  80534. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  80535. /**
  80536. * Utility function to easily create a radio button with a header
  80537. * @param title defines the label to use for the header
  80538. * @param group defines the group to use for the radio button
  80539. * @param isChecked defines the initial state of the radio button
  80540. * @param onValueChanged defines the callback to call when value changes
  80541. * @returns a StackPanel containing the radio button and a textBlock
  80542. */
  80543. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  80544. }
  80545. }
  80546. declare module BABYLON.GUI {
  80547. /**
  80548. * Class used to create slider controls
  80549. */
  80550. export class BaseSlider extends Control {
  80551. name?: string | undefined;
  80552. protected _thumbWidth: ValueAndUnit;
  80553. private _minimum;
  80554. private _maximum;
  80555. private _value;
  80556. private _isVertical;
  80557. protected _barOffset: ValueAndUnit;
  80558. private _isThumbClamped;
  80559. protected _displayThumb: boolean;
  80560. private _step;
  80561. private _lastPointerDownID;
  80562. protected _effectiveBarOffset: number;
  80563. protected _renderLeft: number;
  80564. protected _renderTop: number;
  80565. protected _renderWidth: number;
  80566. protected _renderHeight: number;
  80567. protected _backgroundBoxLength: number;
  80568. protected _backgroundBoxThickness: number;
  80569. protected _effectiveThumbThickness: number;
  80570. /** BABYLON.Observable raised when the sldier value changes */
  80571. onValueChangedObservable: BABYLON.Observable<number>;
  80572. /** Gets or sets a boolean indicating if the thumb must be rendered */
  80573. get displayThumb(): boolean;
  80574. set displayThumb(value: boolean);
  80575. /** Gets or sets a step to apply to values (0 by default) */
  80576. get step(): number;
  80577. set step(value: number);
  80578. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  80579. get barOffset(): string | number;
  80580. /** Gets main bar offset in pixels*/
  80581. get barOffsetInPixels(): number;
  80582. set barOffset(value: string | number);
  80583. /** Gets or sets thumb width */
  80584. get thumbWidth(): string | number;
  80585. /** Gets thumb width in pixels */
  80586. get thumbWidthInPixels(): number;
  80587. set thumbWidth(value: string | number);
  80588. /** Gets or sets minimum value */
  80589. get minimum(): number;
  80590. set minimum(value: number);
  80591. /** Gets or sets maximum value */
  80592. get maximum(): number;
  80593. set maximum(value: number);
  80594. /** Gets or sets current value */
  80595. get value(): number;
  80596. set value(value: number);
  80597. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  80598. get isVertical(): boolean;
  80599. set isVertical(value: boolean);
  80600. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  80601. get isThumbClamped(): boolean;
  80602. set isThumbClamped(value: boolean);
  80603. /**
  80604. * Creates a new BaseSlider
  80605. * @param name defines the control name
  80606. */
  80607. constructor(name?: string | undefined);
  80608. protected _getTypeName(): string;
  80609. protected _getThumbPosition(): number;
  80610. protected _getThumbThickness(type: string): number;
  80611. protected _prepareRenderingData(type: string): void;
  80612. private _pointerIsDown;
  80613. /** @hidden */
  80614. protected _updateValueFromPointer(x: number, y: number): void;
  80615. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  80616. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number, pi: BABYLON.PointerInfoBase): void;
  80617. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  80618. _onCanvasBlur(): void;
  80619. }
  80620. }
  80621. declare module BABYLON.GUI {
  80622. /**
  80623. * Class used to create slider controls
  80624. */
  80625. export class Slider extends BaseSlider {
  80626. name?: string | undefined;
  80627. private _background;
  80628. private _borderColor;
  80629. private _thumbColor;
  80630. private _isThumbCircle;
  80631. protected _displayValueBar: boolean;
  80632. /** Gets or sets a boolean indicating if the value bar must be rendered */
  80633. get displayValueBar(): boolean;
  80634. set displayValueBar(value: boolean);
  80635. /** Gets or sets border color */
  80636. get borderColor(): string;
  80637. set borderColor(value: string);
  80638. /** Gets or sets background color */
  80639. get background(): string;
  80640. set background(value: string);
  80641. /** Gets or sets thumb's color */
  80642. get thumbColor(): string;
  80643. set thumbColor(value: string);
  80644. /** Gets or sets a boolean indicating if the thumb should be round or square */
  80645. get isThumbCircle(): boolean;
  80646. set isThumbCircle(value: boolean);
  80647. /**
  80648. * Creates a new Slider
  80649. * @param name defines the control name
  80650. */
  80651. constructor(name?: string | undefined);
  80652. protected _getTypeName(): string;
  80653. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  80654. }
  80655. }
  80656. declare module BABYLON.GUI {
  80657. /** Class used to create a RadioGroup
  80658. * which contains groups of radio buttons
  80659. */
  80660. export class SelectorGroup {
  80661. /** name of SelectorGroup */
  80662. name: string;
  80663. private _groupPanel;
  80664. private _selectors;
  80665. private _groupHeader;
  80666. /**
  80667. * Creates a new SelectorGroup
  80668. * @param name of group, used as a group heading
  80669. */
  80670. constructor(
  80671. /** name of SelectorGroup */
  80672. name: string);
  80673. /** Gets the groupPanel of the SelectorGroup */
  80674. get groupPanel(): StackPanel;
  80675. /** Gets the selectors array */
  80676. get selectors(): StackPanel[];
  80677. /** Gets and sets the group header */
  80678. get header(): string;
  80679. set header(label: string);
  80680. /** @hidden */
  80681. private _addGroupHeader;
  80682. /** @hidden*/
  80683. _getSelector(selectorNb: number): StackPanel | undefined;
  80684. /** Removes the selector at the given position
  80685. * @param selectorNb the position of the selector within the group
  80686. */
  80687. removeSelector(selectorNb: number): void;
  80688. }
  80689. /** Class used to create a CheckboxGroup
  80690. * which contains groups of checkbox buttons
  80691. */
  80692. export class CheckboxGroup extends SelectorGroup {
  80693. /** Adds a checkbox as a control
  80694. * @param text is the label for the selector
  80695. * @param func is the function called when the Selector is checked
  80696. * @param checked is true when Selector is checked
  80697. */
  80698. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  80699. /** @hidden */
  80700. _setSelectorLabel(selectorNb: number, label: string): void;
  80701. /** @hidden */
  80702. _setSelectorLabelColor(selectorNb: number, color: string): void;
  80703. /** @hidden */
  80704. _setSelectorButtonColor(selectorNb: number, color: string): void;
  80705. /** @hidden */
  80706. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  80707. }
  80708. /** Class used to create a RadioGroup
  80709. * which contains groups of radio buttons
  80710. */
  80711. export class RadioGroup extends SelectorGroup {
  80712. private _selectNb;
  80713. /** Adds a radio button as a control
  80714. * @param label is the label for the selector
  80715. * @param func is the function called when the Selector is checked
  80716. * @param checked is true when Selector is checked
  80717. */
  80718. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  80719. /** @hidden */
  80720. _setSelectorLabel(selectorNb: number, label: string): void;
  80721. /** @hidden */
  80722. _setSelectorLabelColor(selectorNb: number, color: string): void;
  80723. /** @hidden */
  80724. _setSelectorButtonColor(selectorNb: number, color: string): void;
  80725. /** @hidden */
  80726. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  80727. }
  80728. /** Class used to create a SliderGroup
  80729. * which contains groups of slider buttons
  80730. */
  80731. export class SliderGroup extends SelectorGroup {
  80732. /**
  80733. * Adds a slider to the SelectorGroup
  80734. * @param label is the label for the SliderBar
  80735. * @param func is the function called when the Slider moves
  80736. * @param unit is a string describing the units used, eg degrees or metres
  80737. * @param min is the minimum value for the Slider
  80738. * @param max is the maximum value for the Slider
  80739. * @param value is the start value for the Slider between min and max
  80740. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  80741. */
  80742. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  80743. /** @hidden */
  80744. _setSelectorLabel(selectorNb: number, label: string): void;
  80745. /** @hidden */
  80746. _setSelectorLabelColor(selectorNb: number, color: string): void;
  80747. /** @hidden */
  80748. _setSelectorButtonColor(selectorNb: number, color: string): void;
  80749. /** @hidden */
  80750. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  80751. }
  80752. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  80753. * @see https://doc.babylonjs.com/how_to/selector
  80754. */
  80755. export class SelectionPanel extends Rectangle {
  80756. /** name of SelectionPanel */
  80757. name: string;
  80758. /** an array of SelectionGroups */
  80759. groups: SelectorGroup[];
  80760. private _panel;
  80761. private _buttonColor;
  80762. private _buttonBackground;
  80763. private _headerColor;
  80764. private _barColor;
  80765. private _barHeight;
  80766. private _spacerHeight;
  80767. private _labelColor;
  80768. private _groups;
  80769. private _bars;
  80770. /**
  80771. * Creates a new SelectionPanel
  80772. * @param name of SelectionPanel
  80773. * @param groups is an array of SelectionGroups
  80774. */
  80775. constructor(
  80776. /** name of SelectionPanel */
  80777. name: string,
  80778. /** an array of SelectionGroups */
  80779. groups?: SelectorGroup[]);
  80780. protected _getTypeName(): string;
  80781. /** Gets the (stack) panel of the SelectionPanel */
  80782. get panel(): StackPanel;
  80783. /** Gets or sets the headerColor */
  80784. get headerColor(): string;
  80785. set headerColor(color: string);
  80786. private _setHeaderColor;
  80787. /** Gets or sets the button color */
  80788. get buttonColor(): string;
  80789. set buttonColor(color: string);
  80790. private _setbuttonColor;
  80791. /** Gets or sets the label color */
  80792. get labelColor(): string;
  80793. set labelColor(color: string);
  80794. private _setLabelColor;
  80795. /** Gets or sets the button background */
  80796. get buttonBackground(): string;
  80797. set buttonBackground(color: string);
  80798. private _setButtonBackground;
  80799. /** Gets or sets the color of separator bar */
  80800. get barColor(): string;
  80801. set barColor(color: string);
  80802. private _setBarColor;
  80803. /** Gets or sets the height of separator bar */
  80804. get barHeight(): string;
  80805. set barHeight(value: string);
  80806. private _setBarHeight;
  80807. /** Gets or sets the height of spacers*/
  80808. get spacerHeight(): string;
  80809. set spacerHeight(value: string);
  80810. private _setSpacerHeight;
  80811. /** Adds a bar between groups */
  80812. private _addSpacer;
  80813. /** Add a group to the selection panel
  80814. * @param group is the selector group to add
  80815. */
  80816. addGroup(group: SelectorGroup): void;
  80817. /** Remove the group from the given position
  80818. * @param groupNb is the position of the group in the list
  80819. */
  80820. removeGroup(groupNb: number): void;
  80821. /** Change a group header label
  80822. * @param label is the new group header label
  80823. * @param groupNb is the number of the group to relabel
  80824. * */
  80825. setHeaderName(label: string, groupNb: number): void;
  80826. /** Change selector label to the one given
  80827. * @param label is the new selector label
  80828. * @param groupNb is the number of the groupcontaining the selector
  80829. * @param selectorNb is the number of the selector within a group to relabel
  80830. * */
  80831. relabel(label: string, groupNb: number, selectorNb: number): void;
  80832. /** For a given group position remove the selector at the given position
  80833. * @param groupNb is the number of the group to remove the selector from
  80834. * @param selectorNb is the number of the selector within the group
  80835. */
  80836. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  80837. /** For a given group position of correct type add a checkbox button
  80838. * @param groupNb is the number of the group to remove the selector from
  80839. * @param label is the label for the selector
  80840. * @param func is the function called when the Selector is checked
  80841. * @param checked is true when Selector is checked
  80842. */
  80843. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  80844. /** For a given group position of correct type add a radio button
  80845. * @param groupNb is the number of the group to remove the selector from
  80846. * @param label is the label for the selector
  80847. * @param func is the function called when the Selector is checked
  80848. * @param checked is true when Selector is checked
  80849. */
  80850. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  80851. /**
  80852. * For a given slider group add a slider
  80853. * @param groupNb is the number of the group to add the slider to
  80854. * @param label is the label for the Slider
  80855. * @param func is the function called when the Slider moves
  80856. * @param unit is a string describing the units used, eg degrees or metres
  80857. * @param min is the minimum value for the Slider
  80858. * @param max is the maximum value for the Slider
  80859. * @param value is the start value for the Slider between min and max
  80860. * @param onVal is the function used to format the value displayed, eg radians to degrees
  80861. */
  80862. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  80863. }
  80864. }
  80865. declare module BABYLON.GUI {
  80866. /**
  80867. * Class used to hold a the container for ScrollViewer
  80868. * @hidden
  80869. */
  80870. export class _ScrollViewerWindow extends Container {
  80871. parentClientWidth: number;
  80872. parentClientHeight: number;
  80873. private _freezeControls;
  80874. private _parentMeasure;
  80875. private _oldLeft;
  80876. private _oldTop;
  80877. get freezeControls(): boolean;
  80878. set freezeControls(value: boolean);
  80879. private _bucketWidth;
  80880. private _bucketHeight;
  80881. private _buckets;
  80882. private _bucketLen;
  80883. get bucketWidth(): number;
  80884. get bucketHeight(): number;
  80885. setBucketSizes(width: number, height: number): void;
  80886. private _useBuckets;
  80887. private _makeBuckets;
  80888. private _dispatchInBuckets;
  80889. private _updateMeasures;
  80890. private _updateChildrenMeasures;
  80891. private _restoreMeasures;
  80892. /**
  80893. * Creates a new ScrollViewerWindow
  80894. * @param name of ScrollViewerWindow
  80895. */
  80896. constructor(name?: string);
  80897. protected _getTypeName(): string;
  80898. /** @hidden */
  80899. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  80900. /** @hidden */
  80901. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  80902. private _scrollChildren;
  80903. private _scrollChildrenWithBuckets;
  80904. /** @hidden */
  80905. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  80906. protected _postMeasure(): void;
  80907. }
  80908. }
  80909. declare module BABYLON.GUI {
  80910. /**
  80911. * Class used to create slider controls
  80912. */
  80913. export class ScrollBar extends BaseSlider {
  80914. name?: string | undefined;
  80915. private _background;
  80916. private _borderColor;
  80917. private _tempMeasure;
  80918. /** Gets or sets border color */
  80919. get borderColor(): string;
  80920. set borderColor(value: string);
  80921. /** Gets or sets background color */
  80922. get background(): string;
  80923. set background(value: string);
  80924. /**
  80925. * Creates a new Slider
  80926. * @param name defines the control name
  80927. */
  80928. constructor(name?: string | undefined);
  80929. protected _getTypeName(): string;
  80930. protected _getThumbThickness(): number;
  80931. _draw(context: CanvasRenderingContext2D): void;
  80932. private _first;
  80933. private _originX;
  80934. private _originY;
  80935. /** @hidden */
  80936. protected _updateValueFromPointer(x: number, y: number): void;
  80937. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  80938. }
  80939. }
  80940. declare module BABYLON.GUI {
  80941. /**
  80942. * Class used to create slider controls
  80943. */
  80944. export class ImageScrollBar extends BaseSlider {
  80945. name?: string | undefined;
  80946. private _backgroundBaseImage;
  80947. private _backgroundImage;
  80948. private _thumbImage;
  80949. private _thumbBaseImage;
  80950. private _thumbLength;
  80951. private _thumbHeight;
  80952. private _barImageHeight;
  80953. private _tempMeasure;
  80954. /** Number of 90° rotation to apply on the images when in vertical mode */
  80955. num90RotationInVerticalMode: number;
  80956. /**
  80957. * Gets or sets the image used to render the background for horizontal bar
  80958. */
  80959. get backgroundImage(): Image;
  80960. set backgroundImage(value: Image);
  80961. /**
  80962. * Gets or sets the image used to render the thumb
  80963. */
  80964. get thumbImage(): Image;
  80965. set thumbImage(value: Image);
  80966. /**
  80967. * Gets or sets the length of the thumb
  80968. */
  80969. get thumbLength(): number;
  80970. set thumbLength(value: number);
  80971. /**
  80972. * Gets or sets the height of the thumb
  80973. */
  80974. get thumbHeight(): number;
  80975. set thumbHeight(value: number);
  80976. /**
  80977. * Gets or sets the height of the bar image
  80978. */
  80979. get barImageHeight(): number;
  80980. set barImageHeight(value: number);
  80981. /**
  80982. * Creates a new ImageScrollBar
  80983. * @param name defines the control name
  80984. */
  80985. constructor(name?: string | undefined);
  80986. protected _getTypeName(): string;
  80987. protected _getThumbThickness(): number;
  80988. _draw(context: CanvasRenderingContext2D): void;
  80989. private _first;
  80990. private _originX;
  80991. private _originY;
  80992. /** @hidden */
  80993. protected _updateValueFromPointer(x: number, y: number): void;
  80994. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  80995. }
  80996. }
  80997. declare module BABYLON.GUI {
  80998. /**
  80999. * Class used to hold a viewer window and sliders in a grid
  81000. */
  81001. export class ScrollViewer extends Rectangle {
  81002. private _grid;
  81003. private _horizontalBarSpace;
  81004. private _verticalBarSpace;
  81005. private _dragSpace;
  81006. private _horizontalBar;
  81007. private _verticalBar;
  81008. private _barColor;
  81009. private _barBackground;
  81010. private _barImage;
  81011. private _horizontalBarImage;
  81012. private _verticalBarImage;
  81013. private _barBackgroundImage;
  81014. private _horizontalBarBackgroundImage;
  81015. private _verticalBarBackgroundImage;
  81016. private _barSize;
  81017. private _window;
  81018. private _pointerIsOver;
  81019. private _wheelPrecision;
  81020. private _onWheelObserver;
  81021. private _clientWidth;
  81022. private _clientHeight;
  81023. private _useImageBar;
  81024. private _thumbLength;
  81025. private _thumbHeight;
  81026. private _barImageHeight;
  81027. private _horizontalBarImageHeight;
  81028. private _verticalBarImageHeight;
  81029. private _oldWindowContentsWidth;
  81030. private _oldWindowContentsHeight;
  81031. /**
  81032. * Gets the horizontal scrollbar
  81033. */
  81034. get horizontalBar(): ScrollBar | ImageScrollBar;
  81035. /**
  81036. * Gets the vertical scrollbar
  81037. */
  81038. get verticalBar(): ScrollBar | ImageScrollBar;
  81039. /**
  81040. * Adds a new control to the current container
  81041. * @param control defines the control to add
  81042. * @returns the current container
  81043. */
  81044. addControl(control: BABYLON.Nullable<Control>): Container;
  81045. /**
  81046. * Removes a control from the current container
  81047. * @param control defines the control to remove
  81048. * @returns the current container
  81049. */
  81050. removeControl(control: Control): Container;
  81051. /** Gets the list of children */
  81052. get children(): Control[];
  81053. _flagDescendantsAsMatrixDirty(): void;
  81054. /**
  81055. * Freezes or unfreezes the controls in the window.
  81056. * When controls are frozen, the scroll viewer can render a lot more quickly but updates to positions/sizes of controls
  81057. * are not taken into account. If you want to change positions/sizes, unfreeze, perform the changes then freeze again
  81058. */
  81059. get freezeControls(): boolean;
  81060. set freezeControls(value: boolean);
  81061. /** Gets the bucket width */
  81062. get bucketWidth(): number;
  81063. /** Gets the bucket height */
  81064. get bucketHeight(): number;
  81065. /**
  81066. * Sets the bucket sizes.
  81067. * When freezeControls is true, setting a non-zero bucket size will improve performances by updating only
  81068. * controls that are visible. The bucket sizes is used to subdivide (internally) the window area to smaller areas into which
  81069. * controls are dispatched. So, the size should be roughly equals to the mean size of all the controls of
  81070. * the window. To disable the usage of buckets, sets either width or height (or both) to 0.
  81071. * Please note that using this option will raise the memory usage (the higher the bucket sizes, the less memory
  81072. * used), that's why it is not enabled by default.
  81073. * @param width width of the bucket
  81074. * @param height height of the bucket
  81075. */
  81076. setBucketSizes(width: number, height: number): void;
  81077. private _forceHorizontalBar;
  81078. private _forceVerticalBar;
  81079. /**
  81080. * Forces the horizontal scroll bar to be displayed
  81081. */
  81082. get forceHorizontalBar(): boolean;
  81083. set forceHorizontalBar(value: boolean);
  81084. /**
  81085. * Forces the vertical scroll bar to be displayed
  81086. */
  81087. get forceVerticalBar(): boolean;
  81088. set forceVerticalBar(value: boolean);
  81089. /**
  81090. * Creates a new ScrollViewer
  81091. * @param name of ScrollViewer
  81092. */
  81093. constructor(name?: string, isImageBased?: boolean);
  81094. /** Reset the scroll viewer window to initial size */
  81095. resetWindow(): void;
  81096. protected _getTypeName(): string;
  81097. private _buildClientSizes;
  81098. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  81099. protected _postMeasure(): void;
  81100. /**
  81101. * Gets or sets the mouse wheel precision
  81102. * from 0 to 1 with a default value of 0.05
  81103. * */
  81104. get wheelPrecision(): number;
  81105. set wheelPrecision(value: number);
  81106. /** Gets or sets the scroll bar container background color */
  81107. get scrollBackground(): string;
  81108. set scrollBackground(color: string);
  81109. /** Gets or sets the bar color */
  81110. get barColor(): string;
  81111. set barColor(color: string);
  81112. /** Gets or sets the bar image */
  81113. get thumbImage(): Image;
  81114. set thumbImage(value: Image);
  81115. /** Gets or sets the horizontal bar image */
  81116. get horizontalThumbImage(): Image;
  81117. set horizontalThumbImage(value: Image);
  81118. /** Gets or sets the vertical bar image */
  81119. get verticalThumbImage(): Image;
  81120. set verticalThumbImage(value: Image);
  81121. /** Gets or sets the size of the bar */
  81122. get barSize(): number;
  81123. set barSize(value: number);
  81124. /** Gets or sets the length of the thumb */
  81125. get thumbLength(): number;
  81126. set thumbLength(value: number);
  81127. /** Gets or sets the height of the thumb */
  81128. get thumbHeight(): number;
  81129. set thumbHeight(value: number);
  81130. /** Gets or sets the height of the bar image */
  81131. get barImageHeight(): number;
  81132. set barImageHeight(value: number);
  81133. /** Gets or sets the height of the horizontal bar image */
  81134. get horizontalBarImageHeight(): number;
  81135. set horizontalBarImageHeight(value: number);
  81136. /** Gets or sets the height of the vertical bar image */
  81137. get verticalBarImageHeight(): number;
  81138. set verticalBarImageHeight(value: number);
  81139. /** Gets or sets the bar background */
  81140. get barBackground(): string;
  81141. set barBackground(color: string);
  81142. /** Gets or sets the bar background image */
  81143. get barImage(): Image;
  81144. set barImage(value: Image);
  81145. /** Gets or sets the horizontal bar background image */
  81146. get horizontalBarImage(): Image;
  81147. set horizontalBarImage(value: Image);
  81148. /** Gets or sets the vertical bar background image */
  81149. get verticalBarImage(): Image;
  81150. set verticalBarImage(value: Image);
  81151. private _setWindowPosition;
  81152. /** @hidden */
  81153. private _updateScroller;
  81154. _link(host: AdvancedDynamicTexture): void;
  81155. /** @hidden */
  81156. private _addBar;
  81157. /** @hidden */
  81158. private _attachWheel;
  81159. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  81160. /** Releases associated resources */
  81161. dispose(): void;
  81162. }
  81163. }
  81164. declare module BABYLON.GUI {
  81165. /** Class used to render a grid */
  81166. export class DisplayGrid extends Control {
  81167. name?: string | undefined;
  81168. private _cellWidth;
  81169. private _cellHeight;
  81170. private _minorLineTickness;
  81171. private _minorLineColor;
  81172. private _majorLineTickness;
  81173. private _majorLineColor;
  81174. private _majorLineFrequency;
  81175. private _background;
  81176. private _displayMajorLines;
  81177. private _displayMinorLines;
  81178. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  81179. get displayMinorLines(): boolean;
  81180. set displayMinorLines(value: boolean);
  81181. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  81182. get displayMajorLines(): boolean;
  81183. set displayMajorLines(value: boolean);
  81184. /** Gets or sets background color (Black by default) */
  81185. get background(): string;
  81186. set background(value: string);
  81187. /** Gets or sets the width of each cell (20 by default) */
  81188. get cellWidth(): number;
  81189. set cellWidth(value: number);
  81190. /** Gets or sets the height of each cell (20 by default) */
  81191. get cellHeight(): number;
  81192. set cellHeight(value: number);
  81193. /** Gets or sets the tickness of minor lines (1 by default) */
  81194. get minorLineTickness(): number;
  81195. set minorLineTickness(value: number);
  81196. /** Gets or sets the color of minor lines (DarkGray by default) */
  81197. get minorLineColor(): string;
  81198. set minorLineColor(value: string);
  81199. /** Gets or sets the tickness of major lines (2 by default) */
  81200. get majorLineTickness(): number;
  81201. set majorLineTickness(value: number);
  81202. /** Gets or sets the color of major lines (White by default) */
  81203. get majorLineColor(): string;
  81204. set majorLineColor(value: string);
  81205. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  81206. get majorLineFrequency(): number;
  81207. set majorLineFrequency(value: number);
  81208. /**
  81209. * Creates a new GridDisplayRectangle
  81210. * @param name defines the control name
  81211. */
  81212. constructor(name?: string | undefined);
  81213. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  81214. protected _getTypeName(): string;
  81215. }
  81216. }
  81217. declare module BABYLON.GUI {
  81218. /**
  81219. * Class used to create slider controls based on images
  81220. */
  81221. export class ImageBasedSlider extends BaseSlider {
  81222. name?: string | undefined;
  81223. private _backgroundImage;
  81224. private _thumbImage;
  81225. private _valueBarImage;
  81226. private _tempMeasure;
  81227. get displayThumb(): boolean;
  81228. set displayThumb(value: boolean);
  81229. /**
  81230. * Gets or sets the image used to render the background
  81231. */
  81232. get backgroundImage(): Image;
  81233. set backgroundImage(value: Image);
  81234. /**
  81235. * Gets or sets the image used to render the value bar
  81236. */
  81237. get valueBarImage(): Image;
  81238. set valueBarImage(value: Image);
  81239. /**
  81240. * Gets or sets the image used to render the thumb
  81241. */
  81242. get thumbImage(): Image;
  81243. set thumbImage(value: Image);
  81244. /**
  81245. * Creates a new ImageBasedSlider
  81246. * @param name defines the control name
  81247. */
  81248. constructor(name?: string | undefined);
  81249. protected _getTypeName(): string;
  81250. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  81251. }
  81252. }
  81253. declare module BABYLON.GUI {
  81254. /**
  81255. * Forcing an export so that this code will execute
  81256. * @hidden
  81257. */
  81258. const name = "Statics";
  81259. }
  81260. declare module BABYLON.GUI {
  81261. /**
  81262. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  81263. */
  81264. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  81265. /**
  81266. * Define the instrumented AdvancedDynamicTexture.
  81267. */
  81268. texture: AdvancedDynamicTexture;
  81269. private _captureRenderTime;
  81270. private _renderTime;
  81271. private _captureLayoutTime;
  81272. private _layoutTime;
  81273. private _onBeginRenderObserver;
  81274. private _onEndRenderObserver;
  81275. private _onBeginLayoutObserver;
  81276. private _onEndLayoutObserver;
  81277. /**
  81278. * Gets the perf counter used to capture render time
  81279. */
  81280. get renderTimeCounter(): BABYLON.PerfCounter;
  81281. /**
  81282. * Gets the perf counter used to capture layout time
  81283. */
  81284. get layoutTimeCounter(): BABYLON.PerfCounter;
  81285. /**
  81286. * Enable or disable the render time capture
  81287. */
  81288. get captureRenderTime(): boolean;
  81289. set captureRenderTime(value: boolean);
  81290. /**
  81291. * Enable or disable the layout time capture
  81292. */
  81293. get captureLayoutTime(): boolean;
  81294. set captureLayoutTime(value: boolean);
  81295. /**
  81296. * Instantiates a new advanced dynamic texture instrumentation.
  81297. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  81298. * @param texture Defines the AdvancedDynamicTexture to instrument
  81299. */
  81300. constructor(
  81301. /**
  81302. * Define the instrumented AdvancedDynamicTexture.
  81303. */
  81304. texture: AdvancedDynamicTexture);
  81305. /**
  81306. * Dispose and release associated resources.
  81307. */
  81308. dispose(): void;
  81309. }
  81310. }
  81311. declare module BABYLON.GUI {
  81312. /**
  81313. * Class used to load GUI via XML.
  81314. */
  81315. export class XmlLoader {
  81316. private _nodes;
  81317. private _nodeTypes;
  81318. private _isLoaded;
  81319. private _objectAttributes;
  81320. private _parentClass;
  81321. /**
  81322. * Create a new xml loader
  81323. * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context
  81324. */
  81325. constructor(parentClass?: null);
  81326. private _getChainElement;
  81327. private _getClassAttribute;
  81328. private _createGuiElement;
  81329. private _parseGrid;
  81330. private _parseElement;
  81331. private _prepareSourceElement;
  81332. private _parseElementsFromSource;
  81333. private _parseXml;
  81334. /**
  81335. * Gets if the loading has finished.
  81336. * @returns whether the loading has finished or not
  81337. */
  81338. isLoaded(): boolean;
  81339. /**
  81340. * Gets a loaded node / control by id.
  81341. * @param id the Controls id set in the xml
  81342. * @returns element of type Control
  81343. */
  81344. getNodeById(id: string): any;
  81345. /**
  81346. * Gets all loaded nodes / controls
  81347. * @returns Array of controls
  81348. */
  81349. getNodes(): any;
  81350. /**
  81351. * Initiates the xml layout loading
  81352. * @param xmlFile defines the xml layout to load
  81353. * @param rootNode defines the node / control to use as a parent for the loaded layout controls.
  81354. * @param callback defines the callback called on layout load.
  81355. */
  81356. loadLayout(xmlFile: any, rootNode: any, callback: any): void;
  81357. }
  81358. }
  81359. declare module BABYLON.GUI {
  81360. /**
  81361. * Class used to create containers for controls
  81362. */
  81363. export class Container3D extends Control3D {
  81364. private _blockLayout;
  81365. /**
  81366. * Gets the list of child controls
  81367. */
  81368. protected _children: Control3D[];
  81369. /**
  81370. * Gets the list of child controls
  81371. */
  81372. get children(): Array<Control3D>;
  81373. /**
  81374. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  81375. * This is helpful to optimize layout operation when adding multiple children in a row
  81376. */
  81377. get blockLayout(): boolean;
  81378. set blockLayout(value: boolean);
  81379. /**
  81380. * Creates a new container
  81381. * @param name defines the container name
  81382. */
  81383. constructor(name?: string);
  81384. /**
  81385. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  81386. * @returns the current container
  81387. */
  81388. updateLayout(): Container3D;
  81389. /**
  81390. * Gets a boolean indicating if the given control is in the children of this control
  81391. * @param control defines the control to check
  81392. * @returns true if the control is in the child list
  81393. */
  81394. containsControl(control: Control3D): boolean;
  81395. /**
  81396. * Adds a control to the children of this control
  81397. * @param control defines the control to add
  81398. * @returns the current container
  81399. */
  81400. addControl(control: Control3D): Container3D;
  81401. /**
  81402. * This function will be called everytime a new control is added
  81403. */
  81404. protected _arrangeChildren(): void;
  81405. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  81406. /**
  81407. * Removes a control from the children of this control
  81408. * @param control defines the control to remove
  81409. * @returns the current container
  81410. */
  81411. removeControl(control: Control3D): Container3D;
  81412. protected _getTypeName(): string;
  81413. /**
  81414. * Releases all associated resources
  81415. */
  81416. dispose(): void;
  81417. /** Control rotation will remain unchanged */
  81418. static readonly UNSET_ORIENTATION: number;
  81419. /** Control will rotate to make it look at sphere central axis */
  81420. static readonly FACEORIGIN_ORIENTATION: number;
  81421. /** Control will rotate to make it look back at sphere central axis */
  81422. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  81423. /** Control will rotate to look at z axis (0, 0, 1) */
  81424. static readonly FACEFORWARD_ORIENTATION: number;
  81425. /** Control will rotate to look at negative z axis (0, 0, -1) */
  81426. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  81427. }
  81428. }
  81429. declare module BABYLON.GUI {
  81430. /**
  81431. * Class used to manage 3D user interface
  81432. * @see https://doc.babylonjs.com/how_to/gui3d
  81433. */
  81434. export class GUI3DManager implements BABYLON.IDisposable {
  81435. private _scene;
  81436. private _sceneDisposeObserver;
  81437. private _utilityLayer;
  81438. private _rootContainer;
  81439. private _pointerObserver;
  81440. private _pointerOutObserver;
  81441. /** @hidden */
  81442. _lastPickedControl: Control3D;
  81443. /** @hidden */
  81444. _lastControlOver: {
  81445. [pointerId: number]: Control3D;
  81446. };
  81447. /** @hidden */
  81448. _lastControlDown: {
  81449. [pointerId: number]: Control3D;
  81450. };
  81451. /**
  81452. * BABYLON.Observable raised when the point picked by the pointer events changed
  81453. */
  81454. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  81455. /** @hidden */
  81456. _sharedMaterials: {
  81457. [key: string]: BABYLON.Material;
  81458. };
  81459. /** Gets the hosting scene */
  81460. get scene(): BABYLON.Scene;
  81461. /** Gets associated utility layer */
  81462. get utilityLayer(): BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  81463. /**
  81464. * Creates a new GUI3DManager
  81465. * @param scene
  81466. */
  81467. constructor(scene?: BABYLON.Scene);
  81468. private _handlePointerOut;
  81469. private _doPicking;
  81470. /**
  81471. * Gets the root container
  81472. */
  81473. get rootContainer(): Container3D;
  81474. /**
  81475. * Gets a boolean indicating if the given control is in the root child list
  81476. * @param control defines the control to check
  81477. * @returns true if the control is in the root child list
  81478. */
  81479. containsControl(control: Control3D): boolean;
  81480. /**
  81481. * Adds a control to the root child list
  81482. * @param control defines the control to add
  81483. * @returns the current manager
  81484. */
  81485. addControl(control: Control3D): GUI3DManager;
  81486. /**
  81487. * Removes a control from the root child list
  81488. * @param control defines the control to remove
  81489. * @returns the current container
  81490. */
  81491. removeControl(control: Control3D): GUI3DManager;
  81492. /**
  81493. * Releases all associated resources
  81494. */
  81495. dispose(): void;
  81496. }
  81497. }
  81498. declare module BABYLON.GUI {
  81499. /**
  81500. * Class used to transport BABYLON.Vector3 information for pointer events
  81501. */
  81502. export class Vector3WithInfo extends BABYLON.Vector3 {
  81503. /** defines the current mouse button index */
  81504. buttonIndex: number;
  81505. /**
  81506. * Creates a new Vector3WithInfo
  81507. * @param source defines the vector3 data to transport
  81508. * @param buttonIndex defines the current mouse button index
  81509. */
  81510. constructor(source: BABYLON.Vector3,
  81511. /** defines the current mouse button index */
  81512. buttonIndex?: number);
  81513. }
  81514. }
  81515. declare module BABYLON.GUI {
  81516. /**
  81517. * Class used as base class for controls
  81518. */
  81519. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  81520. /** Defines the control name */
  81521. name?: string | undefined;
  81522. /** @hidden */
  81523. _host: GUI3DManager;
  81524. private _node;
  81525. private _downCount;
  81526. private _enterCount;
  81527. private _downPointerIds;
  81528. private _isVisible;
  81529. /** Gets or sets the control position in world space */
  81530. get position(): BABYLON.Vector3;
  81531. set position(value: BABYLON.Vector3);
  81532. /** Gets or sets the control scaling in world space */
  81533. get scaling(): BABYLON.Vector3;
  81534. set scaling(value: BABYLON.Vector3);
  81535. /** Callback used to start pointer enter animation */
  81536. pointerEnterAnimation: () => void;
  81537. /** Callback used to start pointer out animation */
  81538. pointerOutAnimation: () => void;
  81539. /** Callback used to start pointer down animation */
  81540. pointerDownAnimation: () => void;
  81541. /** Callback used to start pointer up animation */
  81542. pointerUpAnimation: () => void;
  81543. /**
  81544. * An event triggered when the pointer move over the control
  81545. */
  81546. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  81547. /**
  81548. * An event triggered when the pointer move out of the control
  81549. */
  81550. onPointerOutObservable: BABYLON.Observable<Control3D>;
  81551. /**
  81552. * An event triggered when the pointer taps the control
  81553. */
  81554. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  81555. /**
  81556. * An event triggered when pointer is up
  81557. */
  81558. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  81559. /**
  81560. * An event triggered when a control is clicked on (with a mouse)
  81561. */
  81562. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  81563. /**
  81564. * An event triggered when pointer enters the control
  81565. */
  81566. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  81567. /**
  81568. * Gets or sets the parent container
  81569. */
  81570. parent: BABYLON.Nullable<Container3D>;
  81571. private _behaviors;
  81572. /**
  81573. * Gets the list of attached behaviors
  81574. * @see https://doc.babylonjs.com/features/behaviour
  81575. */
  81576. get behaviors(): BABYLON.Behavior<Control3D>[];
  81577. /**
  81578. * Attach a behavior to the control
  81579. * @see https://doc.babylonjs.com/features/behaviour
  81580. * @param behavior defines the behavior to attach
  81581. * @returns the current control
  81582. */
  81583. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  81584. /**
  81585. * Remove an attached behavior
  81586. * @see https://doc.babylonjs.com/features/behaviour
  81587. * @param behavior defines the behavior to attach
  81588. * @returns the current control
  81589. */
  81590. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  81591. /**
  81592. * Gets an attached behavior by name
  81593. * @param name defines the name of the behavior to look for
  81594. * @see https://doc.babylonjs.com/features/behaviour
  81595. * @returns null if behavior was not found else the requested behavior
  81596. */
  81597. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  81598. /** Gets or sets a boolean indicating if the control is visible */
  81599. get isVisible(): boolean;
  81600. set isVisible(value: boolean);
  81601. /**
  81602. * Creates a new control
  81603. * @param name defines the control name
  81604. */
  81605. constructor(
  81606. /** Defines the control name */
  81607. name?: string | undefined);
  81608. /**
  81609. * Gets a string representing the class name
  81610. */
  81611. get typeName(): string;
  81612. /**
  81613. * Get the current class name of the control.
  81614. * @returns current class name
  81615. */
  81616. getClassName(): string;
  81617. protected _getTypeName(): string;
  81618. /**
  81619. * Gets the transform node used by this control
  81620. */
  81621. get node(): BABYLON.Nullable<BABYLON.TransformNode>;
  81622. /**
  81623. * Gets the mesh used to render this control
  81624. */
  81625. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  81626. /**
  81627. * Link the control as child of the given node
  81628. * @param node defines the node to link to. Use null to unlink the control
  81629. * @returns the current control
  81630. */
  81631. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  81632. /** @hidden **/
  81633. _prepareNode(scene: BABYLON.Scene): void;
  81634. /**
  81635. * Node creation.
  81636. * Can be overriden by children
  81637. * @param scene defines the scene where the node must be attached
  81638. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  81639. */
  81640. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  81641. /**
  81642. * Affect a material to the given mesh
  81643. * @param mesh defines the mesh which will represent the control
  81644. */
  81645. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  81646. /** @hidden */
  81647. _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  81648. /** @hidden */
  81649. _onPointerEnter(target: Control3D): boolean;
  81650. /** @hidden */
  81651. _onPointerOut(target: Control3D): void;
  81652. /** @hidden */
  81653. _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  81654. /** @hidden */
  81655. _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  81656. /** @hidden */
  81657. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  81658. /** @hidden */
  81659. _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  81660. /** @hidden */
  81661. _disposeNode(): void;
  81662. /**
  81663. * Releases all associated resources
  81664. */
  81665. dispose(): void;
  81666. }
  81667. }
  81668. declare module BABYLON.GUI {
  81669. /**
  81670. * Class used as a root to all buttons
  81671. */
  81672. export class AbstractButton3D extends Control3D {
  81673. /**
  81674. * Creates a new button
  81675. * @param name defines the control name
  81676. */
  81677. constructor(name?: string);
  81678. protected _getTypeName(): string;
  81679. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  81680. }
  81681. }
  81682. declare module BABYLON.GUI {
  81683. /**
  81684. * Class used to create a button in 3D
  81685. */
  81686. export class Button3D extends AbstractButton3D {
  81687. /** @hidden */
  81688. protected _currentMaterial: BABYLON.Material;
  81689. private _facadeTexture;
  81690. private _content;
  81691. private _contentResolution;
  81692. private _contentScaleRatio;
  81693. /**
  81694. * Gets or sets the texture resolution used to render content (512 by default)
  81695. */
  81696. get contentResolution(): BABYLON.int;
  81697. set contentResolution(value: BABYLON.int);
  81698. /**
  81699. * Gets or sets the texture scale ratio used to render content (2 by default)
  81700. */
  81701. get contentScaleRatio(): number;
  81702. set contentScaleRatio(value: number);
  81703. protected _disposeFacadeTexture(): void;
  81704. protected _resetContent(): void;
  81705. /**
  81706. * Creates a new button
  81707. * @param name defines the control name
  81708. */
  81709. constructor(name?: string);
  81710. /**
  81711. * Gets or sets the GUI 2D content used to display the button's facade
  81712. */
  81713. get content(): Control;
  81714. set content(value: Control);
  81715. /**
  81716. * Apply the facade texture (created from the content property).
  81717. * This function can be overloaded by child classes
  81718. * @param facadeTexture defines the AdvancedDynamicTexture to use
  81719. */
  81720. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  81721. protected _getTypeName(): string;
  81722. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  81723. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  81724. /**
  81725. * Releases all associated resources
  81726. */
  81727. dispose(): void;
  81728. }
  81729. }
  81730. declare module BABYLON.GUI {
  81731. /**
  81732. * Abstract class used to create a container panel deployed on the surface of a volume
  81733. */
  81734. export abstract class VolumeBasedPanel extends Container3D {
  81735. private _columns;
  81736. private _rows;
  81737. private _rowThenColum;
  81738. private _orientation;
  81739. protected _cellWidth: number;
  81740. protected _cellHeight: number;
  81741. /**
  81742. * Gets or sets the distance between elements
  81743. */
  81744. margin: number;
  81745. /**
  81746. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  81747. * | Value | Type | Description |
  81748. * | ----- | ----------------------------------- | ----------- |
  81749. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  81750. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  81751. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  81752. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  81753. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  81754. */
  81755. get orientation(): number;
  81756. set orientation(value: number);
  81757. /**
  81758. * Gets or sets the number of columns requested (10 by default).
  81759. * The panel will automatically compute the number of rows based on number of child controls.
  81760. */
  81761. get columns(): BABYLON.int;
  81762. set columns(value: BABYLON.int);
  81763. /**
  81764. * Gets or sets a the number of rows requested.
  81765. * The panel will automatically compute the number of columns based on number of child controls.
  81766. */
  81767. get rows(): BABYLON.int;
  81768. set rows(value: BABYLON.int);
  81769. /**
  81770. * Creates new VolumeBasedPanel
  81771. */
  81772. constructor();
  81773. protected _arrangeChildren(): void;
  81774. /** Child classes must implement this function to provide correct control positioning */
  81775. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  81776. /** Child classes can implement this function to provide additional processing */
  81777. protected _finalProcessing(): void;
  81778. }
  81779. }
  81780. declare module BABYLON.GUI {
  81781. /**
  81782. * Class used to create a container panel deployed on the surface of a cylinder
  81783. */
  81784. export class CylinderPanel extends VolumeBasedPanel {
  81785. private _radius;
  81786. /**
  81787. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  81788. */
  81789. get radius(): BABYLON.float;
  81790. set radius(value: BABYLON.float);
  81791. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  81792. private _cylindricalMapping;
  81793. }
  81794. }
  81795. declare module BABYLON.GUI {
  81796. /** @hidden */
  81797. export var fluentVertexShader: {
  81798. name: string;
  81799. shader: string;
  81800. };
  81801. }
  81802. declare module BABYLON.GUI {
  81803. /** @hidden */
  81804. export var fluentPixelShader: {
  81805. name: string;
  81806. shader: string;
  81807. };
  81808. }
  81809. declare module BABYLON.GUI {
  81810. /** @hidden */
  81811. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  81812. INNERGLOW: boolean;
  81813. BORDER: boolean;
  81814. HOVERLIGHT: boolean;
  81815. TEXTURE: boolean;
  81816. constructor();
  81817. }
  81818. /**
  81819. * Class used to render controls with fluent desgin
  81820. */
  81821. export class FluentMaterial extends BABYLON.PushMaterial {
  81822. /**
  81823. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  81824. */
  81825. innerGlowColorIntensity: number;
  81826. /**
  81827. * Gets or sets the inner glow color (white by default)
  81828. */
  81829. innerGlowColor: BABYLON.Color3;
  81830. /**
  81831. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  81832. */
  81833. albedoColor: BABYLON.Color3;
  81834. /**
  81835. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  81836. */
  81837. renderBorders: boolean;
  81838. /**
  81839. * Gets or sets border width (default is 0.5)
  81840. */
  81841. borderWidth: number;
  81842. /**
  81843. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  81844. */
  81845. edgeSmoothingValue: number;
  81846. /**
  81847. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  81848. */
  81849. borderMinValue: number;
  81850. /**
  81851. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  81852. */
  81853. renderHoverLight: boolean;
  81854. /**
  81855. * Gets or sets the radius used to render the hover light (default is 1.0)
  81856. */
  81857. hoverRadius: number;
  81858. /**
  81859. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  81860. */
  81861. hoverColor: BABYLON.Color4;
  81862. /**
  81863. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  81864. */
  81865. hoverPosition: BABYLON.Vector3;
  81866. private _albedoTexture;
  81867. /** Gets or sets the texture to use for albedo color */
  81868. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  81869. /**
  81870. * Creates a new Fluent material
  81871. * @param name defines the name of the material
  81872. * @param scene defines the hosting scene
  81873. */
  81874. constructor(name: string, scene: BABYLON.Scene);
  81875. needAlphaBlending(): boolean;
  81876. needAlphaTesting(): boolean;
  81877. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  81878. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  81879. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  81880. getActiveTextures(): BABYLON.BaseTexture[];
  81881. hasTexture(texture: BABYLON.BaseTexture): boolean;
  81882. dispose(forceDisposeEffect?: boolean): void;
  81883. clone(name: string): FluentMaterial;
  81884. serialize(): any;
  81885. getClassName(): string;
  81886. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  81887. }
  81888. }
  81889. declare module BABYLON.GUI {
  81890. /**
  81891. * Class used to create a holographic button in 3D
  81892. */
  81893. export class HolographicButton extends Button3D {
  81894. private _backPlate;
  81895. private _textPlate;
  81896. private _frontPlate;
  81897. private _text;
  81898. private _imageUrl;
  81899. private _shareMaterials;
  81900. private _frontMaterial;
  81901. private _backMaterial;
  81902. private _plateMaterial;
  81903. private _pickedPointObserver;
  81904. private _tooltipFade;
  81905. private _tooltipTextBlock;
  81906. private _tooltipTexture;
  81907. private _tooltipMesh;
  81908. private _tooltipHoverObserver;
  81909. private _tooltipOutObserver;
  81910. private _disposeTooltip;
  81911. /**
  81912. * Rendering ground id of all the mesh in the button
  81913. */
  81914. set renderingGroupId(id: number);
  81915. get renderingGroupId(): number;
  81916. /**
  81917. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  81918. */
  81919. set tooltipText(text: BABYLON.Nullable<string>);
  81920. get tooltipText(): BABYLON.Nullable<string>;
  81921. /**
  81922. * Gets or sets text for the button
  81923. */
  81924. get text(): string;
  81925. set text(value: string);
  81926. /**
  81927. * Gets or sets the image url for the button
  81928. */
  81929. get imageUrl(): string;
  81930. set imageUrl(value: string);
  81931. /**
  81932. * Gets the back material used by this button
  81933. */
  81934. get backMaterial(): FluentMaterial;
  81935. /**
  81936. * Gets the front material used by this button
  81937. */
  81938. get frontMaterial(): FluentMaterial;
  81939. /**
  81940. * Gets the plate material used by this button
  81941. */
  81942. get plateMaterial(): BABYLON.StandardMaterial;
  81943. /**
  81944. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  81945. */
  81946. get shareMaterials(): boolean;
  81947. /**
  81948. * Creates a new button
  81949. * @param name defines the control name
  81950. */
  81951. constructor(name?: string, shareMaterials?: boolean);
  81952. protected _getTypeName(): string;
  81953. private _rebuildContent;
  81954. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  81955. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  81956. private _createBackMaterial;
  81957. private _createFrontMaterial;
  81958. private _createPlateMaterial;
  81959. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  81960. /**
  81961. * Releases all associated resources
  81962. */
  81963. dispose(): void;
  81964. }
  81965. }
  81966. declare module BABYLON.GUI {
  81967. /**
  81968. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  81969. */
  81970. export class MeshButton3D extends Button3D {
  81971. /** @hidden */
  81972. protected _currentMesh: BABYLON.Mesh;
  81973. /**
  81974. * Creates a new 3D button based on a mesh
  81975. * @param mesh mesh to become a 3D button
  81976. * @param name defines the control name
  81977. */
  81978. constructor(mesh: BABYLON.Mesh, name?: string);
  81979. protected _getTypeName(): string;
  81980. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  81981. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  81982. }
  81983. }
  81984. declare module BABYLON.GUI {
  81985. /**
  81986. * Class used to create a container panel deployed on the surface of a plane
  81987. */
  81988. export class PlanePanel extends VolumeBasedPanel {
  81989. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  81990. }
  81991. }
  81992. declare module BABYLON.GUI {
  81993. /**
  81994. * Class used to create a container panel where items get randomized planar mapping
  81995. */
  81996. export class ScatterPanel extends VolumeBasedPanel {
  81997. private _iteration;
  81998. /**
  81999. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  82000. */
  82001. get iteration(): BABYLON.float;
  82002. set iteration(value: BABYLON.float);
  82003. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  82004. private _scatterMapping;
  82005. protected _finalProcessing(): void;
  82006. }
  82007. }
  82008. declare module BABYLON.GUI {
  82009. /**
  82010. * Class used to create a container panel deployed on the surface of a sphere
  82011. */
  82012. export class SpherePanel extends VolumeBasedPanel {
  82013. private _radius;
  82014. /**
  82015. * Gets or sets the radius of the sphere where to project controls (5 by default)
  82016. */
  82017. get radius(): BABYLON.float;
  82018. set radius(value: BABYLON.float);
  82019. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  82020. private _sphericalMapping;
  82021. }
  82022. }
  82023. declare module BABYLON.GUI {
  82024. /**
  82025. * Class used to create a stack panel in 3D on XY plane
  82026. */
  82027. export class StackPanel3D extends Container3D {
  82028. private _isVertical;
  82029. /**
  82030. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  82031. */
  82032. get isVertical(): boolean;
  82033. set isVertical(value: boolean);
  82034. /**
  82035. * Gets or sets the distance between elements
  82036. */
  82037. margin: number;
  82038. /**
  82039. * Creates new StackPanel
  82040. * @param isVertical
  82041. */
  82042. constructor(isVertical?: boolean);
  82043. protected _arrangeChildren(): void;
  82044. }
  82045. }
  82046. declare module BABYLON {
  82047. /**
  82048. * Configuration for glTF validation
  82049. */
  82050. export interface IGLTFValidationConfiguration {
  82051. /**
  82052. * The url of the glTF validator.
  82053. */
  82054. url: string;
  82055. }
  82056. /**
  82057. * glTF validation
  82058. */
  82059. export class GLTFValidation {
  82060. /**
  82061. * The configuration. Defaults to `{ url: "https://preview.babylonjs.com/gltf_validator.js" }`.
  82062. */
  82063. static Configuration: IGLTFValidationConfiguration;
  82064. private static _LoadScriptPromise;
  82065. /**
  82066. * Validate a glTF asset using the glTF-Validator.
  82067. * @param data The JSON of a glTF or the array buffer of a binary glTF
  82068. * @param rootUrl The root url for the glTF
  82069. * @param fileName The file name for the glTF
  82070. * @param getExternalResource The callback to get external resources for the glTF validator
  82071. * @returns A promise that resolves with the glTF validation results once complete
  82072. */
  82073. static ValidateAsync(data: string | ArrayBuffer, rootUrl: string, fileName: string, getExternalResource: (uri: string) => Promise<ArrayBuffer>): Promise<BABYLON.GLTF2.IGLTFValidationResults>;
  82074. }
  82075. }
  82076. declare module BABYLON {
  82077. /**
  82078. * Mode that determines the coordinate system to use.
  82079. */
  82080. export enum GLTFLoaderCoordinateSystemMode {
  82081. /**
  82082. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  82083. */
  82084. AUTO = 0,
  82085. /**
  82086. * Sets the useRightHandedSystem flag on the scene.
  82087. */
  82088. FORCE_RIGHT_HANDED = 1
  82089. }
  82090. /**
  82091. * Mode that determines what animations will start.
  82092. */
  82093. export enum GLTFLoaderAnimationStartMode {
  82094. /**
  82095. * No animation will start.
  82096. */
  82097. NONE = 0,
  82098. /**
  82099. * The first animation will start.
  82100. */
  82101. FIRST = 1,
  82102. /**
  82103. * All animations will start.
  82104. */
  82105. ALL = 2
  82106. }
  82107. /**
  82108. * Interface that contains the data for the glTF asset.
  82109. */
  82110. export interface IGLTFLoaderData {
  82111. /**
  82112. * The object that represents the glTF JSON.
  82113. */
  82114. json: Object;
  82115. /**
  82116. * The BIN chunk of a binary glTF.
  82117. */
  82118. bin: Nullable<IDataBuffer>;
  82119. }
  82120. /**
  82121. * Interface for extending the loader.
  82122. */
  82123. export interface IGLTFLoaderExtension {
  82124. /**
  82125. * The name of this extension.
  82126. */
  82127. readonly name: string;
  82128. /**
  82129. * Defines whether this extension is enabled.
  82130. */
  82131. enabled: boolean;
  82132. /**
  82133. * Defines the order of this extension.
  82134. * The loader sorts the extensions using these values when loading.
  82135. */
  82136. order?: number;
  82137. }
  82138. /**
  82139. * Loader state.
  82140. */
  82141. export enum GLTFLoaderState {
  82142. /**
  82143. * The asset is loading.
  82144. */
  82145. LOADING = 0,
  82146. /**
  82147. * The asset is ready for rendering.
  82148. */
  82149. READY = 1,
  82150. /**
  82151. * The asset is completely loaded.
  82152. */
  82153. COMPLETE = 2
  82154. }
  82155. /** @hidden */
  82156. export interface IGLTFLoader extends IDisposable {
  82157. readonly state: Nullable<GLTFLoaderState>;
  82158. importMeshAsync: (meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string) => Promise<ISceneLoaderAsyncResult>;
  82159. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  82160. }
  82161. /**
  82162. * File loader for loading glTF files into a scene.
  82163. */
  82164. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  82165. /** @hidden */
  82166. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  82167. /** @hidden */
  82168. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  82169. /**
  82170. * Raised when the asset has been parsed
  82171. */
  82172. onParsedObservable: Observable<IGLTFLoaderData>;
  82173. private _onParsedObserver;
  82174. /**
  82175. * Raised when the asset has been parsed
  82176. */
  82177. set onParsed(callback: (loaderData: IGLTFLoaderData) => void);
  82178. /**
  82179. * 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.
  82180. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  82181. * Defaults to true.
  82182. * @hidden
  82183. */
  82184. static IncrementalLoading: boolean;
  82185. /**
  82186. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  82187. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  82188. * @hidden
  82189. */
  82190. static HomogeneousCoordinates: boolean;
  82191. /**
  82192. * The coordinate system mode. Defaults to AUTO.
  82193. */
  82194. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  82195. /**
  82196. * The animation start mode. Defaults to FIRST.
  82197. */
  82198. animationStartMode: GLTFLoaderAnimationStartMode;
  82199. /**
  82200. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  82201. */
  82202. compileMaterials: boolean;
  82203. /**
  82204. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  82205. */
  82206. useClipPlane: boolean;
  82207. /**
  82208. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  82209. */
  82210. compileShadowGenerators: boolean;
  82211. /**
  82212. * Defines if the Alpha blended materials are only applied as coverage.
  82213. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  82214. * If true, no extra effects are applied to transparent pixels.
  82215. */
  82216. transparencyAsCoverage: boolean;
  82217. /**
  82218. * Defines if the loader should use range requests when load binary glTF files from HTTP.
  82219. * Enabling will disable offline support and glTF validator.
  82220. * Defaults to false.
  82221. */
  82222. useRangeRequests: boolean;
  82223. /**
  82224. * Defines if the loader should create instances when multiple glTF nodes point to the same glTF mesh. Defaults to true.
  82225. */
  82226. createInstances: boolean;
  82227. /**
  82228. * 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.
  82229. */
  82230. alwaysComputeBoundingBox: boolean;
  82231. /**
  82232. * If true, load all materials defined in the file, even if not used by any mesh. Defaults to false.
  82233. */
  82234. loadAllMaterials: boolean;
  82235. /**
  82236. * Function called before loading a url referenced by the asset.
  82237. */
  82238. preprocessUrlAsync: (url: string) => Promise<string>;
  82239. /**
  82240. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  82241. * 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, ...)
  82242. */
  82243. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  82244. private _onMeshLoadedObserver;
  82245. /**
  82246. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  82247. * 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, ...)
  82248. */
  82249. set onMeshLoaded(callback: (mesh: AbstractMesh) => void);
  82250. /**
  82251. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  82252. */
  82253. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  82254. private _onTextureLoadedObserver;
  82255. /**
  82256. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  82257. */
  82258. set onTextureLoaded(callback: (texture: BaseTexture) => void);
  82259. /**
  82260. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  82261. */
  82262. readonly onMaterialLoadedObservable: Observable<Material>;
  82263. private _onMaterialLoadedObserver;
  82264. /**
  82265. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  82266. */
  82267. set onMaterialLoaded(callback: (material: Material) => void);
  82268. /**
  82269. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  82270. */
  82271. readonly onCameraLoadedObservable: Observable<Camera>;
  82272. private _onCameraLoadedObserver;
  82273. /**
  82274. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  82275. */
  82276. set onCameraLoaded(callback: (camera: Camera) => void);
  82277. /**
  82278. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  82279. * For assets with LODs, raised when all of the LODs are complete.
  82280. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  82281. */
  82282. readonly onCompleteObservable: Observable<void>;
  82283. private _onCompleteObserver;
  82284. /**
  82285. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  82286. * For assets with LODs, raised when all of the LODs are complete.
  82287. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  82288. */
  82289. set onComplete(callback: () => void);
  82290. /**
  82291. * Observable raised when an error occurs.
  82292. */
  82293. readonly onErrorObservable: Observable<any>;
  82294. private _onErrorObserver;
  82295. /**
  82296. * Callback raised when an error occurs.
  82297. */
  82298. set onError(callback: (reason: any) => void);
  82299. /**
  82300. * Observable raised after the loader is disposed.
  82301. */
  82302. readonly onDisposeObservable: Observable<void>;
  82303. private _onDisposeObserver;
  82304. /**
  82305. * Callback raised after the loader is disposed.
  82306. */
  82307. set onDispose(callback: () => void);
  82308. /**
  82309. * Observable raised after a loader extension is created.
  82310. * Set additional options for a loader extension in this event.
  82311. */
  82312. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  82313. private _onExtensionLoadedObserver;
  82314. /**
  82315. * Callback raised after a loader extension is created.
  82316. */
  82317. set onExtensionLoaded(callback: (extension: IGLTFLoaderExtension) => void);
  82318. /**
  82319. * Defines if the loader logging is enabled.
  82320. */
  82321. get loggingEnabled(): boolean;
  82322. set loggingEnabled(value: boolean);
  82323. /**
  82324. * Defines if the loader should capture performance counters.
  82325. */
  82326. get capturePerformanceCounters(): boolean;
  82327. set capturePerformanceCounters(value: boolean);
  82328. /**
  82329. * Defines if the loader should validate the asset.
  82330. */
  82331. validate: boolean;
  82332. /**
  82333. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  82334. */
  82335. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  82336. private _onValidatedObserver;
  82337. /**
  82338. * Callback raised after a loader extension is created.
  82339. */
  82340. set onValidated(callback: (results: BABYLON.GLTF2.IGLTFValidationResults) => void);
  82341. private _loader;
  82342. private _progressCallback?;
  82343. private _requests;
  82344. private static magicBase64Encoded;
  82345. /**
  82346. * Name of the loader ("gltf")
  82347. */
  82348. name: string;
  82349. /** @hidden */
  82350. extensions: ISceneLoaderPluginExtensions;
  82351. /**
  82352. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  82353. */
  82354. dispose(): void;
  82355. /** @hidden */
  82356. requestFile(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  82357. /** @hidden */
  82358. readFile(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  82359. /** @hidden */
  82360. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<ISceneLoaderAsyncResult>;
  82361. /** @hidden */
  82362. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  82363. /** @hidden */
  82364. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  82365. /** @hidden */
  82366. canDirectLoad(data: string): boolean;
  82367. /** @hidden */
  82368. directLoad(scene: Scene, data: string): Promise<any>;
  82369. /**
  82370. * The callback that allows custom handling of the root url based on the response url.
  82371. * @param rootUrl the original root url
  82372. * @param responseURL the response url if available
  82373. * @returns the new root url
  82374. */
  82375. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  82376. /** @hidden */
  82377. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  82378. /**
  82379. * The loader state or null if the loader is not active.
  82380. */
  82381. get loaderState(): Nullable<GLTFLoaderState>;
  82382. /**
  82383. * Returns a promise that resolves when the asset is completely loaded.
  82384. * @returns a promise that resolves when the asset is completely loaded.
  82385. */
  82386. whenCompleteAsync(): Promise<void>;
  82387. /** @hidden */
  82388. _loadFile(url: string, scene: Scene, onSuccess: (data: string | ArrayBuffer) => void, useArrayBuffer?: boolean, onError?: (request?: WebRequest) => void): IFileRequest;
  82389. /** @hidden */
  82390. _requestFile(url: string, scene: Scene, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  82391. private _onProgress;
  82392. private _validate;
  82393. private _getLoader;
  82394. private _parseJson;
  82395. private _unpackBinaryAsync;
  82396. private _unpackBinaryV1Async;
  82397. private _unpackBinaryV2Async;
  82398. private static _parseVersion;
  82399. private static _compareVersion;
  82400. private static readonly _logSpaces;
  82401. private _logIndentLevel;
  82402. private _loggingEnabled;
  82403. /** @hidden */
  82404. _log: (message: string) => void;
  82405. /** @hidden */
  82406. _logOpen(message: string): void;
  82407. /** @hidden */
  82408. _logClose(): void;
  82409. private _logEnabled;
  82410. private _logDisabled;
  82411. private _capturePerformanceCounters;
  82412. /** @hidden */
  82413. _startPerformanceCounter: (counterName: string) => void;
  82414. /** @hidden */
  82415. _endPerformanceCounter: (counterName: string) => void;
  82416. private _startPerformanceCounterEnabled;
  82417. private _startPerformanceCounterDisabled;
  82418. private _endPerformanceCounterEnabled;
  82419. private _endPerformanceCounterDisabled;
  82420. }
  82421. }
  82422. declare module BABYLON.GLTF1 {
  82423. /**
  82424. * Enums
  82425. * @hidden
  82426. */
  82427. export enum EComponentType {
  82428. BYTE = 5120,
  82429. UNSIGNED_BYTE = 5121,
  82430. SHORT = 5122,
  82431. UNSIGNED_SHORT = 5123,
  82432. FLOAT = 5126
  82433. }
  82434. /** @hidden */
  82435. export enum EShaderType {
  82436. FRAGMENT = 35632,
  82437. VERTEX = 35633
  82438. }
  82439. /** @hidden */
  82440. export enum EParameterType {
  82441. BYTE = 5120,
  82442. UNSIGNED_BYTE = 5121,
  82443. SHORT = 5122,
  82444. UNSIGNED_SHORT = 5123,
  82445. INT = 5124,
  82446. UNSIGNED_INT = 5125,
  82447. FLOAT = 5126,
  82448. FLOAT_VEC2 = 35664,
  82449. FLOAT_VEC3 = 35665,
  82450. FLOAT_VEC4 = 35666,
  82451. INT_VEC2 = 35667,
  82452. INT_VEC3 = 35668,
  82453. INT_VEC4 = 35669,
  82454. BOOL = 35670,
  82455. BOOL_VEC2 = 35671,
  82456. BOOL_VEC3 = 35672,
  82457. BOOL_VEC4 = 35673,
  82458. FLOAT_MAT2 = 35674,
  82459. FLOAT_MAT3 = 35675,
  82460. FLOAT_MAT4 = 35676,
  82461. SAMPLER_2D = 35678
  82462. }
  82463. /** @hidden */
  82464. export enum ETextureWrapMode {
  82465. CLAMP_TO_EDGE = 33071,
  82466. MIRRORED_REPEAT = 33648,
  82467. REPEAT = 10497
  82468. }
  82469. /** @hidden */
  82470. export enum ETextureFilterType {
  82471. NEAREST = 9728,
  82472. LINEAR = 9728,
  82473. NEAREST_MIPMAP_NEAREST = 9984,
  82474. LINEAR_MIPMAP_NEAREST = 9985,
  82475. NEAREST_MIPMAP_LINEAR = 9986,
  82476. LINEAR_MIPMAP_LINEAR = 9987
  82477. }
  82478. /** @hidden */
  82479. export enum ETextureFormat {
  82480. ALPHA = 6406,
  82481. RGB = 6407,
  82482. RGBA = 6408,
  82483. LUMINANCE = 6409,
  82484. LUMINANCE_ALPHA = 6410
  82485. }
  82486. /** @hidden */
  82487. export enum ECullingType {
  82488. FRONT = 1028,
  82489. BACK = 1029,
  82490. FRONT_AND_BACK = 1032
  82491. }
  82492. /** @hidden */
  82493. export enum EBlendingFunction {
  82494. ZERO = 0,
  82495. ONE = 1,
  82496. SRC_COLOR = 768,
  82497. ONE_MINUS_SRC_COLOR = 769,
  82498. DST_COLOR = 774,
  82499. ONE_MINUS_DST_COLOR = 775,
  82500. SRC_ALPHA = 770,
  82501. ONE_MINUS_SRC_ALPHA = 771,
  82502. DST_ALPHA = 772,
  82503. ONE_MINUS_DST_ALPHA = 773,
  82504. CONSTANT_COLOR = 32769,
  82505. ONE_MINUS_CONSTANT_COLOR = 32770,
  82506. CONSTANT_ALPHA = 32771,
  82507. ONE_MINUS_CONSTANT_ALPHA = 32772,
  82508. SRC_ALPHA_SATURATE = 776
  82509. }
  82510. /** @hidden */
  82511. export interface IGLTFProperty {
  82512. extensions?: {
  82513. [key: string]: any;
  82514. };
  82515. extras?: Object;
  82516. }
  82517. /** @hidden */
  82518. export interface IGLTFChildRootProperty extends IGLTFProperty {
  82519. name?: string;
  82520. }
  82521. /** @hidden */
  82522. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  82523. bufferView: string;
  82524. byteOffset: number;
  82525. byteStride: number;
  82526. count: number;
  82527. type: string;
  82528. componentType: EComponentType;
  82529. max?: number[];
  82530. min?: number[];
  82531. name?: string;
  82532. }
  82533. /** @hidden */
  82534. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  82535. buffer: string;
  82536. byteOffset: number;
  82537. byteLength: number;
  82538. byteStride: number;
  82539. target?: number;
  82540. }
  82541. /** @hidden */
  82542. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  82543. uri: string;
  82544. byteLength?: number;
  82545. type?: string;
  82546. }
  82547. /** @hidden */
  82548. export interface IGLTFShader extends IGLTFChildRootProperty {
  82549. uri: string;
  82550. type: EShaderType;
  82551. }
  82552. /** @hidden */
  82553. export interface IGLTFProgram extends IGLTFChildRootProperty {
  82554. attributes: string[];
  82555. fragmentShader: string;
  82556. vertexShader: string;
  82557. }
  82558. /** @hidden */
  82559. export interface IGLTFTechniqueParameter {
  82560. type: number;
  82561. count?: number;
  82562. semantic?: string;
  82563. node?: string;
  82564. value?: number | boolean | string | Array<any>;
  82565. source?: string;
  82566. babylonValue?: any;
  82567. }
  82568. /** @hidden */
  82569. export interface IGLTFTechniqueCommonProfile {
  82570. lightingModel: string;
  82571. texcoordBindings: Object;
  82572. parameters?: Array<any>;
  82573. }
  82574. /** @hidden */
  82575. export interface IGLTFTechniqueStatesFunctions {
  82576. blendColor?: number[];
  82577. blendEquationSeparate?: number[];
  82578. blendFuncSeparate?: number[];
  82579. colorMask: boolean[];
  82580. cullFace: number[];
  82581. }
  82582. /** @hidden */
  82583. export interface IGLTFTechniqueStates {
  82584. enable: number[];
  82585. functions: IGLTFTechniqueStatesFunctions;
  82586. }
  82587. /** @hidden */
  82588. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  82589. parameters: {
  82590. [key: string]: IGLTFTechniqueParameter;
  82591. };
  82592. program: string;
  82593. attributes: {
  82594. [key: string]: string;
  82595. };
  82596. uniforms: {
  82597. [key: string]: string;
  82598. };
  82599. states: IGLTFTechniqueStates;
  82600. }
  82601. /** @hidden */
  82602. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  82603. technique?: string;
  82604. values: string[];
  82605. }
  82606. /** @hidden */
  82607. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  82608. attributes: {
  82609. [key: string]: string;
  82610. };
  82611. indices: string;
  82612. material: string;
  82613. mode?: number;
  82614. }
  82615. /** @hidden */
  82616. export interface IGLTFMesh extends IGLTFChildRootProperty {
  82617. primitives: IGLTFMeshPrimitive[];
  82618. }
  82619. /** @hidden */
  82620. export interface IGLTFImage extends IGLTFChildRootProperty {
  82621. uri: string;
  82622. }
  82623. /** @hidden */
  82624. export interface IGLTFSampler extends IGLTFChildRootProperty {
  82625. magFilter?: number;
  82626. minFilter?: number;
  82627. wrapS?: number;
  82628. wrapT?: number;
  82629. }
  82630. /** @hidden */
  82631. export interface IGLTFTexture extends IGLTFChildRootProperty {
  82632. sampler: string;
  82633. source: string;
  82634. format?: ETextureFormat;
  82635. internalFormat?: ETextureFormat;
  82636. target?: number;
  82637. type?: number;
  82638. babylonTexture?: Texture;
  82639. }
  82640. /** @hidden */
  82641. export interface IGLTFAmbienLight {
  82642. color?: number[];
  82643. }
  82644. /** @hidden */
  82645. export interface IGLTFDirectionalLight {
  82646. color?: number[];
  82647. }
  82648. /** @hidden */
  82649. export interface IGLTFPointLight {
  82650. color?: number[];
  82651. constantAttenuation?: number;
  82652. linearAttenuation?: number;
  82653. quadraticAttenuation?: number;
  82654. }
  82655. /** @hidden */
  82656. export interface IGLTFSpotLight {
  82657. color?: number[];
  82658. constantAttenuation?: number;
  82659. fallOfAngle?: number;
  82660. fallOffExponent?: number;
  82661. linearAttenuation?: number;
  82662. quadraticAttenuation?: number;
  82663. }
  82664. /** @hidden */
  82665. export interface IGLTFLight extends IGLTFChildRootProperty {
  82666. type: string;
  82667. }
  82668. /** @hidden */
  82669. export interface IGLTFCameraOrthographic {
  82670. xmag: number;
  82671. ymag: number;
  82672. zfar: number;
  82673. znear: number;
  82674. }
  82675. /** @hidden */
  82676. export interface IGLTFCameraPerspective {
  82677. aspectRatio: number;
  82678. yfov: number;
  82679. zfar: number;
  82680. znear: number;
  82681. }
  82682. /** @hidden */
  82683. export interface IGLTFCamera extends IGLTFChildRootProperty {
  82684. type: string;
  82685. }
  82686. /** @hidden */
  82687. export interface IGLTFAnimationChannelTarget {
  82688. id: string;
  82689. path: string;
  82690. }
  82691. /** @hidden */
  82692. export interface IGLTFAnimationChannel {
  82693. sampler: string;
  82694. target: IGLTFAnimationChannelTarget;
  82695. }
  82696. /** @hidden */
  82697. export interface IGLTFAnimationSampler {
  82698. input: string;
  82699. output: string;
  82700. interpolation?: string;
  82701. }
  82702. /** @hidden */
  82703. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  82704. channels?: IGLTFAnimationChannel[];
  82705. parameters?: {
  82706. [key: string]: string;
  82707. };
  82708. samplers?: {
  82709. [key: string]: IGLTFAnimationSampler;
  82710. };
  82711. }
  82712. /** @hidden */
  82713. export interface IGLTFNodeInstanceSkin {
  82714. skeletons: string[];
  82715. skin: string;
  82716. meshes: string[];
  82717. }
  82718. /** @hidden */
  82719. export interface IGLTFSkins extends IGLTFChildRootProperty {
  82720. bindShapeMatrix: number[];
  82721. inverseBindMatrices: string;
  82722. jointNames: string[];
  82723. babylonSkeleton?: Skeleton;
  82724. }
  82725. /** @hidden */
  82726. export interface IGLTFNode extends IGLTFChildRootProperty {
  82727. camera?: string;
  82728. children: string[];
  82729. skin?: string;
  82730. jointName?: string;
  82731. light?: string;
  82732. matrix: number[];
  82733. mesh?: string;
  82734. meshes?: string[];
  82735. rotation?: number[];
  82736. scale?: number[];
  82737. translation?: number[];
  82738. babylonNode?: Node;
  82739. }
  82740. /** @hidden */
  82741. export interface IGLTFScene extends IGLTFChildRootProperty {
  82742. nodes: string[];
  82743. }
  82744. /** @hidden */
  82745. export interface IGLTFRuntime {
  82746. extensions: {
  82747. [key: string]: any;
  82748. };
  82749. accessors: {
  82750. [key: string]: IGLTFAccessor;
  82751. };
  82752. buffers: {
  82753. [key: string]: IGLTFBuffer;
  82754. };
  82755. bufferViews: {
  82756. [key: string]: IGLTFBufferView;
  82757. };
  82758. meshes: {
  82759. [key: string]: IGLTFMesh;
  82760. };
  82761. lights: {
  82762. [key: string]: IGLTFLight;
  82763. };
  82764. cameras: {
  82765. [key: string]: IGLTFCamera;
  82766. };
  82767. nodes: {
  82768. [key: string]: IGLTFNode;
  82769. };
  82770. images: {
  82771. [key: string]: IGLTFImage;
  82772. };
  82773. textures: {
  82774. [key: string]: IGLTFTexture;
  82775. };
  82776. shaders: {
  82777. [key: string]: IGLTFShader;
  82778. };
  82779. programs: {
  82780. [key: string]: IGLTFProgram;
  82781. };
  82782. samplers: {
  82783. [key: string]: IGLTFSampler;
  82784. };
  82785. techniques: {
  82786. [key: string]: IGLTFTechnique;
  82787. };
  82788. materials: {
  82789. [key: string]: IGLTFMaterial;
  82790. };
  82791. animations: {
  82792. [key: string]: IGLTFAnimation;
  82793. };
  82794. skins: {
  82795. [key: string]: IGLTFSkins;
  82796. };
  82797. currentScene?: Object;
  82798. scenes: {
  82799. [key: string]: IGLTFScene;
  82800. };
  82801. extensionsUsed: string[];
  82802. extensionsRequired?: string[];
  82803. buffersCount: number;
  82804. shaderscount: number;
  82805. scene: Scene;
  82806. rootUrl: string;
  82807. loadedBufferCount: number;
  82808. loadedBufferViews: {
  82809. [name: string]: ArrayBufferView;
  82810. };
  82811. loadedShaderCount: number;
  82812. importOnlyMeshes: boolean;
  82813. importMeshesNames?: string[];
  82814. dummyNodes: Node[];
  82815. forAssetContainer: boolean;
  82816. }
  82817. /** @hidden */
  82818. export interface INodeToRoot {
  82819. bone: Bone;
  82820. node: IGLTFNode;
  82821. id: string;
  82822. }
  82823. /** @hidden */
  82824. export interface IJointNode {
  82825. node: IGLTFNode;
  82826. id: string;
  82827. }
  82828. }
  82829. declare module BABYLON.GLTF1 {
  82830. /**
  82831. * Utils functions for GLTF
  82832. * @hidden
  82833. */
  82834. export class GLTFUtils {
  82835. /**
  82836. * Sets the given "parameter" matrix
  82837. * @param scene: the Scene object
  82838. * @param source: the source node where to pick the matrix
  82839. * @param parameter: the GLTF technique parameter
  82840. * @param uniformName: the name of the shader's uniform
  82841. * @param shaderMaterial: the shader material
  82842. */
  82843. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  82844. /**
  82845. * Sets the given "parameter" matrix
  82846. * @param shaderMaterial: the shader material
  82847. * @param uniform: the name of the shader's uniform
  82848. * @param value: the value of the uniform
  82849. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  82850. */
  82851. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  82852. /**
  82853. * Returns the wrap mode of the texture
  82854. * @param mode: the mode value
  82855. */
  82856. static GetWrapMode(mode: number): number;
  82857. /**
  82858. * Returns the byte stride giving an accessor
  82859. * @param accessor: the GLTF accessor objet
  82860. */
  82861. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  82862. /**
  82863. * Returns the texture filter mode giving a mode value
  82864. * @param mode: the filter mode value
  82865. */
  82866. static GetTextureFilterMode(mode: number): ETextureFilterType;
  82867. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  82868. /**
  82869. * Returns a buffer from its accessor
  82870. * @param gltfRuntime: the GLTF runtime
  82871. * @param accessor: the GLTF accessor
  82872. */
  82873. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  82874. /**
  82875. * Decodes a buffer view into a string
  82876. * @param view: the buffer view
  82877. */
  82878. static DecodeBufferToText(view: ArrayBufferView): string;
  82879. /**
  82880. * Returns the default material of gltf. Related to
  82881. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  82882. * @param scene: the Babylon.js scene
  82883. */
  82884. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  82885. private static _DefaultMaterial;
  82886. }
  82887. }
  82888. declare module BABYLON.GLTF1 {
  82889. /**
  82890. * Implementation of the base glTF spec
  82891. * @hidden
  82892. */
  82893. export class GLTFLoaderBase {
  82894. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  82895. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  82896. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  82897. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  82898. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  82899. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  82900. }
  82901. /**
  82902. * glTF V1 Loader
  82903. * @hidden
  82904. */
  82905. export class GLTFLoader implements IGLTFLoader {
  82906. static Extensions: {
  82907. [name: string]: GLTFLoaderExtension;
  82908. };
  82909. static RegisterExtension(extension: GLTFLoaderExtension): void;
  82910. state: Nullable<GLTFLoaderState>;
  82911. dispose(): void;
  82912. private _importMeshAsync;
  82913. /**
  82914. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  82915. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  82916. * @param scene the scene the meshes should be added to
  82917. * @param forAssetContainer defines if the entities must be stored in the scene
  82918. * @param data gltf data containing information of the meshes in a loaded file
  82919. * @param rootUrl root url to load from
  82920. * @param onProgress event that fires when loading progress has occured
  82921. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  82922. */
  82923. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void): Promise<ISceneLoaderAsyncResult>;
  82924. private _loadAsync;
  82925. /**
  82926. * Imports all objects from a loaded gltf file and adds them to the scene
  82927. * @param scene the scene the objects should be added to
  82928. * @param data gltf data containing information of the meshes in a loaded file
  82929. * @param rootUrl root url to load from
  82930. * @param onProgress event that fires when loading progress has occured
  82931. * @returns a promise which completes when objects have been loaded to the scene
  82932. */
  82933. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void): Promise<void>;
  82934. private _loadShadersAsync;
  82935. private _loadBuffersAsync;
  82936. private _createNodes;
  82937. }
  82938. /** @hidden */
  82939. export abstract class GLTFLoaderExtension {
  82940. private _name;
  82941. constructor(name: string);
  82942. get name(): string;
  82943. /**
  82944. * Defines an override for loading the runtime
  82945. * Return true to stop further extensions from loading the runtime
  82946. */
  82947. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  82948. /**
  82949. * Defines an onverride for creating gltf runtime
  82950. * Return true to stop further extensions from creating the runtime
  82951. */
  82952. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  82953. /**
  82954. * Defines an override for loading buffers
  82955. * Return true to stop further extensions from loading this buffer
  82956. */
  82957. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  82958. /**
  82959. * Defines an override for loading texture buffers
  82960. * Return true to stop further extensions from loading this texture data
  82961. */
  82962. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  82963. /**
  82964. * Defines an override for creating textures
  82965. * Return true to stop further extensions from loading this texture
  82966. */
  82967. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  82968. /**
  82969. * Defines an override for loading shader strings
  82970. * Return true to stop further extensions from loading this shader data
  82971. */
  82972. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  82973. /**
  82974. * Defines an override for loading materials
  82975. * Return true to stop further extensions from loading this material
  82976. */
  82977. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  82978. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  82979. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  82980. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  82981. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  82982. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  82983. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  82984. private static LoadTextureBufferAsync;
  82985. private static CreateTextureAsync;
  82986. private static ApplyExtensions;
  82987. }
  82988. }
  82989. declare module BABYLON.GLTF1 {
  82990. /** @hidden */
  82991. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  82992. private _bin;
  82993. constructor();
  82994. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  82995. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  82996. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  82997. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  82998. }
  82999. }
  83000. declare module BABYLON.GLTF1 {
  83001. /** @hidden */
  83002. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  83003. constructor();
  83004. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  83005. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  83006. private _loadTexture;
  83007. }
  83008. }
  83009. declare module BABYLON.GLTF2.Loader {
  83010. /**
  83011. * Loader interface with an index field.
  83012. */
  83013. export interface IArrayItem {
  83014. /**
  83015. * The index of this item in the array.
  83016. */
  83017. index: number;
  83018. }
  83019. /**
  83020. * Loader interface with additional members.
  83021. */
  83022. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  83023. /** @hidden */
  83024. _data?: Promise<ArrayBufferView>;
  83025. /** @hidden */
  83026. _babylonVertexBuffer?: Promise<VertexBuffer>;
  83027. }
  83028. /**
  83029. * Loader interface with additional members.
  83030. */
  83031. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  83032. }
  83033. /** @hidden */
  83034. export interface _IAnimationSamplerData {
  83035. input: Float32Array;
  83036. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  83037. output: Float32Array;
  83038. }
  83039. /**
  83040. * Loader interface with additional members.
  83041. */
  83042. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  83043. /** @hidden */
  83044. _data?: Promise<_IAnimationSamplerData>;
  83045. }
  83046. /**
  83047. * Loader interface with additional members.
  83048. */
  83049. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  83050. channels: IAnimationChannel[];
  83051. samplers: IAnimationSampler[];
  83052. /** @hidden */
  83053. _babylonAnimationGroup?: AnimationGroup;
  83054. }
  83055. /**
  83056. * Loader interface with additional members.
  83057. */
  83058. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  83059. /** @hidden */
  83060. _data?: Promise<ArrayBufferView>;
  83061. }
  83062. /**
  83063. * Loader interface with additional members.
  83064. */
  83065. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  83066. /** @hidden */
  83067. _data?: Promise<ArrayBufferView>;
  83068. /** @hidden */
  83069. _babylonBuffer?: Promise<Buffer>;
  83070. }
  83071. /**
  83072. * Loader interface with additional members.
  83073. */
  83074. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  83075. }
  83076. /**
  83077. * Loader interface with additional members.
  83078. */
  83079. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  83080. /** @hidden */
  83081. _data?: Promise<ArrayBufferView>;
  83082. }
  83083. /**
  83084. * Loader interface with additional members.
  83085. */
  83086. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  83087. }
  83088. /**
  83089. * Loader interface with additional members.
  83090. */
  83091. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  83092. }
  83093. /**
  83094. * Loader interface with additional members.
  83095. */
  83096. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  83097. baseColorTexture?: ITextureInfo;
  83098. metallicRoughnessTexture?: ITextureInfo;
  83099. }
  83100. /**
  83101. * Loader interface with additional members.
  83102. */
  83103. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  83104. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  83105. normalTexture?: IMaterialNormalTextureInfo;
  83106. occlusionTexture?: IMaterialOcclusionTextureInfo;
  83107. emissiveTexture?: ITextureInfo;
  83108. /** @hidden */
  83109. _data?: {
  83110. [babylonDrawMode: number]: {
  83111. babylonMaterial: Material;
  83112. babylonMeshes: AbstractMesh[];
  83113. promise: Promise<void>;
  83114. };
  83115. };
  83116. }
  83117. /**
  83118. * Loader interface with additional members.
  83119. */
  83120. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  83121. primitives: IMeshPrimitive[];
  83122. }
  83123. /**
  83124. * Loader interface with additional members.
  83125. */
  83126. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  83127. /** @hidden */
  83128. _instanceData?: {
  83129. babylonSourceMesh: Mesh;
  83130. promise: Promise<any>;
  83131. };
  83132. }
  83133. /**
  83134. * Loader interface with additional members.
  83135. */
  83136. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  83137. /**
  83138. * The parent glTF node.
  83139. */
  83140. parent?: INode;
  83141. /** @hidden */
  83142. _babylonTransformNode?: TransformNode;
  83143. /** @hidden */
  83144. _primitiveBabylonMeshes?: AbstractMesh[];
  83145. /** @hidden */
  83146. _babylonBones?: Bone[];
  83147. /** @hidden */
  83148. _numMorphTargets?: number;
  83149. }
  83150. /** @hidden */
  83151. export interface _ISamplerData {
  83152. noMipMaps: boolean;
  83153. samplingMode: number;
  83154. wrapU: number;
  83155. wrapV: number;
  83156. }
  83157. /**
  83158. * Loader interface with additional members.
  83159. */
  83160. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  83161. /** @hidden */
  83162. _data?: _ISamplerData;
  83163. }
  83164. /**
  83165. * Loader interface with additional members.
  83166. */
  83167. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  83168. }
  83169. /**
  83170. * Loader interface with additional members.
  83171. */
  83172. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  83173. /** @hidden */
  83174. _data?: {
  83175. babylonSkeleton: Skeleton;
  83176. promise: Promise<void>;
  83177. };
  83178. }
  83179. /**
  83180. * Loader interface with additional members.
  83181. */
  83182. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  83183. /** @hidden */
  83184. _textureInfo: ITextureInfo;
  83185. }
  83186. /**
  83187. * Loader interface with additional members.
  83188. */
  83189. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  83190. /** false or undefined if the texture holds color data (true if data are roughness, normal, ...) */
  83191. nonColorData?: boolean;
  83192. }
  83193. /**
  83194. * Loader interface with additional members.
  83195. */
  83196. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  83197. accessors?: IAccessor[];
  83198. animations?: IAnimation[];
  83199. buffers?: IBuffer[];
  83200. bufferViews?: IBufferView[];
  83201. cameras?: ICamera[];
  83202. images?: IImage[];
  83203. materials?: IMaterial[];
  83204. meshes?: IMesh[];
  83205. nodes?: INode[];
  83206. samplers?: ISampler[];
  83207. scenes?: IScene[];
  83208. skins?: ISkin[];
  83209. textures?: ITexture[];
  83210. }
  83211. }
  83212. declare module BABYLON.GLTF2 {
  83213. /**
  83214. * Interface for a glTF loader extension.
  83215. */
  83216. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  83217. /**
  83218. * Called after the loader state changes to LOADING.
  83219. */
  83220. onLoading?(): void;
  83221. /**
  83222. * Called after the loader state changes to READY.
  83223. */
  83224. onReady?(): void;
  83225. /**
  83226. * Define this method to modify the default behavior when loading scenes.
  83227. * @param context The context when loading the asset
  83228. * @param scene The glTF scene property
  83229. * @returns A promise that resolves when the load is complete or null if not handled
  83230. */
  83231. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  83232. /**
  83233. * Define this method to modify the default behavior when loading nodes.
  83234. * @param context The context when loading the asset
  83235. * @param node The glTF node property
  83236. * @param assign A function called synchronously after parsing the glTF properties
  83237. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  83238. */
  83239. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  83240. /**
  83241. * Define this method to modify the default behavior when loading cameras.
  83242. * @param context The context when loading the asset
  83243. * @param camera The glTF camera property
  83244. * @param assign A function called synchronously after parsing the glTF properties
  83245. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  83246. */
  83247. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  83248. /**
  83249. * @hidden
  83250. * Define this method to modify the default behavior when loading vertex data for mesh primitives.
  83251. * @param context The context when loading the asset
  83252. * @param primitive The glTF mesh primitive property
  83253. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  83254. */
  83255. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  83256. /**
  83257. * @hidden
  83258. * Define this method to modify the default behavior when loading data for mesh primitives.
  83259. * @param context The context when loading the asset
  83260. * @param name The mesh name when loading the asset
  83261. * @param node The glTF node when loading the asset
  83262. * @param mesh The glTF mesh when loading the asset
  83263. * @param primitive The glTF mesh primitive property
  83264. * @param assign A function called synchronously after parsing the glTF properties
  83265. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  83266. */
  83267. _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Nullable<Promise<AbstractMesh>>;
  83268. /**
  83269. * @hidden
  83270. * Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  83271. * @param context The context when loading the asset
  83272. * @param material The glTF material property
  83273. * @param assign A function called synchronously after parsing the glTF properties
  83274. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  83275. */
  83276. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Nullable<Mesh>, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  83277. /**
  83278. * Define this method to modify the default behavior when creating materials.
  83279. * @param context The context when loading the asset
  83280. * @param material The glTF material property
  83281. * @param babylonDrawMode The draw mode for the Babylon material
  83282. * @returns The Babylon material or null if not handled
  83283. */
  83284. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  83285. /**
  83286. * Define this method to modify the default behavior when loading material properties.
  83287. * @param context The context when loading the asset
  83288. * @param material The glTF material property
  83289. * @param babylonMaterial The Babylon material
  83290. * @returns A promise that resolves when the load is complete or null if not handled
  83291. */
  83292. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  83293. /**
  83294. * Define this method to modify the default behavior when loading texture infos.
  83295. * @param context The context when loading the asset
  83296. * @param textureInfo The glTF texture info property
  83297. * @param assign A function called synchronously after parsing the glTF properties
  83298. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  83299. */
  83300. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  83301. /**
  83302. * @hidden
  83303. * Define this method to modify the default behavior when loading textures.
  83304. * @param context The context when loading the asset
  83305. * @param texture The glTF texture property
  83306. * @param assign A function called synchronously after parsing the glTF properties
  83307. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  83308. */
  83309. _loadTextureAsync?(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  83310. /**
  83311. * Define this method to modify the default behavior when loading animations.
  83312. * @param context The context when loading the asset
  83313. * @param animation The glTF animation property
  83314. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  83315. */
  83316. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  83317. /**
  83318. * @hidden
  83319. * Define this method to modify the default behavior when loading skins.
  83320. * @param context The context when loading the asset
  83321. * @param node The glTF node property
  83322. * @param skin The glTF skin property
  83323. * @returns A promise that resolves when the load is complete or null if not handled
  83324. */
  83325. _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  83326. /**
  83327. * @hidden
  83328. * Define this method to modify the default behavior when loading uris.
  83329. * @param context The context when loading the asset
  83330. * @param property The glTF property associated with the uri
  83331. * @param uri The uri to load
  83332. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  83333. */
  83334. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  83335. /**
  83336. * Define this method to modify the default behavior when loading buffer views.
  83337. * @param context The context when loading the asset
  83338. * @param bufferView The glTF buffer view property
  83339. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  83340. */
  83341. loadBufferViewAsync?(context: string, bufferView: IBufferView): Nullable<Promise<ArrayBufferView>>;
  83342. /**
  83343. * Define this method to modify the default behavior when loading buffers.
  83344. * @param context The context when loading the asset
  83345. * @param buffer The glTF buffer property
  83346. * @param byteOffset The byte offset to load
  83347. * @param byteLength The byte length to load
  83348. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  83349. */
  83350. loadBufferAsync?(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  83351. }
  83352. }
  83353. declare module BABYLON.GLTF2 {
  83354. /**
  83355. * Helper class for working with arrays when loading the glTF asset
  83356. */
  83357. export class ArrayItem {
  83358. /**
  83359. * Gets an item from the given array.
  83360. * @param context The context when loading the asset
  83361. * @param array The array to get the item from
  83362. * @param index The index to the array
  83363. * @returns The array item
  83364. */
  83365. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  83366. /**
  83367. * Assign an `index` field to each item of the given array.
  83368. * @param array The array of items
  83369. */
  83370. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  83371. }
  83372. /**
  83373. * The glTF 2.0 loader
  83374. */
  83375. export class GLTFLoader implements IGLTFLoader {
  83376. /** @hidden */
  83377. _completePromises: Promise<any>[];
  83378. /** @hidden */
  83379. _forAssetContainer: boolean;
  83380. /** Storage */
  83381. _babylonLights: Light[];
  83382. /** @hidden */
  83383. _disableInstancedMesh: number;
  83384. private _disposed;
  83385. private _parent;
  83386. private _state;
  83387. private _extensions;
  83388. private _rootUrl;
  83389. private _fileName;
  83390. private _uniqueRootUrl;
  83391. private _gltf;
  83392. private _bin;
  83393. private _babylonScene;
  83394. private _rootBabylonMesh;
  83395. private _defaultBabylonMaterialData;
  83396. private static _RegisteredExtensions;
  83397. /**
  83398. * The default glTF sampler.
  83399. */
  83400. static readonly DefaultSampler: ISampler;
  83401. /**
  83402. * Registers a loader extension.
  83403. * @param name The name of the loader extension.
  83404. * @param factory The factory function that creates the loader extension.
  83405. */
  83406. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  83407. /**
  83408. * Unregisters a loader extension.
  83409. * @param name The name of the loader extension.
  83410. * @returns A boolean indicating whether the extension has been unregistered
  83411. */
  83412. static UnregisterExtension(name: string): boolean;
  83413. /**
  83414. * The loader state.
  83415. */
  83416. get state(): Nullable<GLTFLoaderState>;
  83417. /**
  83418. * The object that represents the glTF JSON.
  83419. */
  83420. get gltf(): IGLTF;
  83421. /**
  83422. * The BIN chunk of a binary glTF.
  83423. */
  83424. get bin(): Nullable<IDataBuffer>;
  83425. /**
  83426. * The parent file loader.
  83427. */
  83428. get parent(): GLTFFileLoader;
  83429. /**
  83430. * The Babylon scene when loading the asset.
  83431. */
  83432. get babylonScene(): Scene;
  83433. /**
  83434. * The root Babylon mesh when loading the asset.
  83435. */
  83436. get rootBabylonMesh(): Mesh;
  83437. /** @hidden */
  83438. constructor(parent: GLTFFileLoader);
  83439. /** @hidden */
  83440. dispose(): void;
  83441. /** @hidden */
  83442. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<ISceneLoaderAsyncResult>;
  83443. /** @hidden */
  83444. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  83445. private _loadAsync;
  83446. private _loadData;
  83447. private _setupData;
  83448. private _loadExtensions;
  83449. private _checkExtensions;
  83450. private _setState;
  83451. private _createRootNode;
  83452. /**
  83453. * Loads a glTF scene.
  83454. * @param context The context when loading the asset
  83455. * @param scene The glTF scene property
  83456. * @returns A promise that resolves when the load is complete
  83457. */
  83458. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  83459. private _forEachPrimitive;
  83460. private _getGeometries;
  83461. private _getMeshes;
  83462. private _getTransformNodes;
  83463. private _getSkeletons;
  83464. private _getAnimationGroups;
  83465. private _startAnimations;
  83466. /**
  83467. * Loads a glTF node.
  83468. * @param context The context when loading the asset
  83469. * @param node The glTF node property
  83470. * @param assign A function called synchronously after parsing the glTF properties
  83471. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  83472. */
  83473. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  83474. private _loadMeshAsync;
  83475. /**
  83476. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  83477. * @param context The context when loading the asset
  83478. * @param name The mesh name when loading the asset
  83479. * @param node The glTF node when loading the asset
  83480. * @param mesh The glTF mesh when loading the asset
  83481. * @param primitive The glTF mesh primitive property
  83482. * @param assign A function called synchronously after parsing the glTF properties
  83483. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  83484. */
  83485. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  83486. private _loadVertexDataAsync;
  83487. private _createMorphTargets;
  83488. private _loadMorphTargetsAsync;
  83489. private _loadMorphTargetVertexDataAsync;
  83490. private static _LoadTransform;
  83491. private _loadSkinAsync;
  83492. private _loadBones;
  83493. private _loadBone;
  83494. private _loadSkinInverseBindMatricesDataAsync;
  83495. private _updateBoneMatrices;
  83496. private _getNodeMatrix;
  83497. /**
  83498. * Loads a glTF camera.
  83499. * @param context The context when loading the asset
  83500. * @param camera The glTF camera property
  83501. * @param assign A function called synchronously after parsing the glTF properties
  83502. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  83503. */
  83504. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  83505. private _loadAnimationsAsync;
  83506. /**
  83507. * Loads a glTF animation.
  83508. * @param context The context when loading the asset
  83509. * @param animation The glTF animation property
  83510. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  83511. */
  83512. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  83513. /**
  83514. * @hidden Loads a glTF animation channel.
  83515. * @param context The context when loading the asset
  83516. * @param animationContext The context of the animation when loading the asset
  83517. * @param animation The glTF animation property
  83518. * @param channel The glTF animation channel property
  83519. * @param babylonAnimationGroup The babylon animation group property
  83520. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  83521. * @returns A void promise when the channel load is complete
  83522. */
  83523. _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  83524. private _loadAnimationSamplerAsync;
  83525. private _loadBufferAsync;
  83526. /**
  83527. * Loads a glTF buffer view.
  83528. * @param context The context when loading the asset
  83529. * @param bufferView The glTF buffer view property
  83530. * @returns A promise that resolves with the loaded data when the load is complete
  83531. */
  83532. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  83533. private _loadAccessorAsync;
  83534. /** @hidden */
  83535. _loadFloatAccessorAsync(context: string, accessor: IAccessor): Promise<Float32Array>;
  83536. private _loadIndicesAccessorAsync;
  83537. private _loadVertexBufferViewAsync;
  83538. private _loadVertexAccessorAsync;
  83539. private _loadMaterialMetallicRoughnessPropertiesAsync;
  83540. /** @hidden */
  83541. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Nullable<Mesh>, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  83542. private _createDefaultMaterial;
  83543. /**
  83544. * Creates a Babylon material from a glTF material.
  83545. * @param context The context when loading the asset
  83546. * @param material The glTF material property
  83547. * @param babylonDrawMode The draw mode for the Babylon material
  83548. * @returns The Babylon material
  83549. */
  83550. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  83551. /**
  83552. * Loads properties from a glTF material into a Babylon material.
  83553. * @param context The context when loading the asset
  83554. * @param material The glTF material property
  83555. * @param babylonMaterial The Babylon material
  83556. * @returns A promise that resolves when the load is complete
  83557. */
  83558. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  83559. /**
  83560. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  83561. * @param context The context when loading the asset
  83562. * @param material The glTF material property
  83563. * @param babylonMaterial The Babylon material
  83564. * @returns A promise that resolves when the load is complete
  83565. */
  83566. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  83567. /**
  83568. * Loads the alpha properties from a glTF material into a Babylon material.
  83569. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  83570. * @param context The context when loading the asset
  83571. * @param material The glTF material property
  83572. * @param babylonMaterial The Babylon material
  83573. */
  83574. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  83575. /**
  83576. * Loads a glTF texture info.
  83577. * @param context The context when loading the asset
  83578. * @param textureInfo The glTF texture info property
  83579. * @param assign A function called synchronously after parsing the glTF properties
  83580. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  83581. */
  83582. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  83583. /** @hidden */
  83584. _loadTextureAsync(context: string, texture: ITexture, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  83585. /** @hidden */
  83586. _createTextureAsync(context: string, sampler: ISampler, image: IImage, assign?: (babylonTexture: BaseTexture) => void, textureLoaderOptions?: any): Promise<BaseTexture>;
  83587. private _loadSampler;
  83588. /**
  83589. * Loads a glTF image.
  83590. * @param context The context when loading the asset
  83591. * @param image The glTF image property
  83592. * @returns A promise that resolves with the loaded data when the load is complete
  83593. */
  83594. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  83595. /**
  83596. * Loads a glTF uri.
  83597. * @param context The context when loading the asset
  83598. * @param property The glTF property associated with the uri
  83599. * @param uri The base64 or relative uri
  83600. * @returns A promise that resolves with the loaded data when the load is complete
  83601. */
  83602. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  83603. /**
  83604. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  83605. * @param babylonObject the Babylon object with metadata
  83606. * @param pointer the JSON pointer
  83607. */
  83608. static AddPointerMetadata(babylonObject: {
  83609. metadata: any;
  83610. }, pointer: string): void;
  83611. private static _GetTextureWrapMode;
  83612. private static _GetTextureSamplingMode;
  83613. private static _GetTypedArrayConstructor;
  83614. private static _GetTypedArray;
  83615. private static _GetNumComponents;
  83616. private static _ValidateUri;
  83617. /** @hidden */
  83618. static _GetDrawMode(context: string, mode: number | undefined): number;
  83619. private _compileMaterialsAsync;
  83620. private _compileShadowGeneratorsAsync;
  83621. private _forEachExtensions;
  83622. private _applyExtensions;
  83623. private _extensionsOnLoading;
  83624. private _extensionsOnReady;
  83625. private _extensionsLoadSceneAsync;
  83626. private _extensionsLoadNodeAsync;
  83627. private _extensionsLoadCameraAsync;
  83628. private _extensionsLoadVertexDataAsync;
  83629. private _extensionsLoadMeshPrimitiveAsync;
  83630. private _extensionsLoadMaterialAsync;
  83631. private _extensionsCreateMaterial;
  83632. private _extensionsLoadMaterialPropertiesAsync;
  83633. private _extensionsLoadTextureInfoAsync;
  83634. private _extensionsLoadTextureAsync;
  83635. private _extensionsLoadAnimationAsync;
  83636. private _extensionsLoadSkinAsync;
  83637. private _extensionsLoadUriAsync;
  83638. private _extensionsLoadBufferViewAsync;
  83639. private _extensionsLoadBufferAsync;
  83640. /**
  83641. * Helper method called by a loader extension to load an glTF extension.
  83642. * @param context The context when loading the asset
  83643. * @param property The glTF property to load the extension from
  83644. * @param extensionName The name of the extension to load
  83645. * @param actionAsync The action to run
  83646. * @returns The promise returned by actionAsync or null if the extension does not exist
  83647. */
  83648. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  83649. /**
  83650. * Helper method called by a loader extension to load a glTF extra.
  83651. * @param context The context when loading the asset
  83652. * @param property The glTF property to load the extra from
  83653. * @param extensionName The name of the extension to load
  83654. * @param actionAsync The action to run
  83655. * @returns The promise returned by actionAsync or null if the extra does not exist
  83656. */
  83657. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  83658. /**
  83659. * Checks for presence of an extension.
  83660. * @param name The name of the extension to check
  83661. * @returns A boolean indicating the presence of the given extension name in `extensionsUsed`
  83662. */
  83663. isExtensionUsed(name: string): boolean;
  83664. /**
  83665. * Increments the indentation level and logs a message.
  83666. * @param message The message to log
  83667. */
  83668. logOpen(message: string): void;
  83669. /**
  83670. * Decrements the indentation level.
  83671. */
  83672. logClose(): void;
  83673. /**
  83674. * Logs a message
  83675. * @param message The message to log
  83676. */
  83677. log(message: string): void;
  83678. /**
  83679. * Starts a performance counter.
  83680. * @param counterName The name of the performance counter
  83681. */
  83682. startPerformanceCounter(counterName: string): void;
  83683. /**
  83684. * Ends a performance counter.
  83685. * @param counterName The name of the performance counter
  83686. */
  83687. endPerformanceCounter(counterName: string): void;
  83688. }
  83689. }
  83690. declare module BABYLON.GLTF2.Loader.Extensions {
  83691. /** @hidden */
  83692. interface IEXTLightsImageBased_LightImageBased {
  83693. _babylonTexture?: BaseTexture;
  83694. _loaded?: Promise<void>;
  83695. }
  83696. /**
  83697. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_lights_image_based/README.md)
  83698. */
  83699. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  83700. /**
  83701. * The name of this extension.
  83702. */
  83703. readonly name: string;
  83704. /**
  83705. * Defines whether this extension is enabled.
  83706. */
  83707. enabled: boolean;
  83708. private _loader;
  83709. private _lights?;
  83710. /** @hidden */
  83711. constructor(loader: GLTFLoader);
  83712. /** @hidden */
  83713. dispose(): void;
  83714. /** @hidden */
  83715. onLoading(): void;
  83716. /** @hidden */
  83717. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  83718. private _loadLightAsync;
  83719. }
  83720. }
  83721. declare module BABYLON.GLTF2.Loader.Extensions {
  83722. /**
  83723. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1691)
  83724. * [Playground Sample](https://playground.babylonjs.com/#QFIGLW#9)
  83725. * !!! Experimental Extension Subject to Changes !!!
  83726. */
  83727. export class EXT_mesh_gpu_instancing implements IGLTFLoaderExtension {
  83728. /**
  83729. * The name of this extension.
  83730. */
  83731. readonly name: string;
  83732. /**
  83733. * Defines whether this extension is enabled.
  83734. */
  83735. enabled: boolean;
  83736. private _loader;
  83737. /** @hidden */
  83738. constructor(loader: GLTFLoader);
  83739. /** @hidden */
  83740. dispose(): void;
  83741. /** @hidden */
  83742. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  83743. }
  83744. }
  83745. declare module BABYLON.GLTF2.Loader.Extensions {
  83746. /**
  83747. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_texture_webp/)
  83748. */
  83749. export class EXT_texture_webp implements IGLTFLoaderExtension {
  83750. /** The name of this extension. */
  83751. readonly name: string;
  83752. /** Defines whether this extension is enabled. */
  83753. enabled: boolean;
  83754. private _loader;
  83755. /** @hidden */
  83756. constructor(loader: GLTFLoader);
  83757. /** @hidden */
  83758. dispose(): void;
  83759. /** @hidden */
  83760. _loadTextureAsync(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  83761. }
  83762. }
  83763. declare module BABYLON.GLTF2.Loader.Extensions {
  83764. /**
  83765. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  83766. */
  83767. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  83768. /**
  83769. * The name of this extension.
  83770. */
  83771. readonly name: string;
  83772. /**
  83773. * The draco compression used to decode vertex data or DracoCompression.Default if not defined
  83774. */
  83775. dracoCompression?: DracoCompression;
  83776. /**
  83777. * Defines whether this extension is enabled.
  83778. */
  83779. enabled: boolean;
  83780. private _loader;
  83781. /** @hidden */
  83782. constructor(loader: GLTFLoader);
  83783. /** @hidden */
  83784. dispose(): void;
  83785. /** @hidden */
  83786. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  83787. }
  83788. }
  83789. declare module BABYLON.GLTF2.Loader.Extensions {
  83790. /**
  83791. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual)
  83792. */
  83793. export class KHR_lights implements IGLTFLoaderExtension {
  83794. /**
  83795. * The name of this extension.
  83796. */
  83797. readonly name: string;
  83798. /**
  83799. * Defines whether this extension is enabled.
  83800. */
  83801. enabled: boolean;
  83802. private _loader;
  83803. private _lights?;
  83804. /** @hidden */
  83805. constructor(loader: GLTFLoader);
  83806. /** @hidden */
  83807. dispose(): void;
  83808. /** @hidden */
  83809. onLoading(): void;
  83810. /** @hidden */
  83811. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  83812. }
  83813. }
  83814. declare module BABYLON.GLTF2.Loader.Extensions {
  83815. /**
  83816. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  83817. */
  83818. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  83819. /**
  83820. * The name of this extension.
  83821. */
  83822. readonly name: string;
  83823. /**
  83824. * Defines whether this extension is enabled.
  83825. */
  83826. enabled: boolean;
  83827. /**
  83828. * Defines a number that determines the order the extensions are applied.
  83829. */
  83830. order: number;
  83831. private _loader;
  83832. /** @hidden */
  83833. constructor(loader: GLTFLoader);
  83834. /** @hidden */
  83835. dispose(): void;
  83836. /** @hidden */
  83837. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  83838. private _loadSpecularGlossinessPropertiesAsync;
  83839. }
  83840. }
  83841. declare module BABYLON.GLTF2.Loader.Extensions {
  83842. /**
  83843. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  83844. */
  83845. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  83846. /**
  83847. * The name of this extension.
  83848. */
  83849. readonly name: string;
  83850. /**
  83851. * Defines whether this extension is enabled.
  83852. */
  83853. enabled: boolean;
  83854. /**
  83855. * Defines a number that determines the order the extensions are applied.
  83856. */
  83857. order: number;
  83858. private _loader;
  83859. /** @hidden */
  83860. constructor(loader: GLTFLoader);
  83861. /** @hidden */
  83862. dispose(): void;
  83863. /** @hidden */
  83864. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  83865. private _loadUnlitPropertiesAsync;
  83866. }
  83867. }
  83868. declare module BABYLON.GLTF2.Loader.Extensions {
  83869. /**
  83870. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_clearcoat/README.md)
  83871. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#7F7PN6#8)
  83872. */
  83873. export class KHR_materials_clearcoat implements IGLTFLoaderExtension {
  83874. /**
  83875. * The name of this extension.
  83876. */
  83877. readonly name: string;
  83878. /**
  83879. * Defines whether this extension is enabled.
  83880. */
  83881. enabled: boolean;
  83882. /**
  83883. * Defines a number that determines the order the extensions are applied.
  83884. */
  83885. order: number;
  83886. private _loader;
  83887. /** @hidden */
  83888. constructor(loader: GLTFLoader);
  83889. /** @hidden */
  83890. dispose(): void;
  83891. /** @hidden */
  83892. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  83893. private _loadClearCoatPropertiesAsync;
  83894. }
  83895. }
  83896. declare module BABYLON.GLTF2.Loader.Extensions {
  83897. /**
  83898. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1688)
  83899. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  83900. * !!! Experimental Extension Subject to Changes !!!
  83901. */
  83902. export class KHR_materials_sheen implements IGLTFLoaderExtension {
  83903. /**
  83904. * The name of this extension.
  83905. */
  83906. readonly name: string;
  83907. /**
  83908. * Defines whether this extension is enabled.
  83909. */
  83910. enabled: boolean;
  83911. /**
  83912. * Defines a number that determines the order the extensions are applied.
  83913. */
  83914. order: number;
  83915. private _loader;
  83916. /** @hidden */
  83917. constructor(loader: GLTFLoader);
  83918. /** @hidden */
  83919. dispose(): void;
  83920. /** @hidden */
  83921. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  83922. private _loadSheenPropertiesAsync;
  83923. }
  83924. }
  83925. declare module BABYLON.GLTF2.Loader.Extensions {
  83926. /**
  83927. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1719)
  83928. * !!! Experimental Extension Subject to Changes !!!
  83929. */
  83930. export class KHR_materials_specular implements IGLTFLoaderExtension {
  83931. /**
  83932. * The name of this extension.
  83933. */
  83934. readonly name: string;
  83935. /**
  83936. * Defines whether this extension is enabled.
  83937. */
  83938. enabled: boolean;
  83939. /**
  83940. * Defines a number that determines the order the extensions are applied.
  83941. */
  83942. order: number;
  83943. private _loader;
  83944. /** @hidden */
  83945. constructor(loader: GLTFLoader);
  83946. /** @hidden */
  83947. dispose(): void;
  83948. /** @hidden */
  83949. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  83950. private _loadSpecularPropertiesAsync;
  83951. }
  83952. }
  83953. declare module BABYLON.GLTF2.Loader.Extensions {
  83954. /**
  83955. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1718)
  83956. * !!! Experimental Extension Subject to Changes !!!
  83957. */
  83958. export class KHR_materials_ior implements IGLTFLoaderExtension {
  83959. /**
  83960. * Default ior Value from the spec.
  83961. */
  83962. private static readonly _DEFAULT_IOR;
  83963. /**
  83964. * The name of this extension.
  83965. */
  83966. readonly name: string;
  83967. /**
  83968. * Defines whether this extension is enabled.
  83969. */
  83970. enabled: boolean;
  83971. /**
  83972. * Defines a number that determines the order the extensions are applied.
  83973. */
  83974. order: number;
  83975. private _loader;
  83976. /** @hidden */
  83977. constructor(loader: GLTFLoader);
  83978. /** @hidden */
  83979. dispose(): void;
  83980. /** @hidden */
  83981. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  83982. private _loadIorPropertiesAsync;
  83983. }
  83984. }
  83985. declare module BABYLON.GLTF2.Loader.Extensions {
  83986. /**
  83987. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1681)
  83988. * !!! Experimental Extension Subject to Changes !!!
  83989. */
  83990. export class KHR_materials_variants implements IGLTFLoaderExtension {
  83991. /**
  83992. * The name of this extension.
  83993. */
  83994. readonly name: string;
  83995. /**
  83996. * Defines whether this extension is enabled.
  83997. */
  83998. enabled: boolean;
  83999. private _loader;
  84000. private _variants?;
  84001. /** @hidden */
  84002. constructor(loader: GLTFLoader);
  84003. /** @hidden */
  84004. dispose(): void;
  84005. /**
  84006. * Gets the list of available variant names for this asset.
  84007. * @param rootMesh The glTF root mesh
  84008. * @returns the list of all the variant names for this model
  84009. */
  84010. static GetAvailableVariants(rootMesh: Mesh): string[];
  84011. /**
  84012. * Gets the list of available variant names for this asset.
  84013. * @param rootMesh The glTF root mesh
  84014. * @returns the list of all the variant names for this model
  84015. */
  84016. getAvailableVariants(rootMesh: Mesh): string[];
  84017. /**
  84018. * Select a variant given a variant name or a list of variant names.
  84019. * @param rootMesh The glTF root mesh
  84020. * @param variantName The variant name(s) to select.
  84021. */
  84022. static SelectVariant(rootMesh: Mesh, variantName: string | string[]): void;
  84023. /**
  84024. * Select a variant given a variant name or a list of variant names.
  84025. * @param rootMesh The glTF root mesh
  84026. * @param variantName The variant name(s) to select.
  84027. */
  84028. selectVariant(rootMesh: Mesh, variantName: string | string[]): void;
  84029. /**
  84030. * Reset back to the original before selecting a variant.
  84031. * @param rootMesh The glTF root mesh
  84032. */
  84033. static Reset(rootMesh: Mesh): void;
  84034. /**
  84035. * Reset back to the original before selecting a variant.
  84036. * @param rootMesh The glTF root mesh
  84037. */
  84038. reset(rootMesh: Mesh): void;
  84039. /**
  84040. * Gets the last selected variant name(s) or null if original.
  84041. * @param rootMesh The glTF root mesh
  84042. * @returns The selected variant name(s).
  84043. */
  84044. static GetLastSelectedVariant(rootMesh: Mesh): Nullable<string | string[]>;
  84045. /**
  84046. * Gets the last selected variant name(s) or null if original.
  84047. * @param rootMesh The glTF root mesh
  84048. * @returns The selected variant name(s).
  84049. */
  84050. getLastSelectedVariant(rootMesh: Mesh): Nullable<string | string[]>;
  84051. private static _GetExtensionMetadata;
  84052. /** @hidden */
  84053. onLoading(): void;
  84054. /** @hidden */
  84055. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Nullable<Promise<AbstractMesh>>;
  84056. }
  84057. }
  84058. declare module BABYLON.GLTF2.Loader.Extensions {
  84059. /**
  84060. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1698)
  84061. * !!! Experimental Extension Subject to Changes !!!
  84062. */
  84063. export class KHR_materials_transmission implements IGLTFLoaderExtension {
  84064. /**
  84065. * The name of this extension.
  84066. */
  84067. readonly name: string;
  84068. /**
  84069. * Defines whether this extension is enabled.
  84070. */
  84071. enabled: boolean;
  84072. /**
  84073. * Defines a number that determines the order the extensions are applied.
  84074. */
  84075. order: number;
  84076. private _loader;
  84077. /** @hidden */
  84078. constructor(loader: GLTFLoader);
  84079. /** @hidden */
  84080. dispose(): void;
  84081. /** @hidden */
  84082. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  84083. private _loadTransparentPropertiesAsync;
  84084. }
  84085. }
  84086. declare module BABYLON.GLTF2.Loader.Extensions {
  84087. /**
  84088. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1825)
  84089. * !!! Experimental Extension Subject to Changes !!!
  84090. */
  84091. export class KHR_materials_translucency implements IGLTFLoaderExtension {
  84092. /**
  84093. * The name of this extension.
  84094. */
  84095. readonly name: string;
  84096. /**
  84097. * Defines whether this extension is enabled.
  84098. */
  84099. enabled: boolean;
  84100. /**
  84101. * Defines a number that determines the order the extensions are applied.
  84102. */
  84103. order: number;
  84104. private _loader;
  84105. /** @hidden */
  84106. constructor(loader: GLTFLoader);
  84107. /** @hidden */
  84108. dispose(): void;
  84109. /** @hidden */
  84110. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  84111. private _loadTranslucentPropertiesAsync;
  84112. }
  84113. }
  84114. declare module BABYLON.GLTF2.Loader.Extensions {
  84115. /**
  84116. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_mesh_quantization)
  84117. */
  84118. export class KHR_mesh_quantization implements IGLTFLoaderExtension {
  84119. /**
  84120. * The name of this extension.
  84121. */
  84122. readonly name: string;
  84123. /**
  84124. * Defines whether this extension is enabled.
  84125. */
  84126. enabled: boolean;
  84127. /** @hidden */
  84128. constructor(loader: GLTFLoader);
  84129. /** @hidden */
  84130. dispose(): void;
  84131. }
  84132. }
  84133. declare module BABYLON.GLTF2.Loader.Extensions {
  84134. /**
  84135. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1751)
  84136. * !!! Experimental Extension Subject to Changes !!!
  84137. */
  84138. export class KHR_texture_basisu implements IGLTFLoaderExtension {
  84139. /** The name of this extension. */
  84140. readonly name: string;
  84141. /** Defines whether this extension is enabled. */
  84142. enabled: boolean;
  84143. private _loader;
  84144. /** @hidden */
  84145. constructor(loader: GLTFLoader);
  84146. /** @hidden */
  84147. dispose(): void;
  84148. /** @hidden */
  84149. _loadTextureAsync(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  84150. }
  84151. }
  84152. declare module BABYLON.GLTF2.Loader.Extensions {
  84153. /**
  84154. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform)
  84155. */
  84156. export class KHR_texture_transform implements IGLTFLoaderExtension {
  84157. /**
  84158. * The name of this extension.
  84159. */
  84160. readonly name: string;
  84161. /**
  84162. * Defines whether this extension is enabled.
  84163. */
  84164. enabled: boolean;
  84165. private _loader;
  84166. /** @hidden */
  84167. constructor(loader: GLTFLoader);
  84168. /** @hidden */
  84169. dispose(): void;
  84170. /** @hidden */
  84171. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  84172. }
  84173. }
  84174. declare module BABYLON.GLTF2.Loader.Extensions {
  84175. /**
  84176. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  84177. */
  84178. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  84179. /**
  84180. * The name of this extension.
  84181. */
  84182. readonly name: string;
  84183. /**
  84184. * Defines whether this extension is enabled.
  84185. */
  84186. enabled: boolean;
  84187. private _loader;
  84188. private _clips;
  84189. private _emitters;
  84190. /** @hidden */
  84191. constructor(loader: GLTFLoader);
  84192. /** @hidden */
  84193. dispose(): void;
  84194. /** @hidden */
  84195. onLoading(): void;
  84196. /** @hidden */
  84197. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  84198. /** @hidden */
  84199. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  84200. /** @hidden */
  84201. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  84202. private _loadClipAsync;
  84203. private _loadEmitterAsync;
  84204. private _getEventAction;
  84205. private _loadAnimationEventAsync;
  84206. }
  84207. }
  84208. declare module BABYLON.GLTF2.Loader.Extensions {
  84209. /**
  84210. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  84211. */
  84212. export class MSFT_lod implements IGLTFLoaderExtension {
  84213. /**
  84214. * The name of this extension.
  84215. */
  84216. readonly name: string;
  84217. /**
  84218. * Defines whether this extension is enabled.
  84219. */
  84220. enabled: boolean;
  84221. /**
  84222. * Defines a number that determines the order the extensions are applied.
  84223. */
  84224. order: number;
  84225. /**
  84226. * Maximum number of LODs to load, starting from the lowest LOD.
  84227. */
  84228. maxLODsToLoad: number;
  84229. /**
  84230. * Observable raised when all node LODs of one level are loaded.
  84231. * The event data is the index of the loaded LOD starting from zero.
  84232. * Dispose the loader to cancel the loading of the next level of LODs.
  84233. */
  84234. onNodeLODsLoadedObservable: Observable<number>;
  84235. /**
  84236. * Observable raised when all material LODs of one level are loaded.
  84237. * The event data is the index of the loaded LOD starting from zero.
  84238. * Dispose the loader to cancel the loading of the next level of LODs.
  84239. */
  84240. onMaterialLODsLoadedObservable: Observable<number>;
  84241. private _loader;
  84242. private _bufferLODs;
  84243. private _nodeIndexLOD;
  84244. private _nodeSignalLODs;
  84245. private _nodePromiseLODs;
  84246. private _nodeBufferLODs;
  84247. private _materialIndexLOD;
  84248. private _materialSignalLODs;
  84249. private _materialPromiseLODs;
  84250. private _materialBufferLODs;
  84251. /** @hidden */
  84252. constructor(loader: GLTFLoader);
  84253. /** @hidden */
  84254. dispose(): void;
  84255. /** @hidden */
  84256. onReady(): void;
  84257. /** @hidden */
  84258. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  84259. /** @hidden */
  84260. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  84261. /** @hidden */
  84262. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Nullable<Mesh>, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  84263. /** @hidden */
  84264. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  84265. /** @hidden */
  84266. loadBufferAsync(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  84267. private _loadBufferLOD;
  84268. /**
  84269. * Gets an array of LOD properties from lowest to highest.
  84270. */
  84271. private _getLODs;
  84272. private _disposeTransformNode;
  84273. private _disposeMaterials;
  84274. }
  84275. }
  84276. declare module BABYLON.GLTF2.Loader.Extensions {
  84277. /** @hidden */
  84278. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  84279. readonly name: string;
  84280. enabled: boolean;
  84281. private _loader;
  84282. constructor(loader: GLTFLoader);
  84283. dispose(): void;
  84284. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  84285. }
  84286. }
  84287. declare module BABYLON.GLTF2.Loader.Extensions {
  84288. /** @hidden */
  84289. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  84290. readonly name: string;
  84291. enabled: boolean;
  84292. private _loader;
  84293. constructor(loader: GLTFLoader);
  84294. dispose(): void;
  84295. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  84296. }
  84297. }
  84298. declare module BABYLON.GLTF2.Loader.Extensions {
  84299. /**
  84300. * Store glTF extras (if present) in BJS objects' metadata
  84301. */
  84302. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  84303. /**
  84304. * The name of this extension.
  84305. */
  84306. readonly name: string;
  84307. /**
  84308. * Defines whether this extension is enabled.
  84309. */
  84310. enabled: boolean;
  84311. private _loader;
  84312. private _assignExtras;
  84313. /** @hidden */
  84314. constructor(loader: GLTFLoader);
  84315. /** @hidden */
  84316. dispose(): void;
  84317. /** @hidden */
  84318. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  84319. /** @hidden */
  84320. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  84321. /** @hidden */
  84322. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  84323. }
  84324. }
  84325. declare module BABYLON {
  84326. /**
  84327. * Class reading and parsing the MTL file bundled with the obj file.
  84328. */
  84329. export class MTLFileLoader {
  84330. /**
  84331. * Invert Y-Axis of referenced textures on load
  84332. */
  84333. static INVERT_TEXTURE_Y: boolean;
  84334. /**
  84335. * All material loaded from the mtl will be set here
  84336. */
  84337. materials: StandardMaterial[];
  84338. /**
  84339. * This function will read the mtl file and create each material described inside
  84340. * This function could be improve by adding :
  84341. * -some component missing (Ni, Tf...)
  84342. * -including the specific options available
  84343. *
  84344. * @param scene defines the scene the material will be created in
  84345. * @param data defines the mtl data to parse
  84346. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  84347. * @param forAssetContainer defines if the material should be registered in the scene
  84348. */
  84349. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string, forAssetContainer: boolean): void;
  84350. /**
  84351. * Gets the texture for the material.
  84352. *
  84353. * If the material is imported from input file,
  84354. * We sanitize the url to ensure it takes the textre from aside the material.
  84355. *
  84356. * @param rootUrl The root url to load from
  84357. * @param value The value stored in the mtl
  84358. * @return The Texture
  84359. */
  84360. private static _getTexture;
  84361. }
  84362. }
  84363. declare module BABYLON {
  84364. /**
  84365. * Options for loading OBJ/MTL files
  84366. */
  84367. type MeshLoadOptions = {
  84368. /**
  84369. * Defines if UVs are optimized by default during load.
  84370. */
  84371. OptimizeWithUV: boolean;
  84372. /**
  84373. * Defines custom scaling of UV coordinates of loaded meshes.
  84374. */
  84375. UVScaling: Vector2;
  84376. /**
  84377. * Invert model on y-axis (does a model scaling inversion)
  84378. */
  84379. InvertY: boolean;
  84380. /**
  84381. * Invert Y-Axis of referenced textures on load
  84382. */
  84383. InvertTextureY: boolean;
  84384. /**
  84385. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  84386. */
  84387. ImportVertexColors: boolean;
  84388. /**
  84389. * Compute the normals for the model, even if normals are present in the file.
  84390. */
  84391. ComputeNormals: boolean;
  84392. /**
  84393. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  84394. */
  84395. SkipMaterials: boolean;
  84396. /**
  84397. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  84398. */
  84399. MaterialLoadingFailsSilently: boolean;
  84400. };
  84401. /**
  84402. * OBJ file type loader.
  84403. * This is a babylon scene loader plugin.
  84404. */
  84405. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  84406. /**
  84407. * Defines if UVs are optimized by default during load.
  84408. */
  84409. static OPTIMIZE_WITH_UV: boolean;
  84410. /**
  84411. * Invert model on y-axis (does a model scaling inversion)
  84412. */
  84413. static INVERT_Y: boolean;
  84414. /**
  84415. * Invert Y-Axis of referenced textures on load
  84416. */
  84417. static get INVERT_TEXTURE_Y(): boolean;
  84418. static set INVERT_TEXTURE_Y(value: boolean);
  84419. /**
  84420. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  84421. */
  84422. static IMPORT_VERTEX_COLORS: boolean;
  84423. /**
  84424. * Compute the normals for the model, even if normals are present in the file.
  84425. */
  84426. static COMPUTE_NORMALS: boolean;
  84427. /**
  84428. * Defines custom scaling of UV coordinates of loaded meshes.
  84429. */
  84430. static UV_SCALING: Vector2;
  84431. /**
  84432. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  84433. */
  84434. static SKIP_MATERIALS: boolean;
  84435. /**
  84436. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  84437. *
  84438. * Defaults to true for backwards compatibility.
  84439. */
  84440. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  84441. /**
  84442. * Defines the name of the plugin.
  84443. */
  84444. name: string;
  84445. /**
  84446. * Defines the extension the plugin is able to load.
  84447. */
  84448. extensions: string;
  84449. /** @hidden */
  84450. obj: RegExp;
  84451. /** @hidden */
  84452. group: RegExp;
  84453. /** @hidden */
  84454. mtllib: RegExp;
  84455. /** @hidden */
  84456. usemtl: RegExp;
  84457. /** @hidden */
  84458. smooth: RegExp;
  84459. /** @hidden */
  84460. vertexPattern: RegExp;
  84461. /** @hidden */
  84462. normalPattern: RegExp;
  84463. /** @hidden */
  84464. uvPattern: RegExp;
  84465. /** @hidden */
  84466. facePattern1: RegExp;
  84467. /** @hidden */
  84468. facePattern2: RegExp;
  84469. /** @hidden */
  84470. facePattern3: RegExp;
  84471. /** @hidden */
  84472. facePattern4: RegExp;
  84473. /** @hidden */
  84474. facePattern5: RegExp;
  84475. private _forAssetContainer;
  84476. private _meshLoadOptions;
  84477. /**
  84478. * Creates loader for .OBJ files
  84479. *
  84480. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  84481. */
  84482. constructor(meshLoadOptions?: MeshLoadOptions);
  84483. private static get currentMeshLoadOptions();
  84484. /**
  84485. * Calls synchronously the MTL file attached to this obj.
  84486. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  84487. * Without this function materials are not displayed in the first frame (but displayed after).
  84488. * In consequence it is impossible to get material information in your HTML file
  84489. *
  84490. * @param url The URL of the MTL file
  84491. * @param rootUrl
  84492. * @param onSuccess Callback function to be called when the MTL file is loaded
  84493. * @private
  84494. */
  84495. private _loadMTL;
  84496. /**
  84497. * Instantiates a OBJ file loader plugin.
  84498. * @returns the created plugin
  84499. */
  84500. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  84501. /**
  84502. * If the data string can be loaded directly.
  84503. *
  84504. * @param data string containing the file data
  84505. * @returns if the data can be loaded directly
  84506. */
  84507. canDirectLoad(data: string): boolean;
  84508. /**
  84509. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  84510. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  84511. * @param scene the scene the meshes should be added to
  84512. * @param data the OBJ data to load
  84513. * @param rootUrl root url to load from
  84514. * @param onProgress event that fires when loading progress has occured
  84515. * @param fileName Defines the name of the file to load
  84516. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  84517. */
  84518. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<ISceneLoaderAsyncResult>;
  84519. /**
  84520. * Imports all objects from the loaded OBJ data and adds them to the scene
  84521. * @param scene the scene the objects should be added to
  84522. * @param data the OBJ data to load
  84523. * @param rootUrl root url to load from
  84524. * @param onProgress event that fires when loading progress has occured
  84525. * @param fileName Defines the name of the file to load
  84526. * @returns a promise which completes when objects have been loaded to the scene
  84527. */
  84528. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  84529. /**
  84530. * Load into an asset container.
  84531. * @param scene The scene to load into
  84532. * @param data The data to import
  84533. * @param rootUrl The root url for scene and resources
  84534. * @param onProgress The callback when the load progresses
  84535. * @param fileName Defines the name of the file to load
  84536. * @returns The loaded asset container
  84537. */
  84538. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  84539. /**
  84540. * Read the OBJ file and create an Array of meshes.
  84541. * Each mesh contains all information given by the OBJ and the MTL file.
  84542. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  84543. *
  84544. * @param meshesNames
  84545. * @param scene Scene The scene where are displayed the data
  84546. * @param data String The content of the obj file
  84547. * @param rootUrl String The path to the folder
  84548. * @returns Array<AbstractMesh>
  84549. * @private
  84550. */
  84551. private _parseSolid;
  84552. }
  84553. }
  84554. declare module BABYLON {
  84555. /**
  84556. * STL file type loader.
  84557. * This is a babylon scene loader plugin.
  84558. */
  84559. export class STLFileLoader implements ISceneLoaderPlugin {
  84560. /** @hidden */
  84561. solidPattern: RegExp;
  84562. /** @hidden */
  84563. facetsPattern: RegExp;
  84564. /** @hidden */
  84565. normalPattern: RegExp;
  84566. /** @hidden */
  84567. vertexPattern: RegExp;
  84568. /**
  84569. * Defines the name of the plugin.
  84570. */
  84571. name: string;
  84572. /**
  84573. * Defines the extensions the stl loader is able to load.
  84574. * force data to come in as an ArrayBuffer
  84575. * we'll convert to string if it looks like it's an ASCII .stl
  84576. */
  84577. extensions: ISceneLoaderPluginExtensions;
  84578. /**
  84579. * Import meshes into a scene.
  84580. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  84581. * @param scene The scene to import into
  84582. * @param data The data to import
  84583. * @param rootUrl The root url for scene and resources
  84584. * @param meshes The meshes array to import into
  84585. * @param particleSystems The particle systems array to import into
  84586. * @param skeletons The skeletons array to import into
  84587. * @param onError The callback when import fails
  84588. * @returns True if successful or false otherwise
  84589. */
  84590. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  84591. /**
  84592. * Load into a scene.
  84593. * @param scene The scene to load into
  84594. * @param data The data to import
  84595. * @param rootUrl The root url for scene and resources
  84596. * @param onError The callback when import fails
  84597. * @returns true if successful or false otherwise
  84598. */
  84599. load(scene: Scene, data: any, rootUrl: string): boolean;
  84600. /**
  84601. * Load into an asset container.
  84602. * @param scene The scene to load into
  84603. * @param data The data to import
  84604. * @param rootUrl The root url for scene and resources
  84605. * @param onError The callback when import fails
  84606. * @returns The loaded asset container
  84607. */
  84608. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  84609. private _isBinary;
  84610. private _parseBinary;
  84611. private _parseASCII;
  84612. }
  84613. }
  84614. declare module BABYLON {
  84615. /**
  84616. * Class for generating OBJ data from a Babylon scene.
  84617. */
  84618. export class OBJExport {
  84619. /**
  84620. * Exports the geometry of a Mesh array in .OBJ file format (text)
  84621. * @param mesh defines the list of meshes to serialize
  84622. * @param materials defines if materials should be exported
  84623. * @param matlibname defines the name of the associated mtl file
  84624. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  84625. * @returns the OBJ content
  84626. */
  84627. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  84628. /**
  84629. * Exports the material(s) of a mesh in .MTL file format (text)
  84630. * @param mesh defines the mesh to extract the material from
  84631. * @returns the mtl content
  84632. */
  84633. static MTL(mesh: Mesh): string;
  84634. }
  84635. }
  84636. declare module BABYLON {
  84637. /** @hidden */
  84638. export var __IGLTFExporterExtension: number;
  84639. /**
  84640. * Interface for extending the exporter
  84641. * @hidden
  84642. */
  84643. export interface IGLTFExporterExtension {
  84644. /**
  84645. * The name of this extension
  84646. */
  84647. readonly name: string;
  84648. /**
  84649. * Defines whether this extension is enabled
  84650. */
  84651. enabled: boolean;
  84652. /**
  84653. * Defines whether this extension is required
  84654. */
  84655. required: boolean;
  84656. }
  84657. }
  84658. declare module BABYLON.GLTF2.Exporter {
  84659. /** @hidden */
  84660. export var __IGLTFExporterExtensionV2: number;
  84661. /**
  84662. * Interface for a glTF exporter extension
  84663. * @hidden
  84664. */
  84665. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  84666. /**
  84667. * Define this method to modify the default behavior before exporting a texture
  84668. * @param context The context when loading the asset
  84669. * @param babylonTexture The Babylon.js texture
  84670. * @param mimeType The mime-type of the generated image
  84671. * @returns A promise that resolves with the exported texture
  84672. */
  84673. preExportTextureAsync?(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Texture>;
  84674. /**
  84675. * Define this method to get notified when a texture info is created
  84676. * @param context The context when loading the asset
  84677. * @param textureInfo The glTF texture info
  84678. * @param babylonTexture The Babylon.js texture
  84679. */
  84680. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  84681. /**
  84682. * Define this method to modify the default behavior when exporting texture info
  84683. * @param context The context when loading the asset
  84684. * @param meshPrimitive glTF mesh primitive
  84685. * @param babylonSubMesh Babylon submesh
  84686. * @param binaryWriter glTF serializer binary writer instance
  84687. * @returns nullable IMeshPrimitive promise
  84688. */
  84689. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: Nullable<IMeshPrimitive>, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<IMeshPrimitive>;
  84690. /**
  84691. * Define this method to modify the default behavior when exporting a node
  84692. * @param context The context when exporting the node
  84693. * @param node glTF node
  84694. * @param babylonNode BabylonJS node
  84695. * @returns nullable INode promise
  84696. */
  84697. postExportNodeAsync?(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  84698. [key: number]: number;
  84699. }): Promise<Nullable<INode>>;
  84700. /**
  84701. * Define this method to modify the default behavior when exporting a material
  84702. * @param material glTF material
  84703. * @param babylonMaterial BabylonJS material
  84704. * @returns nullable IMaterial promise
  84705. */
  84706. postExportMaterialAsync?(context: string, node: Nullable<IMaterial>, babylonMaterial: Material): Promise<IMaterial>;
  84707. /**
  84708. * Define this method to return additional textures to export from a material
  84709. * @param material glTF material
  84710. * @param babylonMaterial BabylonJS material
  84711. * @returns List of textures
  84712. */
  84713. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  84714. /** Gets a boolean indicating that this extension was used */
  84715. wasUsed: boolean;
  84716. /** Gets a boolean indicating that this extension is required for the file to work */
  84717. required: boolean;
  84718. /**
  84719. * Called after the exporter state changes to EXPORTING
  84720. */
  84721. onExporting?(): void;
  84722. }
  84723. }
  84724. declare module BABYLON.GLTF2.Exporter {
  84725. /**
  84726. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  84727. * @hidden
  84728. */
  84729. export class _GLTFMaterialExporter {
  84730. /**
  84731. * Represents the dielectric specular values for R, G and B
  84732. */
  84733. private static readonly _DielectricSpecular;
  84734. /**
  84735. * Allows the maximum specular power to be defined for material calculations
  84736. */
  84737. private static readonly _MaxSpecularPower;
  84738. /**
  84739. * Mapping to store textures
  84740. */
  84741. private _textureMap;
  84742. /**
  84743. * Numeric tolerance value
  84744. */
  84745. private static readonly _Epsilon;
  84746. /**
  84747. * Reference to the glTF Exporter
  84748. */
  84749. private _exporter;
  84750. constructor(exporter: _Exporter);
  84751. /**
  84752. * Specifies if two colors are approximately equal in value
  84753. * @param color1 first color to compare to
  84754. * @param color2 second color to compare to
  84755. * @param epsilon threshold value
  84756. */
  84757. private static FuzzyEquals;
  84758. /**
  84759. * Gets the materials from a Babylon scene and converts them to glTF materials
  84760. * @param scene babylonjs scene
  84761. * @param mimeType texture mime type
  84762. * @param images array of images
  84763. * @param textures array of textures
  84764. * @param materials array of materials
  84765. * @param imageData mapping of texture names to base64 textures
  84766. * @param hasTextureCoords specifies if texture coordinates are present on the material
  84767. */
  84768. _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  84769. /**
  84770. * Makes a copy of the glTF material without the texture parameters
  84771. * @param originalMaterial original glTF material
  84772. * @returns glTF material without texture parameters
  84773. */
  84774. _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  84775. /**
  84776. * Specifies if the material has any texture parameters present
  84777. * @param material glTF Material
  84778. * @returns boolean specifying if texture parameters are present
  84779. */
  84780. _hasTexturesPresent(material: IMaterial): boolean;
  84781. /**
  84782. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  84783. * @param babylonStandardMaterial
  84784. * @returns glTF Metallic Roughness Material representation
  84785. */
  84786. _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  84787. /**
  84788. * Computes the metallic factor
  84789. * @param diffuse diffused value
  84790. * @param specular specular value
  84791. * @param oneMinusSpecularStrength one minus the specular strength
  84792. * @returns metallic value
  84793. */
  84794. static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  84795. /**
  84796. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  84797. * @param glTFMaterial glTF material
  84798. * @param babylonMaterial Babylon material
  84799. */
  84800. private static _SetAlphaMode;
  84801. /**
  84802. * Converts a Babylon Standard Material to a glTF Material
  84803. * @param babylonStandardMaterial BJS Standard Material
  84804. * @param mimeType mime type to use for the textures
  84805. * @param images array of glTF image interfaces
  84806. * @param textures array of glTF texture interfaces
  84807. * @param materials array of glTF material interfaces
  84808. * @param imageData map of image file name to data
  84809. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  84810. */
  84811. _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  84812. private _finishMaterial;
  84813. /**
  84814. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  84815. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  84816. * @param mimeType mime type to use for the textures
  84817. * @param images array of glTF image interfaces
  84818. * @param textures array of glTF texture interfaces
  84819. * @param materials array of glTF material interfaces
  84820. * @param imageData map of image file name to data
  84821. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  84822. */
  84823. _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  84824. /**
  84825. * Converts an image typed array buffer to a base64 image
  84826. * @param buffer typed array buffer
  84827. * @param width width of the image
  84828. * @param height height of the image
  84829. * @param mimeType mimetype of the image
  84830. * @returns base64 image string
  84831. */
  84832. private _createBase64FromCanvasAsync;
  84833. /**
  84834. * Generates a white texture based on the specified width and height
  84835. * @param width width of the texture in pixels
  84836. * @param height height of the texture in pixels
  84837. * @param scene babylonjs scene
  84838. * @returns white texture
  84839. */
  84840. private _createWhiteTexture;
  84841. /**
  84842. * 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
  84843. * @param texture1 first texture to resize
  84844. * @param texture2 second texture to resize
  84845. * @param scene babylonjs scene
  84846. * @returns resized textures or null
  84847. */
  84848. private _resizeTexturesToSameDimensions;
  84849. /**
  84850. * Converts an array of pixels to a Float32Array
  84851. * Throws an error if the pixel format is not supported
  84852. * @param pixels - array buffer containing pixel values
  84853. * @returns Float32 of pixels
  84854. */
  84855. private _convertPixelArrayToFloat32;
  84856. /**
  84857. * Convert Specular Glossiness Textures to Metallic Roughness
  84858. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  84859. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  84860. * @param diffuseTexture texture used to store diffuse information
  84861. * @param specularGlossinessTexture texture used to store specular and glossiness information
  84862. * @param factors specular glossiness material factors
  84863. * @param mimeType the mime type to use for the texture
  84864. * @returns pbr metallic roughness interface or null
  84865. */
  84866. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  84867. /**
  84868. * Converts specular glossiness material properties to metallic roughness
  84869. * @param specularGlossiness interface with specular glossiness material properties
  84870. * @returns interface with metallic roughness material properties
  84871. */
  84872. private _convertSpecularGlossinessToMetallicRoughness;
  84873. /**
  84874. * Calculates the surface reflectance, independent of lighting conditions
  84875. * @param color Color source to calculate brightness from
  84876. * @returns number representing the perceived brightness, or zero if color is undefined
  84877. */
  84878. private _getPerceivedBrightness;
  84879. /**
  84880. * Returns the maximum color component value
  84881. * @param color
  84882. * @returns maximum color component value, or zero if color is null or undefined
  84883. */
  84884. private _getMaxComponent;
  84885. /**
  84886. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  84887. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  84888. * @param mimeType mime type to use for the textures
  84889. * @param images array of glTF image interfaces
  84890. * @param textures array of glTF texture interfaces
  84891. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  84892. * @param imageData map of image file name to data
  84893. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  84894. * @returns glTF PBR Metallic Roughness factors
  84895. */
  84896. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  84897. private _getGLTFTextureSampler;
  84898. private _getGLTFTextureWrapMode;
  84899. private _getGLTFTextureWrapModesSampler;
  84900. /**
  84901. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  84902. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  84903. * @param mimeType mime type to use for the textures
  84904. * @param images array of glTF image interfaces
  84905. * @param textures array of glTF texture interfaces
  84906. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  84907. * @param imageData map of image file name to data
  84908. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  84909. * @returns glTF PBR Metallic Roughness factors
  84910. */
  84911. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  84912. /**
  84913. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  84914. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  84915. * @param mimeType mime type to use for the textures
  84916. * @param images array of glTF image interfaces
  84917. * @param textures array of glTF texture interfaces
  84918. * @param materials array of glTF material interfaces
  84919. * @param imageData map of image file name to data
  84920. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  84921. */
  84922. _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  84923. private setMetallicRoughnessPbrMaterial;
  84924. private getPixelsFromTexture;
  84925. /**
  84926. * Extracts a texture from a Babylon texture into file data and glTF data
  84927. * @param babylonTexture Babylon texture to extract
  84928. * @param mimeType Mime Type of the babylonTexture
  84929. * @return glTF texture info, or null if the texture format is not supported
  84930. */
  84931. _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  84932. _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  84933. /**
  84934. * Builds a texture from base64 string
  84935. * @param base64Texture base64 texture string
  84936. * @param baseTextureName Name to use for the texture
  84937. * @param mimeType image mime type for the texture
  84938. * @param images array of images
  84939. * @param textures array of textures
  84940. * @param imageData map of image data
  84941. * @returns glTF texture info, or null if the texture format is not supported
  84942. */
  84943. private _getTextureInfoFromBase64;
  84944. }
  84945. }
  84946. declare module BABYLON {
  84947. /**
  84948. * Class for holding and downloading glTF file data
  84949. */
  84950. export class GLTFData {
  84951. /**
  84952. * Object which contains the file name as the key and its data as the value
  84953. */
  84954. glTFFiles: {
  84955. [fileName: string]: string | Blob;
  84956. };
  84957. /**
  84958. * Initializes the glTF file object
  84959. */
  84960. constructor();
  84961. /**
  84962. * Downloads the glTF data as files based on their names and data
  84963. */
  84964. downloadFiles(): void;
  84965. }
  84966. }
  84967. declare module BABYLON {
  84968. /**
  84969. * Holds a collection of exporter options and parameters
  84970. */
  84971. export interface IExportOptions {
  84972. /**
  84973. * Function which indicates whether a babylon node should be exported or not
  84974. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  84975. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  84976. */
  84977. shouldExportNode?(node: Node): boolean;
  84978. /**
  84979. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  84980. * @param metadata source metadata to read from
  84981. * @returns the data to store to glTF node extras
  84982. */
  84983. metadataSelector?(metadata: any): any;
  84984. /**
  84985. * The sample rate to bake animation curves
  84986. */
  84987. animationSampleRate?: number;
  84988. /**
  84989. * Begin serialization without waiting for the scene to be ready
  84990. */
  84991. exportWithoutWaitingForScene?: boolean;
  84992. /**
  84993. * Indicates if coordinate system swapping root nodes should be included in export
  84994. */
  84995. includeCoordinateSystemConversionNodes?: boolean;
  84996. }
  84997. /**
  84998. * Class for generating glTF data from a Babylon scene.
  84999. */
  85000. export class GLTF2Export {
  85001. /**
  85002. * Exports the geometry of the scene to .gltf file format asynchronously
  85003. * @param scene Babylon scene with scene hierarchy information
  85004. * @param filePrefix File prefix to use when generating the glTF file
  85005. * @param options Exporter options
  85006. * @returns Returns an object with a .gltf file and associates texture names
  85007. * as keys and their data and paths as values
  85008. */
  85009. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  85010. private static _PreExportAsync;
  85011. private static _PostExportAsync;
  85012. /**
  85013. * Exports the geometry of the scene to .glb file format asychronously
  85014. * @param scene Babylon scene with scene hierarchy information
  85015. * @param filePrefix File prefix to use when generating glb file
  85016. * @param options Exporter options
  85017. * @returns Returns an object with a .glb filename as key and data as value
  85018. */
  85019. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  85020. }
  85021. }
  85022. declare module BABYLON.GLTF2.Exporter {
  85023. /**
  85024. * @hidden
  85025. */
  85026. export class _GLTFUtilities {
  85027. /**
  85028. * Creates a buffer view based on the supplied arguments
  85029. * @param bufferIndex index value of the specified buffer
  85030. * @param byteOffset byte offset value
  85031. * @param byteLength byte length of the bufferView
  85032. * @param byteStride byte distance between conequential elements
  85033. * @param name name of the buffer view
  85034. * @returns bufferView for glTF
  85035. */
  85036. static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  85037. /**
  85038. * Creates an accessor based on the supplied arguments
  85039. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  85040. * @param name The name of the accessor
  85041. * @param type The type of the accessor
  85042. * @param componentType The datatype of components in the attribute
  85043. * @param count The number of attributes referenced by this accessor
  85044. * @param byteOffset The offset relative to the start of the bufferView in bytes
  85045. * @param min Minimum value of each component in this attribute
  85046. * @param max Maximum value of each component in this attribute
  85047. * @returns accessor for glTF
  85048. */
  85049. static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  85050. /**
  85051. * Calculates the minimum and maximum values of an array of position floats
  85052. * @param positions Positions array of a mesh
  85053. * @param vertexStart Starting vertex offset to calculate min and max values
  85054. * @param vertexCount Number of vertices to check for min and max values
  85055. * @returns min number array and max number array
  85056. */
  85057. static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  85058. min: number[];
  85059. max: number[];
  85060. };
  85061. /**
  85062. * Converts a new right-handed Vector3
  85063. * @param vector vector3 array
  85064. * @returns right-handed Vector3
  85065. */
  85066. static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  85067. /**
  85068. * Converts a Vector3 to right-handed
  85069. * @param vector Vector3 to convert to right-handed
  85070. */
  85071. static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  85072. /**
  85073. * Converts a three element number array to right-handed
  85074. * @param vector number array to convert to right-handed
  85075. */
  85076. static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  85077. /**
  85078. * Converts a new right-handed Vector3
  85079. * @param vector vector3 array
  85080. * @returns right-handed Vector3
  85081. */
  85082. static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  85083. /**
  85084. * Converts a Vector3 to right-handed
  85085. * @param vector Vector3 to convert to right-handed
  85086. */
  85087. static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  85088. /**
  85089. * Converts a three element number array to right-handed
  85090. * @param vector number array to convert to right-handed
  85091. */
  85092. static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  85093. /**
  85094. * Converts a Vector4 to right-handed
  85095. * @param vector Vector4 to convert to right-handed
  85096. */
  85097. static _GetRightHandedVector4FromRef(vector: Vector4): void;
  85098. /**
  85099. * Converts a Vector4 to right-handed
  85100. * @param vector Vector4 to convert to right-handed
  85101. */
  85102. static _GetRightHandedArray4FromRef(vector: number[]): void;
  85103. /**
  85104. * Converts a Quaternion to right-handed
  85105. * @param quaternion Source quaternion to convert to right-handed
  85106. */
  85107. static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  85108. /**
  85109. * Converts a Quaternion to right-handed
  85110. * @param quaternion Source quaternion to convert to right-handed
  85111. */
  85112. static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  85113. static _NormalizeTangentFromRef(tangent: Vector4): void;
  85114. static _GetRightHandedMatrixFromRef(matrix: Matrix): void;
  85115. static _GetDataAccessorElementCount(accessorType: AccessorType): 1 | 3 | 2 | 4 | 9 | 16;
  85116. }
  85117. }
  85118. declare module BABYLON.GLTF2.Exporter {
  85119. /**
  85120. * Converts Babylon Scene into glTF 2.0.
  85121. * @hidden
  85122. */
  85123. export class _Exporter {
  85124. /**
  85125. * Stores the glTF to export
  85126. */
  85127. _glTF: IGLTF;
  85128. /**
  85129. * Stores all generated buffer views, which represents views into the main glTF buffer data
  85130. */
  85131. _bufferViews: IBufferView[];
  85132. /**
  85133. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  85134. */
  85135. _accessors: IAccessor[];
  85136. /**
  85137. * Stores all the generated nodes, which contains transform and/or mesh information per node
  85138. */
  85139. _nodes: INode[];
  85140. /**
  85141. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  85142. */
  85143. private _scenes;
  85144. /**
  85145. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  85146. */
  85147. private _meshes;
  85148. /**
  85149. * Stores all the generated material information, which represents the appearance of each primitive
  85150. */
  85151. _materials: IMaterial[];
  85152. _materialMap: {
  85153. [materialID: number]: number;
  85154. };
  85155. /**
  85156. * Stores all the generated texture information, which is referenced by glTF materials
  85157. */
  85158. _textures: ITexture[];
  85159. /**
  85160. * Stores all the generated image information, which is referenced by glTF textures
  85161. */
  85162. _images: IImage[];
  85163. /**
  85164. * Stores all the texture samplers
  85165. */
  85166. _samplers: ISampler[];
  85167. /**
  85168. * Stores all the generated glTF skins
  85169. */
  85170. _skins: ISkin[];
  85171. /**
  85172. * Stores all the generated animation samplers, which is referenced by glTF animations
  85173. */
  85174. /**
  85175. * Stores the animations for glTF models
  85176. */
  85177. private _animations;
  85178. /**
  85179. * Stores the total amount of bytes stored in the glTF buffer
  85180. */
  85181. private _totalByteLength;
  85182. /**
  85183. * Stores a reference to the Babylon scene containing the source geometry and material information
  85184. */
  85185. _babylonScene: Scene;
  85186. /**
  85187. * Stores a map of the image data, where the key is the file name and the value
  85188. * is the image data
  85189. */
  85190. _imageData: {
  85191. [fileName: string]: {
  85192. data: Uint8Array;
  85193. mimeType: ImageMimeType;
  85194. };
  85195. };
  85196. protected _orderedImageData: Array<{
  85197. data: Uint8Array;
  85198. mimeType: ImageMimeType;
  85199. }>;
  85200. /**
  85201. * Stores a map of the unique id of a node to its index in the node array
  85202. */
  85203. _nodeMap: {
  85204. [key: number]: number;
  85205. };
  85206. /**
  85207. * Specifies if the source Babylon scene was left handed, and needed conversion.
  85208. */
  85209. _convertToRightHandedSystem: boolean;
  85210. /**
  85211. * Specifies if a Babylon node should be converted to right-handed on export
  85212. */
  85213. _convertToRightHandedSystemMap: {
  85214. [nodeId: number]: boolean;
  85215. };
  85216. _includeCoordinateSystemConversionNodes: boolean;
  85217. /**
  85218. * Baked animation sample rate
  85219. */
  85220. private _animationSampleRate;
  85221. private _options;
  85222. private _localEngine;
  85223. _glTFMaterialExporter: _GLTFMaterialExporter;
  85224. private _extensions;
  85225. private static _ExtensionNames;
  85226. private static _ExtensionFactories;
  85227. private _applyExtension;
  85228. private _applyExtensions;
  85229. _extensionsPreExportTextureAsync(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Nullable<BaseTexture>>;
  85230. _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<Nullable<IMeshPrimitive>>;
  85231. _extensionsPostExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  85232. [key: number]: number;
  85233. }): Promise<Nullable<INode>>;
  85234. _extensionsPostExportMaterialAsync(context: string, material: Nullable<IMaterial>, babylonMaterial: Material): Promise<Nullable<IMaterial>>;
  85235. _extensionsPostExportMaterialAdditionalTextures(context: string, material: IMaterial, babylonMaterial: Material): BaseTexture[];
  85236. _extensionsPostExportTextures(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  85237. private _forEachExtensions;
  85238. private _extensionsOnExporting;
  85239. /**
  85240. * Load glTF serializer extensions
  85241. */
  85242. private _loadExtensions;
  85243. /**
  85244. * Creates a glTF Exporter instance, which can accept optional exporter options
  85245. * @param babylonScene Babylon scene object
  85246. * @param options Options to modify the behavior of the exporter
  85247. */
  85248. constructor(babylonScene: Scene, options?: IExportOptions);
  85249. dispose(): void;
  85250. /**
  85251. * Registers a glTF exporter extension
  85252. * @param name Name of the extension to export
  85253. * @param factory The factory function that creates the exporter extension
  85254. */
  85255. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  85256. /**
  85257. * Un-registers an exporter extension
  85258. * @param name The name fo the exporter extension
  85259. * @returns A boolean indicating whether the extension has been un-registered
  85260. */
  85261. static UnregisterExtension(name: string): boolean;
  85262. /**
  85263. * Lazy load a local engine
  85264. */
  85265. _getLocalEngine(): Engine;
  85266. private reorderIndicesBasedOnPrimitiveMode;
  85267. /**
  85268. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  85269. * clock-wise during export to glTF
  85270. * @param submesh BabylonJS submesh
  85271. * @param primitiveMode Primitive mode of the mesh
  85272. * @param sideOrientation the winding order of the submesh
  85273. * @param vertexBufferKind The type of vertex attribute
  85274. * @param meshAttributeArray The vertex attribute data
  85275. * @param byteOffset The offset to the binary data
  85276. * @param binaryWriter The binary data for the glTF file
  85277. * @param convertToRightHandedSystem Converts the values to right-handed
  85278. */
  85279. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  85280. /**
  85281. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  85282. * clock-wise during export to glTF
  85283. * @param submesh BabylonJS submesh
  85284. * @param primitiveMode Primitive mode of the mesh
  85285. * @param sideOrientation the winding order of the submesh
  85286. * @param vertexBufferKind The type of vertex attribute
  85287. * @param meshAttributeArray The vertex attribute data
  85288. * @param byteOffset The offset to the binary data
  85289. * @param binaryWriter The binary data for the glTF file
  85290. * @param convertToRightHandedSystem Converts the values to right-handed
  85291. */
  85292. private reorderTriangleFillMode;
  85293. /**
  85294. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  85295. * clock-wise during export to glTF
  85296. * @param submesh BabylonJS submesh
  85297. * @param primitiveMode Primitive mode of the mesh
  85298. * @param sideOrientation the winding order of the submesh
  85299. * @param vertexBufferKind The type of vertex attribute
  85300. * @param meshAttributeArray The vertex attribute data
  85301. * @param byteOffset The offset to the binary data
  85302. * @param binaryWriter The binary data for the glTF file
  85303. * @param convertToRightHandedSystem Converts the values to right-handed
  85304. */
  85305. private reorderTriangleStripDrawMode;
  85306. /**
  85307. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  85308. * clock-wise during export to glTF
  85309. * @param submesh BabylonJS submesh
  85310. * @param primitiveMode Primitive mode of the mesh
  85311. * @param sideOrientation the winding order of the submesh
  85312. * @param vertexBufferKind The type of vertex attribute
  85313. * @param meshAttributeArray The vertex attribute data
  85314. * @param byteOffset The offset to the binary data
  85315. * @param binaryWriter The binary data for the glTF file
  85316. * @param convertToRightHandedSystem Converts the values to right-handed
  85317. */
  85318. private reorderTriangleFanMode;
  85319. /**
  85320. * Writes the vertex attribute data to binary
  85321. * @param vertices The vertices to write to the binary writer
  85322. * @param byteOffset The offset into the binary writer to overwrite binary data
  85323. * @param vertexAttributeKind The vertex attribute type
  85324. * @param meshAttributeArray The vertex attribute data
  85325. * @param binaryWriter The writer containing the binary data
  85326. * @param convertToRightHandedSystem Converts the values to right-handed
  85327. */
  85328. private writeVertexAttributeData;
  85329. /**
  85330. * Writes mesh attribute data to a data buffer
  85331. * Returns the bytelength of the data
  85332. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  85333. * @param meshAttributeArray Array containing the attribute data
  85334. * @param byteStride Specifies the space between data
  85335. * @param binaryWriter The buffer to write the binary data to
  85336. * @param convertToRightHandedSystem Converts the values to right-handed
  85337. */
  85338. writeAttributeData(vertexBufferKind: string, attributeComponentKind: AccessorComponentType, meshAttributeArray: FloatArray, stride: number, binaryWriter: _BinaryWriter, convertToRightHandedSystem: boolean, babylonTransformNode: TransformNode): void;
  85339. /**
  85340. * Writes mesh attribute data to a data buffer
  85341. * Returns the bytelength of the data
  85342. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  85343. * @param meshAttributeArray Array containing the attribute data
  85344. * @param byteStride Specifies the space between data
  85345. * @param binaryWriter The buffer to write the binary data to
  85346. * @param convertToRightHandedSystem Converts the values to right-handed
  85347. */
  85348. writeMorphTargetAttributeData(vertexBufferKind: string, attributeComponentKind: AccessorComponentType, meshPrimitive: SubMesh, morphTarget: MorphTarget, meshAttributeArray: FloatArray, morphTargetAttributeArray: FloatArray, stride: number, binaryWriter: _BinaryWriter, convertToRightHandedSystem: boolean, minMax?: any): void;
  85349. /**
  85350. * Generates glTF json data
  85351. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  85352. * @param glTFPrefix Text to use when prefixing a glTF file
  85353. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  85354. * @returns json data as string
  85355. */
  85356. private generateJSON;
  85357. /**
  85358. * Generates data for .gltf and .bin files based on the glTF prefix string
  85359. * @param glTFPrefix Text to use when prefixing a glTF file
  85360. * @param dispose Dispose the exporter
  85361. * @returns GLTFData with glTF file data
  85362. */
  85363. _generateGLTFAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  85364. /**
  85365. * Creates a binary buffer for glTF
  85366. * @returns array buffer for binary data
  85367. */
  85368. private _generateBinaryAsync;
  85369. /**
  85370. * Pads the number to a multiple of 4
  85371. * @param num number to pad
  85372. * @returns padded number
  85373. */
  85374. private _getPadding;
  85375. /**
  85376. * @hidden
  85377. */
  85378. _generateGLBAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  85379. /**
  85380. * Sets the TRS for each node
  85381. * @param node glTF Node for storing the transformation data
  85382. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  85383. * @param convertToRightHandedSystem Converts the values to right-handed
  85384. */
  85385. private setNodeTransformation;
  85386. private getVertexBufferFromMesh;
  85387. /**
  85388. * Creates a bufferview based on the vertices type for the Babylon mesh
  85389. * @param kind Indicates the type of vertices data
  85390. * @param componentType Indicates the numerical type used to store the data
  85391. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  85392. * @param binaryWriter The buffer to write the bufferview data to
  85393. * @param convertToRightHandedSystem Converts the values to right-handed
  85394. */
  85395. private createBufferViewKind;
  85396. /**
  85397. * Creates a bufferview based on the vertices type for the Babylon mesh
  85398. * @param babylonSubMesh The Babylon submesh that the morph target is applied to
  85399. * @param babylonMorphTarget the morph target to be exported
  85400. * @param binaryWriter The buffer to write the bufferview data to
  85401. * @param convertToRightHandedSystem Converts the values to right-handed
  85402. */
  85403. private setMorphTargetAttributes;
  85404. /**
  85405. * The primitive mode of the Babylon mesh
  85406. * @param babylonMesh The BabylonJS mesh
  85407. */
  85408. private getMeshPrimitiveMode;
  85409. /**
  85410. * Sets the primitive mode of the glTF mesh primitive
  85411. * @param meshPrimitive glTF mesh primitive
  85412. * @param primitiveMode The primitive mode
  85413. */
  85414. private setPrimitiveMode;
  85415. /**
  85416. * Sets the vertex attribute accessor based of the glTF mesh primitive
  85417. * @param meshPrimitive glTF mesh primitive
  85418. * @param attributeKind vertex attribute
  85419. * @returns boolean specifying if uv coordinates are present
  85420. */
  85421. private setAttributeKind;
  85422. /**
  85423. * Sets data for the primitive attributes of each submesh
  85424. * @param mesh glTF Mesh object to store the primitive attribute information
  85425. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  85426. * @param binaryWriter Buffer to write the attribute data to
  85427. * @param convertToRightHandedSystem Converts the values to right-handed
  85428. */
  85429. private setPrimitiveAttributesAsync;
  85430. /**
  85431. * Check if the node is used to convert its descendants from a right handed coordinate system to the Babylon scene's coordinate system.
  85432. * @param node The node to check
  85433. * @returns True if the node is used to convert its descendants from right-handed to left-handed. False otherwise
  85434. */
  85435. private isBabylonCoordinateSystemConvertingNode;
  85436. /**
  85437. * Creates a glTF scene based on the array of meshes
  85438. * Returns the the total byte offset
  85439. * @param babylonScene Babylon scene to get the mesh data from
  85440. * @param binaryWriter Buffer to write binary data to
  85441. */
  85442. private createSceneAsync;
  85443. /**
  85444. * Creates a mapping of Node unique id to node index and handles animations
  85445. * @param babylonScene Babylon Scene
  85446. * @param nodes Babylon transform nodes
  85447. * @param binaryWriter Buffer to write binary data to
  85448. * @returns Node mapping of unique id to index
  85449. */
  85450. private createNodeMapAndAnimationsAsync;
  85451. /**
  85452. * Creates a glTF node from a Babylon mesh
  85453. * @param babylonMesh Source Babylon mesh
  85454. * @param binaryWriter Buffer for storing geometry data
  85455. * @param convertToRightHandedSystem Converts the values to right-handed
  85456. * @param nodeMap Node mapping of unique id to glTF node index
  85457. * @returns glTF node
  85458. */
  85459. private createNodeAsync;
  85460. /**
  85461. * Creates a glTF skin from a Babylon skeleton
  85462. * @param babylonScene Babylon Scene
  85463. * @param nodes Babylon transform nodes
  85464. * @param binaryWriter Buffer to write binary data to
  85465. * @returns Node mapping of unique id to index
  85466. */
  85467. private createSkinsAsync;
  85468. }
  85469. /**
  85470. * @hidden
  85471. *
  85472. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  85473. */
  85474. export class _BinaryWriter {
  85475. /**
  85476. * Array buffer which stores all binary data
  85477. */
  85478. private _arrayBuffer;
  85479. /**
  85480. * View of the array buffer
  85481. */
  85482. private _dataView;
  85483. /**
  85484. * byte offset of data in array buffer
  85485. */
  85486. private _byteOffset;
  85487. /**
  85488. * Initialize binary writer with an initial byte length
  85489. * @param byteLength Initial byte length of the array buffer
  85490. */
  85491. constructor(byteLength: number);
  85492. /**
  85493. * Resize the array buffer to the specified byte length
  85494. * @param byteLength
  85495. */
  85496. private resizeBuffer;
  85497. /**
  85498. * Get an array buffer with the length of the byte offset
  85499. * @returns ArrayBuffer resized to the byte offset
  85500. */
  85501. getArrayBuffer(): ArrayBuffer;
  85502. /**
  85503. * Get the byte offset of the array buffer
  85504. * @returns byte offset
  85505. */
  85506. getByteOffset(): number;
  85507. /**
  85508. * Stores an UInt8 in the array buffer
  85509. * @param entry
  85510. * @param byteOffset If defined, specifies where to set the value as an offset.
  85511. */
  85512. setUInt8(entry: number, byteOffset?: number): void;
  85513. /**
  85514. * Stores an UInt16 in the array buffer
  85515. * @param entry
  85516. * @param byteOffset If defined, specifies where to set the value as an offset.
  85517. */
  85518. setUInt16(entry: number, byteOffset?: number): void;
  85519. /**
  85520. * Gets an UInt32 in the array buffer
  85521. * @param entry
  85522. * @param byteOffset If defined, specifies where to set the value as an offset.
  85523. */
  85524. getUInt32(byteOffset: number): number;
  85525. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  85526. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  85527. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  85528. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  85529. /**
  85530. * Stores a Float32 in the array buffer
  85531. * @param entry
  85532. */
  85533. setFloat32(entry: number, byteOffset?: number): void;
  85534. /**
  85535. * Stores an UInt32 in the array buffer
  85536. * @param entry
  85537. * @param byteOffset If defined, specifies where to set the value as an offset.
  85538. */
  85539. setUInt32(entry: number, byteOffset?: number): void;
  85540. }
  85541. }
  85542. declare module BABYLON.GLTF2.Exporter {
  85543. /**
  85544. * @hidden
  85545. * Interface to store animation data.
  85546. */
  85547. export interface _IAnimationData {
  85548. /**
  85549. * Keyframe data.
  85550. */
  85551. inputs: number[];
  85552. /**
  85553. * Value data.
  85554. */
  85555. outputs: number[][];
  85556. /**
  85557. * Animation interpolation data.
  85558. */
  85559. samplerInterpolation: AnimationSamplerInterpolation;
  85560. /**
  85561. * Minimum keyframe value.
  85562. */
  85563. inputsMin: number;
  85564. /**
  85565. * Maximum keyframe value.
  85566. */
  85567. inputsMax: number;
  85568. }
  85569. /**
  85570. * @hidden
  85571. */
  85572. export interface _IAnimationInfo {
  85573. /**
  85574. * The target channel for the animation
  85575. */
  85576. animationChannelTargetPath: AnimationChannelTargetPath;
  85577. /**
  85578. * The glTF accessor type for the data.
  85579. */
  85580. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4 | AccessorType.SCALAR;
  85581. /**
  85582. * Specifies if quaternions should be used.
  85583. */
  85584. useQuaternion: boolean;
  85585. }
  85586. /**
  85587. * @hidden
  85588. * Utility class for generating glTF animation data from BabylonJS.
  85589. */
  85590. export class _GLTFAnimation {
  85591. /**
  85592. * @ignore
  85593. *
  85594. * Creates glTF channel animation from BabylonJS animation.
  85595. * @param babylonTransformNode - BabylonJS mesh.
  85596. * @param animation - animation.
  85597. * @param animationChannelTargetPath - The target animation channel.
  85598. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  85599. * @param useQuaternion - Specifies if quaternions are used.
  85600. * @returns nullable IAnimationData
  85601. */
  85602. static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  85603. private static _DeduceAnimationInfo;
  85604. /**
  85605. * @ignore
  85606. * Create node animations from the transform node animations
  85607. * @param babylonNode
  85608. * @param runtimeGLTFAnimation
  85609. * @param idleGLTFAnimations
  85610. * @param nodeMap
  85611. * @param nodes
  85612. * @param binaryWriter
  85613. * @param bufferViews
  85614. * @param accessors
  85615. * @param convertToRightHandedSystem
  85616. * @param animationSampleRate
  85617. */
  85618. static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  85619. [key: number]: number;
  85620. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  85621. /**
  85622. * @ignore
  85623. * Create individual morph animations from the mesh's morph target animation tracks
  85624. * @param babylonNode
  85625. * @param runtimeGLTFAnimation
  85626. * @param idleGLTFAnimations
  85627. * @param nodeMap
  85628. * @param nodes
  85629. * @param binaryWriter
  85630. * @param bufferViews
  85631. * @param accessors
  85632. * @param convertToRightHandedSystem
  85633. * @param animationSampleRate
  85634. */
  85635. static _CreateMorphTargetAnimationFromMorphTargetAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  85636. [key: number]: number;
  85637. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  85638. /**
  85639. * @ignore
  85640. * Create node and morph animations from the animation groups
  85641. * @param babylonScene
  85642. * @param glTFAnimations
  85643. * @param nodeMap
  85644. * @param nodes
  85645. * @param binaryWriter
  85646. * @param bufferViews
  85647. * @param accessors
  85648. * @param convertToRightHandedSystemMap
  85649. * @param animationSampleRate
  85650. */
  85651. static _CreateNodeAndMorphAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  85652. [key: number]: number;
  85653. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystemMap: {
  85654. [nodeId: number]: boolean;
  85655. }, animationSampleRate: number): void;
  85656. private static AddAnimation;
  85657. /**
  85658. * Create a baked animation
  85659. * @param babylonTransformNode BabylonJS mesh
  85660. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  85661. * @param animationChannelTargetPath animation target channel
  85662. * @param minFrame minimum animation frame
  85663. * @param maxFrame maximum animation frame
  85664. * @param fps frames per second of the animation
  85665. * @param inputs input key frames of the animation
  85666. * @param outputs output key frame data of the animation
  85667. * @param convertToRightHandedSystem converts the values to right-handed
  85668. * @param useQuaternion specifies if quaternions should be used
  85669. */
  85670. private static _CreateBakedAnimation;
  85671. private static _ConvertFactorToVector3OrQuaternion;
  85672. private static _SetInterpolatedValue;
  85673. /**
  85674. * Creates linear animation from the animation key frames
  85675. * @param babylonTransformNode BabylonJS mesh
  85676. * @param animation BabylonJS animation
  85677. * @param animationChannelTargetPath The target animation channel
  85678. * @param frameDelta The difference between the last and first frame of the animation
  85679. * @param inputs Array to store the key frame times
  85680. * @param outputs Array to store the key frame data
  85681. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  85682. * @param useQuaternion Specifies if quaternions are used in the animation
  85683. */
  85684. private static _CreateLinearOrStepAnimation;
  85685. /**
  85686. * Creates cubic spline animation from the animation key frames
  85687. * @param babylonTransformNode BabylonJS mesh
  85688. * @param animation BabylonJS animation
  85689. * @param animationChannelTargetPath The target animation channel
  85690. * @param frameDelta The difference between the last and first frame of the animation
  85691. * @param inputs Array to store the key frame times
  85692. * @param outputs Array to store the key frame data
  85693. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  85694. * @param useQuaternion Specifies if quaternions are used in the animation
  85695. */
  85696. private static _CreateCubicSplineAnimation;
  85697. private static _GetBasePositionRotationOrScale;
  85698. /**
  85699. * Adds a key frame value
  85700. * @param keyFrame
  85701. * @param animation
  85702. * @param outputs
  85703. * @param animationChannelTargetPath
  85704. * @param basePositionRotationOrScale
  85705. * @param convertToRightHandedSystem
  85706. * @param useQuaternion
  85707. */
  85708. private static _AddKeyframeValue;
  85709. /**
  85710. * Determine the interpolation based on the key frames
  85711. * @param keyFrames
  85712. * @param animationChannelTargetPath
  85713. * @param useQuaternion
  85714. */
  85715. private static _DeduceInterpolation;
  85716. /**
  85717. * Adds an input tangent or output tangent to the output data
  85718. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  85719. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  85720. * @param outputs The animation data by keyframe
  85721. * @param animationChannelTargetPath The target animation channel
  85722. * @param interpolation The interpolation type
  85723. * @param keyFrame The key frame with the animation data
  85724. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  85725. * @param useQuaternion Specifies if quaternions are used
  85726. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  85727. */
  85728. private static AddSplineTangent;
  85729. /**
  85730. * Get the minimum and maximum key frames' frame values
  85731. * @param keyFrames animation key frames
  85732. * @returns the minimum and maximum key frame value
  85733. */
  85734. private static calculateMinMaxKeyFrames;
  85735. }
  85736. }
  85737. declare module BABYLON.GLTF2.Exporter {
  85738. /** @hidden */
  85739. export var textureTransformPixelShader: {
  85740. name: string;
  85741. shader: string;
  85742. };
  85743. }
  85744. declare module BABYLON.GLTF2.Exporter.Extensions {
  85745. /**
  85746. * @hidden
  85747. */
  85748. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  85749. private _recordedTextures;
  85750. /** Name of this extension */
  85751. readonly name: string;
  85752. /** Defines whether this extension is enabled */
  85753. enabled: boolean;
  85754. /** Defines whether this extension is required */
  85755. required: boolean;
  85756. /** Reference to the glTF exporter */
  85757. private _wasUsed;
  85758. constructor(exporter: _Exporter);
  85759. dispose(): void;
  85760. /** @hidden */
  85761. get wasUsed(): boolean;
  85762. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  85763. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Texture>;
  85764. /**
  85765. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  85766. * @param babylonTexture
  85767. * @param offset
  85768. * @param rotation
  85769. * @param scale
  85770. * @param scene
  85771. */
  85772. private _textureTransformTextureAsync;
  85773. }
  85774. }
  85775. declare module BABYLON.GLTF2.Exporter.Extensions {
  85776. /**
  85777. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  85778. */
  85779. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  85780. /** The name of this extension. */
  85781. readonly name: string;
  85782. /** Defines whether this extension is enabled. */
  85783. enabled: boolean;
  85784. /** Defines whether this extension is required */
  85785. required: boolean;
  85786. /** Reference to the glTF exporter */
  85787. private _exporter;
  85788. private _lights;
  85789. /** @hidden */
  85790. constructor(exporter: _Exporter);
  85791. /** @hidden */
  85792. dispose(): void;
  85793. /** @hidden */
  85794. get wasUsed(): boolean;
  85795. /** @hidden */
  85796. onExporting(): void;
  85797. /**
  85798. * Define this method to modify the default behavior when exporting a node
  85799. * @param context The context when exporting the node
  85800. * @param node glTF node
  85801. * @param babylonNode BabylonJS node
  85802. * @param nodeMap Node mapping of unique id to glTF node index
  85803. * @returns nullable INode promise
  85804. */
  85805. postExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  85806. [key: number]: number;
  85807. }): Promise<Nullable<INode>>;
  85808. }
  85809. }
  85810. declare module BABYLON.GLTF2.Exporter.Extensions {
  85811. /**
  85812. * @hidden
  85813. */
  85814. export class KHR_materials_sheen implements IGLTFExporterExtensionV2 {
  85815. /** Name of this extension */
  85816. readonly name: string;
  85817. /** Defines whether this extension is enabled */
  85818. enabled: boolean;
  85819. /** Defines whether this extension is required */
  85820. required: boolean;
  85821. /** Reference to the glTF exporter */
  85822. private _textureInfos;
  85823. private _exportedTextures;
  85824. private _wasUsed;
  85825. constructor(exporter: _Exporter);
  85826. dispose(): void;
  85827. /** @hidden */
  85828. get wasUsed(): boolean;
  85829. private _getTextureIndex;
  85830. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  85831. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  85832. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  85833. }
  85834. }
  85835. declare module BABYLON.GLTF2.Exporter.Extensions {
  85836. /**
  85837. * @hidden
  85838. */
  85839. export class KHR_materials_unlit implements IGLTFExporterExtensionV2 {
  85840. /** Name of this extension */
  85841. readonly name: string;
  85842. /** Defines whether this extension is enabled */
  85843. enabled: boolean;
  85844. /** Defines whether this extension is required */
  85845. required: boolean;
  85846. private _wasUsed;
  85847. constructor(exporter: _Exporter);
  85848. /** @hidden */
  85849. get wasUsed(): boolean;
  85850. dispose(): void;
  85851. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  85852. }
  85853. }
  85854. declare module BABYLON {
  85855. /**
  85856. * Class for generating STL data from a Babylon scene.
  85857. */
  85858. export class STLExport {
  85859. /**
  85860. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  85861. * @param meshes list defines the mesh to serialize
  85862. * @param download triggers the automatic download of the file.
  85863. * @param fileName changes the downloads fileName.
  85864. * @param binary changes the STL to a binary type.
  85865. * @param isLittleEndian toggle for binary type exporter.
  85866. * @returns the STL as UTF8 string
  85867. */
  85868. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean): any;
  85869. }
  85870. }
  85871. declare module "babylonjs-gltf2interface" {
  85872. export = BABYLON.GLTF2;
  85873. }
  85874. /**
  85875. * Module for glTF 2.0 Interface
  85876. */
  85877. declare module BABYLON.GLTF2 {
  85878. /**
  85879. * The datatype of the components in the attribute
  85880. */
  85881. const enum AccessorComponentType {
  85882. /**
  85883. * Byte
  85884. */
  85885. BYTE = 5120,
  85886. /**
  85887. * Unsigned Byte
  85888. */
  85889. UNSIGNED_BYTE = 5121,
  85890. /**
  85891. * Short
  85892. */
  85893. SHORT = 5122,
  85894. /**
  85895. * Unsigned Short
  85896. */
  85897. UNSIGNED_SHORT = 5123,
  85898. /**
  85899. * Unsigned Int
  85900. */
  85901. UNSIGNED_INT = 5125,
  85902. /**
  85903. * Float
  85904. */
  85905. FLOAT = 5126,
  85906. }
  85907. /**
  85908. * Specifies if the attirbute is a scalar, vector, or matrix
  85909. */
  85910. const enum AccessorType {
  85911. /**
  85912. * Scalar
  85913. */
  85914. SCALAR = "SCALAR",
  85915. /**
  85916. * Vector2
  85917. */
  85918. VEC2 = "VEC2",
  85919. /**
  85920. * Vector3
  85921. */
  85922. VEC3 = "VEC3",
  85923. /**
  85924. * Vector4
  85925. */
  85926. VEC4 = "VEC4",
  85927. /**
  85928. * Matrix2x2
  85929. */
  85930. MAT2 = "MAT2",
  85931. /**
  85932. * Matrix3x3
  85933. */
  85934. MAT3 = "MAT3",
  85935. /**
  85936. * Matrix4x4
  85937. */
  85938. MAT4 = "MAT4",
  85939. }
  85940. /**
  85941. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  85942. */
  85943. const enum AnimationChannelTargetPath {
  85944. /**
  85945. * Translation
  85946. */
  85947. TRANSLATION = "translation",
  85948. /**
  85949. * Rotation
  85950. */
  85951. ROTATION = "rotation",
  85952. /**
  85953. * Scale
  85954. */
  85955. SCALE = "scale",
  85956. /**
  85957. * Weights
  85958. */
  85959. WEIGHTS = "weights",
  85960. }
  85961. /**
  85962. * Interpolation algorithm
  85963. */
  85964. const enum AnimationSamplerInterpolation {
  85965. /**
  85966. * The animated values are linearly interpolated between keyframes
  85967. */
  85968. LINEAR = "LINEAR",
  85969. /**
  85970. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  85971. */
  85972. STEP = "STEP",
  85973. /**
  85974. * The animation's interpolation is computed using a cubic spline with specified tangents
  85975. */
  85976. CUBICSPLINE = "CUBICSPLINE",
  85977. }
  85978. /**
  85979. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  85980. */
  85981. const enum CameraType {
  85982. /**
  85983. * A perspective camera containing properties to create a perspective projection matrix
  85984. */
  85985. PERSPECTIVE = "perspective",
  85986. /**
  85987. * An orthographic camera containing properties to create an orthographic projection matrix
  85988. */
  85989. ORTHOGRAPHIC = "orthographic",
  85990. }
  85991. /**
  85992. * The mime-type of the image
  85993. */
  85994. const enum ImageMimeType {
  85995. /**
  85996. * JPEG Mime-type
  85997. */
  85998. JPEG = "image/jpeg",
  85999. /**
  86000. * PNG Mime-type
  86001. */
  86002. PNG = "image/png",
  86003. }
  86004. /**
  86005. * The alpha rendering mode of the material
  86006. */
  86007. const enum MaterialAlphaMode {
  86008. /**
  86009. * The alpha value is ignored and the rendered output is fully opaque
  86010. */
  86011. OPAQUE = "OPAQUE",
  86012. /**
  86013. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  86014. */
  86015. MASK = "MASK",
  86016. /**
  86017. * 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)
  86018. */
  86019. BLEND = "BLEND",
  86020. }
  86021. /**
  86022. * The type of the primitives to render
  86023. */
  86024. const enum MeshPrimitiveMode {
  86025. /**
  86026. * Points
  86027. */
  86028. POINTS = 0,
  86029. /**
  86030. * Lines
  86031. */
  86032. LINES = 1,
  86033. /**
  86034. * Line Loop
  86035. */
  86036. LINE_LOOP = 2,
  86037. /**
  86038. * Line Strip
  86039. */
  86040. LINE_STRIP = 3,
  86041. /**
  86042. * Triangles
  86043. */
  86044. TRIANGLES = 4,
  86045. /**
  86046. * Triangle Strip
  86047. */
  86048. TRIANGLE_STRIP = 5,
  86049. /**
  86050. * Triangle Fan
  86051. */
  86052. TRIANGLE_FAN = 6,
  86053. }
  86054. /**
  86055. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  86056. */
  86057. const enum TextureMagFilter {
  86058. /**
  86059. * Nearest
  86060. */
  86061. NEAREST = 9728,
  86062. /**
  86063. * Linear
  86064. */
  86065. LINEAR = 9729,
  86066. }
  86067. /**
  86068. * Minification filter. All valid values correspond to WebGL enums
  86069. */
  86070. const enum TextureMinFilter {
  86071. /**
  86072. * Nearest
  86073. */
  86074. NEAREST = 9728,
  86075. /**
  86076. * Linear
  86077. */
  86078. LINEAR = 9729,
  86079. /**
  86080. * Nearest Mip-Map Nearest
  86081. */
  86082. NEAREST_MIPMAP_NEAREST = 9984,
  86083. /**
  86084. * Linear Mipmap Nearest
  86085. */
  86086. LINEAR_MIPMAP_NEAREST = 9985,
  86087. /**
  86088. * Nearest Mipmap Linear
  86089. */
  86090. NEAREST_MIPMAP_LINEAR = 9986,
  86091. /**
  86092. * Linear Mipmap Linear
  86093. */
  86094. LINEAR_MIPMAP_LINEAR = 9987,
  86095. }
  86096. /**
  86097. * S (U) wrapping mode. All valid values correspond to WebGL enums
  86098. */
  86099. const enum TextureWrapMode {
  86100. /**
  86101. * Clamp to Edge
  86102. */
  86103. CLAMP_TO_EDGE = 33071,
  86104. /**
  86105. * Mirrored Repeat
  86106. */
  86107. MIRRORED_REPEAT = 33648,
  86108. /**
  86109. * Repeat
  86110. */
  86111. REPEAT = 10497,
  86112. }
  86113. /**
  86114. * glTF Property
  86115. */
  86116. interface IProperty {
  86117. /**
  86118. * Dictionary object with extension-specific objects
  86119. */
  86120. extensions?: {
  86121. [key: string]: any;
  86122. };
  86123. /**
  86124. * Application-Specific data
  86125. */
  86126. extras?: any;
  86127. }
  86128. /**
  86129. * glTF Child of Root Property
  86130. */
  86131. interface IChildRootProperty extends IProperty {
  86132. /**
  86133. * The user-defined name of this object
  86134. */
  86135. name?: string;
  86136. }
  86137. /**
  86138. * Indices of those attributes that deviate from their initialization value
  86139. */
  86140. interface IAccessorSparseIndices extends IProperty {
  86141. /**
  86142. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  86143. */
  86144. bufferView: number;
  86145. /**
  86146. * The offset relative to the start of the bufferView in bytes. Must be aligned
  86147. */
  86148. byteOffset?: number;
  86149. /**
  86150. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  86151. */
  86152. componentType: AccessorComponentType;
  86153. }
  86154. /**
  86155. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  86156. */
  86157. interface IAccessorSparseValues extends IProperty {
  86158. /**
  86159. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  86160. */
  86161. bufferView: number;
  86162. /**
  86163. * The offset relative to the start of the bufferView in bytes. Must be aligned
  86164. */
  86165. byteOffset?: number;
  86166. }
  86167. /**
  86168. * Sparse storage of attributes that deviate from their initialization value
  86169. */
  86170. interface IAccessorSparse extends IProperty {
  86171. /**
  86172. * The number of attributes encoded in this sparse accessor
  86173. */
  86174. count: number;
  86175. /**
  86176. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  86177. */
  86178. indices: IAccessorSparseIndices;
  86179. /**
  86180. * 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
  86181. */
  86182. values: IAccessorSparseValues;
  86183. }
  86184. /**
  86185. * 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
  86186. */
  86187. interface IAccessor extends IChildRootProperty {
  86188. /**
  86189. * The index of the bufferview
  86190. */
  86191. bufferView?: number;
  86192. /**
  86193. * The offset relative to the start of the bufferView in bytes
  86194. */
  86195. byteOffset?: number;
  86196. /**
  86197. * The datatype of components in the attribute
  86198. */
  86199. componentType: AccessorComponentType;
  86200. /**
  86201. * Specifies whether integer data values should be normalized
  86202. */
  86203. normalized?: boolean;
  86204. /**
  86205. * The number of attributes referenced by this accessor
  86206. */
  86207. count: number;
  86208. /**
  86209. * Specifies if the attribute is a scalar, vector, or matrix
  86210. */
  86211. type: AccessorType;
  86212. /**
  86213. * Maximum value of each component in this attribute
  86214. */
  86215. max?: number[];
  86216. /**
  86217. * Minimum value of each component in this attribute
  86218. */
  86219. min?: number[];
  86220. /**
  86221. * Sparse storage of attributes that deviate from their initialization value
  86222. */
  86223. sparse?: IAccessorSparse;
  86224. }
  86225. /**
  86226. * Targets an animation's sampler at a node's property
  86227. */
  86228. interface IAnimationChannel extends IProperty {
  86229. /**
  86230. * The index of a sampler in this animation used to compute the value for the target
  86231. */
  86232. sampler: number;
  86233. /**
  86234. * The index of the node and TRS property to target
  86235. */
  86236. target: IAnimationChannelTarget;
  86237. }
  86238. /**
  86239. * The index of the node and TRS property that an animation channel targets
  86240. */
  86241. interface IAnimationChannelTarget extends IProperty {
  86242. /**
  86243. * The index of the node to target
  86244. */
  86245. node: number;
  86246. /**
  86247. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  86248. */
  86249. path: AnimationChannelTargetPath;
  86250. }
  86251. /**
  86252. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  86253. */
  86254. interface IAnimationSampler extends IProperty {
  86255. /**
  86256. * The index of an accessor containing keyframe input values, e.g., time
  86257. */
  86258. input: number;
  86259. /**
  86260. * Interpolation algorithm
  86261. */
  86262. interpolation?: AnimationSamplerInterpolation;
  86263. /**
  86264. * The index of an accessor, containing keyframe output values
  86265. */
  86266. output: number;
  86267. }
  86268. /**
  86269. * A keyframe animation
  86270. */
  86271. interface IAnimation extends IChildRootProperty {
  86272. /**
  86273. * An array of channels, each of which targets an animation's sampler at a node's property
  86274. */
  86275. channels: IAnimationChannel[];
  86276. /**
  86277. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  86278. */
  86279. samplers: IAnimationSampler[];
  86280. }
  86281. /**
  86282. * Metadata about the glTF asset
  86283. */
  86284. interface IAsset extends IChildRootProperty {
  86285. /**
  86286. * A copyright message suitable for display to credit the content creator
  86287. */
  86288. copyright?: string;
  86289. /**
  86290. * Tool that generated this glTF model. Useful for debugging
  86291. */
  86292. generator?: string;
  86293. /**
  86294. * The glTF version that this asset targets
  86295. */
  86296. version: string;
  86297. /**
  86298. * The minimum glTF version that this asset targets
  86299. */
  86300. minVersion?: string;
  86301. }
  86302. /**
  86303. * A buffer points to binary geometry, animation, or skins
  86304. */
  86305. interface IBuffer extends IChildRootProperty {
  86306. /**
  86307. * 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
  86308. */
  86309. uri?: string;
  86310. /**
  86311. * The length of the buffer in bytes
  86312. */
  86313. byteLength: number;
  86314. }
  86315. /**
  86316. * A view into a buffer generally representing a subset of the buffer
  86317. */
  86318. interface IBufferView extends IChildRootProperty {
  86319. /**
  86320. * The index of the buffer
  86321. */
  86322. buffer: number;
  86323. /**
  86324. * The offset into the buffer in bytes
  86325. */
  86326. byteOffset?: number;
  86327. /**
  86328. * The lenth of the bufferView in bytes
  86329. */
  86330. byteLength: number;
  86331. /**
  86332. * The stride, in bytes
  86333. */
  86334. byteStride?: number;
  86335. }
  86336. /**
  86337. * An orthographic camera containing properties to create an orthographic projection matrix
  86338. */
  86339. interface ICameraOrthographic extends IProperty {
  86340. /**
  86341. * The floating-point horizontal magnification of the view. Must not be zero
  86342. */
  86343. xmag: number;
  86344. /**
  86345. * The floating-point vertical magnification of the view. Must not be zero
  86346. */
  86347. ymag: number;
  86348. /**
  86349. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  86350. */
  86351. zfar: number;
  86352. /**
  86353. * The floating-point distance to the near clipping plane
  86354. */
  86355. znear: number;
  86356. }
  86357. /**
  86358. * A perspective camera containing properties to create a perspective projection matrix
  86359. */
  86360. interface ICameraPerspective extends IProperty {
  86361. /**
  86362. * The floating-point aspect ratio of the field of view
  86363. */
  86364. aspectRatio?: number;
  86365. /**
  86366. * The floating-point vertical field of view in radians
  86367. */
  86368. yfov: number;
  86369. /**
  86370. * The floating-point distance to the far clipping plane
  86371. */
  86372. zfar?: number;
  86373. /**
  86374. * The floating-point distance to the near clipping plane
  86375. */
  86376. znear: number;
  86377. }
  86378. /**
  86379. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  86380. */
  86381. interface ICamera extends IChildRootProperty {
  86382. /**
  86383. * An orthographic camera containing properties to create an orthographic projection matrix
  86384. */
  86385. orthographic?: ICameraOrthographic;
  86386. /**
  86387. * A perspective camera containing properties to create a perspective projection matrix
  86388. */
  86389. perspective?: ICameraPerspective;
  86390. /**
  86391. * Specifies if the camera uses a perspective or orthographic projection
  86392. */
  86393. type: CameraType;
  86394. }
  86395. /**
  86396. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  86397. */
  86398. interface IImage extends IChildRootProperty {
  86399. /**
  86400. * 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
  86401. */
  86402. uri?: string;
  86403. /**
  86404. * The image's MIME type
  86405. */
  86406. mimeType?: ImageMimeType;
  86407. /**
  86408. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  86409. */
  86410. bufferView?: number;
  86411. }
  86412. /**
  86413. * Material Normal Texture Info
  86414. */
  86415. interface IMaterialNormalTextureInfo extends ITextureInfo {
  86416. /**
  86417. * The scalar multiplier applied to each normal vector of the normal texture
  86418. */
  86419. scale?: number;
  86420. }
  86421. /**
  86422. * Material Occlusion Texture Info
  86423. */
  86424. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  86425. /**
  86426. * A scalar multiplier controlling the amount of occlusion applied
  86427. */
  86428. strength?: number;
  86429. }
  86430. /**
  86431. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  86432. */
  86433. interface IMaterialPbrMetallicRoughness {
  86434. /**
  86435. * The material's base color factor
  86436. */
  86437. baseColorFactor?: number[];
  86438. /**
  86439. * The base color texture
  86440. */
  86441. baseColorTexture?: ITextureInfo;
  86442. /**
  86443. * The metalness of the material
  86444. */
  86445. metallicFactor?: number;
  86446. /**
  86447. * The roughness of the material
  86448. */
  86449. roughnessFactor?: number;
  86450. /**
  86451. * The metallic-roughness texture
  86452. */
  86453. metallicRoughnessTexture?: ITextureInfo;
  86454. }
  86455. /**
  86456. * The material appearance of a primitive
  86457. */
  86458. interface IMaterial extends IChildRootProperty {
  86459. /**
  86460. * 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
  86461. */
  86462. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  86463. /**
  86464. * The normal map texture
  86465. */
  86466. normalTexture?: IMaterialNormalTextureInfo;
  86467. /**
  86468. * The occlusion map texture
  86469. */
  86470. occlusionTexture?: IMaterialOcclusionTextureInfo;
  86471. /**
  86472. * The emissive map texture
  86473. */
  86474. emissiveTexture?: ITextureInfo;
  86475. /**
  86476. * 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
  86477. */
  86478. emissiveFactor?: number[];
  86479. /**
  86480. * The alpha rendering mode of the material
  86481. */
  86482. alphaMode?: MaterialAlphaMode;
  86483. /**
  86484. * The alpha cutoff value of the material
  86485. */
  86486. alphaCutoff?: number;
  86487. /**
  86488. * Specifies whether the material is double sided
  86489. */
  86490. doubleSided?: boolean;
  86491. }
  86492. /**
  86493. * Geometry to be rendered with the given material
  86494. */
  86495. interface IMeshPrimitive extends IProperty {
  86496. /**
  86497. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  86498. */
  86499. attributes: {
  86500. [name: string]: number;
  86501. };
  86502. /**
  86503. * The index of the accessor that contains the indices
  86504. */
  86505. indices?: number;
  86506. /**
  86507. * The index of the material to apply to this primitive when rendering
  86508. */
  86509. material?: number;
  86510. /**
  86511. * The type of primitives to render. All valid values correspond to WebGL enums
  86512. */
  86513. mode?: MeshPrimitiveMode;
  86514. /**
  86515. * 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
  86516. */
  86517. targets?: {
  86518. [name: string]: number;
  86519. }[];
  86520. }
  86521. /**
  86522. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  86523. */
  86524. interface IMesh extends IChildRootProperty {
  86525. /**
  86526. * An array of primitives, each defining geometry to be rendered with a material
  86527. */
  86528. primitives: IMeshPrimitive[];
  86529. /**
  86530. * Array of weights to be applied to the Morph Targets
  86531. */
  86532. weights?: number[];
  86533. }
  86534. /**
  86535. * A node in the node hierarchy
  86536. */
  86537. interface INode extends IChildRootProperty {
  86538. /**
  86539. * The index of the camera referenced by this node
  86540. */
  86541. camera?: number;
  86542. /**
  86543. * The indices of this node's children
  86544. */
  86545. children?: number[];
  86546. /**
  86547. * The index of the skin referenced by this node
  86548. */
  86549. skin?: number;
  86550. /**
  86551. * A floating-point 4x4 transformation matrix stored in column-major order
  86552. */
  86553. matrix?: number[];
  86554. /**
  86555. * The index of the mesh in this node
  86556. */
  86557. mesh?: number;
  86558. /**
  86559. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  86560. */
  86561. rotation?: number[];
  86562. /**
  86563. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  86564. */
  86565. scale?: number[];
  86566. /**
  86567. * The node's translation along the x, y, and z axes
  86568. */
  86569. translation?: number[];
  86570. /**
  86571. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  86572. */
  86573. weights?: number[];
  86574. }
  86575. /**
  86576. * Texture sampler properties for filtering and wrapping modes
  86577. */
  86578. interface ISampler extends IChildRootProperty {
  86579. /**
  86580. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  86581. */
  86582. magFilter?: TextureMagFilter;
  86583. /**
  86584. * Minification filter. All valid values correspond to WebGL enums
  86585. */
  86586. minFilter?: TextureMinFilter;
  86587. /**
  86588. * S (U) wrapping mode. All valid values correspond to WebGL enums
  86589. */
  86590. wrapS?: TextureWrapMode;
  86591. /**
  86592. * T (V) wrapping mode. All valid values correspond to WebGL enums
  86593. */
  86594. wrapT?: TextureWrapMode;
  86595. }
  86596. /**
  86597. * The root nodes of a scene
  86598. */
  86599. interface IScene extends IChildRootProperty {
  86600. /**
  86601. * The indices of each root node
  86602. */
  86603. nodes: number[];
  86604. }
  86605. /**
  86606. * Joints and matrices defining a skin
  86607. */
  86608. interface ISkin extends IChildRootProperty {
  86609. /**
  86610. * 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
  86611. */
  86612. inverseBindMatrices?: number;
  86613. /**
  86614. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  86615. */
  86616. skeleton?: number;
  86617. /**
  86618. * 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)
  86619. */
  86620. joints: number[];
  86621. }
  86622. /**
  86623. * A texture and its sampler
  86624. */
  86625. interface ITexture extends IChildRootProperty {
  86626. /**
  86627. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  86628. */
  86629. sampler?: number;
  86630. /**
  86631. * The index of the image used by this texture
  86632. */
  86633. source: number;
  86634. }
  86635. /**
  86636. * Reference to a texture
  86637. */
  86638. interface ITextureInfo extends IProperty {
  86639. /**
  86640. * The index of the texture
  86641. */
  86642. index: number;
  86643. /**
  86644. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  86645. */
  86646. texCoord?: number;
  86647. }
  86648. /**
  86649. * The root object for a glTF asset
  86650. */
  86651. interface IGLTF extends IProperty {
  86652. /**
  86653. * An array of accessors. An accessor is a typed view into a bufferView
  86654. */
  86655. accessors?: IAccessor[];
  86656. /**
  86657. * An array of keyframe animations
  86658. */
  86659. animations?: IAnimation[];
  86660. /**
  86661. * Metadata about the glTF asset
  86662. */
  86663. asset: IAsset;
  86664. /**
  86665. * An array of buffers. A buffer points to binary geometry, animation, or skins
  86666. */
  86667. buffers?: IBuffer[];
  86668. /**
  86669. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  86670. */
  86671. bufferViews?: IBufferView[];
  86672. /**
  86673. * An array of cameras
  86674. */
  86675. cameras?: ICamera[];
  86676. /**
  86677. * Names of glTF extensions used somewhere in this asset
  86678. */
  86679. extensionsUsed?: string[];
  86680. /**
  86681. * Names of glTF extensions required to properly load this asset
  86682. */
  86683. extensionsRequired?: string[];
  86684. /**
  86685. * An array of images. An image defines data used to create a texture
  86686. */
  86687. images?: IImage[];
  86688. /**
  86689. * An array of materials. A material defines the appearance of a primitive
  86690. */
  86691. materials?: IMaterial[];
  86692. /**
  86693. * An array of meshes. A mesh is a set of primitives to be rendered
  86694. */
  86695. meshes?: IMesh[];
  86696. /**
  86697. * An array of nodes
  86698. */
  86699. nodes?: INode[];
  86700. /**
  86701. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  86702. */
  86703. samplers?: ISampler[];
  86704. /**
  86705. * The index of the default scene
  86706. */
  86707. scene?: number;
  86708. /**
  86709. * An array of scenes
  86710. */
  86711. scenes?: IScene[];
  86712. /**
  86713. * An array of skins. A skin is defined by joints and matrices
  86714. */
  86715. skins?: ISkin[];
  86716. /**
  86717. * An array of textures
  86718. */
  86719. textures?: ITexture[];
  86720. }
  86721. /**
  86722. * The glTF validation results
  86723. * @ignore
  86724. */
  86725. interface IGLTFValidationResults {
  86726. info: {
  86727. generator: string;
  86728. hasAnimations: boolean;
  86729. hasDefaultScene: boolean;
  86730. hasMaterials: boolean;
  86731. hasMorphTargets: boolean;
  86732. hasSkins: boolean;
  86733. hasTextures: boolean;
  86734. maxAttributesUsed: number;
  86735. primitivesCount: number
  86736. };
  86737. issues: {
  86738. messages: Array<string>;
  86739. numErrors: number;
  86740. numHints: number;
  86741. numInfos: number;
  86742. numWarnings: number;
  86743. truncated: boolean
  86744. };
  86745. mimeType: string;
  86746. uri: string;
  86747. validatedAt: string;
  86748. validatorVersion: string;
  86749. }
  86750. /**
  86751. * The glTF validation options
  86752. */
  86753. interface IGLTFValidationOptions {
  86754. /** Uri to use */
  86755. uri?: string;
  86756. /** Function used to load external resources */
  86757. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  86758. /** Boolean indicating that we need to validate accessor data */
  86759. validateAccessorData?: boolean;
  86760. /** max number of issues allowed */
  86761. maxIssues?: number;
  86762. /** Ignored issues */
  86763. ignoredIssues?: Array<string>;
  86764. /** Value to override severy settings */
  86765. severityOverrides?: Object;
  86766. }
  86767. /**
  86768. * The glTF validator object
  86769. * @ignore
  86770. */
  86771. interface IGLTFValidator {
  86772. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  86773. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  86774. }
  86775. /**
  86776. * Interfaces from the EXT_lights_image_based extension
  86777. */
  86778. /** @hidden */
  86779. interface IEXTLightsImageBased_LightReferenceImageBased {
  86780. light: number;
  86781. }
  86782. /** @hidden */
  86783. interface IEXTLightsImageBased_LightImageBased extends IChildRootProperty {
  86784. intensity: number;
  86785. rotation: number[];
  86786. specularImageSize: number;
  86787. specularImages: number[][];
  86788. irradianceCoefficients: number[][];
  86789. }
  86790. /** @hidden */
  86791. interface IEXTLightsImageBased {
  86792. lights: IEXTLightsImageBased_LightImageBased[];
  86793. }
  86794. /**
  86795. * Interfaces from the EXT_mesh_gpu_instancing extension
  86796. * !!! Experimental Extension Subject to Changes !!!
  86797. */
  86798. /** @hidden */
  86799. interface IEXTMeshGpuInstancing {
  86800. mesh?: number;
  86801. attributes: { [name: string]: number };
  86802. }
  86803. /**
  86804. * Interfaces from the KHR_draco_mesh_compression extension
  86805. */
  86806. /** @hidden */
  86807. interface IKHRDracoMeshCompression {
  86808. bufferView: number;
  86809. attributes: { [name: string]: number };
  86810. }
  86811. /**
  86812. * Interfaces from the KHR_lights_punctual extension
  86813. */
  86814. /** @hidden */
  86815. const enum IKHRLightsPunctual_LightType {
  86816. DIRECTIONAL = "directional",
  86817. POINT = "point",
  86818. SPOT = "spot"
  86819. }
  86820. /** @hidden */
  86821. interface IKHRLightsPunctual_LightReference {
  86822. light: number;
  86823. }
  86824. /** @hidden */
  86825. interface IKHRLightsPunctual_Light extends IChildRootProperty {
  86826. type: IKHRLightsPunctual_LightType;
  86827. color?: number[];
  86828. intensity?: number;
  86829. range?: number;
  86830. spot?: {
  86831. innerConeAngle?: number;
  86832. outerConeAngle?: number;
  86833. };
  86834. }
  86835. /** @hidden */
  86836. interface IKHRLightsPunctual {
  86837. lights: IKHRLightsPunctual_Light[];
  86838. }
  86839. /**
  86840. * Interfaces from the KHR_materials_clearcoat extension
  86841. * !!! Experimental Extension Subject to Changes !!!
  86842. */
  86843. /** @hidden */
  86844. interface IKHRMaterialsClearcoat {
  86845. clearcoatFactor: number;
  86846. clearcoatTexture: ITextureInfo;
  86847. clearcoatRoughnessFactor: number;
  86848. clearcoatRoughnessTexture: ITextureInfo;
  86849. clearcoatNormalTexture: IMaterialNormalTextureInfo;
  86850. }
  86851. /**
  86852. * Interfaces from the KHR_materials_ior extension
  86853. * !!! Experimental Extension Subject to Changes !!!
  86854. */
  86855. /** @hidden */
  86856. interface IKHRMaterialsIor {
  86857. ior: number;
  86858. }
  86859. /**
  86860. * Interfaces from the KHR_materials_pbrSpecularGlossiness extension
  86861. */
  86862. /** @hidden */
  86863. interface IKHRMaterialsPbrSpecularGlossiness {
  86864. diffuseFactor: number[];
  86865. diffuseTexture: ITextureInfo;
  86866. specularFactor: number[];
  86867. glossinessFactor: number;
  86868. specularGlossinessTexture: ITextureInfo;
  86869. }
  86870. /**
  86871. * Interfaces from the KHR_materials_sheen extension
  86872. * !!! Experimental Extension Subject to Changes !!!
  86873. */
  86874. /** @hidden */
  86875. interface IKHRMaterialsSheen {
  86876. sheenColorFactor?: number[];
  86877. sheenColorTexture?: ITextureInfo;
  86878. sheenRoughnessFactor?: number;
  86879. sheenRoughnessTexture?: ITextureInfo;
  86880. }
  86881. /**
  86882. * Interfaces from the KHR_materials_specular extension
  86883. * !!! Experimental Extension Subject to Changes !!!
  86884. */
  86885. /** @hidden */
  86886. interface IKHRMaterialsSpecular {
  86887. specularFactor: number;
  86888. specularColorFactor: number[];
  86889. specularTexture: ITextureInfo;
  86890. }
  86891. /**
  86892. * Interfaces from the KHR_materials_transmission extension
  86893. * !!! Experimental Extension Subject to Changes !!!
  86894. */
  86895. /** @hidden */
  86896. interface IKHRMaterialsTransmission {
  86897. transmissionFactor?: number;
  86898. transmissionTexture?: ITextureInfo;
  86899. }
  86900. /**
  86901. * Interfaces from the KHR_materials_translucency extension
  86902. * !!! Experimental Extension Subject to Changes !!!
  86903. */
  86904. /** @hidden */
  86905. interface IKHRMaterialsTranslucency {
  86906. translucencyFactor?: number;
  86907. translucencyTexture?: ITextureInfo;
  86908. }
  86909. /**
  86910. * Interfaces from the KHR_materials_variants extension
  86911. * !!! Experimental Extension Subject to Changes !!!
  86912. */
  86913. /** @hidden */
  86914. interface IKHRMaterialVariants_Mapping extends IProperty {
  86915. mappings: Array<{
  86916. variants: number[];
  86917. material: number;
  86918. }>;
  86919. }
  86920. /** @hidden */
  86921. interface IKHRMaterialVariants_Variant extends IProperty {
  86922. name: string;
  86923. }
  86924. /** @hidden */
  86925. interface IKHRMaterialVariants_Variants extends IChildRootProperty {
  86926. variants: Array<IKHRMaterialVariants_Variant>;
  86927. }
  86928. /**
  86929. * Interfaces from the KHR_texture_basisu extension
  86930. * !!! Experimental Extension Subject to Changes !!!
  86931. */
  86932. /** @hidden */
  86933. interface IKHRTextureBasisU {
  86934. source: number;
  86935. }
  86936. /**
  86937. * Interfaces from the EXT_texture_webp extension
  86938. */
  86939. /** @hidden */
  86940. interface IEXTTextureWebP {
  86941. source: number;
  86942. }
  86943. /**
  86944. * Interfaces from the KHR_texture_transform extension
  86945. */
  86946. /** @hidden */
  86947. interface IKHRTextureTransform {
  86948. offset?: number[];
  86949. rotation?: number;
  86950. scale?: number[];
  86951. texCoord?: number;
  86952. }
  86953. /**
  86954. * Interfaces from the KHR_xmp extension
  86955. * !!! Experimental Extension Subject to Changes !!!
  86956. */
  86957. /** @hidden */
  86958. interface IKHRXmp_Data {
  86959. [key: string]: unknown;
  86960. }
  86961. /** @hidden */
  86962. interface IKHRXmp_Gltf {
  86963. packets: IKHRXmp_Data[];
  86964. }
  86965. /** @hidden */
  86966. interface IKHRXmp_Node {
  86967. packet: number;
  86968. }
  86969. /**
  86970. * Interfaces from the MSFT_audio_emitter extension
  86971. */
  86972. /** @hidden */
  86973. interface IMSFTAudioEmitter_ClipReference {
  86974. clip: number;
  86975. weight?: number;
  86976. }
  86977. /** @hidden */
  86978. interface IMSFTAudioEmitter_EmittersReference {
  86979. emitters: number[];
  86980. }
  86981. /** @hidden */
  86982. const enum IMSFTAudioEmitter_DistanceModel {
  86983. linear = "linear",
  86984. inverse = "inverse",
  86985. exponential = "exponential",
  86986. }
  86987. /** @hidden */
  86988. interface IMSFTAudioEmitter_Emitter {
  86989. name?: string;
  86990. distanceModel?: IMSFTAudioEmitter_DistanceModel;
  86991. refDistance?: number;
  86992. maxDistance?: number;
  86993. rolloffFactor?: number;
  86994. innerAngle?: number;
  86995. outerAngle?: number;
  86996. loop?: boolean;
  86997. volume?: number;
  86998. clips: IMSFTAudioEmitter_ClipReference[];
  86999. }
  87000. /** @hidden */
  87001. const enum IMSFTAudioEmitter_AudioMimeType {
  87002. WAV = "audio/wav",
  87003. }
  87004. /** @hidden */
  87005. interface IMSFTAudioEmitter_Clip extends IProperty {
  87006. uri?: string;
  87007. bufferView?: number;
  87008. mimeType?: IMSFTAudioEmitter_AudioMimeType;
  87009. }
  87010. /** @hidden */
  87011. const enum IMSFTAudioEmitter_AnimationEventAction {
  87012. play = "play",
  87013. pause = "pause",
  87014. stop = "stop",
  87015. }
  87016. /** @hidden */
  87017. interface IMSFTAudioEmitter_AnimationEvent {
  87018. action: IMSFTAudioEmitter_AnimationEventAction;
  87019. emitter: number;
  87020. time: number;
  87021. startOffset?: number;
  87022. }
  87023. /**
  87024. * Interfaces from the MSFT_lod extension
  87025. */
  87026. /** @hidden */
  87027. interface IMSFTLOD {
  87028. ids: number[];
  87029. }
  87030. }
  87031. declare module BABYLON {
  87032. /** @hidden */
  87033. export var cellPixelShader: {
  87034. name: string;
  87035. shader: string;
  87036. };
  87037. }
  87038. declare module BABYLON {
  87039. /** @hidden */
  87040. export var cellVertexShader: {
  87041. name: string;
  87042. shader: string;
  87043. };
  87044. }
  87045. declare module BABYLON {
  87046. export class CellMaterial extends BABYLON.PushMaterial {
  87047. private _diffuseTexture;
  87048. diffuseTexture: BABYLON.BaseTexture;
  87049. diffuseColor: BABYLON.Color3;
  87050. _computeHighLevel: boolean;
  87051. computeHighLevel: boolean;
  87052. private _disableLighting;
  87053. disableLighting: boolean;
  87054. private _maxSimultaneousLights;
  87055. maxSimultaneousLights: number;
  87056. constructor(name: string, scene: BABYLON.Scene);
  87057. needAlphaBlending(): boolean;
  87058. needAlphaTesting(): boolean;
  87059. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87060. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87061. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87062. getAnimatables(): BABYLON.IAnimatable[];
  87063. getActiveTextures(): BABYLON.BaseTexture[];
  87064. hasTexture(texture: BABYLON.BaseTexture): boolean;
  87065. dispose(forceDisposeEffect?: boolean): void;
  87066. getClassName(): string;
  87067. clone(name: string): CellMaterial;
  87068. serialize(): any;
  87069. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  87070. }
  87071. }
  87072. declare module BABYLON {
  87073. export class CustomShaderStructure {
  87074. FragmentStore: string;
  87075. VertexStore: string;
  87076. constructor();
  87077. }
  87078. export class ShaderSpecialParts {
  87079. constructor();
  87080. Fragment_Begin: string;
  87081. Fragment_Definitions: string;
  87082. Fragment_MainBegin: string;
  87083. Fragment_Custom_Diffuse: string;
  87084. Fragment_Before_Lights: string;
  87085. Fragment_Before_Fog: string;
  87086. Fragment_Custom_Alpha: string;
  87087. Fragment_Before_FragColor: string;
  87088. Vertex_Begin: string;
  87089. Vertex_Definitions: string;
  87090. Vertex_MainBegin: string;
  87091. Vertex_Before_PositionUpdated: string;
  87092. Vertex_Before_NormalUpdated: string;
  87093. Vertex_After_WorldPosComputed: string;
  87094. Vertex_MainEnd: string;
  87095. }
  87096. export class CustomMaterial extends BABYLON.StandardMaterial {
  87097. static ShaderIndexer: number;
  87098. CustomParts: ShaderSpecialParts;
  87099. _isCreatedShader: boolean;
  87100. _createdShaderName: string;
  87101. _customUniform: string[];
  87102. _newUniforms: string[];
  87103. _newUniformInstances: {
  87104. [name: string]: any;
  87105. };
  87106. _newSamplerInstances: {
  87107. [name: string]: BABYLON.Texture;
  87108. };
  87109. _customAttributes: string[];
  87110. FragmentShader: string;
  87111. VertexShader: string;
  87112. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  87113. ReviewUniform(name: string, arr: string[]): string[];
  87114. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[]): string;
  87115. constructor(name: string, scene: BABYLON.Scene);
  87116. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  87117. AddAttribute(name: string): CustomMaterial;
  87118. Fragment_Begin(shaderPart: string): CustomMaterial;
  87119. Fragment_Definitions(shaderPart: string): CustomMaterial;
  87120. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  87121. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  87122. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  87123. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  87124. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  87125. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  87126. Vertex_Begin(shaderPart: string): CustomMaterial;
  87127. Vertex_Definitions(shaderPart: string): CustomMaterial;
  87128. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  87129. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  87130. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  87131. Vertex_After_WorldPosComputed(shaderPart: string): CustomMaterial;
  87132. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  87133. }
  87134. }
  87135. declare module BABYLON {
  87136. export class ShaderAlebdoParts {
  87137. constructor();
  87138. Fragment_Begin: string;
  87139. Fragment_Definitions: string;
  87140. Fragment_MainBegin: string;
  87141. Fragment_Custom_Albedo: string;
  87142. Fragment_Before_Lights: string;
  87143. Fragment_Custom_MetallicRoughness: string;
  87144. Fragment_Custom_MicroSurface: string;
  87145. Fragment_Before_Fog: string;
  87146. Fragment_Custom_Alpha: string;
  87147. Fragment_Before_FragColor: string;
  87148. Vertex_Begin: string;
  87149. Vertex_Definitions: string;
  87150. Vertex_MainBegin: string;
  87151. Vertex_Before_PositionUpdated: string;
  87152. Vertex_Before_NormalUpdated: string;
  87153. Vertex_After_WorldPosComputed: string;
  87154. Vertex_MainEnd: string;
  87155. }
  87156. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  87157. static ShaderIndexer: number;
  87158. CustomParts: ShaderAlebdoParts;
  87159. _isCreatedShader: boolean;
  87160. _createdShaderName: string;
  87161. _customUniform: string[];
  87162. _newUniforms: string[];
  87163. _newUniformInstances: {
  87164. [name: string]: any;
  87165. };
  87166. _newSamplerInstances: {
  87167. [name: string]: BABYLON.Texture;
  87168. };
  87169. _customAttributes: string[];
  87170. FragmentShader: string;
  87171. VertexShader: string;
  87172. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  87173. ReviewUniform(name: string, arr: string[]): string[];
  87174. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[]): string;
  87175. constructor(name: string, scene: BABYLON.Scene);
  87176. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  87177. AddAttribute(name: string): PBRCustomMaterial;
  87178. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  87179. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  87180. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  87181. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  87182. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  87183. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  87184. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  87185. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  87186. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  87187. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  87188. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  87189. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  87190. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  87191. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  87192. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  87193. Vertex_After_WorldPosComputed(shaderPart: string): PBRCustomMaterial;
  87194. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  87195. }
  87196. }
  87197. declare module BABYLON {
  87198. /** @hidden */
  87199. export var firePixelShader: {
  87200. name: string;
  87201. shader: string;
  87202. };
  87203. }
  87204. declare module BABYLON {
  87205. /** @hidden */
  87206. export var fireVertexShader: {
  87207. name: string;
  87208. shader: string;
  87209. };
  87210. }
  87211. declare module BABYLON {
  87212. export class FireMaterial extends BABYLON.PushMaterial {
  87213. private _diffuseTexture;
  87214. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  87215. private _distortionTexture;
  87216. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  87217. private _opacityTexture;
  87218. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  87219. diffuseColor: BABYLON.Color3;
  87220. speed: number;
  87221. private _scaledDiffuse;
  87222. private _lastTime;
  87223. constructor(name: string, scene: BABYLON.Scene);
  87224. needAlphaBlending(): boolean;
  87225. needAlphaTesting(): boolean;
  87226. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87227. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87228. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87229. getAnimatables(): BABYLON.IAnimatable[];
  87230. getActiveTextures(): BABYLON.BaseTexture[];
  87231. hasTexture(texture: BABYLON.BaseTexture): boolean;
  87232. getClassName(): string;
  87233. dispose(forceDisposeEffect?: boolean): void;
  87234. clone(name: string): FireMaterial;
  87235. serialize(): any;
  87236. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  87237. }
  87238. }
  87239. declare module BABYLON {
  87240. /** @hidden */
  87241. export var furPixelShader: {
  87242. name: string;
  87243. shader: string;
  87244. };
  87245. }
  87246. declare module BABYLON {
  87247. /** @hidden */
  87248. export var furVertexShader: {
  87249. name: string;
  87250. shader: string;
  87251. };
  87252. }
  87253. declare module BABYLON {
  87254. export class FurMaterial extends BABYLON.PushMaterial {
  87255. private _diffuseTexture;
  87256. diffuseTexture: BABYLON.BaseTexture;
  87257. private _heightTexture;
  87258. heightTexture: BABYLON.BaseTexture;
  87259. diffuseColor: BABYLON.Color3;
  87260. furLength: number;
  87261. furAngle: number;
  87262. furColor: BABYLON.Color3;
  87263. furOffset: number;
  87264. furSpacing: number;
  87265. furGravity: BABYLON.Vector3;
  87266. furSpeed: number;
  87267. furDensity: number;
  87268. furOcclusion: number;
  87269. furTexture: BABYLON.DynamicTexture;
  87270. private _disableLighting;
  87271. disableLighting: boolean;
  87272. private _maxSimultaneousLights;
  87273. maxSimultaneousLights: number;
  87274. highLevelFur: boolean;
  87275. _meshes: BABYLON.AbstractMesh[];
  87276. private _furTime;
  87277. constructor(name: string, scene: BABYLON.Scene);
  87278. get furTime(): number;
  87279. set furTime(furTime: number);
  87280. needAlphaBlending(): boolean;
  87281. needAlphaTesting(): boolean;
  87282. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87283. updateFur(): void;
  87284. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87285. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87286. getAnimatables(): BABYLON.IAnimatable[];
  87287. getActiveTextures(): BABYLON.BaseTexture[];
  87288. hasTexture(texture: BABYLON.BaseTexture): boolean;
  87289. dispose(forceDisposeEffect?: boolean): void;
  87290. clone(name: string): FurMaterial;
  87291. serialize(): any;
  87292. getClassName(): string;
  87293. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  87294. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  87295. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  87296. }
  87297. }
  87298. declare module BABYLON {
  87299. /** @hidden */
  87300. export var gradientPixelShader: {
  87301. name: string;
  87302. shader: string;
  87303. };
  87304. }
  87305. declare module BABYLON {
  87306. /** @hidden */
  87307. export var gradientVertexShader: {
  87308. name: string;
  87309. shader: string;
  87310. };
  87311. }
  87312. declare module BABYLON {
  87313. export class GradientMaterial extends BABYLON.PushMaterial {
  87314. private _maxSimultaneousLights;
  87315. maxSimultaneousLights: number;
  87316. topColor: BABYLON.Color3;
  87317. topColorAlpha: number;
  87318. bottomColor: BABYLON.Color3;
  87319. bottomColorAlpha: number;
  87320. offset: number;
  87321. scale: number;
  87322. smoothness: number;
  87323. private _disableLighting;
  87324. disableLighting: boolean;
  87325. constructor(name: string, scene: BABYLON.Scene);
  87326. needAlphaBlending(): boolean;
  87327. needAlphaTesting(): boolean;
  87328. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87329. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87330. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87331. getAnimatables(): BABYLON.IAnimatable[];
  87332. dispose(forceDisposeEffect?: boolean): void;
  87333. clone(name: string): GradientMaterial;
  87334. serialize(): any;
  87335. getClassName(): string;
  87336. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  87337. }
  87338. }
  87339. declare module BABYLON {
  87340. /** @hidden */
  87341. export var gridPixelShader: {
  87342. name: string;
  87343. shader: string;
  87344. };
  87345. }
  87346. declare module BABYLON {
  87347. /** @hidden */
  87348. export var gridVertexShader: {
  87349. name: string;
  87350. shader: string;
  87351. };
  87352. }
  87353. declare module BABYLON {
  87354. /**
  87355. * The grid materials allows you to wrap any shape with a grid.
  87356. * Colors are customizable.
  87357. */
  87358. export class GridMaterial extends BABYLON.PushMaterial {
  87359. /**
  87360. * Main color of the grid (e.g. between lines)
  87361. */
  87362. mainColor: BABYLON.Color3;
  87363. /**
  87364. * Color of the grid lines.
  87365. */
  87366. lineColor: BABYLON.Color3;
  87367. /**
  87368. * The scale of the grid compared to unit.
  87369. */
  87370. gridRatio: number;
  87371. /**
  87372. * Allows setting an offset for the grid lines.
  87373. */
  87374. gridOffset: BABYLON.Vector3;
  87375. /**
  87376. * The frequency of thicker lines.
  87377. */
  87378. majorUnitFrequency: number;
  87379. /**
  87380. * The visibility of minor units in the grid.
  87381. */
  87382. minorUnitVisibility: number;
  87383. /**
  87384. * The grid opacity outside of the lines.
  87385. */
  87386. opacity: number;
  87387. /**
  87388. * Determine RBG output is premultiplied by alpha value.
  87389. */
  87390. preMultiplyAlpha: boolean;
  87391. private _opacityTexture;
  87392. opacityTexture: BABYLON.BaseTexture;
  87393. private _gridControl;
  87394. /**
  87395. * constructor
  87396. * @param name The name given to the material in order to identify it afterwards.
  87397. * @param scene The scene the material is used in.
  87398. */
  87399. constructor(name: string, scene: BABYLON.Scene);
  87400. /**
  87401. * Returns wehter or not the grid requires alpha blending.
  87402. */
  87403. needAlphaBlending(): boolean;
  87404. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  87405. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87406. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87407. /**
  87408. * Dispose the material and its associated resources.
  87409. * @param forceDisposeEffect will also dispose the used effect when true
  87410. */
  87411. dispose(forceDisposeEffect?: boolean): void;
  87412. clone(name: string): GridMaterial;
  87413. serialize(): any;
  87414. getClassName(): string;
  87415. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  87416. }
  87417. }
  87418. declare module BABYLON {
  87419. /** @hidden */
  87420. export var lavaPixelShader: {
  87421. name: string;
  87422. shader: string;
  87423. };
  87424. }
  87425. declare module BABYLON {
  87426. /** @hidden */
  87427. export var lavaVertexShader: {
  87428. name: string;
  87429. shader: string;
  87430. };
  87431. }
  87432. declare module BABYLON {
  87433. export class LavaMaterial extends BABYLON.PushMaterial {
  87434. private _diffuseTexture;
  87435. diffuseTexture: BABYLON.BaseTexture;
  87436. noiseTexture: BABYLON.BaseTexture;
  87437. fogColor: BABYLON.Color3;
  87438. speed: number;
  87439. movingSpeed: number;
  87440. lowFrequencySpeed: number;
  87441. fogDensity: number;
  87442. private _lastTime;
  87443. diffuseColor: BABYLON.Color3;
  87444. private _disableLighting;
  87445. disableLighting: boolean;
  87446. private _unlit;
  87447. unlit: boolean;
  87448. private _maxSimultaneousLights;
  87449. maxSimultaneousLights: number;
  87450. private _scaledDiffuse;
  87451. constructor(name: string, scene: BABYLON.Scene);
  87452. needAlphaBlending(): boolean;
  87453. needAlphaTesting(): boolean;
  87454. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87455. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87456. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87457. getAnimatables(): BABYLON.IAnimatable[];
  87458. getActiveTextures(): BABYLON.BaseTexture[];
  87459. hasTexture(texture: BABYLON.BaseTexture): boolean;
  87460. dispose(forceDisposeEffect?: boolean): void;
  87461. clone(name: string): LavaMaterial;
  87462. serialize(): any;
  87463. getClassName(): string;
  87464. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  87465. }
  87466. }
  87467. declare module BABYLON {
  87468. /** @hidden */
  87469. export var mixPixelShader: {
  87470. name: string;
  87471. shader: string;
  87472. };
  87473. }
  87474. declare module BABYLON {
  87475. /** @hidden */
  87476. export var mixVertexShader: {
  87477. name: string;
  87478. shader: string;
  87479. };
  87480. }
  87481. declare module BABYLON {
  87482. export class MixMaterial extends BABYLON.PushMaterial {
  87483. /**
  87484. * Mix textures
  87485. */
  87486. private _mixTexture1;
  87487. mixTexture1: BABYLON.BaseTexture;
  87488. private _mixTexture2;
  87489. mixTexture2: BABYLON.BaseTexture;
  87490. /**
  87491. * Diffuse textures
  87492. */
  87493. private _diffuseTexture1;
  87494. diffuseTexture1: BABYLON.Texture;
  87495. private _diffuseTexture2;
  87496. diffuseTexture2: BABYLON.Texture;
  87497. private _diffuseTexture3;
  87498. diffuseTexture3: BABYLON.Texture;
  87499. private _diffuseTexture4;
  87500. diffuseTexture4: BABYLON.Texture;
  87501. private _diffuseTexture5;
  87502. diffuseTexture5: BABYLON.Texture;
  87503. private _diffuseTexture6;
  87504. diffuseTexture6: BABYLON.Texture;
  87505. private _diffuseTexture7;
  87506. diffuseTexture7: BABYLON.Texture;
  87507. private _diffuseTexture8;
  87508. diffuseTexture8: BABYLON.Texture;
  87509. /**
  87510. * Uniforms
  87511. */
  87512. diffuseColor: BABYLON.Color3;
  87513. specularColor: BABYLON.Color3;
  87514. specularPower: number;
  87515. private _disableLighting;
  87516. disableLighting: boolean;
  87517. private _maxSimultaneousLights;
  87518. maxSimultaneousLights: number;
  87519. constructor(name: string, scene: BABYLON.Scene);
  87520. needAlphaBlending(): boolean;
  87521. needAlphaTesting(): boolean;
  87522. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87523. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87524. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87525. getAnimatables(): BABYLON.IAnimatable[];
  87526. getActiveTextures(): BABYLON.BaseTexture[];
  87527. hasTexture(texture: BABYLON.BaseTexture): boolean;
  87528. dispose(forceDisposeEffect?: boolean): void;
  87529. clone(name: string): MixMaterial;
  87530. serialize(): any;
  87531. getClassName(): string;
  87532. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  87533. }
  87534. }
  87535. declare module BABYLON {
  87536. /** @hidden */
  87537. export var normalPixelShader: {
  87538. name: string;
  87539. shader: string;
  87540. };
  87541. }
  87542. declare module BABYLON {
  87543. /** @hidden */
  87544. export var normalVertexShader: {
  87545. name: string;
  87546. shader: string;
  87547. };
  87548. }
  87549. declare module BABYLON {
  87550. export class NormalMaterial extends BABYLON.PushMaterial {
  87551. private _diffuseTexture;
  87552. diffuseTexture: BABYLON.BaseTexture;
  87553. diffuseColor: BABYLON.Color3;
  87554. private _disableLighting;
  87555. disableLighting: boolean;
  87556. private _maxSimultaneousLights;
  87557. maxSimultaneousLights: number;
  87558. constructor(name: string, scene: BABYLON.Scene);
  87559. needAlphaBlending(): boolean;
  87560. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  87561. needAlphaTesting(): boolean;
  87562. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87563. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87564. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87565. getAnimatables(): BABYLON.IAnimatable[];
  87566. getActiveTextures(): BABYLON.BaseTexture[];
  87567. hasTexture(texture: BABYLON.BaseTexture): boolean;
  87568. dispose(forceDisposeEffect?: boolean): void;
  87569. clone(name: string): NormalMaterial;
  87570. serialize(): any;
  87571. getClassName(): string;
  87572. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  87573. }
  87574. }
  87575. declare module BABYLON {
  87576. /** @hidden */
  87577. export var shadowOnlyPixelShader: {
  87578. name: string;
  87579. shader: string;
  87580. };
  87581. }
  87582. declare module BABYLON {
  87583. /** @hidden */
  87584. export var shadowOnlyVertexShader: {
  87585. name: string;
  87586. shader: string;
  87587. };
  87588. }
  87589. declare module BABYLON {
  87590. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  87591. private _activeLight;
  87592. private _needAlphaBlending;
  87593. constructor(name: string, scene: BABYLON.Scene);
  87594. shadowColor: BABYLON.Color3;
  87595. needAlphaBlending(): boolean;
  87596. needAlphaTesting(): boolean;
  87597. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87598. get activeLight(): BABYLON.IShadowLight;
  87599. set activeLight(light: BABYLON.IShadowLight);
  87600. private _getFirstShadowLightForMesh;
  87601. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87602. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87603. clone(name: string): ShadowOnlyMaterial;
  87604. serialize(): any;
  87605. getClassName(): string;
  87606. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  87607. }
  87608. }
  87609. declare module BABYLON {
  87610. /** @hidden */
  87611. export var simplePixelShader: {
  87612. name: string;
  87613. shader: string;
  87614. };
  87615. }
  87616. declare module BABYLON {
  87617. /** @hidden */
  87618. export var simpleVertexShader: {
  87619. name: string;
  87620. shader: string;
  87621. };
  87622. }
  87623. declare module BABYLON {
  87624. export class SimpleMaterial extends BABYLON.PushMaterial {
  87625. private _diffuseTexture;
  87626. diffuseTexture: BABYLON.BaseTexture;
  87627. diffuseColor: BABYLON.Color3;
  87628. private _disableLighting;
  87629. disableLighting: boolean;
  87630. private _maxSimultaneousLights;
  87631. maxSimultaneousLights: number;
  87632. constructor(name: string, scene: BABYLON.Scene);
  87633. needAlphaBlending(): boolean;
  87634. needAlphaTesting(): boolean;
  87635. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87636. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87637. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87638. getAnimatables(): BABYLON.IAnimatable[];
  87639. getActiveTextures(): BABYLON.BaseTexture[];
  87640. hasTexture(texture: BABYLON.BaseTexture): boolean;
  87641. dispose(forceDisposeEffect?: boolean): void;
  87642. clone(name: string): SimpleMaterial;
  87643. serialize(): any;
  87644. getClassName(): string;
  87645. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  87646. }
  87647. }
  87648. declare module BABYLON {
  87649. /** @hidden */
  87650. export var skyPixelShader: {
  87651. name: string;
  87652. shader: string;
  87653. };
  87654. }
  87655. declare module BABYLON {
  87656. /** @hidden */
  87657. export var skyVertexShader: {
  87658. name: string;
  87659. shader: string;
  87660. };
  87661. }
  87662. declare module BABYLON {
  87663. /**
  87664. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  87665. * @see https://doc.babylonjs.com/extensions/sky
  87666. */
  87667. export class SkyMaterial extends BABYLON.PushMaterial {
  87668. /**
  87669. * Defines the overall luminance of sky in interval ]0, 1[.
  87670. */
  87671. luminance: number;
  87672. /**
  87673. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  87674. */
  87675. turbidity: number;
  87676. /**
  87677. * Defines the sky appearance (light intensity).
  87678. */
  87679. rayleigh: number;
  87680. /**
  87681. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  87682. */
  87683. mieCoefficient: number;
  87684. /**
  87685. * Defines the amount of haze particles following the Mie scattering theory.
  87686. */
  87687. mieDirectionalG: number;
  87688. /**
  87689. * Defines the distance of the sun according to the active scene camera.
  87690. */
  87691. distance: number;
  87692. /**
  87693. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  87694. * "inclined".
  87695. */
  87696. inclination: number;
  87697. /**
  87698. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  87699. * an object direction and a reference direction.
  87700. */
  87701. azimuth: number;
  87702. /**
  87703. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  87704. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  87705. */
  87706. sunPosition: BABYLON.Vector3;
  87707. /**
  87708. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  87709. * .sunPosition property.
  87710. */
  87711. useSunPosition: boolean;
  87712. /**
  87713. * Defines an offset vector used to get a horizon offset.
  87714. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  87715. */
  87716. cameraOffset: BABYLON.Vector3;
  87717. private _cameraPosition;
  87718. /**
  87719. * Instantiates a new sky material.
  87720. * This material allows to create dynamic and texture free
  87721. * effects for skyboxes by taking care of the atmosphere state.
  87722. * @see https://doc.babylonjs.com/extensions/sky
  87723. * @param name Define the name of the material in the scene
  87724. * @param scene Define the scene the material belong to
  87725. */
  87726. constructor(name: string, scene: BABYLON.Scene);
  87727. /**
  87728. * Specifies if the material will require alpha blending
  87729. * @returns a boolean specifying if alpha blending is needed
  87730. */
  87731. needAlphaBlending(): boolean;
  87732. /**
  87733. * Specifies if this material should be rendered in alpha test mode
  87734. * @returns false as the sky material doesn't need alpha testing.
  87735. */
  87736. needAlphaTesting(): boolean;
  87737. /**
  87738. * Get the texture used for alpha test purpose.
  87739. * @returns null as the sky material has no texture.
  87740. */
  87741. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87742. /**
  87743. * Get if the submesh is ready to be used and all its information available.
  87744. * Child classes can use it to update shaders
  87745. * @param mesh defines the mesh to check
  87746. * @param subMesh defines which submesh to check
  87747. * @param useInstances specifies that instances should be used
  87748. * @returns a boolean indicating that the submesh is ready or not
  87749. */
  87750. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87751. /**
  87752. * Binds the submesh to this material by preparing the effect and shader to draw
  87753. * @param world defines the world transformation matrix
  87754. * @param mesh defines the mesh containing the submesh
  87755. * @param subMesh defines the submesh to bind the material to
  87756. */
  87757. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87758. /**
  87759. * Get the list of animatables in the material.
  87760. * @returns the list of animatables object used in the material
  87761. */
  87762. getAnimatables(): BABYLON.IAnimatable[];
  87763. /**
  87764. * Disposes the material
  87765. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  87766. */
  87767. dispose(forceDisposeEffect?: boolean): void;
  87768. /**
  87769. * Makes a duplicate of the material, and gives it a new name
  87770. * @param name defines the new name for the duplicated material
  87771. * @returns the cloned material
  87772. */
  87773. clone(name: string): SkyMaterial;
  87774. /**
  87775. * Serializes this material in a JSON representation
  87776. * @returns the serialized material object
  87777. */
  87778. serialize(): any;
  87779. /**
  87780. * Gets the current class name of the material e.g. "SkyMaterial"
  87781. * Mainly use in serialization.
  87782. * @returns the class name
  87783. */
  87784. getClassName(): string;
  87785. /**
  87786. * Creates a sky material from parsed material data
  87787. * @param source defines the JSON representation of the material
  87788. * @param scene defines the hosting scene
  87789. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  87790. * @returns a new sky material
  87791. */
  87792. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  87793. }
  87794. }
  87795. declare module BABYLON {
  87796. /** @hidden */
  87797. export var terrainPixelShader: {
  87798. name: string;
  87799. shader: string;
  87800. };
  87801. }
  87802. declare module BABYLON {
  87803. /** @hidden */
  87804. export var terrainVertexShader: {
  87805. name: string;
  87806. shader: string;
  87807. };
  87808. }
  87809. declare module BABYLON {
  87810. export class TerrainMaterial extends BABYLON.PushMaterial {
  87811. private _mixTexture;
  87812. mixTexture: BABYLON.BaseTexture;
  87813. private _diffuseTexture1;
  87814. diffuseTexture1: BABYLON.Texture;
  87815. private _diffuseTexture2;
  87816. diffuseTexture2: BABYLON.Texture;
  87817. private _diffuseTexture3;
  87818. diffuseTexture3: BABYLON.Texture;
  87819. private _bumpTexture1;
  87820. bumpTexture1: BABYLON.Texture;
  87821. private _bumpTexture2;
  87822. bumpTexture2: BABYLON.Texture;
  87823. private _bumpTexture3;
  87824. bumpTexture3: BABYLON.Texture;
  87825. diffuseColor: BABYLON.Color3;
  87826. specularColor: BABYLON.Color3;
  87827. specularPower: number;
  87828. private _disableLighting;
  87829. disableLighting: boolean;
  87830. private _maxSimultaneousLights;
  87831. maxSimultaneousLights: number;
  87832. constructor(name: string, scene: BABYLON.Scene);
  87833. needAlphaBlending(): boolean;
  87834. needAlphaTesting(): boolean;
  87835. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87836. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87837. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87838. getAnimatables(): BABYLON.IAnimatable[];
  87839. getActiveTextures(): BABYLON.BaseTexture[];
  87840. hasTexture(texture: BABYLON.BaseTexture): boolean;
  87841. dispose(forceDisposeEffect?: boolean): void;
  87842. clone(name: string): TerrainMaterial;
  87843. serialize(): any;
  87844. getClassName(): string;
  87845. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  87846. }
  87847. }
  87848. declare module BABYLON {
  87849. /** @hidden */
  87850. export var triplanarPixelShader: {
  87851. name: string;
  87852. shader: string;
  87853. };
  87854. }
  87855. declare module BABYLON {
  87856. /** @hidden */
  87857. export var triplanarVertexShader: {
  87858. name: string;
  87859. shader: string;
  87860. };
  87861. }
  87862. declare module BABYLON {
  87863. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  87864. mixTexture: BABYLON.BaseTexture;
  87865. private _diffuseTextureX;
  87866. diffuseTextureX: BABYLON.BaseTexture;
  87867. private _diffuseTextureY;
  87868. diffuseTextureY: BABYLON.BaseTexture;
  87869. private _diffuseTextureZ;
  87870. diffuseTextureZ: BABYLON.BaseTexture;
  87871. private _normalTextureX;
  87872. normalTextureX: BABYLON.BaseTexture;
  87873. private _normalTextureY;
  87874. normalTextureY: BABYLON.BaseTexture;
  87875. private _normalTextureZ;
  87876. normalTextureZ: BABYLON.BaseTexture;
  87877. tileSize: number;
  87878. diffuseColor: BABYLON.Color3;
  87879. specularColor: BABYLON.Color3;
  87880. specularPower: number;
  87881. private _disableLighting;
  87882. disableLighting: boolean;
  87883. private _maxSimultaneousLights;
  87884. maxSimultaneousLights: number;
  87885. constructor(name: string, scene: BABYLON.Scene);
  87886. needAlphaBlending(): boolean;
  87887. needAlphaTesting(): boolean;
  87888. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87889. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87890. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87891. getAnimatables(): BABYLON.IAnimatable[];
  87892. getActiveTextures(): BABYLON.BaseTexture[];
  87893. hasTexture(texture: BABYLON.BaseTexture): boolean;
  87894. dispose(forceDisposeEffect?: boolean): void;
  87895. clone(name: string): TriPlanarMaterial;
  87896. serialize(): any;
  87897. getClassName(): string;
  87898. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  87899. }
  87900. }
  87901. declare module BABYLON {
  87902. /** @hidden */
  87903. export var waterPixelShader: {
  87904. name: string;
  87905. shader: string;
  87906. };
  87907. }
  87908. declare module BABYLON {
  87909. /** @hidden */
  87910. export var waterVertexShader: {
  87911. name: string;
  87912. shader: string;
  87913. };
  87914. }
  87915. declare module BABYLON {
  87916. export class WaterMaterial extends BABYLON.PushMaterial {
  87917. renderTargetSize: BABYLON.Vector2;
  87918. private _bumpTexture;
  87919. bumpTexture: BABYLON.BaseTexture;
  87920. diffuseColor: BABYLON.Color3;
  87921. specularColor: BABYLON.Color3;
  87922. specularPower: number;
  87923. private _disableLighting;
  87924. disableLighting: boolean;
  87925. private _maxSimultaneousLights;
  87926. maxSimultaneousLights: number;
  87927. /**
  87928. * Defines the wind force.
  87929. */
  87930. windForce: number;
  87931. /**
  87932. * Defines the direction of the wind in the plane (X, Z).
  87933. */
  87934. windDirection: BABYLON.Vector2;
  87935. /**
  87936. * Defines the height of the waves.
  87937. */
  87938. waveHeight: number;
  87939. /**
  87940. * Defines the bump height related to the bump map.
  87941. */
  87942. bumpHeight: number;
  87943. /**
  87944. * Defines wether or not: to add a smaller moving bump to less steady waves.
  87945. */
  87946. private _bumpSuperimpose;
  87947. bumpSuperimpose: boolean;
  87948. /**
  87949. * Defines wether or not color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  87950. */
  87951. private _fresnelSeparate;
  87952. fresnelSeparate: boolean;
  87953. /**
  87954. * Defines wether or not bump Wwves modify the reflection.
  87955. */
  87956. private _bumpAffectsReflection;
  87957. bumpAffectsReflection: boolean;
  87958. /**
  87959. * Defines the water color blended with the refraction (near).
  87960. */
  87961. waterColor: BABYLON.Color3;
  87962. /**
  87963. * Defines the blend factor related to the water color.
  87964. */
  87965. colorBlendFactor: number;
  87966. /**
  87967. * Defines the water color blended with the reflection (far).
  87968. */
  87969. waterColor2: BABYLON.Color3;
  87970. /**
  87971. * Defines the blend factor related to the water color (reflection, far).
  87972. */
  87973. colorBlendFactor2: number;
  87974. /**
  87975. * Defines the maximum length of a wave.
  87976. */
  87977. waveLength: number;
  87978. /**
  87979. * Defines the waves speed.
  87980. */
  87981. waveSpeed: number;
  87982. /**
  87983. * 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.
  87984. */
  87985. waveCount: number;
  87986. /**
  87987. * Sets or gets whether or not automatic clipping should be enabled or not. Setting to true will save performances and
  87988. * will avoid calculating useless pixels in the pixel shader of the water material.
  87989. */
  87990. disableClipPlane: boolean;
  87991. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  87992. private _mesh;
  87993. private _refractionRTT;
  87994. private _reflectionRTT;
  87995. private _reflectionTransform;
  87996. private _lastTime;
  87997. private _lastDeltaTime;
  87998. private _useLogarithmicDepth;
  87999. private _waitingRenderList;
  88000. private _imageProcessingConfiguration;
  88001. private _imageProcessingObserver;
  88002. /**
  88003. * Gets a boolean indicating that current material needs to register RTT
  88004. */
  88005. get hasRenderTargetTextures(): boolean;
  88006. /**
  88007. * Constructor
  88008. */
  88009. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  88010. get useLogarithmicDepth(): boolean;
  88011. set useLogarithmicDepth(value: boolean);
  88012. get refractionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  88013. get reflectionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  88014. addToRenderList(node: any): void;
  88015. enableRenderTargets(enable: boolean): void;
  88016. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  88017. get renderTargetsEnabled(): boolean;
  88018. needAlphaBlending(): boolean;
  88019. needAlphaTesting(): boolean;
  88020. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  88021. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  88022. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  88023. private _createRenderTargets;
  88024. getAnimatables(): BABYLON.IAnimatable[];
  88025. getActiveTextures(): BABYLON.BaseTexture[];
  88026. hasTexture(texture: BABYLON.BaseTexture): boolean;
  88027. dispose(forceDisposeEffect?: boolean): void;
  88028. clone(name: string): WaterMaterial;
  88029. serialize(): any;
  88030. getClassName(): string;
  88031. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  88032. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  88033. }
  88034. }
  88035. declare module BABYLON {
  88036. /** @hidden */
  88037. export var asciiartPixelShader: {
  88038. name: string;
  88039. shader: string;
  88040. };
  88041. }
  88042. declare module BABYLON {
  88043. /**
  88044. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  88045. *
  88046. * It basically takes care rendering the font front the given font size to a texture.
  88047. * This is used later on in the postprocess.
  88048. */
  88049. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  88050. private _font;
  88051. private _text;
  88052. private _charSize;
  88053. /**
  88054. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  88055. */
  88056. get charSize(): number;
  88057. /**
  88058. * Create a new instance of the Ascii Art FontTexture class
  88059. * @param name the name of the texture
  88060. * @param font the font to use, use the W3C CSS notation
  88061. * @param text the caracter set to use in the rendering.
  88062. * @param scene the scene that owns the texture
  88063. */
  88064. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  88065. /**
  88066. * Gets the max char width of a font.
  88067. * @param font the font to use, use the W3C CSS notation
  88068. * @return the max char width
  88069. */
  88070. private getFontWidth;
  88071. /**
  88072. * Gets the max char height of a font.
  88073. * @param font the font to use, use the W3C CSS notation
  88074. * @return the max char height
  88075. */
  88076. private getFontHeight;
  88077. /**
  88078. * Clones the current AsciiArtTexture.
  88079. * @return the clone of the texture.
  88080. */
  88081. clone(): AsciiArtFontTexture;
  88082. /**
  88083. * Parses a json object representing the texture and returns an instance of it.
  88084. * @param source the source JSON representation
  88085. * @param scene the scene to create the texture for
  88086. * @return the parsed texture
  88087. */
  88088. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  88089. }
  88090. /**
  88091. * Option available in the Ascii Art Post Process.
  88092. */
  88093. export interface IAsciiArtPostProcessOptions {
  88094. /**
  88095. * The font to use following the w3c font definition.
  88096. */
  88097. font?: string;
  88098. /**
  88099. * The character set to use in the postprocess.
  88100. */
  88101. characterSet?: string;
  88102. /**
  88103. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  88104. * This number is defined between 0 and 1;
  88105. */
  88106. mixToTile?: number;
  88107. /**
  88108. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  88109. * This number is defined between 0 and 1;
  88110. */
  88111. mixToNormal?: number;
  88112. }
  88113. /**
  88114. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  88115. *
  88116. * Simmply add it to your scene and let the nerd that lives in you have fun.
  88117. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  88118. */
  88119. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  88120. /**
  88121. * The font texture used to render the char in the post process.
  88122. */
  88123. private _asciiArtFontTexture;
  88124. /**
  88125. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  88126. * This number is defined between 0 and 1;
  88127. */
  88128. mixToTile: number;
  88129. /**
  88130. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  88131. * This number is defined between 0 and 1;
  88132. */
  88133. mixToNormal: number;
  88134. /**
  88135. * Instantiates a new Ascii Art Post Process.
  88136. * @param name the name to give to the postprocess
  88137. * @camera the camera to apply the post process to.
  88138. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  88139. */
  88140. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  88141. }
  88142. }
  88143. declare module BABYLON {
  88144. /** @hidden */
  88145. export var digitalrainPixelShader: {
  88146. name: string;
  88147. shader: string;
  88148. };
  88149. }
  88150. declare module BABYLON {
  88151. /**
  88152. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  88153. *
  88154. * It basically takes care rendering the font front the given font size to a texture.
  88155. * This is used later on in the postprocess.
  88156. */
  88157. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  88158. private _font;
  88159. private _text;
  88160. private _charSize;
  88161. /**
  88162. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  88163. */
  88164. get charSize(): number;
  88165. /**
  88166. * Create a new instance of the Digital Rain FontTexture class
  88167. * @param name the name of the texture
  88168. * @param font the font to use, use the W3C CSS notation
  88169. * @param text the caracter set to use in the rendering.
  88170. * @param scene the scene that owns the texture
  88171. */
  88172. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  88173. /**
  88174. * Gets the max char width of a font.
  88175. * @param font the font to use, use the W3C CSS notation
  88176. * @return the max char width
  88177. */
  88178. private getFontWidth;
  88179. /**
  88180. * Gets the max char height of a font.
  88181. * @param font the font to use, use the W3C CSS notation
  88182. * @return the max char height
  88183. */
  88184. private getFontHeight;
  88185. /**
  88186. * Clones the current DigitalRainFontTexture.
  88187. * @return the clone of the texture.
  88188. */
  88189. clone(): DigitalRainFontTexture;
  88190. /**
  88191. * Parses a json object representing the texture and returns an instance of it.
  88192. * @param source the source JSON representation
  88193. * @param scene the scene to create the texture for
  88194. * @return the parsed texture
  88195. */
  88196. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  88197. }
  88198. /**
  88199. * Option available in the Digital Rain Post Process.
  88200. */
  88201. export interface IDigitalRainPostProcessOptions {
  88202. /**
  88203. * The font to use following the w3c font definition.
  88204. */
  88205. font?: string;
  88206. /**
  88207. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  88208. * This number is defined between 0 and 1;
  88209. */
  88210. mixToTile?: number;
  88211. /**
  88212. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  88213. * This number is defined between 0 and 1;
  88214. */
  88215. mixToNormal?: number;
  88216. }
  88217. /**
  88218. * DigitalRainPostProcess helps rendering everithing in digital rain.
  88219. *
  88220. * Simmply add it to your scene and let the nerd that lives in you have fun.
  88221. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  88222. */
  88223. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  88224. /**
  88225. * The font texture used to render the char in the post process.
  88226. */
  88227. private _digitalRainFontTexture;
  88228. /**
  88229. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  88230. * This number is defined between 0 and 1;
  88231. */
  88232. mixToTile: number;
  88233. /**
  88234. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  88235. * This number is defined between 0 and 1;
  88236. */
  88237. mixToNormal: number;
  88238. /**
  88239. * Instantiates a new Digital Rain Post Process.
  88240. * @param name the name to give to the postprocess
  88241. * @camera the camera to apply the post process to.
  88242. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  88243. */
  88244. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  88245. }
  88246. }
  88247. declare module BABYLON {
  88248. /** @hidden */
  88249. export var brickProceduralTexturePixelShader: {
  88250. name: string;
  88251. shader: string;
  88252. };
  88253. }
  88254. declare module BABYLON {
  88255. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  88256. private _numberOfBricksHeight;
  88257. private _numberOfBricksWidth;
  88258. private _jointColor;
  88259. private _brickColor;
  88260. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  88261. updateShaderUniforms(): void;
  88262. get numberOfBricksHeight(): number;
  88263. set numberOfBricksHeight(value: number);
  88264. get numberOfBricksWidth(): number;
  88265. set numberOfBricksWidth(value: number);
  88266. get jointColor(): BABYLON.Color3;
  88267. set jointColor(value: BABYLON.Color3);
  88268. get brickColor(): BABYLON.Color3;
  88269. set brickColor(value: BABYLON.Color3);
  88270. /**
  88271. * Serializes this brick procedural texture
  88272. * @returns a serialized brick procedural texture object
  88273. */
  88274. serialize(): any;
  88275. /**
  88276. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  88277. * @param parsedTexture defines parsed texture data
  88278. * @param scene defines the current scene
  88279. * @param rootUrl defines the root URL containing brick procedural texture information
  88280. * @returns a parsed Brick Procedural BABYLON.Texture
  88281. */
  88282. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  88283. }
  88284. }
  88285. declare module BABYLON {
  88286. /** @hidden */
  88287. export var cloudProceduralTexturePixelShader: {
  88288. name: string;
  88289. shader: string;
  88290. };
  88291. }
  88292. declare module BABYLON {
  88293. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  88294. private _skyColor;
  88295. private _cloudColor;
  88296. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  88297. updateShaderUniforms(): void;
  88298. get skyColor(): BABYLON.Color4;
  88299. set skyColor(value: BABYLON.Color4);
  88300. get cloudColor(): BABYLON.Color4;
  88301. set cloudColor(value: BABYLON.Color4);
  88302. /**
  88303. * Serializes this cloud procedural texture
  88304. * @returns a serialized cloud procedural texture object
  88305. */
  88306. serialize(): any;
  88307. /**
  88308. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  88309. * @param parsedTexture defines parsed texture data
  88310. * @param scene defines the current scene
  88311. * @param rootUrl defines the root URL containing cloud procedural texture information
  88312. * @returns a parsed Cloud Procedural BABYLON.Texture
  88313. */
  88314. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  88315. }
  88316. }
  88317. declare module BABYLON {
  88318. /** @hidden */
  88319. export var fireProceduralTexturePixelShader: {
  88320. name: string;
  88321. shader: string;
  88322. };
  88323. }
  88324. declare module BABYLON {
  88325. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  88326. private _time;
  88327. private _speed;
  88328. private _autoGenerateTime;
  88329. private _fireColors;
  88330. private _alphaThreshold;
  88331. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  88332. updateShaderUniforms(): void;
  88333. render(useCameraPostProcess?: boolean): void;
  88334. static get PurpleFireColors(): BABYLON.Color3[];
  88335. static get GreenFireColors(): BABYLON.Color3[];
  88336. static get RedFireColors(): BABYLON.Color3[];
  88337. static get BlueFireColors(): BABYLON.Color3[];
  88338. get autoGenerateTime(): boolean;
  88339. set autoGenerateTime(value: boolean);
  88340. get fireColors(): BABYLON.Color3[];
  88341. set fireColors(value: BABYLON.Color3[]);
  88342. get time(): number;
  88343. set time(value: number);
  88344. get speed(): BABYLON.Vector2;
  88345. set speed(value: BABYLON.Vector2);
  88346. get alphaThreshold(): number;
  88347. set alphaThreshold(value: number);
  88348. /**
  88349. * Serializes this fire procedural texture
  88350. * @returns a serialized fire procedural texture object
  88351. */
  88352. serialize(): any;
  88353. /**
  88354. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  88355. * @param parsedTexture defines parsed texture data
  88356. * @param scene defines the current scene
  88357. * @param rootUrl defines the root URL containing fire procedural texture information
  88358. * @returns a parsed Fire Procedural BABYLON.Texture
  88359. */
  88360. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  88361. }
  88362. }
  88363. declare module BABYLON {
  88364. /** @hidden */
  88365. export var grassProceduralTexturePixelShader: {
  88366. name: string;
  88367. shader: string;
  88368. };
  88369. }
  88370. declare module BABYLON {
  88371. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  88372. private _grassColors;
  88373. private _groundColor;
  88374. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  88375. updateShaderUniforms(): void;
  88376. get grassColors(): BABYLON.Color3[];
  88377. set grassColors(value: BABYLON.Color3[]);
  88378. get groundColor(): BABYLON.Color3;
  88379. set groundColor(value: BABYLON.Color3);
  88380. /**
  88381. * Serializes this grass procedural texture
  88382. * @returns a serialized grass procedural texture object
  88383. */
  88384. serialize(): any;
  88385. /**
  88386. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  88387. * @param parsedTexture defines parsed texture data
  88388. * @param scene defines the current scene
  88389. * @param rootUrl defines the root URL containing grass procedural texture information
  88390. * @returns a parsed Grass Procedural BABYLON.Texture
  88391. */
  88392. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  88393. }
  88394. }
  88395. declare module BABYLON {
  88396. /** @hidden */
  88397. export var marbleProceduralTexturePixelShader: {
  88398. name: string;
  88399. shader: string;
  88400. };
  88401. }
  88402. declare module BABYLON {
  88403. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  88404. private _numberOfTilesHeight;
  88405. private _numberOfTilesWidth;
  88406. private _amplitude;
  88407. private _jointColor;
  88408. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  88409. updateShaderUniforms(): void;
  88410. get numberOfTilesHeight(): number;
  88411. set numberOfTilesHeight(value: number);
  88412. get amplitude(): number;
  88413. set amplitude(value: number);
  88414. get numberOfTilesWidth(): number;
  88415. set numberOfTilesWidth(value: number);
  88416. get jointColor(): BABYLON.Color3;
  88417. set jointColor(value: BABYLON.Color3);
  88418. /**
  88419. * Serializes this marble procedural texture
  88420. * @returns a serialized marble procedural texture object
  88421. */
  88422. serialize(): any;
  88423. /**
  88424. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  88425. * @param parsedTexture defines parsed texture data
  88426. * @param scene defines the current scene
  88427. * @param rootUrl defines the root URL containing marble procedural texture information
  88428. * @returns a parsed Marble Procedural BABYLON.Texture
  88429. */
  88430. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  88431. }
  88432. }
  88433. declare module BABYLON {
  88434. /** @hidden */
  88435. export var normalMapProceduralTexturePixelShader: {
  88436. name: string;
  88437. shader: string;
  88438. };
  88439. }
  88440. declare module BABYLON {
  88441. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  88442. private _baseTexture;
  88443. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  88444. updateShaderUniforms(): void;
  88445. render(useCameraPostProcess?: boolean): void;
  88446. resize(size: any, generateMipMaps: any): void;
  88447. get baseTexture(): BABYLON.Texture;
  88448. set baseTexture(texture: BABYLON.Texture);
  88449. /**
  88450. * Serializes this normal map procedural texture
  88451. * @returns a serialized normal map procedural texture object
  88452. */
  88453. serialize(): any;
  88454. /**
  88455. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  88456. * @param parsedTexture defines parsed texture data
  88457. * @param scene defines the current scene
  88458. * @param rootUrl defines the root URL containing normal map procedural texture information
  88459. * @returns a parsed Normal Map Procedural BABYLON.Texture
  88460. */
  88461. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  88462. }
  88463. }
  88464. declare module BABYLON {
  88465. /** @hidden */
  88466. export var perlinNoiseProceduralTexturePixelShader: {
  88467. name: string;
  88468. shader: string;
  88469. };
  88470. }
  88471. declare module BABYLON {
  88472. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  88473. time: number;
  88474. timeScale: number;
  88475. translationSpeed: number;
  88476. private _currentTranslation;
  88477. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  88478. updateShaderUniforms(): void;
  88479. render(useCameraPostProcess?: boolean): void;
  88480. resize(size: any, generateMipMaps: any): void;
  88481. /**
  88482. * Serializes this perlin noise procedural texture
  88483. * @returns a serialized perlin noise procedural texture object
  88484. */
  88485. serialize(): any;
  88486. /**
  88487. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  88488. * @param parsedTexture defines parsed texture data
  88489. * @param scene defines the current scene
  88490. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  88491. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  88492. */
  88493. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  88494. }
  88495. }
  88496. declare module BABYLON {
  88497. /** @hidden */
  88498. export var roadProceduralTexturePixelShader: {
  88499. name: string;
  88500. shader: string;
  88501. };
  88502. }
  88503. declare module BABYLON {
  88504. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  88505. private _roadColor;
  88506. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  88507. updateShaderUniforms(): void;
  88508. get roadColor(): BABYLON.Color3;
  88509. set roadColor(value: BABYLON.Color3);
  88510. /**
  88511. * Serializes this road procedural texture
  88512. * @returns a serialized road procedural texture object
  88513. */
  88514. serialize(): any;
  88515. /**
  88516. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  88517. * @param parsedTexture defines parsed texture data
  88518. * @param scene defines the current scene
  88519. * @param rootUrl defines the root URL containing road procedural texture information
  88520. * @returns a parsed Road Procedural BABYLON.Texture
  88521. */
  88522. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  88523. }
  88524. }
  88525. declare module BABYLON {
  88526. /** @hidden */
  88527. export var starfieldProceduralTexturePixelShader: {
  88528. name: string;
  88529. shader: string;
  88530. };
  88531. }
  88532. declare module BABYLON {
  88533. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  88534. private _time;
  88535. private _alpha;
  88536. private _beta;
  88537. private _zoom;
  88538. private _formuparam;
  88539. private _stepsize;
  88540. private _tile;
  88541. private _brightness;
  88542. private _darkmatter;
  88543. private _distfading;
  88544. private _saturation;
  88545. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  88546. updateShaderUniforms(): void;
  88547. get time(): number;
  88548. set time(value: number);
  88549. get alpha(): number;
  88550. set alpha(value: number);
  88551. get beta(): number;
  88552. set beta(value: number);
  88553. get formuparam(): number;
  88554. set formuparam(value: number);
  88555. get stepsize(): number;
  88556. set stepsize(value: number);
  88557. get zoom(): number;
  88558. set zoom(value: number);
  88559. get tile(): number;
  88560. set tile(value: number);
  88561. get brightness(): number;
  88562. set brightness(value: number);
  88563. get darkmatter(): number;
  88564. set darkmatter(value: number);
  88565. get distfading(): number;
  88566. set distfading(value: number);
  88567. get saturation(): number;
  88568. set saturation(value: number);
  88569. /**
  88570. * Serializes this starfield procedural texture
  88571. * @returns a serialized starfield procedural texture object
  88572. */
  88573. serialize(): any;
  88574. /**
  88575. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  88576. * @param parsedTexture defines parsed texture data
  88577. * @param scene defines the current scene
  88578. * @param rootUrl defines the root URL containing startfield procedural texture information
  88579. * @returns a parsed Starfield Procedural BABYLON.Texture
  88580. */
  88581. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  88582. }
  88583. }
  88584. declare module BABYLON {
  88585. /** @hidden */
  88586. export var woodProceduralTexturePixelShader: {
  88587. name: string;
  88588. shader: string;
  88589. };
  88590. }
  88591. declare module BABYLON {
  88592. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  88593. private _ampScale;
  88594. private _woodColor;
  88595. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  88596. updateShaderUniforms(): void;
  88597. get ampScale(): number;
  88598. set ampScale(value: number);
  88599. get woodColor(): BABYLON.Color3;
  88600. set woodColor(value: BABYLON.Color3);
  88601. /**
  88602. * Serializes this wood procedural texture
  88603. * @returns a serialized wood procedural texture object
  88604. */
  88605. serialize(): any;
  88606. /**
  88607. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  88608. * @param parsedTexture defines parsed texture data
  88609. * @param scene defines the current scene
  88610. * @param rootUrl defines the root URL containing wood procedural texture information
  88611. * @returns a parsed Wood Procedural BABYLON.Texture
  88612. */
  88613. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  88614. }
  88615. }