documentation.d.ts 3.9 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549325503255132552325533255432555325563255732558325593256032561325623256332564325653256632567325683256932570325713257232573325743257532576325773257832579325803258132582325833258432585325863258732588325893259032591325923259332594325953259632597325983259932600326013260232603326043260532606326073260832609326103261132612326133261432615326163261732618326193262032621326223262332624326253262632627326283262932630326313263232633326343263532636326373263832639326403264132642326433264432645326463264732648326493265032651326523265332654326553265632657326583265932660326613266232663326643266532666326673266832669326703267132672326733267432675326763267732678326793268032681326823268332684326853268632687326883268932690326913269232693326943269532696326973269832699327003270132702327033270432705327063270732708327093271032711327123271332714327153271632717327183271932720327213272232723327243272532726327273272832729327303273132732327333273432735327363273732738327393274032741327423274332744327453274632747327483274932750327513275232753327543275532756327573275832759327603276132762327633276432765327663276732768327693277032771327723277332774327753277632777327783277932780327813278232783327843278532786327873278832789327903279132792327933279432795327963279732798327993280032801328023280332804328053280632807328083280932810328113281232813328143281532816328173281832819328203282132822328233282432825328263282732828328293283032831328323283332834328353283632837328383283932840328413284232843328443284532846328473284832849328503285132852328533285432855328563285732858328593286032861328623286332864328653286632867328683286932870328713287232873328743287532876328773287832879328803288132882328833288432885328863288732888328893289032891328923289332894328953289632897328983289932900329013290232903329043290532906329073290832909329103291132912329133291432915329163291732918329193292032921329223292332924329253292632927329283292932930329313293232933329343293532936329373293832939329403294132942329433294432945329463294732948329493295032951329523295332954329553295632957329583295932960329613296232963329643296532966329673296832969329703297132972329733297432975329763297732978329793298032981329823298332984329853298632987329883298932990329913299232993329943299532996329973299832999330003300133002330033300433005330063300733008330093301033011330123301333014330153301633017330183301933020330213302233023330243302533026330273302833029330303303133032330333303433035330363303733038330393304033041330423304333044330453304633047330483304933050330513305233053330543305533056330573305833059330603306133062330633306433065330663306733068330693307033071330723307333074330753307633077330783307933080330813308233083330843308533086330873308833089330903309133092330933309433095330963309733098330993310033101331023310333104331053310633107331083310933110331113311233113331143311533116331173311833119331203312133122331233312433125331263312733128331293313033131331323313333134331353313633137331383313933140331413314233143331443314533146331473314833149331503315133152331533315433155331563315733158331593316033161331623316333164331653316633167331683316933170331713317233173331743317533176331773317833179331803318133182331833318433185331863318733188331893319033191331923319333194331953319633197331983319933200332013320233203332043320533206332073320833209332103321133212332133321433215332163321733218332193322033221332223322333224332253322633227332283322933230332313323233233332343323533236332373323833239332403324133242332433324433245332463324733248332493325033251332523325333254332553325633257332583325933260332613326233263332643326533266332673326833269332703327133272332733327433275332763327733278332793328033281332823328333284332853328633287332883328933290332913329233293332943329533296332973329833299333003330133302333033330433305333063330733308333093331033311333123331333314333153331633317333183331933320333213332233323333243332533326333273332833329333303333133332333333333433335333363333733338333393334033341333423334333344333453334633347333483334933350333513335233353333543335533356333573335833359333603336133362333633336433365333663336733368333693337033371333723337333374333753337633377333783337933380333813338233383333843338533386333873338833389333903339133392333933339433395333963339733398333993340033401334023340333404334053340633407334083340933410334113341233413334143341533416334173341833419334203342133422334233342433425334263342733428334293343033431334323343333434334353343633437334383343933440334413344233443334443344533446334473344833449334503345133452334533345433455334563345733458334593346033461334623346333464334653346633467334683346933470334713347233473334743347533476334773347833479334803348133482334833348433485334863348733488334893349033491334923349333494334953349633497334983349933500335013350233503335043350533506335073350833509335103351133512335133351433515335163351733518335193352033521335223352333524335253352633527335283352933530335313353233533335343353533536335373353833539335403354133542335433354433545335463354733548335493355033551335523355333554335553355633557335583355933560335613356233563335643356533566335673356833569335703357133572335733357433575335763357733578335793358033581335823358333584335853358633587335883358933590335913359233593335943359533596335973359833599336003360133602336033360433605336063360733608336093361033611336123361333614336153361633617336183361933620336213362233623336243362533626336273362833629336303363133632336333363433635336363363733638336393364033641336423364333644336453364633647336483364933650336513365233653336543365533656336573365833659336603366133662336633366433665336663366733668336693367033671336723367333674336753367633677336783367933680336813368233683336843368533686336873368833689336903369133692336933369433695336963369733698336993370033701337023370333704337053370633707337083370933710337113371233713337143371533716337173371833719337203372133722337233372433725337263372733728337293373033731337323373333734337353373633737337383373933740337413374233743337443374533746337473374833749337503375133752337533375433755337563375733758337593376033761337623376333764337653376633767337683376933770337713377233773337743377533776337773377833779337803378133782337833378433785337863378733788337893379033791337923379333794337953379633797337983379933800338013380233803338043380533806338073380833809338103381133812338133381433815338163381733818338193382033821338223382333824338253382633827338283382933830338313383233833338343383533836338373383833839338403384133842338433384433845338463384733848338493385033851338523385333854338553385633857338583385933860338613386233863338643386533866338673386833869338703387133872338733387433875338763387733878338793388033881338823388333884338853388633887338883388933890338913389233893338943389533896338973389833899339003390133902339033390433905339063390733908339093391033911339123391333914339153391633917339183391933920339213392233923339243392533926339273392833929339303393133932339333393433935339363393733938339393394033941339423394333944339453394633947339483394933950339513395233953339543395533956339573395833959339603396133962339633396433965339663396733968339693397033971339723397333974339753397633977339783397933980339813398233983339843398533986339873398833989339903399133992339933399433995339963399733998339993400034001340023400334004340053400634007340083400934010340113401234013340143401534016340173401834019340203402134022340233402434025340263402734028340293403034031340323403334034340353403634037340383403934040340413404234043340443404534046340473404834049340503405134052340533405434055340563405734058340593406034061340623406334064340653406634067340683406934070340713407234073340743407534076340773407834079340803408134082340833408434085340863408734088340893409034091340923409334094340953409634097340983409934100341013410234103341043410534106341073410834109341103411134112341133411434115341163411734118341193412034121341223412334124341253412634127341283412934130341313413234133341343413534136341373413834139341403414134142341433414434145341463414734148341493415034151341523415334154341553415634157341583415934160341613416234163341643416534166341673416834169341703417134172341733417434175341763417734178341793418034181341823418334184341853418634187341883418934190341913419234193341943419534196341973419834199342003420134202342033420434205342063420734208342093421034211342123421334214342153421634217342183421934220342213422234223342243422534226342273422834229342303423134232342333423434235342363423734238342393424034241342423424334244342453424634247342483424934250342513425234253342543425534256342573425834259342603426134262342633426434265342663426734268342693427034271342723427334274342753427634277342783427934280342813428234283342843428534286342873428834289342903429134292342933429434295342963429734298342993430034301343023430334304343053430634307343083430934310343113431234313343143431534316343173431834319343203432134322343233432434325343263432734328343293433034331343323433334334343353433634337343383433934340343413434234343343443434534346343473434834349343503435134352343533435434355343563435734358343593436034361343623436334364343653436634367343683436934370343713437234373343743437534376343773437834379343803438134382343833438434385343863438734388343893439034391343923439334394343953439634397343983439934400344013440234403344043440534406344073440834409344103441134412344133441434415344163441734418344193442034421344223442334424344253442634427344283442934430344313443234433344343443534436344373443834439344403444134442344433444434445344463444734448344493445034451344523445334454344553445634457344583445934460344613446234463344643446534466344673446834469344703447134472344733447434475344763447734478344793448034481344823448334484344853448634487344883448934490344913449234493344943449534496344973449834499345003450134502345033450434505345063450734508345093451034511345123451334514345153451634517345183451934520345213452234523345243452534526345273452834529345303453134532345333453434535345363453734538345393454034541345423454334544345453454634547345483454934550345513455234553345543455534556345573455834559345603456134562345633456434565345663456734568345693457034571345723457334574345753457634577345783457934580345813458234583345843458534586345873458834589345903459134592345933459434595345963459734598345993460034601346023460334604346053460634607346083460934610346113461234613346143461534616346173461834619346203462134622346233462434625346263462734628346293463034631346323463334634346353463634637346383463934640346413464234643346443464534646346473464834649346503465134652346533465434655346563465734658346593466034661346623466334664346653466634667346683466934670346713467234673346743467534676346773467834679346803468134682346833468434685346863468734688346893469034691346923469334694346953469634697346983469934700347013470234703347043470534706347073470834709347103471134712347133471434715347163471734718347193472034721347223472334724347253472634727347283472934730347313473234733347343473534736347373473834739347403474134742347433474434745347463474734748347493475034751347523475334754347553475634757347583475934760347613476234763347643476534766347673476834769347703477134772347733477434775347763477734778347793478034781347823478334784347853478634787347883478934790347913479234793347943479534796347973479834799348003480134802348033480434805348063480734808348093481034811348123481334814348153481634817348183481934820348213482234823348243482534826348273482834829348303483134832348333483434835348363483734838348393484034841348423484334844348453484634847348483484934850348513485234853348543485534856348573485834859348603486134862348633486434865348663486734868348693487034871348723487334874348753487634877348783487934880348813488234883348843488534886348873488834889348903489134892348933489434895348963489734898348993490034901349023490334904349053490634907349083490934910349113491234913349143491534916349173491834919349203492134922349233492434925349263492734928349293493034931349323493334934349353493634937349383493934940349413494234943349443494534946349473494834949349503495134952349533495434955349563495734958349593496034961349623496334964349653496634967349683496934970349713497234973349743497534976349773497834979349803498134982349833498434985349863498734988349893499034991349923499334994349953499634997349983499935000350013500235003350043500535006350073500835009350103501135012350133501435015350163501735018350193502035021350223502335024350253502635027350283502935030350313503235033350343503535036350373503835039350403504135042350433504435045350463504735048350493505035051350523505335054350553505635057350583505935060350613506235063350643506535066350673506835069350703507135072350733507435075350763507735078350793508035081350823508335084350853508635087350883508935090350913509235093350943509535096350973509835099351003510135102351033510435105351063510735108351093511035111351123511335114351153511635117351183511935120351213512235123351243512535126351273512835129351303513135132351333513435135351363513735138351393514035141351423514335144351453514635147351483514935150351513515235153351543515535156351573515835159351603516135162351633516435165351663516735168351693517035171351723517335174351753517635177351783517935180351813518235183351843518535186351873518835189351903519135192351933519435195351963519735198351993520035201352023520335204352053520635207352083520935210352113521235213352143521535216352173521835219352203522135222352233522435225352263522735228352293523035231352323523335234352353523635237352383523935240352413524235243352443524535246352473524835249352503525135252352533525435255352563525735258352593526035261352623526335264352653526635267352683526935270352713527235273352743527535276352773527835279352803528135282352833528435285352863528735288352893529035291352923529335294352953529635297352983529935300353013530235303353043530535306353073530835309353103531135312353133531435315353163531735318353193532035321353223532335324353253532635327353283532935330353313533235333353343533535336353373533835339353403534135342353433534435345353463534735348353493535035351353523535335354353553535635357353583535935360353613536235363353643536535366353673536835369353703537135372353733537435375353763537735378353793538035381353823538335384353853538635387353883538935390353913539235393353943539535396353973539835399354003540135402354033540435405354063540735408354093541035411354123541335414354153541635417354183541935420354213542235423354243542535426354273542835429354303543135432354333543435435354363543735438354393544035441354423544335444354453544635447354483544935450354513545235453354543545535456354573545835459354603546135462354633546435465354663546735468354693547035471354723547335474354753547635477354783547935480354813548235483354843548535486354873548835489354903549135492354933549435495354963549735498354993550035501355023550335504355053550635507355083550935510355113551235513355143551535516355173551835519355203552135522355233552435525355263552735528355293553035531355323553335534355353553635537355383553935540355413554235543355443554535546355473554835549355503555135552355533555435555355563555735558355593556035561355623556335564355653556635567355683556935570355713557235573355743557535576355773557835579355803558135582355833558435585355863558735588355893559035591355923559335594355953559635597355983559935600356013560235603356043560535606356073560835609356103561135612356133561435615356163561735618356193562035621356223562335624356253562635627356283562935630356313563235633356343563535636356373563835639356403564135642356433564435645356463564735648356493565035651356523565335654356553565635657356583565935660356613566235663356643566535666356673566835669356703567135672356733567435675356763567735678356793568035681356823568335684356853568635687356883568935690356913569235693356943569535696356973569835699357003570135702357033570435705357063570735708357093571035711357123571335714357153571635717357183571935720357213572235723357243572535726357273572835729357303573135732357333573435735357363573735738357393574035741357423574335744357453574635747357483574935750357513575235753357543575535756357573575835759357603576135762357633576435765357663576735768357693577035771357723577335774357753577635777357783577935780357813578235783357843578535786357873578835789357903579135792357933579435795357963579735798357993580035801358023580335804358053580635807358083580935810358113581235813358143581535816358173581835819358203582135822358233582435825358263582735828358293583035831358323583335834358353583635837358383583935840358413584235843358443584535846358473584835849358503585135852358533585435855358563585735858358593586035861358623586335864358653586635867358683586935870358713587235873358743587535876358773587835879358803588135882358833588435885358863588735888358893589035891358923589335894358953589635897358983589935900359013590235903359043590535906359073590835909359103591135912359133591435915359163591735918359193592035921359223592335924359253592635927359283592935930359313593235933359343593535936359373593835939359403594135942359433594435945359463594735948359493595035951359523595335954359553595635957359583595935960359613596235963359643596535966359673596835969359703597135972359733597435975359763597735978359793598035981359823598335984359853598635987359883598935990359913599235993359943599535996359973599835999360003600136002360033600436005360063600736008360093601036011360123601336014360153601636017360183601936020360213602236023360243602536026360273602836029360303603136032360333603436035360363603736038360393604036041360423604336044360453604636047360483604936050360513605236053360543605536056360573605836059360603606136062360633606436065360663606736068360693607036071360723607336074360753607636077360783607936080360813608236083360843608536086360873608836089360903609136092360933609436095360963609736098360993610036101361023610336104361053610636107361083610936110361113611236113361143611536116361173611836119361203612136122361233612436125361263612736128361293613036131361323613336134361353613636137361383613936140361413614236143361443614536146361473614836149361503615136152361533615436155361563615736158361593616036161361623616336164361653616636167361683616936170361713617236173361743617536176361773617836179361803618136182361833618436185361863618736188361893619036191361923619336194361953619636197361983619936200362013620236203362043620536206362073620836209362103621136212362133621436215362163621736218362193622036221362223622336224362253622636227362283622936230362313623236233362343623536236362373623836239362403624136242362433624436245362463624736248362493625036251362523625336254362553625636257362583625936260362613626236263362643626536266362673626836269362703627136272362733627436275362763627736278362793628036281362823628336284362853628636287362883628936290362913629236293362943629536296362973629836299363003630136302363033630436305363063630736308363093631036311363123631336314363153631636317363183631936320363213632236323363243632536326363273632836329363303633136332363333633436335363363633736338363393634036341363423634336344363453634636347363483634936350363513635236353363543635536356363573635836359363603636136362363633636436365363663636736368363693637036371363723637336374363753637636377363783637936380363813638236383363843638536386363873638836389363903639136392363933639436395363963639736398363993640036401364023640336404364053640636407364083640936410364113641236413364143641536416364173641836419364203642136422364233642436425364263642736428364293643036431364323643336434364353643636437364383643936440364413644236443364443644536446364473644836449364503645136452364533645436455364563645736458364593646036461364623646336464364653646636467364683646936470364713647236473364743647536476364773647836479364803648136482364833648436485364863648736488364893649036491364923649336494364953649636497364983649936500365013650236503365043650536506365073650836509365103651136512365133651436515365163651736518365193652036521365223652336524365253652636527365283652936530365313653236533365343653536536365373653836539365403654136542365433654436545365463654736548365493655036551365523655336554365553655636557365583655936560365613656236563365643656536566365673656836569365703657136572365733657436575365763657736578365793658036581365823658336584365853658636587365883658936590365913659236593365943659536596365973659836599366003660136602366033660436605366063660736608366093661036611366123661336614366153661636617366183661936620366213662236623366243662536626366273662836629366303663136632366333663436635366363663736638366393664036641366423664336644366453664636647366483664936650366513665236653366543665536656366573665836659366603666136662366633666436665366663666736668366693667036671366723667336674366753667636677366783667936680366813668236683366843668536686366873668836689366903669136692366933669436695366963669736698366993670036701367023670336704367053670636707367083670936710367113671236713367143671536716367173671836719367203672136722367233672436725367263672736728367293673036731367323673336734367353673636737367383673936740367413674236743367443674536746367473674836749367503675136752367533675436755367563675736758367593676036761367623676336764367653676636767367683676936770367713677236773367743677536776367773677836779367803678136782367833678436785367863678736788367893679036791367923679336794367953679636797367983679936800368013680236803368043680536806368073680836809368103681136812368133681436815368163681736818368193682036821368223682336824368253682636827368283682936830368313683236833368343683536836368373683836839368403684136842368433684436845368463684736848368493685036851368523685336854368553685636857368583685936860368613686236863368643686536866368673686836869368703687136872368733687436875368763687736878368793688036881368823688336884368853688636887368883688936890368913689236893368943689536896368973689836899369003690136902369033690436905369063690736908369093691036911369123691336914369153691636917369183691936920369213692236923369243692536926369273692836929369303693136932369333693436935369363693736938369393694036941369423694336944369453694636947369483694936950369513695236953369543695536956369573695836959369603696136962369633696436965369663696736968369693697036971369723697336974369753697636977369783697936980369813698236983369843698536986369873698836989369903699136992369933699436995369963699736998369993700037001370023700337004370053700637007370083700937010370113701237013370143701537016370173701837019370203702137022370233702437025370263702737028370293703037031370323703337034370353703637037370383703937040370413704237043370443704537046370473704837049370503705137052370533705437055370563705737058370593706037061370623706337064370653706637067370683706937070370713707237073370743707537076370773707837079370803708137082370833708437085370863708737088370893709037091370923709337094370953709637097370983709937100371013710237103371043710537106371073710837109371103711137112371133711437115371163711737118371193712037121371223712337124371253712637127371283712937130371313713237133371343713537136371373713837139371403714137142371433714437145371463714737148371493715037151371523715337154371553715637157371583715937160371613716237163371643716537166371673716837169371703717137172371733717437175371763717737178371793718037181371823718337184371853718637187371883718937190371913719237193371943719537196371973719837199372003720137202372033720437205372063720737208372093721037211372123721337214372153721637217372183721937220372213722237223372243722537226372273722837229372303723137232372333723437235372363723737238372393724037241372423724337244372453724637247372483724937250372513725237253372543725537256372573725837259372603726137262372633726437265372663726737268372693727037271372723727337274372753727637277372783727937280372813728237283372843728537286372873728837289372903729137292372933729437295372963729737298372993730037301373023730337304373053730637307373083730937310373113731237313373143731537316373173731837319373203732137322373233732437325373263732737328373293733037331373323733337334373353733637337373383733937340373413734237343373443734537346373473734837349373503735137352373533735437355373563735737358373593736037361373623736337364373653736637367373683736937370373713737237373373743737537376373773737837379373803738137382373833738437385373863738737388373893739037391373923739337394373953739637397373983739937400374013740237403374043740537406374073740837409374103741137412374133741437415374163741737418374193742037421374223742337424374253742637427374283742937430374313743237433374343743537436374373743837439374403744137442374433744437445374463744737448374493745037451374523745337454374553745637457374583745937460374613746237463374643746537466374673746837469374703747137472374733747437475374763747737478374793748037481374823748337484374853748637487374883748937490374913749237493374943749537496374973749837499375003750137502375033750437505375063750737508375093751037511375123751337514375153751637517375183751937520375213752237523375243752537526375273752837529375303753137532375333753437535375363753737538375393754037541375423754337544375453754637547375483754937550375513755237553375543755537556375573755837559375603756137562375633756437565375663756737568375693757037571375723757337574375753757637577375783757937580375813758237583375843758537586375873758837589375903759137592375933759437595375963759737598375993760037601376023760337604376053760637607376083760937610376113761237613376143761537616376173761837619376203762137622376233762437625376263762737628376293763037631376323763337634376353763637637376383763937640376413764237643376443764537646376473764837649376503765137652376533765437655376563765737658376593766037661376623766337664376653766637667376683766937670376713767237673376743767537676376773767837679376803768137682376833768437685376863768737688376893769037691376923769337694376953769637697376983769937700377013770237703377043770537706377073770837709377103771137712377133771437715377163771737718377193772037721377223772337724377253772637727377283772937730377313773237733377343773537736377373773837739377403774137742377433774437745377463774737748377493775037751377523775337754377553775637757377583775937760377613776237763377643776537766377673776837769377703777137772377733777437775377763777737778377793778037781377823778337784377853778637787377883778937790377913779237793377943779537796377973779837799378003780137802378033780437805378063780737808378093781037811378123781337814378153781637817378183781937820378213782237823378243782537826378273782837829378303783137832378333783437835378363783737838378393784037841378423784337844378453784637847378483784937850378513785237853378543785537856378573785837859378603786137862378633786437865378663786737868378693787037871378723787337874378753787637877378783787937880378813788237883378843788537886378873788837889378903789137892378933789437895378963789737898378993790037901379023790337904379053790637907379083790937910379113791237913379143791537916379173791837919379203792137922379233792437925379263792737928379293793037931379323793337934379353793637937379383793937940379413794237943379443794537946379473794837949379503795137952379533795437955379563795737958379593796037961379623796337964379653796637967379683796937970379713797237973379743797537976379773797837979379803798137982379833798437985379863798737988379893799037991379923799337994379953799637997379983799938000380013800238003380043800538006380073800838009380103801138012380133801438015380163801738018380193802038021380223802338024380253802638027380283802938030380313803238033380343803538036380373803838039380403804138042380433804438045380463804738048380493805038051380523805338054380553805638057380583805938060380613806238063380643806538066380673806838069380703807138072380733807438075380763807738078380793808038081380823808338084380853808638087380883808938090380913809238093380943809538096380973809838099381003810138102381033810438105381063810738108381093811038111381123811338114381153811638117381183811938120381213812238123381243812538126381273812838129381303813138132381333813438135381363813738138381393814038141381423814338144381453814638147381483814938150381513815238153381543815538156381573815838159381603816138162381633816438165381663816738168381693817038171381723817338174381753817638177381783817938180381813818238183381843818538186381873818838189381903819138192381933819438195381963819738198381993820038201382023820338204382053820638207382083820938210382113821238213382143821538216382173821838219382203822138222382233822438225382263822738228382293823038231382323823338234382353823638237382383823938240382413824238243382443824538246382473824838249382503825138252382533825438255382563825738258382593826038261382623826338264382653826638267382683826938270382713827238273382743827538276382773827838279382803828138282382833828438285382863828738288382893829038291382923829338294382953829638297382983829938300383013830238303383043830538306383073830838309383103831138312383133831438315383163831738318383193832038321383223832338324383253832638327383283832938330383313833238333383343833538336383373833838339383403834138342383433834438345383463834738348383493835038351383523835338354383553835638357383583835938360383613836238363383643836538366383673836838369383703837138372383733837438375383763837738378383793838038381383823838338384383853838638387383883838938390383913839238393383943839538396383973839838399384003840138402384033840438405384063840738408384093841038411384123841338414384153841638417384183841938420384213842238423384243842538426384273842838429384303843138432384333843438435384363843738438384393844038441384423844338444384453844638447384483844938450384513845238453384543845538456384573845838459384603846138462384633846438465384663846738468384693847038471384723847338474384753847638477384783847938480384813848238483384843848538486384873848838489384903849138492384933849438495384963849738498384993850038501385023850338504385053850638507385083850938510385113851238513385143851538516385173851838519385203852138522385233852438525385263852738528385293853038531385323853338534385353853638537385383853938540385413854238543385443854538546385473854838549385503855138552385533855438555385563855738558385593856038561385623856338564385653856638567385683856938570385713857238573385743857538576385773857838579385803858138582385833858438585385863858738588385893859038591385923859338594385953859638597385983859938600386013860238603386043860538606386073860838609386103861138612386133861438615386163861738618386193862038621386223862338624386253862638627386283862938630386313863238633386343863538636386373863838639386403864138642386433864438645386463864738648386493865038651386523865338654386553865638657386583865938660386613866238663386643866538666386673866838669386703867138672386733867438675386763867738678386793868038681386823868338684386853868638687386883868938690386913869238693386943869538696386973869838699387003870138702387033870438705387063870738708387093871038711387123871338714387153871638717387183871938720387213872238723387243872538726387273872838729387303873138732387333873438735387363873738738387393874038741387423874338744387453874638747387483874938750387513875238753387543875538756387573875838759387603876138762387633876438765387663876738768387693877038771387723877338774387753877638777387783877938780387813878238783387843878538786387873878838789387903879138792387933879438795387963879738798387993880038801388023880338804388053880638807388083880938810388113881238813388143881538816388173881838819388203882138822388233882438825388263882738828388293883038831388323883338834388353883638837388383883938840388413884238843388443884538846388473884838849388503885138852388533885438855388563885738858388593886038861388623886338864388653886638867388683886938870388713887238873388743887538876388773887838879388803888138882388833888438885388863888738888388893889038891388923889338894388953889638897388983889938900389013890238903389043890538906389073890838909389103891138912389133891438915389163891738918389193892038921389223892338924389253892638927389283892938930389313893238933389343893538936389373893838939389403894138942389433894438945389463894738948389493895038951389523895338954389553895638957389583895938960389613896238963389643896538966389673896838969389703897138972389733897438975389763897738978389793898038981389823898338984389853898638987389883898938990389913899238993389943899538996389973899838999390003900139002390033900439005390063900739008390093901039011390123901339014390153901639017390183901939020390213902239023390243902539026390273902839029390303903139032390333903439035390363903739038390393904039041390423904339044390453904639047390483904939050390513905239053390543905539056390573905839059390603906139062390633906439065390663906739068390693907039071390723907339074390753907639077390783907939080390813908239083390843908539086390873908839089390903909139092390933909439095390963909739098390993910039101391023910339104391053910639107391083910939110391113911239113391143911539116391173911839119391203912139122391233912439125391263912739128391293913039131391323913339134391353913639137391383913939140391413914239143391443914539146391473914839149391503915139152391533915439155391563915739158391593916039161391623916339164391653916639167391683916939170391713917239173391743917539176391773917839179391803918139182391833918439185391863918739188391893919039191391923919339194391953919639197391983919939200392013920239203392043920539206392073920839209392103921139212392133921439215392163921739218392193922039221392223922339224392253922639227392283922939230392313923239233392343923539236392373923839239392403924139242392433924439245392463924739248392493925039251392523925339254392553925639257392583925939260392613926239263392643926539266392673926839269392703927139272392733927439275392763927739278392793928039281392823928339284392853928639287392883928939290392913929239293392943929539296392973929839299393003930139302393033930439305393063930739308393093931039311393123931339314393153931639317393183931939320393213932239323393243932539326393273932839329393303933139332393333933439335393363933739338393393934039341393423934339344393453934639347393483934939350393513935239353393543935539356393573935839359393603936139362393633936439365393663936739368393693937039371393723937339374393753937639377393783937939380393813938239383393843938539386393873938839389393903939139392393933939439395393963939739398393993940039401394023940339404394053940639407394083940939410394113941239413394143941539416394173941839419394203942139422394233942439425394263942739428394293943039431394323943339434394353943639437394383943939440394413944239443394443944539446394473944839449394503945139452394533945439455394563945739458394593946039461394623946339464394653946639467394683946939470394713947239473394743947539476394773947839479394803948139482394833948439485394863948739488394893949039491394923949339494394953949639497394983949939500395013950239503395043950539506395073950839509395103951139512395133951439515395163951739518395193952039521395223952339524395253952639527395283952939530395313953239533395343953539536395373953839539395403954139542395433954439545395463954739548395493955039551395523955339554395553955639557395583955939560395613956239563395643956539566395673956839569395703957139572395733957439575395763957739578395793958039581395823958339584395853958639587395883958939590395913959239593395943959539596395973959839599396003960139602396033960439605396063960739608396093961039611396123961339614396153961639617396183961939620396213962239623396243962539626396273962839629396303963139632396333963439635396363963739638396393964039641396423964339644396453964639647396483964939650396513965239653396543965539656396573965839659396603966139662396633966439665396663966739668396693967039671396723967339674396753967639677396783967939680396813968239683396843968539686396873968839689396903969139692396933969439695396963969739698396993970039701397023970339704397053970639707397083970939710397113971239713397143971539716397173971839719397203972139722397233972439725397263972739728397293973039731397323973339734397353973639737397383973939740397413974239743397443974539746397473974839749397503975139752397533975439755397563975739758397593976039761397623976339764397653976639767397683976939770397713977239773397743977539776397773977839779397803978139782397833978439785397863978739788397893979039791397923979339794397953979639797397983979939800398013980239803398043980539806398073980839809398103981139812398133981439815398163981739818398193982039821398223982339824398253982639827398283982939830398313983239833398343983539836398373983839839398403984139842398433984439845398463984739848398493985039851398523985339854398553985639857398583985939860398613986239863398643986539866398673986839869398703987139872398733987439875398763987739878398793988039881398823988339884398853988639887398883988939890398913989239893398943989539896398973989839899399003990139902399033990439905399063990739908399093991039911399123991339914399153991639917399183991939920399213992239923399243992539926399273992839929399303993139932399333993439935399363993739938399393994039941399423994339944399453994639947399483994939950399513995239953399543995539956399573995839959399603996139962399633996439965399663996739968399693997039971399723997339974399753997639977399783997939980399813998239983399843998539986399873998839989399903999139992399933999439995399963999739998399994000040001400024000340004400054000640007400084000940010400114001240013400144001540016400174001840019400204002140022400234002440025400264002740028400294003040031400324003340034400354003640037400384003940040400414004240043400444004540046400474004840049400504005140052400534005440055400564005740058400594006040061400624006340064400654006640067400684006940070400714007240073400744007540076400774007840079400804008140082400834008440085400864008740088400894009040091400924009340094400954009640097400984009940100401014010240103401044010540106401074010840109401104011140112401134011440115401164011740118401194012040121401224012340124401254012640127401284012940130401314013240133401344013540136401374013840139401404014140142401434014440145401464014740148401494015040151401524015340154401554015640157401584015940160401614016240163401644016540166401674016840169401704017140172401734017440175401764017740178401794018040181401824018340184401854018640187401884018940190401914019240193401944019540196401974019840199402004020140202402034020440205402064020740208402094021040211402124021340214402154021640217402184021940220402214022240223402244022540226402274022840229402304023140232402334023440235402364023740238402394024040241402424024340244402454024640247402484024940250402514025240253402544025540256402574025840259402604026140262402634026440265402664026740268402694027040271402724027340274402754027640277402784027940280402814028240283402844028540286402874028840289402904029140292402934029440295402964029740298402994030040301403024030340304403054030640307403084030940310403114031240313403144031540316403174031840319403204032140322403234032440325403264032740328403294033040331403324033340334403354033640337403384033940340403414034240343403444034540346403474034840349403504035140352403534035440355403564035740358403594036040361403624036340364403654036640367403684036940370403714037240373403744037540376403774037840379403804038140382403834038440385403864038740388403894039040391403924039340394403954039640397403984039940400404014040240403404044040540406404074040840409404104041140412404134041440415404164041740418404194042040421404224042340424404254042640427404284042940430404314043240433404344043540436404374043840439404404044140442404434044440445404464044740448404494045040451404524045340454404554045640457404584045940460404614046240463404644046540466404674046840469404704047140472404734047440475404764047740478404794048040481404824048340484404854048640487404884048940490404914049240493404944049540496404974049840499405004050140502405034050440505405064050740508405094051040511405124051340514405154051640517405184051940520405214052240523405244052540526405274052840529405304053140532405334053440535405364053740538405394054040541405424054340544405454054640547405484054940550405514055240553405544055540556405574055840559405604056140562405634056440565405664056740568405694057040571405724057340574405754057640577405784057940580405814058240583405844058540586405874058840589405904059140592405934059440595405964059740598405994060040601406024060340604406054060640607406084060940610406114061240613406144061540616406174061840619406204062140622406234062440625406264062740628406294063040631406324063340634406354063640637406384063940640406414064240643406444064540646406474064840649406504065140652406534065440655406564065740658406594066040661406624066340664406654066640667406684066940670406714067240673406744067540676406774067840679406804068140682406834068440685406864068740688406894069040691406924069340694406954069640697406984069940700407014070240703407044070540706407074070840709407104071140712407134071440715407164071740718407194072040721407224072340724407254072640727407284072940730407314073240733407344073540736407374073840739407404074140742407434074440745407464074740748407494075040751407524075340754407554075640757407584075940760407614076240763407644076540766407674076840769407704077140772407734077440775407764077740778407794078040781407824078340784407854078640787407884078940790407914079240793407944079540796407974079840799408004080140802408034080440805408064080740808408094081040811408124081340814408154081640817408184081940820408214082240823408244082540826408274082840829408304083140832408334083440835408364083740838408394084040841408424084340844408454084640847408484084940850408514085240853408544085540856408574085840859408604086140862408634086440865408664086740868408694087040871408724087340874408754087640877408784087940880408814088240883408844088540886408874088840889408904089140892408934089440895408964089740898408994090040901409024090340904409054090640907409084090940910409114091240913409144091540916409174091840919409204092140922409234092440925409264092740928409294093040931409324093340934409354093640937409384093940940409414094240943409444094540946409474094840949409504095140952409534095440955409564095740958409594096040961409624096340964409654096640967409684096940970409714097240973409744097540976409774097840979409804098140982409834098440985409864098740988409894099040991409924099340994409954099640997409984099941000410014100241003410044100541006410074100841009410104101141012410134101441015410164101741018410194102041021410224102341024410254102641027410284102941030410314103241033410344103541036410374103841039410404104141042410434104441045410464104741048410494105041051410524105341054410554105641057410584105941060410614106241063410644106541066410674106841069410704107141072410734107441075410764107741078410794108041081410824108341084410854108641087410884108941090410914109241093410944109541096410974109841099411004110141102411034110441105411064110741108411094111041111411124111341114411154111641117411184111941120411214112241123411244112541126411274112841129411304113141132411334113441135411364113741138411394114041141411424114341144411454114641147411484114941150411514115241153411544115541156411574115841159411604116141162411634116441165411664116741168411694117041171411724117341174411754117641177411784117941180411814118241183411844118541186411874118841189411904119141192411934119441195411964119741198411994120041201412024120341204412054120641207412084120941210412114121241213412144121541216412174121841219412204122141222412234122441225412264122741228412294123041231412324123341234412354123641237412384123941240412414124241243412444124541246412474124841249412504125141252412534125441255412564125741258412594126041261412624126341264412654126641267412684126941270412714127241273412744127541276412774127841279412804128141282412834128441285412864128741288412894129041291412924129341294412954129641297412984129941300413014130241303413044130541306413074130841309413104131141312413134131441315413164131741318413194132041321413224132341324413254132641327413284132941330413314133241333413344133541336413374133841339413404134141342413434134441345413464134741348413494135041351413524135341354413554135641357413584135941360413614136241363413644136541366413674136841369413704137141372413734137441375413764137741378413794138041381413824138341384413854138641387413884138941390413914139241393413944139541396413974139841399414004140141402414034140441405414064140741408414094141041411414124141341414414154141641417414184141941420414214142241423414244142541426414274142841429414304143141432414334143441435414364143741438414394144041441414424144341444414454144641447414484144941450414514145241453414544145541456414574145841459414604146141462414634146441465414664146741468414694147041471414724147341474414754147641477414784147941480414814148241483414844148541486414874148841489414904149141492414934149441495414964149741498414994150041501415024150341504415054150641507415084150941510415114151241513415144151541516415174151841519415204152141522415234152441525415264152741528415294153041531415324153341534415354153641537415384153941540415414154241543415444154541546415474154841549415504155141552415534155441555415564155741558415594156041561415624156341564415654156641567415684156941570415714157241573415744157541576415774157841579415804158141582415834158441585415864158741588415894159041591415924159341594415954159641597415984159941600416014160241603416044160541606416074160841609416104161141612416134161441615416164161741618416194162041621416224162341624416254162641627416284162941630416314163241633416344163541636416374163841639416404164141642416434164441645416464164741648416494165041651416524165341654416554165641657416584165941660416614166241663416644166541666416674166841669416704167141672416734167441675416764167741678416794168041681416824168341684416854168641687416884168941690416914169241693416944169541696416974169841699417004170141702417034170441705417064170741708417094171041711417124171341714417154171641717417184171941720417214172241723417244172541726417274172841729417304173141732417334173441735417364173741738417394174041741417424174341744417454174641747417484174941750417514175241753417544175541756417574175841759417604176141762417634176441765417664176741768417694177041771417724177341774417754177641777417784177941780417814178241783417844178541786417874178841789417904179141792417934179441795417964179741798417994180041801418024180341804418054180641807418084180941810418114181241813418144181541816418174181841819418204182141822418234182441825418264182741828418294183041831418324183341834418354183641837418384183941840418414184241843418444184541846418474184841849418504185141852418534185441855418564185741858418594186041861418624186341864418654186641867418684186941870418714187241873418744187541876418774187841879418804188141882418834188441885418864188741888418894189041891418924189341894418954189641897418984189941900419014190241903419044190541906419074190841909419104191141912419134191441915419164191741918419194192041921419224192341924419254192641927419284192941930419314193241933419344193541936419374193841939419404194141942419434194441945419464194741948419494195041951419524195341954419554195641957419584195941960419614196241963419644196541966419674196841969419704197141972419734197441975419764197741978419794198041981419824198341984419854198641987419884198941990419914199241993419944199541996419974199841999420004200142002420034200442005420064200742008420094201042011420124201342014420154201642017420184201942020420214202242023420244202542026420274202842029420304203142032420334203442035420364203742038420394204042041420424204342044420454204642047420484204942050420514205242053420544205542056420574205842059420604206142062420634206442065420664206742068420694207042071420724207342074420754207642077420784207942080420814208242083420844208542086420874208842089420904209142092420934209442095420964209742098420994210042101421024210342104421054210642107421084210942110421114211242113421144211542116421174211842119421204212142122421234212442125421264212742128421294213042131421324213342134421354213642137421384213942140421414214242143421444214542146421474214842149421504215142152421534215442155421564215742158421594216042161421624216342164421654216642167421684216942170421714217242173421744217542176421774217842179421804218142182421834218442185421864218742188421894219042191421924219342194421954219642197421984219942200422014220242203422044220542206422074220842209422104221142212422134221442215422164221742218422194222042221422224222342224422254222642227422284222942230422314223242233422344223542236422374223842239422404224142242422434224442245422464224742248422494225042251422524225342254422554225642257422584225942260422614226242263422644226542266422674226842269422704227142272422734227442275422764227742278422794228042281422824228342284422854228642287422884228942290422914229242293422944229542296422974229842299423004230142302423034230442305423064230742308423094231042311423124231342314423154231642317423184231942320423214232242323423244232542326423274232842329423304233142332423334233442335423364233742338423394234042341423424234342344423454234642347423484234942350423514235242353423544235542356423574235842359423604236142362423634236442365423664236742368423694237042371423724237342374423754237642377423784237942380423814238242383423844238542386423874238842389423904239142392423934239442395423964239742398423994240042401424024240342404424054240642407424084240942410424114241242413424144241542416424174241842419424204242142422424234242442425424264242742428424294243042431424324243342434424354243642437424384243942440424414244242443424444244542446424474244842449424504245142452424534245442455424564245742458424594246042461424624246342464424654246642467424684246942470424714247242473424744247542476424774247842479424804248142482424834248442485424864248742488424894249042491424924249342494424954249642497424984249942500425014250242503425044250542506425074250842509425104251142512425134251442515425164251742518425194252042521425224252342524425254252642527425284252942530425314253242533425344253542536425374253842539425404254142542425434254442545425464254742548425494255042551425524255342554425554255642557425584255942560425614256242563425644256542566425674256842569425704257142572425734257442575425764257742578425794258042581425824258342584425854258642587425884258942590425914259242593425944259542596425974259842599426004260142602426034260442605426064260742608426094261042611426124261342614426154261642617426184261942620426214262242623426244262542626426274262842629426304263142632426334263442635426364263742638426394264042641426424264342644426454264642647426484264942650426514265242653426544265542656426574265842659426604266142662426634266442665426664266742668426694267042671426724267342674426754267642677426784267942680426814268242683426844268542686426874268842689426904269142692426934269442695426964269742698426994270042701427024270342704427054270642707427084270942710427114271242713427144271542716427174271842719427204272142722427234272442725427264272742728427294273042731427324273342734427354273642737427384273942740427414274242743427444274542746427474274842749427504275142752427534275442755427564275742758427594276042761427624276342764427654276642767427684276942770427714277242773427744277542776427774277842779427804278142782427834278442785427864278742788427894279042791427924279342794427954279642797427984279942800428014280242803428044280542806428074280842809428104281142812428134281442815428164281742818428194282042821428224282342824428254282642827428284282942830428314283242833428344283542836428374283842839428404284142842428434284442845428464284742848428494285042851428524285342854428554285642857428584285942860428614286242863428644286542866428674286842869428704287142872428734287442875428764287742878428794288042881428824288342884428854288642887428884288942890428914289242893428944289542896428974289842899429004290142902429034290442905429064290742908429094291042911429124291342914429154291642917429184291942920429214292242923429244292542926429274292842929429304293142932429334293442935429364293742938429394294042941429424294342944429454294642947429484294942950429514295242953429544295542956429574295842959429604296142962429634296442965429664296742968429694297042971429724297342974429754297642977429784297942980429814298242983429844298542986429874298842989429904299142992429934299442995429964299742998429994300043001430024300343004430054300643007430084300943010430114301243013430144301543016430174301843019430204302143022430234302443025430264302743028430294303043031430324303343034430354303643037430384303943040430414304243043430444304543046430474304843049430504305143052430534305443055430564305743058430594306043061430624306343064430654306643067430684306943070430714307243073430744307543076430774307843079430804308143082430834308443085430864308743088430894309043091430924309343094430954309643097430984309943100431014310243103431044310543106431074310843109431104311143112431134311443115431164311743118431194312043121431224312343124431254312643127431284312943130431314313243133431344313543136431374313843139431404314143142431434314443145431464314743148431494315043151431524315343154431554315643157431584315943160431614316243163431644316543166431674316843169431704317143172431734317443175431764317743178431794318043181431824318343184431854318643187431884318943190431914319243193431944319543196431974319843199432004320143202432034320443205432064320743208432094321043211432124321343214432154321643217432184321943220432214322243223432244322543226432274322843229432304323143232432334323443235432364323743238432394324043241432424324343244432454324643247432484324943250432514325243253432544325543256432574325843259432604326143262432634326443265432664326743268432694327043271432724327343274432754327643277432784327943280432814328243283432844328543286432874328843289432904329143292432934329443295432964329743298432994330043301433024330343304433054330643307433084330943310433114331243313433144331543316433174331843319433204332143322433234332443325433264332743328433294333043331433324333343334433354333643337433384333943340433414334243343433444334543346433474334843349433504335143352433534335443355433564335743358433594336043361433624336343364433654336643367433684336943370433714337243373433744337543376433774337843379433804338143382433834338443385433864338743388433894339043391433924339343394433954339643397433984339943400434014340243403434044340543406434074340843409434104341143412434134341443415434164341743418434194342043421434224342343424434254342643427434284342943430434314343243433434344343543436434374343843439434404344143442434434344443445434464344743448434494345043451434524345343454434554345643457434584345943460434614346243463434644346543466434674346843469434704347143472434734347443475434764347743478434794348043481434824348343484434854348643487434884348943490434914349243493434944349543496434974349843499435004350143502435034350443505435064350743508435094351043511435124351343514435154351643517435184351943520435214352243523435244352543526435274352843529435304353143532435334353443535435364353743538435394354043541435424354343544435454354643547435484354943550435514355243553435544355543556435574355843559435604356143562435634356443565435664356743568435694357043571435724357343574435754357643577435784357943580435814358243583435844358543586435874358843589435904359143592435934359443595435964359743598435994360043601436024360343604436054360643607436084360943610436114361243613436144361543616436174361843619436204362143622436234362443625436264362743628436294363043631436324363343634436354363643637436384363943640436414364243643436444364543646436474364843649436504365143652436534365443655436564365743658436594366043661436624366343664436654366643667436684366943670436714367243673436744367543676436774367843679436804368143682436834368443685436864368743688436894369043691436924369343694436954369643697436984369943700437014370243703437044370543706437074370843709437104371143712437134371443715437164371743718437194372043721437224372343724437254372643727437284372943730437314373243733437344373543736437374373843739437404374143742437434374443745437464374743748437494375043751437524375343754437554375643757437584375943760437614376243763437644376543766437674376843769437704377143772437734377443775437764377743778437794378043781437824378343784437854378643787437884378943790437914379243793437944379543796437974379843799438004380143802438034380443805438064380743808438094381043811438124381343814438154381643817438184381943820438214382243823438244382543826438274382843829438304383143832438334383443835438364383743838438394384043841438424384343844438454384643847438484384943850438514385243853438544385543856438574385843859438604386143862438634386443865438664386743868438694387043871438724387343874438754387643877438784387943880438814388243883438844388543886438874388843889438904389143892438934389443895438964389743898438994390043901439024390343904439054390643907439084390943910439114391243913439144391543916439174391843919439204392143922439234392443925439264392743928439294393043931439324393343934439354393643937439384393943940439414394243943439444394543946439474394843949439504395143952439534395443955439564395743958439594396043961439624396343964439654396643967439684396943970439714397243973439744397543976439774397843979439804398143982439834398443985439864398743988439894399043991439924399343994439954399643997439984399944000440014400244003440044400544006440074400844009440104401144012440134401444015440164401744018440194402044021440224402344024440254402644027440284402944030440314403244033440344403544036440374403844039440404404144042440434404444045440464404744048440494405044051440524405344054440554405644057440584405944060440614406244063440644406544066440674406844069440704407144072440734407444075440764407744078440794408044081440824408344084440854408644087440884408944090440914409244093440944409544096440974409844099441004410144102441034410444105441064410744108441094411044111441124411344114441154411644117441184411944120441214412244123441244412544126441274412844129441304413144132441334413444135441364413744138441394414044141441424414344144441454414644147441484414944150441514415244153441544415544156441574415844159441604416144162441634416444165441664416744168441694417044171441724417344174441754417644177441784417944180441814418244183441844418544186441874418844189441904419144192441934419444195441964419744198441994420044201442024420344204442054420644207442084420944210442114421244213442144421544216442174421844219442204422144222442234422444225442264422744228442294423044231442324423344234442354423644237442384423944240442414424244243442444424544246442474424844249442504425144252442534425444255442564425744258442594426044261442624426344264442654426644267442684426944270442714427244273442744427544276442774427844279442804428144282442834428444285442864428744288442894429044291442924429344294442954429644297442984429944300443014430244303443044430544306443074430844309443104431144312443134431444315443164431744318443194432044321443224432344324443254432644327443284432944330443314433244333443344433544336443374433844339443404434144342443434434444345443464434744348443494435044351443524435344354443554435644357443584435944360443614436244363443644436544366443674436844369443704437144372443734437444375443764437744378443794438044381443824438344384443854438644387443884438944390443914439244393443944439544396443974439844399444004440144402444034440444405444064440744408444094441044411444124441344414444154441644417444184441944420444214442244423444244442544426444274442844429444304443144432444334443444435444364443744438444394444044441444424444344444444454444644447444484444944450444514445244453444544445544456444574445844459444604446144462444634446444465444664446744468444694447044471444724447344474444754447644477444784447944480444814448244483444844448544486444874448844489444904449144492444934449444495444964449744498444994450044501445024450344504445054450644507445084450944510445114451244513445144451544516445174451844519445204452144522445234452444525445264452744528445294453044531445324453344534445354453644537445384453944540445414454244543445444454544546445474454844549445504455144552445534455444555445564455744558445594456044561445624456344564445654456644567445684456944570445714457244573445744457544576445774457844579445804458144582445834458444585445864458744588445894459044591445924459344594445954459644597445984459944600446014460244603446044460544606446074460844609446104461144612446134461444615446164461744618446194462044621446224462344624446254462644627446284462944630446314463244633446344463544636446374463844639446404464144642446434464444645446464464744648446494465044651446524465344654446554465644657446584465944660446614466244663446644466544666446674466844669446704467144672446734467444675446764467744678446794468044681446824468344684446854468644687446884468944690446914469244693446944469544696446974469844699447004470144702447034470444705447064470744708447094471044711447124471344714447154471644717447184471944720447214472244723447244472544726447274472844729447304473144732447334473444735447364473744738447394474044741447424474344744447454474644747447484474944750447514475244753447544475544756447574475844759447604476144762447634476444765447664476744768447694477044771447724477344774447754477644777447784477944780447814478244783447844478544786447874478844789447904479144792447934479444795447964479744798447994480044801448024480344804448054480644807448084480944810448114481244813448144481544816448174481844819448204482144822448234482444825448264482744828448294483044831448324483344834448354483644837448384483944840448414484244843448444484544846448474484844849448504485144852448534485444855448564485744858448594486044861448624486344864448654486644867448684486944870448714487244873448744487544876448774487844879448804488144882448834488444885448864488744888448894489044891448924489344894448954489644897448984489944900449014490244903449044490544906449074490844909449104491144912449134491444915449164491744918449194492044921449224492344924449254492644927449284492944930449314493244933449344493544936449374493844939449404494144942449434494444945449464494744948449494495044951449524495344954449554495644957449584495944960449614496244963449644496544966449674496844969449704497144972449734497444975449764497744978449794498044981449824498344984449854498644987449884498944990449914499244993449944499544996449974499844999450004500145002450034500445005450064500745008450094501045011450124501345014450154501645017450184501945020450214502245023450244502545026450274502845029450304503145032450334503445035450364503745038450394504045041450424504345044450454504645047450484504945050450514505245053450544505545056450574505845059450604506145062450634506445065450664506745068450694507045071450724507345074450754507645077450784507945080450814508245083450844508545086450874508845089450904509145092450934509445095450964509745098450994510045101451024510345104451054510645107451084510945110451114511245113451144511545116451174511845119451204512145122451234512445125451264512745128451294513045131451324513345134451354513645137451384513945140451414514245143451444514545146451474514845149451504515145152451534515445155451564515745158451594516045161451624516345164451654516645167451684516945170451714517245173451744517545176451774517845179451804518145182451834518445185451864518745188451894519045191451924519345194451954519645197451984519945200452014520245203452044520545206452074520845209452104521145212452134521445215452164521745218452194522045221452224522345224452254522645227452284522945230452314523245233452344523545236452374523845239452404524145242452434524445245452464524745248452494525045251452524525345254452554525645257452584525945260452614526245263452644526545266452674526845269452704527145272452734527445275452764527745278452794528045281452824528345284452854528645287452884528945290452914529245293452944529545296452974529845299453004530145302453034530445305453064530745308453094531045311453124531345314453154531645317453184531945320453214532245323453244532545326453274532845329453304533145332453334533445335453364533745338453394534045341453424534345344453454534645347453484534945350453514535245353453544535545356453574535845359453604536145362453634536445365453664536745368453694537045371453724537345374453754537645377453784537945380453814538245383453844538545386453874538845389453904539145392453934539445395453964539745398453994540045401454024540345404454054540645407454084540945410454114541245413454144541545416454174541845419454204542145422454234542445425454264542745428454294543045431454324543345434454354543645437454384543945440454414544245443454444544545446454474544845449454504545145452454534545445455454564545745458454594546045461454624546345464454654546645467454684546945470454714547245473454744547545476454774547845479454804548145482454834548445485454864548745488454894549045491454924549345494454954549645497454984549945500455014550245503455044550545506455074550845509455104551145512455134551445515455164551745518455194552045521455224552345524455254552645527455284552945530455314553245533455344553545536455374553845539455404554145542455434554445545455464554745548455494555045551455524555345554455554555645557455584555945560455614556245563455644556545566455674556845569455704557145572455734557445575455764557745578455794558045581455824558345584455854558645587455884558945590455914559245593455944559545596455974559845599456004560145602456034560445605456064560745608456094561045611456124561345614456154561645617456184561945620456214562245623456244562545626456274562845629456304563145632456334563445635456364563745638456394564045641456424564345644456454564645647456484564945650456514565245653456544565545656456574565845659456604566145662456634566445665456664566745668456694567045671456724567345674456754567645677456784567945680456814568245683456844568545686456874568845689456904569145692456934569445695456964569745698456994570045701457024570345704457054570645707457084570945710457114571245713457144571545716457174571845719457204572145722457234572445725457264572745728457294573045731457324573345734457354573645737457384573945740457414574245743457444574545746457474574845749457504575145752457534575445755457564575745758457594576045761457624576345764457654576645767457684576945770457714577245773457744577545776457774577845779457804578145782457834578445785457864578745788457894579045791457924579345794457954579645797457984579945800458014580245803458044580545806458074580845809458104581145812458134581445815458164581745818458194582045821458224582345824458254582645827458284582945830458314583245833458344583545836458374583845839458404584145842458434584445845458464584745848458494585045851458524585345854458554585645857458584585945860458614586245863458644586545866458674586845869458704587145872458734587445875458764587745878458794588045881458824588345884458854588645887458884588945890458914589245893458944589545896458974589845899459004590145902459034590445905459064590745908459094591045911459124591345914459154591645917459184591945920459214592245923459244592545926459274592845929459304593145932459334593445935459364593745938459394594045941459424594345944459454594645947459484594945950459514595245953459544595545956459574595845959459604596145962459634596445965459664596745968459694597045971459724597345974459754597645977459784597945980459814598245983459844598545986459874598845989459904599145992459934599445995459964599745998459994600046001460024600346004460054600646007460084600946010460114601246013460144601546016460174601846019460204602146022460234602446025460264602746028460294603046031460324603346034460354603646037460384603946040460414604246043460444604546046460474604846049460504605146052460534605446055460564605746058460594606046061460624606346064460654606646067460684606946070460714607246073460744607546076460774607846079460804608146082460834608446085460864608746088460894609046091460924609346094460954609646097460984609946100461014610246103461044610546106461074610846109461104611146112461134611446115461164611746118461194612046121461224612346124461254612646127461284612946130461314613246133461344613546136461374613846139461404614146142461434614446145461464614746148461494615046151461524615346154461554615646157461584615946160461614616246163461644616546166461674616846169461704617146172461734617446175461764617746178461794618046181461824618346184461854618646187461884618946190461914619246193461944619546196461974619846199462004620146202462034620446205462064620746208462094621046211462124621346214462154621646217462184621946220462214622246223462244622546226462274622846229462304623146232462334623446235462364623746238462394624046241462424624346244462454624646247462484624946250462514625246253462544625546256462574625846259462604626146262462634626446265462664626746268462694627046271462724627346274462754627646277462784627946280462814628246283462844628546286462874628846289462904629146292462934629446295462964629746298462994630046301463024630346304463054630646307463084630946310463114631246313463144631546316463174631846319463204632146322463234632446325463264632746328463294633046331463324633346334463354633646337463384633946340463414634246343463444634546346463474634846349463504635146352463534635446355463564635746358463594636046361463624636346364463654636646367463684636946370463714637246373463744637546376463774637846379463804638146382463834638446385463864638746388463894639046391463924639346394463954639646397463984639946400464014640246403464044640546406464074640846409464104641146412464134641446415464164641746418464194642046421464224642346424464254642646427464284642946430464314643246433464344643546436464374643846439464404644146442464434644446445464464644746448464494645046451464524645346454464554645646457464584645946460464614646246463464644646546466464674646846469464704647146472464734647446475464764647746478464794648046481464824648346484464854648646487464884648946490464914649246493464944649546496464974649846499465004650146502465034650446505465064650746508465094651046511465124651346514465154651646517465184651946520465214652246523465244652546526465274652846529465304653146532465334653446535465364653746538465394654046541465424654346544465454654646547465484654946550465514655246553465544655546556465574655846559465604656146562465634656446565465664656746568465694657046571465724657346574465754657646577465784657946580465814658246583465844658546586465874658846589465904659146592465934659446595465964659746598465994660046601466024660346604466054660646607466084660946610466114661246613466144661546616466174661846619466204662146622466234662446625466264662746628466294663046631466324663346634466354663646637466384663946640466414664246643466444664546646466474664846649466504665146652466534665446655466564665746658466594666046661466624666346664466654666646667466684666946670466714667246673466744667546676466774667846679466804668146682466834668446685466864668746688466894669046691466924669346694466954669646697466984669946700467014670246703467044670546706467074670846709467104671146712467134671446715467164671746718467194672046721467224672346724467254672646727467284672946730467314673246733467344673546736467374673846739467404674146742467434674446745467464674746748467494675046751467524675346754467554675646757467584675946760467614676246763467644676546766467674676846769467704677146772467734677446775467764677746778467794678046781467824678346784467854678646787467884678946790467914679246793467944679546796467974679846799468004680146802468034680446805468064680746808468094681046811468124681346814468154681646817468184681946820468214682246823468244682546826468274682846829468304683146832468334683446835468364683746838468394684046841468424684346844468454684646847468484684946850468514685246853468544685546856468574685846859468604686146862468634686446865468664686746868468694687046871468724687346874468754687646877468784687946880468814688246883468844688546886468874688846889468904689146892468934689446895468964689746898468994690046901469024690346904469054690646907469084690946910469114691246913469144691546916469174691846919469204692146922469234692446925469264692746928469294693046931469324693346934469354693646937469384693946940469414694246943469444694546946469474694846949469504695146952469534695446955469564695746958469594696046961469624696346964469654696646967469684696946970469714697246973469744697546976469774697846979469804698146982469834698446985469864698746988469894699046991469924699346994469954699646997469984699947000470014700247003470044700547006470074700847009470104701147012470134701447015470164701747018470194702047021470224702347024470254702647027470284702947030470314703247033470344703547036470374703847039470404704147042470434704447045470464704747048470494705047051470524705347054470554705647057470584705947060470614706247063470644706547066470674706847069470704707147072470734707447075470764707747078470794708047081470824708347084470854708647087470884708947090470914709247093470944709547096470974709847099471004710147102471034710447105471064710747108471094711047111471124711347114471154711647117471184711947120471214712247123471244712547126471274712847129471304713147132471334713447135471364713747138471394714047141471424714347144471454714647147471484714947150471514715247153471544715547156471574715847159471604716147162471634716447165471664716747168471694717047171471724717347174471754717647177471784717947180471814718247183471844718547186471874718847189471904719147192471934719447195471964719747198471994720047201472024720347204472054720647207472084720947210472114721247213472144721547216472174721847219472204722147222472234722447225472264722747228472294723047231472324723347234472354723647237472384723947240472414724247243472444724547246472474724847249472504725147252472534725447255472564725747258472594726047261472624726347264472654726647267472684726947270472714727247273472744727547276472774727847279472804728147282472834728447285472864728747288472894729047291472924729347294472954729647297472984729947300473014730247303473044730547306473074730847309473104731147312473134731447315473164731747318473194732047321473224732347324473254732647327473284732947330473314733247333473344733547336473374733847339473404734147342473434734447345473464734747348473494735047351473524735347354473554735647357473584735947360473614736247363473644736547366473674736847369473704737147372473734737447375473764737747378473794738047381473824738347384473854738647387473884738947390473914739247393473944739547396473974739847399474004740147402474034740447405474064740747408474094741047411474124741347414474154741647417474184741947420474214742247423474244742547426474274742847429474304743147432474334743447435474364743747438474394744047441474424744347444474454744647447474484744947450474514745247453474544745547456474574745847459474604746147462474634746447465474664746747468474694747047471474724747347474474754747647477474784747947480474814748247483474844748547486474874748847489474904749147492474934749447495474964749747498474994750047501475024750347504475054750647507475084750947510475114751247513475144751547516475174751847519475204752147522475234752447525475264752747528475294753047531475324753347534475354753647537475384753947540475414754247543475444754547546475474754847549475504755147552475534755447555475564755747558475594756047561475624756347564475654756647567475684756947570475714757247573475744757547576475774757847579475804758147582475834758447585475864758747588475894759047591475924759347594475954759647597475984759947600476014760247603476044760547606476074760847609476104761147612476134761447615476164761747618476194762047621476224762347624476254762647627476284762947630476314763247633476344763547636476374763847639476404764147642476434764447645476464764747648476494765047651476524765347654476554765647657476584765947660476614766247663476644766547666476674766847669476704767147672476734767447675476764767747678476794768047681476824768347684476854768647687476884768947690476914769247693476944769547696476974769847699477004770147702477034770447705477064770747708477094771047711477124771347714477154771647717477184771947720477214772247723477244772547726477274772847729477304773147732477334773447735477364773747738477394774047741477424774347744477454774647747477484774947750477514775247753477544775547756477574775847759477604776147762477634776447765477664776747768477694777047771477724777347774477754777647777477784777947780477814778247783477844778547786477874778847789477904779147792477934779447795477964779747798477994780047801478024780347804478054780647807478084780947810478114781247813478144781547816478174781847819478204782147822478234782447825478264782747828478294783047831478324783347834478354783647837478384783947840478414784247843478444784547846478474784847849478504785147852478534785447855478564785747858478594786047861478624786347864478654786647867478684786947870478714787247873478744787547876478774787847879478804788147882478834788447885478864788747888478894789047891478924789347894478954789647897478984789947900479014790247903479044790547906479074790847909479104791147912479134791447915479164791747918479194792047921479224792347924479254792647927479284792947930479314793247933479344793547936479374793847939479404794147942479434794447945479464794747948479494795047951479524795347954479554795647957479584795947960479614796247963479644796547966479674796847969479704797147972479734797447975479764797747978479794798047981479824798347984479854798647987479884798947990479914799247993479944799547996479974799847999480004800148002480034800448005480064800748008480094801048011480124801348014480154801648017480184801948020480214802248023480244802548026480274802848029480304803148032480334803448035480364803748038480394804048041480424804348044480454804648047480484804948050480514805248053480544805548056480574805848059480604806148062480634806448065480664806748068480694807048071480724807348074480754807648077480784807948080480814808248083480844808548086480874808848089480904809148092480934809448095480964809748098480994810048101481024810348104481054810648107481084810948110481114811248113481144811548116481174811848119481204812148122481234812448125481264812748128481294813048131481324813348134481354813648137481384813948140481414814248143481444814548146481474814848149481504815148152481534815448155481564815748158481594816048161481624816348164481654816648167481684816948170481714817248173481744817548176481774817848179481804818148182481834818448185481864818748188481894819048191481924819348194481954819648197481984819948200482014820248203482044820548206482074820848209482104821148212482134821448215482164821748218482194822048221482224822348224482254822648227482284822948230482314823248233482344823548236482374823848239482404824148242482434824448245482464824748248482494825048251482524825348254482554825648257482584825948260482614826248263482644826548266482674826848269482704827148272482734827448275482764827748278482794828048281482824828348284482854828648287482884828948290482914829248293482944829548296482974829848299483004830148302483034830448305483064830748308483094831048311483124831348314483154831648317483184831948320483214832248323483244832548326483274832848329483304833148332483334833448335483364833748338483394834048341483424834348344483454834648347483484834948350483514835248353483544835548356483574835848359483604836148362483634836448365483664836748368483694837048371483724837348374483754837648377483784837948380483814838248383483844838548386483874838848389483904839148392483934839448395483964839748398483994840048401484024840348404484054840648407484084840948410484114841248413484144841548416484174841848419484204842148422484234842448425484264842748428484294843048431484324843348434484354843648437484384843948440484414844248443484444844548446484474844848449484504845148452484534845448455484564845748458484594846048461484624846348464484654846648467484684846948470484714847248473484744847548476484774847848479484804848148482484834848448485484864848748488484894849048491484924849348494484954849648497484984849948500485014850248503485044850548506485074850848509485104851148512485134851448515485164851748518485194852048521485224852348524485254852648527485284852948530485314853248533485344853548536485374853848539485404854148542485434854448545485464854748548485494855048551485524855348554485554855648557485584855948560485614856248563485644856548566485674856848569485704857148572485734857448575485764857748578485794858048581485824858348584485854858648587485884858948590485914859248593485944859548596485974859848599486004860148602486034860448605486064860748608486094861048611486124861348614486154861648617486184861948620486214862248623486244862548626486274862848629486304863148632486334863448635486364863748638486394864048641486424864348644486454864648647486484864948650486514865248653486544865548656486574865848659486604866148662486634866448665486664866748668486694867048671486724867348674486754867648677486784867948680486814868248683486844868548686486874868848689486904869148692486934869448695486964869748698486994870048701487024870348704487054870648707487084870948710487114871248713487144871548716487174871848719487204872148722487234872448725487264872748728487294873048731487324873348734487354873648737487384873948740487414874248743487444874548746487474874848749487504875148752487534875448755487564875748758487594876048761487624876348764487654876648767487684876948770487714877248773487744877548776487774877848779487804878148782487834878448785487864878748788487894879048791487924879348794487954879648797487984879948800488014880248803488044880548806488074880848809488104881148812488134881448815488164881748818488194882048821488224882348824488254882648827488284882948830488314883248833488344883548836488374883848839488404884148842488434884448845488464884748848488494885048851488524885348854488554885648857488584885948860488614886248863488644886548866488674886848869488704887148872488734887448875488764887748878488794888048881488824888348884488854888648887488884888948890488914889248893488944889548896488974889848899489004890148902489034890448905489064890748908489094891048911489124891348914489154891648917489184891948920489214892248923489244892548926489274892848929489304893148932489334893448935489364893748938489394894048941489424894348944489454894648947489484894948950489514895248953489544895548956489574895848959489604896148962489634896448965489664896748968489694897048971489724897348974489754897648977489784897948980489814898248983489844898548986489874898848989489904899148992489934899448995489964899748998489994900049001490024900349004490054900649007490084900949010490114901249013490144901549016490174901849019490204902149022490234902449025490264902749028490294903049031490324903349034490354903649037490384903949040490414904249043490444904549046490474904849049490504905149052490534905449055490564905749058490594906049061490624906349064490654906649067490684906949070490714907249073490744907549076490774907849079490804908149082490834908449085490864908749088490894909049091490924909349094490954909649097490984909949100491014910249103491044910549106491074910849109491104911149112491134911449115491164911749118491194912049121491224912349124491254912649127491284912949130491314913249133491344913549136491374913849139491404914149142491434914449145491464914749148491494915049151491524915349154491554915649157491584915949160491614916249163491644916549166491674916849169491704917149172491734917449175491764917749178491794918049181491824918349184491854918649187491884918949190491914919249193491944919549196491974919849199492004920149202492034920449205492064920749208492094921049211492124921349214492154921649217492184921949220492214922249223492244922549226492274922849229492304923149232492334923449235492364923749238492394924049241492424924349244492454924649247492484924949250492514925249253492544925549256492574925849259492604926149262492634926449265492664926749268492694927049271492724927349274492754927649277492784927949280492814928249283492844928549286492874928849289492904929149292492934929449295492964929749298492994930049301493024930349304493054930649307493084930949310493114931249313493144931549316493174931849319493204932149322493234932449325493264932749328493294933049331493324933349334493354933649337493384933949340493414934249343493444934549346493474934849349493504935149352493534935449355493564935749358493594936049361493624936349364493654936649367493684936949370493714937249373493744937549376493774937849379493804938149382493834938449385493864938749388493894939049391493924939349394493954939649397493984939949400494014940249403494044940549406494074940849409494104941149412494134941449415494164941749418494194942049421494224942349424494254942649427494284942949430494314943249433494344943549436494374943849439494404944149442494434944449445494464944749448494494945049451494524945349454494554945649457494584945949460494614946249463494644946549466494674946849469494704947149472494734947449475494764947749478494794948049481494824948349484494854948649487494884948949490494914949249493494944949549496494974949849499495004950149502495034950449505495064950749508495094951049511495124951349514495154951649517495184951949520495214952249523495244952549526495274952849529495304953149532495334953449535495364953749538495394954049541495424954349544495454954649547495484954949550495514955249553495544955549556495574955849559495604956149562495634956449565495664956749568495694957049571495724957349574495754957649577495784957949580495814958249583495844958549586495874958849589495904959149592495934959449595495964959749598495994960049601496024960349604496054960649607496084960949610496114961249613496144961549616496174961849619496204962149622496234962449625496264962749628496294963049631496324963349634496354963649637496384963949640496414964249643496444964549646496474964849649496504965149652496534965449655496564965749658496594966049661496624966349664496654966649667496684966949670496714967249673496744967549676496774967849679496804968149682496834968449685496864968749688496894969049691496924969349694496954969649697496984969949700497014970249703497044970549706497074970849709497104971149712497134971449715497164971749718497194972049721497224972349724497254972649727497284972949730497314973249733497344973549736497374973849739497404974149742497434974449745497464974749748497494975049751497524975349754497554975649757497584975949760497614976249763497644976549766497674976849769497704977149772497734977449775497764977749778497794978049781497824978349784497854978649787497884978949790497914979249793497944979549796497974979849799498004980149802498034980449805498064980749808498094981049811498124981349814498154981649817498184981949820498214982249823498244982549826498274982849829498304983149832498334983449835498364983749838498394984049841498424984349844498454984649847498484984949850498514985249853498544985549856498574985849859498604986149862498634986449865498664986749868498694987049871498724987349874498754987649877498784987949880498814988249883498844988549886498874988849889498904989149892498934989449895498964989749898498994990049901499024990349904499054990649907499084990949910499114991249913499144991549916499174991849919499204992149922499234992449925499264992749928499294993049931499324993349934499354993649937499384993949940499414994249943499444994549946499474994849949499504995149952499534995449955499564995749958499594996049961499624996349964499654996649967499684996949970499714997249973499744997549976499774997849979499804998149982499834998449985499864998749988499894999049991499924999349994499954999649997499984999950000500015000250003500045000550006500075000850009500105001150012500135001450015500165001750018500195002050021500225002350024500255002650027500285002950030500315003250033500345003550036500375003850039500405004150042500435004450045500465004750048500495005050051500525005350054500555005650057500585005950060500615006250063500645006550066500675006850069500705007150072500735007450075500765007750078500795008050081500825008350084500855008650087500885008950090500915009250093500945009550096500975009850099501005010150102501035010450105501065010750108501095011050111501125011350114501155011650117501185011950120501215012250123501245012550126501275012850129501305013150132501335013450135501365013750138501395014050141501425014350144501455014650147501485014950150501515015250153501545015550156501575015850159501605016150162501635016450165501665016750168501695017050171501725017350174501755017650177501785017950180501815018250183501845018550186501875018850189501905019150192501935019450195501965019750198501995020050201502025020350204502055020650207502085020950210502115021250213502145021550216502175021850219502205022150222502235022450225502265022750228502295023050231502325023350234502355023650237502385023950240502415024250243502445024550246502475024850249502505025150252502535025450255502565025750258502595026050261502625026350264502655026650267502685026950270502715027250273502745027550276502775027850279502805028150282502835028450285502865028750288502895029050291502925029350294502955029650297502985029950300503015030250303503045030550306503075030850309503105031150312503135031450315503165031750318503195032050321503225032350324503255032650327503285032950330503315033250333503345033550336503375033850339503405034150342503435034450345503465034750348503495035050351503525035350354503555035650357503585035950360503615036250363503645036550366503675036850369503705037150372503735037450375503765037750378503795038050381503825038350384503855038650387503885038950390503915039250393503945039550396503975039850399504005040150402504035040450405504065040750408504095041050411504125041350414504155041650417504185041950420504215042250423504245042550426504275042850429504305043150432504335043450435504365043750438504395044050441504425044350444504455044650447504485044950450504515045250453504545045550456504575045850459504605046150462504635046450465504665046750468504695047050471504725047350474504755047650477504785047950480504815048250483504845048550486504875048850489504905049150492504935049450495504965049750498504995050050501505025050350504505055050650507505085050950510505115051250513505145051550516505175051850519505205052150522505235052450525505265052750528505295053050531505325053350534505355053650537505385053950540505415054250543505445054550546505475054850549505505055150552505535055450555505565055750558505595056050561505625056350564505655056650567505685056950570505715057250573505745057550576505775057850579505805058150582505835058450585505865058750588505895059050591505925059350594505955059650597505985059950600506015060250603506045060550606506075060850609506105061150612506135061450615506165061750618506195062050621506225062350624506255062650627506285062950630506315063250633506345063550636506375063850639506405064150642506435064450645506465064750648506495065050651506525065350654506555065650657506585065950660506615066250663506645066550666506675066850669506705067150672506735067450675506765067750678506795068050681506825068350684506855068650687506885068950690506915069250693506945069550696506975069850699507005070150702507035070450705507065070750708507095071050711507125071350714507155071650717507185071950720507215072250723507245072550726507275072850729507305073150732507335073450735507365073750738507395074050741507425074350744507455074650747507485074950750507515075250753507545075550756507575075850759507605076150762507635076450765507665076750768507695077050771507725077350774507755077650777507785077950780507815078250783507845078550786507875078850789507905079150792507935079450795507965079750798507995080050801508025080350804508055080650807508085080950810508115081250813508145081550816508175081850819508205082150822508235082450825508265082750828508295083050831508325083350834508355083650837508385083950840508415084250843508445084550846508475084850849508505085150852508535085450855508565085750858508595086050861508625086350864508655086650867508685086950870508715087250873508745087550876508775087850879508805088150882508835088450885508865088750888508895089050891508925089350894508955089650897508985089950900509015090250903509045090550906509075090850909509105091150912509135091450915509165091750918509195092050921509225092350924509255092650927509285092950930509315093250933509345093550936509375093850939509405094150942509435094450945509465094750948509495095050951509525095350954509555095650957509585095950960509615096250963509645096550966509675096850969509705097150972509735097450975509765097750978509795098050981509825098350984509855098650987509885098950990509915099250993509945099550996509975099850999510005100151002510035100451005510065100751008510095101051011510125101351014510155101651017510185101951020510215102251023510245102551026510275102851029510305103151032510335103451035510365103751038510395104051041510425104351044510455104651047510485104951050510515105251053510545105551056510575105851059510605106151062510635106451065510665106751068510695107051071510725107351074510755107651077510785107951080510815108251083510845108551086510875108851089510905109151092510935109451095510965109751098510995110051101511025110351104511055110651107511085110951110511115111251113511145111551116511175111851119511205112151122511235112451125511265112751128511295113051131511325113351134511355113651137511385113951140511415114251143511445114551146511475114851149511505115151152511535115451155511565115751158511595116051161511625116351164511655116651167511685116951170511715117251173511745117551176511775117851179511805118151182511835118451185511865118751188511895119051191511925119351194511955119651197511985119951200512015120251203512045120551206512075120851209512105121151212512135121451215512165121751218512195122051221512225122351224512255122651227512285122951230512315123251233512345123551236512375123851239512405124151242512435124451245512465124751248512495125051251512525125351254512555125651257512585125951260512615126251263512645126551266512675126851269512705127151272512735127451275512765127751278512795128051281512825128351284512855128651287512885128951290512915129251293512945129551296512975129851299513005130151302513035130451305513065130751308513095131051311513125131351314513155131651317513185131951320513215132251323513245132551326513275132851329513305133151332513335133451335513365133751338513395134051341513425134351344513455134651347513485134951350513515135251353513545135551356513575135851359513605136151362513635136451365513665136751368513695137051371513725137351374513755137651377513785137951380513815138251383513845138551386513875138851389513905139151392513935139451395513965139751398513995140051401514025140351404514055140651407514085140951410514115141251413514145141551416514175141851419514205142151422514235142451425514265142751428514295143051431514325143351434514355143651437514385143951440514415144251443514445144551446514475144851449514505145151452514535145451455514565145751458514595146051461514625146351464514655146651467514685146951470514715147251473514745147551476514775147851479514805148151482514835148451485514865148751488514895149051491514925149351494514955149651497514985149951500515015150251503515045150551506515075150851509515105151151512515135151451515515165151751518515195152051521515225152351524515255152651527515285152951530515315153251533515345153551536515375153851539515405154151542515435154451545515465154751548515495155051551515525155351554515555155651557515585155951560515615156251563515645156551566515675156851569515705157151572515735157451575515765157751578515795158051581515825158351584515855158651587515885158951590515915159251593515945159551596515975159851599516005160151602516035160451605516065160751608516095161051611516125161351614516155161651617516185161951620516215162251623516245162551626516275162851629516305163151632516335163451635516365163751638516395164051641516425164351644516455164651647516485164951650516515165251653516545165551656516575165851659516605166151662516635166451665516665166751668516695167051671516725167351674516755167651677516785167951680516815168251683516845168551686516875168851689516905169151692516935169451695516965169751698516995170051701517025170351704517055170651707517085170951710517115171251713517145171551716517175171851719517205172151722517235172451725517265172751728517295173051731517325173351734517355173651737517385173951740517415174251743517445174551746517475174851749517505175151752517535175451755517565175751758517595176051761517625176351764517655176651767517685176951770517715177251773517745177551776517775177851779517805178151782517835178451785517865178751788517895179051791517925179351794517955179651797517985179951800518015180251803518045180551806518075180851809518105181151812518135181451815518165181751818518195182051821518225182351824518255182651827518285182951830518315183251833518345183551836518375183851839518405184151842518435184451845518465184751848518495185051851518525185351854518555185651857518585185951860518615186251863518645186551866518675186851869518705187151872518735187451875518765187751878518795188051881518825188351884518855188651887518885188951890518915189251893518945189551896518975189851899519005190151902519035190451905519065190751908519095191051911519125191351914519155191651917519185191951920519215192251923519245192551926519275192851929519305193151932519335193451935519365193751938519395194051941519425194351944519455194651947519485194951950519515195251953519545195551956519575195851959519605196151962519635196451965519665196751968519695197051971519725197351974519755197651977519785197951980519815198251983519845198551986519875198851989519905199151992519935199451995519965199751998519995200052001520025200352004520055200652007520085200952010520115201252013520145201552016520175201852019520205202152022520235202452025520265202752028520295203052031520325203352034520355203652037520385203952040520415204252043520445204552046520475204852049520505205152052520535205452055520565205752058520595206052061520625206352064520655206652067520685206952070520715207252073520745207552076520775207852079520805208152082520835208452085520865208752088520895209052091520925209352094520955209652097520985209952100521015210252103521045210552106521075210852109521105211152112521135211452115521165211752118521195212052121521225212352124521255212652127521285212952130521315213252133521345213552136521375213852139521405214152142521435214452145521465214752148521495215052151521525215352154521555215652157521585215952160521615216252163521645216552166521675216852169521705217152172521735217452175521765217752178521795218052181521825218352184521855218652187521885218952190521915219252193521945219552196521975219852199522005220152202522035220452205522065220752208522095221052211522125221352214522155221652217522185221952220522215222252223522245222552226522275222852229522305223152232522335223452235522365223752238522395224052241522425224352244522455224652247522485224952250522515225252253522545225552256522575225852259522605226152262522635226452265522665226752268522695227052271522725227352274522755227652277522785227952280522815228252283522845228552286522875228852289522905229152292522935229452295522965229752298522995230052301523025230352304523055230652307523085230952310523115231252313523145231552316523175231852319523205232152322523235232452325523265232752328523295233052331523325233352334523355233652337523385233952340523415234252343523445234552346523475234852349523505235152352523535235452355523565235752358523595236052361523625236352364523655236652367523685236952370523715237252373523745237552376523775237852379523805238152382523835238452385523865238752388523895239052391523925239352394523955239652397523985239952400524015240252403524045240552406524075240852409524105241152412524135241452415524165241752418524195242052421524225242352424524255242652427524285242952430524315243252433524345243552436524375243852439524405244152442524435244452445524465244752448524495245052451524525245352454524555245652457524585245952460524615246252463524645246552466524675246852469524705247152472524735247452475524765247752478524795248052481524825248352484524855248652487524885248952490524915249252493524945249552496524975249852499525005250152502525035250452505525065250752508525095251052511525125251352514525155251652517525185251952520525215252252523525245252552526525275252852529525305253152532525335253452535525365253752538525395254052541525425254352544525455254652547525485254952550525515255252553525545255552556525575255852559525605256152562525635256452565525665256752568525695257052571525725257352574525755257652577525785257952580525815258252583525845258552586525875258852589525905259152592525935259452595525965259752598525995260052601526025260352604526055260652607526085260952610526115261252613526145261552616526175261852619526205262152622526235262452625526265262752628526295263052631526325263352634526355263652637526385263952640526415264252643526445264552646526475264852649526505265152652526535265452655526565265752658526595266052661526625266352664526655266652667526685266952670526715267252673526745267552676526775267852679526805268152682526835268452685526865268752688526895269052691526925269352694526955269652697526985269952700527015270252703527045270552706527075270852709527105271152712527135271452715527165271752718527195272052721527225272352724527255272652727527285272952730527315273252733527345273552736527375273852739527405274152742527435274452745527465274752748527495275052751527525275352754527555275652757527585275952760527615276252763527645276552766527675276852769527705277152772527735277452775527765277752778527795278052781527825278352784527855278652787527885278952790527915279252793527945279552796527975279852799528005280152802528035280452805528065280752808528095281052811528125281352814528155281652817528185281952820528215282252823528245282552826528275282852829528305283152832528335283452835528365283752838528395284052841528425284352844528455284652847528485284952850528515285252853528545285552856528575285852859528605286152862528635286452865528665286752868528695287052871528725287352874528755287652877528785287952880528815288252883528845288552886528875288852889528905289152892528935289452895528965289752898528995290052901529025290352904529055290652907529085290952910529115291252913529145291552916529175291852919529205292152922529235292452925529265292752928529295293052931529325293352934529355293652937529385293952940529415294252943529445294552946529475294852949529505295152952529535295452955529565295752958529595296052961529625296352964529655296652967529685296952970529715297252973529745297552976529775297852979529805298152982529835298452985529865298752988529895299052991529925299352994529955299652997529985299953000530015300253003530045300553006530075300853009530105301153012530135301453015530165301753018530195302053021530225302353024530255302653027530285302953030530315303253033530345303553036530375303853039530405304153042530435304453045530465304753048530495305053051530525305353054530555305653057530585305953060530615306253063530645306553066530675306853069530705307153072530735307453075530765307753078530795308053081530825308353084530855308653087530885308953090530915309253093530945309553096530975309853099531005310153102531035310453105531065310753108531095311053111531125311353114531155311653117531185311953120531215312253123531245312553126531275312853129531305313153132531335313453135531365313753138531395314053141531425314353144531455314653147531485314953150531515315253153531545315553156531575315853159531605316153162531635316453165531665316753168531695317053171531725317353174531755317653177531785317953180531815318253183531845318553186531875318853189531905319153192531935319453195531965319753198531995320053201532025320353204532055320653207532085320953210532115321253213532145321553216532175321853219532205322153222532235322453225532265322753228532295323053231532325323353234532355323653237532385323953240532415324253243532445324553246532475324853249532505325153252532535325453255532565325753258532595326053261532625326353264532655326653267532685326953270532715327253273532745327553276532775327853279532805328153282532835328453285532865328753288532895329053291532925329353294532955329653297532985329953300533015330253303533045330553306533075330853309533105331153312533135331453315533165331753318533195332053321533225332353324533255332653327533285332953330533315333253333533345333553336533375333853339533405334153342533435334453345533465334753348533495335053351533525335353354533555335653357533585335953360533615336253363533645336553366533675336853369533705337153372533735337453375533765337753378533795338053381533825338353384533855338653387533885338953390533915339253393533945339553396533975339853399534005340153402534035340453405534065340753408534095341053411534125341353414534155341653417534185341953420534215342253423534245342553426534275342853429534305343153432534335343453435534365343753438534395344053441534425344353444534455344653447534485344953450534515345253453534545345553456534575345853459534605346153462534635346453465534665346753468534695347053471534725347353474534755347653477534785347953480534815348253483534845348553486534875348853489534905349153492534935349453495534965349753498534995350053501535025350353504535055350653507535085350953510535115351253513535145351553516535175351853519535205352153522535235352453525535265352753528535295353053531535325353353534535355353653537535385353953540535415354253543535445354553546535475354853549535505355153552535535355453555535565355753558535595356053561535625356353564535655356653567535685356953570535715357253573535745357553576535775357853579535805358153582535835358453585535865358753588535895359053591535925359353594535955359653597535985359953600536015360253603536045360553606536075360853609536105361153612536135361453615536165361753618536195362053621536225362353624536255362653627536285362953630536315363253633536345363553636536375363853639536405364153642536435364453645536465364753648536495365053651536525365353654536555365653657536585365953660536615366253663536645366553666536675366853669536705367153672536735367453675536765367753678536795368053681536825368353684536855368653687536885368953690536915369253693536945369553696536975369853699537005370153702537035370453705537065370753708537095371053711537125371353714537155371653717537185371953720537215372253723537245372553726537275372853729537305373153732537335373453735537365373753738537395374053741537425374353744537455374653747537485374953750537515375253753537545375553756537575375853759537605376153762537635376453765537665376753768537695377053771537725377353774537755377653777537785377953780537815378253783537845378553786537875378853789537905379153792537935379453795537965379753798537995380053801538025380353804538055380653807538085380953810538115381253813538145381553816538175381853819538205382153822538235382453825538265382753828538295383053831538325383353834538355383653837538385383953840538415384253843538445384553846538475384853849538505385153852538535385453855538565385753858538595386053861538625386353864538655386653867538685386953870538715387253873538745387553876538775387853879538805388153882538835388453885538865388753888538895389053891538925389353894538955389653897538985389953900539015390253903539045390553906539075390853909539105391153912539135391453915539165391753918539195392053921539225392353924539255392653927539285392953930539315393253933539345393553936539375393853939539405394153942539435394453945539465394753948539495395053951539525395353954539555395653957539585395953960539615396253963539645396553966539675396853969539705397153972539735397453975539765397753978539795398053981539825398353984539855398653987539885398953990539915399253993539945399553996539975399853999540005400154002540035400454005540065400754008540095401054011540125401354014540155401654017540185401954020540215402254023540245402554026540275402854029540305403154032540335403454035540365403754038540395404054041540425404354044540455404654047540485404954050540515405254053540545405554056540575405854059540605406154062540635406454065540665406754068540695407054071540725407354074540755407654077540785407954080540815408254083540845408554086540875408854089540905409154092540935409454095540965409754098540995410054101541025410354104541055410654107541085410954110541115411254113541145411554116541175411854119541205412154122541235412454125541265412754128541295413054131541325413354134541355413654137541385413954140541415414254143541445414554146541475414854149541505415154152541535415454155541565415754158541595416054161541625416354164541655416654167541685416954170541715417254173541745417554176541775417854179541805418154182541835418454185541865418754188541895419054191541925419354194541955419654197541985419954200542015420254203542045420554206542075420854209542105421154212542135421454215542165421754218542195422054221542225422354224542255422654227542285422954230542315423254233542345423554236542375423854239542405424154242542435424454245542465424754248542495425054251542525425354254542555425654257542585425954260542615426254263542645426554266542675426854269542705427154272542735427454275542765427754278542795428054281542825428354284542855428654287542885428954290542915429254293542945429554296542975429854299543005430154302543035430454305543065430754308543095431054311543125431354314543155431654317543185431954320543215432254323543245432554326543275432854329543305433154332543335433454335543365433754338543395434054341543425434354344543455434654347543485434954350543515435254353543545435554356543575435854359543605436154362543635436454365543665436754368543695437054371543725437354374543755437654377543785437954380543815438254383543845438554386543875438854389543905439154392543935439454395543965439754398543995440054401544025440354404544055440654407544085440954410544115441254413544145441554416544175441854419544205442154422544235442454425544265442754428544295443054431544325443354434544355443654437544385443954440544415444254443544445444554446544475444854449544505445154452544535445454455544565445754458544595446054461544625446354464544655446654467544685446954470544715447254473544745447554476544775447854479544805448154482544835448454485544865448754488544895449054491544925449354494544955449654497544985449954500545015450254503545045450554506545075450854509545105451154512545135451454515545165451754518545195452054521545225452354524545255452654527545285452954530545315453254533545345453554536545375453854539545405454154542545435454454545545465454754548545495455054551545525455354554545555455654557545585455954560545615456254563545645456554566545675456854569545705457154572545735457454575545765457754578545795458054581545825458354584545855458654587545885458954590545915459254593545945459554596545975459854599546005460154602546035460454605546065460754608546095461054611546125461354614546155461654617546185461954620546215462254623546245462554626546275462854629546305463154632546335463454635546365463754638546395464054641546425464354644546455464654647546485464954650546515465254653546545465554656546575465854659546605466154662546635466454665546665466754668546695467054671546725467354674546755467654677546785467954680546815468254683546845468554686546875468854689546905469154692546935469454695546965469754698546995470054701547025470354704547055470654707547085470954710547115471254713547145471554716547175471854719547205472154722547235472454725547265472754728547295473054731547325473354734547355473654737547385473954740547415474254743547445474554746547475474854749547505475154752547535475454755547565475754758547595476054761547625476354764547655476654767547685476954770547715477254773547745477554776547775477854779547805478154782547835478454785547865478754788547895479054791547925479354794547955479654797547985479954800548015480254803548045480554806548075480854809548105481154812548135481454815548165481754818548195482054821548225482354824548255482654827548285482954830548315483254833548345483554836548375483854839548405484154842548435484454845548465484754848548495485054851548525485354854548555485654857548585485954860548615486254863548645486554866548675486854869548705487154872548735487454875548765487754878548795488054881548825488354884548855488654887548885488954890548915489254893548945489554896548975489854899549005490154902549035490454905549065490754908549095491054911549125491354914549155491654917549185491954920549215492254923549245492554926549275492854929549305493154932549335493454935549365493754938549395494054941549425494354944549455494654947549485494954950549515495254953549545495554956549575495854959549605496154962549635496454965549665496754968549695497054971549725497354974549755497654977549785497954980549815498254983549845498554986549875498854989549905499154992549935499454995549965499754998549995500055001550025500355004550055500655007550085500955010550115501255013550145501555016550175501855019550205502155022550235502455025550265502755028550295503055031550325503355034550355503655037550385503955040550415504255043550445504555046550475504855049550505505155052550535505455055550565505755058550595506055061550625506355064550655506655067550685506955070550715507255073550745507555076550775507855079550805508155082550835508455085550865508755088550895509055091550925509355094550955509655097550985509955100551015510255103551045510555106551075510855109551105511155112551135511455115551165511755118551195512055121551225512355124551255512655127551285512955130551315513255133551345513555136551375513855139551405514155142551435514455145551465514755148551495515055151551525515355154551555515655157551585515955160551615516255163551645516555166551675516855169551705517155172551735517455175551765517755178551795518055181551825518355184551855518655187551885518955190551915519255193551945519555196551975519855199552005520155202552035520455205552065520755208552095521055211552125521355214552155521655217552185521955220552215522255223552245522555226552275522855229552305523155232552335523455235552365523755238552395524055241552425524355244552455524655247552485524955250552515525255253552545525555256552575525855259552605526155262552635526455265552665526755268552695527055271552725527355274552755527655277552785527955280552815528255283552845528555286552875528855289552905529155292552935529455295552965529755298552995530055301553025530355304553055530655307553085530955310553115531255313553145531555316553175531855319553205532155322553235532455325553265532755328553295533055331553325533355334553355533655337553385533955340553415534255343553445534555346553475534855349553505535155352553535535455355553565535755358553595536055361553625536355364553655536655367553685536955370553715537255373553745537555376553775537855379553805538155382553835538455385553865538755388553895539055391553925539355394553955539655397553985539955400554015540255403554045540555406554075540855409554105541155412554135541455415554165541755418554195542055421554225542355424554255542655427554285542955430554315543255433554345543555436554375543855439554405544155442554435544455445554465544755448554495545055451554525545355454554555545655457554585545955460554615546255463554645546555466554675546855469554705547155472554735547455475554765547755478554795548055481554825548355484554855548655487554885548955490554915549255493554945549555496554975549855499555005550155502555035550455505555065550755508555095551055511555125551355514555155551655517555185551955520555215552255523555245552555526555275552855529555305553155532555335553455535555365553755538555395554055541555425554355544555455554655547555485554955550555515555255553555545555555556555575555855559555605556155562555635556455565555665556755568555695557055571555725557355574555755557655577555785557955580555815558255583555845558555586555875558855589555905559155592555935559455595555965559755598555995560055601556025560355604556055560655607556085560955610556115561255613556145561555616556175561855619556205562155622556235562455625556265562755628556295563055631556325563355634556355563655637556385563955640556415564255643556445564555646556475564855649556505565155652556535565455655556565565755658556595566055661556625566355664556655566655667556685566955670556715567255673556745567555676556775567855679556805568155682556835568455685556865568755688556895569055691556925569355694556955569655697556985569955700557015570255703557045570555706557075570855709557105571155712557135571455715557165571755718557195572055721557225572355724557255572655727557285572955730557315573255733557345573555736557375573855739557405574155742557435574455745557465574755748557495575055751557525575355754557555575655757557585575955760557615576255763557645576555766557675576855769557705577155772557735577455775557765577755778557795578055781557825578355784557855578655787557885578955790557915579255793557945579555796557975579855799558005580155802558035580455805558065580755808558095581055811558125581355814558155581655817558185581955820558215582255823558245582555826558275582855829558305583155832558335583455835558365583755838558395584055841558425584355844558455584655847558485584955850558515585255853558545585555856558575585855859558605586155862558635586455865558665586755868558695587055871558725587355874558755587655877558785587955880558815588255883558845588555886558875588855889558905589155892558935589455895558965589755898558995590055901559025590355904559055590655907559085590955910559115591255913559145591555916559175591855919559205592155922559235592455925559265592755928559295593055931559325593355934559355593655937559385593955940559415594255943559445594555946559475594855949559505595155952559535595455955559565595755958559595596055961559625596355964559655596655967559685596955970559715597255973559745597555976559775597855979559805598155982559835598455985559865598755988559895599055991559925599355994559955599655997559985599956000560015600256003560045600556006560075600856009560105601156012560135601456015560165601756018560195602056021560225602356024560255602656027560285602956030560315603256033560345603556036560375603856039560405604156042560435604456045560465604756048560495605056051560525605356054560555605656057560585605956060560615606256063560645606556066560675606856069560705607156072560735607456075560765607756078560795608056081560825608356084560855608656087560885608956090560915609256093560945609556096560975609856099561005610156102561035610456105561065610756108561095611056111561125611356114561155611656117561185611956120561215612256123561245612556126561275612856129561305613156132561335613456135561365613756138561395614056141561425614356144561455614656147561485614956150561515615256153561545615556156561575615856159561605616156162561635616456165561665616756168561695617056171561725617356174561755617656177561785617956180561815618256183561845618556186561875618856189561905619156192561935619456195561965619756198561995620056201562025620356204562055620656207562085620956210562115621256213562145621556216562175621856219562205622156222562235622456225562265622756228562295623056231562325623356234562355623656237562385623956240562415624256243562445624556246562475624856249562505625156252562535625456255562565625756258562595626056261562625626356264562655626656267562685626956270562715627256273562745627556276562775627856279562805628156282562835628456285562865628756288562895629056291562925629356294562955629656297562985629956300563015630256303563045630556306563075630856309563105631156312563135631456315563165631756318563195632056321563225632356324563255632656327563285632956330563315633256333563345633556336563375633856339563405634156342563435634456345563465634756348563495635056351563525635356354563555635656357563585635956360563615636256363563645636556366563675636856369563705637156372563735637456375563765637756378563795638056381563825638356384563855638656387563885638956390563915639256393563945639556396563975639856399564005640156402564035640456405564065640756408564095641056411564125641356414564155641656417564185641956420564215642256423564245642556426564275642856429564305643156432564335643456435564365643756438564395644056441564425644356444564455644656447564485644956450564515645256453564545645556456564575645856459564605646156462564635646456465564665646756468564695647056471564725647356474564755647656477564785647956480564815648256483564845648556486564875648856489564905649156492564935649456495564965649756498564995650056501565025650356504565055650656507565085650956510565115651256513565145651556516565175651856519565205652156522565235652456525565265652756528565295653056531565325653356534565355653656537565385653956540565415654256543565445654556546565475654856549565505655156552565535655456555565565655756558565595656056561565625656356564565655656656567565685656956570565715657256573565745657556576565775657856579565805658156582565835658456585565865658756588565895659056591565925659356594565955659656597565985659956600566015660256603566045660556606566075660856609566105661156612566135661456615566165661756618566195662056621566225662356624566255662656627566285662956630566315663256633566345663556636566375663856639566405664156642566435664456645566465664756648566495665056651566525665356654566555665656657566585665956660566615666256663566645666556666566675666856669566705667156672566735667456675566765667756678566795668056681566825668356684566855668656687566885668956690566915669256693566945669556696566975669856699567005670156702567035670456705567065670756708567095671056711567125671356714567155671656717567185671956720567215672256723567245672556726567275672856729567305673156732567335673456735567365673756738567395674056741567425674356744567455674656747567485674956750567515675256753567545675556756567575675856759567605676156762567635676456765567665676756768567695677056771567725677356774567755677656777567785677956780567815678256783567845678556786567875678856789567905679156792567935679456795567965679756798567995680056801568025680356804568055680656807568085680956810568115681256813568145681556816568175681856819568205682156822568235682456825568265682756828568295683056831568325683356834568355683656837568385683956840568415684256843568445684556846568475684856849568505685156852568535685456855568565685756858568595686056861568625686356864568655686656867568685686956870568715687256873568745687556876568775687856879568805688156882568835688456885568865688756888568895689056891568925689356894568955689656897568985689956900569015690256903569045690556906569075690856909569105691156912569135691456915569165691756918569195692056921569225692356924569255692656927569285692956930569315693256933569345693556936569375693856939569405694156942569435694456945569465694756948569495695056951569525695356954569555695656957569585695956960569615696256963569645696556966569675696856969569705697156972569735697456975569765697756978569795698056981569825698356984569855698656987569885698956990569915699256993569945699556996569975699856999570005700157002570035700457005570065700757008570095701057011570125701357014570155701657017570185701957020570215702257023570245702557026570275702857029570305703157032570335703457035570365703757038570395704057041570425704357044570455704657047570485704957050570515705257053570545705557056570575705857059570605706157062570635706457065570665706757068570695707057071570725707357074570755707657077570785707957080570815708257083570845708557086570875708857089570905709157092570935709457095570965709757098570995710057101571025710357104571055710657107571085710957110571115711257113571145711557116571175711857119571205712157122571235712457125571265712757128571295713057131571325713357134571355713657137571385713957140571415714257143571445714557146571475714857149571505715157152571535715457155571565715757158571595716057161571625716357164571655716657167571685716957170571715717257173571745717557176571775717857179571805718157182571835718457185571865718757188571895719057191571925719357194571955719657197571985719957200572015720257203572045720557206572075720857209572105721157212572135721457215572165721757218572195722057221572225722357224572255722657227572285722957230572315723257233572345723557236572375723857239572405724157242572435724457245572465724757248572495725057251572525725357254572555725657257572585725957260572615726257263572645726557266572675726857269572705727157272572735727457275572765727757278572795728057281572825728357284572855728657287572885728957290572915729257293572945729557296572975729857299573005730157302573035730457305573065730757308573095731057311573125731357314573155731657317573185731957320573215732257323573245732557326573275732857329573305733157332573335733457335573365733757338573395734057341573425734357344573455734657347573485734957350573515735257353573545735557356573575735857359573605736157362573635736457365573665736757368573695737057371573725737357374573755737657377573785737957380573815738257383573845738557386573875738857389573905739157392573935739457395573965739757398573995740057401574025740357404574055740657407574085740957410574115741257413574145741557416574175741857419574205742157422574235742457425574265742757428574295743057431574325743357434574355743657437574385743957440574415744257443574445744557446574475744857449574505745157452574535745457455574565745757458574595746057461574625746357464574655746657467574685746957470574715747257473574745747557476574775747857479574805748157482574835748457485574865748757488574895749057491574925749357494574955749657497574985749957500575015750257503575045750557506575075750857509575105751157512575135751457515575165751757518575195752057521575225752357524575255752657527575285752957530575315753257533575345753557536575375753857539575405754157542575435754457545575465754757548575495755057551575525755357554575555755657557575585755957560575615756257563575645756557566575675756857569575705757157572575735757457575575765757757578575795758057581575825758357584575855758657587575885758957590575915759257593575945759557596575975759857599576005760157602576035760457605576065760757608576095761057611576125761357614576155761657617576185761957620576215762257623576245762557626576275762857629576305763157632576335763457635576365763757638576395764057641576425764357644576455764657647576485764957650576515765257653576545765557656576575765857659576605766157662576635766457665576665766757668576695767057671576725767357674576755767657677576785767957680576815768257683576845768557686576875768857689576905769157692576935769457695576965769757698576995770057701577025770357704577055770657707577085770957710577115771257713577145771557716577175771857719577205772157722577235772457725577265772757728577295773057731577325773357734577355773657737577385773957740577415774257743577445774557746577475774857749577505775157752577535775457755577565775757758577595776057761577625776357764577655776657767577685776957770577715777257773577745777557776577775777857779577805778157782577835778457785577865778757788577895779057791577925779357794577955779657797577985779957800578015780257803578045780557806578075780857809578105781157812578135781457815578165781757818578195782057821578225782357824578255782657827578285782957830578315783257833578345783557836578375783857839578405784157842578435784457845578465784757848578495785057851578525785357854578555785657857578585785957860578615786257863578645786557866578675786857869578705787157872578735787457875578765787757878578795788057881578825788357884578855788657887578885788957890578915789257893578945789557896578975789857899579005790157902579035790457905579065790757908579095791057911579125791357914579155791657917579185791957920579215792257923579245792557926579275792857929579305793157932579335793457935579365793757938579395794057941579425794357944579455794657947579485794957950579515795257953579545795557956579575795857959579605796157962579635796457965579665796757968579695797057971579725797357974579755797657977579785797957980579815798257983579845798557986579875798857989579905799157992579935799457995579965799757998579995800058001580025800358004580055800658007580085800958010580115801258013580145801558016580175801858019580205802158022580235802458025580265802758028580295803058031580325803358034580355803658037580385803958040580415804258043580445804558046580475804858049580505805158052580535805458055580565805758058580595806058061580625806358064580655806658067580685806958070580715807258073580745807558076580775807858079580805808158082580835808458085580865808758088580895809058091580925809358094580955809658097580985809958100581015810258103581045810558106581075810858109581105811158112581135811458115581165811758118581195812058121581225812358124581255812658127581285812958130581315813258133581345813558136581375813858139581405814158142581435814458145581465814758148581495815058151581525815358154581555815658157581585815958160581615816258163581645816558166581675816858169581705817158172581735817458175581765817758178581795818058181581825818358184581855818658187581885818958190581915819258193581945819558196581975819858199582005820158202582035820458205582065820758208582095821058211582125821358214582155821658217582185821958220582215822258223582245822558226582275822858229582305823158232582335823458235582365823758238582395824058241582425824358244582455824658247582485824958250582515825258253582545825558256582575825858259582605826158262582635826458265582665826758268582695827058271582725827358274582755827658277582785827958280582815828258283582845828558286582875828858289582905829158292582935829458295582965829758298582995830058301583025830358304583055830658307583085830958310583115831258313583145831558316583175831858319583205832158322583235832458325583265832758328583295833058331583325833358334583355833658337583385833958340583415834258343583445834558346583475834858349583505835158352583535835458355583565835758358583595836058361583625836358364583655836658367583685836958370583715837258373583745837558376583775837858379583805838158382583835838458385583865838758388583895839058391583925839358394583955839658397583985839958400584015840258403584045840558406584075840858409584105841158412584135841458415584165841758418584195842058421584225842358424584255842658427584285842958430584315843258433584345843558436584375843858439584405844158442584435844458445584465844758448584495845058451584525845358454584555845658457584585845958460584615846258463584645846558466584675846858469584705847158472584735847458475584765847758478584795848058481584825848358484584855848658487584885848958490584915849258493584945849558496584975849858499585005850158502585035850458505585065850758508585095851058511585125851358514585155851658517585185851958520585215852258523585245852558526585275852858529585305853158532585335853458535585365853758538585395854058541585425854358544585455854658547585485854958550585515855258553585545855558556585575855858559585605856158562585635856458565585665856758568585695857058571585725857358574585755857658577585785857958580585815858258583585845858558586585875858858589585905859158592585935859458595585965859758598585995860058601586025860358604586055860658607586085860958610586115861258613586145861558616586175861858619586205862158622586235862458625586265862758628586295863058631586325863358634586355863658637586385863958640586415864258643586445864558646586475864858649586505865158652586535865458655586565865758658586595866058661586625866358664586655866658667586685866958670586715867258673586745867558676586775867858679586805868158682586835868458685586865868758688586895869058691586925869358694586955869658697586985869958700587015870258703587045870558706587075870858709587105871158712587135871458715587165871758718587195872058721587225872358724587255872658727587285872958730587315873258733587345873558736587375873858739587405874158742587435874458745587465874758748587495875058751587525875358754587555875658757587585875958760587615876258763587645876558766587675876858769587705877158772587735877458775587765877758778587795878058781587825878358784587855878658787587885878958790587915879258793587945879558796587975879858799588005880158802588035880458805588065880758808588095881058811588125881358814588155881658817588185881958820588215882258823588245882558826588275882858829588305883158832588335883458835588365883758838588395884058841588425884358844588455884658847588485884958850588515885258853588545885558856588575885858859588605886158862588635886458865588665886758868588695887058871588725887358874588755887658877588785887958880588815888258883588845888558886588875888858889588905889158892588935889458895588965889758898588995890058901589025890358904589055890658907589085890958910589115891258913589145891558916589175891858919589205892158922589235892458925589265892758928589295893058931589325893358934589355893658937589385893958940589415894258943589445894558946589475894858949589505895158952589535895458955589565895758958589595896058961589625896358964589655896658967589685896958970589715897258973589745897558976589775897858979589805898158982589835898458985589865898758988589895899058991589925899358994589955899658997589985899959000590015900259003590045900559006590075900859009590105901159012590135901459015590165901759018590195902059021590225902359024590255902659027590285902959030590315903259033590345903559036590375903859039590405904159042590435904459045590465904759048590495905059051590525905359054590555905659057590585905959060590615906259063590645906559066590675906859069590705907159072590735907459075590765907759078590795908059081590825908359084590855908659087590885908959090590915909259093590945909559096590975909859099591005910159102591035910459105591065910759108591095911059111591125911359114591155911659117591185911959120591215912259123591245912559126591275912859129591305913159132591335913459135591365913759138591395914059141591425914359144591455914659147591485914959150591515915259153591545915559156591575915859159591605916159162591635916459165591665916759168591695917059171591725917359174591755917659177591785917959180591815918259183591845918559186591875918859189591905919159192591935919459195591965919759198591995920059201592025920359204592055920659207592085920959210592115921259213592145921559216592175921859219592205922159222592235922459225592265922759228592295923059231592325923359234592355923659237592385923959240592415924259243592445924559246592475924859249592505925159252592535925459255592565925759258592595926059261592625926359264592655926659267592685926959270592715927259273592745927559276592775927859279592805928159282592835928459285592865928759288592895929059291592925929359294592955929659297592985929959300593015930259303593045930559306593075930859309593105931159312593135931459315593165931759318593195932059321593225932359324593255932659327593285932959330593315933259333593345933559336593375933859339593405934159342593435934459345593465934759348593495935059351593525935359354593555935659357593585935959360593615936259363593645936559366593675936859369593705937159372593735937459375593765937759378593795938059381593825938359384593855938659387593885938959390593915939259393593945939559396593975939859399594005940159402594035940459405594065940759408594095941059411594125941359414594155941659417594185941959420594215942259423594245942559426594275942859429594305943159432594335943459435594365943759438594395944059441594425944359444594455944659447594485944959450594515945259453594545945559456594575945859459594605946159462594635946459465594665946759468594695947059471594725947359474594755947659477594785947959480594815948259483594845948559486594875948859489594905949159492594935949459495594965949759498594995950059501595025950359504595055950659507595085950959510595115951259513595145951559516595175951859519595205952159522595235952459525595265952759528595295953059531595325953359534595355953659537595385953959540595415954259543595445954559546595475954859549595505955159552595535955459555595565955759558595595956059561595625956359564595655956659567595685956959570595715957259573595745957559576595775957859579595805958159582595835958459585595865958759588595895959059591595925959359594595955959659597595985959959600596015960259603596045960559606596075960859609596105961159612596135961459615596165961759618596195962059621596225962359624596255962659627596285962959630596315963259633596345963559636596375963859639596405964159642596435964459645596465964759648596495965059651596525965359654596555965659657596585965959660596615966259663596645966559666596675966859669596705967159672596735967459675596765967759678596795968059681596825968359684596855968659687596885968959690596915969259693596945969559696596975969859699597005970159702597035970459705597065970759708597095971059711597125971359714597155971659717597185971959720597215972259723597245972559726597275972859729597305973159732597335973459735597365973759738597395974059741597425974359744597455974659747597485974959750597515975259753597545975559756597575975859759597605976159762597635976459765597665976759768597695977059771597725977359774597755977659777597785977959780597815978259783597845978559786597875978859789597905979159792597935979459795597965979759798597995980059801598025980359804598055980659807598085980959810598115981259813598145981559816598175981859819598205982159822598235982459825598265982759828598295983059831598325983359834598355983659837598385983959840598415984259843598445984559846598475984859849598505985159852598535985459855598565985759858598595986059861598625986359864598655986659867598685986959870598715987259873598745987559876598775987859879598805988159882598835988459885598865988759888598895989059891598925989359894598955989659897598985989959900599015990259903599045990559906599075990859909599105991159912599135991459915599165991759918599195992059921599225992359924599255992659927599285992959930599315993259933599345993559936599375993859939599405994159942599435994459945599465994759948599495995059951599525995359954599555995659957599585995959960599615996259963599645996559966599675996859969599705997159972599735997459975599765997759978599795998059981599825998359984599855998659987599885998959990599915999259993599945999559996599975999859999600006000160002600036000460005600066000760008600096001060011600126001360014600156001660017600186001960020600216002260023600246002560026600276002860029600306003160032600336003460035600366003760038600396004060041600426004360044600456004660047600486004960050600516005260053600546005560056600576005860059600606006160062600636006460065600666006760068600696007060071600726007360074600756007660077600786007960080600816008260083600846008560086600876008860089600906009160092600936009460095600966009760098600996010060101601026010360104601056010660107601086010960110601116011260113601146011560116601176011860119601206012160122601236012460125601266012760128601296013060131601326013360134601356013660137601386013960140601416014260143601446014560146601476014860149601506015160152601536015460155601566015760158601596016060161601626016360164601656016660167601686016960170601716017260173601746017560176601776017860179601806018160182601836018460185601866018760188601896019060191601926019360194601956019660197601986019960200602016020260203602046020560206602076020860209602106021160212602136021460215602166021760218602196022060221602226022360224602256022660227602286022960230602316023260233602346023560236602376023860239602406024160242602436024460245602466024760248602496025060251602526025360254602556025660257602586025960260602616026260263602646026560266602676026860269602706027160272602736027460275602766027760278602796028060281602826028360284602856028660287602886028960290602916029260293602946029560296602976029860299603006030160302603036030460305603066030760308603096031060311603126031360314603156031660317603186031960320603216032260323603246032560326603276032860329603306033160332603336033460335603366033760338603396034060341603426034360344603456034660347603486034960350603516035260353603546035560356603576035860359603606036160362603636036460365603666036760368603696037060371603726037360374603756037660377603786037960380603816038260383603846038560386603876038860389603906039160392603936039460395603966039760398603996040060401604026040360404604056040660407604086040960410604116041260413604146041560416604176041860419604206042160422604236042460425604266042760428604296043060431604326043360434604356043660437604386043960440604416044260443604446044560446604476044860449604506045160452604536045460455604566045760458604596046060461604626046360464604656046660467604686046960470604716047260473604746047560476604776047860479604806048160482604836048460485604866048760488604896049060491604926049360494604956049660497604986049960500605016050260503605046050560506605076050860509605106051160512605136051460515605166051760518605196052060521605226052360524605256052660527605286052960530605316053260533605346053560536605376053860539605406054160542605436054460545605466054760548605496055060551605526055360554605556055660557605586055960560605616056260563605646056560566605676056860569605706057160572605736057460575605766057760578605796058060581605826058360584605856058660587605886058960590605916059260593605946059560596605976059860599606006060160602606036060460605606066060760608606096061060611606126061360614606156061660617606186061960620606216062260623606246062560626606276062860629606306063160632606336063460635606366063760638606396064060641606426064360644606456064660647606486064960650606516065260653606546065560656606576065860659606606066160662606636066460665606666066760668606696067060671606726067360674606756067660677606786067960680606816068260683606846068560686606876068860689606906069160692606936069460695606966069760698606996070060701607026070360704607056070660707607086070960710607116071260713607146071560716607176071860719607206072160722607236072460725607266072760728607296073060731607326073360734607356073660737607386073960740607416074260743607446074560746607476074860749607506075160752607536075460755607566075760758607596076060761607626076360764607656076660767607686076960770607716077260773607746077560776607776077860779607806078160782607836078460785607866078760788607896079060791607926079360794607956079660797607986079960800608016080260803608046080560806608076080860809608106081160812608136081460815608166081760818608196082060821608226082360824608256082660827608286082960830608316083260833608346083560836608376083860839608406084160842608436084460845608466084760848608496085060851608526085360854608556085660857608586085960860608616086260863608646086560866608676086860869608706087160872608736087460875608766087760878608796088060881608826088360884608856088660887608886088960890608916089260893608946089560896608976089860899609006090160902609036090460905609066090760908609096091060911609126091360914609156091660917609186091960920609216092260923609246092560926609276092860929609306093160932609336093460935609366093760938609396094060941609426094360944609456094660947609486094960950609516095260953609546095560956609576095860959609606096160962609636096460965609666096760968609696097060971609726097360974609756097660977609786097960980609816098260983609846098560986609876098860989609906099160992609936099460995609966099760998609996100061001610026100361004610056100661007610086100961010610116101261013610146101561016610176101861019610206102161022610236102461025610266102761028610296103061031610326103361034610356103661037610386103961040610416104261043610446104561046610476104861049610506105161052610536105461055610566105761058610596106061061610626106361064610656106661067610686106961070610716107261073610746107561076610776107861079610806108161082610836108461085610866108761088610896109061091610926109361094610956109661097610986109961100611016110261103611046110561106611076110861109611106111161112611136111461115611166111761118611196112061121611226112361124611256112661127611286112961130611316113261133611346113561136611376113861139611406114161142611436114461145611466114761148611496115061151611526115361154611556115661157611586115961160611616116261163611646116561166611676116861169611706117161172611736117461175611766117761178611796118061181611826118361184611856118661187611886118961190611916119261193611946119561196611976119861199612006120161202612036120461205612066120761208612096121061211612126121361214612156121661217612186121961220612216122261223612246122561226612276122861229612306123161232612336123461235612366123761238612396124061241612426124361244612456124661247612486124961250612516125261253612546125561256612576125861259612606126161262612636126461265612666126761268612696127061271612726127361274612756127661277612786127961280612816128261283612846128561286612876128861289612906129161292612936129461295612966129761298612996130061301613026130361304613056130661307613086130961310613116131261313613146131561316613176131861319613206132161322613236132461325613266132761328613296133061331613326133361334613356133661337613386133961340613416134261343613446134561346613476134861349613506135161352613536135461355613566135761358613596136061361613626136361364613656136661367613686136961370613716137261373613746137561376613776137861379613806138161382613836138461385613866138761388613896139061391613926139361394613956139661397613986139961400614016140261403614046140561406614076140861409614106141161412614136141461415614166141761418614196142061421614226142361424614256142661427614286142961430614316143261433614346143561436614376143861439614406144161442614436144461445614466144761448614496145061451614526145361454614556145661457614586145961460614616146261463614646146561466614676146861469614706147161472614736147461475614766147761478614796148061481614826148361484614856148661487614886148961490614916149261493614946149561496614976149861499615006150161502615036150461505615066150761508615096151061511615126151361514615156151661517615186151961520615216152261523615246152561526615276152861529615306153161532615336153461535615366153761538615396154061541615426154361544615456154661547615486154961550615516155261553615546155561556615576155861559615606156161562615636156461565615666156761568615696157061571615726157361574615756157661577615786157961580615816158261583615846158561586615876158861589615906159161592615936159461595615966159761598615996160061601616026160361604616056160661607616086160961610616116161261613616146161561616616176161861619616206162161622616236162461625616266162761628616296163061631616326163361634616356163661637616386163961640616416164261643616446164561646616476164861649616506165161652616536165461655616566165761658616596166061661616626166361664616656166661667616686166961670616716167261673616746167561676616776167861679616806168161682616836168461685616866168761688616896169061691616926169361694616956169661697616986169961700617016170261703617046170561706617076170861709617106171161712617136171461715617166171761718617196172061721617226172361724617256172661727617286172961730617316173261733617346173561736617376173861739617406174161742617436174461745617466174761748617496175061751617526175361754617556175661757617586175961760617616176261763617646176561766617676176861769617706177161772617736177461775617766177761778617796178061781617826178361784617856178661787617886178961790617916179261793617946179561796617976179861799618006180161802618036180461805618066180761808618096181061811618126181361814618156181661817618186181961820618216182261823618246182561826618276182861829618306183161832618336183461835618366183761838618396184061841618426184361844618456184661847618486184961850618516185261853618546185561856618576185861859618606186161862618636186461865618666186761868618696187061871618726187361874618756187661877618786187961880618816188261883618846188561886618876188861889618906189161892618936189461895618966189761898618996190061901619026190361904619056190661907619086190961910619116191261913619146191561916619176191861919619206192161922619236192461925619266192761928619296193061931619326193361934619356193661937619386193961940619416194261943619446194561946619476194861949619506195161952619536195461955619566195761958619596196061961619626196361964619656196661967619686196961970619716197261973619746197561976619776197861979619806198161982619836198461985619866198761988619896199061991619926199361994619956199661997619986199962000620016200262003620046200562006620076200862009620106201162012620136201462015620166201762018620196202062021620226202362024620256202662027620286202962030620316203262033620346203562036620376203862039620406204162042620436204462045620466204762048620496205062051620526205362054620556205662057620586205962060620616206262063620646206562066620676206862069620706207162072620736207462075620766207762078620796208062081620826208362084620856208662087620886208962090620916209262093620946209562096620976209862099621006210162102621036210462105621066210762108621096211062111621126211362114621156211662117621186211962120621216212262123621246212562126621276212862129621306213162132621336213462135621366213762138621396214062141621426214362144621456214662147621486214962150621516215262153621546215562156621576215862159621606216162162621636216462165621666216762168621696217062171621726217362174621756217662177621786217962180621816218262183621846218562186621876218862189621906219162192621936219462195621966219762198621996220062201622026220362204622056220662207622086220962210622116221262213622146221562216622176221862219622206222162222622236222462225622266222762228622296223062231622326223362234622356223662237622386223962240622416224262243622446224562246622476224862249622506225162252622536225462255622566225762258622596226062261622626226362264622656226662267622686226962270622716227262273622746227562276622776227862279622806228162282622836228462285622866228762288622896229062291622926229362294622956229662297622986229962300623016230262303623046230562306623076230862309623106231162312623136231462315623166231762318623196232062321623226232362324623256232662327623286232962330623316233262333623346233562336623376233862339623406234162342623436234462345623466234762348623496235062351623526235362354623556235662357623586235962360623616236262363623646236562366623676236862369623706237162372623736237462375623766237762378623796238062381623826238362384623856238662387623886238962390623916239262393623946239562396623976239862399624006240162402624036240462405624066240762408624096241062411624126241362414624156241662417624186241962420624216242262423624246242562426624276242862429624306243162432624336243462435624366243762438624396244062441624426244362444624456244662447624486244962450624516245262453624546245562456624576245862459624606246162462624636246462465624666246762468624696247062471624726247362474624756247662477624786247962480624816248262483624846248562486624876248862489624906249162492624936249462495624966249762498624996250062501625026250362504625056250662507625086250962510625116251262513625146251562516625176251862519625206252162522625236252462525625266252762528625296253062531625326253362534625356253662537625386253962540625416254262543625446254562546625476254862549625506255162552625536255462555625566255762558625596256062561625626256362564625656256662567625686256962570625716257262573625746257562576625776257862579625806258162582625836258462585625866258762588625896259062591625926259362594625956259662597625986259962600626016260262603626046260562606626076260862609626106261162612626136261462615626166261762618626196262062621626226262362624626256262662627626286262962630626316263262633626346263562636626376263862639626406264162642626436264462645626466264762648626496265062651626526265362654626556265662657626586265962660626616266262663626646266562666626676266862669626706267162672626736267462675626766267762678626796268062681626826268362684626856268662687626886268962690626916269262693626946269562696626976269862699627006270162702627036270462705627066270762708627096271062711627126271362714627156271662717627186271962720627216272262723627246272562726627276272862729627306273162732627336273462735627366273762738627396274062741627426274362744627456274662747627486274962750627516275262753627546275562756627576275862759627606276162762627636276462765627666276762768627696277062771627726277362774627756277662777627786277962780627816278262783627846278562786627876278862789627906279162792627936279462795627966279762798627996280062801628026280362804628056280662807628086280962810628116281262813628146281562816628176281862819628206282162822628236282462825628266282762828628296283062831628326283362834628356283662837628386283962840628416284262843628446284562846628476284862849628506285162852628536285462855628566285762858628596286062861628626286362864628656286662867628686286962870628716287262873628746287562876628776287862879628806288162882628836288462885628866288762888628896289062891628926289362894628956289662897628986289962900629016290262903629046290562906629076290862909629106291162912629136291462915629166291762918629196292062921629226292362924629256292662927629286292962930629316293262933629346293562936629376293862939629406294162942629436294462945629466294762948629496295062951629526295362954629556295662957629586295962960629616296262963629646296562966629676296862969629706297162972629736297462975629766297762978629796298062981629826298362984629856298662987629886298962990629916299262993629946299562996629976299862999630006300163002630036300463005630066300763008630096301063011630126301363014630156301663017630186301963020630216302263023630246302563026630276302863029630306303163032630336303463035630366303763038630396304063041630426304363044630456304663047630486304963050630516305263053630546305563056630576305863059630606306163062630636306463065630666306763068630696307063071630726307363074630756307663077630786307963080630816308263083630846308563086630876308863089630906309163092630936309463095630966309763098630996310063101631026310363104631056310663107631086310963110631116311263113631146311563116631176311863119631206312163122631236312463125631266312763128631296313063131631326313363134631356313663137631386313963140631416314263143631446314563146631476314863149631506315163152631536315463155631566315763158631596316063161631626316363164631656316663167631686316963170631716317263173631746317563176631776317863179631806318163182631836318463185631866318763188631896319063191631926319363194631956319663197631986319963200632016320263203632046320563206632076320863209632106321163212632136321463215632166321763218632196322063221632226322363224632256322663227632286322963230632316323263233632346323563236632376323863239632406324163242632436324463245632466324763248632496325063251632526325363254632556325663257632586325963260632616326263263632646326563266632676326863269632706327163272632736327463275632766327763278632796328063281632826328363284632856328663287632886328963290632916329263293632946329563296632976329863299633006330163302633036330463305633066330763308633096331063311633126331363314633156331663317633186331963320633216332263323633246332563326633276332863329633306333163332633336333463335633366333763338633396334063341633426334363344633456334663347633486334963350633516335263353633546335563356633576335863359633606336163362633636336463365633666336763368633696337063371633726337363374633756337663377633786337963380633816338263383633846338563386633876338863389633906339163392633936339463395633966339763398633996340063401634026340363404634056340663407634086340963410634116341263413634146341563416634176341863419634206342163422634236342463425634266342763428634296343063431634326343363434634356343663437634386343963440634416344263443634446344563446634476344863449634506345163452634536345463455634566345763458634596346063461634626346363464634656346663467634686346963470634716347263473634746347563476634776347863479634806348163482634836348463485634866348763488634896349063491634926349363494634956349663497634986349963500635016350263503635046350563506635076350863509635106351163512635136351463515635166351763518635196352063521635226352363524635256352663527635286352963530635316353263533635346353563536635376353863539635406354163542635436354463545635466354763548635496355063551635526355363554635556355663557635586355963560635616356263563635646356563566635676356863569635706357163572635736357463575635766357763578635796358063581635826358363584635856358663587635886358963590635916359263593635946359563596635976359863599636006360163602636036360463605636066360763608636096361063611636126361363614636156361663617636186361963620636216362263623636246362563626636276362863629636306363163632636336363463635636366363763638636396364063641636426364363644636456364663647636486364963650636516365263653636546365563656636576365863659636606366163662636636366463665636666366763668636696367063671636726367363674636756367663677636786367963680636816368263683636846368563686636876368863689636906369163692636936369463695636966369763698636996370063701637026370363704637056370663707637086370963710637116371263713637146371563716637176371863719637206372163722637236372463725637266372763728637296373063731637326373363734637356373663737637386373963740637416374263743637446374563746637476374863749637506375163752637536375463755637566375763758637596376063761637626376363764637656376663767637686376963770637716377263773637746377563776637776377863779637806378163782637836378463785637866378763788637896379063791637926379363794637956379663797637986379963800638016380263803638046380563806638076380863809638106381163812638136381463815638166381763818638196382063821638226382363824638256382663827638286382963830638316383263833638346383563836638376383863839638406384163842638436384463845638466384763848638496385063851638526385363854638556385663857638586385963860638616386263863638646386563866638676386863869638706387163872638736387463875638766387763878638796388063881638826388363884638856388663887638886388963890638916389263893638946389563896638976389863899639006390163902639036390463905639066390763908639096391063911639126391363914639156391663917639186391963920639216392263923639246392563926639276392863929639306393163932639336393463935639366393763938639396394063941639426394363944639456394663947639486394963950639516395263953639546395563956639576395863959639606396163962639636396463965639666396763968639696397063971639726397363974639756397663977639786397963980639816398263983639846398563986639876398863989639906399163992639936399463995639966399763998639996400064001640026400364004640056400664007640086400964010640116401264013640146401564016640176401864019640206402164022640236402464025640266402764028640296403064031640326403364034640356403664037640386403964040640416404264043640446404564046640476404864049640506405164052640536405464055640566405764058640596406064061640626406364064640656406664067640686406964070640716407264073640746407564076640776407864079640806408164082640836408464085640866408764088640896409064091640926409364094640956409664097640986409964100641016410264103641046410564106641076410864109641106411164112641136411464115641166411764118641196412064121641226412364124641256412664127641286412964130641316413264133641346413564136641376413864139641406414164142641436414464145641466414764148641496415064151641526415364154641556415664157641586415964160641616416264163641646416564166641676416864169641706417164172641736417464175641766417764178641796418064181641826418364184641856418664187641886418964190641916419264193641946419564196641976419864199642006420164202642036420464205642066420764208642096421064211642126421364214642156421664217642186421964220642216422264223642246422564226642276422864229642306423164232642336423464235642366423764238642396424064241642426424364244642456424664247642486424964250642516425264253642546425564256642576425864259642606426164262642636426464265642666426764268642696427064271642726427364274642756427664277642786427964280642816428264283642846428564286642876428864289642906429164292642936429464295642966429764298642996430064301643026430364304643056430664307643086430964310643116431264313643146431564316643176431864319643206432164322643236432464325643266432764328643296433064331643326433364334643356433664337643386433964340643416434264343643446434564346643476434864349643506435164352643536435464355643566435764358643596436064361643626436364364643656436664367643686436964370643716437264373643746437564376643776437864379643806438164382643836438464385643866438764388643896439064391643926439364394643956439664397643986439964400644016440264403644046440564406644076440864409644106441164412644136441464415644166441764418644196442064421644226442364424644256442664427644286442964430644316443264433644346443564436644376443864439644406444164442644436444464445644466444764448644496445064451644526445364454644556445664457644586445964460644616446264463644646446564466644676446864469644706447164472644736447464475644766447764478644796448064481644826448364484644856448664487644886448964490644916449264493644946449564496644976449864499645006450164502645036450464505645066450764508645096451064511645126451364514645156451664517645186451964520645216452264523645246452564526645276452864529645306453164532645336453464535645366453764538645396454064541645426454364544645456454664547645486454964550645516455264553645546455564556645576455864559645606456164562645636456464565645666456764568645696457064571645726457364574645756457664577645786457964580645816458264583645846458564586645876458864589645906459164592645936459464595645966459764598645996460064601646026460364604646056460664607646086460964610646116461264613646146461564616646176461864619646206462164622646236462464625646266462764628646296463064631646326463364634646356463664637646386463964640646416464264643646446464564646646476464864649646506465164652646536465464655646566465764658646596466064661646626466364664646656466664667646686466964670646716467264673646746467564676646776467864679646806468164682646836468464685646866468764688646896469064691646926469364694646956469664697646986469964700647016470264703647046470564706647076470864709647106471164712647136471464715647166471764718647196472064721647226472364724647256472664727647286472964730647316473264733647346473564736647376473864739647406474164742647436474464745647466474764748647496475064751647526475364754647556475664757647586475964760647616476264763647646476564766647676476864769647706477164772647736477464775647766477764778647796478064781647826478364784647856478664787647886478964790647916479264793647946479564796647976479864799648006480164802648036480464805648066480764808648096481064811648126481364814648156481664817648186481964820648216482264823648246482564826648276482864829648306483164832648336483464835648366483764838648396484064841648426484364844648456484664847648486484964850648516485264853648546485564856648576485864859648606486164862648636486464865648666486764868648696487064871648726487364874648756487664877648786487964880648816488264883648846488564886648876488864889648906489164892648936489464895648966489764898648996490064901649026490364904649056490664907649086490964910649116491264913649146491564916649176491864919649206492164922649236492464925649266492764928649296493064931649326493364934649356493664937649386493964940649416494264943649446494564946649476494864949649506495164952649536495464955649566495764958649596496064961649626496364964649656496664967649686496964970649716497264973649746497564976649776497864979649806498164982649836498464985649866498764988649896499064991649926499364994649956499664997649986499965000650016500265003650046500565006650076500865009650106501165012650136501465015650166501765018650196502065021650226502365024650256502665027650286502965030650316503265033650346503565036650376503865039650406504165042650436504465045650466504765048650496505065051650526505365054650556505665057650586505965060650616506265063650646506565066650676506865069650706507165072650736507465075650766507765078650796508065081650826508365084650856508665087650886508965090650916509265093650946509565096650976509865099651006510165102651036510465105651066510765108651096511065111651126511365114651156511665117651186511965120651216512265123651246512565126651276512865129651306513165132651336513465135651366513765138651396514065141651426514365144651456514665147651486514965150651516515265153651546515565156651576515865159651606516165162651636516465165651666516765168651696517065171651726517365174651756517665177651786517965180651816518265183651846518565186651876518865189651906519165192651936519465195651966519765198651996520065201652026520365204652056520665207652086520965210652116521265213652146521565216652176521865219652206522165222652236522465225652266522765228652296523065231652326523365234652356523665237652386523965240652416524265243652446524565246652476524865249652506525165252652536525465255652566525765258652596526065261652626526365264652656526665267652686526965270652716527265273652746527565276652776527865279652806528165282652836528465285652866528765288652896529065291652926529365294652956529665297652986529965300653016530265303653046530565306653076530865309653106531165312653136531465315653166531765318653196532065321653226532365324653256532665327653286532965330653316533265333653346533565336653376533865339653406534165342653436534465345653466534765348653496535065351653526535365354653556535665357653586535965360653616536265363653646536565366653676536865369653706537165372653736537465375653766537765378653796538065381653826538365384653856538665387653886538965390653916539265393653946539565396653976539865399654006540165402654036540465405654066540765408654096541065411654126541365414654156541665417654186541965420654216542265423654246542565426654276542865429654306543165432654336543465435654366543765438654396544065441654426544365444654456544665447654486544965450654516545265453654546545565456654576545865459654606546165462654636546465465654666546765468654696547065471654726547365474654756547665477654786547965480654816548265483654846548565486654876548865489654906549165492654936549465495654966549765498654996550065501655026550365504655056550665507655086550965510655116551265513655146551565516655176551865519655206552165522655236552465525655266552765528655296553065531655326553365534655356553665537655386553965540655416554265543655446554565546655476554865549655506555165552655536555465555655566555765558655596556065561655626556365564655656556665567655686556965570655716557265573655746557565576655776557865579655806558165582655836558465585655866558765588655896559065591655926559365594655956559665597655986559965600656016560265603656046560565606656076560865609656106561165612656136561465615656166561765618656196562065621656226562365624656256562665627656286562965630656316563265633656346563565636656376563865639656406564165642656436564465645656466564765648656496565065651656526565365654656556565665657656586565965660656616566265663656646566565666656676566865669656706567165672656736567465675656766567765678656796568065681656826568365684656856568665687656886568965690656916569265693656946569565696656976569865699657006570165702657036570465705657066570765708657096571065711657126571365714657156571665717657186571965720657216572265723657246572565726657276572865729657306573165732657336573465735657366573765738657396574065741657426574365744657456574665747657486574965750657516575265753657546575565756657576575865759657606576165762657636576465765657666576765768657696577065771657726577365774657756577665777657786577965780657816578265783657846578565786657876578865789657906579165792657936579465795657966579765798657996580065801658026580365804658056580665807658086580965810658116581265813658146581565816658176581865819658206582165822658236582465825658266582765828658296583065831658326583365834658356583665837658386583965840658416584265843658446584565846658476584865849658506585165852658536585465855658566585765858658596586065861658626586365864658656586665867658686586965870658716587265873658746587565876658776587865879658806588165882658836588465885658866588765888658896589065891658926589365894658956589665897658986589965900659016590265903659046590565906659076590865909659106591165912659136591465915659166591765918659196592065921659226592365924659256592665927659286592965930659316593265933659346593565936659376593865939659406594165942659436594465945659466594765948659496595065951659526595365954659556595665957659586595965960659616596265963659646596565966659676596865969659706597165972659736597465975659766597765978659796598065981659826598365984659856598665987659886598965990659916599265993659946599565996659976599865999660006600166002660036600466005660066600766008660096601066011660126601366014660156601666017660186601966020660216602266023660246602566026660276602866029660306603166032660336603466035660366603766038660396604066041660426604366044660456604666047660486604966050660516605266053660546605566056660576605866059660606606166062660636606466065660666606766068660696607066071660726607366074660756607666077660786607966080660816608266083660846608566086660876608866089660906609166092660936609466095660966609766098660996610066101661026610366104661056610666107661086610966110661116611266113661146611566116661176611866119661206612166122661236612466125661266612766128661296613066131661326613366134661356613666137661386613966140661416614266143661446614566146661476614866149661506615166152661536615466155661566615766158661596616066161661626616366164661656616666167661686616966170661716617266173661746617566176661776617866179661806618166182661836618466185661866618766188661896619066191661926619366194661956619666197661986619966200662016620266203662046620566206662076620866209662106621166212662136621466215662166621766218662196622066221662226622366224662256622666227662286622966230662316623266233662346623566236662376623866239662406624166242662436624466245662466624766248662496625066251662526625366254662556625666257662586625966260662616626266263662646626566266662676626866269662706627166272662736627466275662766627766278662796628066281662826628366284662856628666287662886628966290662916629266293662946629566296662976629866299663006630166302663036630466305663066630766308663096631066311663126631366314663156631666317663186631966320663216632266323663246632566326663276632866329663306633166332663336633466335663366633766338663396634066341663426634366344663456634666347663486634966350663516635266353663546635566356663576635866359663606636166362663636636466365663666636766368663696637066371663726637366374663756637666377663786637966380663816638266383663846638566386663876638866389663906639166392663936639466395663966639766398663996640066401664026640366404664056640666407664086640966410664116641266413664146641566416664176641866419664206642166422664236642466425664266642766428664296643066431664326643366434664356643666437664386643966440664416644266443664446644566446664476644866449664506645166452664536645466455664566645766458664596646066461664626646366464664656646666467664686646966470664716647266473664746647566476664776647866479664806648166482664836648466485664866648766488664896649066491664926649366494664956649666497664986649966500665016650266503665046650566506665076650866509665106651166512665136651466515665166651766518665196652066521665226652366524665256652666527665286652966530665316653266533665346653566536665376653866539665406654166542665436654466545665466654766548665496655066551665526655366554665556655666557665586655966560665616656266563665646656566566665676656866569665706657166572665736657466575665766657766578665796658066581665826658366584665856658666587665886658966590665916659266593665946659566596665976659866599666006660166602666036660466605666066660766608666096661066611666126661366614666156661666617666186661966620666216662266623666246662566626666276662866629666306663166632666336663466635666366663766638666396664066641666426664366644666456664666647666486664966650666516665266653666546665566656666576665866659666606666166662666636666466665666666666766668666696667066671666726667366674666756667666677666786667966680666816668266683666846668566686666876668866689666906669166692666936669466695666966669766698666996670066701667026670366704667056670666707667086670966710667116671266713667146671566716667176671866719667206672166722667236672466725667266672766728667296673066731667326673366734667356673666737667386673966740667416674266743667446674566746667476674866749667506675166752667536675466755667566675766758667596676066761667626676366764667656676666767667686676966770667716677266773667746677566776667776677866779667806678166782667836678466785667866678766788667896679066791667926679366794667956679666797667986679966800668016680266803668046680566806668076680866809668106681166812668136681466815668166681766818668196682066821668226682366824668256682666827668286682966830668316683266833668346683566836668376683866839668406684166842668436684466845668466684766848668496685066851668526685366854668556685666857668586685966860668616686266863668646686566866668676686866869668706687166872668736687466875668766687766878668796688066881668826688366884668856688666887668886688966890668916689266893668946689566896668976689866899669006690166902669036690466905669066690766908669096691066911669126691366914669156691666917669186691966920669216692266923669246692566926669276692866929669306693166932669336693466935669366693766938669396694066941669426694366944669456694666947669486694966950669516695266953669546695566956669576695866959669606696166962669636696466965669666696766968669696697066971669726697366974669756697666977669786697966980669816698266983669846698566986669876698866989669906699166992669936699466995669966699766998669996700067001670026700367004670056700667007670086700967010670116701267013670146701567016670176701867019670206702167022670236702467025670266702767028670296703067031670326703367034670356703667037670386703967040670416704267043670446704567046670476704867049670506705167052670536705467055670566705767058670596706067061670626706367064670656706667067670686706967070670716707267073670746707567076670776707867079670806708167082670836708467085670866708767088670896709067091670926709367094670956709667097670986709967100671016710267103671046710567106671076710867109671106711167112671136711467115671166711767118671196712067121671226712367124671256712667127671286712967130671316713267133671346713567136671376713867139671406714167142671436714467145671466714767148671496715067151671526715367154671556715667157671586715967160671616716267163671646716567166671676716867169671706717167172671736717467175671766717767178671796718067181671826718367184671856718667187671886718967190671916719267193671946719567196671976719867199672006720167202672036720467205672066720767208672096721067211672126721367214672156721667217672186721967220672216722267223672246722567226672276722867229672306723167232672336723467235672366723767238672396724067241672426724367244672456724667247672486724967250672516725267253672546725567256672576725867259672606726167262672636726467265672666726767268672696727067271672726727367274672756727667277672786727967280672816728267283672846728567286672876728867289672906729167292672936729467295672966729767298672996730067301673026730367304673056730667307673086730967310673116731267313673146731567316673176731867319673206732167322673236732467325673266732767328673296733067331673326733367334673356733667337673386733967340673416734267343673446734567346673476734867349673506735167352673536735467355673566735767358673596736067361673626736367364673656736667367673686736967370673716737267373673746737567376673776737867379673806738167382673836738467385673866738767388673896739067391673926739367394673956739667397673986739967400674016740267403674046740567406674076740867409674106741167412674136741467415674166741767418674196742067421674226742367424674256742667427674286742967430674316743267433674346743567436674376743867439674406744167442674436744467445674466744767448674496745067451674526745367454674556745667457674586745967460674616746267463674646746567466674676746867469674706747167472674736747467475674766747767478674796748067481674826748367484674856748667487674886748967490674916749267493674946749567496674976749867499675006750167502675036750467505675066750767508675096751067511675126751367514675156751667517675186751967520675216752267523675246752567526675276752867529675306753167532675336753467535675366753767538675396754067541675426754367544675456754667547675486754967550675516755267553675546755567556675576755867559675606756167562675636756467565675666756767568675696757067571675726757367574675756757667577675786757967580675816758267583675846758567586675876758867589675906759167592675936759467595675966759767598675996760067601676026760367604676056760667607676086760967610676116761267613676146761567616676176761867619676206762167622676236762467625676266762767628676296763067631676326763367634676356763667637676386763967640676416764267643676446764567646676476764867649676506765167652676536765467655676566765767658676596766067661676626766367664676656766667667676686766967670676716767267673676746767567676676776767867679676806768167682676836768467685676866768767688676896769067691676926769367694676956769667697676986769967700677016770267703677046770567706677076770867709677106771167712677136771467715677166771767718677196772067721677226772367724677256772667727677286772967730677316773267733677346773567736677376773867739677406774167742677436774467745677466774767748677496775067751677526775367754677556775667757677586775967760677616776267763677646776567766677676776867769677706777167772677736777467775677766777767778677796778067781677826778367784677856778667787677886778967790677916779267793677946779567796677976779867799678006780167802678036780467805678066780767808678096781067811678126781367814678156781667817678186781967820678216782267823678246782567826678276782867829678306783167832678336783467835678366783767838678396784067841678426784367844678456784667847678486784967850678516785267853678546785567856678576785867859678606786167862678636786467865678666786767868678696787067871678726787367874678756787667877678786787967880678816788267883678846788567886678876788867889678906789167892678936789467895678966789767898678996790067901679026790367904679056790667907679086790967910679116791267913679146791567916679176791867919679206792167922679236792467925679266792767928679296793067931679326793367934679356793667937679386793967940679416794267943679446794567946679476794867949679506795167952679536795467955679566795767958679596796067961679626796367964679656796667967679686796967970679716797267973679746797567976679776797867979679806798167982679836798467985679866798767988679896799067991679926799367994679956799667997679986799968000680016800268003680046800568006680076800868009680106801168012680136801468015680166801768018680196802068021680226802368024680256802668027680286802968030680316803268033680346803568036680376803868039680406804168042680436804468045680466804768048680496805068051680526805368054680556805668057680586805968060680616806268063680646806568066680676806868069680706807168072680736807468075680766807768078680796808068081680826808368084680856808668087680886808968090680916809268093680946809568096680976809868099681006810168102681036810468105681066810768108681096811068111681126811368114681156811668117681186811968120681216812268123681246812568126681276812868129681306813168132681336813468135681366813768138681396814068141681426814368144681456814668147681486814968150681516815268153681546815568156681576815868159681606816168162681636816468165681666816768168681696817068171681726817368174681756817668177681786817968180681816818268183681846818568186681876818868189681906819168192681936819468195681966819768198681996820068201682026820368204682056820668207682086820968210682116821268213682146821568216682176821868219682206822168222682236822468225682266822768228682296823068231682326823368234682356823668237682386823968240682416824268243682446824568246682476824868249682506825168252682536825468255682566825768258682596826068261682626826368264682656826668267682686826968270682716827268273682746827568276682776827868279682806828168282682836828468285682866828768288682896829068291682926829368294682956829668297682986829968300683016830268303683046830568306683076830868309683106831168312683136831468315683166831768318683196832068321683226832368324683256832668327683286832968330683316833268333683346833568336683376833868339683406834168342683436834468345683466834768348683496835068351683526835368354683556835668357683586835968360683616836268363683646836568366683676836868369683706837168372683736837468375683766837768378683796838068381683826838368384683856838668387683886838968390683916839268393683946839568396683976839868399684006840168402684036840468405684066840768408684096841068411684126841368414684156841668417684186841968420684216842268423684246842568426684276842868429684306843168432684336843468435684366843768438684396844068441684426844368444684456844668447684486844968450684516845268453684546845568456684576845868459684606846168462684636846468465684666846768468684696847068471684726847368474684756847668477684786847968480684816848268483684846848568486684876848868489684906849168492684936849468495684966849768498684996850068501685026850368504685056850668507685086850968510685116851268513685146851568516685176851868519685206852168522685236852468525685266852768528685296853068531685326853368534685356853668537685386853968540685416854268543685446854568546685476854868549685506855168552685536855468555685566855768558685596856068561685626856368564685656856668567685686856968570685716857268573685746857568576685776857868579685806858168582685836858468585685866858768588685896859068591685926859368594685956859668597685986859968600686016860268603686046860568606686076860868609686106861168612686136861468615686166861768618686196862068621686226862368624686256862668627686286862968630686316863268633686346863568636686376863868639686406864168642686436864468645686466864768648686496865068651686526865368654686556865668657686586865968660686616866268663686646866568666686676866868669686706867168672686736867468675686766867768678686796868068681686826868368684686856868668687686886868968690686916869268693686946869568696686976869868699687006870168702687036870468705687066870768708687096871068711687126871368714687156871668717687186871968720687216872268723687246872568726687276872868729687306873168732687336873468735687366873768738687396874068741687426874368744687456874668747687486874968750687516875268753687546875568756687576875868759687606876168762687636876468765687666876768768687696877068771687726877368774687756877668777687786877968780687816878268783687846878568786687876878868789687906879168792687936879468795687966879768798687996880068801688026880368804688056880668807688086880968810688116881268813688146881568816688176881868819688206882168822688236882468825688266882768828688296883068831688326883368834688356883668837688386883968840688416884268843688446884568846688476884868849688506885168852688536885468855688566885768858688596886068861688626886368864688656886668867688686886968870688716887268873688746887568876688776887868879688806888168882688836888468885688866888768888688896889068891688926889368894688956889668897688986889968900689016890268903689046890568906689076890868909689106891168912689136891468915689166891768918689196892068921689226892368924689256892668927689286892968930689316893268933689346893568936689376893868939689406894168942689436894468945689466894768948689496895068951689526895368954689556895668957689586895968960689616896268963689646896568966689676896868969689706897168972689736897468975689766897768978689796898068981689826898368984689856898668987689886898968990689916899268993689946899568996689976899868999690006900169002690036900469005690066900769008690096901069011690126901369014690156901669017690186901969020690216902269023690246902569026690276902869029690306903169032690336903469035690366903769038690396904069041690426904369044690456904669047690486904969050690516905269053690546905569056690576905869059690606906169062690636906469065690666906769068690696907069071690726907369074690756907669077690786907969080690816908269083690846908569086690876908869089690906909169092690936909469095690966909769098690996910069101691026910369104691056910669107691086910969110691116911269113691146911569116691176911869119691206912169122691236912469125691266912769128691296913069131691326913369134691356913669137691386913969140691416914269143691446914569146691476914869149691506915169152691536915469155691566915769158691596916069161691626916369164691656916669167691686916969170691716917269173691746917569176691776917869179691806918169182691836918469185691866918769188691896919069191691926919369194691956919669197691986919969200692016920269203692046920569206692076920869209692106921169212692136921469215692166921769218692196922069221692226922369224692256922669227692286922969230692316923269233692346923569236692376923869239692406924169242692436924469245692466924769248692496925069251692526925369254692556925669257692586925969260692616926269263692646926569266692676926869269692706927169272692736927469275692766927769278692796928069281692826928369284692856928669287692886928969290692916929269293692946929569296692976929869299693006930169302693036930469305693066930769308693096931069311693126931369314693156931669317693186931969320693216932269323693246932569326693276932869329693306933169332693336933469335693366933769338693396934069341693426934369344693456934669347693486934969350693516935269353693546935569356693576935869359693606936169362693636936469365693666936769368693696937069371693726937369374693756937669377693786937969380693816938269383693846938569386693876938869389693906939169392693936939469395693966939769398693996940069401694026940369404694056940669407694086940969410694116941269413694146941569416694176941869419694206942169422694236942469425694266942769428694296943069431694326943369434694356943669437694386943969440694416944269443694446944569446694476944869449694506945169452694536945469455694566945769458694596946069461694626946369464694656946669467694686946969470694716947269473694746947569476694776947869479694806948169482694836948469485694866948769488694896949069491694926949369494694956949669497694986949969500695016950269503695046950569506695076950869509695106951169512695136951469515695166951769518695196952069521695226952369524695256952669527695286952969530695316953269533695346953569536695376953869539695406954169542695436954469545695466954769548695496955069551695526955369554695556955669557695586955969560695616956269563695646956569566695676956869569695706957169572695736957469575695766957769578695796958069581695826958369584695856958669587695886958969590695916959269593695946959569596695976959869599696006960169602696036960469605696066960769608696096961069611696126961369614696156961669617696186961969620696216962269623696246962569626696276962869629696306963169632696336963469635696366963769638696396964069641696426964369644696456964669647696486964969650696516965269653696546965569656696576965869659696606966169662696636966469665696666966769668696696967069671696726967369674696756967669677696786967969680696816968269683696846968569686696876968869689696906969169692696936969469695696966969769698696996970069701697026970369704697056970669707697086970969710697116971269713697146971569716697176971869719697206972169722697236972469725697266972769728697296973069731697326973369734697356973669737697386973969740697416974269743697446974569746697476974869749697506975169752697536975469755697566975769758697596976069761697626976369764697656976669767697686976969770697716977269773697746977569776697776977869779697806978169782697836978469785697866978769788697896979069791697926979369794697956979669797697986979969800698016980269803698046980569806698076980869809698106981169812698136981469815698166981769818698196982069821698226982369824698256982669827698286982969830698316983269833698346983569836698376983869839698406984169842698436984469845698466984769848698496985069851698526985369854698556985669857698586985969860698616986269863698646986569866698676986869869698706987169872698736987469875698766987769878698796988069881698826988369884698856988669887698886988969890698916989269893698946989569896698976989869899699006990169902699036990469905699066990769908699096991069911699126991369914699156991669917699186991969920699216992269923699246992569926699276992869929699306993169932699336993469935699366993769938699396994069941699426994369944699456994669947699486994969950699516995269953699546995569956699576995869959699606996169962699636996469965699666996769968699696997069971699726997369974699756997669977699786997969980699816998269983699846998569986699876998869989699906999169992699936999469995699966999769998699997000070001700027000370004700057000670007700087000970010700117001270013700147001570016700177001870019700207002170022700237002470025700267002770028700297003070031700327003370034700357003670037700387003970040700417004270043700447004570046700477004870049700507005170052700537005470055700567005770058700597006070061700627006370064700657006670067700687006970070700717007270073700747007570076700777007870079700807008170082700837008470085700867008770088700897009070091700927009370094700957009670097700987009970100701017010270103701047010570106701077010870109701107011170112701137011470115701167011770118701197012070121701227012370124701257012670127701287012970130701317013270133701347013570136701377013870139701407014170142701437014470145701467014770148701497015070151701527015370154701557015670157701587015970160701617016270163701647016570166701677016870169701707017170172701737017470175701767017770178701797018070181701827018370184701857018670187701887018970190701917019270193701947019570196701977019870199702007020170202702037020470205702067020770208702097021070211702127021370214702157021670217702187021970220702217022270223702247022570226702277022870229702307023170232702337023470235702367023770238702397024070241702427024370244702457024670247702487024970250702517025270253702547025570256702577025870259702607026170262702637026470265702667026770268702697027070271702727027370274702757027670277702787027970280702817028270283702847028570286702877028870289702907029170292702937029470295702967029770298702997030070301703027030370304703057030670307703087030970310703117031270313703147031570316703177031870319703207032170322703237032470325703267032770328703297033070331703327033370334703357033670337703387033970340703417034270343703447034570346703477034870349703507035170352703537035470355703567035770358703597036070361703627036370364703657036670367703687036970370703717037270373703747037570376703777037870379703807038170382703837038470385703867038770388703897039070391703927039370394703957039670397703987039970400704017040270403704047040570406704077040870409704107041170412704137041470415704167041770418704197042070421704227042370424704257042670427704287042970430704317043270433704347043570436704377043870439704407044170442704437044470445704467044770448704497045070451704527045370454704557045670457704587045970460704617046270463704647046570466704677046870469704707047170472704737047470475704767047770478704797048070481704827048370484704857048670487704887048970490704917049270493704947049570496704977049870499705007050170502705037050470505705067050770508705097051070511705127051370514705157051670517705187051970520705217052270523705247052570526705277052870529705307053170532705337053470535705367053770538705397054070541705427054370544705457054670547705487054970550705517055270553705547055570556705577055870559705607056170562705637056470565705667056770568705697057070571705727057370574705757057670577705787057970580705817058270583705847058570586705877058870589705907059170592705937059470595705967059770598705997060070601706027060370604706057060670607706087060970610706117061270613706147061570616706177061870619706207062170622706237062470625706267062770628706297063070631706327063370634706357063670637706387063970640706417064270643706447064570646706477064870649706507065170652706537065470655706567065770658706597066070661706627066370664706657066670667706687066970670706717067270673706747067570676706777067870679706807068170682706837068470685706867068770688706897069070691706927069370694706957069670697706987069970700707017070270703707047070570706707077070870709707107071170712707137071470715707167071770718707197072070721707227072370724707257072670727707287072970730707317073270733707347073570736707377073870739707407074170742707437074470745707467074770748707497075070751707527075370754707557075670757707587075970760707617076270763707647076570766707677076870769707707077170772707737077470775707767077770778707797078070781707827078370784707857078670787707887078970790707917079270793707947079570796707977079870799708007080170802708037080470805708067080770808708097081070811708127081370814708157081670817708187081970820708217082270823708247082570826708277082870829708307083170832708337083470835708367083770838708397084070841708427084370844708457084670847708487084970850708517085270853708547085570856708577085870859708607086170862708637086470865708667086770868708697087070871708727087370874708757087670877708787087970880708817088270883708847088570886708877088870889708907089170892708937089470895708967089770898708997090070901709027090370904709057090670907709087090970910709117091270913709147091570916709177091870919709207092170922709237092470925709267092770928709297093070931709327093370934709357093670937709387093970940709417094270943709447094570946709477094870949709507095170952709537095470955709567095770958709597096070961709627096370964709657096670967709687096970970709717097270973709747097570976709777097870979709807098170982709837098470985709867098770988709897099070991709927099370994709957099670997709987099971000710017100271003710047100571006710077100871009710107101171012710137101471015710167101771018710197102071021710227102371024710257102671027710287102971030710317103271033710347103571036710377103871039710407104171042710437104471045710467104771048710497105071051710527105371054710557105671057710587105971060710617106271063710647106571066710677106871069710707107171072710737107471075710767107771078710797108071081710827108371084710857108671087710887108971090710917109271093710947109571096710977109871099711007110171102711037110471105711067110771108711097111071111711127111371114711157111671117711187111971120711217112271123711247112571126711277112871129711307113171132711337113471135711367113771138711397114071141711427114371144711457114671147711487114971150711517115271153711547115571156711577115871159711607116171162711637116471165711667116771168711697117071171711727117371174711757117671177711787117971180711817118271183711847118571186711877118871189711907119171192711937119471195711967119771198711997120071201712027120371204712057120671207712087120971210712117121271213712147121571216712177121871219712207122171222712237122471225712267122771228712297123071231712327123371234712357123671237712387123971240712417124271243712447124571246712477124871249712507125171252712537125471255712567125771258712597126071261712627126371264712657126671267712687126971270712717127271273712747127571276712777127871279712807128171282712837128471285712867128771288712897129071291712927129371294712957129671297712987129971300713017130271303713047130571306713077130871309713107131171312713137131471315713167131771318713197132071321713227132371324713257132671327713287132971330713317133271333713347133571336713377133871339713407134171342713437134471345713467134771348713497135071351713527135371354713557135671357713587135971360713617136271363713647136571366713677136871369713707137171372713737137471375713767137771378713797138071381713827138371384713857138671387713887138971390713917139271393713947139571396713977139871399714007140171402714037140471405714067140771408714097141071411714127141371414714157141671417714187141971420714217142271423714247142571426714277142871429714307143171432714337143471435714367143771438714397144071441714427144371444714457144671447714487144971450714517145271453714547145571456714577145871459714607146171462714637146471465714667146771468714697147071471714727147371474714757147671477714787147971480714817148271483714847148571486714877148871489714907149171492714937149471495714967149771498714997150071501715027150371504715057150671507715087150971510715117151271513715147151571516715177151871519715207152171522715237152471525715267152771528715297153071531715327153371534715357153671537715387153971540715417154271543715447154571546715477154871549715507155171552715537155471555715567155771558715597156071561715627156371564715657156671567715687156971570715717157271573715747157571576715777157871579715807158171582715837158471585715867158771588715897159071591715927159371594715957159671597715987159971600716017160271603716047160571606716077160871609716107161171612716137161471615716167161771618716197162071621716227162371624716257162671627716287162971630716317163271633716347163571636716377163871639716407164171642716437164471645716467164771648716497165071651716527165371654716557165671657716587165971660716617166271663716647166571666716677166871669716707167171672716737167471675716767167771678716797168071681716827168371684716857168671687716887168971690716917169271693716947169571696716977169871699717007170171702717037170471705717067170771708717097171071711717127171371714717157171671717717187171971720717217172271723717247172571726717277172871729717307173171732717337173471735717367173771738717397174071741717427174371744717457174671747717487174971750717517175271753717547175571756717577175871759717607176171762717637176471765717667176771768717697177071771717727177371774717757177671777717787177971780717817178271783717847178571786717877178871789717907179171792717937179471795717967179771798717997180071801718027180371804718057180671807718087180971810718117181271813718147181571816718177181871819718207182171822718237182471825718267182771828718297183071831718327183371834718357183671837718387183971840718417184271843718447184571846718477184871849718507185171852718537185471855718567185771858718597186071861718627186371864718657186671867718687186971870718717187271873718747187571876718777187871879718807188171882718837188471885718867188771888718897189071891718927189371894718957189671897718987189971900719017190271903719047190571906719077190871909719107191171912719137191471915719167191771918719197192071921719227192371924719257192671927719287192971930719317193271933719347193571936719377193871939719407194171942719437194471945719467194771948719497195071951719527195371954719557195671957719587195971960719617196271963719647196571966719677196871969719707197171972719737197471975719767197771978719797198071981719827198371984719857198671987719887198971990719917199271993719947199571996719977199871999720007200172002720037200472005720067200772008720097201072011720127201372014720157201672017720187201972020720217202272023720247202572026720277202872029720307203172032720337203472035720367203772038720397204072041720427204372044720457204672047720487204972050720517205272053720547205572056720577205872059720607206172062720637206472065720667206772068720697207072071720727207372074720757207672077720787207972080720817208272083720847208572086720877208872089720907209172092720937209472095720967209772098720997210072101721027210372104721057210672107721087210972110721117211272113721147211572116721177211872119721207212172122721237212472125721267212772128721297213072131721327213372134721357213672137721387213972140721417214272143721447214572146721477214872149721507215172152721537215472155721567215772158721597216072161721627216372164721657216672167721687216972170721717217272173721747217572176721777217872179721807218172182721837218472185721867218772188721897219072191721927219372194721957219672197721987219972200722017220272203722047220572206722077220872209722107221172212722137221472215722167221772218722197222072221722227222372224722257222672227722287222972230722317223272233722347223572236722377223872239722407224172242722437224472245722467224772248722497225072251722527225372254722557225672257722587225972260722617226272263722647226572266722677226872269722707227172272722737227472275722767227772278722797228072281722827228372284722857228672287722887228972290722917229272293722947229572296722977229872299723007230172302723037230472305723067230772308723097231072311723127231372314723157231672317723187231972320723217232272323723247232572326723277232872329723307233172332723337233472335723367233772338723397234072341723427234372344723457234672347723487234972350723517235272353723547235572356723577235872359723607236172362723637236472365723667236772368723697237072371723727237372374723757237672377723787237972380723817238272383723847238572386723877238872389723907239172392723937239472395723967239772398723997240072401724027240372404724057240672407724087240972410724117241272413724147241572416724177241872419724207242172422724237242472425724267242772428724297243072431724327243372434724357243672437724387243972440724417244272443724447244572446724477244872449724507245172452724537245472455724567245772458724597246072461724627246372464724657246672467724687246972470724717247272473724747247572476724777247872479724807248172482724837248472485724867248772488724897249072491724927249372494724957249672497724987249972500725017250272503725047250572506725077250872509725107251172512725137251472515725167251772518725197252072521725227252372524725257252672527725287252972530725317253272533725347253572536725377253872539725407254172542725437254472545725467254772548725497255072551725527255372554725557255672557725587255972560725617256272563725647256572566725677256872569725707257172572725737257472575725767257772578725797258072581725827258372584725857258672587725887258972590725917259272593725947259572596725977259872599726007260172602726037260472605726067260772608726097261072611726127261372614726157261672617726187261972620726217262272623726247262572626726277262872629726307263172632726337263472635726367263772638726397264072641726427264372644726457264672647726487264972650726517265272653726547265572656726577265872659726607266172662726637266472665726667266772668726697267072671726727267372674726757267672677726787267972680726817268272683726847268572686726877268872689726907269172692726937269472695726967269772698726997270072701727027270372704727057270672707727087270972710727117271272713727147271572716727177271872719727207272172722727237272472725727267272772728727297273072731727327273372734727357273672737727387273972740727417274272743727447274572746727477274872749727507275172752727537275472755727567275772758727597276072761727627276372764727657276672767727687276972770727717277272773727747277572776727777277872779727807278172782727837278472785727867278772788727897279072791727927279372794727957279672797727987279972800728017280272803728047280572806728077280872809728107281172812728137281472815728167281772818728197282072821728227282372824728257282672827728287282972830728317283272833728347283572836728377283872839728407284172842728437284472845728467284772848728497285072851728527285372854728557285672857728587285972860728617286272863728647286572866728677286872869728707287172872728737287472875728767287772878728797288072881728827288372884728857288672887728887288972890728917289272893728947289572896728977289872899729007290172902729037290472905729067290772908729097291072911729127291372914729157291672917729187291972920729217292272923729247292572926729277292872929729307293172932729337293472935729367293772938729397294072941729427294372944729457294672947729487294972950729517295272953729547295572956729577295872959729607296172962729637296472965729667296772968729697297072971729727297372974729757297672977729787297972980729817298272983729847298572986729877298872989729907299172992729937299472995729967299772998729997300073001730027300373004730057300673007730087300973010730117301273013730147301573016730177301873019730207302173022730237302473025730267302773028730297303073031730327303373034730357303673037730387303973040730417304273043730447304573046730477304873049730507305173052730537305473055730567305773058730597306073061730627306373064730657306673067730687306973070730717307273073730747307573076730777307873079730807308173082730837308473085730867308773088730897309073091730927309373094730957309673097730987309973100731017310273103731047310573106731077310873109731107311173112731137311473115731167311773118731197312073121731227312373124731257312673127731287312973130731317313273133731347313573136731377313873139731407314173142731437314473145731467314773148731497315073151731527315373154731557315673157731587315973160731617316273163731647316573166731677316873169731707317173172731737317473175731767317773178731797318073181731827318373184731857318673187731887318973190731917319273193731947319573196731977319873199732007320173202732037320473205732067320773208732097321073211732127321373214732157321673217732187321973220732217322273223732247322573226732277322873229732307323173232732337323473235732367323773238732397324073241732427324373244732457324673247732487324973250732517325273253732547325573256732577325873259732607326173262732637326473265732667326773268732697327073271732727327373274732757327673277732787327973280732817328273283732847328573286732877328873289732907329173292732937329473295732967329773298732997330073301733027330373304733057330673307733087330973310733117331273313733147331573316733177331873319733207332173322733237332473325733267332773328733297333073331733327333373334733357333673337733387333973340733417334273343733447334573346733477334873349733507335173352733537335473355733567335773358733597336073361733627336373364733657336673367733687336973370733717337273373733747337573376733777337873379733807338173382733837338473385733867338773388733897339073391733927339373394733957339673397733987339973400734017340273403734047340573406734077340873409734107341173412734137341473415734167341773418734197342073421734227342373424734257342673427734287342973430734317343273433734347343573436734377343873439734407344173442734437344473445734467344773448734497345073451734527345373454734557345673457734587345973460734617346273463734647346573466734677346873469734707347173472734737347473475734767347773478734797348073481734827348373484734857348673487734887348973490734917349273493734947349573496734977349873499735007350173502735037350473505735067350773508735097351073511735127351373514735157351673517735187351973520735217352273523735247352573526735277352873529735307353173532735337353473535735367353773538735397354073541735427354373544735457354673547735487354973550735517355273553735547355573556735577355873559735607356173562735637356473565735667356773568735697357073571735727357373574735757357673577735787357973580735817358273583735847358573586735877358873589735907359173592735937359473595735967359773598735997360073601736027360373604736057360673607736087360973610736117361273613736147361573616736177361873619736207362173622736237362473625736267362773628736297363073631736327363373634736357363673637736387363973640736417364273643736447364573646736477364873649736507365173652736537365473655736567365773658736597366073661736627366373664736657366673667736687366973670736717367273673736747367573676736777367873679736807368173682736837368473685736867368773688736897369073691736927369373694736957369673697736987369973700737017370273703737047370573706737077370873709737107371173712737137371473715737167371773718737197372073721737227372373724737257372673727737287372973730737317373273733737347373573736737377373873739737407374173742737437374473745737467374773748737497375073751737527375373754737557375673757737587375973760737617376273763737647376573766737677376873769737707377173772737737377473775737767377773778737797378073781737827378373784737857378673787737887378973790737917379273793737947379573796737977379873799738007380173802738037380473805738067380773808738097381073811738127381373814738157381673817738187381973820738217382273823738247382573826738277382873829738307383173832738337383473835738367383773838738397384073841738427384373844738457384673847738487384973850738517385273853738547385573856738577385873859738607386173862738637386473865738667386773868738697387073871738727387373874738757387673877738787387973880738817388273883738847388573886738877388873889738907389173892738937389473895738967389773898738997390073901739027390373904739057390673907739087390973910739117391273913739147391573916739177391873919739207392173922739237392473925739267392773928739297393073931739327393373934739357393673937739387393973940739417394273943739447394573946739477394873949739507395173952739537395473955739567395773958739597396073961739627396373964739657396673967739687396973970739717397273973739747397573976739777397873979739807398173982739837398473985739867398773988739897399073991739927399373994739957399673997739987399974000740017400274003740047400574006740077400874009740107401174012740137401474015740167401774018740197402074021740227402374024740257402674027740287402974030740317403274033740347403574036740377403874039740407404174042740437404474045740467404774048740497405074051740527405374054740557405674057740587405974060740617406274063740647406574066740677406874069740707407174072740737407474075740767407774078740797408074081740827408374084740857408674087740887408974090740917409274093740947409574096740977409874099741007410174102741037410474105741067410774108741097411074111741127411374114741157411674117741187411974120741217412274123741247412574126741277412874129741307413174132741337413474135741367413774138741397414074141741427414374144741457414674147741487414974150741517415274153741547415574156741577415874159741607416174162741637416474165741667416774168741697417074171741727417374174741757417674177741787417974180741817418274183741847418574186741877418874189741907419174192741937419474195741967419774198741997420074201742027420374204742057420674207742087420974210742117421274213742147421574216742177421874219742207422174222742237422474225742267422774228742297423074231742327423374234742357423674237742387423974240742417424274243742447424574246742477424874249742507425174252742537425474255742567425774258742597426074261742627426374264742657426674267742687426974270742717427274273742747427574276742777427874279742807428174282742837428474285742867428774288742897429074291742927429374294742957429674297742987429974300743017430274303743047430574306743077430874309743107431174312743137431474315743167431774318743197432074321743227432374324743257432674327743287432974330743317433274333743347433574336743377433874339743407434174342743437434474345743467434774348743497435074351743527435374354743557435674357743587435974360743617436274363743647436574366743677436874369743707437174372743737437474375743767437774378743797438074381743827438374384743857438674387743887438974390743917439274393743947439574396743977439874399744007440174402744037440474405744067440774408744097441074411744127441374414744157441674417744187441974420744217442274423744247442574426744277442874429744307443174432744337443474435744367443774438744397444074441744427444374444744457444674447744487444974450744517445274453744547445574456744577445874459744607446174462744637446474465744667446774468744697447074471744727447374474744757447674477744787447974480744817448274483744847448574486744877448874489744907449174492744937449474495744967449774498744997450074501745027450374504745057450674507745087450974510745117451274513745147451574516745177451874519745207452174522745237452474525745267452774528745297453074531745327453374534745357453674537745387453974540745417454274543745447454574546745477454874549745507455174552745537455474555745567455774558745597456074561745627456374564745657456674567745687456974570745717457274573745747457574576745777457874579745807458174582745837458474585745867458774588745897459074591745927459374594745957459674597745987459974600746017460274603746047460574606746077460874609746107461174612746137461474615746167461774618746197462074621746227462374624746257462674627746287462974630746317463274633746347463574636746377463874639746407464174642746437464474645746467464774648746497465074651746527465374654746557465674657746587465974660746617466274663746647466574666746677466874669746707467174672746737467474675746767467774678746797468074681746827468374684746857468674687746887468974690746917469274693746947469574696746977469874699747007470174702747037470474705747067470774708747097471074711747127471374714747157471674717747187471974720747217472274723747247472574726747277472874729747307473174732747337473474735747367473774738747397474074741747427474374744747457474674747747487474974750747517475274753747547475574756747577475874759747607476174762747637476474765747667476774768747697477074771747727477374774747757477674777747787477974780747817478274783747847478574786747877478874789747907479174792747937479474795747967479774798747997480074801748027480374804748057480674807748087480974810748117481274813748147481574816748177481874819748207482174822748237482474825748267482774828748297483074831748327483374834748357483674837748387483974840748417484274843748447484574846748477484874849748507485174852748537485474855748567485774858748597486074861748627486374864748657486674867748687486974870748717487274873748747487574876748777487874879748807488174882748837488474885748867488774888748897489074891748927489374894748957489674897748987489974900749017490274903749047490574906749077490874909749107491174912749137491474915749167491774918749197492074921749227492374924749257492674927749287492974930749317493274933749347493574936749377493874939749407494174942749437494474945749467494774948749497495074951749527495374954749557495674957749587495974960749617496274963749647496574966749677496874969749707497174972749737497474975749767497774978749797498074981749827498374984749857498674987749887498974990749917499274993749947499574996749977499874999750007500175002750037500475005750067500775008750097501075011750127501375014750157501675017750187501975020750217502275023750247502575026750277502875029750307503175032750337503475035750367503775038750397504075041750427504375044750457504675047750487504975050750517505275053750547505575056750577505875059750607506175062750637506475065750667506775068750697507075071750727507375074750757507675077750787507975080750817508275083750847508575086750877508875089750907509175092750937509475095750967509775098750997510075101751027510375104751057510675107751087510975110751117511275113751147511575116751177511875119751207512175122751237512475125751267512775128751297513075131751327513375134751357513675137751387513975140751417514275143751447514575146751477514875149751507515175152751537515475155751567515775158751597516075161751627516375164751657516675167751687516975170751717517275173751747517575176751777517875179751807518175182751837518475185751867518775188751897519075191751927519375194751957519675197751987519975200752017520275203752047520575206752077520875209752107521175212752137521475215752167521775218752197522075221752227522375224752257522675227752287522975230752317523275233752347523575236752377523875239752407524175242752437524475245752467524775248752497525075251752527525375254752557525675257752587525975260752617526275263752647526575266752677526875269752707527175272752737527475275752767527775278752797528075281752827528375284752857528675287752887528975290752917529275293752947529575296752977529875299753007530175302753037530475305753067530775308753097531075311753127531375314753157531675317753187531975320753217532275323753247532575326753277532875329753307533175332753337533475335753367533775338753397534075341753427534375344753457534675347753487534975350753517535275353753547535575356753577535875359753607536175362753637536475365753667536775368753697537075371753727537375374753757537675377753787537975380753817538275383753847538575386753877538875389753907539175392753937539475395753967539775398753997540075401754027540375404754057540675407754087540975410754117541275413754147541575416754177541875419754207542175422754237542475425754267542775428754297543075431754327543375434754357543675437754387543975440754417544275443754447544575446754477544875449754507545175452754537545475455754567545775458754597546075461754627546375464754657546675467754687546975470754717547275473754747547575476754777547875479754807548175482754837548475485754867548775488754897549075491754927549375494754957549675497754987549975500755017550275503755047550575506755077550875509755107551175512755137551475515755167551775518755197552075521755227552375524755257552675527755287552975530755317553275533755347553575536755377553875539755407554175542755437554475545755467554775548755497555075551755527555375554755557555675557755587555975560755617556275563755647556575566755677556875569755707557175572755737557475575755767557775578755797558075581755827558375584755857558675587755887558975590755917559275593755947559575596755977559875599756007560175602756037560475605756067560775608756097561075611756127561375614756157561675617756187561975620756217562275623756247562575626756277562875629756307563175632756337563475635756367563775638756397564075641756427564375644756457564675647756487564975650756517565275653756547565575656756577565875659756607566175662756637566475665756667566775668756697567075671756727567375674756757567675677756787567975680756817568275683756847568575686756877568875689756907569175692756937569475695756967569775698756997570075701757027570375704757057570675707757087570975710757117571275713757147571575716757177571875719757207572175722757237572475725757267572775728757297573075731757327573375734757357573675737757387573975740757417574275743757447574575746757477574875749757507575175752757537575475755757567575775758757597576075761757627576375764757657576675767757687576975770757717577275773757747577575776757777577875779757807578175782757837578475785757867578775788757897579075791757927579375794757957579675797757987579975800758017580275803758047580575806758077580875809758107581175812758137581475815758167581775818758197582075821758227582375824758257582675827758287582975830758317583275833758347583575836758377583875839758407584175842758437584475845758467584775848758497585075851758527585375854758557585675857758587585975860758617586275863758647586575866758677586875869758707587175872758737587475875758767587775878758797588075881758827588375884758857588675887758887588975890758917589275893758947589575896758977589875899759007590175902759037590475905759067590775908759097591075911759127591375914759157591675917759187591975920759217592275923759247592575926759277592875929759307593175932759337593475935759367593775938759397594075941759427594375944759457594675947759487594975950759517595275953759547595575956759577595875959759607596175962759637596475965759667596775968759697597075971759727597375974759757597675977759787597975980759817598275983759847598575986759877598875989759907599175992759937599475995759967599775998759997600076001760027600376004760057600676007760087600976010760117601276013760147601576016760177601876019760207602176022760237602476025760267602776028760297603076031760327603376034760357603676037760387603976040760417604276043760447604576046760477604876049760507605176052760537605476055760567605776058760597606076061760627606376064760657606676067760687606976070760717607276073760747607576076760777607876079760807608176082760837608476085760867608776088760897609076091760927609376094760957609676097760987609976100761017610276103761047610576106761077610876109761107611176112761137611476115761167611776118761197612076121761227612376124761257612676127761287612976130761317613276133761347613576136761377613876139761407614176142761437614476145761467614776148761497615076151761527615376154761557615676157761587615976160761617616276163761647616576166761677616876169761707617176172761737617476175761767617776178761797618076181761827618376184761857618676187761887618976190761917619276193761947619576196761977619876199762007620176202762037620476205762067620776208762097621076211762127621376214762157621676217762187621976220762217622276223762247622576226762277622876229762307623176232762337623476235762367623776238762397624076241762427624376244762457624676247762487624976250762517625276253762547625576256762577625876259762607626176262762637626476265762667626776268762697627076271762727627376274762757627676277762787627976280762817628276283762847628576286762877628876289762907629176292762937629476295762967629776298762997630076301763027630376304763057630676307763087630976310763117631276313763147631576316763177631876319763207632176322763237632476325763267632776328763297633076331763327633376334763357633676337763387633976340763417634276343763447634576346763477634876349763507635176352763537635476355763567635776358763597636076361763627636376364763657636676367763687636976370763717637276373763747637576376763777637876379763807638176382763837638476385763867638776388763897639076391763927639376394763957639676397763987639976400764017640276403764047640576406764077640876409764107641176412764137641476415764167641776418764197642076421764227642376424764257642676427764287642976430764317643276433764347643576436764377643876439764407644176442764437644476445764467644776448764497645076451764527645376454764557645676457764587645976460764617646276463764647646576466764677646876469764707647176472764737647476475764767647776478764797648076481764827648376484764857648676487764887648976490764917649276493764947649576496764977649876499765007650176502765037650476505765067650776508765097651076511765127651376514765157651676517765187651976520765217652276523765247652576526765277652876529765307653176532765337653476535765367653776538765397654076541765427654376544765457654676547765487654976550765517655276553765547655576556765577655876559765607656176562765637656476565765667656776568765697657076571765727657376574765757657676577765787657976580765817658276583765847658576586765877658876589765907659176592765937659476595765967659776598765997660076601766027660376604766057660676607766087660976610766117661276613766147661576616766177661876619766207662176622766237662476625766267662776628766297663076631766327663376634766357663676637766387663976640766417664276643766447664576646766477664876649766507665176652766537665476655766567665776658766597666076661766627666376664766657666676667766687666976670766717667276673766747667576676766777667876679766807668176682766837668476685766867668776688766897669076691766927669376694766957669676697766987669976700767017670276703767047670576706767077670876709767107671176712767137671476715767167671776718767197672076721767227672376724767257672676727767287672976730767317673276733767347673576736767377673876739767407674176742767437674476745767467674776748767497675076751767527675376754767557675676757767587675976760767617676276763767647676576766767677676876769767707677176772767737677476775767767677776778767797678076781767827678376784767857678676787767887678976790767917679276793767947679576796767977679876799768007680176802768037680476805768067680776808768097681076811768127681376814768157681676817768187681976820768217682276823768247682576826768277682876829768307683176832768337683476835768367683776838768397684076841768427684376844768457684676847768487684976850768517685276853768547685576856768577685876859768607686176862768637686476865768667686776868768697687076871768727687376874768757687676877768787687976880768817688276883768847688576886768877688876889768907689176892768937689476895768967689776898768997690076901769027690376904769057690676907769087690976910769117691276913769147691576916769177691876919769207692176922769237692476925769267692776928769297693076931769327693376934769357693676937769387693976940769417694276943769447694576946769477694876949769507695176952769537695476955769567695776958769597696076961769627696376964769657696676967769687696976970769717697276973769747697576976769777697876979769807698176982769837698476985769867698776988769897699076991769927699376994769957699676997769987699977000770017700277003770047700577006770077700877009770107701177012770137701477015770167701777018770197702077021770227702377024770257702677027770287702977030770317703277033770347703577036770377703877039770407704177042770437704477045770467704777048770497705077051770527705377054770557705677057770587705977060770617706277063770647706577066770677706877069770707707177072770737707477075770767707777078770797708077081770827708377084770857708677087770887708977090770917709277093770947709577096770977709877099771007710177102771037710477105771067710777108771097711077111771127711377114771157711677117771187711977120771217712277123771247712577126771277712877129771307713177132771337713477135771367713777138771397714077141771427714377144771457714677147771487714977150771517715277153771547715577156771577715877159771607716177162771637716477165771667716777168771697717077171771727717377174771757717677177771787717977180771817718277183771847718577186771877718877189771907719177192771937719477195771967719777198771997720077201772027720377204772057720677207772087720977210772117721277213772147721577216772177721877219772207722177222772237722477225772267722777228772297723077231772327723377234772357723677237772387723977240772417724277243772447724577246772477724877249772507725177252772537725477255772567725777258772597726077261772627726377264772657726677267772687726977270772717727277273772747727577276772777727877279772807728177282772837728477285772867728777288772897729077291772927729377294772957729677297772987729977300773017730277303773047730577306773077730877309773107731177312773137731477315773167731777318773197732077321773227732377324773257732677327773287732977330773317733277333773347733577336773377733877339773407734177342773437734477345773467734777348773497735077351773527735377354773557735677357773587735977360773617736277363773647736577366773677736877369773707737177372773737737477375773767737777378773797738077381773827738377384773857738677387773887738977390773917739277393773947739577396773977739877399774007740177402774037740477405774067740777408774097741077411774127741377414774157741677417774187741977420774217742277423774247742577426774277742877429774307743177432774337743477435774367743777438774397744077441774427744377444774457744677447774487744977450774517745277453774547745577456774577745877459774607746177462774637746477465774667746777468774697747077471774727747377474774757747677477774787747977480774817748277483774847748577486774877748877489774907749177492774937749477495774967749777498774997750077501775027750377504775057750677507775087750977510775117751277513775147751577516775177751877519775207752177522775237752477525775267752777528775297753077531775327753377534775357753677537775387753977540775417754277543775447754577546775477754877549775507755177552775537755477555775567755777558775597756077561775627756377564775657756677567775687756977570775717757277573775747757577576775777757877579775807758177582775837758477585775867758777588775897759077591775927759377594775957759677597775987759977600776017760277603776047760577606776077760877609776107761177612776137761477615776167761777618776197762077621776227762377624776257762677627776287762977630776317763277633776347763577636776377763877639776407764177642776437764477645776467764777648776497765077651776527765377654776557765677657776587765977660776617766277663776647766577666776677766877669776707767177672776737767477675776767767777678776797768077681776827768377684776857768677687776887768977690776917769277693776947769577696776977769877699777007770177702777037770477705777067770777708777097771077711777127771377714777157771677717777187771977720777217772277723777247772577726777277772877729777307773177732777337773477735777367773777738777397774077741777427774377744777457774677747777487774977750777517775277753777547775577756777577775877759777607776177762777637776477765777667776777768777697777077771777727777377774777757777677777777787777977780777817778277783777847778577786777877778877789777907779177792777937779477795777967779777798777997780077801778027780377804778057780677807778087780977810778117781277813778147781577816778177781877819778207782177822778237782477825778267782777828778297783077831778327783377834778357783677837778387783977840778417784277843778447784577846778477784877849778507785177852778537785477855778567785777858778597786077861778627786377864778657786677867778687786977870778717787277873778747787577876778777787877879778807788177882778837788477885778867788777888778897789077891778927789377894778957789677897778987789977900779017790277903779047790577906779077790877909779107791177912779137791477915779167791777918779197792077921779227792377924779257792677927779287792977930779317793277933779347793577936779377793877939779407794177942779437794477945779467794777948779497795077951779527795377954779557795677957779587795977960779617796277963779647796577966779677796877969779707797177972779737797477975779767797777978779797798077981779827798377984779857798677987779887798977990779917799277993779947799577996779977799877999780007800178002780037800478005780067800778008780097801078011780127801378014780157801678017780187801978020780217802278023780247802578026780277802878029780307803178032780337803478035780367803778038780397804078041780427804378044780457804678047780487804978050780517805278053780547805578056780577805878059780607806178062780637806478065780667806778068780697807078071780727807378074780757807678077780787807978080780817808278083780847808578086780877808878089780907809178092780937809478095780967809778098780997810078101781027810378104781057810678107781087810978110781117811278113781147811578116781177811878119781207812178122781237812478125781267812778128781297813078131781327813378134781357813678137781387813978140781417814278143781447814578146781477814878149781507815178152781537815478155781567815778158781597816078161781627816378164781657816678167781687816978170781717817278173781747817578176781777817878179781807818178182781837818478185781867818778188781897819078191781927819378194781957819678197781987819978200782017820278203782047820578206782077820878209782107821178212782137821478215782167821778218782197822078221782227822378224782257822678227782287822978230782317823278233782347823578236782377823878239782407824178242782437824478245782467824778248782497825078251782527825378254782557825678257782587825978260782617826278263782647826578266782677826878269782707827178272782737827478275782767827778278782797828078281782827828378284782857828678287782887828978290782917829278293782947829578296782977829878299783007830178302783037830478305783067830778308783097831078311783127831378314783157831678317783187831978320783217832278323783247832578326783277832878329783307833178332783337833478335783367833778338783397834078341783427834378344783457834678347783487834978350783517835278353783547835578356783577835878359783607836178362783637836478365783667836778368783697837078371783727837378374783757837678377783787837978380783817838278383783847838578386783877838878389783907839178392783937839478395783967839778398783997840078401784027840378404784057840678407784087840978410784117841278413784147841578416784177841878419784207842178422784237842478425784267842778428784297843078431784327843378434784357843678437784387843978440784417844278443784447844578446784477844878449784507845178452784537845478455784567845778458784597846078461784627846378464784657846678467784687846978470784717847278473784747847578476784777847878479784807848178482784837848478485784867848778488784897849078491784927849378494784957849678497784987849978500785017850278503785047850578506785077850878509785107851178512785137851478515785167851778518785197852078521785227852378524785257852678527785287852978530785317853278533785347853578536785377853878539785407854178542785437854478545785467854778548785497855078551785527855378554785557855678557785587855978560785617856278563785647856578566785677856878569785707857178572785737857478575785767857778578785797858078581785827858378584785857858678587785887858978590785917859278593785947859578596785977859878599786007860178602786037860478605786067860778608786097861078611786127861378614786157861678617786187861978620786217862278623786247862578626786277862878629786307863178632786337863478635786367863778638786397864078641786427864378644786457864678647786487864978650786517865278653786547865578656786577865878659786607866178662786637866478665786667866778668786697867078671786727867378674786757867678677786787867978680786817868278683786847868578686786877868878689786907869178692786937869478695786967869778698786997870078701787027870378704787057870678707787087870978710787117871278713787147871578716787177871878719787207872178722787237872478725787267872778728787297873078731787327873378734787357873678737787387873978740787417874278743787447874578746787477874878749787507875178752787537875478755787567875778758787597876078761787627876378764787657876678767787687876978770787717877278773787747877578776787777877878779787807878178782787837878478785787867878778788787897879078791787927879378794787957879678797787987879978800788017880278803788047880578806788077880878809788107881178812788137881478815788167881778818788197882078821788227882378824788257882678827788287882978830788317883278833788347883578836788377883878839788407884178842788437884478845788467884778848788497885078851788527885378854788557885678857788587885978860788617886278863788647886578866788677886878869788707887178872788737887478875788767887778878788797888078881788827888378884788857888678887788887888978890788917889278893788947889578896788977889878899789007890178902789037890478905789067890778908789097891078911789127891378914789157891678917789187891978920789217892278923789247892578926789277892878929789307893178932789337893478935789367893778938789397894078941789427894378944789457894678947789487894978950789517895278953789547895578956789577895878959789607896178962789637896478965789667896778968789697897078971789727897378974789757897678977789787897978980789817898278983789847898578986789877898878989789907899178992789937899478995789967899778998789997900079001790027900379004790057900679007790087900979010790117901279013790147901579016790177901879019790207902179022790237902479025790267902779028790297903079031790327903379034790357903679037790387903979040790417904279043790447904579046790477904879049790507905179052790537905479055790567905779058790597906079061790627906379064790657906679067790687906979070790717907279073790747907579076790777907879079790807908179082790837908479085790867908779088790897909079091790927909379094790957909679097790987909979100791017910279103791047910579106791077910879109791107911179112791137911479115791167911779118791197912079121791227912379124791257912679127791287912979130791317913279133791347913579136791377913879139791407914179142791437914479145791467914779148791497915079151791527915379154791557915679157791587915979160791617916279163791647916579166791677916879169791707917179172791737917479175791767917779178791797918079181791827918379184791857918679187791887918979190791917919279193791947919579196791977919879199792007920179202792037920479205792067920779208792097921079211792127921379214792157921679217792187921979220792217922279223792247922579226792277922879229792307923179232792337923479235792367923779238792397924079241792427924379244792457924679247792487924979250792517925279253792547925579256792577925879259792607926179262792637926479265792667926779268792697927079271792727927379274792757927679277792787927979280792817928279283792847928579286792877928879289792907929179292792937929479295792967929779298792997930079301793027930379304793057930679307793087930979310793117931279313793147931579316793177931879319793207932179322793237932479325793267932779328793297933079331793327933379334793357933679337793387933979340793417934279343793447934579346793477934879349793507935179352793537935479355793567935779358793597936079361793627936379364793657936679367793687936979370793717937279373793747937579376793777937879379793807938179382793837938479385793867938779388793897939079391793927939379394793957939679397793987939979400794017940279403794047940579406794077940879409794107941179412794137941479415794167941779418794197942079421794227942379424794257942679427794287942979430794317943279433794347943579436794377943879439794407944179442794437944479445794467944779448794497945079451794527945379454794557945679457794587945979460794617946279463794647946579466794677946879469794707947179472794737947479475794767947779478794797948079481794827948379484794857948679487794887948979490794917949279493794947949579496794977949879499795007950179502795037950479505795067950779508795097951079511795127951379514795157951679517795187951979520795217952279523795247952579526795277952879529795307953179532795337953479535795367953779538795397954079541795427954379544795457954679547795487954979550795517955279553795547955579556795577955879559795607956179562795637956479565795667956779568795697957079571795727957379574795757957679577795787957979580795817958279583795847958579586795877958879589795907959179592795937959479595795967959779598795997960079601796027960379604796057960679607796087960979610796117961279613796147961579616796177961879619796207962179622796237962479625796267962779628796297963079631796327963379634796357963679637796387963979640796417964279643796447964579646796477964879649796507965179652796537965479655796567965779658796597966079661796627966379664796657966679667796687966979670796717967279673796747967579676796777967879679796807968179682796837968479685796867968779688796897969079691796927969379694796957969679697796987969979700797017970279703797047970579706797077970879709797107971179712797137971479715797167971779718797197972079721797227972379724797257972679727797287972979730797317973279733797347973579736797377973879739797407974179742797437974479745797467974779748797497975079751797527975379754797557975679757797587975979760797617976279763797647976579766797677976879769797707977179772797737977479775797767977779778797797978079781797827978379784797857978679787797887978979790797917979279793797947979579796797977979879799798007980179802798037980479805798067980779808798097981079811798127981379814798157981679817798187981979820798217982279823798247982579826798277982879829798307983179832798337983479835798367983779838798397984079841798427984379844798457984679847798487984979850798517985279853798547985579856798577985879859798607986179862798637986479865798667986779868798697987079871798727987379874798757987679877798787987979880798817988279883798847988579886798877988879889798907989179892798937989479895798967989779898798997990079901799027990379904799057990679907799087990979910799117991279913799147991579916799177991879919799207992179922799237992479925799267992779928799297993079931799327993379934799357993679937799387993979940799417994279943799447994579946799477994879949799507995179952799537995479955799567995779958799597996079961799627996379964799657996679967799687996979970799717997279973799747997579976799777997879979799807998179982799837998479985799867998779988799897999079991799927999379994799957999679997799987999980000800018000280003800048000580006800078000880009800108001180012800138001480015800168001780018800198002080021800228002380024800258002680027800288002980030800318003280033800348003580036800378003880039800408004180042800438004480045800468004780048800498005080051800528005380054800558005680057800588005980060800618006280063800648006580066800678006880069800708007180072800738007480075800768007780078800798008080081800828008380084800858008680087800888008980090800918009280093800948009580096800978009880099801008010180102801038010480105801068010780108801098011080111801128011380114801158011680117801188011980120801218012280123801248012580126801278012880129801308013180132801338013480135801368013780138801398014080141801428014380144801458014680147801488014980150801518015280153801548015580156801578015880159801608016180162801638016480165801668016780168801698017080171801728017380174801758017680177801788017980180801818018280183801848018580186801878018880189801908019180192801938019480195801968019780198801998020080201802028020380204802058020680207802088020980210802118021280213802148021580216802178021880219802208022180222802238022480225802268022780228802298023080231802328023380234802358023680237802388023980240802418024280243802448024580246802478024880249802508025180252802538025480255802568025780258802598026080261802628026380264802658026680267802688026980270802718027280273802748027580276802778027880279802808028180282802838028480285802868028780288802898029080291802928029380294802958029680297802988029980300803018030280303803048030580306803078030880309803108031180312803138031480315803168031780318803198032080321803228032380324803258032680327803288032980330803318033280333803348033580336803378033880339803408034180342803438034480345803468034780348803498035080351803528035380354803558035680357803588035980360803618036280363803648036580366803678036880369803708037180372803738037480375803768037780378803798038080381803828038380384803858038680387803888038980390803918039280393803948039580396803978039880399804008040180402804038040480405804068040780408804098041080411804128041380414804158041680417804188041980420804218042280423804248042580426804278042880429804308043180432804338043480435804368043780438804398044080441804428044380444804458044680447804488044980450804518045280453804548045580456804578045880459804608046180462804638046480465804668046780468804698047080471804728047380474804758047680477804788047980480804818048280483804848048580486804878048880489804908049180492804938049480495804968049780498804998050080501805028050380504805058050680507805088050980510805118051280513805148051580516805178051880519805208052180522805238052480525805268052780528805298053080531805328053380534805358053680537805388053980540805418054280543805448054580546805478054880549805508055180552805538055480555805568055780558805598056080561805628056380564805658056680567805688056980570805718057280573805748057580576805778057880579805808058180582805838058480585805868058780588805898059080591805928059380594805958059680597805988059980600806018060280603806048060580606806078060880609806108061180612806138061480615806168061780618806198062080621806228062380624806258062680627806288062980630806318063280633806348063580636806378063880639806408064180642806438064480645806468064780648806498065080651806528065380654806558065680657806588065980660806618066280663806648066580666806678066880669806708067180672806738067480675806768067780678806798068080681806828068380684806858068680687806888068980690806918069280693806948069580696806978069880699807008070180702807038070480705807068070780708807098071080711807128071380714807158071680717807188071980720807218072280723807248072580726807278072880729807308073180732807338073480735807368073780738807398074080741807428074380744807458074680747807488074980750807518075280753807548075580756807578075880759807608076180762807638076480765807668076780768807698077080771807728077380774807758077680777807788077980780807818078280783807848078580786807878078880789807908079180792807938079480795807968079780798807998080080801808028080380804808058080680807808088080980810808118081280813808148081580816808178081880819808208082180822808238082480825808268082780828808298083080831808328083380834808358083680837808388083980840808418084280843808448084580846808478084880849808508085180852808538085480855808568085780858808598086080861808628086380864808658086680867808688086980870808718087280873808748087580876808778087880879808808088180882808838088480885808868088780888808898089080891808928089380894808958089680897808988089980900809018090280903809048090580906809078090880909809108091180912809138091480915809168091780918809198092080921809228092380924809258092680927809288092980930809318093280933809348093580936809378093880939809408094180942809438094480945809468094780948809498095080951809528095380954809558095680957809588095980960809618096280963809648096580966809678096880969809708097180972809738097480975809768097780978809798098080981809828098380984809858098680987809888098980990809918099280993809948099580996809978099880999810008100181002810038100481005810068100781008810098101081011810128101381014810158101681017810188101981020810218102281023810248102581026810278102881029810308103181032810338103481035810368103781038810398104081041810428104381044810458104681047810488104981050810518105281053810548105581056810578105881059810608106181062810638106481065810668106781068810698107081071810728107381074810758107681077810788107981080810818108281083810848108581086810878108881089810908109181092810938109481095810968109781098810998110081101811028110381104811058110681107811088110981110811118111281113811148111581116811178111881119811208112181122811238112481125811268112781128811298113081131811328113381134811358113681137811388113981140811418114281143811448114581146811478114881149811508115181152811538115481155811568115781158811598116081161811628116381164811658116681167811688116981170811718117281173811748117581176811778117881179811808118181182811838118481185811868118781188811898119081191811928119381194811958119681197811988119981200812018120281203812048120581206812078120881209812108121181212812138121481215812168121781218812198122081221812228122381224812258122681227812288122981230812318123281233812348123581236812378123881239812408124181242812438124481245812468124781248812498125081251812528125381254812558125681257812588125981260812618126281263812648126581266812678126881269812708127181272812738127481275812768127781278812798128081281812828128381284812858128681287812888128981290812918129281293812948129581296812978129881299813008130181302813038130481305813068130781308813098131081311813128131381314813158131681317813188131981320813218132281323813248132581326813278132881329813308133181332813338133481335813368133781338813398134081341813428134381344813458134681347813488134981350813518135281353813548135581356813578135881359813608136181362813638136481365813668136781368813698137081371813728137381374813758137681377813788137981380813818138281383813848138581386813878138881389813908139181392813938139481395813968139781398813998140081401814028140381404814058140681407814088140981410814118141281413814148141581416814178141881419814208142181422814238142481425814268142781428814298143081431814328143381434814358143681437814388143981440814418144281443814448144581446814478144881449814508145181452814538145481455814568145781458814598146081461814628146381464814658146681467814688146981470814718147281473814748147581476814778147881479814808148181482814838148481485814868148781488814898149081491814928149381494814958149681497814988149981500815018150281503815048150581506815078150881509815108151181512815138151481515815168151781518815198152081521815228152381524815258152681527815288152981530815318153281533815348153581536815378153881539815408154181542815438154481545815468154781548815498155081551815528155381554815558155681557815588155981560815618156281563815648156581566815678156881569815708157181572815738157481575815768157781578815798158081581815828158381584815858158681587815888158981590815918159281593815948159581596815978159881599816008160181602816038160481605816068160781608816098161081611816128161381614816158161681617816188161981620816218162281623816248162581626816278162881629816308163181632816338163481635816368163781638816398164081641816428164381644816458164681647816488164981650816518165281653816548165581656816578165881659816608166181662816638166481665816668166781668816698167081671816728167381674816758167681677816788167981680816818168281683816848168581686816878168881689816908169181692816938169481695816968169781698816998170081701817028170381704817058170681707817088170981710817118171281713817148171581716817178171881719817208172181722817238172481725817268172781728817298173081731817328173381734817358173681737817388173981740817418174281743817448174581746817478174881749817508175181752817538175481755817568175781758817598176081761817628176381764817658176681767817688176981770817718177281773817748177581776817778177881779817808178181782817838178481785817868178781788817898179081791817928179381794817958179681797817988179981800818018180281803818048180581806818078180881809818108181181812818138181481815818168181781818818198182081821818228182381824818258182681827818288182981830818318183281833818348183581836818378183881839818408184181842818438184481845818468184781848818498185081851818528185381854818558185681857818588185981860818618186281863818648186581866818678186881869818708187181872818738187481875818768187781878818798188081881818828188381884818858188681887818888188981890818918189281893818948189581896818978189881899819008190181902819038190481905819068190781908819098191081911819128191381914819158191681917819188191981920819218192281923819248192581926819278192881929819308193181932819338193481935819368193781938819398194081941819428194381944819458194681947819488194981950819518195281953819548195581956819578195881959819608196181962819638196481965819668196781968819698197081971819728197381974819758197681977819788197981980819818198281983819848198581986819878198881989819908199181992819938199481995819968199781998819998200082001820028200382004820058200682007820088200982010820118201282013820148201582016820178201882019820208202182022820238202482025820268202782028820298203082031820328203382034820358203682037820388203982040820418204282043820448204582046820478204882049820508205182052820538205482055820568205782058820598206082061820628206382064820658206682067820688206982070820718207282073820748207582076820778207882079820808208182082820838208482085820868208782088820898209082091820928209382094820958209682097820988209982100821018210282103821048210582106821078210882109821108211182112821138211482115821168211782118821198212082121821228212382124821258212682127821288212982130821318213282133821348213582136821378213882139821408214182142821438214482145821468214782148821498215082151821528215382154821558215682157821588215982160821618216282163821648216582166821678216882169821708217182172821738217482175821768217782178821798218082181821828218382184821858218682187821888218982190821918219282193821948219582196821978219882199822008220182202822038220482205822068220782208822098221082211822128221382214822158221682217822188221982220822218222282223822248222582226822278222882229822308223182232822338223482235822368223782238822398224082241822428224382244822458224682247822488224982250822518225282253822548225582256822578225882259822608226182262822638226482265822668226782268822698227082271822728227382274822758227682277822788227982280822818228282283822848228582286822878228882289822908229182292822938229482295822968229782298822998230082301823028230382304823058230682307823088230982310823118231282313823148231582316823178231882319823208232182322823238232482325823268232782328823298233082331823328233382334823358233682337823388233982340823418234282343823448234582346823478234882349823508235182352823538235482355823568235782358823598236082361823628236382364823658236682367823688236982370823718237282373823748237582376823778237882379823808238182382823838238482385823868238782388823898239082391823928239382394823958239682397823988239982400824018240282403824048240582406824078240882409824108241182412824138241482415824168241782418824198242082421824228242382424824258242682427824288242982430824318243282433824348243582436824378243882439824408244182442824438244482445824468244782448824498245082451824528245382454824558245682457824588245982460824618246282463824648246582466824678246882469824708247182472824738247482475824768247782478824798248082481824828248382484824858248682487824888248982490824918249282493824948249582496824978249882499825008250182502825038250482505825068250782508825098251082511825128251382514825158251682517825188251982520825218252282523825248252582526825278252882529825308253182532825338253482535825368253782538825398254082541825428254382544825458254682547825488254982550825518255282553825548255582556825578255882559825608256182562825638256482565825668256782568825698257082571825728257382574825758257682577825788257982580825818258282583825848258582586825878258882589825908259182592825938259482595825968259782598825998260082601826028260382604826058260682607826088260982610826118261282613826148261582616826178261882619826208262182622826238262482625826268262782628826298263082631826328263382634826358263682637826388263982640826418264282643826448264582646826478264882649826508265182652826538265482655826568265782658826598266082661826628266382664826658266682667826688266982670826718267282673826748267582676826778267882679826808268182682826838268482685826868268782688826898269082691826928269382694826958269682697826988269982700827018270282703827048270582706827078270882709827108271182712827138271482715827168271782718827198272082721827228272382724827258272682727827288272982730827318273282733827348273582736827378273882739827408274182742827438274482745827468274782748827498275082751827528275382754827558275682757827588275982760827618276282763827648276582766827678276882769827708277182772827738277482775827768277782778827798278082781827828278382784827858278682787827888278982790827918279282793827948279582796827978279882799828008280182802828038280482805828068280782808828098281082811828128281382814828158281682817828188281982820828218282282823828248282582826828278282882829828308283182832828338283482835828368283782838828398284082841828428284382844828458284682847828488284982850828518285282853828548285582856828578285882859828608286182862828638286482865828668286782868828698287082871828728287382874828758287682877828788287982880828818288282883828848288582886828878288882889828908289182892828938289482895828968289782898828998290082901829028290382904829058290682907829088290982910829118291282913829148291582916829178291882919829208292182922829238292482925829268292782928829298293082931829328293382934829358293682937829388293982940829418294282943829448294582946829478294882949829508295182952829538295482955829568295782958829598296082961829628296382964829658296682967829688296982970829718297282973829748297582976829778297882979829808298182982829838298482985829868298782988829898299082991829928299382994829958299682997829988299983000830018300283003830048300583006830078300883009830108301183012830138301483015830168301783018830198302083021830228302383024830258302683027830288302983030830318303283033830348303583036830378303883039830408304183042830438304483045830468304783048830498305083051830528305383054830558305683057830588305983060830618306283063830648306583066830678306883069830708307183072830738307483075830768307783078830798308083081830828308383084830858308683087830888308983090830918309283093830948309583096830978309883099831008310183102831038310483105831068310783108831098311083111831128311383114831158311683117831188311983120831218312283123831248312583126831278312883129831308313183132831338313483135831368313783138831398314083141831428314383144831458314683147831488314983150831518315283153831548315583156831578315883159831608316183162831638316483165831668316783168831698317083171831728317383174831758317683177831788317983180831818318283183831848318583186831878318883189831908319183192831938319483195831968319783198831998320083201832028320383204832058320683207832088320983210832118321283213832148321583216832178321883219832208322183222832238322483225832268322783228832298323083231832328323383234832358323683237832388323983240832418324283243832448324583246832478324883249832508325183252832538325483255832568325783258832598326083261832628326383264832658326683267832688326983270832718327283273832748327583276832778327883279832808328183282832838328483285832868328783288832898329083291832928329383294832958329683297832988329983300833018330283303833048330583306833078330883309833108331183312833138331483315833168331783318833198332083321833228332383324833258332683327833288332983330833318333283333833348333583336833378333883339833408334183342833438334483345833468334783348833498335083351833528335383354833558335683357833588335983360833618336283363833648336583366833678336883369833708337183372833738337483375833768337783378833798338083381833828338383384833858338683387833888338983390833918339283393833948339583396833978339883399834008340183402834038340483405834068340783408834098341083411834128341383414834158341683417834188341983420834218342283423834248342583426834278342883429834308343183432834338343483435834368343783438834398344083441834428344383444834458344683447834488344983450834518345283453834548345583456834578345883459834608346183462834638346483465834668346783468834698347083471834728347383474834758347683477834788347983480834818348283483834848348583486834878348883489834908349183492834938349483495834968349783498834998350083501835028350383504835058350683507835088350983510835118351283513835148351583516835178351883519835208352183522835238352483525835268352783528835298353083531835328353383534835358353683537835388353983540835418354283543835448354583546835478354883549835508355183552835538355483555835568355783558835598356083561835628356383564835658356683567835688356983570835718357283573835748357583576835778357883579835808358183582835838358483585835868358783588835898359083591835928359383594835958359683597835988359983600836018360283603836048360583606836078360883609836108361183612836138361483615836168361783618836198362083621836228362383624836258362683627836288362983630836318363283633836348363583636836378363883639836408364183642836438364483645836468364783648836498365083651836528365383654836558365683657836588365983660836618366283663836648366583666836678366883669836708367183672836738367483675836768367783678836798368083681836828368383684836858368683687836888368983690836918369283693836948369583696836978369883699837008370183702837038370483705837068370783708837098371083711837128371383714837158371683717837188371983720837218372283723837248372583726837278372883729837308373183732837338373483735837368373783738837398374083741837428374383744837458374683747837488374983750837518375283753837548375583756837578375883759837608376183762837638376483765837668376783768837698377083771837728377383774837758377683777837788377983780837818378283783837848378583786837878378883789837908379183792837938379483795837968379783798837998380083801838028380383804838058380683807838088380983810838118381283813838148381583816838178381883819838208382183822838238382483825838268382783828838298383083831838328383383834838358383683837838388383983840838418384283843838448384583846838478384883849838508385183852838538385483855838568385783858838598386083861838628386383864838658386683867838688386983870838718387283873838748387583876838778387883879838808388183882838838388483885838868388783888838898389083891838928389383894838958389683897838988389983900839018390283903839048390583906839078390883909839108391183912839138391483915839168391783918839198392083921839228392383924839258392683927839288392983930839318393283933839348393583936839378393883939839408394183942839438394483945839468394783948839498395083951839528395383954839558395683957839588395983960839618396283963839648396583966839678396883969839708397183972839738397483975839768397783978839798398083981839828398383984839858398683987839888398983990839918399283993839948399583996839978399883999840008400184002840038400484005840068400784008840098401084011840128401384014840158401684017840188401984020840218402284023840248402584026840278402884029840308403184032840338403484035840368403784038840398404084041840428404384044840458404684047840488404984050840518405284053840548405584056840578405884059840608406184062840638406484065840668406784068840698407084071840728407384074840758407684077840788407984080840818408284083840848408584086840878408884089840908409184092840938409484095840968409784098840998410084101841028410384104841058410684107841088410984110841118411284113841148411584116841178411884119841208412184122841238412484125841268412784128841298413084131841328413384134841358413684137841388413984140841418414284143841448414584146841478414884149841508415184152841538415484155841568415784158841598416084161841628416384164841658416684167841688416984170841718417284173841748417584176841778417884179841808418184182841838418484185841868418784188841898419084191841928419384194841958419684197841988419984200842018420284203842048420584206842078420884209842108421184212842138421484215842168421784218842198422084221842228422384224842258422684227842288422984230842318423284233842348423584236842378423884239842408424184242842438424484245842468424784248842498425084251842528425384254842558425684257842588425984260842618426284263842648426584266842678426884269842708427184272842738427484275842768427784278842798428084281842828428384284842858428684287842888428984290842918429284293842948429584296842978429884299843008430184302843038430484305843068430784308843098431084311843128431384314843158431684317843188431984320843218432284323843248432584326843278432884329843308433184332843338433484335843368433784338843398434084341843428434384344843458434684347843488434984350843518435284353843548435584356843578435884359843608436184362843638436484365843668436784368843698437084371843728437384374843758437684377843788437984380843818438284383843848438584386843878438884389843908439184392843938439484395843968439784398843998440084401844028440384404844058440684407844088440984410844118441284413844148441584416844178441884419844208442184422844238442484425844268442784428844298443084431844328443384434844358443684437844388443984440844418444284443844448444584446844478444884449844508445184452844538445484455844568445784458844598446084461844628446384464844658446684467844688446984470844718447284473844748447584476844778447884479844808448184482844838448484485844868448784488844898449084491844928449384494844958449684497844988449984500845018450284503845048450584506845078450884509845108451184512845138451484515845168451784518845198452084521845228452384524845258452684527845288452984530845318453284533845348453584536845378453884539845408454184542845438454484545845468454784548845498455084551845528455384554845558455684557845588455984560845618456284563845648456584566845678456884569845708457184572845738457484575845768457784578845798458084581845828458384584845858458684587845888458984590845918459284593845948459584596845978459884599846008460184602846038460484605846068460784608846098461084611846128461384614846158461684617846188461984620846218462284623846248462584626846278462884629846308463184632846338463484635846368463784638846398464084641846428464384644846458464684647846488464984650846518465284653846548465584656846578465884659846608466184662846638466484665846668466784668846698467084671846728467384674846758467684677846788467984680846818468284683846848468584686846878468884689846908469184692846938469484695846968469784698846998470084701847028470384704847058470684707847088470984710847118471284713847148471584716847178471884719847208472184722847238472484725847268472784728847298473084731847328473384734847358473684737847388473984740847418474284743847448474584746847478474884749847508475184752847538475484755847568475784758847598476084761847628476384764847658476684767847688476984770847718477284773847748477584776847778477884779847808478184782847838478484785847868478784788847898479084791847928479384794847958479684797847988479984800848018480284803848048480584806848078480884809848108481184812848138481484815848168481784818848198482084821848228482384824848258482684827848288482984830848318483284833848348483584836848378483884839848408484184842848438484484845848468484784848848498485084851848528485384854848558485684857848588485984860848618486284863848648486584866848678486884869848708487184872848738487484875848768487784878848798488084881848828488384884848858488684887848888488984890848918489284893848948489584896848978489884899849008490184902849038490484905849068490784908849098491084911849128491384914849158491684917849188491984920849218492284923849248492584926849278492884929849308493184932849338493484935849368493784938849398494084941849428494384944849458494684947849488494984950849518495284953849548495584956849578495884959849608496184962849638496484965849668496784968849698497084971849728497384974849758497684977849788497984980849818498284983849848498584986849878498884989849908499184992849938499484995849968499784998849998500085001850028500385004850058500685007850088500985010850118501285013850148501585016850178501885019850208502185022850238502485025850268502785028850298503085031850328503385034850358503685037850388503985040850418504285043850448504585046850478504885049850508505185052850538505485055850568505785058850598506085061850628506385064850658506685067850688506985070850718507285073850748507585076850778507885079850808508185082850838508485085850868508785088850898509085091850928509385094850958509685097850988509985100851018510285103851048510585106851078510885109851108511185112851138511485115851168511785118851198512085121851228512385124851258512685127851288512985130851318513285133851348513585136851378513885139851408514185142851438514485145851468514785148851498515085151851528515385154851558515685157851588515985160851618516285163851648516585166851678516885169851708517185172851738517485175851768517785178851798518085181851828518385184851858518685187851888518985190851918519285193851948519585196851978519885199852008520185202852038520485205852068520785208852098521085211852128521385214852158521685217852188521985220852218522285223852248522585226852278522885229852308523185232852338523485235852368523785238852398524085241852428524385244852458524685247852488524985250852518525285253852548525585256852578525885259852608526185262852638526485265852668526785268852698527085271852728527385274852758527685277852788527985280852818528285283852848528585286852878528885289852908529185292852938529485295852968529785298852998530085301853028530385304853058530685307853088530985310853118531285313853148531585316853178531885319853208532185322853238532485325853268532785328853298533085331853328533385334853358533685337853388533985340853418534285343853448534585346853478534885349853508535185352853538535485355853568535785358853598536085361853628536385364853658536685367853688536985370853718537285373853748537585376853778537885379853808538185382853838538485385853868538785388853898539085391853928539385394853958539685397853988539985400854018540285403854048540585406854078540885409854108541185412854138541485415854168541785418854198542085421854228542385424854258542685427854288542985430854318543285433854348543585436854378543885439854408544185442854438544485445854468544785448854498545085451854528545385454854558545685457854588545985460854618546285463854648546585466854678546885469854708547185472854738547485475854768547785478854798548085481854828548385484854858548685487854888548985490854918549285493854948549585496854978549885499855008550185502855038550485505855068550785508855098551085511855128551385514855158551685517855188551985520855218552285523855248552585526855278552885529855308553185532855338553485535855368553785538855398554085541855428554385544855458554685547855488554985550855518555285553855548555585556855578555885559855608556185562855638556485565855668556785568855698557085571855728557385574855758557685577855788557985580855818558285583855848558585586855878558885589855908559185592855938559485595855968559785598855998560085601856028560385604856058560685607856088560985610856118561285613856148561585616856178561885619856208562185622856238562485625856268562785628856298563085631856328563385634856358563685637856388563985640856418564285643856448564585646856478564885649856508565185652856538565485655856568565785658856598566085661856628566385664856658566685667856688566985670856718567285673856748567585676856778567885679856808568185682856838568485685856868568785688856898569085691856928569385694856958569685697856988569985700857018570285703857048570585706857078570885709857108571185712857138571485715857168571785718857198572085721857228572385724857258572685727857288572985730857318573285733857348573585736857378573885739857408574185742857438574485745857468574785748857498575085751857528575385754857558575685757857588575985760857618576285763857648576585766857678576885769857708577185772857738577485775857768577785778857798578085781857828578385784857858578685787857888578985790857918579285793857948579585796857978579885799858008580185802858038580485805858068580785808858098581085811858128581385814858158581685817858188581985820858218582285823858248582585826858278582885829858308583185832858338583485835858368583785838858398584085841858428584385844858458584685847858488584985850858518585285853858548585585856858578585885859858608586185862858638586485865858668586785868858698587085871858728587385874858758587685877858788587985880858818588285883858848588585886858878588885889858908589185892858938589485895858968589785898858998590085901859028590385904859058590685907859088590985910859118591285913859148591585916859178591885919859208592185922859238592485925859268592785928859298593085931859328593385934859358593685937859388593985940859418594285943859448594585946859478594885949859508595185952859538595485955859568595785958859598596085961859628596385964859658596685967859688596985970859718597285973859748597585976859778597885979859808598185982859838598485985859868598785988859898599085991859928599385994859958599685997859988599986000860018600286003860048600586006860078600886009860108601186012860138601486015860168601786018860198602086021860228602386024860258602686027860288602986030860318603286033860348603586036860378603886039860408604186042860438604486045860468604786048860498605086051860528605386054860558605686057860588605986060860618606286063860648606586066860678606886069860708607186072860738607486075860768607786078860798608086081860828608386084860858608686087860888608986090860918609286093860948609586096860978609886099861008610186102861038610486105861068610786108861098611086111861128611386114861158611686117861188611986120861218612286123861248612586126861278612886129861308613186132861338613486135861368613786138861398614086141861428614386144861458614686147861488614986150861518615286153861548615586156861578615886159861608616186162861638616486165861668616786168861698617086171861728617386174861758617686177861788617986180861818618286183861848618586186861878618886189861908619186192861938619486195861968619786198861998620086201862028620386204862058620686207862088620986210862118621286213862148621586216862178621886219862208622186222862238622486225862268622786228862298623086231862328623386234862358623686237862388623986240862418624286243862448624586246862478624886249862508625186252862538625486255862568625786258862598626086261862628626386264862658626686267862688626986270862718627286273862748627586276862778627886279862808628186282862838628486285862868628786288862898629086291862928629386294862958629686297862988629986300863018630286303863048630586306863078630886309863108631186312863138631486315863168631786318863198632086321863228632386324863258632686327863288632986330863318633286333863348633586336863378633886339863408634186342863438634486345863468634786348863498635086351863528635386354863558635686357863588635986360863618636286363863648636586366863678636886369863708637186372863738637486375863768637786378863798638086381863828638386384863858638686387863888638986390863918639286393863948639586396863978639886399864008640186402864038640486405864068640786408864098641086411864128641386414864158641686417864188641986420864218642286423864248642586426864278642886429864308643186432864338643486435864368643786438864398644086441864428644386444864458644686447864488644986450864518645286453864548645586456864578645886459864608646186462864638646486465864668646786468864698647086471864728647386474864758647686477864788647986480864818648286483864848648586486864878648886489864908649186492864938649486495864968649786498864998650086501865028650386504865058650686507865088650986510865118651286513865148651586516865178651886519865208652186522865238652486525865268652786528865298653086531865328653386534865358653686537865388653986540865418654286543865448654586546865478654886549865508655186552865538655486555865568655786558865598656086561865628656386564865658656686567865688656986570865718657286573865748657586576865778657886579865808658186582865838658486585865868658786588865898659086591865928659386594865958659686597865988659986600866018660286603866048660586606866078660886609866108661186612866138661486615866168661786618866198662086621866228662386624866258662686627866288662986630866318663286633866348663586636866378663886639866408664186642866438664486645866468664786648866498665086651866528665386654866558665686657866588665986660866618666286663866648666586666866678666886669866708667186672866738667486675866768667786678866798668086681866828668386684866858668686687866888668986690866918669286693866948669586696866978669886699867008670186702867038670486705867068670786708867098671086711867128671386714867158671686717867188671986720867218672286723867248672586726867278672886729867308673186732867338673486735867368673786738867398674086741867428674386744867458674686747867488674986750867518675286753867548675586756867578675886759867608676186762867638676486765867668676786768867698677086771867728677386774867758677686777867788677986780867818678286783867848678586786867878678886789867908679186792867938679486795867968679786798867998680086801868028680386804868058680686807868088680986810868118681286813868148681586816868178681886819868208682186822868238682486825868268682786828868298683086831868328683386834868358683686837868388683986840868418684286843868448684586846868478684886849868508685186852868538685486855868568685786858868598686086861868628686386864868658686686867868688686986870868718687286873868748687586876868778687886879868808688186882868838688486885868868688786888868898689086891868928689386894868958689686897868988689986900869018690286903869048690586906869078690886909869108691186912869138691486915869168691786918869198692086921869228692386924869258692686927869288692986930869318693286933869348693586936869378693886939869408694186942869438694486945869468694786948869498695086951869528695386954869558695686957869588695986960869618696286963869648696586966869678696886969869708697186972869738697486975869768697786978869798698086981869828698386984869858698686987869888698986990869918699286993869948699586996869978699886999870008700187002870038700487005870068700787008870098701087011870128701387014870158701687017870188701987020870218702287023870248702587026870278702887029870308703187032870338703487035870368703787038870398704087041870428704387044870458704687047870488704987050870518705287053870548705587056870578705887059870608706187062870638706487065870668706787068870698707087071870728707387074870758707687077870788707987080870818708287083870848708587086870878708887089870908709187092870938709487095870968709787098870998710087101871028710387104871058710687107871088710987110871118711287113871148711587116871178711887119871208712187122871238712487125871268712787128871298713087131871328713387134871358713687137871388713987140871418714287143871448714587146871478714887149871508715187152871538715487155871568715787158871598716087161871628716387164871658716687167871688716987170871718717287173871748717587176871778717887179871808718187182871838718487185871868718787188871898719087191871928719387194871958719687197871988719987200872018720287203872048720587206872078720887209872108721187212872138721487215872168721787218872198722087221872228722387224872258722687227872288722987230872318723287233872348723587236872378723887239872408724187242872438724487245872468724787248872498725087251872528725387254872558725687257872588725987260872618726287263872648726587266872678726887269872708727187272872738727487275872768727787278872798728087281872828728387284872858728687287872888728987290872918729287293872948729587296872978729887299873008730187302873038730487305873068730787308873098731087311873128731387314873158731687317873188731987320873218732287323873248732587326873278732887329873308733187332873338733487335873368733787338873398734087341873428734387344873458734687347873488734987350873518735287353873548735587356873578735887359873608736187362873638736487365873668736787368873698737087371873728737387374873758737687377873788737987380873818738287383873848738587386873878738887389873908739187392873938739487395873968739787398873998740087401874028740387404874058740687407874088740987410874118741287413874148741587416874178741887419874208742187422874238742487425874268742787428874298743087431874328743387434874358743687437874388743987440874418744287443874448744587446874478744887449874508745187452874538745487455874568745787458874598746087461874628746387464874658746687467874688746987470874718747287473874748747587476874778747887479874808748187482874838748487485874868748787488874898749087491874928749387494874958749687497874988749987500875018750287503875048750587506875078750887509875108751187512875138751487515875168751787518875198752087521875228752387524875258752687527875288752987530875318753287533875348753587536875378753887539875408754187542875438754487545875468754787548875498755087551875528755387554875558755687557875588755987560875618756287563875648756587566875678756887569875708757187572875738757487575875768757787578875798758087581875828758387584875858758687587875888758987590875918759287593875948759587596875978759887599876008760187602876038760487605876068760787608876098761087611876128761387614876158761687617876188761987620876218762287623876248762587626876278762887629876308763187632876338763487635876368763787638876398764087641876428764387644876458764687647876488764987650876518765287653876548765587656876578765887659876608766187662876638766487665876668766787668876698767087671876728767387674876758767687677876788767987680876818768287683876848768587686876878768887689876908769187692876938769487695876968769787698876998770087701877028770387704877058770687707877088770987710877118771287713877148771587716877178771887719877208772187722877238772487725877268772787728877298773087731877328773387734877358773687737877388773987740877418774287743877448774587746877478774887749877508775187752877538775487755877568775787758877598776087761877628776387764877658776687767877688776987770877718777287773877748777587776877778777887779877808778187782877838778487785877868778787788877898779087791877928779387794877958779687797877988779987800878018780287803878048780587806878078780887809878108781187812878138781487815878168781787818878198782087821878228782387824878258782687827878288782987830878318783287833878348783587836878378783887839878408784187842878438784487845878468784787848878498785087851878528785387854878558785687857878588785987860878618786287863878648786587866878678786887869878708787187872878738787487875878768787787878878798788087881878828788387884878858788687887878888788987890878918789287893878948789587896878978789887899879008790187902879038790487905879068790787908879098791087911879128791387914879158791687917879188791987920879218792287923879248792587926879278792887929879308793187932879338793487935879368793787938879398794087941879428794387944879458794687947879488794987950879518795287953879548795587956879578795887959879608796187962879638796487965879668796787968879698797087971879728797387974879758797687977879788797987980879818798287983879848798587986879878798887989879908799187992879938799487995879968799787998879998800088001880028800388004880058800688007880088800988010880118801288013880148801588016880178801888019880208802188022880238802488025880268802788028880298803088031880328803388034880358803688037880388803988040880418804288043880448804588046880478804888049880508805188052880538805488055880568805788058880598806088061880628806388064880658806688067880688806988070880718807288073880748807588076880778807888079880808808188082880838808488085880868808788088880898809088091880928809388094880958809688097880988809988100881018810288103881048810588106881078810888109881108811188112881138811488115881168811788118881198812088121881228812388124881258812688127881288812988130881318813288133881348813588136881378813888139881408814188142881438814488145881468814788148881498815088151881528815388154881558815688157881588815988160881618816288163881648816588166881678816888169881708817188172881738817488175881768817788178881798818088181881828818388184881858818688187881888818988190881918819288193881948819588196881978819888199882008820188202882038820488205882068820788208882098821088211882128821388214882158821688217882188821988220882218822288223882248822588226882278822888229882308823188232882338823488235882368823788238882398824088241882428824388244882458824688247882488824988250882518825288253882548825588256882578825888259882608826188262882638826488265882668826788268882698827088271882728827388274882758827688277882788827988280882818828288283882848828588286882878828888289882908829188292882938829488295882968829788298882998830088301883028830388304883058830688307883088830988310883118831288313883148831588316883178831888319883208832188322883238832488325883268832788328883298833088331883328833388334883358833688337883388833988340883418834288343883448834588346883478834888349883508835188352883538835488355883568835788358883598836088361883628836388364883658836688367883688836988370883718837288373883748837588376883778837888379883808838188382883838838488385883868838788388883898839088391883928839388394883958839688397883988839988400884018840288403884048840588406884078840888409884108841188412884138841488415884168841788418884198842088421884228842388424884258842688427884288842988430884318843288433884348843588436884378843888439884408844188442884438844488445884468844788448884498845088451884528845388454884558845688457884588845988460884618846288463884648846588466884678846888469884708847188472884738847488475884768847788478884798848088481884828848388484884858848688487884888848988490884918849288493884948849588496884978849888499885008850188502885038850488505885068850788508885098851088511885128851388514885158851688517885188851988520885218852288523885248852588526885278852888529885308853188532885338853488535885368853788538885398854088541885428854388544885458854688547885488854988550885518855288553885548855588556885578855888559885608856188562885638856488565885668856788568885698857088571885728857388574885758857688577885788857988580885818858288583885848858588586885878858888589885908859188592885938859488595885968859788598885998860088601886028860388604886058860688607886088860988610886118861288613886148861588616886178861888619886208862188622886238862488625886268862788628886298863088631886328863388634886358863688637886388863988640886418864288643886448864588646886478864888649886508865188652886538865488655886568865788658886598866088661886628866388664886658866688667886688866988670886718867288673886748867588676886778867888679886808868188682886838868488685886868868788688886898869088691886928869388694886958869688697886988869988700887018870288703887048870588706887078870888709887108871188712887138871488715887168871788718887198872088721887228872388724887258872688727887288872988730887318873288733887348873588736887378873888739887408874188742887438874488745887468874788748887498875088751887528875388754887558875688757887588875988760887618876288763887648876588766887678876888769887708877188772887738877488775887768877788778887798878088781887828878388784887858878688787887888878988790887918879288793887948879588796887978879888799888008880188802888038880488805888068880788808888098881088811888128881388814888158881688817888188881988820888218882288823888248882588826888278882888829888308883188832888338883488835888368883788838888398884088841888428884388844888458884688847888488884988850888518885288853888548885588856888578885888859888608886188862888638886488865888668886788868888698887088871888728887388874888758887688877888788887988880888818888288883888848888588886888878888888889888908889188892888938889488895888968889788898888998890088901889028890388904889058890688907889088890988910889118891288913889148891588916889178891888919889208892188922889238892488925889268892788928889298893088931889328893388934889358893688937889388893988940889418894288943889448894588946889478894888949889508895188952889538895488955889568895788958889598896088961889628896388964889658896688967889688896988970889718897288973889748897588976889778897888979889808898188982889838898488985889868898788988889898899088991889928899388994889958899688997889988899989000890018900289003890048900589006890078900889009890108901189012890138901489015890168901789018890198902089021890228902389024890258902689027890288902989030890318903289033890348903589036890378903889039890408904189042890438904489045890468904789048890498905089051890528905389054890558905689057890588905989060890618906289063890648906589066890678906889069890708907189072890738907489075890768907789078890798908089081890828908389084890858908689087890888908989090890918909289093890948909589096890978909889099891008910189102891038910489105891068910789108891098911089111891128911389114891158911689117891188911989120891218912289123891248912589126891278912889129891308913189132891338913489135891368913789138891398914089141891428914389144891458914689147891488914989150891518915289153891548915589156891578915889159891608916189162891638916489165891668916789168891698917089171891728917389174891758917689177891788917989180891818918289183891848918589186891878918889189891908919189192891938919489195891968919789198891998920089201892028920389204892058920689207892088920989210892118921289213892148921589216892178921889219892208922189222892238922489225892268922789228892298923089231892328923389234892358923689237892388923989240892418924289243892448924589246892478924889249892508925189252892538925489255892568925789258892598926089261892628926389264892658926689267892688926989270892718927289273892748927589276892778927889279892808928189282892838928489285892868928789288892898929089291892928929389294892958929689297892988929989300893018930289303893048930589306893078930889309893108931189312893138931489315893168931789318893198932089321893228932389324893258932689327893288932989330893318933289333893348933589336893378933889339893408934189342893438934489345893468934789348893498935089351893528935389354893558935689357893588935989360893618936289363893648936589366893678936889369893708937189372893738937489375893768937789378893798938089381893828938389384893858938689387893888938989390893918939289393893948939589396893978939889399894008940189402894038940489405894068940789408894098941089411894128941389414894158941689417894188941989420894218942289423894248942589426894278942889429894308943189432894338943489435894368943789438894398944089441894428944389444894458944689447894488944989450894518945289453894548945589456894578945889459894608946189462894638946489465894668946789468894698947089471894728947389474894758947689477894788947989480894818948289483894848948589486894878948889489894908949189492894938949489495894968949789498894998950089501895028950389504895058950689507895088950989510895118951289513895148951589516895178951889519895208952189522895238952489525895268952789528895298953089531895328953389534895358953689537895388953989540895418954289543895448954589546895478954889549895508955189552895538955489555895568955789558895598956089561895628956389564895658956689567895688956989570895718957289573895748957589576895778957889579895808958189582895838958489585895868958789588895898959089591895928959389594895958959689597895988959989600896018960289603896048960589606896078960889609896108961189612896138961489615896168961789618896198962089621896228962389624896258962689627896288962989630896318963289633896348963589636896378963889639896408964189642896438964489645896468964789648896498965089651896528965389654896558965689657896588965989660896618966289663896648966589666896678966889669896708967189672896738967489675896768967789678896798968089681896828968389684896858968689687896888968989690896918969289693896948969589696896978969889699897008970189702897038970489705897068970789708897098971089711897128971389714897158971689717897188971989720897218972289723897248972589726897278972889729897308973189732897338973489735897368973789738897398974089741897428974389744897458974689747897488974989750897518975289753897548975589756897578975889759897608976189762897638976489765897668976789768897698977089771897728977389774897758977689777897788977989780897818978289783897848978589786897878978889789897908979189792897938979489795897968979789798897998980089801898028980389804898058980689807898088980989810898118981289813898148981589816898178981889819898208982189822898238982489825898268982789828898298983089831898328983389834898358983689837898388983989840898418984289843898448984589846898478984889849898508985189852898538985489855898568985789858898598986089861898628986389864898658986689867898688986989870898718987289873898748987589876898778987889879898808988189882898838988489885898868988789888898898989089891898928989389894898958989689897898988989989900899018990289903899048990589906899078990889909899108991189912899138991489915899168991789918899198992089921899228992389924899258992689927899288992989930899318993289933899348993589936899378993889939899408994189942899438994489945899468994789948899498995089951899528995389954899558995689957899588995989960899618996289963899648996589966899678996889969899708997189972899738997489975899768997789978899798998089981899828998389984899858998689987899888998989990899918999289993899948999589996899978999889999900009000190002900039000490005900069000790008900099001090011900129001390014900159001690017900189001990020900219002290023900249002590026900279002890029900309003190032900339003490035900369003790038900399004090041900429004390044900459004690047900489004990050900519005290053900549005590056900579005890059900609006190062900639006490065900669006790068900699007090071900729007390074900759007690077900789007990080900819008290083900849008590086900879008890089900909009190092900939009490095900969009790098900999010090101901029010390104901059010690107901089010990110901119011290113901149011590116901179011890119901209012190122901239012490125901269012790128901299013090131901329013390134901359013690137901389013990140901419014290143901449014590146901479014890149901509015190152901539015490155901569015790158901599016090161901629016390164901659016690167901689016990170901719017290173901749017590176901779017890179901809018190182901839018490185901869018790188901899019090191901929019390194901959019690197901989019990200902019020290203902049020590206902079020890209902109021190212902139021490215902169021790218902199022090221902229022390224902259022690227902289022990230902319023290233902349023590236902379023890239902409024190242902439024490245902469024790248902499025090251902529025390254902559025690257902589025990260902619026290263902649026590266902679026890269902709027190272902739027490275902769027790278902799028090281902829028390284902859028690287902889028990290902919029290293902949029590296902979029890299903009030190302903039030490305903069030790308903099031090311903129031390314903159031690317903189031990320903219032290323903249032590326903279032890329903309033190332903339033490335903369033790338903399034090341903429034390344903459034690347903489034990350903519035290353903549035590356903579035890359903609036190362903639036490365903669036790368903699037090371903729037390374903759037690377903789037990380903819038290383903849038590386903879038890389903909039190392903939039490395903969039790398903999040090401904029040390404904059040690407904089040990410904119041290413904149041590416904179041890419904209042190422904239042490425904269042790428904299043090431904329043390434904359043690437904389043990440904419044290443904449044590446904479044890449904509045190452904539045490455904569045790458904599046090461904629046390464904659046690467904689046990470904719047290473904749047590476904779047890479904809048190482904839048490485904869048790488904899049090491904929049390494904959049690497904989049990500905019050290503905049050590506905079050890509905109051190512905139051490515905169051790518905199052090521905229052390524905259052690527905289052990530905319053290533905349053590536905379053890539905409054190542905439054490545905469054790548905499055090551905529055390554905559055690557905589055990560905619056290563905649056590566905679056890569905709057190572905739057490575905769057790578905799058090581905829058390584905859058690587905889058990590905919059290593905949059590596905979059890599906009060190602906039060490605906069060790608906099061090611906129061390614906159061690617906189061990620906219062290623906249062590626906279062890629906309063190632906339063490635906369063790638906399064090641906429064390644906459064690647906489064990650906519065290653906549065590656906579065890659906609066190662906639066490665906669066790668906699067090671906729067390674906759067690677906789067990680906819068290683906849068590686906879068890689906909069190692906939069490695906969069790698906999070090701907029070390704907059070690707907089070990710907119071290713907149071590716907179071890719907209072190722907239072490725907269072790728907299073090731907329073390734907359073690737907389073990740907419074290743907449074590746907479074890749907509075190752907539075490755907569075790758907599076090761907629076390764907659076690767907689076990770907719077290773907749077590776907779077890779907809078190782907839078490785907869078790788907899079090791907929079390794907959079690797907989079990800908019080290803908049080590806908079080890809908109081190812908139081490815908169081790818908199082090821908229082390824908259082690827908289082990830908319083290833908349083590836908379083890839908409084190842908439084490845908469084790848908499085090851908529085390854908559085690857908589085990860908619086290863908649086590866908679086890869908709087190872908739087490875908769087790878908799088090881908829088390884908859088690887908889088990890908919089290893908949089590896908979089890899909009090190902909039090490905909069090790908909099091090911909129091390914909159091690917909189091990920909219092290923909249092590926909279092890929909309093190932909339093490935909369093790938909399094090941909429094390944909459094690947909489094990950909519095290953909549095590956909579095890959909609096190962909639096490965909669096790968909699097090971909729097390974909759097690977909789097990980909819098290983909849098590986909879098890989909909099190992909939099490995909969099790998909999100091001910029100391004910059100691007910089100991010910119101291013910149101591016910179101891019910209102191022910239102491025910269102791028910299103091031910329103391034910359103691037910389103991040910419104291043910449104591046910479104891049910509105191052910539105491055910569105791058910599106091061910629106391064910659106691067910689106991070910719107291073910749107591076910779107891079910809108191082910839108491085910869108791088910899109091091910929109391094910959109691097910989109991100911019110291103911049110591106911079110891109911109111191112911139111491115911169111791118911199112091121911229112391124911259112691127911289112991130911319113291133911349113591136911379113891139911409114191142911439114491145911469114791148911499115091151911529115391154911559115691157911589115991160911619116291163911649116591166911679116891169911709117191172911739117491175911769117791178911799118091181911829118391184911859118691187911889118991190911919119291193911949119591196911979119891199912009120191202912039120491205912069120791208912099121091211912129121391214912159121691217912189121991220912219122291223912249122591226912279122891229912309123191232912339123491235912369123791238912399124091241912429124391244912459124691247912489124991250912519125291253912549125591256912579125891259912609126191262912639126491265912669126791268912699127091271912729127391274912759127691277912789127991280912819128291283912849128591286912879128891289912909129191292912939129491295912969129791298912999130091301913029130391304913059130691307913089130991310913119131291313913149131591316913179131891319913209132191322913239132491325913269132791328913299133091331913329133391334913359133691337913389133991340913419134291343913449134591346913479134891349913509135191352913539135491355913569135791358913599136091361913629136391364913659136691367913689136991370913719137291373913749137591376913779137891379913809138191382913839138491385913869138791388913899139091391913929139391394913959139691397913989139991400914019140291403914049140591406914079140891409914109141191412914139141491415914169141791418914199142091421914229142391424914259142691427914289142991430914319143291433914349143591436914379143891439914409144191442914439144491445914469144791448914499145091451914529145391454914559145691457914589145991460914619146291463914649146591466914679146891469914709147191472914739147491475914769147791478914799148091481914829148391484914859148691487914889148991490914919149291493914949149591496914979149891499915009150191502915039150491505915069150791508915099151091511915129151391514915159151691517915189151991520915219152291523915249152591526915279152891529915309153191532915339153491535915369153791538915399154091541915429154391544915459154691547915489154991550915519155291553915549155591556915579155891559915609156191562915639156491565915669156791568915699157091571915729157391574915759157691577915789157991580915819158291583915849158591586915879158891589915909159191592915939159491595915969159791598915999160091601916029160391604916059160691607916089160991610916119161291613916149161591616916179161891619916209162191622916239162491625916269162791628916299163091631916329163391634916359163691637916389163991640916419164291643916449164591646916479164891649916509165191652916539165491655916569165791658916599166091661916629166391664916659166691667916689166991670916719167291673916749167591676916779167891679916809168191682916839168491685916869168791688916899169091691916929169391694916959169691697916989169991700917019170291703917049170591706917079170891709917109171191712917139171491715917169171791718917199172091721917229172391724917259172691727917289172991730917319173291733917349173591736917379173891739917409174191742917439174491745917469174791748917499175091751917529175391754917559175691757917589175991760917619176291763917649176591766917679176891769917709177191772917739177491775917769177791778917799178091781917829178391784917859178691787917889178991790917919179291793917949179591796917979179891799918009180191802918039180491805918069180791808918099181091811918129181391814918159181691817918189181991820918219182291823918249182591826918279182891829918309183191832918339183491835918369183791838918399184091841918429184391844918459184691847918489184991850918519185291853918549185591856918579185891859918609186191862918639186491865918669186791868918699187091871918729187391874918759187691877918789187991880918819188291883918849188591886918879188891889918909189191892918939189491895918969189791898918999190091901919029190391904919059190691907919089190991910919119191291913919149191591916919179191891919919209192191922919239192491925919269192791928919299193091931919329193391934919359193691937919389193991940919419194291943919449194591946919479194891949919509195191952919539195491955919569195791958919599196091961919629196391964919659196691967919689196991970919719197291973919749197591976919779197891979919809198191982919839198491985919869198791988919899199091991919929199391994919959199691997919989199992000920019200292003920049200592006920079200892009920109201192012920139201492015920169201792018920199202092021920229202392024920259202692027920289202992030920319203292033920349203592036920379203892039920409204192042920439204492045920469204792048920499205092051920529205392054920559205692057920589205992060920619206292063920649206592066920679206892069920709207192072920739207492075920769207792078920799208092081920829208392084920859208692087920889208992090920919209292093920949209592096920979209892099921009210192102921039210492105921069210792108921099211092111921129211392114921159211692117921189211992120921219212292123921249212592126921279212892129921309213192132921339213492135921369213792138921399214092141921429214392144921459214692147921489214992150921519215292153921549215592156921579215892159921609216192162921639216492165921669216792168921699217092171921729217392174921759217692177921789217992180921819218292183921849218592186921879218892189921909219192192921939219492195921969219792198921999220092201922029220392204922059220692207922089220992210922119221292213922149221592216922179221892219922209222192222922239222492225922269222792228922299223092231922329223392234922359223692237922389223992240922419224292243922449224592246922479224892249922509225192252922539225492255922569225792258922599226092261922629226392264922659226692267922689226992270922719227292273922749227592276922779227892279922809228192282922839228492285922869228792288922899229092291922929229392294922959229692297922989229992300923019230292303923049230592306923079230892309923109231192312923139231492315923169231792318923199232092321923229232392324923259232692327923289232992330923319233292333923349233592336923379233892339923409234192342923439234492345923469234792348923499235092351923529235392354923559235692357923589235992360923619236292363923649236592366923679236892369923709237192372923739237492375923769237792378923799238092381923829238392384923859238692387923889238992390923919239292393923949239592396923979239892399924009240192402924039240492405924069240792408924099241092411924129241392414924159241692417924189241992420924219242292423924249242592426924279242892429924309243192432924339243492435924369243792438924399244092441924429244392444924459244692447924489244992450924519245292453924549245592456924579245892459924609246192462924639246492465924669246792468924699247092471924729247392474924759247692477924789247992480924819248292483924849248592486924879248892489924909249192492924939249492495924969249792498924999250092501925029250392504925059250692507925089250992510925119251292513925149251592516925179251892519925209252192522925239252492525925269252792528925299253092531925329253392534925359253692537925389253992540925419254292543925449254592546925479254892549925509255192552925539255492555925569255792558925599256092561925629256392564925659256692567925689256992570925719257292573925749257592576925779257892579925809258192582925839258492585925869258792588925899259092591925929259392594925959259692597925989259992600926019260292603926049260592606926079260892609926109261192612926139261492615926169261792618926199262092621926229262392624926259262692627926289262992630926319263292633926349263592636926379263892639926409264192642926439264492645926469264792648926499265092651926529265392654926559265692657926589265992660926619266292663926649266592666926679266892669926709267192672926739267492675926769267792678926799268092681926829268392684926859268692687926889268992690926919269292693926949269592696926979269892699927009270192702927039270492705927069270792708927099271092711927129271392714927159271692717927189271992720927219272292723927249272592726927279272892729927309273192732927339273492735927369273792738927399274092741927429274392744927459274692747927489274992750927519275292753927549275592756927579275892759927609276192762927639276492765927669276792768927699277092771927729277392774927759277692777927789277992780927819278292783927849278592786927879278892789927909279192792927939279492795927969279792798927999280092801928029280392804928059280692807928089280992810928119281292813928149281592816928179281892819928209282192822928239282492825928269282792828928299283092831928329283392834928359283692837928389283992840928419284292843928449284592846928479284892849928509285192852928539285492855928569285792858928599286092861928629286392864928659286692867928689286992870928719287292873928749287592876928779287892879928809288192882928839288492885928869288792888928899289092891928929289392894928959289692897928989289992900929019290292903929049290592906929079290892909929109291192912929139291492915929169291792918929199292092921929229292392924929259292692927929289292992930929319293292933929349293592936929379293892939929409294192942929439294492945929469294792948929499295092951929529295392954929559295692957929589295992960929619296292963929649296592966929679296892969929709297192972929739297492975929769297792978929799298092981929829298392984929859298692987929889298992990929919299292993929949299592996929979299892999930009300193002930039300493005930069300793008930099301093011930129301393014930159301693017930189301993020930219302293023930249302593026930279302893029930309303193032930339303493035930369303793038930399304093041930429304393044930459304693047930489304993050930519305293053930549305593056930579305893059930609306193062930639306493065930669306793068930699307093071930729307393074930759307693077930789307993080930819308293083930849308593086930879308893089930909309193092930939309493095930969309793098930999310093101931029310393104931059310693107931089310993110931119311293113931149311593116931179311893119931209312193122931239312493125931269312793128931299313093131931329313393134931359313693137931389313993140931419314293143931449314593146931479314893149931509315193152931539315493155931569315793158931599316093161931629316393164931659316693167931689316993170931719317293173931749317593176931779317893179931809318193182931839318493185931869318793188931899319093191931929319393194931959319693197931989319993200932019320293203932049320593206932079320893209932109321193212932139321493215932169321793218932199322093221932229322393224932259322693227932289322993230932319323293233932349323593236932379323893239932409324193242932439324493245932469324793248932499325093251932529325393254932559325693257932589325993260932619326293263932649326593266932679326893269932709327193272932739327493275932769327793278932799328093281932829328393284932859328693287932889328993290932919329293293932949329593296932979329893299933009330193302933039330493305933069330793308933099331093311933129331393314933159331693317933189331993320933219332293323933249332593326933279332893329933309333193332933339333493335933369333793338933399334093341933429334393344933459334693347933489334993350933519335293353933549335593356933579335893359933609336193362933639336493365933669336793368933699337093371933729337393374933759337693377933789337993380933819338293383933849338593386933879338893389933909339193392933939339493395933969339793398933999340093401934029340393404934059340693407934089340993410934119341293413934149341593416934179341893419934209342193422934239342493425934269342793428934299343093431934329343393434934359343693437934389343993440934419344293443934449344593446934479344893449934509345193452934539345493455934569345793458934599346093461934629346393464934659346693467934689346993470934719347293473934749347593476934779347893479934809348193482934839348493485934869348793488934899349093491934929349393494934959349693497934989349993500935019350293503935049350593506935079350893509935109351193512935139351493515935169351793518935199352093521935229352393524935259352693527935289352993530935319353293533935349353593536935379353893539935409354193542935439354493545935469354793548935499355093551935529355393554935559355693557935589355993560935619356293563935649356593566935679356893569935709357193572935739357493575935769357793578935799358093581
  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. /**
  333. * Message to display when a message has been logged too many times
  334. */
  335. static MessageLimitReached: string;
  336. private static _LogCache;
  337. private static _LogLimitOutputs;
  338. /**
  339. * Gets a value indicating the number of loading errors
  340. * @ignorenaming
  341. */
  342. static errorsCount: number;
  343. /**
  344. * Callback called when a new log is added
  345. */
  346. static OnNewCacheEntry: (entry: string) => void;
  347. private static _CheckLimit;
  348. private static _GenerateLimitMessage;
  349. private static _AddLogEntry;
  350. private static _FormatMessage;
  351. private static _LogDisabled;
  352. private static _LogEnabled;
  353. private static _WarnDisabled;
  354. private static _WarnEnabled;
  355. private static _ErrorDisabled;
  356. private static _ErrorEnabled;
  357. /**
  358. * Log a message to the console
  359. */
  360. static Log: (message: string, limit?: number) => void;
  361. /**
  362. * Write a warning message to the console
  363. */
  364. static Warn: (message: string, limit?: number) => void;
  365. /**
  366. * Write an error message to the console
  367. */
  368. static Error: (message: string, limit?: number) => void;
  369. /**
  370. * Gets current log cache (list of logs)
  371. */
  372. static get LogCache(): string;
  373. /**
  374. * Clears the log cache
  375. */
  376. static ClearLogCache(): void;
  377. /**
  378. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  379. */
  380. static set LogLevels(level: number);
  381. }
  382. }
  383. declare module BABYLON {
  384. /** @hidden */
  385. export class _TypeStore {
  386. /** @hidden */
  387. static RegisteredTypes: {
  388. [key: string]: Object;
  389. };
  390. /** @hidden */
  391. static GetClass(fqdn: string): any;
  392. }
  393. }
  394. declare module BABYLON {
  395. /**
  396. * Helper to manipulate strings
  397. */
  398. export class StringTools {
  399. /**
  400. * Checks for a matching suffix at the end 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 EndsWith(str: string, suffix: string): boolean;
  406. /**
  407. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  408. * @param str Source string
  409. * @param suffix Suffix to search for in the source string
  410. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  411. */
  412. static StartsWith(str: string, suffix: string): boolean;
  413. /**
  414. * Decodes a buffer into a string
  415. * @param buffer The buffer to decode
  416. * @returns The decoded string
  417. */
  418. static Decode(buffer: Uint8Array | Uint16Array): string;
  419. /**
  420. * Encode a buffer to a base64 string
  421. * @param buffer defines the buffer to encode
  422. * @returns the encoded string
  423. */
  424. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  425. /**
  426. * Converts a number to string and pads with preceeding zeroes until it is of specified length.
  427. * @param num the number to convert and pad
  428. * @param length the expected length of the string
  429. * @returns the padded string
  430. */
  431. static PadNumber(num: number, length: number): string;
  432. }
  433. }
  434. declare module BABYLON {
  435. /**
  436. * Class containing a set of static utilities functions for deep copy.
  437. */
  438. export class DeepCopier {
  439. /**
  440. * Tries to copy an object by duplicating every property
  441. * @param source defines the source object
  442. * @param destination defines the target object
  443. * @param doNotCopyList defines a list of properties to avoid
  444. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  445. */
  446. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  447. }
  448. }
  449. declare module BABYLON {
  450. /**
  451. * Class containing a set of static utilities functions for precision date
  452. */
  453. export class PrecisionDate {
  454. /**
  455. * Gets either window.performance.now() if supported or Date.now() else
  456. */
  457. static get Now(): number;
  458. }
  459. }
  460. declare module BABYLON {
  461. /** @hidden */
  462. export class _DevTools {
  463. static WarnImport(name: string): string;
  464. }
  465. }
  466. declare module BABYLON {
  467. /**
  468. * Interface used to define the mechanism to get data from the network
  469. */
  470. export interface IWebRequest {
  471. /**
  472. * Returns client's response url
  473. */
  474. responseURL: string;
  475. /**
  476. * Returns client's status
  477. */
  478. status: number;
  479. /**
  480. * Returns client's status as a text
  481. */
  482. statusText: string;
  483. }
  484. }
  485. declare module BABYLON {
  486. /**
  487. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  488. */
  489. export class WebRequest implements IWebRequest {
  490. private readonly _xhr;
  491. /**
  492. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  493. * i.e. when loading files, where the server/service expects an Authorization header
  494. */
  495. static CustomRequestHeaders: {
  496. [key: string]: string;
  497. };
  498. /**
  499. * Add callback functions in this array to update all the requests before they get sent to the network
  500. */
  501. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  502. private _injectCustomRequestHeaders;
  503. /**
  504. * Gets or sets a function to be called when loading progress changes
  505. */
  506. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  507. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  508. /**
  509. * Returns client's state
  510. */
  511. get readyState(): number;
  512. /**
  513. * Returns client's status
  514. */
  515. get status(): number;
  516. /**
  517. * Returns client's status as a text
  518. */
  519. get statusText(): string;
  520. /**
  521. * Returns client's response
  522. */
  523. get response(): any;
  524. /**
  525. * Returns client's response url
  526. */
  527. get responseURL(): string;
  528. /**
  529. * Returns client's response as text
  530. */
  531. get responseText(): string;
  532. /**
  533. * Gets or sets the expected response type
  534. */
  535. get responseType(): XMLHttpRequestResponseType;
  536. set responseType(value: XMLHttpRequestResponseType);
  537. /** @hidden */
  538. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  539. /** @hidden */
  540. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  541. /**
  542. * Cancels any network activity
  543. */
  544. abort(): void;
  545. /**
  546. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  547. * @param body defines an optional request body
  548. */
  549. send(body?: Document | BodyInit | null): void;
  550. /**
  551. * Sets the request method, request URL
  552. * @param method defines the method to use (GET, POST, etc..)
  553. * @param url defines the url to connect with
  554. */
  555. open(method: string, url: string): void;
  556. /**
  557. * Sets the value of a request header.
  558. * @param name The name of the header whose value is to be set
  559. * @param value The value to set as the body of the header
  560. */
  561. setRequestHeader(name: string, value: string): void;
  562. /**
  563. * Get the string containing the text of a particular header's value.
  564. * @param name The name of the header
  565. * @returns The string containing the text of the given header name
  566. */
  567. getResponseHeader(name: string): Nullable<string>;
  568. }
  569. }
  570. declare module BABYLON {
  571. /**
  572. * File request interface
  573. */
  574. export interface IFileRequest {
  575. /**
  576. * Raised when the request is complete (success or error).
  577. */
  578. onCompleteObservable: Observable<IFileRequest>;
  579. /**
  580. * Aborts the request for a file.
  581. */
  582. abort: () => void;
  583. }
  584. }
  585. declare module BABYLON {
  586. /**
  587. * Define options used to create a render target texture
  588. */
  589. export class RenderTargetCreationOptions {
  590. /**
  591. * Specifies if mipmaps must be created. If undefined, the value from generateMipMaps is taken instead
  592. */
  593. createMipMaps?: boolean;
  594. /**
  595. * Specifies if mipmaps must be generated
  596. */
  597. generateMipMaps?: boolean;
  598. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  599. generateDepthBuffer?: boolean;
  600. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  601. generateStencilBuffer?: boolean;
  602. /** Defines texture type (int by default) */
  603. type?: number;
  604. /** Defines sampling mode (trilinear by default) */
  605. samplingMode?: number;
  606. /** Defines format (RGBA by default) */
  607. format?: number;
  608. /** Defines sample count (1 by default) */
  609. samples?: number;
  610. }
  611. }
  612. declare module BABYLON {
  613. /** Defines the cross module used constants to avoid circular dependncies */
  614. export class Constants {
  615. /** Defines that alpha blending is disabled */
  616. static readonly ALPHA_DISABLE: number;
  617. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  618. static readonly ALPHA_ADD: number;
  619. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  620. static readonly ALPHA_COMBINE: number;
  621. /** Defines that alpha blending is DEST - SRC * DEST */
  622. static readonly ALPHA_SUBTRACT: number;
  623. /** Defines that alpha blending is SRC * DEST */
  624. static readonly ALPHA_MULTIPLY: number;
  625. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  626. static readonly ALPHA_MAXIMIZED: number;
  627. /** Defines that alpha blending is SRC + DEST */
  628. static readonly ALPHA_ONEONE: number;
  629. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  630. static readonly ALPHA_PREMULTIPLIED: number;
  631. /**
  632. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  633. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  634. */
  635. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  636. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  637. static readonly ALPHA_INTERPOLATE: number;
  638. /**
  639. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  640. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  641. */
  642. static readonly ALPHA_SCREENMODE: number;
  643. /**
  644. * Defines that alpha blending is SRC + DST
  645. * Alpha will be set to SRC ALPHA + DST ALPHA
  646. */
  647. static readonly ALPHA_ONEONE_ONEONE: number;
  648. /**
  649. * Defines that alpha blending is SRC * DST ALPHA + DST
  650. * Alpha will be set to 0
  651. */
  652. static readonly ALPHA_ALPHATOCOLOR: number;
  653. /**
  654. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  655. */
  656. static readonly ALPHA_REVERSEONEMINUS: number;
  657. /**
  658. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  659. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  660. */
  661. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  662. /**
  663. * Defines that alpha blending is SRC + DST
  664. * Alpha will be set to SRC ALPHA
  665. */
  666. static readonly ALPHA_ONEONE_ONEZERO: number;
  667. /**
  668. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  669. * Alpha will be set to DST ALPHA
  670. */
  671. static readonly ALPHA_EXCLUSION: number;
  672. /** Defines that alpha blending equation a SUM */
  673. static readonly ALPHA_EQUATION_ADD: number;
  674. /** Defines that alpha blending equation a SUBSTRACTION */
  675. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  676. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  677. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  678. /** Defines that alpha blending equation a MAX operation */
  679. static readonly ALPHA_EQUATION_MAX: number;
  680. /** Defines that alpha blending equation a MIN operation */
  681. static readonly ALPHA_EQUATION_MIN: number;
  682. /**
  683. * Defines that alpha blending equation a DARKEN operation:
  684. * It takes the min of the src and sums the alpha channels.
  685. */
  686. static readonly ALPHA_EQUATION_DARKEN: number;
  687. /** Defines that the ressource is not delayed*/
  688. static readonly DELAYLOADSTATE_NONE: number;
  689. /** Defines that the ressource was successfully delay loaded */
  690. static readonly DELAYLOADSTATE_LOADED: number;
  691. /** Defines that the ressource is currently delay loading */
  692. static readonly DELAYLOADSTATE_LOADING: number;
  693. /** Defines that the ressource is delayed and has not started loading */
  694. static readonly DELAYLOADSTATE_NOTLOADED: number;
  695. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  696. static readonly NEVER: number;
  697. /** 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 */
  698. static readonly ALWAYS: number;
  699. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  700. static readonly LESS: number;
  701. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  702. static readonly EQUAL: number;
  703. /** 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 */
  704. static readonly LEQUAL: number;
  705. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  706. static readonly GREATER: number;
  707. /** 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 */
  708. static readonly GEQUAL: number;
  709. /** 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 */
  710. static readonly NOTEQUAL: number;
  711. /** Passed to stencilOperation to specify that stencil value must be kept */
  712. static readonly KEEP: number;
  713. /** Passed to stencilOperation to specify that stencil value must be zero */
  714. static readonly ZERO: number;
  715. /** Passed to stencilOperation to specify that stencil value must be replaced */
  716. static readonly REPLACE: number;
  717. /** Passed to stencilOperation to specify that stencil value must be incremented */
  718. static readonly INCR: number;
  719. /** Passed to stencilOperation to specify that stencil value must be decremented */
  720. static readonly DECR: number;
  721. /** Passed to stencilOperation to specify that stencil value must be inverted */
  722. static readonly INVERT: number;
  723. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  724. static readonly INCR_WRAP: number;
  725. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  726. static readonly DECR_WRAP: number;
  727. /** Texture is not repeating outside of 0..1 UVs */
  728. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  729. /** Texture is repeating outside of 0..1 UVs */
  730. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  731. /** Texture is repeating and mirrored */
  732. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  733. /** ALPHA */
  734. static readonly TEXTUREFORMAT_ALPHA: number;
  735. /** LUMINANCE */
  736. static readonly TEXTUREFORMAT_LUMINANCE: number;
  737. /** LUMINANCE_ALPHA */
  738. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  739. /** RGB */
  740. static readonly TEXTUREFORMAT_RGB: number;
  741. /** RGBA */
  742. static readonly TEXTUREFORMAT_RGBA: number;
  743. /** RED */
  744. static readonly TEXTUREFORMAT_RED: number;
  745. /** RED (2nd reference) */
  746. static readonly TEXTUREFORMAT_R: number;
  747. /** RG */
  748. static readonly TEXTUREFORMAT_RG: number;
  749. /** RED_INTEGER */
  750. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  751. /** RED_INTEGER (2nd reference) */
  752. static readonly TEXTUREFORMAT_R_INTEGER: number;
  753. /** RG_INTEGER */
  754. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  755. /** RGB_INTEGER */
  756. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  757. /** RGBA_INTEGER */
  758. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  759. /** BGRA */
  760. static readonly TEXTUREFORMAT_BGRA: number;
  761. /** Depth 24 bits + Stencil 8 bits */
  762. static readonly TEXTUREFORMAT_DEPTH24_STENCIL8: number;
  763. /** Depth 32 bits float */
  764. static readonly TEXTUREFORMAT_DEPTH32_FLOAT: number;
  765. /** Compressed BC7 */
  766. static readonly TEXTUREFORMAT_COMPRESSED_RGBA_BPTC_UNORM: number;
  767. /** Compressed BC6 unsigned float */
  768. static readonly TEXTUREFORMAT_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT: number;
  769. /** Compressed BC6 signed float */
  770. static readonly TEXTUREFORMAT_COMPRESSED_RGB_BPTC_SIGNED_FLOAT: number;
  771. /** Compressed BC3 */
  772. static readonly TEXTUREFORMAT_COMPRESSED_RGBA_S3TC_DXT5: number;
  773. /** Compressed BC2 */
  774. static readonly TEXTUREFORMAT_COMPRESSED_RGBA_S3TC_DXT3: number;
  775. /** Compressed BC1 */
  776. static readonly TEXTUREFORMAT_COMPRESSED_RGBA_S3TC_DXT1: number;
  777. /** UNSIGNED_BYTE */
  778. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  779. /** UNSIGNED_BYTE (2nd reference) */
  780. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  781. /** FLOAT */
  782. static readonly TEXTURETYPE_FLOAT: number;
  783. /** HALF_FLOAT */
  784. static readonly TEXTURETYPE_HALF_FLOAT: number;
  785. /** BYTE */
  786. static readonly TEXTURETYPE_BYTE: number;
  787. /** SHORT */
  788. static readonly TEXTURETYPE_SHORT: number;
  789. /** UNSIGNED_SHORT */
  790. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  791. /** INT */
  792. static readonly TEXTURETYPE_INT: number;
  793. /** UNSIGNED_INT */
  794. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  795. /** UNSIGNED_SHORT_4_4_4_4 */
  796. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  797. /** UNSIGNED_SHORT_5_5_5_1 */
  798. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  799. /** UNSIGNED_SHORT_5_6_5 */
  800. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  801. /** UNSIGNED_INT_2_10_10_10_REV */
  802. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  803. /** UNSIGNED_INT_24_8 */
  804. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  805. /** UNSIGNED_INT_10F_11F_11F_REV */
  806. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  807. /** UNSIGNED_INT_5_9_9_9_REV */
  808. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  809. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  810. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  811. /** nearest is mag = nearest and min = nearest and no mip */
  812. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  813. /** mag = nearest and min = nearest and mip = none */
  814. static readonly TEXTURE_NEAREST_NEAREST: number;
  815. /** Bilinear is mag = linear and min = linear and no mip */
  816. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  817. /** mag = linear and min = linear and mip = none */
  818. static readonly TEXTURE_LINEAR_LINEAR: number;
  819. /** Trilinear is mag = linear and min = linear and mip = linear */
  820. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  821. /** Trilinear is mag = linear and min = linear and mip = linear */
  822. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  823. /** mag = nearest and min = nearest and mip = nearest */
  824. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  825. /** mag = nearest and min = linear and mip = nearest */
  826. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  827. /** mag = nearest and min = linear and mip = linear */
  828. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  829. /** mag = nearest and min = linear and mip = none */
  830. static readonly TEXTURE_NEAREST_LINEAR: number;
  831. /** nearest is mag = nearest and min = nearest and mip = linear */
  832. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  833. /** mag = linear and min = nearest and mip = nearest */
  834. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  835. /** mag = linear and min = nearest and mip = linear */
  836. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  837. /** Bilinear is mag = linear and min = linear and mip = nearest */
  838. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  839. /** mag = linear and min = nearest and mip = none */
  840. static readonly TEXTURE_LINEAR_NEAREST: number;
  841. /** Explicit coordinates mode */
  842. static readonly TEXTURE_EXPLICIT_MODE: number;
  843. /** Spherical coordinates mode */
  844. static readonly TEXTURE_SPHERICAL_MODE: number;
  845. /** Planar coordinates mode */
  846. static readonly TEXTURE_PLANAR_MODE: number;
  847. /** Cubic coordinates mode */
  848. static readonly TEXTURE_CUBIC_MODE: number;
  849. /** Projection coordinates mode */
  850. static readonly TEXTURE_PROJECTION_MODE: number;
  851. /** Skybox coordinates mode */
  852. static readonly TEXTURE_SKYBOX_MODE: number;
  853. /** Inverse Cubic coordinates mode */
  854. static readonly TEXTURE_INVCUBIC_MODE: number;
  855. /** Equirectangular coordinates mode */
  856. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  857. /** Equirectangular Fixed coordinates mode */
  858. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  859. /** Equirectangular Fixed Mirrored coordinates mode */
  860. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  861. /** Offline (baking) quality for texture filtering */
  862. static readonly TEXTURE_FILTERING_QUALITY_OFFLINE: number;
  863. /** High quality for texture filtering */
  864. static readonly TEXTURE_FILTERING_QUALITY_HIGH: number;
  865. /** Medium quality for texture filtering */
  866. static readonly TEXTURE_FILTERING_QUALITY_MEDIUM: number;
  867. /** Low quality for texture filtering */
  868. static readonly TEXTURE_FILTERING_QUALITY_LOW: number;
  869. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  870. static readonly SCALEMODE_FLOOR: number;
  871. /** Defines that texture rescaling will look for the nearest power of 2 size */
  872. static readonly SCALEMODE_NEAREST: number;
  873. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  874. static readonly SCALEMODE_CEILING: number;
  875. /**
  876. * The dirty texture flag value
  877. */
  878. static readonly MATERIAL_TextureDirtyFlag: number;
  879. /**
  880. * The dirty light flag value
  881. */
  882. static readonly MATERIAL_LightDirtyFlag: number;
  883. /**
  884. * The dirty fresnel flag value
  885. */
  886. static readonly MATERIAL_FresnelDirtyFlag: number;
  887. /**
  888. * The dirty attribute flag value
  889. */
  890. static readonly MATERIAL_AttributesDirtyFlag: number;
  891. /**
  892. * The dirty misc flag value
  893. */
  894. static readonly MATERIAL_MiscDirtyFlag: number;
  895. /**
  896. * The dirty prepass flag value
  897. */
  898. static readonly MATERIAL_PrePassDirtyFlag: number;
  899. /**
  900. * The all dirty flag value
  901. */
  902. static readonly MATERIAL_AllDirtyFlag: number;
  903. /**
  904. * Returns the triangle fill mode
  905. */
  906. static readonly MATERIAL_TriangleFillMode: number;
  907. /**
  908. * Returns the wireframe mode
  909. */
  910. static readonly MATERIAL_WireFrameFillMode: number;
  911. /**
  912. * Returns the point fill mode
  913. */
  914. static readonly MATERIAL_PointFillMode: number;
  915. /**
  916. * Returns the point list draw mode
  917. */
  918. static readonly MATERIAL_PointListDrawMode: number;
  919. /**
  920. * Returns the line list draw mode
  921. */
  922. static readonly MATERIAL_LineListDrawMode: number;
  923. /**
  924. * Returns the line loop draw mode
  925. */
  926. static readonly MATERIAL_LineLoopDrawMode: number;
  927. /**
  928. * Returns the line strip draw mode
  929. */
  930. static readonly MATERIAL_LineStripDrawMode: number;
  931. /**
  932. * Returns the triangle strip draw mode
  933. */
  934. static readonly MATERIAL_TriangleStripDrawMode: number;
  935. /**
  936. * Returns the triangle fan draw mode
  937. */
  938. static readonly MATERIAL_TriangleFanDrawMode: number;
  939. /**
  940. * Stores the clock-wise side orientation
  941. */
  942. static readonly MATERIAL_ClockWiseSideOrientation: number;
  943. /**
  944. * Stores the counter clock-wise side orientation
  945. */
  946. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  947. /**
  948. * Nothing
  949. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  950. */
  951. static readonly ACTION_NothingTrigger: number;
  952. /**
  953. * On pick
  954. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  955. */
  956. static readonly ACTION_OnPickTrigger: number;
  957. /**
  958. * On left pick
  959. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  960. */
  961. static readonly ACTION_OnLeftPickTrigger: number;
  962. /**
  963. * On right pick
  964. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  965. */
  966. static readonly ACTION_OnRightPickTrigger: number;
  967. /**
  968. * On center pick
  969. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  970. */
  971. static readonly ACTION_OnCenterPickTrigger: number;
  972. /**
  973. * On pick down
  974. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  975. */
  976. static readonly ACTION_OnPickDownTrigger: number;
  977. /**
  978. * On double pick
  979. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  980. */
  981. static readonly ACTION_OnDoublePickTrigger: number;
  982. /**
  983. * On pick up
  984. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  985. */
  986. static readonly ACTION_OnPickUpTrigger: number;
  987. /**
  988. * On pick out.
  989. * This trigger will only be raised if you also declared a OnPickDown
  990. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  991. */
  992. static readonly ACTION_OnPickOutTrigger: number;
  993. /**
  994. * On long press
  995. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  996. */
  997. static readonly ACTION_OnLongPressTrigger: number;
  998. /**
  999. * On pointer over
  1000. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1001. */
  1002. static readonly ACTION_OnPointerOverTrigger: number;
  1003. /**
  1004. * On pointer out
  1005. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1006. */
  1007. static readonly ACTION_OnPointerOutTrigger: number;
  1008. /**
  1009. * On every frame
  1010. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1011. */
  1012. static readonly ACTION_OnEveryFrameTrigger: number;
  1013. /**
  1014. * On intersection enter
  1015. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1016. */
  1017. static readonly ACTION_OnIntersectionEnterTrigger: number;
  1018. /**
  1019. * On intersection exit
  1020. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1021. */
  1022. static readonly ACTION_OnIntersectionExitTrigger: number;
  1023. /**
  1024. * On key down
  1025. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1026. */
  1027. static readonly ACTION_OnKeyDownTrigger: number;
  1028. /**
  1029. * On key up
  1030. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1031. */
  1032. static readonly ACTION_OnKeyUpTrigger: number;
  1033. /**
  1034. * Billboard mode will only apply to Y axis
  1035. */
  1036. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  1037. /**
  1038. * Billboard mode will apply to all axes
  1039. */
  1040. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  1041. /**
  1042. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  1043. */
  1044. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  1045. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  1046. * Test order :
  1047. * Is the bounding sphere outside the frustum ?
  1048. * If not, are the bounding box vertices outside the frustum ?
  1049. * It not, then the cullable object is in the frustum.
  1050. */
  1051. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  1052. /** Culling strategy : Bounding Sphere Only.
  1053. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  1054. * It's also less accurate than the standard because some not visible objects can still be selected.
  1055. * Test : is the bounding sphere outside the frustum ?
  1056. * If not, then the cullable object is in the frustum.
  1057. */
  1058. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  1059. /** Culling strategy : Optimistic Inclusion.
  1060. * This in an inclusion test first, then the standard exclusion test.
  1061. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  1062. * 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.
  1063. * Anyway, it's as accurate as the standard strategy.
  1064. * Test :
  1065. * Is the cullable object bounding sphere center in the frustum ?
  1066. * If not, apply the default culling strategy.
  1067. */
  1068. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  1069. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  1070. * This in an inclusion test first, then the bounding sphere only exclusion test.
  1071. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  1072. * 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.
  1073. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  1074. * Test :
  1075. * Is the cullable object bounding sphere center in the frustum ?
  1076. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  1077. */
  1078. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  1079. /**
  1080. * No logging while loading
  1081. */
  1082. static readonly SCENELOADER_NO_LOGGING: number;
  1083. /**
  1084. * Minimal logging while loading
  1085. */
  1086. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  1087. /**
  1088. * Summary logging while loading
  1089. */
  1090. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  1091. /**
  1092. * Detailled logging while loading
  1093. */
  1094. static readonly SCENELOADER_DETAILED_LOGGING: number;
  1095. /**
  1096. * Constant used to retrieve the irradiance texture index in the textures array in the prepass
  1097. * using getIndex(Constants.PREPASS_IRRADIANCE_TEXTURE_TYPE)
  1098. */
  1099. static readonly PREPASS_IRRADIANCE_TEXTURE_TYPE: number;
  1100. /**
  1101. * Constant used to retrieve the position texture index in the textures array in the prepass
  1102. * using getIndex(Constants.PREPASS_POSITION_TEXTURE_INDEX)
  1103. */
  1104. static readonly PREPASS_POSITION_TEXTURE_TYPE: number;
  1105. /**
  1106. * Constant used to retrieve the velocity texture index in the textures array in the prepass
  1107. * using getIndex(Constants.PREPASS_VELOCITY_TEXTURE_INDEX)
  1108. */
  1109. static readonly PREPASS_VELOCITY_TEXTURE_TYPE: number;
  1110. /**
  1111. * Constant used to retrieve the reflectivity texture index in the textures array in the prepass
  1112. * using the getIndex(Constants.PREPASS_REFLECTIVITY_TEXTURE_TYPE)
  1113. */
  1114. static readonly PREPASS_REFLECTIVITY_TEXTURE_TYPE: number;
  1115. /**
  1116. * Constant used to retrieve the lit color texture index in the textures array in the prepass
  1117. * using the getIndex(Constants.PREPASS_COLOR_TEXTURE_TYPE)
  1118. */
  1119. static readonly PREPASS_COLOR_TEXTURE_TYPE: number;
  1120. /**
  1121. * Constant used to retrieve depth + normal index in the textures array in the prepass
  1122. * using the getIndex(Constants.PREPASS_DEPTHNORMAL_TEXTURE_TYPE)
  1123. */
  1124. static readonly PREPASS_DEPTHNORMAL_TEXTURE_TYPE: number;
  1125. /**
  1126. * Constant used to retrieve albedo index in the textures array in the prepass
  1127. * using the getIndex(Constants.PREPASS_ALBEDO_TEXTURE_TYPE)
  1128. */
  1129. static readonly PREPASS_ALBEDO_TEXTURE_TYPE: number;
  1130. /**
  1131. * Prefixes used by the engine for custom effects
  1132. */
  1133. static readonly CUSTOMEFFECT_PREFIX_SHADOWGENERATOR: string;
  1134. }
  1135. }
  1136. declare module BABYLON {
  1137. /** @hidden */
  1138. export interface HardwareTextureWrapper {
  1139. underlyingResource: any;
  1140. set(hardwareTexture: any): void;
  1141. setUsage(textureSource: number, generateMipMaps: boolean, isCube: boolean, width: number, height: number): void;
  1142. reset(): void;
  1143. release(): void;
  1144. }
  1145. }
  1146. declare module BABYLON {
  1147. /**
  1148. * This represents the required contract to create a new type of texture loader.
  1149. */
  1150. export interface IInternalTextureLoader {
  1151. /**
  1152. * Defines wether the loader supports cascade loading the different faces.
  1153. */
  1154. supportCascades: boolean;
  1155. /**
  1156. * This returns if the loader support the current file information.
  1157. * @param extension defines the file extension of the file being loaded
  1158. * @param mimeType defines the optional mime type of the file being loaded
  1159. * @returns true if the loader can load the specified file
  1160. */
  1161. canLoad(extension: string, mimeType?: string): boolean;
  1162. /**
  1163. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  1164. * @param data contains the texture data
  1165. * @param texture defines the BabylonJS internal texture
  1166. * @param createPolynomials will be true if polynomials have been requested
  1167. * @param onLoad defines the callback to trigger once the texture is ready
  1168. * @param onError defines the callback to trigger in case of error
  1169. * @param options options to be passed to the loader
  1170. */
  1171. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, options?: any): void;
  1172. /**
  1173. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  1174. * @param data contains the texture data
  1175. * @param texture defines the BabylonJS internal texture
  1176. * @param callback defines the method to call once ready to upload
  1177. * @param options options to be passed to the loader
  1178. */
  1179. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void, options?: any): void;
  1180. }
  1181. }
  1182. declare module BABYLON {
  1183. /**
  1184. * @hidden
  1185. */
  1186. export interface IColor4Like {
  1187. r: float;
  1188. g: float;
  1189. b: float;
  1190. a: float;
  1191. }
  1192. /**
  1193. * @hidden
  1194. */
  1195. export interface IColor3Like {
  1196. r: float;
  1197. g: float;
  1198. b: float;
  1199. }
  1200. /**
  1201. * @hidden
  1202. */
  1203. export interface IVector4Like {
  1204. x: float;
  1205. y: float;
  1206. z: float;
  1207. w: float;
  1208. }
  1209. /**
  1210. * @hidden
  1211. */
  1212. export interface IVector3Like {
  1213. x: float;
  1214. y: float;
  1215. z: float;
  1216. }
  1217. /**
  1218. * @hidden
  1219. */
  1220. export interface IVector2Like {
  1221. x: float;
  1222. y: float;
  1223. }
  1224. /**
  1225. * @hidden
  1226. */
  1227. export interface IMatrixLike {
  1228. toArray(): DeepImmutable<Float32Array | Array<number>>;
  1229. updateFlag: int;
  1230. }
  1231. /**
  1232. * @hidden
  1233. */
  1234. export interface IViewportLike {
  1235. x: float;
  1236. y: float;
  1237. width: float;
  1238. height: float;
  1239. }
  1240. /**
  1241. * @hidden
  1242. */
  1243. export interface IPlaneLike {
  1244. normal: IVector3Like;
  1245. d: float;
  1246. normalize(): void;
  1247. }
  1248. }
  1249. declare module BABYLON {
  1250. /**
  1251. * Class used to store and describe the pipeline context associated with an effect
  1252. */
  1253. export interface IPipelineContext {
  1254. /**
  1255. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1256. */
  1257. isAsync: boolean;
  1258. /**
  1259. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1260. */
  1261. isReady: boolean;
  1262. /** @hidden */
  1263. _name?: string;
  1264. /** @hidden */
  1265. _getVertexShaderCode(): string | null;
  1266. /** @hidden */
  1267. _getFragmentShaderCode(): string | null;
  1268. /** @hidden */
  1269. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1270. /** @hidden */
  1271. _fillEffectInformation(effect: Effect, uniformBuffersNames: {
  1272. [key: string]: number;
  1273. }, uniformsNames: string[], uniforms: {
  1274. [key: string]: Nullable<WebGLUniformLocation>;
  1275. }, samplerList: string[], samplers: {
  1276. [key: string]: number;
  1277. }, attributesNames: string[], attributes: number[]): void;
  1278. /** Releases the resources associated with the pipeline. */
  1279. dispose(): void;
  1280. /**
  1281. * Sets an integer value on a uniform variable.
  1282. * @param uniformName Name of the variable.
  1283. * @param value Value to be set.
  1284. */
  1285. setInt(uniformName: string, value: number): void;
  1286. /**
  1287. * Sets an int2 value on a uniform variable.
  1288. * @param uniformName Name of the variable.
  1289. * @param x First int in int2.
  1290. * @param y Second int in int2.
  1291. */
  1292. setInt2(uniformName: string, x: number, y: number): void;
  1293. /**
  1294. * Sets an int3 value on a uniform variable.
  1295. * @param uniformName Name of the variable.
  1296. * @param x First int in int3.
  1297. * @param y Second int in int3.
  1298. * @param z Third int in int3.
  1299. */
  1300. setInt3(uniformName: string, x: number, y: number, z: number): void;
  1301. /**
  1302. * Sets an int4 value on a uniform variable.
  1303. * @param uniformName Name of the variable.
  1304. * @param x First int in int4.
  1305. * @param y Second int in int4.
  1306. * @param z Third int in int4.
  1307. * @param w Fourth int in int4.
  1308. */
  1309. setInt4(uniformName: string, x: number, y: number, z: number, w: number): void;
  1310. /**
  1311. * Sets an int array on a uniform variable.
  1312. * @param uniformName Name of the variable.
  1313. * @param array array to be set.
  1314. */
  1315. setIntArray(uniformName: string, array: Int32Array): void;
  1316. /**
  1317. * 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)
  1318. * @param uniformName Name of the variable.
  1319. * @param array array to be set.
  1320. */
  1321. setIntArray2(uniformName: string, array: Int32Array): void;
  1322. /**
  1323. * 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)
  1324. * @param uniformName Name of the variable.
  1325. * @param array array to be set.
  1326. */
  1327. setIntArray3(uniformName: string, array: Int32Array): void;
  1328. /**
  1329. * 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)
  1330. * @param uniformName Name of the variable.
  1331. * @param array array to be set.
  1332. */
  1333. setIntArray4(uniformName: string, array: Int32Array): void;
  1334. /**
  1335. * Sets an array on a uniform variable.
  1336. * @param uniformName Name of the variable.
  1337. * @param array array to be set.
  1338. */
  1339. setArray(uniformName: string, array: number[] | Float32Array): void;
  1340. /**
  1341. * 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)
  1342. * @param uniformName Name of the variable.
  1343. * @param array array to be set.
  1344. */
  1345. setArray2(uniformName: string, array: number[] | Float32Array): void;
  1346. /**
  1347. * 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)
  1348. * @param uniformName Name of the variable.
  1349. * @param array array to be set.
  1350. */
  1351. setArray3(uniformName: string, array: number[] | Float32Array): void;
  1352. /**
  1353. * 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)
  1354. * @param uniformName Name of the variable.
  1355. * @param array array to be set.
  1356. */
  1357. setArray4(uniformName: string, array: number[] | Float32Array): void;
  1358. /**
  1359. * Sets matrices on a uniform variable.
  1360. * @param uniformName Name of the variable.
  1361. * @param matrices matrices to be set.
  1362. */
  1363. setMatrices(uniformName: string, matrices: Float32Array): void;
  1364. /**
  1365. * Sets matrix on a uniform variable.
  1366. * @param uniformName Name of the variable.
  1367. * @param matrix matrix to be set.
  1368. */
  1369. setMatrix(uniformName: string, matrix: IMatrixLike): void;
  1370. /**
  1371. * 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)
  1372. * @param uniformName Name of the variable.
  1373. * @param matrix matrix to be set.
  1374. */
  1375. setMatrix3x3(uniformName: string, matrix: Float32Array): void;
  1376. /**
  1377. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  1378. * @param uniformName Name of the variable.
  1379. * @param matrix matrix to be set.
  1380. */
  1381. setMatrix2x2(uniformName: string, matrix: Float32Array): void;
  1382. /**
  1383. * Sets a float on a uniform variable.
  1384. * @param uniformName Name of the variable.
  1385. * @param value value to be set.
  1386. */
  1387. setFloat(uniformName: string, value: number): void;
  1388. /**
  1389. * Sets a Vector2 on a uniform variable.
  1390. * @param uniformName Name of the variable.
  1391. * @param vector2 vector2 to be set.
  1392. */
  1393. setVector2(uniformName: string, vector2: IVector2Like): void;
  1394. /**
  1395. * Sets a float2 on a uniform variable.
  1396. * @param uniformName Name of the variable.
  1397. * @param x First float in float2.
  1398. * @param y Second float in float2.
  1399. */
  1400. setFloat2(uniformName: string, x: number, y: number): void;
  1401. /**
  1402. * Sets a Vector3 on a uniform variable.
  1403. * @param uniformName Name of the variable.
  1404. * @param vector3 Value to be set.
  1405. */
  1406. setVector3(uniformName: string, vector3: IVector3Like): void;
  1407. /**
  1408. * Sets a float3 on a uniform variable.
  1409. * @param uniformName Name of the variable.
  1410. * @param x First float in float3.
  1411. * @param y Second float in float3.
  1412. * @param z Third float in float3.
  1413. */
  1414. setFloat3(uniformName: string, x: number, y: number, z: number): void;
  1415. /**
  1416. * Sets a Vector4 on a uniform variable.
  1417. * @param uniformName Name of the variable.
  1418. * @param vector4 Value to be set.
  1419. */
  1420. setVector4(uniformName: string, vector4: IVector4Like): void;
  1421. /**
  1422. * Sets a float4 on a uniform variable.
  1423. * @param uniformName Name of the variable.
  1424. * @param x First float in float4.
  1425. * @param y Second float in float4.
  1426. * @param z Third float in float4.
  1427. * @param w Fourth float in float4.
  1428. */
  1429. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): void;
  1430. /**
  1431. * Sets a Color3 on a uniform variable.
  1432. * @param uniformName Name of the variable.
  1433. * @param color3 Value to be set.
  1434. */
  1435. setColor3(uniformName: string, color3: IColor3Like): void;
  1436. /**
  1437. * Sets a Color4 on a uniform variable.
  1438. * @param uniformName Name of the variable.
  1439. * @param color3 Value to be set.
  1440. * @param alpha Alpha value to be set.
  1441. */
  1442. setColor4(uniformName: string, color3: IColor3Like, alpha: number): void;
  1443. /**
  1444. * Sets a Color4 on a uniform variable
  1445. * @param uniformName defines the name of the variable
  1446. * @param color4 defines the value to be set
  1447. */
  1448. setDirectColor4(uniformName: string, color4: IColor4Like): void;
  1449. }
  1450. }
  1451. declare module BABYLON {
  1452. /**
  1453. * Class used to store gfx data (like WebGLBuffer)
  1454. */
  1455. export class DataBuffer {
  1456. private static _Counter;
  1457. /**
  1458. * Gets or sets the number of objects referencing this buffer
  1459. */
  1460. references: number;
  1461. /** Gets or sets the size of the underlying buffer */
  1462. capacity: number;
  1463. /**
  1464. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1465. */
  1466. is32Bits: boolean;
  1467. /**
  1468. * Gets the underlying buffer
  1469. */
  1470. get underlyingResource(): any;
  1471. /**
  1472. * Gets the unique id of this buffer
  1473. */
  1474. readonly uniqueId: number;
  1475. /**
  1476. * Constructs the buffer
  1477. */
  1478. constructor();
  1479. }
  1480. }
  1481. declare module BABYLON {
  1482. /** @hidden */
  1483. export interface IShaderProcessor {
  1484. attributeProcessor?: (attribute: string, preProcessors: {
  1485. [key: string]: string;
  1486. }, processingContext: Nullable<ShaderProcessingContext>) => string;
  1487. varyingProcessor?: (varying: string, isFragment: boolean, preProcessors: {
  1488. [key: string]: string;
  1489. }, processingContext: Nullable<ShaderProcessingContext>) => string;
  1490. uniformProcessor?: (uniform: string, isFragment: boolean, preProcessors: {
  1491. [key: string]: string;
  1492. }, processingContext: Nullable<ShaderProcessingContext>) => string;
  1493. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>) => string;
  1494. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>) => string;
  1495. lineProcessor?: (line: string, isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>) => string;
  1496. preProcessor?: (code: string, defines: string[], isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>) => string;
  1497. postProcessor?: (code: string, defines: string[], isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>, engine: ThinEngine) => string;
  1498. initializeShaders?: (processingContext: Nullable<ShaderProcessingContext>) => void;
  1499. finalizeShaders?: (vertexCode: string, fragmentCode: string, processingContext: Nullable<ShaderProcessingContext>) => {
  1500. vertexCode: string;
  1501. fragmentCode: string;
  1502. };
  1503. }
  1504. }
  1505. declare module BABYLON {
  1506. /** @hidden */
  1507. export interface ShaderProcessingContext {
  1508. }
  1509. /** @hidden */
  1510. export interface ProcessingOptions {
  1511. defines: string[];
  1512. indexParameters: any;
  1513. isFragment: boolean;
  1514. shouldUseHighPrecisionShader: boolean;
  1515. supportsUniformBuffers: boolean;
  1516. shadersRepository: string;
  1517. includesShadersStore: {
  1518. [key: string]: string;
  1519. };
  1520. processor: Nullable<IShaderProcessor>;
  1521. version: string;
  1522. platformName: string;
  1523. lookForClosingBracketForUniformBuffer?: boolean;
  1524. processingContext: Nullable<ShaderProcessingContext>;
  1525. }
  1526. }
  1527. declare module BABYLON {
  1528. /** @hidden */
  1529. export class ShaderCodeNode {
  1530. line: string;
  1531. children: ShaderCodeNode[];
  1532. additionalDefineKey?: string;
  1533. additionalDefineValue?: string;
  1534. isValid(preprocessors: {
  1535. [key: string]: string;
  1536. }): boolean;
  1537. process(preprocessors: {
  1538. [key: string]: string;
  1539. }, options: ProcessingOptions): string;
  1540. }
  1541. }
  1542. declare module BABYLON {
  1543. /** @hidden */
  1544. export class ShaderCodeCursor {
  1545. private _lines;
  1546. lineIndex: number;
  1547. get currentLine(): string;
  1548. get canRead(): boolean;
  1549. set lines(value: string[]);
  1550. }
  1551. }
  1552. declare module BABYLON {
  1553. /** @hidden */
  1554. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1555. process(preprocessors: {
  1556. [key: string]: string;
  1557. }, options: ProcessingOptions): string;
  1558. }
  1559. }
  1560. declare module BABYLON {
  1561. /** @hidden */
  1562. export class ShaderDefineExpression {
  1563. isTrue(preprocessors: {
  1564. [key: string]: string;
  1565. }): boolean;
  1566. private static _OperatorPriority;
  1567. private static _Stack;
  1568. static postfixToInfix(postfix: string[]): string;
  1569. static infixToPostfix(infix: string): string[];
  1570. }
  1571. }
  1572. declare module BABYLON {
  1573. /** @hidden */
  1574. export class ShaderCodeTestNode extends ShaderCodeNode {
  1575. testExpression: ShaderDefineExpression;
  1576. isValid(preprocessors: {
  1577. [key: string]: string;
  1578. }): boolean;
  1579. }
  1580. }
  1581. declare module BABYLON {
  1582. /** @hidden */
  1583. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1584. define: string;
  1585. not: boolean;
  1586. constructor(define: string, not?: boolean);
  1587. isTrue(preprocessors: {
  1588. [key: string]: string;
  1589. }): boolean;
  1590. }
  1591. }
  1592. declare module BABYLON {
  1593. /** @hidden */
  1594. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1595. leftOperand: ShaderDefineExpression;
  1596. rightOperand: ShaderDefineExpression;
  1597. isTrue(preprocessors: {
  1598. [key: string]: string;
  1599. }): boolean;
  1600. }
  1601. }
  1602. declare module BABYLON {
  1603. /** @hidden */
  1604. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1605. leftOperand: ShaderDefineExpression;
  1606. rightOperand: ShaderDefineExpression;
  1607. isTrue(preprocessors: {
  1608. [key: string]: string;
  1609. }): boolean;
  1610. }
  1611. }
  1612. declare module BABYLON {
  1613. /** @hidden */
  1614. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1615. define: string;
  1616. operand: string;
  1617. testValue: string;
  1618. constructor(define: string, operand: string, testValue: string);
  1619. isTrue(preprocessors: {
  1620. [key: string]: string;
  1621. }): boolean;
  1622. }
  1623. }
  1624. declare module BABYLON {
  1625. /**
  1626. * Class used to enable access to offline support
  1627. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1628. */
  1629. export interface IOfflineProvider {
  1630. /**
  1631. * Gets a boolean indicating if scene must be saved in the database
  1632. */
  1633. enableSceneOffline: boolean;
  1634. /**
  1635. * Gets a boolean indicating if textures must be saved in the database
  1636. */
  1637. enableTexturesOffline: boolean;
  1638. /**
  1639. * Open the offline support and make it available
  1640. * @param successCallback defines the callback to call on success
  1641. * @param errorCallback defines the callback to call on error
  1642. */
  1643. open(successCallback: () => void, errorCallback: () => void): void;
  1644. /**
  1645. * Loads an image from the offline support
  1646. * @param url defines the url to load from
  1647. * @param image defines the target DOM image
  1648. */
  1649. loadImage(url: string, image: HTMLImageElement): void;
  1650. /**
  1651. * Loads a file from offline support
  1652. * @param url defines the URL to load from
  1653. * @param sceneLoaded defines a callback to call on success
  1654. * @param progressCallBack defines a callback to call when progress changed
  1655. * @param errorCallback defines a callback to call on error
  1656. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1657. */
  1658. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1659. }
  1660. }
  1661. declare module BABYLON {
  1662. /**
  1663. * Class used to help managing file picking and drag'n'drop
  1664. * File Storage
  1665. */
  1666. export class FilesInputStore {
  1667. /**
  1668. * List of files ready to be loaded
  1669. */
  1670. static FilesToLoad: {
  1671. [key: string]: File;
  1672. };
  1673. }
  1674. }
  1675. declare module BABYLON {
  1676. /**
  1677. * Class used to define a retry strategy when error happens while loading assets
  1678. */
  1679. export class RetryStrategy {
  1680. /**
  1681. * Function used to defines an exponential back off strategy
  1682. * @param maxRetries defines the maximum number of retries (3 by default)
  1683. * @param baseInterval defines the interval between retries
  1684. * @returns the strategy function to use
  1685. */
  1686. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1687. }
  1688. }
  1689. declare module BABYLON {
  1690. /**
  1691. * @ignore
  1692. * Application error to support additional information when loading a file
  1693. */
  1694. export abstract class BaseError extends Error {
  1695. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1696. }
  1697. }
  1698. declare module BABYLON {
  1699. /** @ignore */
  1700. export class LoadFileError extends BaseError {
  1701. request?: WebRequest;
  1702. file?: File;
  1703. /**
  1704. * Creates a new LoadFileError
  1705. * @param message defines the message of the error
  1706. * @param request defines the optional web request
  1707. * @param file defines the optional file
  1708. */
  1709. constructor(message: string, object?: WebRequest | File);
  1710. }
  1711. /** @ignore */
  1712. export class RequestFileError extends BaseError {
  1713. request: WebRequest;
  1714. /**
  1715. * Creates a new LoadFileError
  1716. * @param message defines the message of the error
  1717. * @param request defines the optional web request
  1718. */
  1719. constructor(message: string, request: WebRequest);
  1720. }
  1721. /** @ignore */
  1722. export class ReadFileError extends BaseError {
  1723. file: File;
  1724. /**
  1725. * Creates a new ReadFileError
  1726. * @param message defines the message of the error
  1727. * @param file defines the optional file
  1728. */
  1729. constructor(message: string, file: File);
  1730. }
  1731. /**
  1732. * @hidden
  1733. */
  1734. export class FileTools {
  1735. /**
  1736. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1737. */
  1738. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1739. /**
  1740. * Gets or sets the base URL to use to load assets
  1741. */
  1742. static BaseUrl: string;
  1743. /**
  1744. * Default behaviour for cors in the application.
  1745. * It can be a string if the expected behavior is identical in the entire app.
  1746. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1747. */
  1748. static CorsBehavior: string | ((url: string | string[]) => string);
  1749. /**
  1750. * Gets or sets a function used to pre-process url before using them to load assets
  1751. */
  1752. static PreprocessUrl: (url: string) => string;
  1753. /**
  1754. * Removes unwanted characters from an url
  1755. * @param url defines the url to clean
  1756. * @returns the cleaned url
  1757. */
  1758. private static _CleanUrl;
  1759. /**
  1760. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1761. * @param url define the url we are trying
  1762. * @param element define the dom element where to configure the cors policy
  1763. */
  1764. static SetCorsBehavior(url: string | string[], element: {
  1765. crossOrigin: string | null;
  1766. }): void;
  1767. /**
  1768. * Loads an image as an HTMLImageElement.
  1769. * @param input url string, ArrayBuffer, or Blob to load
  1770. * @param onLoad callback called when the image successfully loads
  1771. * @param onError callback called when the image fails to load
  1772. * @param offlineProvider offline provider for caching
  1773. * @param mimeType optional mime type
  1774. * @returns the HTMLImageElement of the loaded image
  1775. */
  1776. 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>;
  1777. /**
  1778. * Reads a file from a File object
  1779. * @param file defines the file to load
  1780. * @param onSuccess defines the callback to call when data is loaded
  1781. * @param onProgress defines the callback to call during loading process
  1782. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1783. * @param onError defines the callback to call when an error occurs
  1784. * @returns a file request object
  1785. */
  1786. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1787. /**
  1788. * Loads a file from a url
  1789. * @param url url to load
  1790. * @param onSuccess callback called when the file successfully loads
  1791. * @param onProgress callback called while file is loading (if the server supports this mode)
  1792. * @param offlineProvider defines the offline provider for caching
  1793. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1794. * @param onError callback called when the file fails to load
  1795. * @returns a file request object
  1796. */
  1797. 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;
  1798. /**
  1799. * Loads a file
  1800. * @param url url to load
  1801. * @param onSuccess callback called when the file successfully loads
  1802. * @param onProgress callback called while file is loading (if the server supports this mode)
  1803. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1804. * @param onError callback called when the file fails to load
  1805. * @param onOpened callback called when the web request is opened
  1806. * @returns a file request object
  1807. */
  1808. 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;
  1809. /**
  1810. * Checks if the loaded document was accessed via `file:`-Protocol.
  1811. * @returns boolean
  1812. */
  1813. static IsFileURL(): boolean;
  1814. }
  1815. }
  1816. declare module BABYLON {
  1817. /** @hidden */
  1818. export class ShaderProcessor {
  1819. static Initialize(options: ProcessingOptions): void;
  1820. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void, engine: ThinEngine): void;
  1821. static Finalize(vertexCode: string, fragmentCode: string, options: ProcessingOptions): {
  1822. vertexCode: string;
  1823. fragmentCode: string;
  1824. };
  1825. private static _ProcessPrecision;
  1826. private static _ExtractOperation;
  1827. private static _BuildSubExpression;
  1828. private static _BuildExpression;
  1829. private static _MoveCursorWithinIf;
  1830. private static _MoveCursor;
  1831. private static _EvaluatePreProcessors;
  1832. private static _PreparePreProcessors;
  1833. private static _ProcessShaderConversion;
  1834. private static _ProcessIncludes;
  1835. /**
  1836. * Loads a file from a url
  1837. * @param url url to load
  1838. * @param onSuccess callback called when the file successfully loads
  1839. * @param onProgress callback called while file is loading (if the server supports this mode)
  1840. * @param offlineProvider defines the offline provider for caching
  1841. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1842. * @param onError callback called when the file fails to load
  1843. * @returns a file request object
  1844. * @hidden
  1845. */
  1846. 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;
  1847. }
  1848. }
  1849. declare module BABYLON {
  1850. /**
  1851. * Interface used to define common properties for effect fallbacks
  1852. */
  1853. export interface IEffectFallbacks {
  1854. /**
  1855. * Removes the defines that should be removed when falling back.
  1856. * @param currentDefines defines the current define statements for the shader.
  1857. * @param effect defines the current effect we try to compile
  1858. * @returns The resulting defines with defines of the current rank removed.
  1859. */
  1860. reduce(currentDefines: string, effect: Effect): string;
  1861. /**
  1862. * Removes the fallback from the bound mesh.
  1863. */
  1864. unBindMesh(): void;
  1865. /**
  1866. * Checks to see if more fallbacks are still availible.
  1867. */
  1868. hasMoreFallbacks: boolean;
  1869. }
  1870. }
  1871. declare module BABYLON {
  1872. /**
  1873. * Interface for the size containing width and height
  1874. */
  1875. export interface ISize {
  1876. /**
  1877. * Width
  1878. */
  1879. width: number;
  1880. /**
  1881. * Heighht
  1882. */
  1883. height: number;
  1884. }
  1885. /**
  1886. * Size containing widht and height
  1887. */
  1888. export class Size implements ISize {
  1889. /**
  1890. * Width
  1891. */
  1892. width: number;
  1893. /**
  1894. * Height
  1895. */
  1896. height: number;
  1897. /**
  1898. * Creates a Size object from the given width and height (floats).
  1899. * @param width width of the new size
  1900. * @param height height of the new size
  1901. */
  1902. constructor(width: number, height: number);
  1903. /**
  1904. * Returns a string with the Size width and height
  1905. * @returns a string with the Size width and height
  1906. */
  1907. toString(): string;
  1908. /**
  1909. * "Size"
  1910. * @returns the string "Size"
  1911. */
  1912. getClassName(): string;
  1913. /**
  1914. * Returns the Size hash code.
  1915. * @returns a hash code for a unique width and height
  1916. */
  1917. getHashCode(): number;
  1918. /**
  1919. * Updates the current size from the given one.
  1920. * @param src the given size
  1921. */
  1922. copyFrom(src: Size): void;
  1923. /**
  1924. * Updates in place the current Size from the given floats.
  1925. * @param width width of the new size
  1926. * @param height height of the new size
  1927. * @returns the updated Size.
  1928. */
  1929. copyFromFloats(width: number, height: number): Size;
  1930. /**
  1931. * Updates in place the current Size from the given floats.
  1932. * @param width width to set
  1933. * @param height height to set
  1934. * @returns the updated Size.
  1935. */
  1936. set(width: number, height: number): Size;
  1937. /**
  1938. * Multiplies the width and height by numbers
  1939. * @param w factor to multiple the width by
  1940. * @param h factor to multiple the height by
  1941. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  1942. */
  1943. multiplyByFloats(w: number, h: number): Size;
  1944. /**
  1945. * Clones the size
  1946. * @returns a new Size copied from the given one.
  1947. */
  1948. clone(): Size;
  1949. /**
  1950. * True if the current Size and the given one width and height are strictly equal.
  1951. * @param other the other size to compare against
  1952. * @returns True if the current Size and the given one width and height are strictly equal.
  1953. */
  1954. equals(other: Size): boolean;
  1955. /**
  1956. * The surface of the Size : width * height (float).
  1957. */
  1958. get surface(): number;
  1959. /**
  1960. * Create a new size of zero
  1961. * @returns a new Size set to (0.0, 0.0)
  1962. */
  1963. static Zero(): Size;
  1964. /**
  1965. * Sums the width and height of two sizes
  1966. * @param otherSize size to add to this size
  1967. * @returns a new Size set as the addition result of the current Size and the given one.
  1968. */
  1969. add(otherSize: Size): Size;
  1970. /**
  1971. * Subtracts the width and height of two
  1972. * @param otherSize size to subtract to this size
  1973. * @returns a new Size set as the subtraction result of the given one from the current Size.
  1974. */
  1975. subtract(otherSize: Size): Size;
  1976. /**
  1977. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  1978. * @param start starting size to lerp between
  1979. * @param end end size to lerp between
  1980. * @param amount amount to lerp between the start and end values
  1981. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  1982. */
  1983. static Lerp(start: Size, end: Size, amount: number): Size;
  1984. }
  1985. }
  1986. declare module BABYLON {
  1987. /**
  1988. * Base class of all the textures in babylon.
  1989. * It groups all the common properties required to work with Thin Engine.
  1990. */
  1991. export class ThinTexture {
  1992. protected _wrapU: number;
  1993. /**
  1994. * | Value | Type | Description |
  1995. * | ----- | ------------------ | ----------- |
  1996. * | 0 | CLAMP_ADDRESSMODE | |
  1997. * | 1 | WRAP_ADDRESSMODE | |
  1998. * | 2 | MIRROR_ADDRESSMODE | |
  1999. */
  2000. get wrapU(): number;
  2001. set wrapU(value: number);
  2002. protected _wrapV: number;
  2003. /**
  2004. * | Value | Type | Description |
  2005. * | ----- | ------------------ | ----------- |
  2006. * | 0 | CLAMP_ADDRESSMODE | |
  2007. * | 1 | WRAP_ADDRESSMODE | |
  2008. * | 2 | MIRROR_ADDRESSMODE | |
  2009. */
  2010. get wrapV(): number;
  2011. set wrapV(value: number);
  2012. /**
  2013. * | Value | Type | Description |
  2014. * | ----- | ------------------ | ----------- |
  2015. * | 0 | CLAMP_ADDRESSMODE | |
  2016. * | 1 | WRAP_ADDRESSMODE | |
  2017. * | 2 | MIRROR_ADDRESSMODE | |
  2018. */
  2019. wrapR: number;
  2020. /**
  2021. * With compliant hardware and browser (supporting anisotropic filtering)
  2022. * this defines the level of anisotropic filtering in the texture.
  2023. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  2024. */
  2025. anisotropicFilteringLevel: number;
  2026. /**
  2027. * Define the current state of the loading sequence when in delayed load mode.
  2028. */
  2029. delayLoadState: number;
  2030. /**
  2031. * How a texture is mapped.
  2032. * Unused in thin texture mode.
  2033. */
  2034. get coordinatesMode(): number;
  2035. /**
  2036. * Define if the texture is a cube texture or if false a 2d texture.
  2037. */
  2038. get isCube(): boolean;
  2039. set isCube(value: boolean);
  2040. /**
  2041. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  2042. */
  2043. get is3D(): boolean;
  2044. set is3D(value: boolean);
  2045. /**
  2046. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  2047. */
  2048. get is2DArray(): boolean;
  2049. set is2DArray(value: boolean);
  2050. /**
  2051. * Get the class name of the texture.
  2052. * @returns "ThinTexture"
  2053. */
  2054. getClassName(): string;
  2055. /** @hidden */
  2056. _texture: Nullable<InternalTexture>;
  2057. protected _engine: Nullable<ThinEngine>;
  2058. private _cachedSize;
  2059. private _cachedBaseSize;
  2060. /**
  2061. * Instantiates a new ThinTexture.
  2062. * Base class of all the textures in babylon.
  2063. * This can be used as an internal texture wrapper in ThinEngine to benefit from the cache
  2064. * @param internalTexture Define the internalTexture to wrap
  2065. */
  2066. constructor(internalTexture: Nullable<InternalTexture>);
  2067. /**
  2068. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  2069. * @returns true if fully ready
  2070. */
  2071. isReady(): boolean;
  2072. /**
  2073. * Triggers the load sequence in delayed load mode.
  2074. */
  2075. delayLoad(): void;
  2076. /**
  2077. * Get the underlying lower level texture from Babylon.
  2078. * @returns the insternal texture
  2079. */
  2080. getInternalTexture(): Nullable<InternalTexture>;
  2081. /**
  2082. * Get the size of the texture.
  2083. * @returns the texture size.
  2084. */
  2085. getSize(): ISize;
  2086. /**
  2087. * Get the base size of the texture.
  2088. * It can be different from the size if the texture has been resized for POT for instance
  2089. * @returns the base size
  2090. */
  2091. getBaseSize(): ISize;
  2092. /**
  2093. * Update the sampling mode of the texture.
  2094. * Default is Trilinear mode.
  2095. *
  2096. * | Value | Type | Description |
  2097. * | ----- | ------------------ | ----------- |
  2098. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  2099. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  2100. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  2101. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  2102. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  2103. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  2104. * | 7 | NEAREST_LINEAR | |
  2105. * | 8 | NEAREST_NEAREST | |
  2106. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  2107. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  2108. * | 11 | LINEAR_LINEAR | |
  2109. * | 12 | LINEAR_NEAREST | |
  2110. *
  2111. * > _mag_: magnification filter (close to the viewer)
  2112. * > _min_: minification filter (far from the viewer)
  2113. * > _mip_: filter used between mip map levels
  2114. *@param samplingMode Define the new sampling mode of the texture
  2115. */
  2116. updateSamplingMode(samplingMode: number): void;
  2117. /**
  2118. * Release and destroy the underlying lower level texture aka internalTexture.
  2119. */
  2120. releaseInternalTexture(): void;
  2121. /**
  2122. * Dispose the texture and release its associated resources.
  2123. */
  2124. dispose(): void;
  2125. }
  2126. }
  2127. declare module BABYLON {
  2128. /**
  2129. * Defines an array and its length.
  2130. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  2131. */
  2132. export interface ISmartArrayLike<T> {
  2133. /**
  2134. * The data of the array.
  2135. */
  2136. data: Array<T>;
  2137. /**
  2138. * The active length of the array.
  2139. */
  2140. length: number;
  2141. }
  2142. /**
  2143. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  2144. */
  2145. export class SmartArray<T> implements ISmartArrayLike<T> {
  2146. /**
  2147. * The full set of data from the array.
  2148. */
  2149. data: Array<T>;
  2150. /**
  2151. * The active length of the array.
  2152. */
  2153. length: number;
  2154. protected _id: number;
  2155. /**
  2156. * Instantiates a Smart Array.
  2157. * @param capacity defines the default capacity of the array.
  2158. */
  2159. constructor(capacity: number);
  2160. /**
  2161. * Pushes a value at the end of the active data.
  2162. * @param value defines the object to push in the array.
  2163. */
  2164. push(value: T): void;
  2165. /**
  2166. * Iterates over the active data and apply the lambda to them.
  2167. * @param func defines the action to apply on each value.
  2168. */
  2169. forEach(func: (content: T) => void): void;
  2170. /**
  2171. * Sorts the full sets of data.
  2172. * @param compareFn defines the comparison function to apply.
  2173. */
  2174. sort(compareFn: (a: T, b: T) => number): void;
  2175. /**
  2176. * Resets the active data to an empty array.
  2177. */
  2178. reset(): void;
  2179. /**
  2180. * Releases all the data from the array as well as the array.
  2181. */
  2182. dispose(): void;
  2183. /**
  2184. * Concats the active data with a given array.
  2185. * @param array defines the data to concatenate with.
  2186. */
  2187. concat(array: any): void;
  2188. /**
  2189. * Returns the position of a value in the active data.
  2190. * @param value defines the value to find the index for
  2191. * @returns the index if found in the active data otherwise -1
  2192. */
  2193. indexOf(value: T): number;
  2194. /**
  2195. * Returns whether an element is part of the active data.
  2196. * @param value defines the value to look for
  2197. * @returns true if found in the active data otherwise false
  2198. */
  2199. contains(value: T): boolean;
  2200. private static _GlobalId;
  2201. }
  2202. /**
  2203. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  2204. * The data in this array can only be present once
  2205. */
  2206. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  2207. private _duplicateId;
  2208. /**
  2209. * Pushes a value at the end of the active data.
  2210. * THIS DOES NOT PREVENT DUPPLICATE DATA
  2211. * @param value defines the object to push in the array.
  2212. */
  2213. push(value: T): void;
  2214. /**
  2215. * Pushes a value at the end of the active data.
  2216. * If the data is already present, it won t be added again
  2217. * @param value defines the object to push in the array.
  2218. * @returns true if added false if it was already present
  2219. */
  2220. pushNoDuplicate(value: T): boolean;
  2221. /**
  2222. * Resets the active data to an empty array.
  2223. */
  2224. reset(): void;
  2225. /**
  2226. * Concats the active data with a given array.
  2227. * This ensures no dupplicate will be present in the result.
  2228. * @param array defines the data to concatenate with.
  2229. */
  2230. concatWithNoDuplicate(array: any): void;
  2231. }
  2232. }
  2233. declare module BABYLON {
  2234. /**
  2235. * Class used to evalaute queries containing `and` and `or` operators
  2236. */
  2237. export class AndOrNotEvaluator {
  2238. /**
  2239. * Evaluate a query
  2240. * @param query defines the query to evaluate
  2241. * @param evaluateCallback defines the callback used to filter result
  2242. * @returns true if the query matches
  2243. */
  2244. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  2245. private static _HandleParenthesisContent;
  2246. private static _SimplifyNegation;
  2247. }
  2248. }
  2249. declare module BABYLON {
  2250. /**
  2251. * Class used to store custom tags
  2252. */
  2253. export class Tags {
  2254. /**
  2255. * Adds support for tags on the given object
  2256. * @param obj defines the object to use
  2257. */
  2258. static EnableFor(obj: any): void;
  2259. /**
  2260. * Removes tags support
  2261. * @param obj defines the object to use
  2262. */
  2263. static DisableFor(obj: any): void;
  2264. /**
  2265. * Gets a boolean indicating if the given object has tags
  2266. * @param obj defines the object to use
  2267. * @returns a boolean
  2268. */
  2269. static HasTags(obj: any): boolean;
  2270. /**
  2271. * Gets the tags available on a given object
  2272. * @param obj defines the object to use
  2273. * @param asString defines if the tags must be returned as a string instead of an array of strings
  2274. * @returns the tags
  2275. */
  2276. static GetTags(obj: any, asString?: boolean): any;
  2277. /**
  2278. * Adds tags to an object
  2279. * @param obj defines the object to use
  2280. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  2281. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  2282. */
  2283. static AddTagsTo(obj: any, tagsString: string): void;
  2284. /**
  2285. * @hidden
  2286. */
  2287. static _AddTagTo(obj: any, tag: string): void;
  2288. /**
  2289. * Removes specific tags from a specific object
  2290. * @param obj defines the object to use
  2291. * @param tagsString defines the tags to remove
  2292. */
  2293. static RemoveTagsFrom(obj: any, tagsString: string): void;
  2294. /**
  2295. * @hidden
  2296. */
  2297. static _RemoveTagFrom(obj: any, tag: string): void;
  2298. /**
  2299. * Defines if tags hosted on an object match a given query
  2300. * @param obj defines the object to use
  2301. * @param tagsQuery defines the tag query
  2302. * @returns a boolean
  2303. */
  2304. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  2305. }
  2306. }
  2307. declare module BABYLON {
  2308. /**
  2309. * Scalar computation library
  2310. */
  2311. export class Scalar {
  2312. /**
  2313. * Two pi constants convenient for computation.
  2314. */
  2315. static TwoPi: number;
  2316. /**
  2317. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  2318. * @param a number
  2319. * @param b number
  2320. * @param epsilon (default = 1.401298E-45)
  2321. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  2322. */
  2323. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  2324. /**
  2325. * Returns a string : the upper case translation of the number i to hexadecimal.
  2326. * @param i number
  2327. * @returns the upper case translation of the number i to hexadecimal.
  2328. */
  2329. static ToHex(i: number): string;
  2330. /**
  2331. * Returns -1 if value is negative and +1 is value is positive.
  2332. * @param value the value
  2333. * @returns the value itself if it's equal to zero.
  2334. */
  2335. static Sign(value: number): number;
  2336. /**
  2337. * Returns the value itself if it's between min and max.
  2338. * Returns min if the value is lower than min.
  2339. * Returns max if the value is greater than max.
  2340. * @param value the value to clmap
  2341. * @param min the min value to clamp to (default: 0)
  2342. * @param max the max value to clamp to (default: 1)
  2343. * @returns the clamped value
  2344. */
  2345. static Clamp(value: number, min?: number, max?: number): number;
  2346. /**
  2347. * the log2 of value.
  2348. * @param value the value to compute log2 of
  2349. * @returns the log2 of value.
  2350. */
  2351. static Log2(value: number): number;
  2352. /**
  2353. * the floor part of a log2 value.
  2354. * @param value the value to compute log2 of
  2355. * @returns the log2 of value.
  2356. */
  2357. static ILog2(value: number): number;
  2358. /**
  2359. * Loops the value, so that it is never larger than length and never smaller than 0.
  2360. *
  2361. * This is similar to the modulo operator but it works with floating point numbers.
  2362. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  2363. * With t = 5 and length = 2.5, the result would be 0.0.
  2364. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  2365. * @param value the value
  2366. * @param length the length
  2367. * @returns the looped value
  2368. */
  2369. static Repeat(value: number, length: number): number;
  2370. /**
  2371. * Normalize the value between 0.0 and 1.0 using min and max values
  2372. * @param value value to normalize
  2373. * @param min max to normalize between
  2374. * @param max min to normalize between
  2375. * @returns the normalized value
  2376. */
  2377. static Normalize(value: number, min: number, max: number): number;
  2378. /**
  2379. * Denormalize the value from 0.0 and 1.0 using min and max values
  2380. * @param normalized value to denormalize
  2381. * @param min max to denormalize between
  2382. * @param max min to denormalize between
  2383. * @returns the denormalized value
  2384. */
  2385. static Denormalize(normalized: number, min: number, max: number): number;
  2386. /**
  2387. * Calculates the shortest difference between two given angles given in degrees.
  2388. * @param current current angle in degrees
  2389. * @param target target angle in degrees
  2390. * @returns the delta
  2391. */
  2392. static DeltaAngle(current: number, target: number): number;
  2393. /**
  2394. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  2395. * @param tx value
  2396. * @param length length
  2397. * @returns The returned value will move back and forth between 0 and length
  2398. */
  2399. static PingPong(tx: number, length: number): number;
  2400. /**
  2401. * Interpolates between min and max with smoothing at the limits.
  2402. *
  2403. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  2404. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  2405. * @param from from
  2406. * @param to to
  2407. * @param tx value
  2408. * @returns the smooth stepped value
  2409. */
  2410. static SmoothStep(from: number, to: number, tx: number): number;
  2411. /**
  2412. * Moves a value current towards target.
  2413. *
  2414. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  2415. * Negative values of maxDelta pushes the value away from target.
  2416. * @param current current value
  2417. * @param target target value
  2418. * @param maxDelta max distance to move
  2419. * @returns resulting value
  2420. */
  2421. static MoveTowards(current: number, target: number, maxDelta: number): number;
  2422. /**
  2423. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  2424. *
  2425. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  2426. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  2427. * @param current current value
  2428. * @param target target value
  2429. * @param maxDelta max distance to move
  2430. * @returns resulting angle
  2431. */
  2432. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  2433. /**
  2434. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  2435. * @param start start value
  2436. * @param end target value
  2437. * @param amount amount to lerp between
  2438. * @returns the lerped value
  2439. */
  2440. static Lerp(start: number, end: number, amount: number): number;
  2441. /**
  2442. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  2443. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  2444. * @param start start value
  2445. * @param end target value
  2446. * @param amount amount to lerp between
  2447. * @returns the lerped value
  2448. */
  2449. static LerpAngle(start: number, end: number, amount: number): number;
  2450. /**
  2451. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  2452. * @param a start value
  2453. * @param b target value
  2454. * @param value value between a and b
  2455. * @returns the inverseLerp value
  2456. */
  2457. static InverseLerp(a: number, b: number, value: number): number;
  2458. /**
  2459. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  2460. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  2461. * @param value1 spline value
  2462. * @param tangent1 spline value
  2463. * @param value2 spline value
  2464. * @param tangent2 spline value
  2465. * @param amount input value
  2466. * @returns hermite result
  2467. */
  2468. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  2469. /**
  2470. * Returns a random float number between and min and max values
  2471. * @param min min value of random
  2472. * @param max max value of random
  2473. * @returns random value
  2474. */
  2475. static RandomRange(min: number, max: number): number;
  2476. /**
  2477. * This function returns percentage of a number in a given range.
  2478. *
  2479. * RangeToPercent(40,20,60) will return 0.5 (50%)
  2480. * RangeToPercent(34,0,100) will return 0.34 (34%)
  2481. * @param number to convert to percentage
  2482. * @param min min range
  2483. * @param max max range
  2484. * @returns the percentage
  2485. */
  2486. static RangeToPercent(number: number, min: number, max: number): number;
  2487. /**
  2488. * This function returns number that corresponds to the percentage in a given range.
  2489. *
  2490. * PercentToRange(0.34,0,100) will return 34.
  2491. * @param percent to convert to number
  2492. * @param min min range
  2493. * @param max max range
  2494. * @returns the number
  2495. */
  2496. static PercentToRange(percent: number, min: number, max: number): number;
  2497. /**
  2498. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  2499. * @param angle The angle to normalize in radian.
  2500. * @return The converted angle.
  2501. */
  2502. static NormalizeRadians(angle: number): number;
  2503. }
  2504. }
  2505. declare module BABYLON {
  2506. /**
  2507. * Constant used to convert a value to gamma space
  2508. * @ignorenaming
  2509. */
  2510. export const ToGammaSpace: number;
  2511. /**
  2512. * Constant used to convert a value to linear space
  2513. * @ignorenaming
  2514. */
  2515. export const ToLinearSpace = 2.2;
  2516. /**
  2517. * Constant used to define the minimal number value in Babylon.js
  2518. * @ignorenaming
  2519. */
  2520. let Epsilon: number;
  2521. }
  2522. declare module BABYLON {
  2523. /**
  2524. * Class used to represent a viewport on screen
  2525. */
  2526. export class Viewport {
  2527. /** viewport left coordinate */
  2528. x: number;
  2529. /** viewport top coordinate */
  2530. y: number;
  2531. /**viewport width */
  2532. width: number;
  2533. /** viewport height */
  2534. height: number;
  2535. /**
  2536. * Creates a Viewport object located at (x, y) and sized (width, height)
  2537. * @param x defines viewport left coordinate
  2538. * @param y defines viewport top coordinate
  2539. * @param width defines the viewport width
  2540. * @param height defines the viewport height
  2541. */
  2542. constructor(
  2543. /** viewport left coordinate */
  2544. x: number,
  2545. /** viewport top coordinate */
  2546. y: number,
  2547. /**viewport width */
  2548. width: number,
  2549. /** viewport height */
  2550. height: number);
  2551. /**
  2552. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  2553. * @param renderWidth defines the rendering width
  2554. * @param renderHeight defines the rendering height
  2555. * @returns a new Viewport
  2556. */
  2557. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  2558. /**
  2559. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  2560. * @param renderWidth defines the rendering width
  2561. * @param renderHeight defines the rendering height
  2562. * @param ref defines the target viewport
  2563. * @returns the current viewport
  2564. */
  2565. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  2566. /**
  2567. * Returns a new Viewport copied from the current one
  2568. * @returns a new Viewport
  2569. */
  2570. clone(): Viewport;
  2571. }
  2572. }
  2573. declare module BABYLON {
  2574. /**
  2575. * Class containing a set of static utilities functions for arrays.
  2576. */
  2577. export class ArrayTools {
  2578. /**
  2579. * Returns an array of the given size filled with element built from the given constructor and the paramters
  2580. * @param size the number of element to construct and put in the array
  2581. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  2582. * @returns a new array filled with new objects
  2583. */
  2584. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  2585. }
  2586. }
  2587. declare module BABYLON {
  2588. /**
  2589. * Represents a plane by the equation ax + by + cz + d = 0
  2590. */
  2591. export class Plane {
  2592. private static _TmpMatrix;
  2593. /**
  2594. * Normal of the plane (a,b,c)
  2595. */
  2596. normal: Vector3;
  2597. /**
  2598. * d component of the plane
  2599. */
  2600. d: number;
  2601. /**
  2602. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  2603. * @param a a component of the plane
  2604. * @param b b component of the plane
  2605. * @param c c component of the plane
  2606. * @param d d component of the plane
  2607. */
  2608. constructor(a: number, b: number, c: number, d: number);
  2609. /**
  2610. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  2611. */
  2612. asArray(): number[];
  2613. /**
  2614. * @returns a new plane copied from the current Plane.
  2615. */
  2616. clone(): Plane;
  2617. /**
  2618. * @returns the string "Plane".
  2619. */
  2620. getClassName(): string;
  2621. /**
  2622. * @returns the Plane hash code.
  2623. */
  2624. getHashCode(): number;
  2625. /**
  2626. * Normalize the current Plane in place.
  2627. * @returns the updated Plane.
  2628. */
  2629. normalize(): Plane;
  2630. /**
  2631. * Applies a transformation the plane and returns the result
  2632. * @param transformation the transformation matrix to be applied to the plane
  2633. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  2634. */
  2635. transform(transformation: DeepImmutable<Matrix>): Plane;
  2636. /**
  2637. * Compute the dot product between the point and the plane normal
  2638. * @param point point to calculate the dot product with
  2639. * @returns the dot product (float) of the point coordinates and the plane normal.
  2640. */
  2641. dotCoordinate(point: DeepImmutable<Vector3>): number;
  2642. /**
  2643. * Updates the current Plane from the plane defined by the three given points.
  2644. * @param point1 one of the points used to contruct the plane
  2645. * @param point2 one of the points used to contruct the plane
  2646. * @param point3 one of the points used to contruct the plane
  2647. * @returns the updated Plane.
  2648. */
  2649. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2650. /**
  2651. * 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).
  2652. * Note that for this function to work as expected you should make sure that:
  2653. * - direction and the plane normal are normalized
  2654. * - epsilon is a number just bigger than -1, something like -0.99 for eg
  2655. * @param direction the direction to check if the plane is facing
  2656. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  2657. * @returns True if the plane is facing the given direction
  2658. */
  2659. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  2660. /**
  2661. * Calculates the distance to a point
  2662. * @param point point to calculate distance to
  2663. * @returns the signed distance (float) from the given point to the Plane.
  2664. */
  2665. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  2666. /**
  2667. * Creates a plane from an array
  2668. * @param array the array to create a plane from
  2669. * @returns a new Plane from the given array.
  2670. */
  2671. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  2672. /**
  2673. * Creates a plane from three points
  2674. * @param point1 point used to create the plane
  2675. * @param point2 point used to create the plane
  2676. * @param point3 point used to create the plane
  2677. * @returns a new Plane defined by the three given points.
  2678. */
  2679. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2680. /**
  2681. * Creates a plane from an origin point and a normal
  2682. * @param origin origin of the plane to be constructed
  2683. * @param normal normal of the plane to be constructed
  2684. * @returns a new Plane the normal vector to this plane at the given origin point.
  2685. * Note : the vector "normal" is updated because normalized.
  2686. */
  2687. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: Vector3): Plane;
  2688. /**
  2689. * Calculates the distance from a plane and a point
  2690. * @param origin origin of the plane to be constructed
  2691. * @param normal normal of the plane to be constructed
  2692. * @param point point to calculate distance to
  2693. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  2694. */
  2695. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  2696. }
  2697. }
  2698. declare module BABYLON {
  2699. /** @hidden */
  2700. export class PerformanceConfigurator {
  2701. /** @hidden */
  2702. static MatrixUse64Bits: boolean;
  2703. /** @hidden */
  2704. static MatrixTrackPrecisionChange: boolean;
  2705. /** @hidden */
  2706. static MatrixCurrentType: any;
  2707. /** @hidden */
  2708. static MatrixTrackedMatrices: Array<any> | null;
  2709. /** @hidden */
  2710. static SetMatrixPrecision(use64bits: boolean): void;
  2711. }
  2712. }
  2713. declare module BABYLON {
  2714. /**
  2715. * Class representing a vector containing 2 coordinates
  2716. */
  2717. export class Vector2 {
  2718. /** defines the first coordinate */
  2719. x: number;
  2720. /** defines the second coordinate */
  2721. y: number;
  2722. /**
  2723. * Creates a new Vector2 from the given x and y coordinates
  2724. * @param x defines the first coordinate
  2725. * @param y defines the second coordinate
  2726. */
  2727. constructor(
  2728. /** defines the first coordinate */
  2729. x?: number,
  2730. /** defines the second coordinate */
  2731. y?: number);
  2732. /**
  2733. * Gets a string with the Vector2 coordinates
  2734. * @returns a string with the Vector2 coordinates
  2735. */
  2736. toString(): string;
  2737. /**
  2738. * Gets class name
  2739. * @returns the string "Vector2"
  2740. */
  2741. getClassName(): string;
  2742. /**
  2743. * Gets current vector hash code
  2744. * @returns the Vector2 hash code as a number
  2745. */
  2746. getHashCode(): number;
  2747. /**
  2748. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  2749. * @param array defines the source array
  2750. * @param index defines the offset in source array
  2751. * @returns the current Vector2
  2752. */
  2753. toArray(array: FloatArray, index?: number): Vector2;
  2754. /**
  2755. * Update the current vector from an array
  2756. * @param array defines the destination array
  2757. * @param index defines the offset in the destination array
  2758. * @returns the current Vector3
  2759. */
  2760. fromArray(array: FloatArray, index?: number): Vector2;
  2761. /**
  2762. * Copy the current vector to an array
  2763. * @returns a new array with 2 elements: the Vector2 coordinates.
  2764. */
  2765. asArray(): number[];
  2766. /**
  2767. * Sets the Vector2 coordinates with the given Vector2 coordinates
  2768. * @param source defines the source Vector2
  2769. * @returns the current updated Vector2
  2770. */
  2771. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  2772. /**
  2773. * Sets the Vector2 coordinates with the given floats
  2774. * @param x defines the first coordinate
  2775. * @param y defines the second coordinate
  2776. * @returns the current updated Vector2
  2777. */
  2778. copyFromFloats(x: number, y: number): Vector2;
  2779. /**
  2780. * Sets the Vector2 coordinates with the given floats
  2781. * @param x defines the first coordinate
  2782. * @param y defines the second coordinate
  2783. * @returns the current updated Vector2
  2784. */
  2785. set(x: number, y: number): Vector2;
  2786. /**
  2787. * Add another vector with the current one
  2788. * @param otherVector defines the other vector
  2789. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  2790. */
  2791. add(otherVector: DeepImmutable<Vector2>): Vector2;
  2792. /**
  2793. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  2794. * @param otherVector defines the other vector
  2795. * @param result defines the target vector
  2796. * @returns the unmodified current Vector2
  2797. */
  2798. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2799. /**
  2800. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  2801. * @param otherVector defines the other vector
  2802. * @returns the current updated Vector2
  2803. */
  2804. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2805. /**
  2806. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  2807. * @param otherVector defines the other vector
  2808. * @returns a new Vector2
  2809. */
  2810. addVector3(otherVector: Vector3): Vector2;
  2811. /**
  2812. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  2813. * @param otherVector defines the other vector
  2814. * @returns a new Vector2
  2815. */
  2816. subtract(otherVector: Vector2): Vector2;
  2817. /**
  2818. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  2819. * @param otherVector defines the other vector
  2820. * @param result defines the target vector
  2821. * @returns the unmodified current Vector2
  2822. */
  2823. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2824. /**
  2825. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2826. * @param otherVector defines the other vector
  2827. * @returns the current updated Vector2
  2828. */
  2829. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2830. /**
  2831. * Multiplies in place the current Vector2 coordinates by the given ones
  2832. * @param otherVector defines the other vector
  2833. * @returns the current updated Vector2
  2834. */
  2835. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2836. /**
  2837. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2838. * @param otherVector defines the other vector
  2839. * @returns a new Vector2
  2840. */
  2841. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2842. /**
  2843. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2844. * @param otherVector defines the other vector
  2845. * @param result defines the target vector
  2846. * @returns the unmodified current Vector2
  2847. */
  2848. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2849. /**
  2850. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2851. * @param x defines the first coordinate
  2852. * @param y defines the second coordinate
  2853. * @returns a new Vector2
  2854. */
  2855. multiplyByFloats(x: number, y: number): Vector2;
  2856. /**
  2857. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2858. * @param otherVector defines the other vector
  2859. * @returns a new Vector2
  2860. */
  2861. divide(otherVector: Vector2): Vector2;
  2862. /**
  2863. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2864. * @param otherVector defines the other vector
  2865. * @param result defines the target vector
  2866. * @returns the unmodified current Vector2
  2867. */
  2868. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2869. /**
  2870. * Divides the current Vector2 coordinates by the given ones
  2871. * @param otherVector defines the other vector
  2872. * @returns the current updated Vector2
  2873. */
  2874. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2875. /**
  2876. * Gets a new Vector2 with current Vector2 negated coordinates
  2877. * @returns a new Vector2
  2878. */
  2879. negate(): Vector2;
  2880. /**
  2881. * Negate this vector in place
  2882. * @returns this
  2883. */
  2884. negateInPlace(): Vector2;
  2885. /**
  2886. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  2887. * @param result defines the Vector3 object where to store the result
  2888. * @returns the current Vector2
  2889. */
  2890. negateToRef(result: Vector2): Vector2;
  2891. /**
  2892. * Multiply the Vector2 coordinates by scale
  2893. * @param scale defines the scaling factor
  2894. * @returns the current updated Vector2
  2895. */
  2896. scaleInPlace(scale: number): Vector2;
  2897. /**
  2898. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2899. * @param scale defines the scaling factor
  2900. * @returns a new Vector2
  2901. */
  2902. scale(scale: number): Vector2;
  2903. /**
  2904. * Scale the current Vector2 values by a factor to a given Vector2
  2905. * @param scale defines the scale factor
  2906. * @param result defines the Vector2 object where to store the result
  2907. * @returns the unmodified current Vector2
  2908. */
  2909. scaleToRef(scale: number, result: Vector2): Vector2;
  2910. /**
  2911. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2912. * @param scale defines the scale factor
  2913. * @param result defines the Vector2 object where to store the result
  2914. * @returns the unmodified current Vector2
  2915. */
  2916. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2917. /**
  2918. * Gets a boolean if two vectors are equals
  2919. * @param otherVector defines the other vector
  2920. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2921. */
  2922. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2923. /**
  2924. * Gets a boolean if two vectors are equals (using an epsilon value)
  2925. * @param otherVector defines the other vector
  2926. * @param epsilon defines the minimal distance to consider equality
  2927. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2928. */
  2929. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2930. /**
  2931. * Gets a new Vector2 from current Vector2 floored values
  2932. * @returns a new Vector2
  2933. */
  2934. floor(): Vector2;
  2935. /**
  2936. * Gets a new Vector2 from current Vector2 floored values
  2937. * @returns a new Vector2
  2938. */
  2939. fract(): Vector2;
  2940. /**
  2941. * Gets the length of the vector
  2942. * @returns the vector length (float)
  2943. */
  2944. length(): number;
  2945. /**
  2946. * Gets the vector squared length
  2947. * @returns the vector squared length (float)
  2948. */
  2949. lengthSquared(): number;
  2950. /**
  2951. * Normalize the vector
  2952. * @returns the current updated Vector2
  2953. */
  2954. normalize(): Vector2;
  2955. /**
  2956. * Gets a new Vector2 copied from the Vector2
  2957. * @returns a new Vector2
  2958. */
  2959. clone(): Vector2;
  2960. /**
  2961. * Gets a new Vector2(0, 0)
  2962. * @returns a new Vector2
  2963. */
  2964. static Zero(): Vector2;
  2965. /**
  2966. * Gets a new Vector2(1, 1)
  2967. * @returns a new Vector2
  2968. */
  2969. static One(): Vector2;
  2970. /**
  2971. * Gets a new Vector2 set from the given index element of the given array
  2972. * @param array defines the data source
  2973. * @param offset defines the offset in the data source
  2974. * @returns a new Vector2
  2975. */
  2976. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2977. /**
  2978. * Sets "result" from the given index element of the given array
  2979. * @param array defines the data source
  2980. * @param offset defines the offset in the data source
  2981. * @param result defines the target vector
  2982. */
  2983. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2984. /**
  2985. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2986. * @param value1 defines 1st point of control
  2987. * @param value2 defines 2nd point of control
  2988. * @param value3 defines 3rd point of control
  2989. * @param value4 defines 4th point of control
  2990. * @param amount defines the interpolation factor
  2991. * @returns a new Vector2
  2992. */
  2993. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2994. /**
  2995. * 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".
  2996. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2997. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2998. * @param value defines the value to clamp
  2999. * @param min defines the lower limit
  3000. * @param max defines the upper limit
  3001. * @returns a new Vector2
  3002. */
  3003. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  3004. /**
  3005. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  3006. * @param value1 defines the 1st control point
  3007. * @param tangent1 defines the outgoing tangent
  3008. * @param value2 defines the 2nd control point
  3009. * @param tangent2 defines the incoming tangent
  3010. * @param amount defines the interpolation factor
  3011. * @returns a new Vector2
  3012. */
  3013. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  3014. /**
  3015. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  3016. * @param start defines the start vector
  3017. * @param end defines the end vector
  3018. * @param amount defines the interpolation factor
  3019. * @returns a new Vector2
  3020. */
  3021. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  3022. /**
  3023. * Gets the dot product of the vector "left" and the vector "right"
  3024. * @param left defines first vector
  3025. * @param right defines second vector
  3026. * @returns the dot product (float)
  3027. */
  3028. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  3029. /**
  3030. * Returns a new Vector2 equal to the normalized given vector
  3031. * @param vector defines the vector to normalize
  3032. * @returns a new Vector2
  3033. */
  3034. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  3035. /**
  3036. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  3037. * @param left defines 1st vector
  3038. * @param right defines 2nd vector
  3039. * @returns a new Vector2
  3040. */
  3041. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  3042. /**
  3043. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  3044. * @param left defines 1st vector
  3045. * @param right defines 2nd vector
  3046. * @returns a new Vector2
  3047. */
  3048. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  3049. /**
  3050. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  3051. * @param vector defines the vector to transform
  3052. * @param transformation defines the matrix to apply
  3053. * @returns a new Vector2
  3054. */
  3055. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  3056. /**
  3057. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  3058. * @param vector defines the vector to transform
  3059. * @param transformation defines the matrix to apply
  3060. * @param result defines the target vector
  3061. */
  3062. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  3063. /**
  3064. * Determines if a given vector is included in a triangle
  3065. * @param p defines the vector to test
  3066. * @param p0 defines 1st triangle point
  3067. * @param p1 defines 2nd triangle point
  3068. * @param p2 defines 3rd triangle point
  3069. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  3070. */
  3071. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  3072. /**
  3073. * Gets the distance between the vectors "value1" and "value2"
  3074. * @param value1 defines first vector
  3075. * @param value2 defines second vector
  3076. * @returns the distance between vectors
  3077. */
  3078. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  3079. /**
  3080. * Returns the squared distance between the vectors "value1" and "value2"
  3081. * @param value1 defines first vector
  3082. * @param value2 defines second vector
  3083. * @returns the squared distance between vectors
  3084. */
  3085. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  3086. /**
  3087. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  3088. * @param value1 defines first vector
  3089. * @param value2 defines second vector
  3090. * @returns a new Vector2
  3091. */
  3092. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  3093. /**
  3094. * Gets the center of the vectors "value1" and "value2" and stores the result in the vector "ref"
  3095. * @param value1 defines first vector
  3096. * @param value2 defines second vector
  3097. * @param ref defines third vector
  3098. * @returns ref
  3099. */
  3100. static CenterToRef(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, ref: DeepImmutable<Vector2>): Vector2;
  3101. /**
  3102. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  3103. * @param p defines the middle point
  3104. * @param segA defines one point of the segment
  3105. * @param segB defines the other point of the segment
  3106. * @returns the shortest distance
  3107. */
  3108. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  3109. }
  3110. /**
  3111. * Class used to store (x,y,z) vector representation
  3112. * A Vector3 is the main object used in 3D geometry
  3113. * It can represent etiher the coordinates of a point the space, either a direction
  3114. * Reminder: js uses a left handed forward facing system
  3115. */
  3116. export class Vector3 {
  3117. private static _UpReadOnly;
  3118. private static _ZeroReadOnly;
  3119. /** @hidden */
  3120. _x: number;
  3121. /** @hidden */
  3122. _y: number;
  3123. /** @hidden */
  3124. _z: number;
  3125. /** @hidden */
  3126. _isDirty: boolean;
  3127. /** Gets or sets the x coordinate */
  3128. get x(): number;
  3129. set x(value: number);
  3130. /** Gets or sets the y coordinate */
  3131. get y(): number;
  3132. set y(value: number);
  3133. /** Gets or sets the z coordinate */
  3134. get z(): number;
  3135. set z(value: number);
  3136. /**
  3137. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  3138. * @param x defines the first coordinates (on X axis)
  3139. * @param y defines the second coordinates (on Y axis)
  3140. * @param z defines the third coordinates (on Z axis)
  3141. */
  3142. constructor(x?: number, y?: number, z?: number);
  3143. /**
  3144. * Creates a string representation of the Vector3
  3145. * @returns a string with the Vector3 coordinates.
  3146. */
  3147. toString(): string;
  3148. /**
  3149. * Gets the class name
  3150. * @returns the string "Vector3"
  3151. */
  3152. getClassName(): string;
  3153. /**
  3154. * Creates the Vector3 hash code
  3155. * @returns a number which tends to be unique between Vector3 instances
  3156. */
  3157. getHashCode(): number;
  3158. /**
  3159. * Creates an array containing three elements : the coordinates of the Vector3
  3160. * @returns a new array of numbers
  3161. */
  3162. asArray(): number[];
  3163. /**
  3164. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  3165. * @param array defines the destination array
  3166. * @param index defines the offset in the destination array
  3167. * @returns the current Vector3
  3168. */
  3169. toArray(array: FloatArray, index?: number): Vector3;
  3170. /**
  3171. * Update the current vector from an array
  3172. * @param array defines the destination array
  3173. * @param index defines the offset in the destination array
  3174. * @returns the current Vector3
  3175. */
  3176. fromArray(array: FloatArray, index?: number): Vector3;
  3177. /**
  3178. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  3179. * @returns a new Quaternion object, computed from the Vector3 coordinates
  3180. */
  3181. toQuaternion(): Quaternion;
  3182. /**
  3183. * Adds the given vector to the current Vector3
  3184. * @param otherVector defines the second operand
  3185. * @returns the current updated Vector3
  3186. */
  3187. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  3188. /**
  3189. * Adds the given coordinates to the current Vector3
  3190. * @param x defines the x coordinate of the operand
  3191. * @param y defines the y coordinate of the operand
  3192. * @param z defines the z coordinate of the operand
  3193. * @returns the current updated Vector3
  3194. */
  3195. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  3196. /**
  3197. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  3198. * @param otherVector defines the second operand
  3199. * @returns the resulting Vector3
  3200. */
  3201. add(otherVector: DeepImmutable<Vector3>): Vector3;
  3202. /**
  3203. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  3204. * @param otherVector defines the second operand
  3205. * @param result defines the Vector3 object where to store the result
  3206. * @returns the current Vector3
  3207. */
  3208. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  3209. /**
  3210. * Subtract the given vector from the current Vector3
  3211. * @param otherVector defines the second operand
  3212. * @returns the current updated Vector3
  3213. */
  3214. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  3215. /**
  3216. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  3217. * @param otherVector defines the second operand
  3218. * @returns the resulting Vector3
  3219. */
  3220. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  3221. /**
  3222. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  3223. * @param otherVector defines the second operand
  3224. * @param result defines the Vector3 object where to store the result
  3225. * @returns the current Vector3
  3226. */
  3227. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  3228. /**
  3229. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  3230. * @param x defines the x coordinate of the operand
  3231. * @param y defines the y coordinate of the operand
  3232. * @param z defines the z coordinate of the operand
  3233. * @returns the resulting Vector3
  3234. */
  3235. subtractFromFloats(x: number, y: number, z: number): Vector3;
  3236. /**
  3237. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  3238. * @param x defines the x coordinate of the operand
  3239. * @param y defines the y coordinate of the operand
  3240. * @param z defines the z coordinate of the operand
  3241. * @param result defines the Vector3 object where to store the result
  3242. * @returns the current Vector3
  3243. */
  3244. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  3245. /**
  3246. * Gets a new Vector3 set with the current Vector3 negated coordinates
  3247. * @returns a new Vector3
  3248. */
  3249. negate(): Vector3;
  3250. /**
  3251. * Negate this vector in place
  3252. * @returns this
  3253. */
  3254. negateInPlace(): Vector3;
  3255. /**
  3256. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  3257. * @param result defines the Vector3 object where to store the result
  3258. * @returns the current Vector3
  3259. */
  3260. negateToRef(result: Vector3): Vector3;
  3261. /**
  3262. * Multiplies the Vector3 coordinates by the float "scale"
  3263. * @param scale defines the multiplier factor
  3264. * @returns the current updated Vector3
  3265. */
  3266. scaleInPlace(scale: number): Vector3;
  3267. /**
  3268. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  3269. * @param scale defines the multiplier factor
  3270. * @returns a new Vector3
  3271. */
  3272. scale(scale: number): Vector3;
  3273. /**
  3274. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  3275. * @param scale defines the multiplier factor
  3276. * @param result defines the Vector3 object where to store the result
  3277. * @returns the current Vector3
  3278. */
  3279. scaleToRef(scale: number, result: Vector3): Vector3;
  3280. /**
  3281. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  3282. * @param scale defines the scale factor
  3283. * @param result defines the Vector3 object where to store the result
  3284. * @returns the unmodified current Vector3
  3285. */
  3286. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  3287. /**
  3288. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  3289. * @param origin defines the origin of the projection ray
  3290. * @param plane defines the plane to project to
  3291. * @returns the projected vector3
  3292. */
  3293. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  3294. /**
  3295. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  3296. * @param origin defines the origin of the projection ray
  3297. * @param plane defines the plane to project to
  3298. * @param result defines the Vector3 where to store the result
  3299. */
  3300. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  3301. /**
  3302. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  3303. * @param otherVector defines the second operand
  3304. * @returns true if both vectors are equals
  3305. */
  3306. equals(otherVector: DeepImmutable<Vector3>): boolean;
  3307. /**
  3308. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  3309. * @param otherVector defines the second operand
  3310. * @param epsilon defines the minimal distance to define values as equals
  3311. * @returns true if both vectors are distant less than epsilon
  3312. */
  3313. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  3314. /**
  3315. * Returns true if the current Vector3 coordinates equals the given floats
  3316. * @param x defines the x coordinate of the operand
  3317. * @param y defines the y coordinate of the operand
  3318. * @param z defines the z coordinate of the operand
  3319. * @returns true if both vectors are equals
  3320. */
  3321. equalsToFloats(x: number, y: number, z: number): boolean;
  3322. /**
  3323. * Multiplies the current Vector3 coordinates by the given ones
  3324. * @param otherVector defines the second operand
  3325. * @returns the current updated Vector3
  3326. */
  3327. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  3328. /**
  3329. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  3330. * @param otherVector defines the second operand
  3331. * @returns the new Vector3
  3332. */
  3333. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  3334. /**
  3335. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  3336. * @param otherVector defines the second operand
  3337. * @param result defines the Vector3 object where to store the result
  3338. * @returns the current Vector3
  3339. */
  3340. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  3341. /**
  3342. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  3343. * @param x defines the x coordinate of the operand
  3344. * @param y defines the y coordinate of the operand
  3345. * @param z defines the z coordinate of the operand
  3346. * @returns the new Vector3
  3347. */
  3348. multiplyByFloats(x: number, y: number, z: number): Vector3;
  3349. /**
  3350. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  3351. * @param otherVector defines the second operand
  3352. * @returns the new Vector3
  3353. */
  3354. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  3355. /**
  3356. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  3357. * @param otherVector defines the second operand
  3358. * @param result defines the Vector3 object where to store the result
  3359. * @returns the current Vector3
  3360. */
  3361. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  3362. /**
  3363. * Divides the current Vector3 coordinates by the given ones.
  3364. * @param otherVector defines the second operand
  3365. * @returns the current updated Vector3
  3366. */
  3367. divideInPlace(otherVector: Vector3): Vector3;
  3368. /**
  3369. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  3370. * @param other defines the second operand
  3371. * @returns the current updated Vector3
  3372. */
  3373. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  3374. /**
  3375. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  3376. * @param other defines the second operand
  3377. * @returns the current updated Vector3
  3378. */
  3379. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  3380. /**
  3381. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  3382. * @param x defines the x coordinate of the operand
  3383. * @param y defines the y coordinate of the operand
  3384. * @param z defines the z coordinate of the operand
  3385. * @returns the current updated Vector3
  3386. */
  3387. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  3388. /**
  3389. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  3390. * @param x defines the x coordinate of the operand
  3391. * @param y defines the y coordinate of the operand
  3392. * @param z defines the z coordinate of the operand
  3393. * @returns the current updated Vector3
  3394. */
  3395. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  3396. /**
  3397. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  3398. * Check if is non uniform within a certain amount of decimal places to account for this
  3399. * @param epsilon the amount the values can differ
  3400. * @returns if the the vector is non uniform to a certain number of decimal places
  3401. */
  3402. isNonUniformWithinEpsilon(epsilon: number): boolean;
  3403. /**
  3404. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  3405. */
  3406. get isNonUniform(): boolean;
  3407. /**
  3408. * Gets a new Vector3 from current Vector3 floored values
  3409. * @returns a new Vector3
  3410. */
  3411. floor(): Vector3;
  3412. /**
  3413. * Gets a new Vector3 from current Vector3 floored values
  3414. * @returns a new Vector3
  3415. */
  3416. fract(): Vector3;
  3417. /**
  3418. * Gets the length of the Vector3
  3419. * @returns the length of the Vector3
  3420. */
  3421. length(): number;
  3422. /**
  3423. * Gets the squared length of the Vector3
  3424. * @returns squared length of the Vector3
  3425. */
  3426. lengthSquared(): number;
  3427. /**
  3428. * Normalize the current Vector3.
  3429. * Please note that this is an in place operation.
  3430. * @returns the current updated Vector3
  3431. */
  3432. normalize(): Vector3;
  3433. /**
  3434. * Reorders the x y z properties of the vector in place
  3435. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  3436. * @returns the current updated vector
  3437. */
  3438. reorderInPlace(order: string): this;
  3439. /**
  3440. * Rotates the vector around 0,0,0 by a quaternion
  3441. * @param quaternion the rotation quaternion
  3442. * @param result vector to store the result
  3443. * @returns the resulting vector
  3444. */
  3445. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  3446. /**
  3447. * Rotates a vector around a given point
  3448. * @param quaternion the rotation quaternion
  3449. * @param point the point to rotate around
  3450. * @param result vector to store the result
  3451. * @returns the resulting vector
  3452. */
  3453. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  3454. /**
  3455. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  3456. * The cross product is then orthogonal to both current and "other"
  3457. * @param other defines the right operand
  3458. * @returns the cross product
  3459. */
  3460. cross(other: Vector3): Vector3;
  3461. /**
  3462. * Normalize the current Vector3 with the given input length.
  3463. * Please note that this is an in place operation.
  3464. * @param len the length of the vector
  3465. * @returns the current updated Vector3
  3466. */
  3467. normalizeFromLength(len: number): Vector3;
  3468. /**
  3469. * Normalize the current Vector3 to a new vector
  3470. * @returns the new Vector3
  3471. */
  3472. normalizeToNew(): Vector3;
  3473. /**
  3474. * Normalize the current Vector3 to the reference
  3475. * @param reference define the Vector3 to update
  3476. * @returns the updated Vector3
  3477. */
  3478. normalizeToRef(reference: Vector3): Vector3;
  3479. /**
  3480. * Creates a new Vector3 copied from the current Vector3
  3481. * @returns the new Vector3
  3482. */
  3483. clone(): Vector3;
  3484. /**
  3485. * Copies the given vector coordinates to the current Vector3 ones
  3486. * @param source defines the source Vector3
  3487. * @returns the current updated Vector3
  3488. */
  3489. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  3490. /**
  3491. * Copies the given floats to the current Vector3 coordinates
  3492. * @param x defines the x coordinate of the operand
  3493. * @param y defines the y coordinate of the operand
  3494. * @param z defines the z coordinate of the operand
  3495. * @returns the current updated Vector3
  3496. */
  3497. copyFromFloats(x: number, y: number, z: number): Vector3;
  3498. /**
  3499. * Copies the given floats to the current Vector3 coordinates
  3500. * @param x defines the x coordinate of the operand
  3501. * @param y defines the y coordinate of the operand
  3502. * @param z defines the z coordinate of the operand
  3503. * @returns the current updated Vector3
  3504. */
  3505. set(x: number, y: number, z: number): Vector3;
  3506. /**
  3507. * Copies the given float to the current Vector3 coordinates
  3508. * @param v defines the x, y and z coordinates of the operand
  3509. * @returns the current updated Vector3
  3510. */
  3511. setAll(v: number): Vector3;
  3512. /**
  3513. * Get the clip factor between two vectors
  3514. * @param vector0 defines the first operand
  3515. * @param vector1 defines the second operand
  3516. * @param axis defines the axis to use
  3517. * @param size defines the size along the axis
  3518. * @returns the clip factor
  3519. */
  3520. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  3521. /**
  3522. * Get angle between two vectors
  3523. * @param vector0 angle between vector0 and vector1
  3524. * @param vector1 angle between vector0 and vector1
  3525. * @param normal direction of the normal
  3526. * @return the angle between vector0 and vector1
  3527. */
  3528. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  3529. /**
  3530. * Returns a new Vector3 set from the index "offset" of the given array
  3531. * @param array defines the source array
  3532. * @param offset defines the offset in the source array
  3533. * @returns the new Vector3
  3534. */
  3535. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  3536. /**
  3537. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  3538. * @param array defines the source array
  3539. * @param offset defines the offset in the source array
  3540. * @returns the new Vector3
  3541. * @deprecated Please use FromArray instead.
  3542. */
  3543. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  3544. /**
  3545. * Sets the given vector "result" with the element values from the index "offset" of the given array
  3546. * @param array defines the source array
  3547. * @param offset defines the offset in the source array
  3548. * @param result defines the Vector3 where to store the result
  3549. */
  3550. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  3551. /**
  3552. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  3553. * @param array defines the source array
  3554. * @param offset defines the offset in the source array
  3555. * @param result defines the Vector3 where to store the result
  3556. * @deprecated Please use FromArrayToRef instead.
  3557. */
  3558. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  3559. /**
  3560. * Sets the given vector "result" with the given floats.
  3561. * @param x defines the x coordinate of the source
  3562. * @param y defines the y coordinate of the source
  3563. * @param z defines the z coordinate of the source
  3564. * @param result defines the Vector3 where to store the result
  3565. */
  3566. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  3567. /**
  3568. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  3569. * @returns a new empty Vector3
  3570. */
  3571. static Zero(): Vector3;
  3572. /**
  3573. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  3574. * @returns a new unit Vector3
  3575. */
  3576. static One(): Vector3;
  3577. /**
  3578. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  3579. * @returns a new up Vector3
  3580. */
  3581. static Up(): Vector3;
  3582. /**
  3583. * Gets a up Vector3 that must not be updated
  3584. */
  3585. static get UpReadOnly(): DeepImmutable<Vector3>;
  3586. /**
  3587. * Gets a zero Vector3 that must not be updated
  3588. */
  3589. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  3590. /**
  3591. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  3592. * @returns a new down Vector3
  3593. */
  3594. static Down(): Vector3;
  3595. /**
  3596. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  3597. * @param rightHandedSystem is the scene right-handed (negative z)
  3598. * @returns a new forward Vector3
  3599. */
  3600. static Forward(rightHandedSystem?: boolean): Vector3;
  3601. /**
  3602. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  3603. * @param rightHandedSystem is the scene right-handed (negative-z)
  3604. * @returns a new forward Vector3
  3605. */
  3606. static Backward(rightHandedSystem?: boolean): Vector3;
  3607. /**
  3608. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  3609. * @returns a new right Vector3
  3610. */
  3611. static Right(): Vector3;
  3612. /**
  3613. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  3614. * @returns a new left Vector3
  3615. */
  3616. static Left(): Vector3;
  3617. /**
  3618. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  3619. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  3620. * @param vector defines the Vector3 to transform
  3621. * @param transformation defines the transformation matrix
  3622. * @returns the transformed Vector3
  3623. */
  3624. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  3625. /**
  3626. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  3627. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  3628. * @param vector defines the Vector3 to transform
  3629. * @param transformation defines the transformation matrix
  3630. * @param result defines the Vector3 where to store the result
  3631. */
  3632. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3633. /**
  3634. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  3635. * This method computes tranformed coordinates only, not transformed direction vectors
  3636. * @param x define the x coordinate of the source vector
  3637. * @param y define the y coordinate of the source vector
  3638. * @param z define the z coordinate of the source vector
  3639. * @param transformation defines the transformation matrix
  3640. * @param result defines the Vector3 where to store the result
  3641. */
  3642. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3643. /**
  3644. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  3645. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3646. * @param vector defines the Vector3 to transform
  3647. * @param transformation defines the transformation matrix
  3648. * @returns the new Vector3
  3649. */
  3650. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  3651. /**
  3652. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  3653. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3654. * @param vector defines the Vector3 to transform
  3655. * @param transformation defines the transformation matrix
  3656. * @param result defines the Vector3 where to store the result
  3657. */
  3658. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3659. /**
  3660. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  3661. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3662. * @param x define the x coordinate of the source vector
  3663. * @param y define the y coordinate of the source vector
  3664. * @param z define the z coordinate of the source vector
  3665. * @param transformation defines the transformation matrix
  3666. * @param result defines the Vector3 where to store the result
  3667. */
  3668. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3669. /**
  3670. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  3671. * @param value1 defines the first control point
  3672. * @param value2 defines the second control point
  3673. * @param value3 defines the third control point
  3674. * @param value4 defines the fourth control point
  3675. * @param amount defines the amount on the spline to use
  3676. * @returns the new Vector3
  3677. */
  3678. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  3679. /**
  3680. * 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"
  3681. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3682. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3683. * @param value defines the current value
  3684. * @param min defines the lower range value
  3685. * @param max defines the upper range value
  3686. * @returns the new Vector3
  3687. */
  3688. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  3689. /**
  3690. * 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"
  3691. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3692. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3693. * @param value defines the current value
  3694. * @param min defines the lower range value
  3695. * @param max defines the upper range value
  3696. * @param result defines the Vector3 where to store the result
  3697. */
  3698. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  3699. /**
  3700. * Checks if a given vector is inside a specific range
  3701. * @param v defines the vector to test
  3702. * @param min defines the minimum range
  3703. * @param max defines the maximum range
  3704. */
  3705. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  3706. /**
  3707. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  3708. * @param value1 defines the first control point
  3709. * @param tangent1 defines the first tangent vector
  3710. * @param value2 defines the second control point
  3711. * @param tangent2 defines the second tangent vector
  3712. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  3713. * @returns the new Vector3
  3714. */
  3715. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  3716. /**
  3717. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  3718. * @param start defines the start value
  3719. * @param end defines the end value
  3720. * @param amount max defines amount between both (between 0 and 1)
  3721. * @returns the new Vector3
  3722. */
  3723. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  3724. /**
  3725. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  3726. * @param start defines the start value
  3727. * @param end defines the end value
  3728. * @param amount max defines amount between both (between 0 and 1)
  3729. * @param result defines the Vector3 where to store the result
  3730. */
  3731. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  3732. /**
  3733. * Returns the dot product (float) between the vectors "left" and "right"
  3734. * @param left defines the left operand
  3735. * @param right defines the right operand
  3736. * @returns the dot product
  3737. */
  3738. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  3739. /**
  3740. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  3741. * The cross product is then orthogonal to both "left" and "right"
  3742. * @param left defines the left operand
  3743. * @param right defines the right operand
  3744. * @returns the cross product
  3745. */
  3746. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3747. /**
  3748. * Sets the given vector "result" with the cross product of "left" and "right"
  3749. * The cross product is then orthogonal to both "left" and "right"
  3750. * @param left defines the left operand
  3751. * @param right defines the right operand
  3752. * @param result defines the Vector3 where to store the result
  3753. */
  3754. static CrossToRef(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>, result: Vector3): void;
  3755. /**
  3756. * Returns a new Vector3 as the normalization of the given vector
  3757. * @param vector defines the Vector3 to normalize
  3758. * @returns the new Vector3
  3759. */
  3760. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  3761. /**
  3762. * Sets the given vector "result" with the normalization of the given first vector
  3763. * @param vector defines the Vector3 to normalize
  3764. * @param result defines the Vector3 where to store the result
  3765. */
  3766. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  3767. /**
  3768. * Project a Vector3 onto screen space
  3769. * @param vector defines the Vector3 to project
  3770. * @param world defines the world matrix to use
  3771. * @param transform defines the transform (view x projection) matrix to use
  3772. * @param viewport defines the screen viewport to use
  3773. * @returns the new Vector3
  3774. */
  3775. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  3776. /**
  3777. * Project a Vector3 onto screen space to reference
  3778. * @param vector defines the Vector3 to project
  3779. * @param world defines the world matrix to use
  3780. * @param transform defines the transform (view x projection) matrix to use
  3781. * @param viewport defines the screen viewport to use
  3782. * @param result the vector in which the screen space will be stored
  3783. * @returns the new Vector3
  3784. */
  3785. static ProjectToRef(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>, result: DeepImmutable<Vector3>): Vector3;
  3786. /** @hidden */
  3787. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  3788. /**
  3789. * Unproject from screen space to object space
  3790. * @param source defines the screen space Vector3 to use
  3791. * @param viewportWidth defines the current width of the viewport
  3792. * @param viewportHeight defines the current height of the viewport
  3793. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3794. * @param transform defines the transform (view x projection) matrix to use
  3795. * @returns the new Vector3
  3796. */
  3797. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  3798. /**
  3799. * Unproject from screen space to object space
  3800. * @param source defines the screen space Vector3 to use
  3801. * @param viewportWidth defines the current width of the viewport
  3802. * @param viewportHeight defines the current height of the viewport
  3803. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3804. * @param view defines the view matrix to use
  3805. * @param projection defines the projection matrix to use
  3806. * @returns the new Vector3
  3807. */
  3808. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  3809. /**
  3810. * Unproject from screen space to object space
  3811. * @param source defines the screen space Vector3 to use
  3812. * @param viewportWidth defines the current width of the viewport
  3813. * @param viewportHeight defines the current height of the viewport
  3814. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3815. * @param view defines the view matrix to use
  3816. * @param projection defines the projection matrix to use
  3817. * @param result defines the Vector3 where to store the result
  3818. */
  3819. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3820. /**
  3821. * Unproject from screen space to object space
  3822. * @param sourceX defines the screen space x coordinate to use
  3823. * @param sourceY defines the screen space y coordinate to use
  3824. * @param sourceZ defines the screen space z coordinate to use
  3825. * @param viewportWidth defines the current width of the viewport
  3826. * @param viewportHeight defines the current height of the viewport
  3827. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3828. * @param view defines the view matrix to use
  3829. * @param projection defines the projection matrix to use
  3830. * @param result defines the Vector3 where to store the result
  3831. */
  3832. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3833. /**
  3834. * Gets the minimal coordinate values between two Vector3
  3835. * @param left defines the first operand
  3836. * @param right defines the second operand
  3837. * @returns the new Vector3
  3838. */
  3839. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3840. /**
  3841. * Gets the maximal coordinate values between two Vector3
  3842. * @param left defines the first operand
  3843. * @param right defines the second operand
  3844. * @returns the new Vector3
  3845. */
  3846. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3847. /**
  3848. * Returns the distance between the vectors "value1" and "value2"
  3849. * @param value1 defines the first operand
  3850. * @param value2 defines the second operand
  3851. * @returns the distance
  3852. */
  3853. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3854. /**
  3855. * Returns the squared distance between the vectors "value1" and "value2"
  3856. * @param value1 defines the first operand
  3857. * @param value2 defines the second operand
  3858. * @returns the squared distance
  3859. */
  3860. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3861. /**
  3862. * Returns a new Vector3 located at the center between "value1" and "value2"
  3863. * @param value1 defines the first operand
  3864. * @param value2 defines the second operand
  3865. * @returns the new Vector3
  3866. */
  3867. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3868. /**
  3869. * Gets the center of the vectors "value1" and "value2" and stores the result in the vector "ref"
  3870. * @param value1 defines first vector
  3871. * @param value2 defines second vector
  3872. * @param ref defines third vector
  3873. * @returns ref
  3874. */
  3875. static CenterToRef(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, ref: DeepImmutable<Vector3>): Vector3;
  3876. /**
  3877. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3878. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3879. * to something in order to rotate it from its local system to the given target system
  3880. * Note: axis1, axis2 and axis3 are normalized during this operation
  3881. * @param axis1 defines the first axis
  3882. * @param axis2 defines the second axis
  3883. * @param axis3 defines the third axis
  3884. * @returns a new Vector3
  3885. */
  3886. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3887. /**
  3888. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3889. * @param axis1 defines the first axis
  3890. * @param axis2 defines the second axis
  3891. * @param axis3 defines the third axis
  3892. * @param ref defines the Vector3 where to store the result
  3893. */
  3894. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3895. }
  3896. /**
  3897. * Vector4 class created for EulerAngle class conversion to Quaternion
  3898. */
  3899. export class Vector4 {
  3900. /** x value of the vector */
  3901. x: number;
  3902. /** y value of the vector */
  3903. y: number;
  3904. /** z value of the vector */
  3905. z: number;
  3906. /** w value of the vector */
  3907. w: number;
  3908. /**
  3909. * Creates a Vector4 object from the given floats.
  3910. * @param x x value of the vector
  3911. * @param y y value of the vector
  3912. * @param z z value of the vector
  3913. * @param w w value of the vector
  3914. */
  3915. constructor(
  3916. /** x value of the vector */
  3917. x: number,
  3918. /** y value of the vector */
  3919. y: number,
  3920. /** z value of the vector */
  3921. z: number,
  3922. /** w value of the vector */
  3923. w: number);
  3924. /**
  3925. * Returns the string with the Vector4 coordinates.
  3926. * @returns a string containing all the vector values
  3927. */
  3928. toString(): string;
  3929. /**
  3930. * Returns the string "Vector4".
  3931. * @returns "Vector4"
  3932. */
  3933. getClassName(): string;
  3934. /**
  3935. * Returns the Vector4 hash code.
  3936. * @returns a unique hash code
  3937. */
  3938. getHashCode(): number;
  3939. /**
  3940. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3941. * @returns the resulting array
  3942. */
  3943. asArray(): number[];
  3944. /**
  3945. * Populates the given array from the given index with the Vector4 coordinates.
  3946. * @param array array to populate
  3947. * @param index index of the array to start at (default: 0)
  3948. * @returns the Vector4.
  3949. */
  3950. toArray(array: FloatArray, index?: number): Vector4;
  3951. /**
  3952. * Update the current vector from an array
  3953. * @param array defines the destination array
  3954. * @param index defines the offset in the destination array
  3955. * @returns the current Vector3
  3956. */
  3957. fromArray(array: FloatArray, index?: number): Vector4;
  3958. /**
  3959. * Adds the given vector to the current Vector4.
  3960. * @param otherVector the vector to add
  3961. * @returns the updated Vector4.
  3962. */
  3963. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3964. /**
  3965. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3966. * @param otherVector the vector to add
  3967. * @returns the resulting vector
  3968. */
  3969. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3970. /**
  3971. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3972. * @param otherVector the vector to add
  3973. * @param result the vector to store the result
  3974. * @returns the current Vector4.
  3975. */
  3976. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3977. /**
  3978. * Subtract in place the given vector from the current Vector4.
  3979. * @param otherVector the vector to subtract
  3980. * @returns the updated Vector4.
  3981. */
  3982. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3983. /**
  3984. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3985. * @param otherVector the vector to add
  3986. * @returns the new vector with the result
  3987. */
  3988. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3989. /**
  3990. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3991. * @param otherVector the vector to subtract
  3992. * @param result the vector to store the result
  3993. * @returns the current Vector4.
  3994. */
  3995. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3996. /**
  3997. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3998. */
  3999. /**
  4000. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  4001. * @param x value to subtract
  4002. * @param y value to subtract
  4003. * @param z value to subtract
  4004. * @param w value to subtract
  4005. * @returns new vector containing the result
  4006. */
  4007. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  4008. /**
  4009. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  4010. * @param x value to subtract
  4011. * @param y value to subtract
  4012. * @param z value to subtract
  4013. * @param w value to subtract
  4014. * @param result the vector to store the result in
  4015. * @returns the current Vector4.
  4016. */
  4017. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  4018. /**
  4019. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  4020. * @returns a new vector with the negated values
  4021. */
  4022. negate(): Vector4;
  4023. /**
  4024. * Negate this vector in place
  4025. * @returns this
  4026. */
  4027. negateInPlace(): Vector4;
  4028. /**
  4029. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  4030. * @param result defines the Vector3 object where to store the result
  4031. * @returns the current Vector4
  4032. */
  4033. negateToRef(result: Vector4): Vector4;
  4034. /**
  4035. * Multiplies the current Vector4 coordinates by scale (float).
  4036. * @param scale the number to scale with
  4037. * @returns the updated Vector4.
  4038. */
  4039. scaleInPlace(scale: number): Vector4;
  4040. /**
  4041. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  4042. * @param scale the number to scale with
  4043. * @returns a new vector with the result
  4044. */
  4045. scale(scale: number): Vector4;
  4046. /**
  4047. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  4048. * @param scale the number to scale with
  4049. * @param result a vector to store the result in
  4050. * @returns the current Vector4.
  4051. */
  4052. scaleToRef(scale: number, result: Vector4): Vector4;
  4053. /**
  4054. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  4055. * @param scale defines the scale factor
  4056. * @param result defines the Vector4 object where to store the result
  4057. * @returns the unmodified current Vector4
  4058. */
  4059. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  4060. /**
  4061. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  4062. * @param otherVector the vector to compare against
  4063. * @returns true if they are equal
  4064. */
  4065. equals(otherVector: DeepImmutable<Vector4>): boolean;
  4066. /**
  4067. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  4068. * @param otherVector vector to compare against
  4069. * @param epsilon (Default: very small number)
  4070. * @returns true if they are equal
  4071. */
  4072. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  4073. /**
  4074. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  4075. * @param x x value to compare against
  4076. * @param y y value to compare against
  4077. * @param z z value to compare against
  4078. * @param w w value to compare against
  4079. * @returns true if equal
  4080. */
  4081. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  4082. /**
  4083. * Multiplies in place the current Vector4 by the given one.
  4084. * @param otherVector vector to multiple with
  4085. * @returns the updated Vector4.
  4086. */
  4087. multiplyInPlace(otherVector: Vector4): Vector4;
  4088. /**
  4089. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  4090. * @param otherVector vector to multiple with
  4091. * @returns resulting new vector
  4092. */
  4093. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  4094. /**
  4095. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  4096. * @param otherVector vector to multiple with
  4097. * @param result vector to store the result
  4098. * @returns the current Vector4.
  4099. */
  4100. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  4101. /**
  4102. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  4103. * @param x x value multiply with
  4104. * @param y y value multiply with
  4105. * @param z z value multiply with
  4106. * @param w w value multiply with
  4107. * @returns resulting new vector
  4108. */
  4109. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  4110. /**
  4111. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  4112. * @param otherVector vector to devide with
  4113. * @returns resulting new vector
  4114. */
  4115. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  4116. /**
  4117. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  4118. * @param otherVector vector to devide with
  4119. * @param result vector to store the result
  4120. * @returns the current Vector4.
  4121. */
  4122. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  4123. /**
  4124. * Divides the current Vector3 coordinates by the given ones.
  4125. * @param otherVector vector to devide with
  4126. * @returns the updated Vector3.
  4127. */
  4128. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  4129. /**
  4130. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  4131. * @param other defines the second operand
  4132. * @returns the current updated Vector4
  4133. */
  4134. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  4135. /**
  4136. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  4137. * @param other defines the second operand
  4138. * @returns the current updated Vector4
  4139. */
  4140. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  4141. /**
  4142. * Gets a new Vector4 from current Vector4 floored values
  4143. * @returns a new Vector4
  4144. */
  4145. floor(): Vector4;
  4146. /**
  4147. * Gets a new Vector4 from current Vector3 floored values
  4148. * @returns a new Vector4
  4149. */
  4150. fract(): Vector4;
  4151. /**
  4152. * Returns the Vector4 length (float).
  4153. * @returns the length
  4154. */
  4155. length(): number;
  4156. /**
  4157. * Returns the Vector4 squared length (float).
  4158. * @returns the length squared
  4159. */
  4160. lengthSquared(): number;
  4161. /**
  4162. * Normalizes in place the Vector4.
  4163. * @returns the updated Vector4.
  4164. */
  4165. normalize(): Vector4;
  4166. /**
  4167. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  4168. * @returns this converted to a new vector3
  4169. */
  4170. toVector3(): Vector3;
  4171. /**
  4172. * Returns a new Vector4 copied from the current one.
  4173. * @returns the new cloned vector
  4174. */
  4175. clone(): Vector4;
  4176. /**
  4177. * Updates the current Vector4 with the given one coordinates.
  4178. * @param source the source vector to copy from
  4179. * @returns the updated Vector4.
  4180. */
  4181. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  4182. /**
  4183. * Updates the current Vector4 coordinates with the given floats.
  4184. * @param x float to copy from
  4185. * @param y float to copy from
  4186. * @param z float to copy from
  4187. * @param w float to copy from
  4188. * @returns the updated Vector4.
  4189. */
  4190. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  4191. /**
  4192. * Updates the current Vector4 coordinates with the given floats.
  4193. * @param x float to set from
  4194. * @param y float to set from
  4195. * @param z float to set from
  4196. * @param w float to set from
  4197. * @returns the updated Vector4.
  4198. */
  4199. set(x: number, y: number, z: number, w: number): Vector4;
  4200. /**
  4201. * Copies the given float to the current Vector3 coordinates
  4202. * @param v defines the x, y, z and w coordinates of the operand
  4203. * @returns the current updated Vector3
  4204. */
  4205. setAll(v: number): Vector4;
  4206. /**
  4207. * Returns a new Vector4 set from the starting index of the given array.
  4208. * @param array the array to pull values from
  4209. * @param offset the offset into the array to start at
  4210. * @returns the new vector
  4211. */
  4212. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  4213. /**
  4214. * Updates the given vector "result" from the starting index of the given array.
  4215. * @param array the array to pull values from
  4216. * @param offset the offset into the array to start at
  4217. * @param result the vector to store the result in
  4218. */
  4219. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  4220. /**
  4221. * Updates the given vector "result" from the starting index of the given Float32Array.
  4222. * @param array the array to pull values from
  4223. * @param offset the offset into the array to start at
  4224. * @param result the vector to store the result in
  4225. */
  4226. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  4227. /**
  4228. * Updates the given vector "result" coordinates from the given floats.
  4229. * @param x float to set from
  4230. * @param y float to set from
  4231. * @param z float to set from
  4232. * @param w float to set from
  4233. * @param result the vector to the floats in
  4234. */
  4235. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  4236. /**
  4237. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  4238. * @returns the new vector
  4239. */
  4240. static Zero(): Vector4;
  4241. /**
  4242. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  4243. * @returns the new vector
  4244. */
  4245. static One(): Vector4;
  4246. /**
  4247. * Returns a new normalized Vector4 from the given one.
  4248. * @param vector the vector to normalize
  4249. * @returns the vector
  4250. */
  4251. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  4252. /**
  4253. * Updates the given vector "result" from the normalization of the given one.
  4254. * @param vector the vector to normalize
  4255. * @param result the vector to store the result in
  4256. */
  4257. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  4258. /**
  4259. * Returns a vector with the minimum values from the left and right vectors
  4260. * @param left left vector to minimize
  4261. * @param right right vector to minimize
  4262. * @returns a new vector with the minimum of the left and right vector values
  4263. */
  4264. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  4265. /**
  4266. * Returns a vector with the maximum values from the left and right vectors
  4267. * @param left left vector to maximize
  4268. * @param right right vector to maximize
  4269. * @returns a new vector with the maximum of the left and right vector values
  4270. */
  4271. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  4272. /**
  4273. * Returns the distance (float) between the vectors "value1" and "value2".
  4274. * @param value1 value to calulate the distance between
  4275. * @param value2 value to calulate the distance between
  4276. * @return the distance between the two vectors
  4277. */
  4278. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  4279. /**
  4280. * Returns the squared distance (float) between the vectors "value1" and "value2".
  4281. * @param value1 value to calulate the distance between
  4282. * @param value2 value to calulate the distance between
  4283. * @return the distance between the two vectors squared
  4284. */
  4285. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  4286. /**
  4287. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  4288. * @param value1 value to calulate the center between
  4289. * @param value2 value to calulate the center between
  4290. * @return the center between the two vectors
  4291. */
  4292. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  4293. /**
  4294. * Gets the center of the vectors "value1" and "value2" and stores the result in the vector "ref"
  4295. * @param value1 defines first vector
  4296. * @param value2 defines second vector
  4297. * @param ref defines third vector
  4298. * @returns ref
  4299. */
  4300. static CenterToRef(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>, ref: DeepImmutable<Vector4>): Vector4;
  4301. /**
  4302. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  4303. * This methods computes transformed normalized direction vectors only.
  4304. * @param vector the vector to transform
  4305. * @param transformation the transformation matrix to apply
  4306. * @returns the new vector
  4307. */
  4308. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  4309. /**
  4310. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  4311. * This methods computes transformed normalized direction vectors only.
  4312. * @param vector the vector to transform
  4313. * @param transformation the transformation matrix to apply
  4314. * @param result the vector to store the result in
  4315. */
  4316. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  4317. /**
  4318. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  4319. * This methods computes transformed normalized direction vectors only.
  4320. * @param x value to transform
  4321. * @param y value to transform
  4322. * @param z value to transform
  4323. * @param w value to transform
  4324. * @param transformation the transformation matrix to apply
  4325. * @param result the vector to store the results in
  4326. */
  4327. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  4328. /**
  4329. * Creates a new Vector4 from a Vector3
  4330. * @param source defines the source data
  4331. * @param w defines the 4th component (default is 0)
  4332. * @returns a new Vector4
  4333. */
  4334. static FromVector3(source: Vector3, w?: number): Vector4;
  4335. }
  4336. /**
  4337. * Class used to store quaternion data
  4338. * @see https://en.wikipedia.org/wiki/Quaternion
  4339. * @see https://doc.babylonjs.com/features/position,_rotation,_scaling
  4340. */
  4341. export class Quaternion {
  4342. /** @hidden */
  4343. _x: number;
  4344. /** @hidden */
  4345. _y: number;
  4346. /** @hidden */
  4347. _z: number;
  4348. /** @hidden */
  4349. _w: number;
  4350. /** @hidden */
  4351. _isDirty: boolean;
  4352. /** Gets or sets the x coordinate */
  4353. get x(): number;
  4354. set x(value: number);
  4355. /** Gets or sets the y coordinate */
  4356. get y(): number;
  4357. set y(value: number);
  4358. /** Gets or sets the z coordinate */
  4359. get z(): number;
  4360. set z(value: number);
  4361. /** Gets or sets the w coordinate */
  4362. get w(): number;
  4363. set w(value: number);
  4364. /**
  4365. * Creates a new Quaternion from the given floats
  4366. * @param x defines the first component (0 by default)
  4367. * @param y defines the second component (0 by default)
  4368. * @param z defines the third component (0 by default)
  4369. * @param w defines the fourth component (1.0 by default)
  4370. */
  4371. constructor(x?: number, y?: number, z?: number, w?: number);
  4372. /**
  4373. * Gets a string representation for the current quaternion
  4374. * @returns a string with the Quaternion coordinates
  4375. */
  4376. toString(): string;
  4377. /**
  4378. * Gets the class name of the quaternion
  4379. * @returns the string "Quaternion"
  4380. */
  4381. getClassName(): string;
  4382. /**
  4383. * Gets a hash code for this quaternion
  4384. * @returns the quaternion hash code
  4385. */
  4386. getHashCode(): number;
  4387. /**
  4388. * Copy the quaternion to an array
  4389. * @returns a new array populated with 4 elements from the quaternion coordinates
  4390. */
  4391. asArray(): number[];
  4392. /**
  4393. * Check if two quaternions are equals
  4394. * @param otherQuaternion defines the second operand
  4395. * @return true if the current quaternion and the given one coordinates are strictly equals
  4396. */
  4397. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  4398. /**
  4399. * Gets a boolean if two quaternions are equals (using an epsilon value)
  4400. * @param otherQuaternion defines the other quaternion
  4401. * @param epsilon defines the minimal distance to consider equality
  4402. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  4403. */
  4404. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  4405. /**
  4406. * Clone the current quaternion
  4407. * @returns a new quaternion copied from the current one
  4408. */
  4409. clone(): Quaternion;
  4410. /**
  4411. * Copy a quaternion to the current one
  4412. * @param other defines the other quaternion
  4413. * @returns the updated current quaternion
  4414. */
  4415. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  4416. /**
  4417. * Updates the current quaternion with the given float coordinates
  4418. * @param x defines the x coordinate
  4419. * @param y defines the y coordinate
  4420. * @param z defines the z coordinate
  4421. * @param w defines the w coordinate
  4422. * @returns the updated current quaternion
  4423. */
  4424. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  4425. /**
  4426. * Updates the current quaternion from the given float coordinates
  4427. * @param x defines the x coordinate
  4428. * @param y defines the y coordinate
  4429. * @param z defines the z coordinate
  4430. * @param w defines the w coordinate
  4431. * @returns the updated current quaternion
  4432. */
  4433. set(x: number, y: number, z: number, w: number): Quaternion;
  4434. /**
  4435. * Adds two quaternions
  4436. * @param other defines the second operand
  4437. * @returns a new quaternion as the addition result of the given one and the current quaternion
  4438. */
  4439. add(other: DeepImmutable<Quaternion>): Quaternion;
  4440. /**
  4441. * Add a quaternion to the current one
  4442. * @param other defines the quaternion to add
  4443. * @returns the current quaternion
  4444. */
  4445. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  4446. /**
  4447. * Subtract two quaternions
  4448. * @param other defines the second operand
  4449. * @returns a new quaternion as the subtraction result of the given one from the current one
  4450. */
  4451. subtract(other: Quaternion): Quaternion;
  4452. /**
  4453. * Multiplies the current quaternion by a scale factor
  4454. * @param value defines the scale factor
  4455. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  4456. */
  4457. scale(value: number): Quaternion;
  4458. /**
  4459. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  4460. * @param scale defines the scale factor
  4461. * @param result defines the Quaternion object where to store the result
  4462. * @returns the unmodified current quaternion
  4463. */
  4464. scaleToRef(scale: number, result: Quaternion): Quaternion;
  4465. /**
  4466. * Multiplies in place the current quaternion by a scale factor
  4467. * @param value defines the scale factor
  4468. * @returns the current modified quaternion
  4469. */
  4470. scaleInPlace(value: number): Quaternion;
  4471. /**
  4472. * Scale the current quaternion values by a factor and add the result to a given quaternion
  4473. * @param scale defines the scale factor
  4474. * @param result defines the Quaternion object where to store the result
  4475. * @returns the unmodified current quaternion
  4476. */
  4477. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  4478. /**
  4479. * Multiplies two quaternions
  4480. * @param q1 defines the second operand
  4481. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  4482. */
  4483. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  4484. /**
  4485. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  4486. * @param q1 defines the second operand
  4487. * @param result defines the target quaternion
  4488. * @returns the current quaternion
  4489. */
  4490. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  4491. /**
  4492. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  4493. * @param q1 defines the second operand
  4494. * @returns the currentupdated quaternion
  4495. */
  4496. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  4497. /**
  4498. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  4499. * @param ref defines the target quaternion
  4500. * @returns the current quaternion
  4501. */
  4502. conjugateToRef(ref: Quaternion): Quaternion;
  4503. /**
  4504. * Conjugates in place (1-q) the current quaternion
  4505. * @returns the current updated quaternion
  4506. */
  4507. conjugateInPlace(): Quaternion;
  4508. /**
  4509. * Conjugates in place (1-q) the current quaternion
  4510. * @returns a new quaternion
  4511. */
  4512. conjugate(): Quaternion;
  4513. /**
  4514. * Gets length of current quaternion
  4515. * @returns the quaternion length (float)
  4516. */
  4517. length(): number;
  4518. /**
  4519. * Normalize in place the current quaternion
  4520. * @returns the current updated quaternion
  4521. */
  4522. normalize(): Quaternion;
  4523. /**
  4524. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  4525. * @param order is a reserved parameter and is ignored for now
  4526. * @returns a new Vector3 containing the Euler angles
  4527. */
  4528. toEulerAngles(order?: string): Vector3;
  4529. /**
  4530. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  4531. * @param result defines the vector which will be filled with the Euler angles
  4532. * @returns the current unchanged quaternion
  4533. */
  4534. toEulerAnglesToRef(result: Vector3): Quaternion;
  4535. /**
  4536. * Updates the given rotation matrix with the current quaternion values
  4537. * @param result defines the target matrix
  4538. * @returns the current unchanged quaternion
  4539. */
  4540. toRotationMatrix(result: Matrix): Quaternion;
  4541. /**
  4542. * Updates the current quaternion from the given rotation matrix values
  4543. * @param matrix defines the source matrix
  4544. * @returns the current updated quaternion
  4545. */
  4546. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  4547. /**
  4548. * Creates a new quaternion from a rotation matrix
  4549. * @param matrix defines the source matrix
  4550. * @returns a new quaternion created from the given rotation matrix values
  4551. */
  4552. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  4553. /**
  4554. * Updates the given quaternion with the given rotation matrix values
  4555. * @param matrix defines the source matrix
  4556. * @param result defines the target quaternion
  4557. */
  4558. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  4559. /**
  4560. * Returns the dot product (float) between the quaternions "left" and "right"
  4561. * @param left defines the left operand
  4562. * @param right defines the right operand
  4563. * @returns the dot product
  4564. */
  4565. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  4566. /**
  4567. * Checks if the two quaternions are close to each other
  4568. * @param quat0 defines the first quaternion to check
  4569. * @param quat1 defines the second quaternion to check
  4570. * @returns true if the two quaternions are close to each other
  4571. */
  4572. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  4573. /**
  4574. * Creates an empty quaternion
  4575. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  4576. */
  4577. static Zero(): Quaternion;
  4578. /**
  4579. * Inverse a given quaternion
  4580. * @param q defines the source quaternion
  4581. * @returns a new quaternion as the inverted current quaternion
  4582. */
  4583. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  4584. /**
  4585. * Inverse a given quaternion
  4586. * @param q defines the source quaternion
  4587. * @param result the quaternion the result will be stored in
  4588. * @returns the result quaternion
  4589. */
  4590. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  4591. /**
  4592. * Creates an identity quaternion
  4593. * @returns the identity quaternion
  4594. */
  4595. static Identity(): Quaternion;
  4596. /**
  4597. * Gets a boolean indicating if the given quaternion is identity
  4598. * @param quaternion defines the quaternion to check
  4599. * @returns true if the quaternion is identity
  4600. */
  4601. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  4602. /**
  4603. * Creates a quaternion from a rotation around an axis
  4604. * @param axis defines the axis to use
  4605. * @param angle defines the angle to use
  4606. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  4607. */
  4608. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  4609. /**
  4610. * Creates a rotation around an axis and stores it into the given quaternion
  4611. * @param axis defines the axis to use
  4612. * @param angle defines the angle to use
  4613. * @param result defines the target quaternion
  4614. * @returns the target quaternion
  4615. */
  4616. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  4617. /**
  4618. * Creates a new quaternion from data stored into an array
  4619. * @param array defines the data source
  4620. * @param offset defines the offset in the source array where the data starts
  4621. * @returns a new quaternion
  4622. */
  4623. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  4624. /**
  4625. * Updates the given quaternion "result" from the starting index of the given array.
  4626. * @param array the array to pull values from
  4627. * @param offset the offset into the array to start at
  4628. * @param result the quaternion to store the result in
  4629. */
  4630. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  4631. /**
  4632. * Create a quaternion from Euler rotation angles
  4633. * @param x Pitch
  4634. * @param y Yaw
  4635. * @param z Roll
  4636. * @returns the new Quaternion
  4637. */
  4638. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  4639. /**
  4640. * Updates a quaternion from Euler rotation angles
  4641. * @param x Pitch
  4642. * @param y Yaw
  4643. * @param z Roll
  4644. * @param result the quaternion to store the result
  4645. * @returns the updated quaternion
  4646. */
  4647. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  4648. /**
  4649. * Create a quaternion from Euler rotation vector
  4650. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  4651. * @returns the new Quaternion
  4652. */
  4653. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  4654. /**
  4655. * Updates a quaternion from Euler rotation vector
  4656. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  4657. * @param result the quaternion to store the result
  4658. * @returns the updated quaternion
  4659. */
  4660. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  4661. /**
  4662. * Updates a quaternion so that it rotates vector vecFrom to vector vecTo
  4663. * @param vecFrom defines the direction vector from which to rotate
  4664. * @param vecTo defines the direction vector to which to rotate
  4665. * @param result the quaternion to store the result
  4666. * @returns the updated quaternion
  4667. */
  4668. static FromUnitVectorsToRef(vecFrom: DeepImmutable<Vector3>, vecTo: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  4669. /**
  4670. * Creates a new quaternion from the given Euler float angles (y, x, z)
  4671. * @param yaw defines the rotation around Y axis
  4672. * @param pitch defines the rotation around X axis
  4673. * @param roll defines the rotation around Z axis
  4674. * @returns the new quaternion
  4675. */
  4676. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  4677. /**
  4678. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  4679. * @param yaw defines the rotation around Y axis
  4680. * @param pitch defines the rotation around X axis
  4681. * @param roll defines the rotation around Z axis
  4682. * @param result defines the target quaternion
  4683. */
  4684. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  4685. /**
  4686. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  4687. * @param alpha defines the rotation around first axis
  4688. * @param beta defines the rotation around second axis
  4689. * @param gamma defines the rotation around third axis
  4690. * @returns the new quaternion
  4691. */
  4692. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  4693. /**
  4694. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  4695. * @param alpha defines the rotation around first axis
  4696. * @param beta defines the rotation around second axis
  4697. * @param gamma defines the rotation around third axis
  4698. * @param result defines the target quaternion
  4699. */
  4700. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  4701. /**
  4702. * 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)
  4703. * @param axis1 defines the first axis
  4704. * @param axis2 defines the second axis
  4705. * @param axis3 defines the third axis
  4706. * @returns the new quaternion
  4707. */
  4708. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  4709. /**
  4710. * 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
  4711. * @param axis1 defines the first axis
  4712. * @param axis2 defines the second axis
  4713. * @param axis3 defines the third axis
  4714. * @param ref defines the target quaternion
  4715. */
  4716. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  4717. /**
  4718. * Interpolates between two quaternions
  4719. * @param left defines first quaternion
  4720. * @param right defines second quaternion
  4721. * @param amount defines the gradient to use
  4722. * @returns the new interpolated quaternion
  4723. */
  4724. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4725. /**
  4726. * Interpolates between two quaternions and stores it into a target quaternion
  4727. * @param left defines first quaternion
  4728. * @param right defines second quaternion
  4729. * @param amount defines the gradient to use
  4730. * @param result defines the target quaternion
  4731. */
  4732. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  4733. /**
  4734. * Interpolate between two quaternions using Hermite interpolation
  4735. * @param value1 defines first quaternion
  4736. * @param tangent1 defines the incoming tangent
  4737. * @param value2 defines second quaternion
  4738. * @param tangent2 defines the outgoing tangent
  4739. * @param amount defines the target quaternion
  4740. * @returns the new interpolated quaternion
  4741. */
  4742. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4743. }
  4744. /**
  4745. * Class used to store matrix data (4x4)
  4746. */
  4747. export class Matrix {
  4748. /**
  4749. * Gets the precision of matrix computations
  4750. */
  4751. static get Use64Bits(): boolean;
  4752. private static _updateFlagSeed;
  4753. private static _identityReadOnly;
  4754. private _isIdentity;
  4755. private _isIdentityDirty;
  4756. private _isIdentity3x2;
  4757. private _isIdentity3x2Dirty;
  4758. /**
  4759. * Gets the update flag of the matrix which is an unique number for the matrix.
  4760. * It will be incremented every time the matrix data change.
  4761. * You can use it to speed the comparison between two versions of the same matrix.
  4762. */
  4763. updateFlag: number;
  4764. private readonly _m;
  4765. /**
  4766. * Gets the internal data of the matrix
  4767. */
  4768. get m(): DeepImmutable<Float32Array | Array<number>>;
  4769. /** @hidden */
  4770. _markAsUpdated(): void;
  4771. /** @hidden */
  4772. private _updateIdentityStatus;
  4773. /**
  4774. * Creates an empty matrix (filled with zeros)
  4775. */
  4776. constructor();
  4777. /**
  4778. * Check if the current matrix is identity
  4779. * @returns true is the matrix is the identity matrix
  4780. */
  4781. isIdentity(): boolean;
  4782. /**
  4783. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  4784. * @returns true is the matrix is the identity matrix
  4785. */
  4786. isIdentityAs3x2(): boolean;
  4787. /**
  4788. * Gets the determinant of the matrix
  4789. * @returns the matrix determinant
  4790. */
  4791. determinant(): number;
  4792. /**
  4793. * Returns the matrix as a Float32Array or Array<number>
  4794. * @returns the matrix underlying array
  4795. */
  4796. toArray(): DeepImmutable<Float32Array | Array<number>>;
  4797. /**
  4798. * Returns the matrix as a Float32Array or Array<number>
  4799. * @returns the matrix underlying array.
  4800. */
  4801. asArray(): DeepImmutable<Float32Array | Array<number>>;
  4802. /**
  4803. * Inverts the current matrix in place
  4804. * @returns the current inverted matrix
  4805. */
  4806. invert(): Matrix;
  4807. /**
  4808. * Sets all the matrix elements to zero
  4809. * @returns the current matrix
  4810. */
  4811. reset(): Matrix;
  4812. /**
  4813. * Adds the current matrix with a second one
  4814. * @param other defines the matrix to add
  4815. * @returns a new matrix as the addition of the current matrix and the given one
  4816. */
  4817. add(other: DeepImmutable<Matrix>): Matrix;
  4818. /**
  4819. * Sets the given matrix "result" to the addition of the current matrix and the given one
  4820. * @param other defines the matrix to add
  4821. * @param result defines the target matrix
  4822. * @returns the current matrix
  4823. */
  4824. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4825. /**
  4826. * Adds in place the given matrix to the current matrix
  4827. * @param other defines the second operand
  4828. * @returns the current updated matrix
  4829. */
  4830. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  4831. /**
  4832. * Sets the given matrix to the current inverted Matrix
  4833. * @param other defines the target matrix
  4834. * @returns the unmodified current matrix
  4835. */
  4836. invertToRef(other: Matrix): Matrix;
  4837. /**
  4838. * add a value at the specified position in the current Matrix
  4839. * @param index the index of the value within the matrix. between 0 and 15.
  4840. * @param value the value to be added
  4841. * @returns the current updated matrix
  4842. */
  4843. addAtIndex(index: number, value: number): Matrix;
  4844. /**
  4845. * mutiply the specified position in the current Matrix by a value
  4846. * @param index the index of the value within the matrix. between 0 and 15.
  4847. * @param value the value to be added
  4848. * @returns the current updated matrix
  4849. */
  4850. multiplyAtIndex(index: number, value: number): Matrix;
  4851. /**
  4852. * Inserts the translation vector (using 3 floats) in the current matrix
  4853. * @param x defines the 1st component of the translation
  4854. * @param y defines the 2nd component of the translation
  4855. * @param z defines the 3rd component of the translation
  4856. * @returns the current updated matrix
  4857. */
  4858. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4859. /**
  4860. * Adds the translation vector (using 3 floats) in the current matrix
  4861. * @param x defines the 1st component of the translation
  4862. * @param y defines the 2nd component of the translation
  4863. * @param z defines the 3rd component of the translation
  4864. * @returns the current updated matrix
  4865. */
  4866. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4867. /**
  4868. * Inserts the translation vector in the current matrix
  4869. * @param vector3 defines the translation to insert
  4870. * @returns the current updated matrix
  4871. */
  4872. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  4873. /**
  4874. * Gets the translation value of the current matrix
  4875. * @returns a new Vector3 as the extracted translation from the matrix
  4876. */
  4877. getTranslation(): Vector3;
  4878. /**
  4879. * Fill a Vector3 with the extracted translation from the matrix
  4880. * @param result defines the Vector3 where to store the translation
  4881. * @returns the current matrix
  4882. */
  4883. getTranslationToRef(result: Vector3): Matrix;
  4884. /**
  4885. * Remove rotation and scaling part from the matrix
  4886. * @returns the updated matrix
  4887. */
  4888. removeRotationAndScaling(): Matrix;
  4889. /**
  4890. * Multiply two matrices
  4891. * @param other defines the second operand
  4892. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  4893. */
  4894. multiply(other: DeepImmutable<Matrix>): Matrix;
  4895. /**
  4896. * Copy the current matrix from the given one
  4897. * @param other defines the source matrix
  4898. * @returns the current updated matrix
  4899. */
  4900. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  4901. /**
  4902. * Populates the given array from the starting index with the current matrix values
  4903. * @param array defines the target array
  4904. * @param offset defines the offset in the target array where to start storing values
  4905. * @returns the current matrix
  4906. */
  4907. copyToArray(array: Float32Array | Array<number>, offset?: number): Matrix;
  4908. /**
  4909. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  4910. * @param other defines the second operand
  4911. * @param result defines the matrix where to store the multiplication
  4912. * @returns the current matrix
  4913. */
  4914. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4915. /**
  4916. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4917. * @param other defines the second operand
  4918. * @param result defines the array where to store the multiplication
  4919. * @param offset defines the offset in the target array where to start storing values
  4920. * @returns the current matrix
  4921. */
  4922. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array | Array<number>, offset: number): Matrix;
  4923. /**
  4924. * Check equality between this matrix and a second one
  4925. * @param value defines the second matrix to compare
  4926. * @returns true is the current matrix and the given one values are strictly equal
  4927. */
  4928. equals(value: DeepImmutable<Matrix>): boolean;
  4929. /**
  4930. * Clone the current matrix
  4931. * @returns a new matrix from the current matrix
  4932. */
  4933. clone(): Matrix;
  4934. /**
  4935. * Returns the name of the current matrix class
  4936. * @returns the string "Matrix"
  4937. */
  4938. getClassName(): string;
  4939. /**
  4940. * Gets the hash code of the current matrix
  4941. * @returns the hash code
  4942. */
  4943. getHashCode(): number;
  4944. /**
  4945. * Decomposes the current Matrix into a translation, rotation and scaling components
  4946. * @param scale defines the scale vector3 given as a reference to update
  4947. * @param rotation defines the rotation quaternion given as a reference to update
  4948. * @param translation defines the translation vector3 given as a reference to update
  4949. * @returns true if operation was successful
  4950. */
  4951. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4952. /**
  4953. * Gets specific row of the matrix
  4954. * @param index defines the number of the row to get
  4955. * @returns the index-th row of the current matrix as a new Vector4
  4956. */
  4957. getRow(index: number): Nullable<Vector4>;
  4958. /**
  4959. * Sets the index-th row of the current matrix to the vector4 values
  4960. * @param index defines the number of the row to set
  4961. * @param row defines the target vector4
  4962. * @returns the updated current matrix
  4963. */
  4964. setRow(index: number, row: Vector4): Matrix;
  4965. /**
  4966. * Compute the transpose of the matrix
  4967. * @returns the new transposed matrix
  4968. */
  4969. transpose(): Matrix;
  4970. /**
  4971. * Compute the transpose of the matrix and store it in a given matrix
  4972. * @param result defines the target matrix
  4973. * @returns the current matrix
  4974. */
  4975. transposeToRef(result: Matrix): Matrix;
  4976. /**
  4977. * Sets the index-th row of the current matrix with the given 4 x float values
  4978. * @param index defines the row index
  4979. * @param x defines the x component to set
  4980. * @param y defines the y component to set
  4981. * @param z defines the z component to set
  4982. * @param w defines the w component to set
  4983. * @returns the updated current matrix
  4984. */
  4985. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4986. /**
  4987. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4988. * @param scale defines the scale factor
  4989. * @returns a new matrix
  4990. */
  4991. scale(scale: number): Matrix;
  4992. /**
  4993. * Scale the current matrix values by a factor to a given result matrix
  4994. * @param scale defines the scale factor
  4995. * @param result defines the matrix to store the result
  4996. * @returns the current matrix
  4997. */
  4998. scaleToRef(scale: number, result: Matrix): Matrix;
  4999. /**
  5000. * Scale the current matrix values by a factor and add the result to a given matrix
  5001. * @param scale defines the scale factor
  5002. * @param result defines the Matrix to store the result
  5003. * @returns the current matrix
  5004. */
  5005. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  5006. /**
  5007. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  5008. * @param ref matrix to store the result
  5009. */
  5010. toNormalMatrix(ref: Matrix): void;
  5011. /**
  5012. * Gets only rotation part of the current matrix
  5013. * @returns a new matrix sets to the extracted rotation matrix from the current one
  5014. */
  5015. getRotationMatrix(): Matrix;
  5016. /**
  5017. * Extracts the rotation matrix from the current one and sets it as the given "result"
  5018. * @param result defines the target matrix to store data to
  5019. * @returns the current matrix
  5020. */
  5021. getRotationMatrixToRef(result: Matrix): Matrix;
  5022. /**
  5023. * Toggles model matrix from being right handed to left handed in place and vice versa
  5024. */
  5025. toggleModelMatrixHandInPlace(): void;
  5026. /**
  5027. * Toggles projection matrix from being right handed to left handed in place and vice versa
  5028. */
  5029. toggleProjectionMatrixHandInPlace(): void;
  5030. /**
  5031. * Creates a matrix from an array
  5032. * @param array defines the source array
  5033. * @param offset defines an offset in the source array
  5034. * @returns a new Matrix set from the starting index of the given array
  5035. */
  5036. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  5037. /**
  5038. * Copy the content of an array into a given matrix
  5039. * @param array defines the source array
  5040. * @param offset defines an offset in the source array
  5041. * @param result defines the target matrix
  5042. */
  5043. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  5044. /**
  5045. * Stores an array into a matrix after having multiplied each component by a given factor
  5046. * @param array defines the source array
  5047. * @param offset defines the offset in the source array
  5048. * @param scale defines the scaling factor
  5049. * @param result defines the target matrix
  5050. */
  5051. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array | Array<number>>, offset: number, scale: number, result: Matrix): void;
  5052. /**
  5053. * Gets an identity matrix that must not be updated
  5054. */
  5055. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  5056. /**
  5057. * Stores a list of values (16) inside a given matrix
  5058. * @param initialM11 defines 1st value of 1st row
  5059. * @param initialM12 defines 2nd value of 1st row
  5060. * @param initialM13 defines 3rd value of 1st row
  5061. * @param initialM14 defines 4th value of 1st row
  5062. * @param initialM21 defines 1st value of 2nd row
  5063. * @param initialM22 defines 2nd value of 2nd row
  5064. * @param initialM23 defines 3rd value of 2nd row
  5065. * @param initialM24 defines 4th value of 2nd row
  5066. * @param initialM31 defines 1st value of 3rd row
  5067. * @param initialM32 defines 2nd value of 3rd row
  5068. * @param initialM33 defines 3rd value of 3rd row
  5069. * @param initialM34 defines 4th value of 3rd row
  5070. * @param initialM41 defines 1st value of 4th row
  5071. * @param initialM42 defines 2nd value of 4th row
  5072. * @param initialM43 defines 3rd value of 4th row
  5073. * @param initialM44 defines 4th value of 4th row
  5074. * @param result defines the target matrix
  5075. */
  5076. 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;
  5077. /**
  5078. * Creates new matrix from a list of values (16)
  5079. * @param initialM11 defines 1st value of 1st row
  5080. * @param initialM12 defines 2nd value of 1st row
  5081. * @param initialM13 defines 3rd value of 1st row
  5082. * @param initialM14 defines 4th value of 1st row
  5083. * @param initialM21 defines 1st value of 2nd row
  5084. * @param initialM22 defines 2nd value of 2nd row
  5085. * @param initialM23 defines 3rd value of 2nd row
  5086. * @param initialM24 defines 4th value of 2nd row
  5087. * @param initialM31 defines 1st value of 3rd row
  5088. * @param initialM32 defines 2nd value of 3rd row
  5089. * @param initialM33 defines 3rd value of 3rd row
  5090. * @param initialM34 defines 4th value of 3rd row
  5091. * @param initialM41 defines 1st value of 4th row
  5092. * @param initialM42 defines 2nd value of 4th row
  5093. * @param initialM43 defines 3rd value of 4th row
  5094. * @param initialM44 defines 4th value of 4th row
  5095. * @returns the new matrix
  5096. */
  5097. 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;
  5098. /**
  5099. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  5100. * @param scale defines the scale vector3
  5101. * @param rotation defines the rotation quaternion
  5102. * @param translation defines the translation vector3
  5103. * @returns a new matrix
  5104. */
  5105. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  5106. /**
  5107. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  5108. * @param scale defines the scale vector3
  5109. * @param rotation defines the rotation quaternion
  5110. * @param translation defines the translation vector3
  5111. * @param result defines the target matrix
  5112. */
  5113. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  5114. /**
  5115. * Creates a new identity matrix
  5116. * @returns a new identity matrix
  5117. */
  5118. static Identity(): Matrix;
  5119. /**
  5120. * Creates a new identity matrix and stores the result in a given matrix
  5121. * @param result defines the target matrix
  5122. */
  5123. static IdentityToRef(result: Matrix): void;
  5124. /**
  5125. * Creates a new zero matrix
  5126. * @returns a new zero matrix
  5127. */
  5128. static Zero(): Matrix;
  5129. /**
  5130. * Creates a new rotation matrix for "angle" radians around the X axis
  5131. * @param angle defines the angle (in radians) to use
  5132. * @return the new matrix
  5133. */
  5134. static RotationX(angle: number): Matrix;
  5135. /**
  5136. * Creates a new matrix as the invert of a given matrix
  5137. * @param source defines the source matrix
  5138. * @returns the new matrix
  5139. */
  5140. static Invert(source: DeepImmutable<Matrix>): Matrix;
  5141. /**
  5142. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  5143. * @param angle defines the angle (in radians) to use
  5144. * @param result defines the target matrix
  5145. */
  5146. static RotationXToRef(angle: number, result: Matrix): void;
  5147. /**
  5148. * Creates a new rotation matrix for "angle" radians around the Y axis
  5149. * @param angle defines the angle (in radians) to use
  5150. * @return the new matrix
  5151. */
  5152. static RotationY(angle: number): Matrix;
  5153. /**
  5154. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  5155. * @param angle defines the angle (in radians) to use
  5156. * @param result defines the target matrix
  5157. */
  5158. static RotationYToRef(angle: number, result: Matrix): void;
  5159. /**
  5160. * Creates a new rotation matrix for "angle" radians around the Z axis
  5161. * @param angle defines the angle (in radians) to use
  5162. * @return the new matrix
  5163. */
  5164. static RotationZ(angle: number): Matrix;
  5165. /**
  5166. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  5167. * @param angle defines the angle (in radians) to use
  5168. * @param result defines the target matrix
  5169. */
  5170. static RotationZToRef(angle: number, result: Matrix): void;
  5171. /**
  5172. * Creates a new rotation matrix for "angle" radians around the given axis
  5173. * @param axis defines the axis to use
  5174. * @param angle defines the angle (in radians) to use
  5175. * @return the new matrix
  5176. */
  5177. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  5178. /**
  5179. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  5180. * @param axis defines the axis to use
  5181. * @param angle defines the angle (in radians) to use
  5182. * @param result defines the target matrix
  5183. */
  5184. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  5185. /**
  5186. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  5187. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  5188. * @param from defines the vector to align
  5189. * @param to defines the vector to align to
  5190. * @param result defines the target matrix
  5191. */
  5192. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  5193. /**
  5194. * Creates a rotation matrix
  5195. * @param yaw defines the yaw angle in radians (Y axis)
  5196. * @param pitch defines the pitch angle in radians (X axis)
  5197. * @param roll defines the roll angle in radians (Z axis)
  5198. * @returns the new rotation matrix
  5199. */
  5200. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  5201. /**
  5202. * Creates a rotation matrix and stores it in a given matrix
  5203. * @param yaw defines the yaw angle in radians (Y axis)
  5204. * @param pitch defines the pitch angle in radians (X axis)
  5205. * @param roll defines the roll angle in radians (Z axis)
  5206. * @param result defines the target matrix
  5207. */
  5208. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  5209. /**
  5210. * Creates a scaling matrix
  5211. * @param x defines the scale factor on X axis
  5212. * @param y defines the scale factor on Y axis
  5213. * @param z defines the scale factor on Z axis
  5214. * @returns the new matrix
  5215. */
  5216. static Scaling(x: number, y: number, z: number): Matrix;
  5217. /**
  5218. * Creates a scaling matrix and stores it in a given matrix
  5219. * @param x defines the scale factor on X axis
  5220. * @param y defines the scale factor on Y axis
  5221. * @param z defines the scale factor on Z axis
  5222. * @param result defines the target matrix
  5223. */
  5224. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  5225. /**
  5226. * Creates a translation matrix
  5227. * @param x defines the translation on X axis
  5228. * @param y defines the translation on Y axis
  5229. * @param z defines the translationon Z axis
  5230. * @returns the new matrix
  5231. */
  5232. static Translation(x: number, y: number, z: number): Matrix;
  5233. /**
  5234. * Creates a translation matrix and stores it in a given matrix
  5235. * @param x defines the translation on X axis
  5236. * @param y defines the translation on Y axis
  5237. * @param z defines the translationon Z axis
  5238. * @param result defines the target matrix
  5239. */
  5240. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  5241. /**
  5242. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  5243. * @param startValue defines the start value
  5244. * @param endValue defines the end value
  5245. * @param gradient defines the gradient factor
  5246. * @returns the new matrix
  5247. */
  5248. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  5249. /**
  5250. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  5251. * @param startValue defines the start value
  5252. * @param endValue defines the end value
  5253. * @param gradient defines the gradient factor
  5254. * @param result defines the Matrix object where to store data
  5255. */
  5256. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  5257. /**
  5258. * Builds a new matrix whose values are computed by:
  5259. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  5260. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  5261. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  5262. * @param startValue defines the first matrix
  5263. * @param endValue defines the second matrix
  5264. * @param gradient defines the gradient between the two matrices
  5265. * @returns the new matrix
  5266. */
  5267. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  5268. /**
  5269. * Update a matrix to values which are computed by:
  5270. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  5271. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  5272. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  5273. * @param startValue defines the first matrix
  5274. * @param endValue defines the second matrix
  5275. * @param gradient defines the gradient between the two matrices
  5276. * @param result defines the target matrix
  5277. */
  5278. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  5279. /**
  5280. * 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"
  5281. * This function works in left handed mode
  5282. * @param eye defines the final position of the entity
  5283. * @param target defines where the entity should look at
  5284. * @param up defines the up vector for the entity
  5285. * @returns the new matrix
  5286. */
  5287. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  5288. /**
  5289. * 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".
  5290. * This function works in left handed mode
  5291. * @param eye defines the final position of the entity
  5292. * @param target defines where the entity should look at
  5293. * @param up defines the up vector for the entity
  5294. * @param result defines the target matrix
  5295. */
  5296. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  5297. /**
  5298. * 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"
  5299. * This function works in right handed mode
  5300. * @param eye defines the final position of the entity
  5301. * @param target defines where the entity should look at
  5302. * @param up defines the up vector for the entity
  5303. * @returns the new matrix
  5304. */
  5305. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  5306. /**
  5307. * 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".
  5308. * This function works in right handed mode
  5309. * @param eye defines the final position of the entity
  5310. * @param target defines where the entity should look at
  5311. * @param up defines the up vector for the entity
  5312. * @param result defines the target matrix
  5313. */
  5314. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  5315. /**
  5316. * Create a left-handed orthographic projection matrix
  5317. * @param width defines the viewport width
  5318. * @param height defines the viewport height
  5319. * @param znear defines the near clip plane
  5320. * @param zfar defines the far clip plane
  5321. * @returns a new matrix as a left-handed orthographic projection matrix
  5322. */
  5323. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  5324. /**
  5325. * Store a left-handed orthographic projection to a given matrix
  5326. * @param width defines the viewport width
  5327. * @param height defines the viewport height
  5328. * @param znear defines the near clip plane
  5329. * @param zfar defines the far clip plane
  5330. * @param result defines the target matrix
  5331. */
  5332. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  5333. /**
  5334. * Create a left-handed orthographic projection matrix
  5335. * @param left defines the viewport left coordinate
  5336. * @param right defines the viewport right coordinate
  5337. * @param bottom defines the viewport bottom coordinate
  5338. * @param top defines the viewport top coordinate
  5339. * @param znear defines the near clip plane
  5340. * @param zfar defines the far clip plane
  5341. * @returns a new matrix as a left-handed orthographic projection matrix
  5342. */
  5343. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  5344. /**
  5345. * Stores a left-handed orthographic projection into a given matrix
  5346. * @param left defines the viewport left coordinate
  5347. * @param right defines the viewport right coordinate
  5348. * @param bottom defines the viewport bottom coordinate
  5349. * @param top defines the viewport top coordinate
  5350. * @param znear defines the near clip plane
  5351. * @param zfar defines the far clip plane
  5352. * @param result defines the target matrix
  5353. */
  5354. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  5355. /**
  5356. * Creates a right-handed orthographic projection matrix
  5357. * @param left defines the viewport left coordinate
  5358. * @param right defines the viewport right coordinate
  5359. * @param bottom defines the viewport bottom coordinate
  5360. * @param top defines the viewport top coordinate
  5361. * @param znear defines the near clip plane
  5362. * @param zfar defines the far clip plane
  5363. * @returns a new matrix as a right-handed orthographic projection matrix
  5364. */
  5365. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  5366. /**
  5367. * Stores a right-handed orthographic projection into a given matrix
  5368. * @param left defines the viewport left coordinate
  5369. * @param right defines the viewport right coordinate
  5370. * @param bottom defines the viewport bottom coordinate
  5371. * @param top defines the viewport top coordinate
  5372. * @param znear defines the near clip plane
  5373. * @param zfar defines the far clip plane
  5374. * @param result defines the target matrix
  5375. */
  5376. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  5377. /**
  5378. * Creates a left-handed perspective projection matrix
  5379. * @param width defines the viewport width
  5380. * @param height defines the viewport height
  5381. * @param znear defines the near clip plane
  5382. * @param zfar defines the far clip plane
  5383. * @returns a new matrix as a left-handed perspective projection matrix
  5384. */
  5385. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  5386. /**
  5387. * Creates a left-handed perspective projection matrix
  5388. * @param fov defines the horizontal field of view
  5389. * @param aspect defines the aspect ratio
  5390. * @param znear defines the near clip plane
  5391. * @param zfar defines the far clip plane
  5392. * @returns a new matrix as a left-handed perspective projection matrix
  5393. */
  5394. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  5395. /**
  5396. * Stores a left-handed perspective projection into a given matrix
  5397. * @param fov defines the horizontal field of view
  5398. * @param aspect defines the aspect ratio
  5399. * @param znear defines the near clip plane
  5400. * @param zfar defines the far clip plane
  5401. * @param result defines the target matrix
  5402. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  5403. */
  5404. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  5405. /**
  5406. * Stores a left-handed perspective projection into a given matrix with depth reversed
  5407. * @param fov defines the horizontal field of view
  5408. * @param aspect defines the aspect ratio
  5409. * @param znear defines the near clip plane
  5410. * @param zfar not used as infinity is used as far clip
  5411. * @param result defines the target matrix
  5412. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  5413. */
  5414. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  5415. /**
  5416. * Creates a right-handed perspective projection matrix
  5417. * @param fov defines the horizontal field of view
  5418. * @param aspect defines the aspect ratio
  5419. * @param znear defines the near clip plane
  5420. * @param zfar defines the far clip plane
  5421. * @returns a new matrix as a right-handed perspective projection matrix
  5422. */
  5423. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  5424. /**
  5425. * Stores a right-handed perspective projection into a given matrix
  5426. * @param fov defines the horizontal field of view
  5427. * @param aspect defines the aspect ratio
  5428. * @param znear defines the near clip plane
  5429. * @param zfar defines the far clip plane
  5430. * @param result defines the target matrix
  5431. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  5432. */
  5433. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  5434. /**
  5435. * Stores a right-handed perspective projection into a given matrix
  5436. * @param fov defines the horizontal field of view
  5437. * @param aspect defines the aspect ratio
  5438. * @param znear defines the near clip plane
  5439. * @param zfar not used as infinity is used as far clip
  5440. * @param result defines the target matrix
  5441. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  5442. */
  5443. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  5444. /**
  5445. * Stores a perspective projection for WebVR info a given matrix
  5446. * @param fov defines the field of view
  5447. * @param znear defines the near clip plane
  5448. * @param zfar defines the far clip plane
  5449. * @param result defines the target matrix
  5450. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  5451. */
  5452. static PerspectiveFovWebVRToRef(fov: {
  5453. upDegrees: number;
  5454. downDegrees: number;
  5455. leftDegrees: number;
  5456. rightDegrees: number;
  5457. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  5458. /**
  5459. * Computes a complete transformation matrix
  5460. * @param viewport defines the viewport to use
  5461. * @param world defines the world matrix
  5462. * @param view defines the view matrix
  5463. * @param projection defines the projection matrix
  5464. * @param zmin defines the near clip plane
  5465. * @param zmax defines the far clip plane
  5466. * @returns the transformation matrix
  5467. */
  5468. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  5469. /**
  5470. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  5471. * @param matrix defines the matrix to use
  5472. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  5473. */
  5474. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  5475. /**
  5476. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  5477. * @param matrix defines the matrix to use
  5478. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  5479. */
  5480. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  5481. /**
  5482. * Compute the transpose of a given matrix
  5483. * @param matrix defines the matrix to transpose
  5484. * @returns the new matrix
  5485. */
  5486. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  5487. /**
  5488. * Compute the transpose of a matrix and store it in a target matrix
  5489. * @param matrix defines the matrix to transpose
  5490. * @param result defines the target matrix
  5491. */
  5492. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  5493. /**
  5494. * Computes a reflection matrix from a plane
  5495. * @param plane defines the reflection plane
  5496. * @returns a new matrix
  5497. */
  5498. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  5499. /**
  5500. * Computes a reflection matrix from a plane
  5501. * @param plane defines the reflection plane
  5502. * @param result defines the target matrix
  5503. */
  5504. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  5505. /**
  5506. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  5507. * @param xaxis defines the value of the 1st axis
  5508. * @param yaxis defines the value of the 2nd axis
  5509. * @param zaxis defines the value of the 3rd axis
  5510. * @param result defines the target matrix
  5511. */
  5512. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  5513. /**
  5514. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  5515. * @param quat defines the quaternion to use
  5516. * @param result defines the target matrix
  5517. */
  5518. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  5519. }
  5520. /**
  5521. * @hidden
  5522. */
  5523. export class TmpVectors {
  5524. static Vector2: Vector2[];
  5525. static Vector3: Vector3[];
  5526. static Vector4: Vector4[];
  5527. static Quaternion: Quaternion[];
  5528. static Matrix: Matrix[];
  5529. }
  5530. }
  5531. declare module BABYLON {
  5532. /**
  5533. * Defines potential orientation for back face culling
  5534. */
  5535. export enum Orientation {
  5536. /**
  5537. * Clockwise
  5538. */
  5539. CW = 0,
  5540. /** Counter clockwise */
  5541. CCW = 1
  5542. }
  5543. /** Class used to represent a Bezier curve */
  5544. export class BezierCurve {
  5545. /**
  5546. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  5547. * @param t defines the time
  5548. * @param x1 defines the left coordinate on X axis
  5549. * @param y1 defines the left coordinate on Y axis
  5550. * @param x2 defines the right coordinate on X axis
  5551. * @param y2 defines the right coordinate on Y axis
  5552. * @returns the interpolated value
  5553. */
  5554. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  5555. }
  5556. /**
  5557. * Defines angle representation
  5558. */
  5559. export class Angle {
  5560. private _radians;
  5561. /**
  5562. * Creates an Angle object of "radians" radians (float).
  5563. * @param radians the angle in radians
  5564. */
  5565. constructor(radians: number);
  5566. /**
  5567. * Get value in degrees
  5568. * @returns the Angle value in degrees (float)
  5569. */
  5570. degrees(): number;
  5571. /**
  5572. * Get value in radians
  5573. * @returns the Angle value in radians (float)
  5574. */
  5575. radians(): number;
  5576. /**
  5577. * Gets a new Angle object valued with the gradient angle, in radians, of the line joining two points
  5578. * @param a defines first point as the origin
  5579. * @param b defines point
  5580. * @returns a new Angle
  5581. */
  5582. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  5583. /**
  5584. * Gets a new Angle object from the given float in radians
  5585. * @param radians defines the angle value in radians
  5586. * @returns a new Angle
  5587. */
  5588. static FromRadians(radians: number): Angle;
  5589. /**
  5590. * Gets a new Angle object from the given float in degrees
  5591. * @param degrees defines the angle value in degrees
  5592. * @returns a new Angle
  5593. */
  5594. static FromDegrees(degrees: number): Angle;
  5595. }
  5596. /**
  5597. * This represents an arc in a 2d space.
  5598. */
  5599. export class Arc2 {
  5600. /** Defines the start point of the arc */
  5601. startPoint: Vector2;
  5602. /** Defines the mid point of the arc */
  5603. midPoint: Vector2;
  5604. /** Defines the end point of the arc */
  5605. endPoint: Vector2;
  5606. /**
  5607. * Defines the center point of the arc.
  5608. */
  5609. centerPoint: Vector2;
  5610. /**
  5611. * Defines the radius of the arc.
  5612. */
  5613. radius: number;
  5614. /**
  5615. * Defines the angle of the arc (from mid point to end point).
  5616. */
  5617. angle: Angle;
  5618. /**
  5619. * Defines the start angle of the arc (from start point to middle point).
  5620. */
  5621. startAngle: Angle;
  5622. /**
  5623. * Defines the orientation of the arc (clock wise/counter clock wise).
  5624. */
  5625. orientation: Orientation;
  5626. /**
  5627. * Creates an Arc object from the three given points : start, middle and end.
  5628. * @param startPoint Defines the start point of the arc
  5629. * @param midPoint Defines the midlle point of the arc
  5630. * @param endPoint Defines the end point of the arc
  5631. */
  5632. constructor(
  5633. /** Defines the start point of the arc */
  5634. startPoint: Vector2,
  5635. /** Defines the mid point of the arc */
  5636. midPoint: Vector2,
  5637. /** Defines the end point of the arc */
  5638. endPoint: Vector2);
  5639. }
  5640. /**
  5641. * Represents a 2D path made up of multiple 2D points
  5642. */
  5643. export class Path2 {
  5644. private _points;
  5645. private _length;
  5646. /**
  5647. * If the path start and end point are the same
  5648. */
  5649. closed: boolean;
  5650. /**
  5651. * Creates a Path2 object from the starting 2D coordinates x and y.
  5652. * @param x the starting points x value
  5653. * @param y the starting points y value
  5654. */
  5655. constructor(x: number, y: number);
  5656. /**
  5657. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  5658. * @param x the added points x value
  5659. * @param y the added points y value
  5660. * @returns the updated Path2.
  5661. */
  5662. addLineTo(x: number, y: number): Path2;
  5663. /**
  5664. * 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.
  5665. * @param midX middle point x value
  5666. * @param midY middle point y value
  5667. * @param endX end point x value
  5668. * @param endY end point y value
  5669. * @param numberOfSegments (default: 36)
  5670. * @returns the updated Path2.
  5671. */
  5672. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  5673. /**
  5674. * Closes the Path2.
  5675. * @returns the Path2.
  5676. */
  5677. close(): Path2;
  5678. /**
  5679. * Gets the sum of the distance between each sequential point in the path
  5680. * @returns the Path2 total length (float).
  5681. */
  5682. length(): number;
  5683. /**
  5684. * Gets the points which construct the path
  5685. * @returns the Path2 internal array of points.
  5686. */
  5687. getPoints(): Vector2[];
  5688. /**
  5689. * Retreives the point at the distance aways from the starting point
  5690. * @param normalizedLengthPosition the length along the path to retreive the point from
  5691. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  5692. */
  5693. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  5694. /**
  5695. * Creates a new path starting from an x and y position
  5696. * @param x starting x value
  5697. * @param y starting y value
  5698. * @returns a new Path2 starting at the coordinates (x, y).
  5699. */
  5700. static StartingAt(x: number, y: number): Path2;
  5701. }
  5702. /**
  5703. * Represents a 3D path made up of multiple 3D points
  5704. */
  5705. export class Path3D {
  5706. /**
  5707. * an array of Vector3, the curve axis of the Path3D
  5708. */
  5709. path: Vector3[];
  5710. private _curve;
  5711. private _distances;
  5712. private _tangents;
  5713. private _normals;
  5714. private _binormals;
  5715. private _raw;
  5716. private _alignTangentsWithPath;
  5717. private readonly _pointAtData;
  5718. /**
  5719. * new Path3D(path, normal, raw)
  5720. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  5721. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  5722. * @param path an array of Vector3, the curve axis of the Path3D
  5723. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  5724. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  5725. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  5726. */
  5727. constructor(
  5728. /**
  5729. * an array of Vector3, the curve axis of the Path3D
  5730. */
  5731. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  5732. /**
  5733. * Returns the Path3D array of successive Vector3 designing its curve.
  5734. * @returns the Path3D array of successive Vector3 designing its curve.
  5735. */
  5736. getCurve(): Vector3[];
  5737. /**
  5738. * Returns the Path3D array of successive Vector3 designing its curve.
  5739. * @returns the Path3D array of successive Vector3 designing its curve.
  5740. */
  5741. getPoints(): Vector3[];
  5742. /**
  5743. * @returns the computed length (float) of the path.
  5744. */
  5745. length(): number;
  5746. /**
  5747. * Returns an array populated with tangent vectors on each Path3D curve point.
  5748. * @returns an array populated with tangent vectors on each Path3D curve point.
  5749. */
  5750. getTangents(): Vector3[];
  5751. /**
  5752. * Returns an array populated with normal vectors on each Path3D curve point.
  5753. * @returns an array populated with normal vectors on each Path3D curve point.
  5754. */
  5755. getNormals(): Vector3[];
  5756. /**
  5757. * Returns an array populated with binormal vectors on each Path3D curve point.
  5758. * @returns an array populated with binormal vectors on each Path3D curve point.
  5759. */
  5760. getBinormals(): Vector3[];
  5761. /**
  5762. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  5763. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  5764. */
  5765. getDistances(): number[];
  5766. /**
  5767. * Returns an interpolated point along this path
  5768. * @param position the position of the point along this path, from 0.0 to 1.0
  5769. * @returns a new Vector3 as the point
  5770. */
  5771. getPointAt(position: number): Vector3;
  5772. /**
  5773. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5774. * @param position the position of the point along this path, from 0.0 to 1.0
  5775. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  5776. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  5777. */
  5778. getTangentAt(position: number, interpolated?: boolean): Vector3;
  5779. /**
  5780. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5781. * @param position the position of the point along this path, from 0.0 to 1.0
  5782. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  5783. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  5784. */
  5785. getNormalAt(position: number, interpolated?: boolean): Vector3;
  5786. /**
  5787. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  5788. * @param position the position of the point along this path, from 0.0 to 1.0
  5789. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  5790. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  5791. */
  5792. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  5793. /**
  5794. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  5795. * @param position the position of the point along this path, from 0.0 to 1.0
  5796. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  5797. */
  5798. getDistanceAt(position: number): number;
  5799. /**
  5800. * Returns the array index of the previous point of an interpolated point along this path
  5801. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5802. * @returns the array index
  5803. */
  5804. getPreviousPointIndexAt(position: number): number;
  5805. /**
  5806. * 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)
  5807. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5808. * @returns the sub position
  5809. */
  5810. getSubPositionAt(position: number): number;
  5811. /**
  5812. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  5813. * @param target the vector of which to get the closest position to
  5814. * @returns the position of the closest virtual point on this path to the target vector
  5815. */
  5816. getClosestPositionTo(target: Vector3): number;
  5817. /**
  5818. * Returns a sub path (slice) of this path
  5819. * @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
  5820. * @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
  5821. * @returns a sub path (slice) of this path
  5822. */
  5823. slice(start?: number, end?: number): Path3D;
  5824. /**
  5825. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  5826. * @param path path which all values are copied into the curves points
  5827. * @param firstNormal which should be projected onto the curve
  5828. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  5829. * @returns the same object updated.
  5830. */
  5831. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  5832. private _compute;
  5833. private _getFirstNonNullVector;
  5834. private _getLastNonNullVector;
  5835. private _normalVector;
  5836. /**
  5837. * Updates the point at data for an interpolated point along this curve
  5838. * @param position the position of the point along this curve, from 0.0 to 1.0
  5839. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  5840. * @returns the (updated) point at data
  5841. */
  5842. private _updatePointAtData;
  5843. /**
  5844. * Updates the point at data from the specified parameters
  5845. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  5846. * @param point the interpolated point
  5847. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  5848. */
  5849. private _setPointAtData;
  5850. /**
  5851. * Updates the point at interpolation matrix for the tangents, normals and binormals
  5852. */
  5853. private _updateInterpolationMatrix;
  5854. }
  5855. /**
  5856. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5857. * A Curve3 is designed from a series of successive Vector3.
  5858. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  5859. */
  5860. export class Curve3 {
  5861. private _points;
  5862. private _length;
  5863. /**
  5864. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  5865. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  5866. * @param v1 (Vector3) the control point
  5867. * @param v2 (Vector3) the end point of the Quadratic Bezier
  5868. * @param nbPoints (integer) the wanted number of points in the curve
  5869. * @returns the created Curve3
  5870. */
  5871. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5872. /**
  5873. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  5874. * @param v0 (Vector3) the origin point of the Cubic Bezier
  5875. * @param v1 (Vector3) the first control point
  5876. * @param v2 (Vector3) the second control point
  5877. * @param v3 (Vector3) the end point of the Cubic Bezier
  5878. * @param nbPoints (integer) the wanted number of points in the curve
  5879. * @returns the created Curve3
  5880. */
  5881. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5882. /**
  5883. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  5884. * @param p1 (Vector3) the origin point of the Hermite Spline
  5885. * @param t1 (Vector3) the tangent vector at the origin point
  5886. * @param p2 (Vector3) the end point of the Hermite Spline
  5887. * @param t2 (Vector3) the tangent vector at the end point
  5888. * @param nbPoints (integer) the wanted number of points in the curve
  5889. * @returns the created Curve3
  5890. */
  5891. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5892. /**
  5893. * Returns a Curve3 object along a CatmullRom Spline curve :
  5894. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  5895. * @param nbPoints (integer) the wanted number of points between each curve control points
  5896. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5897. * @returns the created Curve3
  5898. */
  5899. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5900. /**
  5901. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5902. * A Curve3 is designed from a series of successive Vector3.
  5903. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5904. * @param points points which make up the curve
  5905. */
  5906. constructor(points: Vector3[]);
  5907. /**
  5908. * @returns the Curve3 stored array of successive Vector3
  5909. */
  5910. getPoints(): Vector3[];
  5911. /**
  5912. * @returns the computed length (float) of the curve.
  5913. */
  5914. length(): number;
  5915. /**
  5916. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5917. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5918. * curveA and curveB keep unchanged.
  5919. * @param curve the curve to continue from this curve
  5920. * @returns the newly constructed curve
  5921. */
  5922. continue(curve: DeepImmutable<Curve3>): Curve3;
  5923. private _computeLength;
  5924. }
  5925. }
  5926. declare module BABYLON {
  5927. /**
  5928. * This represents the main contract an easing function should follow.
  5929. * Easing functions are used throughout the animation system.
  5930. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5931. */
  5932. export interface IEasingFunction {
  5933. /**
  5934. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5935. * of the easing function.
  5936. * The link below provides some of the most common examples of easing functions.
  5937. * @see https://easings.net/
  5938. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5939. * @returns the corresponding value on the curve defined by the easing function
  5940. */
  5941. ease(gradient: number): number;
  5942. }
  5943. /**
  5944. * Base class used for every default easing function.
  5945. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5946. */
  5947. export class EasingFunction implements IEasingFunction {
  5948. /**
  5949. * Interpolation follows the mathematical formula associated with the easing function.
  5950. */
  5951. static readonly EASINGMODE_EASEIN: number;
  5952. /**
  5953. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5954. */
  5955. static readonly EASINGMODE_EASEOUT: number;
  5956. /**
  5957. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5958. */
  5959. static readonly EASINGMODE_EASEINOUT: number;
  5960. private _easingMode;
  5961. /**
  5962. * Sets the easing mode of the current function.
  5963. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5964. */
  5965. setEasingMode(easingMode: number): void;
  5966. /**
  5967. * Gets the current easing mode.
  5968. * @returns the easing mode
  5969. */
  5970. getEasingMode(): number;
  5971. /**
  5972. * @hidden
  5973. */
  5974. easeInCore(gradient: number): number;
  5975. /**
  5976. * Given an input gradient between 0 and 1, this returns the corresponding value
  5977. * of the easing function.
  5978. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5979. * @returns the corresponding value on the curve defined by the easing function
  5980. */
  5981. ease(gradient: number): number;
  5982. }
  5983. /**
  5984. * Easing function with a circle shape (see link below).
  5985. * @see https://easings.net/#easeInCirc
  5986. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5987. */
  5988. export class CircleEase extends EasingFunction implements IEasingFunction {
  5989. /** @hidden */
  5990. easeInCore(gradient: number): number;
  5991. }
  5992. /**
  5993. * Easing function with a ease back shape (see link below).
  5994. * @see https://easings.net/#easeInBack
  5995. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5996. */
  5997. export class BackEase extends EasingFunction implements IEasingFunction {
  5998. /** Defines the amplitude of the function */
  5999. amplitude: number;
  6000. /**
  6001. * Instantiates a back ease easing
  6002. * @see https://easings.net/#easeInBack
  6003. * @param amplitude Defines the amplitude of the function
  6004. */
  6005. constructor(
  6006. /** Defines the amplitude of the function */
  6007. amplitude?: number);
  6008. /** @hidden */
  6009. easeInCore(gradient: number): number;
  6010. }
  6011. /**
  6012. * Easing function with a bouncing shape (see link below).
  6013. * @see https://easings.net/#easeInBounce
  6014. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  6015. */
  6016. export class BounceEase extends EasingFunction implements IEasingFunction {
  6017. /** Defines the number of bounces */
  6018. bounces: number;
  6019. /** Defines the amplitude of the bounce */
  6020. bounciness: number;
  6021. /**
  6022. * Instantiates a bounce easing
  6023. * @see https://easings.net/#easeInBounce
  6024. * @param bounces Defines the number of bounces
  6025. * @param bounciness Defines the amplitude of the bounce
  6026. */
  6027. constructor(
  6028. /** Defines the number of bounces */
  6029. bounces?: number,
  6030. /** Defines the amplitude of the bounce */
  6031. bounciness?: number);
  6032. /** @hidden */
  6033. easeInCore(gradient: number): number;
  6034. }
  6035. /**
  6036. * Easing function with a power of 3 shape (see link below).
  6037. * @see https://easings.net/#easeInCubic
  6038. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  6039. */
  6040. export class CubicEase extends EasingFunction implements IEasingFunction {
  6041. /** @hidden */
  6042. easeInCore(gradient: number): number;
  6043. }
  6044. /**
  6045. * Easing function with an elastic shape (see link below).
  6046. * @see https://easings.net/#easeInElastic
  6047. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  6048. */
  6049. export class ElasticEase extends EasingFunction implements IEasingFunction {
  6050. /** Defines the number of oscillations*/
  6051. oscillations: number;
  6052. /** Defines the amplitude of the oscillations*/
  6053. springiness: number;
  6054. /**
  6055. * Instantiates an elastic easing function
  6056. * @see https://easings.net/#easeInElastic
  6057. * @param oscillations Defines the number of oscillations
  6058. * @param springiness Defines the amplitude of the oscillations
  6059. */
  6060. constructor(
  6061. /** Defines the number of oscillations*/
  6062. oscillations?: number,
  6063. /** Defines the amplitude of the oscillations*/
  6064. springiness?: number);
  6065. /** @hidden */
  6066. easeInCore(gradient: number): number;
  6067. }
  6068. /**
  6069. * Easing function with an exponential shape (see link below).
  6070. * @see https://easings.net/#easeInExpo
  6071. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  6072. */
  6073. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  6074. /** Defines the exponent of the function */
  6075. exponent: number;
  6076. /**
  6077. * Instantiates an exponential easing function
  6078. * @see https://easings.net/#easeInExpo
  6079. * @param exponent Defines the exponent of the function
  6080. */
  6081. constructor(
  6082. /** Defines the exponent of the function */
  6083. exponent?: number);
  6084. /** @hidden */
  6085. easeInCore(gradient: number): number;
  6086. }
  6087. /**
  6088. * Easing function with a power shape (see link below).
  6089. * @see https://easings.net/#easeInQuad
  6090. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  6091. */
  6092. export class PowerEase extends EasingFunction implements IEasingFunction {
  6093. /** Defines the power of the function */
  6094. power: number;
  6095. /**
  6096. * Instantiates an power base easing function
  6097. * @see https://easings.net/#easeInQuad
  6098. * @param power Defines the power of the function
  6099. */
  6100. constructor(
  6101. /** Defines the power of the function */
  6102. power?: number);
  6103. /** @hidden */
  6104. easeInCore(gradient: number): number;
  6105. }
  6106. /**
  6107. * Easing function with a power of 2 shape (see link below).
  6108. * @see https://easings.net/#easeInQuad
  6109. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  6110. */
  6111. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  6112. /** @hidden */
  6113. easeInCore(gradient: number): number;
  6114. }
  6115. /**
  6116. * Easing function with a power of 4 shape (see link below).
  6117. * @see https://easings.net/#easeInQuart
  6118. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  6119. */
  6120. export class QuarticEase extends EasingFunction implements IEasingFunction {
  6121. /** @hidden */
  6122. easeInCore(gradient: number): number;
  6123. }
  6124. /**
  6125. * Easing function with a power of 5 shape (see link below).
  6126. * @see https://easings.net/#easeInQuint
  6127. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  6128. */
  6129. export class QuinticEase extends EasingFunction implements IEasingFunction {
  6130. /** @hidden */
  6131. easeInCore(gradient: number): number;
  6132. }
  6133. /**
  6134. * Easing function with a sin shape (see link below).
  6135. * @see https://easings.net/#easeInSine
  6136. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  6137. */
  6138. export class SineEase extends EasingFunction implements IEasingFunction {
  6139. /** @hidden */
  6140. easeInCore(gradient: number): number;
  6141. }
  6142. /**
  6143. * Easing function with a bezier shape (see link below).
  6144. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6145. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  6146. */
  6147. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  6148. /** Defines the x component of the start tangent in the bezier curve */
  6149. x1: number;
  6150. /** Defines the y component of the start tangent in the bezier curve */
  6151. y1: number;
  6152. /** Defines the x component of the end tangent in the bezier curve */
  6153. x2: number;
  6154. /** Defines the y component of the end tangent in the bezier curve */
  6155. y2: number;
  6156. /**
  6157. * Instantiates a bezier function
  6158. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6159. * @param x1 Defines the x component of the start tangent in the bezier curve
  6160. * @param y1 Defines the y component of the start tangent in the bezier curve
  6161. * @param x2 Defines the x component of the end tangent in the bezier curve
  6162. * @param y2 Defines the y component of the end tangent in the bezier curve
  6163. */
  6164. constructor(
  6165. /** Defines the x component of the start tangent in the bezier curve */
  6166. x1?: number,
  6167. /** Defines the y component of the start tangent in the bezier curve */
  6168. y1?: number,
  6169. /** Defines the x component of the end tangent in the bezier curve */
  6170. x2?: number,
  6171. /** Defines the y component of the end tangent in the bezier curve */
  6172. y2?: number);
  6173. /** @hidden */
  6174. easeInCore(gradient: number): number;
  6175. }
  6176. }
  6177. declare module BABYLON {
  6178. /**
  6179. * Class used to hold a RGB color
  6180. */
  6181. export class Color3 {
  6182. /**
  6183. * Defines the red component (between 0 and 1, default is 0)
  6184. */
  6185. r: number;
  6186. /**
  6187. * Defines the green component (between 0 and 1, default is 0)
  6188. */
  6189. g: number;
  6190. /**
  6191. * Defines the blue component (between 0 and 1, default is 0)
  6192. */
  6193. b: number;
  6194. /**
  6195. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  6196. * @param r defines the red component (between 0 and 1, default is 0)
  6197. * @param g defines the green component (between 0 and 1, default is 0)
  6198. * @param b defines the blue component (between 0 and 1, default is 0)
  6199. */
  6200. constructor(
  6201. /**
  6202. * Defines the red component (between 0 and 1, default is 0)
  6203. */
  6204. r?: number,
  6205. /**
  6206. * Defines the green component (between 0 and 1, default is 0)
  6207. */
  6208. g?: number,
  6209. /**
  6210. * Defines the blue component (between 0 and 1, default is 0)
  6211. */
  6212. b?: number);
  6213. /**
  6214. * Creates a string with the Color3 current values
  6215. * @returns the string representation of the Color3 object
  6216. */
  6217. toString(): string;
  6218. /**
  6219. * Returns the string "Color3"
  6220. * @returns "Color3"
  6221. */
  6222. getClassName(): string;
  6223. /**
  6224. * Compute the Color3 hash code
  6225. * @returns an unique number that can be used to hash Color3 objects
  6226. */
  6227. getHashCode(): number;
  6228. /**
  6229. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  6230. * @param array defines the array where to store the r,g,b components
  6231. * @param index defines an optional index in the target array to define where to start storing values
  6232. * @returns the current Color3 object
  6233. */
  6234. toArray(array: FloatArray, index?: number): Color3;
  6235. /**
  6236. * Update the current color with values stored in an array from the starting index of the given array
  6237. * @param array defines the source array
  6238. * @param offset defines an offset in the source array
  6239. * @returns the current Color3 object
  6240. */
  6241. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  6242. /**
  6243. * Returns a new Color4 object from the current Color3 and the given alpha
  6244. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  6245. * @returns a new Color4 object
  6246. */
  6247. toColor4(alpha?: number): Color4;
  6248. /**
  6249. * Returns a new array populated with 3 numeric elements : red, green and blue values
  6250. * @returns the new array
  6251. */
  6252. asArray(): number[];
  6253. /**
  6254. * Returns the luminance value
  6255. * @returns a float value
  6256. */
  6257. toLuminance(): number;
  6258. /**
  6259. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  6260. * @param otherColor defines the second operand
  6261. * @returns the new Color3 object
  6262. */
  6263. multiply(otherColor: DeepImmutable<Color3>): Color3;
  6264. /**
  6265. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  6266. * @param otherColor defines the second operand
  6267. * @param result defines the Color3 object where to store the result
  6268. * @returns the current Color3
  6269. */
  6270. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  6271. /**
  6272. * Determines equality between Color3 objects
  6273. * @param otherColor defines the second operand
  6274. * @returns true if the rgb values are equal to the given ones
  6275. */
  6276. equals(otherColor: DeepImmutable<Color3>): boolean;
  6277. /**
  6278. * Determines equality between the current Color3 object and a set of r,b,g values
  6279. * @param r defines the red component to check
  6280. * @param g defines the green component to check
  6281. * @param b defines the blue component to check
  6282. * @returns true if the rgb values are equal to the given ones
  6283. */
  6284. equalsFloats(r: number, g: number, b: number): boolean;
  6285. /**
  6286. * Multiplies in place each rgb value by scale
  6287. * @param scale defines the scaling factor
  6288. * @returns the updated Color3
  6289. */
  6290. scale(scale: number): Color3;
  6291. /**
  6292. * Multiplies the rgb values by scale and stores the result into "result"
  6293. * @param scale defines the scaling factor
  6294. * @param result defines the Color3 object where to store the result
  6295. * @returns the unmodified current Color3
  6296. */
  6297. scaleToRef(scale: number, result: Color3): Color3;
  6298. /**
  6299. * Scale the current Color3 values by a factor and add the result to a given Color3
  6300. * @param scale defines the scale factor
  6301. * @param result defines color to store the result into
  6302. * @returns the unmodified current Color3
  6303. */
  6304. scaleAndAddToRef(scale: number, result: Color3): Color3;
  6305. /**
  6306. * Clamps the rgb values by the min and max values and stores the result into "result"
  6307. * @param min defines minimum clamping value (default is 0)
  6308. * @param max defines maximum clamping value (default is 1)
  6309. * @param result defines color to store the result into
  6310. * @returns the original Color3
  6311. */
  6312. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  6313. /**
  6314. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  6315. * @param otherColor defines the second operand
  6316. * @returns the new Color3
  6317. */
  6318. add(otherColor: DeepImmutable<Color3>): Color3;
  6319. /**
  6320. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  6321. * @param otherColor defines the second operand
  6322. * @param result defines Color3 object to store the result into
  6323. * @returns the unmodified current Color3
  6324. */
  6325. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  6326. /**
  6327. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  6328. * @param otherColor defines the second operand
  6329. * @returns the new Color3
  6330. */
  6331. subtract(otherColor: DeepImmutable<Color3>): Color3;
  6332. /**
  6333. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  6334. * @param otherColor defines the second operand
  6335. * @param result defines Color3 object to store the result into
  6336. * @returns the unmodified current Color3
  6337. */
  6338. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  6339. /**
  6340. * Copy the current object
  6341. * @returns a new Color3 copied the current one
  6342. */
  6343. clone(): Color3;
  6344. /**
  6345. * Copies the rgb values from the source in the current Color3
  6346. * @param source defines the source Color3 object
  6347. * @returns the updated Color3 object
  6348. */
  6349. copyFrom(source: DeepImmutable<Color3>): Color3;
  6350. /**
  6351. * Updates the Color3 rgb values from the given floats
  6352. * @param r defines the red component to read from
  6353. * @param g defines the green component to read from
  6354. * @param b defines the blue component to read from
  6355. * @returns the current Color3 object
  6356. */
  6357. copyFromFloats(r: number, g: number, b: number): Color3;
  6358. /**
  6359. * Updates the Color3 rgb values from the given floats
  6360. * @param r defines the red component to read from
  6361. * @param g defines the green component to read from
  6362. * @param b defines the blue component to read from
  6363. * @returns the current Color3 object
  6364. */
  6365. set(r: number, g: number, b: number): Color3;
  6366. /**
  6367. * Compute the Color3 hexadecimal code as a string
  6368. * @returns a string containing the hexadecimal representation of the Color3 object
  6369. */
  6370. toHexString(): string;
  6371. /**
  6372. * Computes a new Color3 converted from the current one to linear space
  6373. * @returns a new Color3 object
  6374. */
  6375. toLinearSpace(): Color3;
  6376. /**
  6377. * Converts current color in rgb space to HSV values
  6378. * @returns a new color3 representing the HSV values
  6379. */
  6380. toHSV(): Color3;
  6381. /**
  6382. * Converts current color in rgb space to HSV values
  6383. * @param result defines the Color3 where to store the HSV values
  6384. */
  6385. toHSVToRef(result: Color3): void;
  6386. /**
  6387. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  6388. * @param convertedColor defines the Color3 object where to store the linear space version
  6389. * @returns the unmodified Color3
  6390. */
  6391. toLinearSpaceToRef(convertedColor: Color3): Color3;
  6392. /**
  6393. * Computes a new Color3 converted from the current one to gamma space
  6394. * @returns a new Color3 object
  6395. */
  6396. toGammaSpace(): Color3;
  6397. /**
  6398. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  6399. * @param convertedColor defines the Color3 object where to store the gamma space version
  6400. * @returns the unmodified Color3
  6401. */
  6402. toGammaSpaceToRef(convertedColor: Color3): Color3;
  6403. private static _BlackReadOnly;
  6404. /**
  6405. * Convert Hue, saturation and value to a Color3 (RGB)
  6406. * @param hue defines the hue
  6407. * @param saturation defines the saturation
  6408. * @param value defines the value
  6409. * @param result defines the Color3 where to store the RGB values
  6410. */
  6411. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  6412. /**
  6413. * Creates a new Color3 from the string containing valid hexadecimal values
  6414. * @param hex defines a string containing valid hexadecimal values
  6415. * @returns a new Color3 object
  6416. */
  6417. static FromHexString(hex: string): Color3;
  6418. /**
  6419. * Creates a new Color3 from the starting index of the given array
  6420. * @param array defines the source array
  6421. * @param offset defines an offset in the source array
  6422. * @returns a new Color3 object
  6423. */
  6424. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  6425. /**
  6426. * Creates a new Color3 from the starting index element of the given array
  6427. * @param array defines the source array to read from
  6428. * @param offset defines the offset in the source array
  6429. * @param result defines the target Color3 object
  6430. */
  6431. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color3): void;
  6432. /**
  6433. * Creates a new Color3 from integer values (< 256)
  6434. * @param r defines the red component to read from (value between 0 and 255)
  6435. * @param g defines the green component to read from (value between 0 and 255)
  6436. * @param b defines the blue component to read from (value between 0 and 255)
  6437. * @returns a new Color3 object
  6438. */
  6439. static FromInts(r: number, g: number, b: number): Color3;
  6440. /**
  6441. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  6442. * @param start defines the start Color3 value
  6443. * @param end defines the end Color3 value
  6444. * @param amount defines the gradient value between start and end
  6445. * @returns a new Color3 object
  6446. */
  6447. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  6448. /**
  6449. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  6450. * @param left defines the start value
  6451. * @param right defines the end value
  6452. * @param amount defines the gradient factor
  6453. * @param result defines the Color3 object where to store the result
  6454. */
  6455. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  6456. /**
  6457. * Returns a Color3 value containing a red color
  6458. * @returns a new Color3 object
  6459. */
  6460. static Red(): Color3;
  6461. /**
  6462. * Returns a Color3 value containing a green color
  6463. * @returns a new Color3 object
  6464. */
  6465. static Green(): Color3;
  6466. /**
  6467. * Returns a Color3 value containing a blue color
  6468. * @returns a new Color3 object
  6469. */
  6470. static Blue(): Color3;
  6471. /**
  6472. * Returns a Color3 value containing a black color
  6473. * @returns a new Color3 object
  6474. */
  6475. static Black(): Color3;
  6476. /**
  6477. * Gets a Color3 value containing a black color that must not be updated
  6478. */
  6479. static get BlackReadOnly(): DeepImmutable<Color3>;
  6480. /**
  6481. * Returns a Color3 value containing a white color
  6482. * @returns a new Color3 object
  6483. */
  6484. static White(): Color3;
  6485. /**
  6486. * Returns a Color3 value containing a purple color
  6487. * @returns a new Color3 object
  6488. */
  6489. static Purple(): Color3;
  6490. /**
  6491. * Returns a Color3 value containing a magenta color
  6492. * @returns a new Color3 object
  6493. */
  6494. static Magenta(): Color3;
  6495. /**
  6496. * Returns a Color3 value containing a yellow color
  6497. * @returns a new Color3 object
  6498. */
  6499. static Yellow(): Color3;
  6500. /**
  6501. * Returns a Color3 value containing a gray color
  6502. * @returns a new Color3 object
  6503. */
  6504. static Gray(): Color3;
  6505. /**
  6506. * Returns a Color3 value containing a teal color
  6507. * @returns a new Color3 object
  6508. */
  6509. static Teal(): Color3;
  6510. /**
  6511. * Returns a Color3 value containing a random color
  6512. * @returns a new Color3 object
  6513. */
  6514. static Random(): Color3;
  6515. }
  6516. /**
  6517. * Class used to hold a RBGA color
  6518. */
  6519. export class Color4 {
  6520. /**
  6521. * Defines the red component (between 0 and 1, default is 0)
  6522. */
  6523. r: number;
  6524. /**
  6525. * Defines the green component (between 0 and 1, default is 0)
  6526. */
  6527. g: number;
  6528. /**
  6529. * Defines the blue component (between 0 and 1, default is 0)
  6530. */
  6531. b: number;
  6532. /**
  6533. * Defines the alpha component (between 0 and 1, default is 1)
  6534. */
  6535. a: number;
  6536. /**
  6537. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  6538. * @param r defines the red component (between 0 and 1, default is 0)
  6539. * @param g defines the green component (between 0 and 1, default is 0)
  6540. * @param b defines the blue component (between 0 and 1, default is 0)
  6541. * @param a defines the alpha component (between 0 and 1, default is 1)
  6542. */
  6543. constructor(
  6544. /**
  6545. * Defines the red component (between 0 and 1, default is 0)
  6546. */
  6547. r?: number,
  6548. /**
  6549. * Defines the green component (between 0 and 1, default is 0)
  6550. */
  6551. g?: number,
  6552. /**
  6553. * Defines the blue component (between 0 and 1, default is 0)
  6554. */
  6555. b?: number,
  6556. /**
  6557. * Defines the alpha component (between 0 and 1, default is 1)
  6558. */
  6559. a?: number);
  6560. /**
  6561. * Adds in place the given Color4 values to the current Color4 object
  6562. * @param right defines the second operand
  6563. * @returns the current updated Color4 object
  6564. */
  6565. addInPlace(right: DeepImmutable<Color4>): Color4;
  6566. /**
  6567. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  6568. * @returns the new array
  6569. */
  6570. asArray(): number[];
  6571. /**
  6572. * Stores from the starting index in the given array the Color4 successive values
  6573. * @param array defines the array where to store the r,g,b components
  6574. * @param index defines an optional index in the target array to define where to start storing values
  6575. * @returns the current Color4 object
  6576. */
  6577. toArray(array: number[], index?: number): Color4;
  6578. /**
  6579. * Update the current color with values stored in an array from the starting index of the given array
  6580. * @param array defines the source array
  6581. * @param offset defines an offset in the source array
  6582. * @returns the current Color4 object
  6583. */
  6584. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  6585. /**
  6586. * Determines equality between Color4 objects
  6587. * @param otherColor defines the second operand
  6588. * @returns true if the rgba values are equal to the given ones
  6589. */
  6590. equals(otherColor: DeepImmutable<Color4>): boolean;
  6591. /**
  6592. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  6593. * @param right defines the second operand
  6594. * @returns a new Color4 object
  6595. */
  6596. add(right: DeepImmutable<Color4>): Color4;
  6597. /**
  6598. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  6599. * @param right defines the second operand
  6600. * @returns a new Color4 object
  6601. */
  6602. subtract(right: DeepImmutable<Color4>): Color4;
  6603. /**
  6604. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  6605. * @param right defines the second operand
  6606. * @param result defines the Color4 object where to store the result
  6607. * @returns the current Color4 object
  6608. */
  6609. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  6610. /**
  6611. * Creates a new Color4 with the current Color4 values multiplied by scale
  6612. * @param scale defines the scaling factor to apply
  6613. * @returns a new Color4 object
  6614. */
  6615. scale(scale: number): Color4;
  6616. /**
  6617. * Multiplies the current Color4 values by scale and stores the result in "result"
  6618. * @param scale defines the scaling factor to apply
  6619. * @param result defines the Color4 object where to store the result
  6620. * @returns the current unmodified Color4
  6621. */
  6622. scaleToRef(scale: number, result: Color4): Color4;
  6623. /**
  6624. * Scale the current Color4 values by a factor and add the result to a given Color4
  6625. * @param scale defines the scale factor
  6626. * @param result defines the Color4 object where to store the result
  6627. * @returns the unmodified current Color4
  6628. */
  6629. scaleAndAddToRef(scale: number, result: Color4): Color4;
  6630. /**
  6631. * Clamps the rgb values by the min and max values and stores the result into "result"
  6632. * @param min defines minimum clamping value (default is 0)
  6633. * @param max defines maximum clamping value (default is 1)
  6634. * @param result defines color to store the result into.
  6635. * @returns the cuurent Color4
  6636. */
  6637. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  6638. /**
  6639. * Multipy an Color4 value by another and return a new Color4 object
  6640. * @param color defines the Color4 value to multiply by
  6641. * @returns a new Color4 object
  6642. */
  6643. multiply(color: Color4): Color4;
  6644. /**
  6645. * Multipy a Color4 value by another and push the result in a reference value
  6646. * @param color defines the Color4 value to multiply by
  6647. * @param result defines the Color4 to fill the result in
  6648. * @returns the result Color4
  6649. */
  6650. multiplyToRef(color: Color4, result: Color4): Color4;
  6651. /**
  6652. * Creates a string with the Color4 current values
  6653. * @returns the string representation of the Color4 object
  6654. */
  6655. toString(): string;
  6656. /**
  6657. * Returns the string "Color4"
  6658. * @returns "Color4"
  6659. */
  6660. getClassName(): string;
  6661. /**
  6662. * Compute the Color4 hash code
  6663. * @returns an unique number that can be used to hash Color4 objects
  6664. */
  6665. getHashCode(): number;
  6666. /**
  6667. * Creates a new Color4 copied from the current one
  6668. * @returns a new Color4 object
  6669. */
  6670. clone(): Color4;
  6671. /**
  6672. * Copies the given Color4 values into the current one
  6673. * @param source defines the source Color4 object
  6674. * @returns the current updated Color4 object
  6675. */
  6676. copyFrom(source: Color4): Color4;
  6677. /**
  6678. * Copies the given float values into the current one
  6679. * @param r defines the red component to read from
  6680. * @param g defines the green component to read from
  6681. * @param b defines the blue component to read from
  6682. * @param a defines the alpha component to read from
  6683. * @returns the current updated Color4 object
  6684. */
  6685. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  6686. /**
  6687. * Copies the given float values into the current one
  6688. * @param r defines the red component to read from
  6689. * @param g defines the green component to read from
  6690. * @param b defines the blue component to read from
  6691. * @param a defines the alpha component to read from
  6692. * @returns the current updated Color4 object
  6693. */
  6694. set(r: number, g: number, b: number, a: number): Color4;
  6695. /**
  6696. * Compute the Color4 hexadecimal code as a string
  6697. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  6698. * @returns a string containing the hexadecimal representation of the Color4 object
  6699. */
  6700. toHexString(returnAsColor3?: boolean): string;
  6701. /**
  6702. * Computes a new Color4 converted from the current one to linear space
  6703. * @returns a new Color4 object
  6704. */
  6705. toLinearSpace(): Color4;
  6706. /**
  6707. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  6708. * @param convertedColor defines the Color4 object where to store the linear space version
  6709. * @returns the unmodified Color4
  6710. */
  6711. toLinearSpaceToRef(convertedColor: Color4): Color4;
  6712. /**
  6713. * Computes a new Color4 converted from the current one to gamma space
  6714. * @returns a new Color4 object
  6715. */
  6716. toGammaSpace(): Color4;
  6717. /**
  6718. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  6719. * @param convertedColor defines the Color4 object where to store the gamma space version
  6720. * @returns the unmodified Color4
  6721. */
  6722. toGammaSpaceToRef(convertedColor: Color4): Color4;
  6723. /**
  6724. * Creates a new Color4 from the string containing valid hexadecimal values
  6725. * @param hex defines a string containing valid hexadecimal values
  6726. * @returns a new Color4 object
  6727. */
  6728. static FromHexString(hex: string): Color4;
  6729. /**
  6730. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  6731. * @param left defines the start value
  6732. * @param right defines the end value
  6733. * @param amount defines the gradient factor
  6734. * @returns a new Color4 object
  6735. */
  6736. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  6737. /**
  6738. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  6739. * @param left defines the start value
  6740. * @param right defines the end value
  6741. * @param amount defines the gradient factor
  6742. * @param result defines the Color4 object where to store data
  6743. */
  6744. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  6745. /**
  6746. * Creates a new Color4 from a Color3 and an alpha value
  6747. * @param color3 defines the source Color3 to read from
  6748. * @param alpha defines the alpha component (1.0 by default)
  6749. * @returns a new Color4 object
  6750. */
  6751. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  6752. /**
  6753. * Creates a new Color4 from the starting index element of the given array
  6754. * @param array defines the source array to read from
  6755. * @param offset defines the offset in the source array
  6756. * @returns a new Color4 object
  6757. */
  6758. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  6759. /**
  6760. * Creates a new Color4 from the starting index element of the given array
  6761. * @param array defines the source array to read from
  6762. * @param offset defines the offset in the source array
  6763. * @param result defines the target Color4 object
  6764. */
  6765. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color4): void;
  6766. /**
  6767. * Creates a new Color3 from integer values (< 256)
  6768. * @param r defines the red component to read from (value between 0 and 255)
  6769. * @param g defines the green component to read from (value between 0 and 255)
  6770. * @param b defines the blue component to read from (value between 0 and 255)
  6771. * @param a defines the alpha component to read from (value between 0 and 255)
  6772. * @returns a new Color3 object
  6773. */
  6774. static FromInts(r: number, g: number, b: number, a: number): Color4;
  6775. /**
  6776. * Check the content of a given array and convert it to an array containing RGBA data
  6777. * If the original array was already containing count * 4 values then it is returned directly
  6778. * @param colors defines the array to check
  6779. * @param count defines the number of RGBA data to expect
  6780. * @returns an array containing count * 4 values (RGBA)
  6781. */
  6782. static CheckColors4(colors: number[], count: number): number[];
  6783. }
  6784. /**
  6785. * @hidden
  6786. */
  6787. export class TmpColors {
  6788. static Color3: Color3[];
  6789. static Color4: Color4[];
  6790. }
  6791. }
  6792. declare module BABYLON {
  6793. /**
  6794. * Defines an interface which represents an animation key frame
  6795. */
  6796. export interface IAnimationKey {
  6797. /**
  6798. * Frame of the key frame
  6799. */
  6800. frame: number;
  6801. /**
  6802. * Value at the specifies key frame
  6803. */
  6804. value: any;
  6805. /**
  6806. * The input tangent for the cubic hermite spline
  6807. */
  6808. inTangent?: any;
  6809. /**
  6810. * The output tangent for the cubic hermite spline
  6811. */
  6812. outTangent?: any;
  6813. /**
  6814. * The animation interpolation type
  6815. */
  6816. interpolation?: AnimationKeyInterpolation;
  6817. }
  6818. /**
  6819. * Enum for the animation key frame interpolation type
  6820. */
  6821. export enum AnimationKeyInterpolation {
  6822. /**
  6823. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6824. */
  6825. STEP = 1
  6826. }
  6827. }
  6828. declare module BABYLON {
  6829. /**
  6830. * Represents the range of an animation
  6831. */
  6832. export class AnimationRange {
  6833. /**The name of the animation range**/
  6834. name: string;
  6835. /**The starting frame of the animation */
  6836. from: number;
  6837. /**The ending frame of the animation*/
  6838. to: number;
  6839. /**
  6840. * Initializes the range of an animation
  6841. * @param name The name of the animation range
  6842. * @param from The starting frame of the animation
  6843. * @param to The ending frame of the animation
  6844. */
  6845. constructor(
  6846. /**The name of the animation range**/
  6847. name: string,
  6848. /**The starting frame of the animation */
  6849. from: number,
  6850. /**The ending frame of the animation*/
  6851. to: number);
  6852. /**
  6853. * Makes a copy of the animation range
  6854. * @returns A copy of the animation range
  6855. */
  6856. clone(): AnimationRange;
  6857. }
  6858. }
  6859. declare module BABYLON {
  6860. /**
  6861. * Composed of a frame, and an action function
  6862. */
  6863. export class AnimationEvent {
  6864. /** The frame for which the event is triggered **/
  6865. frame: number;
  6866. /** The event to perform when triggered **/
  6867. action: (currentFrame: number) => void;
  6868. /** Specifies if the event should be triggered only once**/
  6869. onlyOnce?: boolean | undefined;
  6870. /**
  6871. * Specifies if the animation event is done
  6872. */
  6873. isDone: boolean;
  6874. /**
  6875. * Initializes the animation event
  6876. * @param frame The frame for which the event is triggered
  6877. * @param action The event to perform when triggered
  6878. * @param onlyOnce Specifies if the event should be triggered only once
  6879. */
  6880. constructor(
  6881. /** The frame for which the event is triggered **/
  6882. frame: number,
  6883. /** The event to perform when triggered **/
  6884. action: (currentFrame: number) => void,
  6885. /** Specifies if the event should be triggered only once**/
  6886. onlyOnce?: boolean | undefined);
  6887. /** @hidden */
  6888. _clone(): AnimationEvent;
  6889. }
  6890. }
  6891. declare module BABYLON {
  6892. /**
  6893. * Interface used to define a behavior
  6894. */
  6895. export interface Behavior<T> {
  6896. /** gets or sets behavior's name */
  6897. name: string;
  6898. /**
  6899. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6900. */
  6901. init(): void;
  6902. /**
  6903. * Called when the behavior is attached to a target
  6904. * @param target defines the target where the behavior is attached to
  6905. */
  6906. attach(target: T): void;
  6907. /**
  6908. * Called when the behavior is detached from its target
  6909. */
  6910. detach(): void;
  6911. }
  6912. /**
  6913. * Interface implemented by classes supporting behaviors
  6914. */
  6915. export interface IBehaviorAware<T> {
  6916. /**
  6917. * Attach a behavior
  6918. * @param behavior defines the behavior to attach
  6919. * @returns the current host
  6920. */
  6921. addBehavior(behavior: Behavior<T>): T;
  6922. /**
  6923. * Remove a behavior from the current object
  6924. * @param behavior defines the behavior to detach
  6925. * @returns the current host
  6926. */
  6927. removeBehavior(behavior: Behavior<T>): T;
  6928. /**
  6929. * Gets a behavior using its name to search
  6930. * @param name defines the name to search
  6931. * @returns the behavior or null if not found
  6932. */
  6933. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6934. }
  6935. }
  6936. declare module BABYLON {
  6937. /**
  6938. * Class used to provide helpers for slicing
  6939. */
  6940. export class SliceTools {
  6941. /**
  6942. * Provides a slice function that will work even on IE
  6943. * @param data defines the array to slice
  6944. * @param start defines the start of the data (optional)
  6945. * @param end defines the end of the data (optional)
  6946. * @returns the new sliced array
  6947. */
  6948. static Slice<T>(data: T, start?: number, end?: number): T;
  6949. /**
  6950. * Provides a slice function that will work even on IE
  6951. * The difference between this and Slice is that this will force-convert to array
  6952. * @param data defines the array to slice
  6953. * @param start defines the start of the data (optional)
  6954. * @param end defines the end of the data (optional)
  6955. * @returns the new sliced array
  6956. */
  6957. static SliceToArray<T, P>(data: T, start?: number, end?: number): Array<P>;
  6958. }
  6959. }
  6960. declare module BABYLON {
  6961. /**
  6962. * Class used to store data that will be store in GPU memory
  6963. */
  6964. export class Buffer {
  6965. private _engine;
  6966. private _buffer;
  6967. /** @hidden */
  6968. _data: Nullable<DataArray>;
  6969. private _updatable;
  6970. private _instanced;
  6971. private _divisor;
  6972. private _isAlreadyOwned;
  6973. /**
  6974. * Gets the byte stride.
  6975. */
  6976. readonly byteStride: number;
  6977. /**
  6978. * Constructor
  6979. * @param engine the engine
  6980. * @param data the data to use for this buffer
  6981. * @param updatable whether the data is updatable
  6982. * @param stride the stride (optional)
  6983. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6984. * @param instanced whether the buffer is instanced (optional)
  6985. * @param useBytes set to true if the stride in in bytes (optional)
  6986. * @param divisor sets an optional divisor for instances (1 by default)
  6987. */
  6988. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6989. /**
  6990. * Create a new VertexBuffer based on the current buffer
  6991. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6992. * @param offset defines offset in the buffer (0 by default)
  6993. * @param size defines the size in floats of attributes (position is 3 for instance)
  6994. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6995. * @param instanced defines if the vertex buffer contains indexed data
  6996. * @param useBytes defines if the offset and stride are in bytes *
  6997. * @param divisor sets an optional divisor for instances (1 by default)
  6998. * @returns the new vertex buffer
  6999. */
  7000. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  7001. /**
  7002. * Gets a boolean indicating if the Buffer is updatable?
  7003. * @returns true if the buffer is updatable
  7004. */
  7005. isUpdatable(): boolean;
  7006. /**
  7007. * Gets current buffer's data
  7008. * @returns a DataArray or null
  7009. */
  7010. getData(): Nullable<DataArray>;
  7011. /**
  7012. * Gets underlying native buffer
  7013. * @returns underlying native buffer
  7014. */
  7015. getBuffer(): Nullable<DataBuffer>;
  7016. /**
  7017. * Gets the stride in float32 units (i.e. byte stride / 4).
  7018. * May not be an integer if the byte stride is not divisible by 4.
  7019. * @returns the stride in float32 units
  7020. * @deprecated Please use byteStride instead.
  7021. */
  7022. getStrideSize(): number;
  7023. /**
  7024. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  7025. * @param data defines the data to store
  7026. */
  7027. create(data?: Nullable<DataArray>): void;
  7028. /** @hidden */
  7029. _rebuild(): void;
  7030. /**
  7031. * Update current buffer data
  7032. * @param data defines the data to store
  7033. */
  7034. update(data: DataArray): void;
  7035. /**
  7036. * Updates the data directly.
  7037. * @param data the new data
  7038. * @param offset the new offset
  7039. * @param vertexCount the vertex count (optional)
  7040. * @param useBytes set to true if the offset is in bytes
  7041. */
  7042. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  7043. /** @hidden */
  7044. _increaseReferences(): void;
  7045. /**
  7046. * Release all resources
  7047. */
  7048. dispose(): void;
  7049. }
  7050. /**
  7051. * Specialized buffer used to store vertex data
  7052. */
  7053. export class VertexBuffer {
  7054. private static _Counter;
  7055. /** @hidden */
  7056. _buffer: Buffer;
  7057. private _kind;
  7058. private _size;
  7059. private _ownsBuffer;
  7060. private _instanced;
  7061. private _instanceDivisor;
  7062. /**
  7063. * The byte type.
  7064. */
  7065. static readonly BYTE: number;
  7066. /**
  7067. * The unsigned byte type.
  7068. */
  7069. static readonly UNSIGNED_BYTE: number;
  7070. /**
  7071. * The short type.
  7072. */
  7073. static readonly SHORT: number;
  7074. /**
  7075. * The unsigned short type.
  7076. */
  7077. static readonly UNSIGNED_SHORT: number;
  7078. /**
  7079. * The integer type.
  7080. */
  7081. static readonly INT: number;
  7082. /**
  7083. * The unsigned integer type.
  7084. */
  7085. static readonly UNSIGNED_INT: number;
  7086. /**
  7087. * The float type.
  7088. */
  7089. static readonly FLOAT: number;
  7090. /**
  7091. * Gets or sets the instance divisor when in instanced mode
  7092. */
  7093. get instanceDivisor(): number;
  7094. set instanceDivisor(value: number);
  7095. /**
  7096. * Gets the byte stride.
  7097. */
  7098. readonly byteStride: number;
  7099. /**
  7100. * Gets the byte offset.
  7101. */
  7102. readonly byteOffset: number;
  7103. /**
  7104. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  7105. */
  7106. readonly normalized: boolean;
  7107. /**
  7108. * Gets the data type of each component in the array.
  7109. */
  7110. readonly type: number;
  7111. /**
  7112. * Gets the unique id of this vertex buffer
  7113. */
  7114. readonly uniqueId: number;
  7115. /**
  7116. * Constructor
  7117. * @param engine the engine
  7118. * @param data the data to use for this vertex buffer
  7119. * @param kind the vertex buffer kind
  7120. * @param updatable whether the data is updatable
  7121. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  7122. * @param stride the stride (optional)
  7123. * @param instanced whether the buffer is instanced (optional)
  7124. * @param offset the offset of the data (optional)
  7125. * @param size the number of components (optional)
  7126. * @param type the type of the component (optional)
  7127. * @param normalized whether the data contains normalized data (optional)
  7128. * @param useBytes set to true if stride and offset are in bytes (optional)
  7129. * @param divisor defines the instance divisor to use (1 by default)
  7130. * @param takeBufferOwnership defines if the buffer should be released when the vertex buffer is disposed
  7131. */
  7132. 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);
  7133. /** @hidden */
  7134. _rebuild(): void;
  7135. /**
  7136. * Returns the kind of the VertexBuffer (string)
  7137. * @returns a string
  7138. */
  7139. getKind(): string;
  7140. /**
  7141. * Gets a boolean indicating if the VertexBuffer is updatable?
  7142. * @returns true if the buffer is updatable
  7143. */
  7144. isUpdatable(): boolean;
  7145. /**
  7146. * Gets current buffer's data
  7147. * @returns a DataArray or null
  7148. */
  7149. getData(): Nullable<DataArray>;
  7150. /**
  7151. * Gets current buffer's data as a float array. Float data is constructed if the vertex buffer data cannot be returned directly.
  7152. * @param totalVertices number of vertices in the buffer to take into account
  7153. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  7154. * @returns a float array containing vertex data
  7155. */
  7156. getFloatData(totalVertices: number, forceCopy?: boolean): Nullable<FloatArray>;
  7157. /**
  7158. * Gets underlying native buffer
  7159. * @returns underlying native buffer
  7160. */
  7161. getBuffer(): Nullable<DataBuffer>;
  7162. /**
  7163. * Gets the stride in float32 units (i.e. byte stride / 4).
  7164. * May not be an integer if the byte stride is not divisible by 4.
  7165. * @returns the stride in float32 units
  7166. * @deprecated Please use byteStride instead.
  7167. */
  7168. getStrideSize(): number;
  7169. /**
  7170. * Returns the offset as a multiple of the type byte length.
  7171. * @returns the offset in bytes
  7172. * @deprecated Please use byteOffset instead.
  7173. */
  7174. getOffset(): number;
  7175. /**
  7176. * Returns the number of components per vertex attribute (integer)
  7177. * @returns the size in float
  7178. */
  7179. getSize(): number;
  7180. /**
  7181. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  7182. * @returns true if this buffer is instanced
  7183. */
  7184. getIsInstanced(): boolean;
  7185. /**
  7186. * Returns the instancing divisor, zero for non-instanced (integer).
  7187. * @returns a number
  7188. */
  7189. getInstanceDivisor(): number;
  7190. /**
  7191. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  7192. * @param data defines the data to store
  7193. */
  7194. create(data?: DataArray): void;
  7195. /**
  7196. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  7197. * This function will create a new buffer if the current one is not updatable
  7198. * @param data defines the data to store
  7199. */
  7200. update(data: DataArray): void;
  7201. /**
  7202. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  7203. * Returns the directly updated WebGLBuffer.
  7204. * @param data the new data
  7205. * @param offset the new offset
  7206. * @param useBytes set to true if the offset is in bytes
  7207. */
  7208. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  7209. /**
  7210. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  7211. */
  7212. dispose(): void;
  7213. /**
  7214. * Enumerates each value of this vertex buffer as numbers.
  7215. * @param count the number of values to enumerate
  7216. * @param callback the callback function called for each value
  7217. */
  7218. forEach(count: number, callback: (value: number, index: number) => void): void;
  7219. /**
  7220. * Positions
  7221. */
  7222. static readonly PositionKind: string;
  7223. /**
  7224. * Normals
  7225. */
  7226. static readonly NormalKind: string;
  7227. /**
  7228. * Tangents
  7229. */
  7230. static readonly TangentKind: string;
  7231. /**
  7232. * Texture coordinates
  7233. */
  7234. static readonly UVKind: string;
  7235. /**
  7236. * Texture coordinates 2
  7237. */
  7238. static readonly UV2Kind: string;
  7239. /**
  7240. * Texture coordinates 3
  7241. */
  7242. static readonly UV3Kind: string;
  7243. /**
  7244. * Texture coordinates 4
  7245. */
  7246. static readonly UV4Kind: string;
  7247. /**
  7248. * Texture coordinates 5
  7249. */
  7250. static readonly UV5Kind: string;
  7251. /**
  7252. * Texture coordinates 6
  7253. */
  7254. static readonly UV6Kind: string;
  7255. /**
  7256. * Colors
  7257. */
  7258. static readonly ColorKind: string;
  7259. /**
  7260. * Matrix indices (for bones)
  7261. */
  7262. static readonly MatricesIndicesKind: string;
  7263. /**
  7264. * Matrix weights (for bones)
  7265. */
  7266. static readonly MatricesWeightsKind: string;
  7267. /**
  7268. * Additional matrix indices (for bones)
  7269. */
  7270. static readonly MatricesIndicesExtraKind: string;
  7271. /**
  7272. * Additional matrix weights (for bones)
  7273. */
  7274. static readonly MatricesWeightsExtraKind: string;
  7275. /**
  7276. * Deduces the stride given a kind.
  7277. * @param kind The kind string to deduce
  7278. * @returns The deduced stride
  7279. */
  7280. static DeduceStride(kind: string): number;
  7281. /**
  7282. * Gets the byte length of the given type.
  7283. * @param type the type
  7284. * @returns the number of bytes
  7285. */
  7286. static GetTypeByteLength(type: number): number;
  7287. /**
  7288. * Enumerates each value of the given parameters as numbers.
  7289. * @param data the data to enumerate
  7290. * @param byteOffset the byte offset of the data
  7291. * @param byteStride the byte stride of the data
  7292. * @param componentCount the number of components per element
  7293. * @param componentType the type of the component
  7294. * @param count the number of values to enumerate
  7295. * @param normalized whether the data is normalized
  7296. * @param callback the callback function called for each value
  7297. */
  7298. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  7299. private static _GetFloatValue;
  7300. }
  7301. }
  7302. declare module BABYLON {
  7303. /**
  7304. * @hidden
  7305. */
  7306. export class IntersectionInfo {
  7307. bu: Nullable<number>;
  7308. bv: Nullable<number>;
  7309. distance: number;
  7310. faceId: number;
  7311. subMeshId: number;
  7312. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  7313. }
  7314. }
  7315. declare module BABYLON {
  7316. /**
  7317. * Class used to store bounding sphere information
  7318. */
  7319. export class BoundingSphere {
  7320. /**
  7321. * Gets the center of the bounding sphere in local space
  7322. */
  7323. readonly center: Vector3;
  7324. /**
  7325. * Radius of the bounding sphere in local space
  7326. */
  7327. radius: number;
  7328. /**
  7329. * Gets the center of the bounding sphere in world space
  7330. */
  7331. readonly centerWorld: Vector3;
  7332. /**
  7333. * Radius of the bounding sphere in world space
  7334. */
  7335. radiusWorld: number;
  7336. /**
  7337. * Gets the minimum vector in local space
  7338. */
  7339. readonly minimum: Vector3;
  7340. /**
  7341. * Gets the maximum vector in local space
  7342. */
  7343. readonly maximum: Vector3;
  7344. private _worldMatrix;
  7345. private static readonly TmpVector3;
  7346. /**
  7347. * Creates a new bounding sphere
  7348. * @param min defines the minimum vector (in local space)
  7349. * @param max defines the maximum vector (in local space)
  7350. * @param worldMatrix defines the new world matrix
  7351. */
  7352. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7353. /**
  7354. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  7355. * @param min defines the new minimum vector (in local space)
  7356. * @param max defines the new maximum vector (in local space)
  7357. * @param worldMatrix defines the new world matrix
  7358. */
  7359. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7360. /**
  7361. * Scale the current bounding sphere by applying a scale factor
  7362. * @param factor defines the scale factor to apply
  7363. * @returns the current bounding box
  7364. */
  7365. scale(factor: number): BoundingSphere;
  7366. /**
  7367. * Gets the world matrix of the bounding box
  7368. * @returns a matrix
  7369. */
  7370. getWorldMatrix(): DeepImmutable<Matrix>;
  7371. /** @hidden */
  7372. _update(worldMatrix: DeepImmutable<Matrix>): void;
  7373. /**
  7374. * Tests if the bounding sphere is intersecting the frustum planes
  7375. * @param frustumPlanes defines the frustum planes to test
  7376. * @returns true if there is an intersection
  7377. */
  7378. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7379. /**
  7380. * Tests if the bounding sphere center is in between the frustum planes.
  7381. * Used for optimistic fast inclusion.
  7382. * @param frustumPlanes defines the frustum planes to test
  7383. * @returns true if the sphere center is in between the frustum planes
  7384. */
  7385. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7386. /**
  7387. * Tests if a point is inside the bounding sphere
  7388. * @param point defines the point to test
  7389. * @returns true if the point is inside the bounding sphere
  7390. */
  7391. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7392. /**
  7393. * Checks if two sphere intersct
  7394. * @param sphere0 sphere 0
  7395. * @param sphere1 sphere 1
  7396. * @returns true if the speres intersect
  7397. */
  7398. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  7399. }
  7400. }
  7401. declare module BABYLON {
  7402. /**
  7403. * Class used to store bounding box information
  7404. */
  7405. export class BoundingBox implements ICullable {
  7406. /**
  7407. * Gets the 8 vectors representing the bounding box in local space
  7408. */
  7409. readonly vectors: Vector3[];
  7410. /**
  7411. * Gets the center of the bounding box in local space
  7412. */
  7413. readonly center: Vector3;
  7414. /**
  7415. * Gets the center of the bounding box in world space
  7416. */
  7417. readonly centerWorld: Vector3;
  7418. /**
  7419. * Gets the extend size in local space
  7420. */
  7421. readonly extendSize: Vector3;
  7422. /**
  7423. * Gets the extend size in world space
  7424. */
  7425. readonly extendSizeWorld: Vector3;
  7426. /**
  7427. * Gets the OBB (object bounding box) directions
  7428. */
  7429. readonly directions: Vector3[];
  7430. /**
  7431. * Gets the 8 vectors representing the bounding box in world space
  7432. */
  7433. readonly vectorsWorld: Vector3[];
  7434. /**
  7435. * Gets the minimum vector in world space
  7436. */
  7437. readonly minimumWorld: Vector3;
  7438. /**
  7439. * Gets the maximum vector in world space
  7440. */
  7441. readonly maximumWorld: Vector3;
  7442. /**
  7443. * Gets the minimum vector in local space
  7444. */
  7445. readonly minimum: Vector3;
  7446. /**
  7447. * Gets the maximum vector in local space
  7448. */
  7449. readonly maximum: Vector3;
  7450. private _worldMatrix;
  7451. private static readonly TmpVector3;
  7452. /**
  7453. * @hidden
  7454. */
  7455. _tag: number;
  7456. /**
  7457. * Creates a new bounding box
  7458. * @param min defines the minimum vector (in local space)
  7459. * @param max defines the maximum vector (in local space)
  7460. * @param worldMatrix defines the new world matrix
  7461. */
  7462. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7463. /**
  7464. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7465. * @param min defines the new minimum vector (in local space)
  7466. * @param max defines the new maximum vector (in local space)
  7467. * @param worldMatrix defines the new world matrix
  7468. */
  7469. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7470. /**
  7471. * Scale the current bounding box by applying a scale factor
  7472. * @param factor defines the scale factor to apply
  7473. * @returns the current bounding box
  7474. */
  7475. scale(factor: number): BoundingBox;
  7476. /**
  7477. * Gets the world matrix of the bounding box
  7478. * @returns a matrix
  7479. */
  7480. getWorldMatrix(): DeepImmutable<Matrix>;
  7481. /** @hidden */
  7482. _update(world: DeepImmutable<Matrix>): void;
  7483. /**
  7484. * Tests if the bounding box is intersecting the frustum planes
  7485. * @param frustumPlanes defines the frustum planes to test
  7486. * @returns true if there is an intersection
  7487. */
  7488. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7489. /**
  7490. * Tests if the bounding box is entirely inside the frustum planes
  7491. * @param frustumPlanes defines the frustum planes to test
  7492. * @returns true if there is an inclusion
  7493. */
  7494. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7495. /**
  7496. * Tests if a point is inside the bounding box
  7497. * @param point defines the point to test
  7498. * @returns true if the point is inside the bounding box
  7499. */
  7500. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7501. /**
  7502. * Tests if the bounding box intersects with a bounding sphere
  7503. * @param sphere defines the sphere to test
  7504. * @returns true if there is an intersection
  7505. */
  7506. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7507. /**
  7508. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7509. * @param min defines the min vector to use
  7510. * @param max defines the max vector to use
  7511. * @returns true if there is an intersection
  7512. */
  7513. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7514. /**
  7515. * Tests if two bounding boxes are intersections
  7516. * @param box0 defines the first box to test
  7517. * @param box1 defines the second box to test
  7518. * @returns true if there is an intersection
  7519. */
  7520. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7521. /**
  7522. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7523. * @param minPoint defines the minimum vector of the bounding box
  7524. * @param maxPoint defines the maximum vector of the bounding box
  7525. * @param sphereCenter defines the sphere center
  7526. * @param sphereRadius defines the sphere radius
  7527. * @returns true if there is an intersection
  7528. */
  7529. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7530. /**
  7531. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7532. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7533. * @param frustumPlanes defines the frustum planes to test
  7534. * @return true if there is an inclusion
  7535. */
  7536. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7537. /**
  7538. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7539. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7540. * @param frustumPlanes defines the frustum planes to test
  7541. * @return true if there is an intersection
  7542. */
  7543. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7544. }
  7545. }
  7546. declare module BABYLON {
  7547. /** @hidden */
  7548. export class Collider {
  7549. /** Define if a collision was found */
  7550. collisionFound: boolean;
  7551. /**
  7552. * Define last intersection point in local space
  7553. */
  7554. intersectionPoint: Vector3;
  7555. /**
  7556. * Define last collided mesh
  7557. */
  7558. collidedMesh: Nullable<AbstractMesh>;
  7559. private _collisionPoint;
  7560. private _planeIntersectionPoint;
  7561. private _tempVector;
  7562. private _tempVector2;
  7563. private _tempVector3;
  7564. private _tempVector4;
  7565. private _edge;
  7566. private _baseToVertex;
  7567. private _destinationPoint;
  7568. private _slidePlaneNormal;
  7569. private _displacementVector;
  7570. /** @hidden */
  7571. _radius: Vector3;
  7572. /** @hidden */
  7573. _retry: number;
  7574. private _velocity;
  7575. private _basePoint;
  7576. private _epsilon;
  7577. /** @hidden */
  7578. _velocityWorldLength: number;
  7579. /** @hidden */
  7580. _basePointWorld: Vector3;
  7581. private _velocityWorld;
  7582. private _normalizedVelocity;
  7583. /** @hidden */
  7584. _initialVelocity: Vector3;
  7585. /** @hidden */
  7586. _initialPosition: Vector3;
  7587. private _nearestDistance;
  7588. private _collisionMask;
  7589. get collisionMask(): number;
  7590. set collisionMask(mask: number);
  7591. /**
  7592. * Gets the plane normal used to compute the sliding response (in local space)
  7593. */
  7594. get slidePlaneNormal(): Vector3;
  7595. /** @hidden */
  7596. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7597. /** @hidden */
  7598. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7599. /** @hidden */
  7600. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7601. /** @hidden */
  7602. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7603. /** @hidden */
  7604. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7605. /** @hidden */
  7606. _getResponse(pos: Vector3, vel: Vector3): void;
  7607. }
  7608. }
  7609. declare module BABYLON {
  7610. /**
  7611. * Interface for cullable objects
  7612. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7613. */
  7614. export interface ICullable {
  7615. /**
  7616. * Checks if the object or part of the object is in the frustum
  7617. * @param frustumPlanes Camera near/planes
  7618. * @returns true if the object is in frustum otherwise false
  7619. */
  7620. isInFrustum(frustumPlanes: Plane[]): boolean;
  7621. /**
  7622. * Checks if a cullable object (mesh...) is in the camera frustum
  7623. * Unlike isInFrustum this cheks the full bounding box
  7624. * @param frustumPlanes Camera near/planes
  7625. * @returns true if the object is in frustum otherwise false
  7626. */
  7627. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7628. }
  7629. /**
  7630. * Info for a bounding data of a mesh
  7631. */
  7632. export class BoundingInfo implements ICullable {
  7633. /**
  7634. * Bounding box for the mesh
  7635. */
  7636. readonly boundingBox: BoundingBox;
  7637. /**
  7638. * Bounding sphere for the mesh
  7639. */
  7640. readonly boundingSphere: BoundingSphere;
  7641. private _isLocked;
  7642. private static readonly TmpVector3;
  7643. /**
  7644. * Constructs bounding info
  7645. * @param minimum min vector of the bounding box/sphere
  7646. * @param maximum max vector of the bounding box/sphere
  7647. * @param worldMatrix defines the new world matrix
  7648. */
  7649. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7650. /**
  7651. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7652. * @param min defines the new minimum vector (in local space)
  7653. * @param max defines the new maximum vector (in local space)
  7654. * @param worldMatrix defines the new world matrix
  7655. */
  7656. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7657. /**
  7658. * min vector of the bounding box/sphere
  7659. */
  7660. get minimum(): Vector3;
  7661. /**
  7662. * max vector of the bounding box/sphere
  7663. */
  7664. get maximum(): Vector3;
  7665. /**
  7666. * If the info is locked and won't be updated to avoid perf overhead
  7667. */
  7668. get isLocked(): boolean;
  7669. set isLocked(value: boolean);
  7670. /**
  7671. * Updates the bounding sphere and box
  7672. * @param world world matrix to be used to update
  7673. */
  7674. update(world: DeepImmutable<Matrix>): void;
  7675. /**
  7676. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7677. * @param center New center of the bounding info
  7678. * @param extend New extend of the bounding info
  7679. * @returns the current bounding info
  7680. */
  7681. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7682. /**
  7683. * Grows the bounding info to include the given point.
  7684. * @param point The point that will be included in the current bounding info
  7685. * @returns the current bounding info
  7686. */
  7687. encapsulate(point: Vector3): BoundingInfo;
  7688. /**
  7689. * Grows the bounding info to encapsulate the given bounding info.
  7690. * @param toEncapsulate The bounding info that will be encapsulated in the current bounding info
  7691. * @returns the current bounding info
  7692. */
  7693. encapsulateBoundingInfo(toEncapsulate: BoundingInfo): BoundingInfo;
  7694. /**
  7695. * Scale the current bounding info by applying a scale factor
  7696. * @param factor defines the scale factor to apply
  7697. * @returns the current bounding info
  7698. */
  7699. scale(factor: number): BoundingInfo;
  7700. /**
  7701. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7702. * @param frustumPlanes defines the frustum to test
  7703. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7704. * @returns true if the bounding info is in the frustum planes
  7705. */
  7706. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7707. /**
  7708. * Gets the world distance between the min and max points of the bounding box
  7709. */
  7710. get diagonalLength(): number;
  7711. /**
  7712. * Checks if a cullable object (mesh...) is in the camera frustum
  7713. * Unlike isInFrustum this cheks the full bounding box
  7714. * @param frustumPlanes Camera near/planes
  7715. * @returns true if the object is in frustum otherwise false
  7716. */
  7717. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7718. /** @hidden */
  7719. _checkCollision(collider: Collider): boolean;
  7720. /**
  7721. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7722. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7723. * @param point the point to check intersection with
  7724. * @returns if the point intersects
  7725. */
  7726. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7727. /**
  7728. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7729. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7730. * @param boundingInfo the bounding info to check intersection with
  7731. * @param precise if the intersection should be done using OBB
  7732. * @returns if the bounding info intersects
  7733. */
  7734. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7735. }
  7736. }
  7737. declare module BABYLON {
  7738. /**
  7739. * Extracts minimum and maximum values from a list of indexed positions
  7740. * @param positions defines the positions to use
  7741. * @param indices defines the indices to the positions
  7742. * @param indexStart defines the start index
  7743. * @param indexCount defines the end index
  7744. * @param bias defines bias value to add to the result
  7745. * @return minimum and maximum values
  7746. */
  7747. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7748. minimum: Vector3;
  7749. maximum: Vector3;
  7750. };
  7751. /**
  7752. * Extracts minimum and maximum values from a list of positions
  7753. * @param positions defines the positions to use
  7754. * @param start defines the start index in the positions array
  7755. * @param count defines the number of positions to handle
  7756. * @param bias defines bias value to add to the result
  7757. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7758. * @return minimum and maximum values
  7759. */
  7760. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7761. minimum: Vector3;
  7762. maximum: Vector3;
  7763. };
  7764. }
  7765. declare module BABYLON {
  7766. /**
  7767. * Class used to manipulate GUIDs
  7768. */
  7769. export class GUID {
  7770. /**
  7771. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  7772. * Be aware Math.random() could cause collisions, but:
  7773. * "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"
  7774. * @returns a pseudo random id
  7775. */
  7776. static RandomId(): string;
  7777. }
  7778. }
  7779. declare module BABYLON {
  7780. /**
  7781. * Base class of all the textures in babylon.
  7782. * It groups all the common properties the materials, post process, lights... might need
  7783. * in order to make a correct use of the texture.
  7784. */
  7785. export class BaseTexture extends ThinTexture implements IAnimatable {
  7786. /**
  7787. * Default anisotropic filtering level for the application.
  7788. * It is set to 4 as a good tradeoff between perf and quality.
  7789. */
  7790. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  7791. /**
  7792. * Gets or sets the unique id of the texture
  7793. */
  7794. uniqueId: number;
  7795. /**
  7796. * Define the name of the texture.
  7797. */
  7798. name: string;
  7799. /**
  7800. * Gets or sets an object used to store user defined information.
  7801. */
  7802. metadata: any;
  7803. /**
  7804. * For internal use only. Please do not use.
  7805. */
  7806. reservedDataStore: any;
  7807. private _hasAlpha;
  7808. /**
  7809. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  7810. */
  7811. set hasAlpha(value: boolean);
  7812. get hasAlpha(): boolean;
  7813. /**
  7814. * Defines if the alpha value should be determined via the rgb values.
  7815. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  7816. */
  7817. getAlphaFromRGB: boolean;
  7818. /**
  7819. * Intensity or strength of the texture.
  7820. * It is commonly used by materials to fine tune the intensity of the texture
  7821. */
  7822. level: number;
  7823. /**
  7824. * Define the UV chanel to use starting from 0 and defaulting to 0.
  7825. * This is part of the texture as textures usually maps to one uv set.
  7826. */
  7827. coordinatesIndex: number;
  7828. protected _coordinatesMode: number;
  7829. /**
  7830. * How a texture is mapped.
  7831. *
  7832. * | Value | Type | Description |
  7833. * | ----- | ----------------------------------- | ----------- |
  7834. * | 0 | EXPLICIT_MODE | |
  7835. * | 1 | SPHERICAL_MODE | |
  7836. * | 2 | PLANAR_MODE | |
  7837. * | 3 | CUBIC_MODE | |
  7838. * | 4 | PROJECTION_MODE | |
  7839. * | 5 | SKYBOX_MODE | |
  7840. * | 6 | INVCUBIC_MODE | |
  7841. * | 7 | EQUIRECTANGULAR_MODE | |
  7842. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  7843. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  7844. */
  7845. set coordinatesMode(value: number);
  7846. get coordinatesMode(): number;
  7847. /**
  7848. * | Value | Type | Description |
  7849. * | ----- | ------------------ | ----------- |
  7850. * | 0 | CLAMP_ADDRESSMODE | |
  7851. * | 1 | WRAP_ADDRESSMODE | |
  7852. * | 2 | MIRROR_ADDRESSMODE | |
  7853. */
  7854. get wrapU(): number;
  7855. set wrapU(value: number);
  7856. /**
  7857. * | Value | Type | Description |
  7858. * | ----- | ------------------ | ----------- |
  7859. * | 0 | CLAMP_ADDRESSMODE | |
  7860. * | 1 | WRAP_ADDRESSMODE | |
  7861. * | 2 | MIRROR_ADDRESSMODE | |
  7862. */
  7863. get wrapV(): number;
  7864. set wrapV(value: number);
  7865. /**
  7866. * | Value | Type | Description |
  7867. * | ----- | ------------------ | ----------- |
  7868. * | 0 | CLAMP_ADDRESSMODE | |
  7869. * | 1 | WRAP_ADDRESSMODE | |
  7870. * | 2 | MIRROR_ADDRESSMODE | |
  7871. */
  7872. wrapR: number;
  7873. /**
  7874. * With compliant hardware and browser (supporting anisotropic filtering)
  7875. * this defines the level of anisotropic filtering in the texture.
  7876. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  7877. */
  7878. anisotropicFilteringLevel: number;
  7879. private _isCube;
  7880. /**
  7881. * Define if the texture is a cube texture or if false a 2d texture.
  7882. */
  7883. get isCube(): boolean;
  7884. set isCube(value: boolean);
  7885. /**
  7886. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  7887. */
  7888. get is3D(): boolean;
  7889. set is3D(value: boolean);
  7890. /**
  7891. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  7892. */
  7893. get is2DArray(): boolean;
  7894. set is2DArray(value: boolean);
  7895. private _gammaSpace;
  7896. /**
  7897. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  7898. * HDR texture are usually stored in linear space.
  7899. * This only impacts the PBR and Background materials
  7900. */
  7901. get gammaSpace(): boolean;
  7902. set gammaSpace(gamma: boolean);
  7903. /**
  7904. * Gets or sets whether or not the texture contains RGBD data.
  7905. */
  7906. get isRGBD(): boolean;
  7907. set isRGBD(value: boolean);
  7908. /**
  7909. * Is Z inverted in the texture (useful in a cube texture).
  7910. */
  7911. invertZ: boolean;
  7912. /**
  7913. * Are mip maps generated for this texture or not.
  7914. */
  7915. get noMipmap(): boolean;
  7916. /**
  7917. * @hidden
  7918. */
  7919. lodLevelInAlpha: boolean;
  7920. /**
  7921. * With prefiltered texture, defined the offset used during the prefiltering steps.
  7922. */
  7923. get lodGenerationOffset(): number;
  7924. set lodGenerationOffset(value: number);
  7925. /**
  7926. * With prefiltered texture, defined the scale used during the prefiltering steps.
  7927. */
  7928. get lodGenerationScale(): number;
  7929. set lodGenerationScale(value: number);
  7930. /**
  7931. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  7932. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  7933. * average roughness values.
  7934. */
  7935. get linearSpecularLOD(): boolean;
  7936. set linearSpecularLOD(value: boolean);
  7937. /**
  7938. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  7939. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  7940. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  7941. */
  7942. get irradianceTexture(): Nullable<BaseTexture>;
  7943. set irradianceTexture(value: Nullable<BaseTexture>);
  7944. /**
  7945. * Define if the texture is a render target.
  7946. */
  7947. isRenderTarget: boolean;
  7948. /**
  7949. * Define the unique id of the texture in the scene.
  7950. */
  7951. get uid(): string;
  7952. /** @hidden */
  7953. _prefiltered: boolean;
  7954. /**
  7955. * Return a string representation of the texture.
  7956. * @returns the texture as a string
  7957. */
  7958. toString(): string;
  7959. /**
  7960. * Get the class name of the texture.
  7961. * @returns "BaseTexture"
  7962. */
  7963. getClassName(): string;
  7964. /**
  7965. * Define the list of animation attached to the texture.
  7966. */
  7967. animations: Animation[];
  7968. /**
  7969. * An event triggered when the texture is disposed.
  7970. */
  7971. onDisposeObservable: Observable<BaseTexture>;
  7972. private _onDisposeObserver;
  7973. /**
  7974. * Callback triggered when the texture has been disposed.
  7975. * Kept for back compatibility, you can use the onDisposeObservable instead.
  7976. */
  7977. set onDispose(callback: () => void);
  7978. protected _scene: Nullable<Scene>;
  7979. /** @hidden */
  7980. _texture: Nullable<InternalTexture>;
  7981. private _uid;
  7982. /**
  7983. * Define if the texture is preventinga material to render or not.
  7984. * If not and the texture is not ready, the engine will use a default black texture instead.
  7985. */
  7986. get isBlocking(): boolean;
  7987. /**
  7988. * Instantiates a new BaseTexture.
  7989. * Base class of all the textures in babylon.
  7990. * It groups all the common properties the materials, post process, lights... might need
  7991. * in order to make a correct use of the texture.
  7992. * @param sceneOrEngine Define the scene or engine the texture blongs to
  7993. */
  7994. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  7995. /**
  7996. * Get the scene the texture belongs to.
  7997. * @returns the scene or null if undefined
  7998. */
  7999. getScene(): Nullable<Scene>;
  8000. /** @hidden */
  8001. protected _getEngine(): Nullable<ThinEngine>;
  8002. /**
  8003. * Checks if the texture has the same transform matrix than another texture
  8004. * @param texture texture to check against
  8005. * @returns true if the transforms are the same, else false
  8006. */
  8007. checkTransformsAreIdentical(texture: Nullable<BaseTexture>): boolean;
  8008. /**
  8009. * Get the texture transform matrix used to offset tile the texture for istance.
  8010. * @returns the transformation matrix
  8011. */
  8012. getTextureMatrix(): Matrix;
  8013. /**
  8014. * Get the texture reflection matrix used to rotate/transform the reflection.
  8015. * @returns the reflection matrix
  8016. */
  8017. getReflectionTextureMatrix(): Matrix;
  8018. /**
  8019. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  8020. * @returns true if ready or not blocking
  8021. */
  8022. isReadyOrNotBlocking(): boolean;
  8023. /**
  8024. * Scales the texture if is `canRescale()`
  8025. * @param ratio the resize factor we want to use to rescale
  8026. */
  8027. scale(ratio: number): void;
  8028. /**
  8029. * Get if the texture can rescale.
  8030. */
  8031. get canRescale(): boolean;
  8032. /** @hidden */
  8033. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  8034. /** @hidden */
  8035. _rebuild(): void;
  8036. /**
  8037. * Clones the texture.
  8038. * @returns the cloned texture
  8039. */
  8040. clone(): Nullable<BaseTexture>;
  8041. /**
  8042. * Get the texture underlying type (INT, FLOAT...)
  8043. */
  8044. get textureType(): number;
  8045. /**
  8046. * Get the texture underlying format (RGB, RGBA...)
  8047. */
  8048. get textureFormat(): number;
  8049. /**
  8050. * Indicates that textures need to be re-calculated for all materials
  8051. */
  8052. protected _markAllSubMeshesAsTexturesDirty(): void;
  8053. /**
  8054. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  8055. * This will returns an RGBA array buffer containing either in values (0-255) or
  8056. * float values (0-1) depending of the underlying buffer type.
  8057. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  8058. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  8059. * @param buffer defines a user defined buffer to fill with data (can be null)
  8060. * @param flushRenderer true to flush the renderer from the pending commands before reading the pixels
  8061. * @returns The Array buffer promise containing the pixels data.
  8062. */
  8063. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>, flushRenderer?: boolean): Nullable<Promise<ArrayBufferView>>;
  8064. /** @hidden */
  8065. _readPixelsSync(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>, flushRenderer?: boolean): Nullable<ArrayBufferView>;
  8066. /** @hidden */
  8067. get _lodTextureHigh(): Nullable<BaseTexture>;
  8068. /** @hidden */
  8069. get _lodTextureMid(): Nullable<BaseTexture>;
  8070. /** @hidden */
  8071. get _lodTextureLow(): Nullable<BaseTexture>;
  8072. /**
  8073. * Dispose the texture and release its associated resources.
  8074. */
  8075. dispose(): void;
  8076. /**
  8077. * Serialize the texture into a JSON representation that can be parsed later on.
  8078. * @returns the JSON representation of the texture
  8079. */
  8080. serialize(): any;
  8081. /**
  8082. * Helper function to be called back once a list of texture contains only ready textures.
  8083. * @param textures Define the list of textures to wait for
  8084. * @param callback Define the callback triggered once the entire list will be ready
  8085. */
  8086. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  8087. private static _isScene;
  8088. }
  8089. }
  8090. declare module BABYLON {
  8091. /** @hidden */
  8092. export class WebGLDataBuffer extends DataBuffer {
  8093. private _buffer;
  8094. constructor(resource: WebGLBuffer);
  8095. get underlyingResource(): any;
  8096. }
  8097. }
  8098. declare module BABYLON {
  8099. /** @hidden */
  8100. export class WebGLPipelineContext implements IPipelineContext {
  8101. private _valueCache;
  8102. private _uniforms;
  8103. engine: ThinEngine;
  8104. program: Nullable<WebGLProgram>;
  8105. context?: WebGLRenderingContext;
  8106. vertexShader?: WebGLShader;
  8107. fragmentShader?: WebGLShader;
  8108. isParallelCompiled: boolean;
  8109. onCompiled?: () => void;
  8110. transformFeedback?: WebGLTransformFeedback | null;
  8111. vertexCompilationError: Nullable<string>;
  8112. fragmentCompilationError: Nullable<string>;
  8113. programLinkError: Nullable<string>;
  8114. programValidationError: Nullable<string>;
  8115. get isAsync(): boolean;
  8116. get isReady(): boolean;
  8117. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  8118. _fillEffectInformation(effect: Effect, uniformBuffersNames: {
  8119. [key: string]: number;
  8120. }, uniformsNames: string[], uniforms: {
  8121. [key: string]: Nullable<WebGLUniformLocation>;
  8122. }, samplerList: string[], samplers: {
  8123. [key: string]: number;
  8124. }, attributesNames: string[], attributes: number[]): void;
  8125. /**
  8126. * Release all associated resources.
  8127. **/
  8128. dispose(): void;
  8129. /** @hidden */
  8130. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  8131. /** @hidden */
  8132. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  8133. /** @hidden */
  8134. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  8135. /** @hidden */
  8136. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  8137. /**
  8138. * Sets an interger value on a uniform variable.
  8139. * @param uniformName Name of the variable.
  8140. * @param value Value to be set.
  8141. */
  8142. setInt(uniformName: string, value: number): void;
  8143. /**
  8144. * Sets a int2 on a uniform variable.
  8145. * @param uniformName Name of the variable.
  8146. * @param x First int in int2.
  8147. * @param y Second int in int2.
  8148. */
  8149. setInt2(uniformName: string, x: number, y: number): void;
  8150. /**
  8151. * Sets a int3 on a uniform variable.
  8152. * @param uniformName Name of the variable.
  8153. * @param x First int in int3.
  8154. * @param y Second int in int3.
  8155. * @param y Third int in int3.
  8156. */
  8157. setInt3(uniformName: string, x: number, y: number, z: number): void;
  8158. /**
  8159. * Sets a int4 on a uniform variable.
  8160. * @param uniformName Name of the variable.
  8161. * @param x First int in int4.
  8162. * @param y Second int in int4.
  8163. * @param y Third int in int4.
  8164. * @param w Fourth int in int4.
  8165. */
  8166. setInt4(uniformName: string, x: number, y: number, z: number, w: number): void;
  8167. /**
  8168. * Sets an int array on a uniform variable.
  8169. * @param uniformName Name of the variable.
  8170. * @param array array to be set.
  8171. */
  8172. setIntArray(uniformName: string, array: Int32Array): void;
  8173. /**
  8174. * 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)
  8175. * @param uniformName Name of the variable.
  8176. * @param array array to be set.
  8177. */
  8178. setIntArray2(uniformName: string, array: Int32Array): void;
  8179. /**
  8180. * 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)
  8181. * @param uniformName Name of the variable.
  8182. * @param array array to be set.
  8183. */
  8184. setIntArray3(uniformName: string, array: Int32Array): void;
  8185. /**
  8186. * 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)
  8187. * @param uniformName Name of the variable.
  8188. * @param array array to be set.
  8189. */
  8190. setIntArray4(uniformName: string, array: Int32Array): void;
  8191. /**
  8192. * Sets an array on a uniform variable.
  8193. * @param uniformName Name of the variable.
  8194. * @param array array to be set.
  8195. */
  8196. setArray(uniformName: string, array: number[]): void;
  8197. /**
  8198. * 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)
  8199. * @param uniformName Name of the variable.
  8200. * @param array array to be set.
  8201. */
  8202. setArray2(uniformName: string, array: number[]): void;
  8203. /**
  8204. * 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)
  8205. * @param uniformName Name of the variable.
  8206. * @param array array to be set.
  8207. * @returns this effect.
  8208. */
  8209. setArray3(uniformName: string, array: number[]): void;
  8210. /**
  8211. * 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)
  8212. * @param uniformName Name of the variable.
  8213. * @param array array to be set.
  8214. */
  8215. setArray4(uniformName: string, array: number[]): void;
  8216. /**
  8217. * Sets matrices on a uniform variable.
  8218. * @param uniformName Name of the variable.
  8219. * @param matrices matrices to be set.
  8220. */
  8221. setMatrices(uniformName: string, matrices: Float32Array): void;
  8222. /**
  8223. * Sets matrix on a uniform variable.
  8224. * @param uniformName Name of the variable.
  8225. * @param matrix matrix to be set.
  8226. */
  8227. setMatrix(uniformName: string, matrix: IMatrixLike): void;
  8228. /**
  8229. * 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)
  8230. * @param uniformName Name of the variable.
  8231. * @param matrix matrix to be set.
  8232. */
  8233. setMatrix3x3(uniformName: string, matrix: Float32Array): void;
  8234. /**
  8235. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  8236. * @param uniformName Name of the variable.
  8237. * @param matrix matrix to be set.
  8238. */
  8239. setMatrix2x2(uniformName: string, matrix: Float32Array): void;
  8240. /**
  8241. * Sets a float on a uniform variable.
  8242. * @param uniformName Name of the variable.
  8243. * @param value value to be set.
  8244. * @returns this effect.
  8245. */
  8246. setFloat(uniformName: string, value: number): void;
  8247. /**
  8248. * Sets a Vector2 on a uniform variable.
  8249. * @param uniformName Name of the variable.
  8250. * @param vector2 vector2 to be set.
  8251. */
  8252. setVector2(uniformName: string, vector2: IVector2Like): void;
  8253. /**
  8254. * Sets a float2 on a uniform variable.
  8255. * @param uniformName Name of the variable.
  8256. * @param x First float in float2.
  8257. * @param y Second float in float2.
  8258. */
  8259. setFloat2(uniformName: string, x: number, y: number): void;
  8260. /**
  8261. * Sets a Vector3 on a uniform variable.
  8262. * @param uniformName Name of the variable.
  8263. * @param vector3 Value to be set.
  8264. */
  8265. setVector3(uniformName: string, vector3: IVector3Like): void;
  8266. /**
  8267. * Sets a float3 on a uniform variable.
  8268. * @param uniformName Name of the variable.
  8269. * @param x First float in float3.
  8270. * @param y Second float in float3.
  8271. * @param z Third float in float3.
  8272. */
  8273. setFloat3(uniformName: string, x: number, y: number, z: number): void;
  8274. /**
  8275. * Sets a Vector4 on a uniform variable.
  8276. * @param uniformName Name of the variable.
  8277. * @param vector4 Value to be set.
  8278. */
  8279. setVector4(uniformName: string, vector4: IVector4Like): void;
  8280. /**
  8281. * Sets a float4 on a uniform variable.
  8282. * @param uniformName Name of the variable.
  8283. * @param x First float in float4.
  8284. * @param y Second float in float4.
  8285. * @param z Third float in float4.
  8286. * @param w Fourth float in float4.
  8287. * @returns this effect.
  8288. */
  8289. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): void;
  8290. /**
  8291. * Sets a Color3 on a uniform variable.
  8292. * @param uniformName Name of the variable.
  8293. * @param color3 Value to be set.
  8294. */
  8295. setColor3(uniformName: string, color3: IColor3Like): void;
  8296. /**
  8297. * Sets a Color4 on a uniform variable.
  8298. * @param uniformName Name of the variable.
  8299. * @param color3 Value to be set.
  8300. * @param alpha Alpha value to be set.
  8301. */
  8302. setColor4(uniformName: string, color3: IColor3Like, alpha: number): void;
  8303. /**
  8304. * Sets a Color4 on a uniform variable
  8305. * @param uniformName defines the name of the variable
  8306. * @param color4 defines the value to be set
  8307. */
  8308. setDirectColor4(uniformName: string, color4: IColor4Like): void;
  8309. _getVertexShaderCode(): string | null;
  8310. _getFragmentShaderCode(): string | null;
  8311. }
  8312. }
  8313. declare module BABYLON {
  8314. interface ThinEngine {
  8315. /**
  8316. * Create an uniform buffer
  8317. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  8318. * @param elements defines the content of the uniform buffer
  8319. * @returns the webGL uniform buffer
  8320. */
  8321. createUniformBuffer(elements: FloatArray): DataBuffer;
  8322. /**
  8323. * Create a dynamic uniform buffer
  8324. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  8325. * @param elements defines the content of the uniform buffer
  8326. * @returns the webGL uniform buffer
  8327. */
  8328. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  8329. /**
  8330. * Update an existing uniform buffer
  8331. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  8332. * @param uniformBuffer defines the target uniform buffer
  8333. * @param elements defines the content to update
  8334. * @param offset defines the offset in the uniform buffer where update should start
  8335. * @param count defines the size of the data to update
  8336. */
  8337. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  8338. /**
  8339. * Bind an uniform buffer to the current webGL context
  8340. * @param buffer defines the buffer to bind
  8341. */
  8342. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  8343. /**
  8344. * Bind a buffer to the current webGL context at a given location
  8345. * @param buffer defines the buffer to bind
  8346. * @param location defines the index where to bind the buffer
  8347. * @param name Name of the uniform variable to bind
  8348. */
  8349. bindUniformBufferBase(buffer: DataBuffer, location: number, name: string): void;
  8350. /**
  8351. * Bind a specific block at a given index in a specific shader program
  8352. * @param pipelineContext defines the pipeline context to use
  8353. * @param blockName defines the block name
  8354. * @param index defines the index where to bind the block
  8355. */
  8356. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  8357. }
  8358. }
  8359. declare module BABYLON {
  8360. /**
  8361. * Uniform buffer objects.
  8362. *
  8363. * Handles blocks of uniform on the GPU.
  8364. *
  8365. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  8366. *
  8367. * For more information, please refer to :
  8368. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  8369. */
  8370. export class UniformBuffer {
  8371. /** @hidden */
  8372. static _updatedUbosInFrame: {
  8373. [name: string]: number;
  8374. };
  8375. private _engine;
  8376. private _buffer;
  8377. private _buffers;
  8378. private _bufferIndex;
  8379. private _createBufferOnWrite;
  8380. private _data;
  8381. private _bufferData;
  8382. private _dynamic?;
  8383. private _uniformLocations;
  8384. private _uniformSizes;
  8385. private _uniformArraySizes;
  8386. private _uniformLocationPointer;
  8387. private _needSync;
  8388. private _noUBO;
  8389. private _currentEffect;
  8390. private _currentEffectName;
  8391. private _name;
  8392. private _currentFrameId;
  8393. /** @hidden */
  8394. _alreadyBound: boolean;
  8395. private static _MAX_UNIFORM_SIZE;
  8396. private static _tempBuffer;
  8397. private static _tempBufferInt32View;
  8398. /**
  8399. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  8400. * This is dynamic to allow compat with webgl 1 and 2.
  8401. * You will need to pass the name of the uniform as well as the value.
  8402. */
  8403. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  8404. /**
  8405. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  8406. * This is dynamic to allow compat with webgl 1 and 2.
  8407. * You will need to pass the name of the uniform as well as the value.
  8408. */
  8409. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  8410. /**
  8411. * Lambda to Update a single float in a uniform buffer.
  8412. * This is dynamic to allow compat with webgl 1 and 2.
  8413. * You will need to pass the name of the uniform as well as the value.
  8414. */
  8415. updateFloat: (name: string, x: number) => void;
  8416. /**
  8417. * Lambda to Update a vec2 of float in a uniform buffer.
  8418. * This is dynamic to allow compat with webgl 1 and 2.
  8419. * You will need to pass the name of the uniform as well as the value.
  8420. */
  8421. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  8422. /**
  8423. * Lambda to Update a vec3 of float in a uniform buffer.
  8424. * This is dynamic to allow compat with webgl 1 and 2.
  8425. * You will need to pass the name of the uniform as well as the value.
  8426. */
  8427. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  8428. /**
  8429. * Lambda to Update a vec4 of float in a uniform buffer.
  8430. * This is dynamic to allow compat with webgl 1 and 2.
  8431. * You will need to pass the name of the uniform as well as the value.
  8432. */
  8433. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  8434. /**
  8435. * Lambda to Update an array of float in a uniform buffer.
  8436. * This is dynamic to allow compat with webgl 1 and 2.
  8437. * You will need to pass the name of the uniform as well as the value.
  8438. */
  8439. updateFloatArray: (name: string, array: Float32Array) => void;
  8440. /**
  8441. * Lambda to Update an array of number in a uniform buffer.
  8442. * This is dynamic to allow compat with webgl 1 and 2.
  8443. * You will need to pass the name of the uniform as well as the value.
  8444. */
  8445. updateArray: (name: string, array: number[]) => void;
  8446. /**
  8447. * Lambda to Update an array of number in a uniform buffer.
  8448. * This is dynamic to allow compat with webgl 1 and 2.
  8449. * You will need to pass the name of the uniform as well as the value.
  8450. */
  8451. updateIntArray: (name: string, array: Int32Array) => void;
  8452. /**
  8453. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  8454. * This is dynamic to allow compat with webgl 1 and 2.
  8455. * You will need to pass the name of the uniform as well as the value.
  8456. */
  8457. updateMatrix: (name: string, mat: IMatrixLike) => void;
  8458. /**
  8459. * Lambda to Update an array of 4x4 Matrix in a uniform buffer.
  8460. * This is dynamic to allow compat with webgl 1 and 2.
  8461. * You will need to pass the name of the uniform as well as the value.
  8462. */
  8463. updateMatrices: (name: string, mat: Float32Array) => void;
  8464. /**
  8465. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  8466. * This is dynamic to allow compat with webgl 1 and 2.
  8467. * You will need to pass the name of the uniform as well as the value.
  8468. */
  8469. updateVector3: (name: string, vector: Vector3) => void;
  8470. /**
  8471. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  8472. * This is dynamic to allow compat with webgl 1 and 2.
  8473. * You will need to pass the name of the uniform as well as the value.
  8474. */
  8475. updateVector4: (name: string, vector: Vector4) => void;
  8476. /**
  8477. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  8478. * This is dynamic to allow compat with webgl 1 and 2.
  8479. * You will need to pass the name of the uniform as well as the value.
  8480. */
  8481. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  8482. /**
  8483. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  8484. * This is dynamic to allow compat with webgl 1 and 2.
  8485. * You will need to pass the name of the uniform as well as the value.
  8486. */
  8487. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  8488. /**
  8489. * Lambda to Update a int a uniform buffer.
  8490. * This is dynamic to allow compat with webgl 1 and 2.
  8491. * You will need to pass the name of the uniform as well as the value.
  8492. */
  8493. updateInt: (name: string, x: number, suffix?: string) => void;
  8494. /**
  8495. * Lambda to Update a vec2 of int in a uniform buffer.
  8496. * This is dynamic to allow compat with webgl 1 and 2.
  8497. * You will need to pass the name of the uniform as well as the value.
  8498. */
  8499. updateInt2: (name: string, x: number, y: number, suffix?: string) => void;
  8500. /**
  8501. * Lambda to Update a vec3 of int in a uniform buffer.
  8502. * This is dynamic to allow compat with webgl 1 and 2.
  8503. * You will need to pass the name of the uniform as well as the value.
  8504. */
  8505. updateInt3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  8506. /**
  8507. * Lambda to Update a vec4 of int in a uniform buffer.
  8508. * This is dynamic to allow compat with webgl 1 and 2.
  8509. * You will need to pass the name of the uniform as well as the value.
  8510. */
  8511. updateInt4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  8512. /**
  8513. * Instantiates a new Uniform buffer objects.
  8514. *
  8515. * Handles blocks of uniform on the GPU.
  8516. *
  8517. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  8518. *
  8519. * For more information, please refer to :
  8520. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  8521. * @param engine Define the engine the buffer is associated with
  8522. * @param data Define the data contained in the buffer
  8523. * @param dynamic Define if the buffer is updatable
  8524. * @param name to assign to the buffer (debugging purpose)
  8525. */
  8526. constructor(engine: Engine, data?: number[], dynamic?: boolean, name?: string);
  8527. /**
  8528. * Indicates if the buffer is using the WebGL2 UBO implementation,
  8529. * or just falling back on setUniformXXX calls.
  8530. */
  8531. get useUbo(): boolean;
  8532. /**
  8533. * Indicates if the WebGL underlying uniform buffer is in sync
  8534. * with the javascript cache data.
  8535. */
  8536. get isSync(): boolean;
  8537. /**
  8538. * Indicates if the WebGL underlying uniform buffer is dynamic.
  8539. * Also, a dynamic UniformBuffer will disable cache verification and always
  8540. * update the underlying WebGL uniform buffer to the GPU.
  8541. * @returns if Dynamic, otherwise false
  8542. */
  8543. isDynamic(): boolean;
  8544. /**
  8545. * The data cache on JS side.
  8546. * @returns the underlying data as a float array
  8547. */
  8548. getData(): Float32Array;
  8549. /**
  8550. * The underlying WebGL Uniform buffer.
  8551. * @returns the webgl buffer
  8552. */
  8553. getBuffer(): Nullable<DataBuffer>;
  8554. /**
  8555. * std140 layout specifies how to align data within an UBO structure.
  8556. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  8557. * for specs.
  8558. */
  8559. private _fillAlignment;
  8560. /**
  8561. * Adds an uniform in the buffer.
  8562. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  8563. * for the layout to be correct !
  8564. * @param name Name of the uniform, as used in the uniform block in the shader.
  8565. * @param size Data size, or data directly.
  8566. * @param arraySize The number of elements in the array, 0 if not an array.
  8567. */
  8568. addUniform(name: string, size: number | number[], arraySize?: number): void;
  8569. /**
  8570. * Adds a Matrix 4x4 to the uniform buffer.
  8571. * @param name Name of the uniform, as used in the uniform block in the shader.
  8572. * @param mat A 4x4 matrix.
  8573. */
  8574. addMatrix(name: string, mat: Matrix): void;
  8575. /**
  8576. * Adds a vec2 to the uniform buffer.
  8577. * @param name Name of the uniform, as used in the uniform block in the shader.
  8578. * @param x Define the x component value of the vec2
  8579. * @param y Define the y component value of the vec2
  8580. */
  8581. addFloat2(name: string, x: number, y: number): void;
  8582. /**
  8583. * Adds a vec3 to the uniform buffer.
  8584. * @param name Name of the uniform, as used in the uniform block in the shader.
  8585. * @param x Define the x component value of the vec3
  8586. * @param y Define the y component value of the vec3
  8587. * @param z Define the z component value of the vec3
  8588. */
  8589. addFloat3(name: string, x: number, y: number, z: number): void;
  8590. /**
  8591. * Adds a vec3 to the uniform buffer.
  8592. * @param name Name of the uniform, as used in the uniform block in the shader.
  8593. * @param color Define the vec3 from a Color
  8594. */
  8595. addColor3(name: string, color: Color3): void;
  8596. /**
  8597. * Adds a vec4 to the uniform buffer.
  8598. * @param name Name of the uniform, as used in the uniform block in the shader.
  8599. * @param color Define the rgb components from a Color
  8600. * @param alpha Define the a component of the vec4
  8601. */
  8602. addColor4(name: string, color: Color3, alpha: number): void;
  8603. /**
  8604. * Adds a vec3 to the uniform buffer.
  8605. * @param name Name of the uniform, as used in the uniform block in the shader.
  8606. * @param vector Define the vec3 components from a Vector
  8607. */
  8608. addVector3(name: string, vector: Vector3): void;
  8609. /**
  8610. * Adds a Matrix 3x3 to the uniform buffer.
  8611. * @param name Name of the uniform, as used in the uniform block in the shader.
  8612. */
  8613. addMatrix3x3(name: string): void;
  8614. /**
  8615. * Adds a Matrix 2x2 to the uniform buffer.
  8616. * @param name Name of the uniform, as used in the uniform block in the shader.
  8617. */
  8618. addMatrix2x2(name: string): void;
  8619. /**
  8620. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  8621. */
  8622. create(): void;
  8623. /** @hidden */
  8624. _rebuild(): void;
  8625. /** @hidden */
  8626. get _numBuffers(): number;
  8627. /** @hidden */
  8628. get _indexBuffer(): number;
  8629. /** Gets the name of this buffer */
  8630. get name(): string;
  8631. /**
  8632. * Updates the WebGL Uniform Buffer on the GPU.
  8633. * If the `dynamic` flag is set to true, no cache comparison is done.
  8634. * Otherwise, the buffer will be updated only if the cache differs.
  8635. */
  8636. update(): void;
  8637. private _createNewBuffer;
  8638. private _checkNewFrame;
  8639. /**
  8640. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  8641. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  8642. * @param data Define the flattened data
  8643. * @param size Define the size of the data.
  8644. */
  8645. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  8646. /**
  8647. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  8648. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  8649. * @param data Define the flattened data
  8650. * @param size Define the size of the data.
  8651. */
  8652. updateUniformArray(uniformName: string, data: FloatArray, size: number): void;
  8653. private _valueCache;
  8654. private _cacheMatrix;
  8655. private _updateMatrix3x3ForUniform;
  8656. private _updateMatrix3x3ForEffect;
  8657. private _updateMatrix2x2ForEffect;
  8658. private _updateMatrix2x2ForUniform;
  8659. private _updateFloatForEffect;
  8660. private _updateFloatForUniform;
  8661. private _updateFloat2ForEffect;
  8662. private _updateFloat2ForUniform;
  8663. private _updateFloat3ForEffect;
  8664. private _updateFloat3ForUniform;
  8665. private _updateFloat4ForEffect;
  8666. private _updateFloat4ForUniform;
  8667. private _updateFloatArrayForEffect;
  8668. private _updateFloatArrayForUniform;
  8669. private _updateArrayForEffect;
  8670. private _updateArrayForUniform;
  8671. private _updateIntArrayForEffect;
  8672. private _updateIntArrayForUniform;
  8673. private _updateMatrixForEffect;
  8674. private _updateMatrixForUniform;
  8675. private _updateMatricesForEffect;
  8676. private _updateMatricesForUniform;
  8677. private _updateVector3ForEffect;
  8678. private _updateVector3ForUniform;
  8679. private _updateVector4ForEffect;
  8680. private _updateVector4ForUniform;
  8681. private _updateColor3ForEffect;
  8682. private _updateColor3ForUniform;
  8683. private _updateColor4ForEffect;
  8684. private _updateColor4ForUniform;
  8685. private _updateIntForEffect;
  8686. private _updateIntForUniform;
  8687. private _updateInt2ForEffect;
  8688. private _updateInt2ForUniform;
  8689. private _updateInt3ForEffect;
  8690. private _updateInt3ForUniform;
  8691. private _updateInt4ForEffect;
  8692. private _updateInt4ForUniform;
  8693. /**
  8694. * Sets a sampler uniform on the effect.
  8695. * @param name Define the name of the sampler.
  8696. * @param texture Define the texture to set in the sampler
  8697. */
  8698. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  8699. /**
  8700. * Directly updates the value of the uniform in the cache AND on the GPU.
  8701. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  8702. * @param data Define the flattened data
  8703. */
  8704. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  8705. /**
  8706. * Binds this uniform buffer to an effect.
  8707. * @param effect Define the effect to bind the buffer to
  8708. * @param name Name of the uniform block in the shader.
  8709. */
  8710. bindToEffect(effect: Effect, name: string): void;
  8711. /**
  8712. * Disposes the uniform buffer.
  8713. */
  8714. dispose(): void;
  8715. }
  8716. }
  8717. declare module BABYLON {
  8718. /**
  8719. * Manages the defines for the Material
  8720. */
  8721. export class MaterialDefines {
  8722. /** @hidden */
  8723. protected _keys: string[];
  8724. private _isDirty;
  8725. /** @hidden */
  8726. _renderId: number;
  8727. /** @hidden */
  8728. _areLightsDirty: boolean;
  8729. /** @hidden */
  8730. _areLightsDisposed: boolean;
  8731. /** @hidden */
  8732. _areAttributesDirty: boolean;
  8733. /** @hidden */
  8734. _areTexturesDirty: boolean;
  8735. /** @hidden */
  8736. _areFresnelDirty: boolean;
  8737. /** @hidden */
  8738. _areMiscDirty: boolean;
  8739. /** @hidden */
  8740. _arePrePassDirty: boolean;
  8741. /** @hidden */
  8742. _areImageProcessingDirty: boolean;
  8743. /** @hidden */
  8744. _normals: boolean;
  8745. /** @hidden */
  8746. _uvs: boolean;
  8747. /** @hidden */
  8748. _needNormals: boolean;
  8749. /** @hidden */
  8750. _needUVs: boolean;
  8751. [id: string]: any;
  8752. /**
  8753. * Specifies if the material needs to be re-calculated
  8754. */
  8755. get isDirty(): boolean;
  8756. /**
  8757. * Marks the material to indicate that it has been re-calculated
  8758. */
  8759. markAsProcessed(): void;
  8760. /**
  8761. * Marks the material to indicate that it needs to be re-calculated
  8762. */
  8763. markAsUnprocessed(): void;
  8764. /**
  8765. * Marks the material to indicate all of its defines need to be re-calculated
  8766. */
  8767. markAllAsDirty(): void;
  8768. /**
  8769. * Marks the material to indicate that image processing needs to be re-calculated
  8770. */
  8771. markAsImageProcessingDirty(): void;
  8772. /**
  8773. * Marks the material to indicate the lights need to be re-calculated
  8774. * @param disposed Defines whether the light is dirty due to dispose or not
  8775. */
  8776. markAsLightDirty(disposed?: boolean): void;
  8777. /**
  8778. * Marks the attribute state as changed
  8779. */
  8780. markAsAttributesDirty(): void;
  8781. /**
  8782. * Marks the texture state as changed
  8783. */
  8784. markAsTexturesDirty(): void;
  8785. /**
  8786. * Marks the fresnel state as changed
  8787. */
  8788. markAsFresnelDirty(): void;
  8789. /**
  8790. * Marks the misc state as changed
  8791. */
  8792. markAsMiscDirty(): void;
  8793. /**
  8794. * Marks the prepass state as changed
  8795. */
  8796. markAsPrePassDirty(): void;
  8797. /**
  8798. * Rebuilds the material defines
  8799. */
  8800. rebuild(): void;
  8801. /**
  8802. * Specifies if two material defines are equal
  8803. * @param other - A material define instance to compare to
  8804. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  8805. */
  8806. isEqual(other: MaterialDefines): boolean;
  8807. /**
  8808. * Clones this instance's defines to another instance
  8809. * @param other - material defines to clone values to
  8810. */
  8811. cloneTo(other: MaterialDefines): void;
  8812. /**
  8813. * Resets the material define values
  8814. */
  8815. reset(): void;
  8816. /**
  8817. * Converts the material define values to a string
  8818. * @returns - String of material define information
  8819. */
  8820. toString(): string;
  8821. }
  8822. }
  8823. declare module BABYLON {
  8824. /**
  8825. * Enum that determines the text-wrapping mode to use.
  8826. */
  8827. export enum InspectableType {
  8828. /**
  8829. * Checkbox for booleans
  8830. */
  8831. Checkbox = 0,
  8832. /**
  8833. * Sliders for numbers
  8834. */
  8835. Slider = 1,
  8836. /**
  8837. * Vector3
  8838. */
  8839. Vector3 = 2,
  8840. /**
  8841. * Quaternions
  8842. */
  8843. Quaternion = 3,
  8844. /**
  8845. * Color3
  8846. */
  8847. Color3 = 4,
  8848. /**
  8849. * String
  8850. */
  8851. String = 5
  8852. }
  8853. /**
  8854. * Interface used to define custom inspectable properties.
  8855. * This interface is used by the inspector to display custom property grids
  8856. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  8857. */
  8858. export interface IInspectable {
  8859. /**
  8860. * Gets the label to display
  8861. */
  8862. label: string;
  8863. /**
  8864. * Gets the name of the property to edit
  8865. */
  8866. propertyName: string;
  8867. /**
  8868. * Gets the type of the editor to use
  8869. */
  8870. type: InspectableType;
  8871. /**
  8872. * Gets the minimum value of the property when using in "slider" mode
  8873. */
  8874. min?: number;
  8875. /**
  8876. * Gets the maximum value of the property when using in "slider" mode
  8877. */
  8878. max?: number;
  8879. /**
  8880. * Gets the setp to use when using in "slider" mode
  8881. */
  8882. step?: number;
  8883. }
  8884. }
  8885. declare module BABYLON {
  8886. /**
  8887. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  8888. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  8889. * 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.
  8890. */
  8891. export abstract class Light extends Node {
  8892. /**
  8893. * Falloff Default: light is falling off following the material specification:
  8894. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  8895. */
  8896. static readonly FALLOFF_DEFAULT: number;
  8897. /**
  8898. * Falloff Physical: light is falling off following the inverse squared distance law.
  8899. */
  8900. static readonly FALLOFF_PHYSICAL: number;
  8901. /**
  8902. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  8903. * to enhance interoperability with other engines.
  8904. */
  8905. static readonly FALLOFF_GLTF: number;
  8906. /**
  8907. * Falloff Standard: light is falling off like in the standard material
  8908. * to enhance interoperability with other materials.
  8909. */
  8910. static readonly FALLOFF_STANDARD: number;
  8911. /**
  8912. * If every light affecting the material is in this lightmapMode,
  8913. * material.lightmapTexture adds or multiplies
  8914. * (depends on material.useLightmapAsShadowmap)
  8915. * after every other light calculations.
  8916. */
  8917. static readonly LIGHTMAP_DEFAULT: number;
  8918. /**
  8919. * material.lightmapTexture as only diffuse lighting from this light
  8920. * adds only specular lighting from this light
  8921. * adds dynamic shadows
  8922. */
  8923. static readonly LIGHTMAP_SPECULAR: number;
  8924. /**
  8925. * material.lightmapTexture as only lighting
  8926. * no light calculation from this light
  8927. * only adds dynamic shadows from this light
  8928. */
  8929. static readonly LIGHTMAP_SHADOWSONLY: number;
  8930. /**
  8931. * Each light type uses the default quantity according to its type:
  8932. * point/spot lights use luminous intensity
  8933. * directional lights use illuminance
  8934. */
  8935. static readonly INTENSITYMODE_AUTOMATIC: number;
  8936. /**
  8937. * lumen (lm)
  8938. */
  8939. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  8940. /**
  8941. * candela (lm/sr)
  8942. */
  8943. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  8944. /**
  8945. * lux (lm/m^2)
  8946. */
  8947. static readonly INTENSITYMODE_ILLUMINANCE: number;
  8948. /**
  8949. * nit (cd/m^2)
  8950. */
  8951. static readonly INTENSITYMODE_LUMINANCE: number;
  8952. /**
  8953. * Light type const id of the point light.
  8954. */
  8955. static readonly LIGHTTYPEID_POINTLIGHT: number;
  8956. /**
  8957. * Light type const id of the directional light.
  8958. */
  8959. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  8960. /**
  8961. * Light type const id of the spot light.
  8962. */
  8963. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  8964. /**
  8965. * Light type const id of the hemispheric light.
  8966. */
  8967. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  8968. /**
  8969. * Diffuse gives the basic color to an object.
  8970. */
  8971. diffuse: Color3;
  8972. /**
  8973. * Specular produces a highlight color on an object.
  8974. * Note: This is note affecting PBR materials.
  8975. */
  8976. specular: Color3;
  8977. /**
  8978. * Defines the falloff type for this light. This lets overrriding how punctual light are
  8979. * falling off base on range or angle.
  8980. * This can be set to any values in Light.FALLOFF_x.
  8981. *
  8982. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  8983. * other types of materials.
  8984. */
  8985. falloffType: number;
  8986. /**
  8987. * Strength of the light.
  8988. * Note: By default it is define in the framework own unit.
  8989. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  8990. */
  8991. intensity: number;
  8992. private _range;
  8993. protected _inverseSquaredRange: number;
  8994. /**
  8995. * Defines how far from the source the light is impacting in scene units.
  8996. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  8997. */
  8998. get range(): number;
  8999. /**
  9000. * Defines how far from the source the light is impacting in scene units.
  9001. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9002. */
  9003. set range(value: number);
  9004. /**
  9005. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  9006. * of light.
  9007. */
  9008. private _photometricScale;
  9009. private _intensityMode;
  9010. /**
  9011. * Gets the photometric scale used to interpret the intensity.
  9012. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9013. */
  9014. get intensityMode(): number;
  9015. /**
  9016. * Sets the photometric scale used to interpret the intensity.
  9017. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9018. */
  9019. set intensityMode(value: number);
  9020. private _radius;
  9021. /**
  9022. * Gets the light radius used by PBR Materials to simulate soft area lights.
  9023. */
  9024. get radius(): number;
  9025. /**
  9026. * sets the light radius used by PBR Materials to simulate soft area lights.
  9027. */
  9028. set radius(value: number);
  9029. private _renderPriority;
  9030. /**
  9031. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  9032. * exceeding the number allowed of the materials.
  9033. */
  9034. renderPriority: number;
  9035. private _shadowEnabled;
  9036. /**
  9037. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9038. * the current shadow generator.
  9039. */
  9040. get shadowEnabled(): boolean;
  9041. /**
  9042. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9043. * the current shadow generator.
  9044. */
  9045. set shadowEnabled(value: boolean);
  9046. private _includedOnlyMeshes;
  9047. /**
  9048. * Gets the only meshes impacted by this light.
  9049. */
  9050. get includedOnlyMeshes(): AbstractMesh[];
  9051. /**
  9052. * Sets the only meshes impacted by this light.
  9053. */
  9054. set includedOnlyMeshes(value: AbstractMesh[]);
  9055. private _excludedMeshes;
  9056. /**
  9057. * Gets the meshes not impacted by this light.
  9058. */
  9059. get excludedMeshes(): AbstractMesh[];
  9060. /**
  9061. * Sets the meshes not impacted by this light.
  9062. */
  9063. set excludedMeshes(value: AbstractMesh[]);
  9064. private _excludeWithLayerMask;
  9065. /**
  9066. * Gets the layer id use to find what meshes are not impacted by the light.
  9067. * Inactive if 0
  9068. */
  9069. get excludeWithLayerMask(): number;
  9070. /**
  9071. * Sets the layer id use to find what meshes are not impacted by the light.
  9072. * Inactive if 0
  9073. */
  9074. set excludeWithLayerMask(value: number);
  9075. private _includeOnlyWithLayerMask;
  9076. /**
  9077. * Gets the layer id use to find what meshes are impacted by the light.
  9078. * Inactive if 0
  9079. */
  9080. get includeOnlyWithLayerMask(): number;
  9081. /**
  9082. * Sets the layer id use to find what meshes are impacted by the light.
  9083. * Inactive if 0
  9084. */
  9085. set includeOnlyWithLayerMask(value: number);
  9086. private _lightmapMode;
  9087. /**
  9088. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  9089. */
  9090. get lightmapMode(): number;
  9091. /**
  9092. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  9093. */
  9094. set lightmapMode(value: number);
  9095. /**
  9096. * Shadow generator associted to the light.
  9097. * @hidden Internal use only.
  9098. */
  9099. _shadowGenerator: Nullable<IShadowGenerator>;
  9100. /**
  9101. * @hidden Internal use only.
  9102. */
  9103. _excludedMeshesIds: string[];
  9104. /**
  9105. * @hidden Internal use only.
  9106. */
  9107. _includedOnlyMeshesIds: string[];
  9108. /**
  9109. * The current light unifom buffer.
  9110. * @hidden Internal use only.
  9111. */
  9112. _uniformBuffer: UniformBuffer;
  9113. /** @hidden */
  9114. _renderId: number;
  9115. /**
  9116. * Creates a Light object in the scene.
  9117. * Documentation : https://doc.babylonjs.com/babylon101/lights
  9118. * @param name The firendly name of the light
  9119. * @param scene The scene the light belongs too
  9120. */
  9121. constructor(name: string, scene: Scene);
  9122. protected abstract _buildUniformLayout(): void;
  9123. /**
  9124. * Sets the passed Effect "effect" with the Light information.
  9125. * @param effect The effect to update
  9126. * @param lightIndex The index of the light in the effect to update
  9127. * @returns The light
  9128. */
  9129. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  9130. /**
  9131. * Sets the passed Effect "effect" with the Light textures.
  9132. * @param effect The effect to update
  9133. * @param lightIndex The index of the light in the effect to update
  9134. * @returns The light
  9135. */
  9136. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  9137. /**
  9138. * Binds the lights information from the scene to the effect for the given mesh.
  9139. * @param lightIndex Light index
  9140. * @param scene The scene where the light belongs to
  9141. * @param effect The effect we are binding the data to
  9142. * @param useSpecular Defines if specular is supported
  9143. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9144. */
  9145. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  9146. /**
  9147. * Sets the passed Effect "effect" with the Light information.
  9148. * @param effect The effect to update
  9149. * @param lightDataUniformName The uniform used to store light data (position or direction)
  9150. * @returns The light
  9151. */
  9152. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  9153. /**
  9154. * Returns the string "Light".
  9155. * @returns the class name
  9156. */
  9157. getClassName(): string;
  9158. /** @hidden */
  9159. readonly _isLight: boolean;
  9160. /**
  9161. * Converts the light information to a readable string for debug purpose.
  9162. * @param fullDetails Supports for multiple levels of logging within scene loading
  9163. * @returns the human readable light info
  9164. */
  9165. toString(fullDetails?: boolean): string;
  9166. /** @hidden */
  9167. protected _syncParentEnabledState(): void;
  9168. /**
  9169. * Set the enabled state of this node.
  9170. * @param value - the new enabled state
  9171. */
  9172. setEnabled(value: boolean): void;
  9173. /**
  9174. * Returns the Light associated shadow generator if any.
  9175. * @return the associated shadow generator.
  9176. */
  9177. getShadowGenerator(): Nullable<IShadowGenerator>;
  9178. /**
  9179. * Returns a Vector3, the absolute light position in the World.
  9180. * @returns the world space position of the light
  9181. */
  9182. getAbsolutePosition(): Vector3;
  9183. /**
  9184. * Specifies if the light will affect the passed mesh.
  9185. * @param mesh The mesh to test against the light
  9186. * @return true the mesh is affected otherwise, false.
  9187. */
  9188. canAffectMesh(mesh: AbstractMesh): boolean;
  9189. /**
  9190. * Sort function to order lights for rendering.
  9191. * @param a First Light object to compare to second.
  9192. * @param b Second Light object to compare first.
  9193. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  9194. */
  9195. static CompareLightsPriority(a: Light, b: Light): number;
  9196. /**
  9197. * Releases resources associated with this node.
  9198. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  9199. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  9200. */
  9201. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  9202. /**
  9203. * Returns the light type ID (integer).
  9204. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  9205. */
  9206. getTypeID(): number;
  9207. /**
  9208. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  9209. * @returns the scaled intensity in intensity mode unit
  9210. */
  9211. getScaledIntensity(): number;
  9212. /**
  9213. * Returns a new Light object, named "name", from the current one.
  9214. * @param name The name of the cloned light
  9215. * @param newParent The parent of this light, if it has one
  9216. * @returns the new created light
  9217. */
  9218. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  9219. /**
  9220. * Serializes the current light into a Serialization object.
  9221. * @returns the serialized object.
  9222. */
  9223. serialize(): any;
  9224. /**
  9225. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  9226. * This new light is named "name" and added to the passed scene.
  9227. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  9228. * @param name The friendly name of the light
  9229. * @param scene The scene the new light will belong to
  9230. * @returns the constructor function
  9231. */
  9232. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  9233. /**
  9234. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  9235. * @param parsedLight The JSON representation of the light
  9236. * @param scene The scene to create the parsed light in
  9237. * @returns the created light after parsing
  9238. */
  9239. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  9240. private _hookArrayForExcluded;
  9241. private _hookArrayForIncludedOnly;
  9242. private _resyncMeshes;
  9243. /**
  9244. * Forces the meshes to update their light related information in their rendering used effects
  9245. * @hidden Internal Use Only
  9246. */
  9247. _markMeshesAsLightDirty(): void;
  9248. /**
  9249. * Recomputes the cached photometric scale if needed.
  9250. */
  9251. private _computePhotometricScale;
  9252. /**
  9253. * Returns the Photometric Scale according to the light type and intensity mode.
  9254. */
  9255. private _getPhotometricScale;
  9256. /**
  9257. * Reorder the light in the scene according to their defined priority.
  9258. * @hidden Internal Use Only
  9259. */
  9260. _reorderLightsInScene(): void;
  9261. /**
  9262. * Prepares the list of defines specific to the light type.
  9263. * @param defines the list of defines
  9264. * @param lightIndex defines the index of the light for the effect
  9265. */
  9266. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  9267. }
  9268. }
  9269. declare module BABYLON {
  9270. /** Defines supported spaces */
  9271. export enum Space {
  9272. /** Local (object) space */
  9273. LOCAL = 0,
  9274. /** World space */
  9275. WORLD = 1,
  9276. /** Bone space */
  9277. BONE = 2
  9278. }
  9279. /** Defines the 3 main axes */
  9280. export class Axis {
  9281. /** X axis */
  9282. static X: Vector3;
  9283. /** Y axis */
  9284. static Y: Vector3;
  9285. /** Z axis */
  9286. static Z: Vector3;
  9287. }
  9288. /**
  9289. * Defines cartesian components.
  9290. */
  9291. export enum Coordinate {
  9292. /** X axis */
  9293. X = 0,
  9294. /** Y axis */
  9295. Y = 1,
  9296. /** Z axis */
  9297. Z = 2
  9298. }
  9299. }
  9300. declare module BABYLON {
  9301. /**
  9302. * Interface describing all the common properties and methods a shadow light needs to implement.
  9303. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  9304. * as well as binding the different shadow properties to the effects.
  9305. */
  9306. export interface IShadowLight extends Light {
  9307. /**
  9308. * The light id in the scene (used in scene.findLighById for instance)
  9309. */
  9310. id: string;
  9311. /**
  9312. * The position the shdow will be casted from.
  9313. */
  9314. position: Vector3;
  9315. /**
  9316. * In 2d mode (needCube being false), the direction used to cast the shadow.
  9317. */
  9318. direction: Vector3;
  9319. /**
  9320. * The transformed position. Position of the light in world space taking parenting in account.
  9321. */
  9322. transformedPosition: Vector3;
  9323. /**
  9324. * The transformed direction. Direction of the light in world space taking parenting in account.
  9325. */
  9326. transformedDirection: Vector3;
  9327. /**
  9328. * The friendly name of the light in the scene.
  9329. */
  9330. name: string;
  9331. /**
  9332. * Defines the shadow projection clipping minimum z value.
  9333. */
  9334. shadowMinZ: number;
  9335. /**
  9336. * Defines the shadow projection clipping maximum z value.
  9337. */
  9338. shadowMaxZ: number;
  9339. /**
  9340. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9341. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9342. */
  9343. computeTransformedInformation(): boolean;
  9344. /**
  9345. * Gets the scene the light belongs to.
  9346. * @returns The scene
  9347. */
  9348. getScene(): Scene;
  9349. /**
  9350. * Callback defining a custom Projection Matrix Builder.
  9351. * This can be used to override the default projection matrix computation.
  9352. */
  9353. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9354. /**
  9355. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9356. * @param matrix The materix to updated with the projection information
  9357. * @param viewMatrix The transform matrix of the light
  9358. * @param renderList The list of mesh to render in the map
  9359. * @returns The current light
  9360. */
  9361. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9362. /**
  9363. * Gets the current depth scale used in ESM.
  9364. * @returns The scale
  9365. */
  9366. getDepthScale(): number;
  9367. /**
  9368. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9369. * @returns true if a cube texture needs to be use
  9370. */
  9371. needCube(): boolean;
  9372. /**
  9373. * Detects if the projection matrix requires to be recomputed this frame.
  9374. * @returns true if it requires to be recomputed otherwise, false.
  9375. */
  9376. needProjectionMatrixCompute(): boolean;
  9377. /**
  9378. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9379. */
  9380. forceProjectionMatrixCompute(): void;
  9381. /**
  9382. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9383. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9384. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9385. */
  9386. getShadowDirection(faceIndex?: number): Vector3;
  9387. /**
  9388. * Gets the minZ used for shadow according to both the scene and the light.
  9389. * @param activeCamera The camera we are returning the min for
  9390. * @returns the depth min z
  9391. */
  9392. getDepthMinZ(activeCamera: Camera): number;
  9393. /**
  9394. * Gets the maxZ used for shadow according to both the scene and the light.
  9395. * @param activeCamera The camera we are returning the max for
  9396. * @returns the depth max z
  9397. */
  9398. getDepthMaxZ(activeCamera: Camera): number;
  9399. }
  9400. /**
  9401. * Base implementation IShadowLight
  9402. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  9403. */
  9404. export abstract class ShadowLight extends Light implements IShadowLight {
  9405. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  9406. protected _position: Vector3;
  9407. protected _setPosition(value: Vector3): void;
  9408. /**
  9409. * Sets the position the shadow will be casted from. Also use as the light position for both
  9410. * point and spot lights.
  9411. */
  9412. get position(): Vector3;
  9413. /**
  9414. * Sets the position the shadow will be casted from. Also use as the light position for both
  9415. * point and spot lights.
  9416. */
  9417. set position(value: Vector3);
  9418. protected _direction: Vector3;
  9419. protected _setDirection(value: Vector3): void;
  9420. /**
  9421. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9422. * Also use as the light direction on spot and directional lights.
  9423. */
  9424. get direction(): Vector3;
  9425. /**
  9426. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9427. * Also use as the light direction on spot and directional lights.
  9428. */
  9429. set direction(value: Vector3);
  9430. protected _shadowMinZ: number;
  9431. /**
  9432. * Gets the shadow projection clipping minimum z value.
  9433. */
  9434. get shadowMinZ(): number;
  9435. /**
  9436. * Sets the shadow projection clipping minimum z value.
  9437. */
  9438. set shadowMinZ(value: number);
  9439. protected _shadowMaxZ: number;
  9440. /**
  9441. * Sets the shadow projection clipping maximum z value.
  9442. */
  9443. get shadowMaxZ(): number;
  9444. /**
  9445. * Gets the shadow projection clipping maximum z value.
  9446. */
  9447. set shadowMaxZ(value: number);
  9448. /**
  9449. * Callback defining a custom Projection Matrix Builder.
  9450. * This can be used to override the default projection matrix computation.
  9451. */
  9452. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9453. /**
  9454. * The transformed position. Position of the light in world space taking parenting in account.
  9455. */
  9456. transformedPosition: Vector3;
  9457. /**
  9458. * The transformed direction. Direction of the light in world space taking parenting in account.
  9459. */
  9460. transformedDirection: Vector3;
  9461. private _needProjectionMatrixCompute;
  9462. /**
  9463. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9464. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9465. */
  9466. computeTransformedInformation(): boolean;
  9467. /**
  9468. * Return the depth scale used for the shadow map.
  9469. * @returns the depth scale.
  9470. */
  9471. getDepthScale(): number;
  9472. /**
  9473. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9474. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9475. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9476. */
  9477. getShadowDirection(faceIndex?: number): Vector3;
  9478. /**
  9479. * Returns the ShadowLight absolute position in the World.
  9480. * @returns the position vector in world space
  9481. */
  9482. getAbsolutePosition(): Vector3;
  9483. /**
  9484. * Sets the ShadowLight direction toward the passed target.
  9485. * @param target The point to target in local space
  9486. * @returns the updated ShadowLight direction
  9487. */
  9488. setDirectionToTarget(target: Vector3): Vector3;
  9489. /**
  9490. * Returns the light rotation in euler definition.
  9491. * @returns the x y z rotation in local space.
  9492. */
  9493. getRotation(): Vector3;
  9494. /**
  9495. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9496. * @returns true if a cube texture needs to be use
  9497. */
  9498. needCube(): boolean;
  9499. /**
  9500. * Detects if the projection matrix requires to be recomputed this frame.
  9501. * @returns true if it requires to be recomputed otherwise, false.
  9502. */
  9503. needProjectionMatrixCompute(): boolean;
  9504. /**
  9505. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9506. */
  9507. forceProjectionMatrixCompute(): void;
  9508. /** @hidden */
  9509. _initCache(): void;
  9510. /** @hidden */
  9511. _isSynchronized(): boolean;
  9512. /**
  9513. * Computes the world matrix of the node
  9514. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9515. * @returns the world matrix
  9516. */
  9517. computeWorldMatrix(force?: boolean): Matrix;
  9518. /**
  9519. * Gets the minZ used for shadow according to both the scene and the light.
  9520. * @param activeCamera The camera we are returning the min for
  9521. * @returns the depth min z
  9522. */
  9523. getDepthMinZ(activeCamera: Camera): number;
  9524. /**
  9525. * Gets the maxZ used for shadow according to both the scene and the light.
  9526. * @param activeCamera The camera we are returning the max for
  9527. * @returns the depth max z
  9528. */
  9529. getDepthMaxZ(activeCamera: Camera): number;
  9530. /**
  9531. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9532. * @param matrix The materix to updated with the projection information
  9533. * @param viewMatrix The transform matrix of the light
  9534. * @param renderList The list of mesh to render in the map
  9535. * @returns The current light
  9536. */
  9537. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9538. }
  9539. }
  9540. declare module BABYLON {
  9541. /**
  9542. * Configuration needed for prepass-capable materials
  9543. */
  9544. export class PrePassConfiguration {
  9545. /**
  9546. * Previous world matrices of meshes carrying this material
  9547. * Used for computing velocity
  9548. */
  9549. previousWorldMatrices: {
  9550. [index: number]: Matrix;
  9551. };
  9552. /**
  9553. * Previous view project matrix
  9554. * Used for computing velocity
  9555. */
  9556. previousViewProjection: Matrix;
  9557. /**
  9558. * Previous bones of meshes carrying this material
  9559. * Used for computing velocity
  9560. */
  9561. previousBones: {
  9562. [index: number]: Float32Array;
  9563. };
  9564. /**
  9565. * Add the required uniforms to the current list.
  9566. * @param uniforms defines the current uniform list.
  9567. */
  9568. static AddUniforms(uniforms: string[]): void;
  9569. /**
  9570. * Add the required samplers to the current list.
  9571. * @param samplers defines the current sampler list.
  9572. */
  9573. static AddSamplers(samplers: string[]): void;
  9574. /**
  9575. * Binds the material data.
  9576. * @param effect defines the effect to update
  9577. * @param scene defines the scene the material belongs to.
  9578. * @param mesh The mesh
  9579. * @param world World matrix of this mesh
  9580. * @param isFrozen Is the material frozen
  9581. */
  9582. bindForSubMesh(effect: Effect, scene: Scene, mesh: Mesh, world: Matrix, isFrozen: boolean): void;
  9583. }
  9584. }
  9585. declare module BABYLON {
  9586. /**
  9587. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  9588. * This is the base of the follow, arc rotate cameras and Free camera
  9589. * @see https://doc.babylonjs.com/features/cameras
  9590. */
  9591. export class TargetCamera extends Camera {
  9592. private static _RigCamTransformMatrix;
  9593. private static _TargetTransformMatrix;
  9594. private static _TargetFocalPoint;
  9595. private _tmpUpVector;
  9596. private _tmpTargetVector;
  9597. /**
  9598. * Define the current direction the camera is moving to
  9599. */
  9600. cameraDirection: Vector3;
  9601. /**
  9602. * Define the current rotation the camera is rotating to
  9603. */
  9604. cameraRotation: Vector2;
  9605. /** Gets or sets a boolean indicating that the scaling of the parent hierarchy will not be taken in account by the camera */
  9606. ignoreParentScaling: boolean;
  9607. /**
  9608. * When set, the up vector of the camera will be updated by the rotation of the camera
  9609. */
  9610. updateUpVectorFromRotation: boolean;
  9611. private _tmpQuaternion;
  9612. /**
  9613. * Define the current rotation of the camera
  9614. */
  9615. rotation: Vector3;
  9616. /**
  9617. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  9618. */
  9619. rotationQuaternion: Quaternion;
  9620. /**
  9621. * Define the current speed of the camera
  9622. */
  9623. speed: number;
  9624. /**
  9625. * Add constraint to the camera to prevent it to move freely in all directions and
  9626. * around all axis.
  9627. */
  9628. noRotationConstraint: boolean;
  9629. /**
  9630. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  9631. * panning
  9632. */
  9633. invertRotation: boolean;
  9634. /**
  9635. * Speed multiplier for inverse camera panning
  9636. */
  9637. inverseRotationSpeed: number;
  9638. /**
  9639. * Define the current target of the camera as an object or a position.
  9640. */
  9641. lockedTarget: any;
  9642. /** @hidden */
  9643. _currentTarget: Vector3;
  9644. /** @hidden */
  9645. _initialFocalDistance: number;
  9646. /** @hidden */
  9647. _viewMatrix: Matrix;
  9648. /** @hidden */
  9649. _camMatrix: Matrix;
  9650. /** @hidden */
  9651. _cameraTransformMatrix: Matrix;
  9652. /** @hidden */
  9653. _cameraRotationMatrix: Matrix;
  9654. /** @hidden */
  9655. _referencePoint: Vector3;
  9656. /** @hidden */
  9657. _transformedReferencePoint: Vector3;
  9658. /** @hidden */
  9659. _reset: () => void;
  9660. private _defaultUp;
  9661. /**
  9662. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  9663. * This is the base of the follow, arc rotate cameras and Free camera
  9664. * @see https://doc.babylonjs.com/features/cameras
  9665. * @param name Defines the name of the camera in the scene
  9666. * @param position Defines the start position of the camera in the scene
  9667. * @param scene Defines the scene the camera belongs to
  9668. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  9669. */
  9670. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  9671. /**
  9672. * Gets the position in front of the camera at a given distance.
  9673. * @param distance The distance from the camera we want the position to be
  9674. * @returns the position
  9675. */
  9676. getFrontPosition(distance: number): Vector3;
  9677. /** @hidden */
  9678. _getLockedTargetPosition(): Nullable<Vector3>;
  9679. private _storedPosition;
  9680. private _storedRotation;
  9681. private _storedRotationQuaternion;
  9682. /**
  9683. * Store current camera state of the camera (fov, position, rotation, etc..)
  9684. * @returns the camera
  9685. */
  9686. storeState(): Camera;
  9687. /**
  9688. * Restored camera state. You must call storeState() first
  9689. * @returns whether it was successful or not
  9690. * @hidden
  9691. */
  9692. _restoreStateValues(): boolean;
  9693. /** @hidden */
  9694. _initCache(): void;
  9695. /** @hidden */
  9696. _updateCache(ignoreParentClass?: boolean): void;
  9697. /** @hidden */
  9698. _isSynchronizedViewMatrix(): boolean;
  9699. /** @hidden */
  9700. _computeLocalCameraSpeed(): number;
  9701. /**
  9702. * Defines the target the camera should look at.
  9703. * @param target Defines the new target as a Vector or a mesh
  9704. */
  9705. setTarget(target: Vector3): void;
  9706. /**
  9707. * Defines the target point of the camera.
  9708. * The camera looks towards it form the radius distance.
  9709. */
  9710. get target(): Vector3;
  9711. set target(value: Vector3);
  9712. /**
  9713. * Return the current target position of the camera. This value is expressed in local space.
  9714. * @returns the target position
  9715. */
  9716. getTarget(): Vector3;
  9717. /** @hidden */
  9718. _decideIfNeedsToMove(): boolean;
  9719. /** @hidden */
  9720. _updatePosition(): void;
  9721. /** @hidden */
  9722. _checkInputs(): void;
  9723. protected _updateCameraRotationMatrix(): void;
  9724. /**
  9725. * 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)
  9726. * @returns the current camera
  9727. */
  9728. private _rotateUpVectorWithCameraRotationMatrix;
  9729. private _cachedRotationZ;
  9730. private _cachedQuaternionRotationZ;
  9731. /** @hidden */
  9732. _getViewMatrix(): Matrix;
  9733. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  9734. /**
  9735. * @hidden
  9736. */
  9737. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  9738. /**
  9739. * @hidden
  9740. */
  9741. _updateRigCameras(): void;
  9742. private _getRigCamPositionAndTarget;
  9743. /**
  9744. * Gets the current object class name.
  9745. * @return the class name
  9746. */
  9747. getClassName(): string;
  9748. }
  9749. }
  9750. declare module BABYLON {
  9751. /**
  9752. * @ignore
  9753. * This is a list of all the different input types that are available in the application.
  9754. * Fo instance: ArcRotateCameraGamepadInput...
  9755. */
  9756. export var CameraInputTypes: {};
  9757. /**
  9758. * This is the contract to implement in order to create a new input class.
  9759. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  9760. */
  9761. export interface ICameraInput<TCamera extends Camera> {
  9762. /**
  9763. * Defines the camera the input is attached to.
  9764. */
  9765. camera: Nullable<TCamera>;
  9766. /**
  9767. * Gets the class name of the current intput.
  9768. * @returns the class name
  9769. */
  9770. getClassName(): string;
  9771. /**
  9772. * Get the friendly name associated with the input class.
  9773. * @returns the input friendly name
  9774. */
  9775. getSimpleName(): string;
  9776. /**
  9777. * Attach the input controls to a specific dom element to get the input from.
  9778. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  9779. */
  9780. attachControl(noPreventDefault?: boolean): void;
  9781. /**
  9782. * Detach the current controls from the specified dom element.
  9783. */
  9784. detachControl(): void;
  9785. /**
  9786. * Update the current camera state depending on the inputs that have been used this frame.
  9787. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  9788. */
  9789. checkInputs?: () => void;
  9790. }
  9791. /**
  9792. * Represents a map of input types to input instance or input index to input instance.
  9793. */
  9794. export interface CameraInputsMap<TCamera extends Camera> {
  9795. /**
  9796. * Accessor to the input by input type.
  9797. */
  9798. [name: string]: ICameraInput<TCamera>;
  9799. /**
  9800. * Accessor to the input by input index.
  9801. */
  9802. [idx: number]: ICameraInput<TCamera>;
  9803. }
  9804. /**
  9805. * This represents the input manager used within a camera.
  9806. * It helps dealing with all the different kind of input attached to a camera.
  9807. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  9808. */
  9809. export class CameraInputsManager<TCamera extends Camera> {
  9810. /**
  9811. * Defines the list of inputs attahed to the camera.
  9812. */
  9813. attached: CameraInputsMap<TCamera>;
  9814. /**
  9815. * Defines the dom element the camera is collecting inputs from.
  9816. * This is null if the controls have not been attached.
  9817. */
  9818. attachedToElement: boolean;
  9819. /**
  9820. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  9821. */
  9822. noPreventDefault: boolean;
  9823. /**
  9824. * Defined the camera the input manager belongs to.
  9825. */
  9826. camera: TCamera;
  9827. /**
  9828. * Update the current camera state depending on the inputs that have been used this frame.
  9829. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  9830. */
  9831. checkInputs: () => void;
  9832. /**
  9833. * Instantiate a new Camera Input Manager.
  9834. * @param camera Defines the camera the input manager blongs to
  9835. */
  9836. constructor(camera: TCamera);
  9837. /**
  9838. * Add an input method to a camera
  9839. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  9840. * @param input camera input method
  9841. */
  9842. add(input: ICameraInput<TCamera>): void;
  9843. /**
  9844. * Remove a specific input method from a camera
  9845. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  9846. * @param inputToRemove camera input method
  9847. */
  9848. remove(inputToRemove: ICameraInput<TCamera>): void;
  9849. /**
  9850. * Remove a specific input type from a camera
  9851. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  9852. * @param inputType the type of the input to remove
  9853. */
  9854. removeByType(inputType: string): void;
  9855. private _addCheckInputs;
  9856. /**
  9857. * Attach the input controls to the currently attached dom element to listen the events from.
  9858. * @param input Defines the input to attach
  9859. */
  9860. attachInput(input: ICameraInput<TCamera>): void;
  9861. /**
  9862. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  9863. * @param element Defines the dom element to collect the events from
  9864. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  9865. */
  9866. attachElement(noPreventDefault?: boolean): void;
  9867. /**
  9868. * Detach the current manager inputs controls from a specific dom element.
  9869. * @param element Defines the dom element to collect the events from
  9870. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  9871. */
  9872. detachElement(disconnect?: boolean): void;
  9873. /**
  9874. * Rebuild the dynamic inputCheck function from the current list of
  9875. * defined inputs in the manager.
  9876. */
  9877. rebuildInputCheck(): void;
  9878. /**
  9879. * Remove all attached input methods from a camera
  9880. */
  9881. clear(): void;
  9882. /**
  9883. * Serialize the current input manager attached to a camera.
  9884. * This ensures than once parsed,
  9885. * the input associated to the camera will be identical to the current ones
  9886. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  9887. */
  9888. serialize(serializedCamera: any): void;
  9889. /**
  9890. * Parses an input manager serialized JSON to restore the previous list of inputs
  9891. * and states associated to a camera.
  9892. * @param parsedCamera Defines the JSON to parse
  9893. */
  9894. parse(parsedCamera: any): void;
  9895. }
  9896. }
  9897. declare module BABYLON {
  9898. /**
  9899. * Gather the list of keyboard event types as constants.
  9900. */
  9901. export class KeyboardEventTypes {
  9902. /**
  9903. * The keydown event is fired when a key becomes active (pressed).
  9904. */
  9905. static readonly KEYDOWN: number;
  9906. /**
  9907. * The keyup event is fired when a key has been released.
  9908. */
  9909. static readonly KEYUP: number;
  9910. }
  9911. /**
  9912. * This class is used to store keyboard related info for the onKeyboardObservable event.
  9913. */
  9914. export class KeyboardInfo {
  9915. /**
  9916. * Defines the type of event (KeyboardEventTypes)
  9917. */
  9918. type: number;
  9919. /**
  9920. * Defines the related dom event
  9921. */
  9922. event: KeyboardEvent;
  9923. /**
  9924. * Instantiates a new keyboard info.
  9925. * This class is used to store keyboard related info for the onKeyboardObservable event.
  9926. * @param type Defines the type of event (KeyboardEventTypes)
  9927. * @param event Defines the related dom event
  9928. */
  9929. constructor(
  9930. /**
  9931. * Defines the type of event (KeyboardEventTypes)
  9932. */
  9933. type: number,
  9934. /**
  9935. * Defines the related dom event
  9936. */
  9937. event: KeyboardEvent);
  9938. }
  9939. /**
  9940. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  9941. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  9942. */
  9943. export class KeyboardInfoPre extends KeyboardInfo {
  9944. /**
  9945. * Defines the type of event (KeyboardEventTypes)
  9946. */
  9947. type: number;
  9948. /**
  9949. * Defines the related dom event
  9950. */
  9951. event: KeyboardEvent;
  9952. /**
  9953. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  9954. */
  9955. skipOnPointerObservable: boolean;
  9956. /**
  9957. * Instantiates a new keyboard pre info.
  9958. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  9959. * @param type Defines the type of event (KeyboardEventTypes)
  9960. * @param event Defines the related dom event
  9961. */
  9962. constructor(
  9963. /**
  9964. * Defines the type of event (KeyboardEventTypes)
  9965. */
  9966. type: number,
  9967. /**
  9968. * Defines the related dom event
  9969. */
  9970. event: KeyboardEvent);
  9971. }
  9972. }
  9973. declare module BABYLON {
  9974. /**
  9975. * Manage the keyboard inputs to control the movement of a free camera.
  9976. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  9977. */
  9978. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  9979. /**
  9980. * Defines the camera the input is attached to.
  9981. */
  9982. camera: FreeCamera;
  9983. /**
  9984. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  9985. */
  9986. keysUp: number[];
  9987. /**
  9988. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  9989. */
  9990. keysUpward: number[];
  9991. /**
  9992. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  9993. */
  9994. keysDown: number[];
  9995. /**
  9996. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  9997. */
  9998. keysDownward: number[];
  9999. /**
  10000. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  10001. */
  10002. keysLeft: number[];
  10003. /**
  10004. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  10005. */
  10006. keysRight: number[];
  10007. private _keys;
  10008. private _onCanvasBlurObserver;
  10009. private _onKeyboardObserver;
  10010. private _engine;
  10011. private _scene;
  10012. /**
  10013. * Attach the input controls to a specific dom element to get the input from.
  10014. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  10015. */
  10016. attachControl(noPreventDefault?: boolean): void;
  10017. /**
  10018. * Detach the current controls from the specified dom element.
  10019. */
  10020. detachControl(): void;
  10021. /**
  10022. * Update the current camera state depending on the inputs that have been used this frame.
  10023. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  10024. */
  10025. checkInputs(): void;
  10026. /**
  10027. * Gets the class name of the current intput.
  10028. * @returns the class name
  10029. */
  10030. getClassName(): string;
  10031. /** @hidden */
  10032. _onLostFocus(): void;
  10033. /**
  10034. * Get the friendly name associated with the input class.
  10035. * @returns the input friendly name
  10036. */
  10037. getSimpleName(): string;
  10038. }
  10039. }
  10040. declare module BABYLON {
  10041. /**
  10042. * Interface used to define Action
  10043. */
  10044. export interface IAction {
  10045. /**
  10046. * Trigger for the action
  10047. */
  10048. trigger: number;
  10049. /** Options of the trigger */
  10050. triggerOptions: any;
  10051. /**
  10052. * Gets the trigger parameters
  10053. * @returns the trigger parameters
  10054. */
  10055. getTriggerParameter(): any;
  10056. /**
  10057. * Internal only - executes current action event
  10058. * @hidden
  10059. */
  10060. _executeCurrent(evt?: ActionEvent): void;
  10061. /**
  10062. * Serialize placeholder for child classes
  10063. * @param parent of child
  10064. * @returns the serialized object
  10065. */
  10066. serialize(parent: any): any;
  10067. /**
  10068. * Internal only
  10069. * @hidden
  10070. */
  10071. _prepare(): void;
  10072. /**
  10073. * Internal only - manager for action
  10074. * @hidden
  10075. */
  10076. _actionManager: Nullable<AbstractActionManager>;
  10077. /**
  10078. * Adds action to chain of actions, may be a DoNothingAction
  10079. * @param action defines the next action to execute
  10080. * @returns The action passed in
  10081. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10082. */
  10083. then(action: IAction): IAction;
  10084. }
  10085. /**
  10086. * The action to be carried out following a trigger
  10087. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10088. */
  10089. export class Action implements IAction {
  10090. /** the trigger, with or without parameters, for the action */
  10091. triggerOptions: any;
  10092. /**
  10093. * Trigger for the action
  10094. */
  10095. trigger: number;
  10096. /**
  10097. * Internal only - manager for action
  10098. * @hidden
  10099. */
  10100. _actionManager: ActionManager;
  10101. private _nextActiveAction;
  10102. private _child;
  10103. private _condition?;
  10104. private _triggerParameter;
  10105. /**
  10106. * An event triggered prior to action being executed.
  10107. */
  10108. onBeforeExecuteObservable: Observable<Action>;
  10109. /**
  10110. * Creates a new Action
  10111. * @param triggerOptions the trigger, with or without parameters, for the action
  10112. * @param condition an optional determinant of action
  10113. */
  10114. constructor(
  10115. /** the trigger, with or without parameters, for the action */
  10116. triggerOptions: any, condition?: Condition);
  10117. /**
  10118. * Internal only
  10119. * @hidden
  10120. */
  10121. _prepare(): void;
  10122. /**
  10123. * Gets the trigger parameter
  10124. * @returns the trigger parameter
  10125. */
  10126. getTriggerParameter(): any;
  10127. /**
  10128. * Sets the trigger parameter
  10129. * @param value defines the new trigger parameter
  10130. */
  10131. setTriggerParameter(value: any): void;
  10132. /**
  10133. * Internal only - executes current action event
  10134. * @hidden
  10135. */
  10136. _executeCurrent(evt?: ActionEvent): void;
  10137. /**
  10138. * Execute placeholder for child classes
  10139. * @param evt optional action event
  10140. */
  10141. execute(evt?: ActionEvent): void;
  10142. /**
  10143. * Skips to next active action
  10144. */
  10145. skipToNextActiveAction(): void;
  10146. /**
  10147. * Adds action to chain of actions, may be a DoNothingAction
  10148. * @param action defines the next action to execute
  10149. * @returns The action passed in
  10150. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10151. */
  10152. then(action: Action): Action;
  10153. /**
  10154. * Internal only
  10155. * @hidden
  10156. */
  10157. _getProperty(propertyPath: string): string;
  10158. /**
  10159. * Internal only
  10160. * @hidden
  10161. */
  10162. _getEffectiveTarget(target: any, propertyPath: string): any;
  10163. /**
  10164. * Serialize placeholder for child classes
  10165. * @param parent of child
  10166. * @returns the serialized object
  10167. */
  10168. serialize(parent: any): any;
  10169. /**
  10170. * Internal only called by serialize
  10171. * @hidden
  10172. */
  10173. protected _serialize(serializedAction: any, parent?: any): any;
  10174. /**
  10175. * Internal only
  10176. * @hidden
  10177. */
  10178. static _SerializeValueAsString: (value: any) => string;
  10179. /**
  10180. * Internal only
  10181. * @hidden
  10182. */
  10183. static _GetTargetProperty: (target: Scene | Node) => {
  10184. name: string;
  10185. targetType: string;
  10186. value: string;
  10187. };
  10188. }
  10189. }
  10190. declare module BABYLON {
  10191. /**
  10192. * A Condition applied to an Action
  10193. */
  10194. export class Condition {
  10195. /**
  10196. * Internal only - manager for action
  10197. * @hidden
  10198. */
  10199. _actionManager: ActionManager;
  10200. /**
  10201. * Internal only
  10202. * @hidden
  10203. */
  10204. _evaluationId: number;
  10205. /**
  10206. * Internal only
  10207. * @hidden
  10208. */
  10209. _currentResult: boolean;
  10210. /**
  10211. * Creates a new Condition
  10212. * @param actionManager the manager of the action the condition is applied to
  10213. */
  10214. constructor(actionManager: ActionManager);
  10215. /**
  10216. * Check if the current condition is valid
  10217. * @returns a boolean
  10218. */
  10219. isValid(): boolean;
  10220. /**
  10221. * Internal only
  10222. * @hidden
  10223. */
  10224. _getProperty(propertyPath: string): string;
  10225. /**
  10226. * Internal only
  10227. * @hidden
  10228. */
  10229. _getEffectiveTarget(target: any, propertyPath: string): any;
  10230. /**
  10231. * Serialize placeholder for child classes
  10232. * @returns the serialized object
  10233. */
  10234. serialize(): any;
  10235. /**
  10236. * Internal only
  10237. * @hidden
  10238. */
  10239. protected _serialize(serializedCondition: any): any;
  10240. }
  10241. /**
  10242. * Defines specific conditional operators as extensions of Condition
  10243. */
  10244. export class ValueCondition extends Condition {
  10245. /** path to specify the property of the target the conditional operator uses */
  10246. propertyPath: string;
  10247. /** the value compared by the conditional operator against the current value of the property */
  10248. value: any;
  10249. /** the conditional operator, default ValueCondition.IsEqual */
  10250. operator: number;
  10251. /**
  10252. * Internal only
  10253. * @hidden
  10254. */
  10255. private static _IsEqual;
  10256. /**
  10257. * Internal only
  10258. * @hidden
  10259. */
  10260. private static _IsDifferent;
  10261. /**
  10262. * Internal only
  10263. * @hidden
  10264. */
  10265. private static _IsGreater;
  10266. /**
  10267. * Internal only
  10268. * @hidden
  10269. */
  10270. private static _IsLesser;
  10271. /**
  10272. * returns the number for IsEqual
  10273. */
  10274. static get IsEqual(): number;
  10275. /**
  10276. * Returns the number for IsDifferent
  10277. */
  10278. static get IsDifferent(): number;
  10279. /**
  10280. * Returns the number for IsGreater
  10281. */
  10282. static get IsGreater(): number;
  10283. /**
  10284. * Returns the number for IsLesser
  10285. */
  10286. static get IsLesser(): number;
  10287. /**
  10288. * Internal only The action manager for the condition
  10289. * @hidden
  10290. */
  10291. _actionManager: ActionManager;
  10292. /**
  10293. * Internal only
  10294. * @hidden
  10295. */
  10296. private _target;
  10297. /**
  10298. * Internal only
  10299. * @hidden
  10300. */
  10301. private _effectiveTarget;
  10302. /**
  10303. * Internal only
  10304. * @hidden
  10305. */
  10306. private _property;
  10307. /**
  10308. * Creates a new ValueCondition
  10309. * @param actionManager manager for the action the condition applies to
  10310. * @param target for the action
  10311. * @param propertyPath path to specify the property of the target the conditional operator uses
  10312. * @param value the value compared by the conditional operator against the current value of the property
  10313. * @param operator the conditional operator, default ValueCondition.IsEqual
  10314. */
  10315. constructor(actionManager: ActionManager, target: any,
  10316. /** path to specify the property of the target the conditional operator uses */
  10317. propertyPath: string,
  10318. /** the value compared by the conditional operator against the current value of the property */
  10319. value: any,
  10320. /** the conditional operator, default ValueCondition.IsEqual */
  10321. operator?: number);
  10322. /**
  10323. * Compares the given value with the property value for the specified conditional operator
  10324. * @returns the result of the comparison
  10325. */
  10326. isValid(): boolean;
  10327. /**
  10328. * Serialize the ValueCondition into a JSON compatible object
  10329. * @returns serialization object
  10330. */
  10331. serialize(): any;
  10332. /**
  10333. * Gets the name of the conditional operator for the ValueCondition
  10334. * @param operator the conditional operator
  10335. * @returns the name
  10336. */
  10337. static GetOperatorName(operator: number): string;
  10338. }
  10339. /**
  10340. * Defines a predicate condition as an extension of Condition
  10341. */
  10342. export class PredicateCondition extends Condition {
  10343. /** defines the predicate function used to validate the condition */
  10344. predicate: () => boolean;
  10345. /**
  10346. * Internal only - manager for action
  10347. * @hidden
  10348. */
  10349. _actionManager: ActionManager;
  10350. /**
  10351. * Creates a new PredicateCondition
  10352. * @param actionManager manager for the action the condition applies to
  10353. * @param predicate defines the predicate function used to validate the condition
  10354. */
  10355. constructor(actionManager: ActionManager,
  10356. /** defines the predicate function used to validate the condition */
  10357. predicate: () => boolean);
  10358. /**
  10359. * @returns the validity of the predicate condition
  10360. */
  10361. isValid(): boolean;
  10362. }
  10363. /**
  10364. * Defines a state condition as an extension of Condition
  10365. */
  10366. export class StateCondition extends Condition {
  10367. /** Value to compare with target state */
  10368. value: string;
  10369. /**
  10370. * Internal only - manager for action
  10371. * @hidden
  10372. */
  10373. _actionManager: ActionManager;
  10374. /**
  10375. * Internal only
  10376. * @hidden
  10377. */
  10378. private _target;
  10379. /**
  10380. * Creates a new StateCondition
  10381. * @param actionManager manager for the action the condition applies to
  10382. * @param target of the condition
  10383. * @param value to compare with target state
  10384. */
  10385. constructor(actionManager: ActionManager, target: any,
  10386. /** Value to compare with target state */
  10387. value: string);
  10388. /**
  10389. * Gets a boolean indicating if the current condition is met
  10390. * @returns the validity of the state
  10391. */
  10392. isValid(): boolean;
  10393. /**
  10394. * Serialize the StateCondition into a JSON compatible object
  10395. * @returns serialization object
  10396. */
  10397. serialize(): any;
  10398. }
  10399. }
  10400. declare module BABYLON {
  10401. /**
  10402. * This defines an action responsible to toggle a boolean once triggered.
  10403. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10404. */
  10405. export class SwitchBooleanAction extends Action {
  10406. /**
  10407. * The path to the boolean property in the target object
  10408. */
  10409. propertyPath: string;
  10410. private _target;
  10411. private _effectiveTarget;
  10412. private _property;
  10413. /**
  10414. * Instantiate the action
  10415. * @param triggerOptions defines the trigger options
  10416. * @param target defines the object containing the boolean
  10417. * @param propertyPath defines the path to the boolean property in the target object
  10418. * @param condition defines the trigger related conditions
  10419. */
  10420. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10421. /** @hidden */
  10422. _prepare(): void;
  10423. /**
  10424. * Execute the action toggle the boolean value.
  10425. */
  10426. execute(): void;
  10427. /**
  10428. * Serializes the actions and its related information.
  10429. * @param parent defines the object to serialize in
  10430. * @returns the serialized object
  10431. */
  10432. serialize(parent: any): any;
  10433. }
  10434. /**
  10435. * This defines an action responsible to set a the state field of the target
  10436. * to a desired value once triggered.
  10437. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10438. */
  10439. export class SetStateAction extends Action {
  10440. /**
  10441. * The value to store in the state field.
  10442. */
  10443. value: string;
  10444. private _target;
  10445. /**
  10446. * Instantiate the action
  10447. * @param triggerOptions defines the trigger options
  10448. * @param target defines the object containing the state property
  10449. * @param value defines the value to store in the state field
  10450. * @param condition defines the trigger related conditions
  10451. */
  10452. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10453. /**
  10454. * Execute the action and store the value on the target state property.
  10455. */
  10456. execute(): void;
  10457. /**
  10458. * Serializes the actions and its related information.
  10459. * @param parent defines the object to serialize in
  10460. * @returns the serialized object
  10461. */
  10462. serialize(parent: any): any;
  10463. }
  10464. /**
  10465. * This defines an action responsible to set a property of the target
  10466. * to a desired value once triggered.
  10467. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10468. */
  10469. export class SetValueAction extends Action {
  10470. /**
  10471. * The path of the property to set in the target.
  10472. */
  10473. propertyPath: string;
  10474. /**
  10475. * The value to set in the property
  10476. */
  10477. value: any;
  10478. private _target;
  10479. private _effectiveTarget;
  10480. private _property;
  10481. /**
  10482. * Instantiate the action
  10483. * @param triggerOptions defines the trigger options
  10484. * @param target defines the object containing the property
  10485. * @param propertyPath defines the path of the property to set in the target
  10486. * @param value defines the value to set in the property
  10487. * @param condition defines the trigger related conditions
  10488. */
  10489. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10490. /** @hidden */
  10491. _prepare(): void;
  10492. /**
  10493. * Execute the action and set the targetted property to the desired value.
  10494. */
  10495. execute(): void;
  10496. /**
  10497. * Serializes the actions and its related information.
  10498. * @param parent defines the object to serialize in
  10499. * @returns the serialized object
  10500. */
  10501. serialize(parent: any): any;
  10502. }
  10503. /**
  10504. * This defines an action responsible to increment the target value
  10505. * to a desired value once triggered.
  10506. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10507. */
  10508. export class IncrementValueAction extends Action {
  10509. /**
  10510. * The path of the property to increment in the target.
  10511. */
  10512. propertyPath: string;
  10513. /**
  10514. * The value we should increment the property by.
  10515. */
  10516. value: any;
  10517. private _target;
  10518. private _effectiveTarget;
  10519. private _property;
  10520. /**
  10521. * Instantiate the action
  10522. * @param triggerOptions defines the trigger options
  10523. * @param target defines the object containing the property
  10524. * @param propertyPath defines the path of the property to increment in the target
  10525. * @param value defines the value value we should increment the property by
  10526. * @param condition defines the trigger related conditions
  10527. */
  10528. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10529. /** @hidden */
  10530. _prepare(): void;
  10531. /**
  10532. * Execute the action and increment the target of the value amount.
  10533. */
  10534. execute(): void;
  10535. /**
  10536. * Serializes the actions and its related information.
  10537. * @param parent defines the object to serialize in
  10538. * @returns the serialized object
  10539. */
  10540. serialize(parent: any): any;
  10541. }
  10542. /**
  10543. * This defines an action responsible to start an animation once triggered.
  10544. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10545. */
  10546. export class PlayAnimationAction extends Action {
  10547. /**
  10548. * Where the animation should start (animation frame)
  10549. */
  10550. from: number;
  10551. /**
  10552. * Where the animation should stop (animation frame)
  10553. */
  10554. to: number;
  10555. /**
  10556. * Define if the animation should loop or stop after the first play.
  10557. */
  10558. loop?: boolean;
  10559. private _target;
  10560. /**
  10561. * Instantiate the action
  10562. * @param triggerOptions defines the trigger options
  10563. * @param target defines the target animation or animation name
  10564. * @param from defines from where the animation should start (animation frame)
  10565. * @param end defines where the animation should stop (animation frame)
  10566. * @param loop defines if the animation should loop or stop after the first play
  10567. * @param condition defines the trigger related conditions
  10568. */
  10569. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10570. /** @hidden */
  10571. _prepare(): void;
  10572. /**
  10573. * Execute the action and play the animation.
  10574. */
  10575. execute(): void;
  10576. /**
  10577. * Serializes the actions and its related information.
  10578. * @param parent defines the object to serialize in
  10579. * @returns the serialized object
  10580. */
  10581. serialize(parent: any): any;
  10582. }
  10583. /**
  10584. * This defines an action responsible to stop an animation once triggered.
  10585. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10586. */
  10587. export class StopAnimationAction extends Action {
  10588. private _target;
  10589. /**
  10590. * Instantiate the action
  10591. * @param triggerOptions defines the trigger options
  10592. * @param target defines the target animation or animation name
  10593. * @param condition defines the trigger related conditions
  10594. */
  10595. constructor(triggerOptions: any, target: any, condition?: Condition);
  10596. /** @hidden */
  10597. _prepare(): void;
  10598. /**
  10599. * Execute the action and stop the animation.
  10600. */
  10601. execute(): void;
  10602. /**
  10603. * Serializes the actions and its related information.
  10604. * @param parent defines the object to serialize in
  10605. * @returns the serialized object
  10606. */
  10607. serialize(parent: any): any;
  10608. }
  10609. /**
  10610. * This defines an action responsible that does nothing once triggered.
  10611. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10612. */
  10613. export class DoNothingAction extends Action {
  10614. /**
  10615. * Instantiate the action
  10616. * @param triggerOptions defines the trigger options
  10617. * @param condition defines the trigger related conditions
  10618. */
  10619. constructor(triggerOptions?: any, condition?: Condition);
  10620. /**
  10621. * Execute the action and do nothing.
  10622. */
  10623. execute(): void;
  10624. /**
  10625. * Serializes the actions and its related information.
  10626. * @param parent defines the object to serialize in
  10627. * @returns the serialized object
  10628. */
  10629. serialize(parent: any): any;
  10630. }
  10631. /**
  10632. * This defines an action responsible to trigger several actions once triggered.
  10633. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10634. */
  10635. export class CombineAction extends Action {
  10636. /**
  10637. * The list of aggregated animations to run.
  10638. */
  10639. children: Action[];
  10640. /**
  10641. * Instantiate the action
  10642. * @param triggerOptions defines the trigger options
  10643. * @param children defines the list of aggregated animations to run
  10644. * @param condition defines the trigger related conditions
  10645. */
  10646. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10647. /** @hidden */
  10648. _prepare(): void;
  10649. /**
  10650. * Execute the action and executes all the aggregated actions.
  10651. */
  10652. execute(evt: ActionEvent): void;
  10653. /**
  10654. * Serializes the actions and its related information.
  10655. * @param parent defines the object to serialize in
  10656. * @returns the serialized object
  10657. */
  10658. serialize(parent: any): any;
  10659. }
  10660. /**
  10661. * This defines an action responsible to run code (external event) once triggered.
  10662. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10663. */
  10664. export class ExecuteCodeAction extends Action {
  10665. /**
  10666. * The callback function to run.
  10667. */
  10668. func: (evt: ActionEvent) => void;
  10669. /**
  10670. * Instantiate the action
  10671. * @param triggerOptions defines the trigger options
  10672. * @param func defines the callback function to run
  10673. * @param condition defines the trigger related conditions
  10674. */
  10675. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10676. /**
  10677. * Execute the action and run the attached code.
  10678. */
  10679. execute(evt: ActionEvent): void;
  10680. }
  10681. /**
  10682. * This defines an action responsible to set the parent property of the target once triggered.
  10683. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10684. */
  10685. export class SetParentAction extends Action {
  10686. private _parent;
  10687. private _target;
  10688. /**
  10689. * Instantiate the action
  10690. * @param triggerOptions defines the trigger options
  10691. * @param target defines the target containing the parent property
  10692. * @param parent defines from where the animation should start (animation frame)
  10693. * @param condition defines the trigger related conditions
  10694. */
  10695. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10696. /** @hidden */
  10697. _prepare(): void;
  10698. /**
  10699. * Execute the action and set the parent property.
  10700. */
  10701. execute(): void;
  10702. /**
  10703. * Serializes the actions and its related information.
  10704. * @param parent defines the object to serialize in
  10705. * @returns the serialized object
  10706. */
  10707. serialize(parent: any): any;
  10708. }
  10709. }
  10710. declare module BABYLON {
  10711. /**
  10712. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10713. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10714. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10715. */
  10716. export class ActionManager extends AbstractActionManager {
  10717. /**
  10718. * Nothing
  10719. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10720. */
  10721. static readonly NothingTrigger: number;
  10722. /**
  10723. * On pick
  10724. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10725. */
  10726. static readonly OnPickTrigger: number;
  10727. /**
  10728. * On left pick
  10729. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10730. */
  10731. static readonly OnLeftPickTrigger: number;
  10732. /**
  10733. * On right pick
  10734. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10735. */
  10736. static readonly OnRightPickTrigger: number;
  10737. /**
  10738. * On center pick
  10739. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10740. */
  10741. static readonly OnCenterPickTrigger: number;
  10742. /**
  10743. * On pick down
  10744. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10745. */
  10746. static readonly OnPickDownTrigger: number;
  10747. /**
  10748. * On double pick
  10749. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10750. */
  10751. static readonly OnDoublePickTrigger: number;
  10752. /**
  10753. * On pick up
  10754. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10755. */
  10756. static readonly OnPickUpTrigger: number;
  10757. /**
  10758. * On pick out.
  10759. * This trigger will only be raised if you also declared a OnPickDown
  10760. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10761. */
  10762. static readonly OnPickOutTrigger: number;
  10763. /**
  10764. * On long press
  10765. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10766. */
  10767. static readonly OnLongPressTrigger: number;
  10768. /**
  10769. * On pointer over
  10770. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10771. */
  10772. static readonly OnPointerOverTrigger: number;
  10773. /**
  10774. * On pointer out
  10775. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10776. */
  10777. static readonly OnPointerOutTrigger: number;
  10778. /**
  10779. * On every frame
  10780. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10781. */
  10782. static readonly OnEveryFrameTrigger: number;
  10783. /**
  10784. * On intersection enter
  10785. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10786. */
  10787. static readonly OnIntersectionEnterTrigger: number;
  10788. /**
  10789. * On intersection exit
  10790. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10791. */
  10792. static readonly OnIntersectionExitTrigger: number;
  10793. /**
  10794. * On key down
  10795. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10796. */
  10797. static readonly OnKeyDownTrigger: number;
  10798. /**
  10799. * On key up
  10800. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10801. */
  10802. static readonly OnKeyUpTrigger: number;
  10803. private _scene;
  10804. /**
  10805. * Creates a new action manager
  10806. * @param scene defines the hosting scene
  10807. */
  10808. constructor(scene: Scene);
  10809. /**
  10810. * Releases all associated resources
  10811. */
  10812. dispose(): void;
  10813. /**
  10814. * Gets hosting scene
  10815. * @returns the hosting scene
  10816. */
  10817. getScene(): Scene;
  10818. /**
  10819. * Does this action manager handles actions of any of the given triggers
  10820. * @param triggers defines the triggers to be tested
  10821. * @return a boolean indicating whether one (or more) of the triggers is handled
  10822. */
  10823. hasSpecificTriggers(triggers: number[]): boolean;
  10824. /**
  10825. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10826. * speed.
  10827. * @param triggerA defines the trigger to be tested
  10828. * @param triggerB defines the trigger to be tested
  10829. * @return a boolean indicating whether one (or more) of the triggers is handled
  10830. */
  10831. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10832. /**
  10833. * Does this action manager handles actions of a given trigger
  10834. * @param trigger defines the trigger to be tested
  10835. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10836. * @return whether the trigger is handled
  10837. */
  10838. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10839. /**
  10840. * Does this action manager has pointer triggers
  10841. */
  10842. get hasPointerTriggers(): boolean;
  10843. /**
  10844. * Does this action manager has pick triggers
  10845. */
  10846. get hasPickTriggers(): boolean;
  10847. /**
  10848. * Registers an action to this action manager
  10849. * @param action defines the action to be registered
  10850. * @return the action amended (prepared) after registration
  10851. */
  10852. registerAction(action: IAction): Nullable<IAction>;
  10853. /**
  10854. * Unregisters an action to this action manager
  10855. * @param action defines the action to be unregistered
  10856. * @return a boolean indicating whether the action has been unregistered
  10857. */
  10858. unregisterAction(action: IAction): Boolean;
  10859. /**
  10860. * Process a specific trigger
  10861. * @param trigger defines the trigger to process
  10862. * @param evt defines the event details to be processed
  10863. */
  10864. processTrigger(trigger: number, evt?: IActionEvent): void;
  10865. /** @hidden */
  10866. _getEffectiveTarget(target: any, propertyPath: string): any;
  10867. /** @hidden */
  10868. _getProperty(propertyPath: string): string;
  10869. /**
  10870. * Serialize this manager to a JSON object
  10871. * @param name defines the property name to store this manager
  10872. * @returns a JSON representation of this manager
  10873. */
  10874. serialize(name: string): any;
  10875. /**
  10876. * Creates a new ActionManager from a JSON data
  10877. * @param parsedActions defines the JSON data to read from
  10878. * @param object defines the hosting mesh
  10879. * @param scene defines the hosting scene
  10880. */
  10881. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  10882. /**
  10883. * Get a trigger name by index
  10884. * @param trigger defines the trigger index
  10885. * @returns a trigger name
  10886. */
  10887. static GetTriggerName(trigger: number): string;
  10888. }
  10889. }
  10890. declare module BABYLON {
  10891. /**
  10892. * Class representing a ray with position and direction
  10893. */
  10894. export class Ray {
  10895. /** origin point */
  10896. origin: Vector3;
  10897. /** direction */
  10898. direction: Vector3;
  10899. /** length of the ray */
  10900. length: number;
  10901. private static readonly _TmpVector3;
  10902. private _tmpRay;
  10903. /**
  10904. * Creates a new ray
  10905. * @param origin origin point
  10906. * @param direction direction
  10907. * @param length length of the ray
  10908. */
  10909. constructor(
  10910. /** origin point */
  10911. origin: Vector3,
  10912. /** direction */
  10913. direction: Vector3,
  10914. /** length of the ray */
  10915. length?: number);
  10916. /**
  10917. * Checks if the ray intersects a box
  10918. * This does not account for the ray lenght by design to improve perfs.
  10919. * @param minimum bound of the box
  10920. * @param maximum bound of the box
  10921. * @param intersectionTreshold extra extend to be added to the box in all direction
  10922. * @returns if the box was hit
  10923. */
  10924. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  10925. /**
  10926. * Checks if the ray intersects a box
  10927. * This does not account for the ray lenght by design to improve perfs.
  10928. * @param box the bounding box to check
  10929. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  10930. * @returns if the box was hit
  10931. */
  10932. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  10933. /**
  10934. * If the ray hits a sphere
  10935. * @param sphere the bounding sphere to check
  10936. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  10937. * @returns true if it hits the sphere
  10938. */
  10939. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  10940. /**
  10941. * If the ray hits a triange
  10942. * @param vertex0 triangle vertex
  10943. * @param vertex1 triangle vertex
  10944. * @param vertex2 triangle vertex
  10945. * @returns intersection information if hit
  10946. */
  10947. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  10948. /**
  10949. * Checks if ray intersects a plane
  10950. * @param plane the plane to check
  10951. * @returns the distance away it was hit
  10952. */
  10953. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  10954. /**
  10955. * Calculate the intercept of a ray on a given axis
  10956. * @param axis to check 'x' | 'y' | 'z'
  10957. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  10958. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  10959. */
  10960. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  10961. /**
  10962. * Checks if ray intersects a mesh
  10963. * @param mesh the mesh to check
  10964. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10965. * @returns picking info of the intersecton
  10966. */
  10967. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  10968. /**
  10969. * Checks if ray intersects a mesh
  10970. * @param meshes the meshes to check
  10971. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10972. * @param results array to store result in
  10973. * @returns Array of picking infos
  10974. */
  10975. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  10976. private _comparePickingInfo;
  10977. private static smallnum;
  10978. private static rayl;
  10979. /**
  10980. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  10981. * @param sega the first point of the segment to test the intersection against
  10982. * @param segb the second point of the segment to test the intersection against
  10983. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  10984. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  10985. */
  10986. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  10987. /**
  10988. * Update the ray from viewport position
  10989. * @param x position
  10990. * @param y y position
  10991. * @param viewportWidth viewport width
  10992. * @param viewportHeight viewport height
  10993. * @param world world matrix
  10994. * @param view view matrix
  10995. * @param projection projection matrix
  10996. * @returns this ray updated
  10997. */
  10998. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10999. /**
  11000. * Creates a ray with origin and direction of 0,0,0
  11001. * @returns the new ray
  11002. */
  11003. static Zero(): Ray;
  11004. /**
  11005. * Creates a new ray from screen space and viewport
  11006. * @param x position
  11007. * @param y y position
  11008. * @param viewportWidth viewport width
  11009. * @param viewportHeight viewport height
  11010. * @param world world matrix
  11011. * @param view view matrix
  11012. * @param projection projection matrix
  11013. * @returns new ray
  11014. */
  11015. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11016. /**
  11017. * 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
  11018. * transformed to the given world matrix.
  11019. * @param origin The origin point
  11020. * @param end The end point
  11021. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11022. * @returns the new ray
  11023. */
  11024. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: DeepImmutable<Matrix>): Ray;
  11025. /**
  11026. * Transforms a ray by a matrix
  11027. * @param ray ray to transform
  11028. * @param matrix matrix to apply
  11029. * @returns the resulting new ray
  11030. */
  11031. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11032. /**
  11033. * Transforms a ray by a matrix
  11034. * @param ray ray to transform
  11035. * @param matrix matrix to apply
  11036. * @param result ray to store result in
  11037. */
  11038. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11039. /**
  11040. * Unproject a ray from screen space to object space
  11041. * @param sourceX defines the screen space x coordinate to use
  11042. * @param sourceY defines the screen space y coordinate to use
  11043. * @param viewportWidth defines the current width of the viewport
  11044. * @param viewportHeight defines the current height of the viewport
  11045. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11046. * @param view defines the view matrix to use
  11047. * @param projection defines the projection matrix to use
  11048. */
  11049. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11050. }
  11051. /**
  11052. * Type used to define predicate used to select faces when a mesh intersection is detected
  11053. */
  11054. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11055. interface Scene {
  11056. /** @hidden */
  11057. _tempPickingRay: Nullable<Ray>;
  11058. /** @hidden */
  11059. _cachedRayForTransform: Ray;
  11060. /** @hidden */
  11061. _pickWithRayInverseMatrix: Matrix;
  11062. /** @hidden */
  11063. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11064. /** @hidden */
  11065. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11066. /** @hidden */
  11067. _internalPickForMesh(pickingInfo: Nullable<PickingInfo>, rayFunction: (world: Matrix) => Ray, mesh: AbstractMesh, world: Matrix, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate, skipBoundingInfo?: boolean): Nullable<PickingInfo>;
  11068. }
  11069. }
  11070. declare module BABYLON {
  11071. /**
  11072. * Groups all the scene component constants in one place to ease maintenance.
  11073. * @hidden
  11074. */
  11075. export class SceneComponentConstants {
  11076. static readonly NAME_EFFECTLAYER: string;
  11077. static readonly NAME_LAYER: string;
  11078. static readonly NAME_LENSFLARESYSTEM: string;
  11079. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11080. static readonly NAME_PARTICLESYSTEM: string;
  11081. static readonly NAME_GAMEPAD: string;
  11082. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11083. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11084. static readonly NAME_PREPASSRENDERER: string;
  11085. static readonly NAME_DEPTHRENDERER: string;
  11086. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11087. static readonly NAME_SPRITE: string;
  11088. static readonly NAME_SUBSURFACE: string;
  11089. static readonly NAME_OUTLINERENDERER: string;
  11090. static readonly NAME_PROCEDURALTEXTURE: string;
  11091. static readonly NAME_SHADOWGENERATOR: string;
  11092. static readonly NAME_OCTREE: string;
  11093. static readonly NAME_PHYSICSENGINE: string;
  11094. static readonly NAME_AUDIO: string;
  11095. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11096. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11097. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11098. static readonly STEP_PREACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11099. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11100. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11101. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11102. static readonly STEP_BEFORECAMERADRAW_PREPASS: number;
  11103. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11104. static readonly STEP_BEFORERENDERINGMESH_PREPASS: number;
  11105. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11106. static readonly STEP_AFTERRENDERINGMESH_PREPASS: number;
  11107. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11108. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11109. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11110. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11111. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11112. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11113. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11114. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11115. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11116. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11117. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11118. static readonly STEP_AFTERCAMERADRAW_PREPASS: number;
  11119. static readonly STEP_AFTERRENDER_AUDIO: number;
  11120. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11121. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11122. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11123. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11124. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11125. static readonly STEP_BEFORECLEARSTAGE_PREPASS: number;
  11126. static readonly STEP_POINTERMOVE_SPRITE: number;
  11127. static readonly STEP_POINTERDOWN_SPRITE: number;
  11128. static readonly STEP_POINTERUP_SPRITE: number;
  11129. }
  11130. /**
  11131. * This represents a scene component.
  11132. *
  11133. * This is used to decouple the dependency the scene is having on the different workloads like
  11134. * layers, post processes...
  11135. */
  11136. export interface ISceneComponent {
  11137. /**
  11138. * The name of the component. Each component must have a unique name.
  11139. */
  11140. name: string;
  11141. /**
  11142. * The scene the component belongs to.
  11143. */
  11144. scene: Scene;
  11145. /**
  11146. * Register the component to one instance of a scene.
  11147. */
  11148. register(): void;
  11149. /**
  11150. * Rebuilds the elements related to this component in case of
  11151. * context lost for instance.
  11152. */
  11153. rebuild(): void;
  11154. /**
  11155. * Disposes the component and the associated ressources.
  11156. */
  11157. dispose(): void;
  11158. }
  11159. /**
  11160. * This represents a SERIALIZABLE scene component.
  11161. *
  11162. * This extends Scene Component to add Serialization methods on top.
  11163. */
  11164. export interface ISceneSerializableComponent extends ISceneComponent {
  11165. /**
  11166. * Adds all the elements from the container to the scene
  11167. * @param container the container holding the elements
  11168. */
  11169. addFromContainer(container: AbstractScene): void;
  11170. /**
  11171. * Removes all the elements in the container from the scene
  11172. * @param container contains the elements to remove
  11173. * @param dispose if the removed element should be disposed (default: false)
  11174. */
  11175. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11176. /**
  11177. * Serializes the component data to the specified json object
  11178. * @param serializationObject The object to serialize to
  11179. */
  11180. serialize(serializationObject: any): void;
  11181. }
  11182. /**
  11183. * Strong typing of a Mesh related stage step action
  11184. */
  11185. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11186. /**
  11187. * Strong typing of a Evaluate Sub Mesh related stage step action
  11188. */
  11189. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11190. /**
  11191. * Strong typing of a pre active Mesh related stage step action
  11192. */
  11193. export type PreActiveMeshStageAction = (mesh: AbstractMesh) => void;
  11194. /**
  11195. * Strong typing of a Camera related stage step action
  11196. */
  11197. export type CameraStageAction = (camera: Camera) => void;
  11198. /**
  11199. * Strong typing of a Camera Frame buffer related stage step action
  11200. */
  11201. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11202. /**
  11203. * Strong typing of a Render Target related stage step action
  11204. */
  11205. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11206. /**
  11207. * Strong typing of a RenderingGroup related stage step action
  11208. */
  11209. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11210. /**
  11211. * Strong typing of a Mesh Render related stage step action
  11212. */
  11213. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch, effect: Nullable<Effect>) => void;
  11214. /**
  11215. * Strong typing of a simple stage step action
  11216. */
  11217. export type SimpleStageAction = () => void;
  11218. /**
  11219. * Strong typing of a render target action.
  11220. */
  11221. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11222. /**
  11223. * Strong typing of a pointer move action.
  11224. */
  11225. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  11226. /**
  11227. * Strong typing of a pointer up/down action.
  11228. */
  11229. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11230. /**
  11231. * Representation of a stage in the scene (Basically a list of ordered steps)
  11232. * @hidden
  11233. */
  11234. export class Stage<T extends Function> extends Array<{
  11235. index: number;
  11236. component: ISceneComponent;
  11237. action: T;
  11238. }> {
  11239. /**
  11240. * Hide ctor from the rest of the world.
  11241. * @param items The items to add.
  11242. */
  11243. private constructor();
  11244. /**
  11245. * Creates a new Stage.
  11246. * @returns A new instance of a Stage
  11247. */
  11248. static Create<T extends Function>(): Stage<T>;
  11249. /**
  11250. * Registers a step in an ordered way in the targeted stage.
  11251. * @param index Defines the position to register the step in
  11252. * @param component Defines the component attached to the step
  11253. * @param action Defines the action to launch during the step
  11254. */
  11255. registerStep(index: number, component: ISceneComponent, action: T): void;
  11256. /**
  11257. * Clears all the steps from the stage.
  11258. */
  11259. clear(): void;
  11260. }
  11261. }
  11262. declare module BABYLON {
  11263. interface Scene {
  11264. /** @hidden */
  11265. _pointerOverSprite: Nullable<Sprite>;
  11266. /** @hidden */
  11267. _pickedDownSprite: Nullable<Sprite>;
  11268. /** @hidden */
  11269. _tempSpritePickingRay: Nullable<Ray>;
  11270. /**
  11271. * All of the sprite managers added to this scene
  11272. * @see https://doc.babylonjs.com/babylon101/sprites
  11273. */
  11274. spriteManagers: Array<ISpriteManager>;
  11275. /**
  11276. * An event triggered when sprites rendering is about to start
  11277. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11278. */
  11279. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11280. /**
  11281. * An event triggered when sprites rendering is done
  11282. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11283. */
  11284. onAfterSpritesRenderingObservable: Observable<Scene>;
  11285. /** @hidden */
  11286. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11287. /** Launch a ray to try to pick a sprite in the scene
  11288. * @param x position on screen
  11289. * @param y position on screen
  11290. * @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
  11291. * @param fastCheck defines if the first intersection will be used (and not the closest)
  11292. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11293. * @returns a PickingInfo
  11294. */
  11295. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11296. /** Use the given ray to pick a sprite in the scene
  11297. * @param ray The ray (in world space) to use to pick meshes
  11298. * @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
  11299. * @param fastCheck defines if the first intersection will be used (and not the closest)
  11300. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11301. * @returns a PickingInfo
  11302. */
  11303. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11304. /** @hidden */
  11305. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11306. /** Launch a ray to try to pick sprites in the scene
  11307. * @param x position on screen
  11308. * @param y position on screen
  11309. * @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
  11310. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11311. * @returns a PickingInfo array
  11312. */
  11313. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11314. /** Use the given ray to pick sprites in the scene
  11315. * @param ray The ray (in world space) to use to pick meshes
  11316. * @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
  11317. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11318. * @returns a PickingInfo array
  11319. */
  11320. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11321. /**
  11322. * Force the sprite under the pointer
  11323. * @param sprite defines the sprite to use
  11324. */
  11325. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11326. /**
  11327. * Gets the sprite under the pointer
  11328. * @returns a Sprite or null if no sprite is under the pointer
  11329. */
  11330. getPointerOverSprite(): Nullable<Sprite>;
  11331. }
  11332. /**
  11333. * Defines the sprite scene component responsible to manage sprites
  11334. * in a given scene.
  11335. */
  11336. export class SpriteSceneComponent implements ISceneComponent {
  11337. /**
  11338. * The component name helpfull to identify the component in the list of scene components.
  11339. */
  11340. readonly name: string;
  11341. /**
  11342. * The scene the component belongs to.
  11343. */
  11344. scene: Scene;
  11345. /** @hidden */
  11346. private _spritePredicate;
  11347. /**
  11348. * Creates a new instance of the component for the given scene
  11349. * @param scene Defines the scene to register the component in
  11350. */
  11351. constructor(scene: Scene);
  11352. /**
  11353. * Registers the component in a given scene
  11354. */
  11355. register(): void;
  11356. /**
  11357. * Rebuilds the elements related to this component in case of
  11358. * context lost for instance.
  11359. */
  11360. rebuild(): void;
  11361. /**
  11362. * Disposes the component and the associated ressources.
  11363. */
  11364. dispose(): void;
  11365. private _pickSpriteButKeepRay;
  11366. private _pointerMove;
  11367. private _pointerDown;
  11368. private _pointerUp;
  11369. }
  11370. }
  11371. declare module BABYLON {
  11372. /**
  11373. * Class used to provide helper for timing
  11374. */
  11375. export class TimingTools {
  11376. /**
  11377. * Polyfill for setImmediate
  11378. * @param action defines the action to execute after the current execution block
  11379. */
  11380. static SetImmediate(action: () => void): void;
  11381. }
  11382. }
  11383. declare module BABYLON {
  11384. /**
  11385. * Class used to enable instatition of objects by class name
  11386. */
  11387. export class InstantiationTools {
  11388. /**
  11389. * Use this object to register external classes like custom textures or material
  11390. * to allow the laoders to instantiate them
  11391. */
  11392. static RegisteredExternalClasses: {
  11393. [key: string]: Object;
  11394. };
  11395. /**
  11396. * Tries to instantiate a new object from a given class name
  11397. * @param className defines the class name to instantiate
  11398. * @returns the new object or null if the system was not able to do the instantiation
  11399. */
  11400. static Instantiate(className: string): any;
  11401. }
  11402. }
  11403. declare module BABYLON {
  11404. /**
  11405. * Class used to host copy specific utilities
  11406. */
  11407. export class CopyTools {
  11408. /**
  11409. * Transform some pixel data to a base64 string
  11410. * @param pixels defines the pixel data to transform to base64
  11411. * @param size defines the width and height of the (texture) data
  11412. * @param invertY true if the data must be inverted for the Y coordinate during the conversion
  11413. * @returns The base64 encoded string or null
  11414. */
  11415. static GenerateBase64StringFromPixelData(pixels: ArrayBufferView, size: ISize, invertY?: boolean): Nullable<string>;
  11416. /**
  11417. * Reads the pixels stored in the webgl texture and returns them as a base64 string
  11418. * @param texture defines the texture to read pixels from
  11419. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  11420. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  11421. * @returns The base64 encoded string or null
  11422. */
  11423. static GenerateBase64StringFromTexture(texture: BaseTexture, faceIndex?: number, level?: number): Nullable<string>;
  11424. /**
  11425. * Reads the pixels stored in the webgl texture and returns them as a base64 string
  11426. * @param texture defines the texture to read pixels from
  11427. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  11428. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  11429. * @returns The base64 encoded string or null wrapped in a promise
  11430. */
  11431. static GenerateBase64StringFromTextureAsync(texture: BaseTexture, faceIndex?: number, level?: number): Promise<Nullable<string>>;
  11432. }
  11433. }
  11434. declare module BABYLON {
  11435. /**
  11436. * Define options used to create a depth texture
  11437. */
  11438. export class DepthTextureCreationOptions {
  11439. /** Specifies whether or not a stencil should be allocated in the texture */
  11440. generateStencil?: boolean;
  11441. /** Specifies whether or not bilinear filtering is enable on the texture */
  11442. bilinearFiltering?: boolean;
  11443. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  11444. comparisonFunction?: number;
  11445. /** Specifies if the created texture is a cube texture */
  11446. isCube?: boolean;
  11447. /** Specifies the sample count of the depth/stencil texture texture */
  11448. samples?: number;
  11449. }
  11450. }
  11451. declare module BABYLON {
  11452. interface ThinEngine {
  11453. /**
  11454. * Creates a depth stencil cube texture.
  11455. * This is only available in WebGL 2.
  11456. * @param size The size of face edge in the cube texture.
  11457. * @param options The options defining the cube texture.
  11458. * @returns The cube texture
  11459. */
  11460. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  11461. /**
  11462. * Creates a cube texture
  11463. * @param rootUrl defines the url where the files to load is located
  11464. * @param scene defines the current scene
  11465. * @param files defines the list of files to load (1 per face)
  11466. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  11467. * @param onLoad defines an optional callback raised when the texture is loaded
  11468. * @param onError defines an optional callback raised if there is an issue to load the texture
  11469. * @param format defines the format of the data
  11470. * @param forcedExtension defines the extension to use to pick the right loader
  11471. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  11472. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  11473. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  11474. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  11475. * @param loaderOptions options to be passed to the loader
  11476. * @returns the cube texture as an InternalTexture
  11477. */
  11478. 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;
  11479. /**
  11480. * Creates a cube texture
  11481. * @param rootUrl defines the url where the files to load is located
  11482. * @param scene defines the current scene
  11483. * @param files defines the list of files to load (1 per face)
  11484. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  11485. * @param onLoad defines an optional callback raised when the texture is loaded
  11486. * @param onError defines an optional callback raised if there is an issue to load the texture
  11487. * @param format defines the format of the data
  11488. * @param forcedExtension defines the extension to use to pick the right loader
  11489. * @returns the cube texture as an InternalTexture
  11490. */
  11491. 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;
  11492. /**
  11493. * Creates a cube texture
  11494. * @param rootUrl defines the url where the files to load is located
  11495. * @param scene defines the current scene
  11496. * @param files defines the list of files to load (1 per face)
  11497. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  11498. * @param onLoad defines an optional callback raised when the texture is loaded
  11499. * @param onError defines an optional callback raised if there is an issue to load the texture
  11500. * @param format defines the format of the data
  11501. * @param forcedExtension defines the extension to use to pick the right loader
  11502. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  11503. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  11504. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  11505. * @returns the cube texture as an InternalTexture
  11506. */
  11507. 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;
  11508. /** @hidden */
  11509. createCubeTextureBase(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, fallback: Nullable<InternalTexture>, beforeLoadCubeDataCallback: Nullable<(texture: InternalTexture, data: ArrayBufferView | ArrayBufferView[]) => void>, imageHandler: Nullable<(texture: InternalTexture, imgs: HTMLImageElement[] | ImageBitmap[]) => void>): InternalTexture;
  11510. /** @hidden */
  11511. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  11512. /** @hidden */
  11513. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  11514. /** @hidden */
  11515. _cascadeLoadImgs(scene: Nullable<Scene>, texture: InternalTexture, onfinish: Nullable<(texture: InternalTexture, images: HTMLImageElement[] | ImageBitmap[]) => void>, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  11516. /** @hidden */
  11517. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[] | ImageBitmap[], scene: Nullable<Scene>, texture: InternalTexture, onfinish: Nullable<(texture: InternalTexture, images: HTMLImageElement[] | ImageBitmap[]) => void>, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  11518. /**
  11519. * @hidden
  11520. */
  11521. _setCubeMapTextureParams(texture: InternalTexture, loadMipmap: boolean): void;
  11522. }
  11523. }
  11524. declare module BABYLON {
  11525. /**
  11526. * Class for creating a cube texture
  11527. */
  11528. export class CubeTexture extends BaseTexture {
  11529. private _delayedOnLoad;
  11530. /**
  11531. * Observable triggered once the texture has been loaded.
  11532. */
  11533. onLoadObservable: Observable<CubeTexture>;
  11534. /**
  11535. * The url of the texture
  11536. */
  11537. url: string;
  11538. /**
  11539. * Gets or sets the center of the bounding box associated with the cube texture.
  11540. * It must define where the camera used to render the texture was set
  11541. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  11542. */
  11543. boundingBoxPosition: Vector3;
  11544. private _boundingBoxSize;
  11545. /**
  11546. * Gets or sets the size of the bounding box associated with the cube texture
  11547. * When defined, the cubemap will switch to local mode
  11548. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  11549. * @example https://www.babylonjs-playground.com/#RNASML
  11550. */
  11551. set boundingBoxSize(value: Vector3);
  11552. /**
  11553. * Returns the bounding box size
  11554. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  11555. */
  11556. get boundingBoxSize(): Vector3;
  11557. protected _rotationY: number;
  11558. /**
  11559. * Sets texture matrix rotation angle around Y axis in radians.
  11560. */
  11561. set rotationY(value: number);
  11562. /**
  11563. * Gets texture matrix rotation angle around Y axis radians.
  11564. */
  11565. get rotationY(): number;
  11566. /**
  11567. * Are mip maps generated for this texture or not.
  11568. */
  11569. get noMipmap(): boolean;
  11570. private _noMipmap;
  11571. private _files;
  11572. protected _forcedExtension: Nullable<string>;
  11573. private _extensions;
  11574. private _textureMatrix;
  11575. private _format;
  11576. private _createPolynomials;
  11577. private _loaderOptions;
  11578. /**
  11579. * Creates a cube texture from an array of image urls
  11580. * @param files defines an array of image urls
  11581. * @param scene defines the hosting scene
  11582. * @param noMipmap specifies if mip maps are not used
  11583. * @returns a cube texture
  11584. */
  11585. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  11586. /**
  11587. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  11588. * @param url defines the url of the prefiltered texture
  11589. * @param scene defines the scene the texture is attached to
  11590. * @param forcedExtension defines the extension of the file if different from the url
  11591. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  11592. * @return the prefiltered texture
  11593. */
  11594. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  11595. /**
  11596. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  11597. * as prefiltered data.
  11598. * @param rootUrl defines the url of the texture or the root name of the six images
  11599. * @param null defines the scene or engine the texture is attached to
  11600. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  11601. * @param noMipmap defines if mipmaps should be created or not
  11602. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  11603. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  11604. * @param onError defines a callback triggered in case of error during load
  11605. * @param format defines the internal format to use for the texture once loaded
  11606. * @param prefiltered defines whether or not the texture is created from prefiltered data
  11607. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  11608. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  11609. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  11610. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  11611. * @param loaderOptions options to be passed to the loader
  11612. * @return the cube texture
  11613. */
  11614. 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);
  11615. /**
  11616. * Get the current class name of the texture useful for serialization or dynamic coding.
  11617. * @returns "CubeTexture"
  11618. */
  11619. getClassName(): string;
  11620. /**
  11621. * Update the url (and optional buffer) of this texture if url was null during construction.
  11622. * @param url the url of the texture
  11623. * @param forcedExtension defines the extension to use
  11624. * @param onLoad callback called when the texture is loaded (defaults to null)
  11625. * @param prefiltered Defines whether the updated texture is prefiltered or not
  11626. */
  11627. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  11628. /**
  11629. * Delays loading of the cube texture
  11630. * @param forcedExtension defines the extension to use
  11631. */
  11632. delayLoad(forcedExtension?: string): void;
  11633. /**
  11634. * Returns the reflection texture matrix
  11635. * @returns the reflection texture matrix
  11636. */
  11637. getReflectionTextureMatrix(): Matrix;
  11638. /**
  11639. * Sets the reflection texture matrix
  11640. * @param value Reflection texture matrix
  11641. */
  11642. setReflectionTextureMatrix(value: Matrix): void;
  11643. /**
  11644. * Parses text to create a cube texture
  11645. * @param parsedTexture define the serialized text to read from
  11646. * @param scene defines the hosting scene
  11647. * @param rootUrl defines the root url of the cube texture
  11648. * @returns a cube texture
  11649. */
  11650. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  11651. /**
  11652. * Makes a clone, or deep copy, of the cube texture
  11653. * @returns a new cube texture
  11654. */
  11655. clone(): CubeTexture;
  11656. }
  11657. }
  11658. declare module BABYLON {
  11659. /**
  11660. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  11661. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  11662. * 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;
  11663. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  11664. */
  11665. export class ColorCurves {
  11666. private _dirty;
  11667. private _tempColor;
  11668. private _globalCurve;
  11669. private _highlightsCurve;
  11670. private _midtonesCurve;
  11671. private _shadowsCurve;
  11672. private _positiveCurve;
  11673. private _negativeCurve;
  11674. private _globalHue;
  11675. private _globalDensity;
  11676. private _globalSaturation;
  11677. private _globalExposure;
  11678. /**
  11679. * Gets the global Hue value.
  11680. * 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).
  11681. */
  11682. get globalHue(): number;
  11683. /**
  11684. * Sets the global Hue value.
  11685. * 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).
  11686. */
  11687. set globalHue(value: number);
  11688. /**
  11689. * Gets the global Density value.
  11690. * 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.
  11691. * Values less than zero provide a filter of opposite hue.
  11692. */
  11693. get globalDensity(): number;
  11694. /**
  11695. * Sets the global Density value.
  11696. * 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.
  11697. * Values less than zero provide a filter of opposite hue.
  11698. */
  11699. set globalDensity(value: number);
  11700. /**
  11701. * Gets the global Saturation value.
  11702. * 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.
  11703. */
  11704. get globalSaturation(): number;
  11705. /**
  11706. * Sets the global Saturation value.
  11707. * 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.
  11708. */
  11709. set globalSaturation(value: number);
  11710. /**
  11711. * Gets the global Exposure value.
  11712. * 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.
  11713. */
  11714. get globalExposure(): number;
  11715. /**
  11716. * Sets the global Exposure value.
  11717. * 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.
  11718. */
  11719. set globalExposure(value: number);
  11720. private _highlightsHue;
  11721. private _highlightsDensity;
  11722. private _highlightsSaturation;
  11723. private _highlightsExposure;
  11724. /**
  11725. * Gets the highlights Hue value.
  11726. * 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).
  11727. */
  11728. get highlightsHue(): number;
  11729. /**
  11730. * Sets the highlights Hue value.
  11731. * 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).
  11732. */
  11733. set highlightsHue(value: number);
  11734. /**
  11735. * Gets the highlights Density value.
  11736. * 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.
  11737. * Values less than zero provide a filter of opposite hue.
  11738. */
  11739. get highlightsDensity(): number;
  11740. /**
  11741. * Sets the highlights Density value.
  11742. * 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.
  11743. * Values less than zero provide a filter of opposite hue.
  11744. */
  11745. set highlightsDensity(value: number);
  11746. /**
  11747. * Gets the highlights Saturation value.
  11748. * 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.
  11749. */
  11750. get highlightsSaturation(): number;
  11751. /**
  11752. * Sets the highlights Saturation value.
  11753. * 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.
  11754. */
  11755. set highlightsSaturation(value: number);
  11756. /**
  11757. * Gets the highlights Exposure value.
  11758. * 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.
  11759. */
  11760. get highlightsExposure(): number;
  11761. /**
  11762. * Sets the highlights Exposure value.
  11763. * 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.
  11764. */
  11765. set highlightsExposure(value: number);
  11766. private _midtonesHue;
  11767. private _midtonesDensity;
  11768. private _midtonesSaturation;
  11769. private _midtonesExposure;
  11770. /**
  11771. * Gets the midtones Hue value.
  11772. * 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).
  11773. */
  11774. get midtonesHue(): number;
  11775. /**
  11776. * Sets the midtones Hue value.
  11777. * 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).
  11778. */
  11779. set midtonesHue(value: number);
  11780. /**
  11781. * Gets the midtones Density value.
  11782. * 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.
  11783. * Values less than zero provide a filter of opposite hue.
  11784. */
  11785. get midtonesDensity(): number;
  11786. /**
  11787. * Sets the midtones Density value.
  11788. * 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.
  11789. * Values less than zero provide a filter of opposite hue.
  11790. */
  11791. set midtonesDensity(value: number);
  11792. /**
  11793. * Gets the midtones Saturation value.
  11794. * 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.
  11795. */
  11796. get midtonesSaturation(): number;
  11797. /**
  11798. * Sets the midtones Saturation value.
  11799. * 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.
  11800. */
  11801. set midtonesSaturation(value: number);
  11802. /**
  11803. * Gets the midtones Exposure value.
  11804. * 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.
  11805. */
  11806. get midtonesExposure(): number;
  11807. /**
  11808. * Sets the midtones Exposure value.
  11809. * 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.
  11810. */
  11811. set midtonesExposure(value: number);
  11812. private _shadowsHue;
  11813. private _shadowsDensity;
  11814. private _shadowsSaturation;
  11815. private _shadowsExposure;
  11816. /**
  11817. * Gets the shadows Hue value.
  11818. * 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).
  11819. */
  11820. get shadowsHue(): number;
  11821. /**
  11822. * Sets the shadows Hue value.
  11823. * 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).
  11824. */
  11825. set shadowsHue(value: number);
  11826. /**
  11827. * Gets the shadows Density value.
  11828. * 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.
  11829. * Values less than zero provide a filter of opposite hue.
  11830. */
  11831. get shadowsDensity(): number;
  11832. /**
  11833. * Sets the shadows Density value.
  11834. * 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.
  11835. * Values less than zero provide a filter of opposite hue.
  11836. */
  11837. set shadowsDensity(value: number);
  11838. /**
  11839. * Gets the shadows Saturation value.
  11840. * 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.
  11841. */
  11842. get shadowsSaturation(): number;
  11843. /**
  11844. * Sets the shadows Saturation value.
  11845. * 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.
  11846. */
  11847. set shadowsSaturation(value: number);
  11848. /**
  11849. * Gets the shadows Exposure value.
  11850. * 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.
  11851. */
  11852. get shadowsExposure(): number;
  11853. /**
  11854. * Sets the shadows Exposure value.
  11855. * 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.
  11856. */
  11857. set shadowsExposure(value: number);
  11858. /**
  11859. * Returns the class name
  11860. * @returns The class name
  11861. */
  11862. getClassName(): string;
  11863. /**
  11864. * Binds the color curves to the shader.
  11865. * @param colorCurves The color curve to bind
  11866. * @param effect The effect to bind to
  11867. * @param positiveUniform The positive uniform shader parameter
  11868. * @param neutralUniform The neutral uniform shader parameter
  11869. * @param negativeUniform The negative uniform shader parameter
  11870. */
  11871. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  11872. /**
  11873. * Prepare the list of uniforms associated with the ColorCurves effects.
  11874. * @param uniformsList The list of uniforms used in the effect
  11875. */
  11876. static PrepareUniforms(uniformsList: string[]): void;
  11877. /**
  11878. * Returns color grading data based on a hue, density, saturation and exposure value.
  11879. * @param filterHue The hue of the color filter.
  11880. * @param filterDensity The density of the color filter.
  11881. * @param saturation The saturation.
  11882. * @param exposure The exposure.
  11883. * @param result The result data container.
  11884. */
  11885. private getColorGradingDataToRef;
  11886. /**
  11887. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  11888. * @param value The input slider value in range [-100,100].
  11889. * @returns Adjusted value.
  11890. */
  11891. private static applyColorGradingSliderNonlinear;
  11892. /**
  11893. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  11894. * @param hue The hue (H) input.
  11895. * @param saturation The saturation (S) input.
  11896. * @param brightness The brightness (B) input.
  11897. * @result An RGBA color represented as Vector4.
  11898. */
  11899. private static fromHSBToRef;
  11900. /**
  11901. * Returns a value clamped between min and max
  11902. * @param value The value to clamp
  11903. * @param min The minimum of value
  11904. * @param max The maximum of value
  11905. * @returns The clamped value.
  11906. */
  11907. private static clamp;
  11908. /**
  11909. * Clones the current color curve instance.
  11910. * @return The cloned curves
  11911. */
  11912. clone(): ColorCurves;
  11913. /**
  11914. * Serializes the current color curve instance to a json representation.
  11915. * @return a JSON representation
  11916. */
  11917. serialize(): any;
  11918. /**
  11919. * Parses the color curve from a json representation.
  11920. * @param source the JSON source to parse
  11921. * @return The parsed curves
  11922. */
  11923. static Parse(source: any): ColorCurves;
  11924. }
  11925. }
  11926. declare module BABYLON {
  11927. /**
  11928. * Interface to follow in your material defines to integrate easily the
  11929. * Image proccessing functions.
  11930. * @hidden
  11931. */
  11932. export interface IImageProcessingConfigurationDefines {
  11933. IMAGEPROCESSING: boolean;
  11934. VIGNETTE: boolean;
  11935. VIGNETTEBLENDMODEMULTIPLY: boolean;
  11936. VIGNETTEBLENDMODEOPAQUE: boolean;
  11937. TONEMAPPING: boolean;
  11938. TONEMAPPING_ACES: boolean;
  11939. CONTRAST: boolean;
  11940. EXPOSURE: boolean;
  11941. COLORCURVES: boolean;
  11942. COLORGRADING: boolean;
  11943. COLORGRADING3D: boolean;
  11944. SAMPLER3DGREENDEPTH: boolean;
  11945. SAMPLER3DBGRMAP: boolean;
  11946. IMAGEPROCESSINGPOSTPROCESS: boolean;
  11947. }
  11948. /**
  11949. * @hidden
  11950. */
  11951. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  11952. IMAGEPROCESSING: boolean;
  11953. VIGNETTE: boolean;
  11954. VIGNETTEBLENDMODEMULTIPLY: boolean;
  11955. VIGNETTEBLENDMODEOPAQUE: boolean;
  11956. TONEMAPPING: boolean;
  11957. TONEMAPPING_ACES: boolean;
  11958. CONTRAST: boolean;
  11959. COLORCURVES: boolean;
  11960. COLORGRADING: boolean;
  11961. COLORGRADING3D: boolean;
  11962. SAMPLER3DGREENDEPTH: boolean;
  11963. SAMPLER3DBGRMAP: boolean;
  11964. IMAGEPROCESSINGPOSTPROCESS: boolean;
  11965. EXPOSURE: boolean;
  11966. constructor();
  11967. }
  11968. /**
  11969. * This groups together the common properties used for image processing either in direct forward pass
  11970. * or through post processing effect depending on the use of the image processing pipeline in your scene
  11971. * or not.
  11972. */
  11973. export class ImageProcessingConfiguration {
  11974. /**
  11975. * Default tone mapping applied in BabylonJS.
  11976. */
  11977. static readonly TONEMAPPING_STANDARD: number;
  11978. /**
  11979. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  11980. * to other engines rendering to increase portability.
  11981. */
  11982. static readonly TONEMAPPING_ACES: number;
  11983. /**
  11984. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  11985. */
  11986. colorCurves: Nullable<ColorCurves>;
  11987. private _colorCurvesEnabled;
  11988. /**
  11989. * Gets wether the color curves effect is enabled.
  11990. */
  11991. get colorCurvesEnabled(): boolean;
  11992. /**
  11993. * Sets wether the color curves effect is enabled.
  11994. */
  11995. set colorCurvesEnabled(value: boolean);
  11996. private _colorGradingTexture;
  11997. /**
  11998. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  11999. */
  12000. get colorGradingTexture(): Nullable<BaseTexture>;
  12001. /**
  12002. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  12003. */
  12004. set colorGradingTexture(value: Nullable<BaseTexture>);
  12005. private _colorGradingEnabled;
  12006. /**
  12007. * Gets wether the color grading effect is enabled.
  12008. */
  12009. get colorGradingEnabled(): boolean;
  12010. /**
  12011. * Sets wether the color grading effect is enabled.
  12012. */
  12013. set colorGradingEnabled(value: boolean);
  12014. private _colorGradingWithGreenDepth;
  12015. /**
  12016. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  12017. */
  12018. get colorGradingWithGreenDepth(): boolean;
  12019. /**
  12020. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  12021. */
  12022. set colorGradingWithGreenDepth(value: boolean);
  12023. private _colorGradingBGR;
  12024. /**
  12025. * Gets wether the color grading texture contains BGR values.
  12026. */
  12027. get colorGradingBGR(): boolean;
  12028. /**
  12029. * Sets wether the color grading texture contains BGR values.
  12030. */
  12031. set colorGradingBGR(value: boolean);
  12032. /** @hidden */
  12033. _exposure: number;
  12034. /**
  12035. * Gets the Exposure used in the effect.
  12036. */
  12037. get exposure(): number;
  12038. /**
  12039. * Sets the Exposure used in the effect.
  12040. */
  12041. set exposure(value: number);
  12042. private _toneMappingEnabled;
  12043. /**
  12044. * Gets wether the tone mapping effect is enabled.
  12045. */
  12046. get toneMappingEnabled(): boolean;
  12047. /**
  12048. * Sets wether the tone mapping effect is enabled.
  12049. */
  12050. set toneMappingEnabled(value: boolean);
  12051. private _toneMappingType;
  12052. /**
  12053. * Gets the type of tone mapping effect.
  12054. */
  12055. get toneMappingType(): number;
  12056. /**
  12057. * Sets the type of tone mapping effect used in BabylonJS.
  12058. */
  12059. set toneMappingType(value: number);
  12060. protected _contrast: number;
  12061. /**
  12062. * Gets the contrast used in the effect.
  12063. */
  12064. get contrast(): number;
  12065. /**
  12066. * Sets the contrast used in the effect.
  12067. */
  12068. set contrast(value: number);
  12069. /**
  12070. * Vignette stretch size.
  12071. */
  12072. vignetteStretch: number;
  12073. /**
  12074. * Vignette centre X Offset.
  12075. */
  12076. vignetteCentreX: number;
  12077. /**
  12078. * Vignette centre Y Offset.
  12079. */
  12080. vignetteCentreY: number;
  12081. /**
  12082. * Vignette weight or intensity of the vignette effect.
  12083. */
  12084. vignetteWeight: number;
  12085. /**
  12086. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  12087. * if vignetteEnabled is set to true.
  12088. */
  12089. vignetteColor: Color4;
  12090. /**
  12091. * Camera field of view used by the Vignette effect.
  12092. */
  12093. vignetteCameraFov: number;
  12094. private _vignetteBlendMode;
  12095. /**
  12096. * Gets the vignette blend mode allowing different kind of effect.
  12097. */
  12098. get vignetteBlendMode(): number;
  12099. /**
  12100. * Sets the vignette blend mode allowing different kind of effect.
  12101. */
  12102. set vignetteBlendMode(value: number);
  12103. private _vignetteEnabled;
  12104. /**
  12105. * Gets wether the vignette effect is enabled.
  12106. */
  12107. get vignetteEnabled(): boolean;
  12108. /**
  12109. * Sets wether the vignette effect is enabled.
  12110. */
  12111. set vignetteEnabled(value: boolean);
  12112. private _applyByPostProcess;
  12113. /**
  12114. * Gets wether the image processing is applied through a post process or not.
  12115. */
  12116. get applyByPostProcess(): boolean;
  12117. /**
  12118. * Sets wether the image processing is applied through a post process or not.
  12119. */
  12120. set applyByPostProcess(value: boolean);
  12121. private _isEnabled;
  12122. /**
  12123. * Gets wether the image processing is enabled or not.
  12124. */
  12125. get isEnabled(): boolean;
  12126. /**
  12127. * Sets wether the image processing is enabled or not.
  12128. */
  12129. set isEnabled(value: boolean);
  12130. /**
  12131. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  12132. */
  12133. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  12134. /**
  12135. * Method called each time the image processing information changes requires to recompile the effect.
  12136. */
  12137. protected _updateParameters(): void;
  12138. /**
  12139. * Gets the current class name.
  12140. * @return "ImageProcessingConfiguration"
  12141. */
  12142. getClassName(): string;
  12143. /**
  12144. * Prepare the list of uniforms associated with the Image Processing effects.
  12145. * @param uniforms The list of uniforms used in the effect
  12146. * @param defines the list of defines currently in use
  12147. */
  12148. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  12149. /**
  12150. * Prepare the list of samplers associated with the Image Processing effects.
  12151. * @param samplersList The list of uniforms used in the effect
  12152. * @param defines the list of defines currently in use
  12153. */
  12154. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  12155. /**
  12156. * Prepare the list of defines associated to the shader.
  12157. * @param defines the list of defines to complete
  12158. * @param forPostProcess Define if we are currently in post process mode or not
  12159. */
  12160. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  12161. /**
  12162. * Returns true if all the image processing information are ready.
  12163. * @returns True if ready, otherwise, false
  12164. */
  12165. isReady(): boolean;
  12166. /**
  12167. * Binds the image processing to the shader.
  12168. * @param effect The effect to bind to
  12169. * @param overrideAspectRatio Override the aspect ratio of the effect
  12170. */
  12171. bind(effect: Effect, overrideAspectRatio?: number): void;
  12172. /**
  12173. * Clones the current image processing instance.
  12174. * @return The cloned image processing
  12175. */
  12176. clone(): ImageProcessingConfiguration;
  12177. /**
  12178. * Serializes the current image processing instance to a json representation.
  12179. * @return a JSON representation
  12180. */
  12181. serialize(): any;
  12182. /**
  12183. * Parses the image processing from a json representation.
  12184. * @param source the JSON source to parse
  12185. * @return The parsed image processing
  12186. */
  12187. static Parse(source: any): ImageProcessingConfiguration;
  12188. private static _VIGNETTEMODE_MULTIPLY;
  12189. private static _VIGNETTEMODE_OPAQUE;
  12190. /**
  12191. * Used to apply the vignette as a mix with the pixel color.
  12192. */
  12193. static get VIGNETTEMODE_MULTIPLY(): number;
  12194. /**
  12195. * Used to apply the vignette as a replacement of the pixel color.
  12196. */
  12197. static get VIGNETTEMODE_OPAQUE(): number;
  12198. }
  12199. }
  12200. declare module BABYLON {
  12201. /** @hidden */
  12202. export var postprocessVertexShader: {
  12203. name: string;
  12204. shader: string;
  12205. };
  12206. }
  12207. declare module BABYLON {
  12208. /**
  12209. * Type used to define a render target texture size (either with a number or with a rect width and height)
  12210. */
  12211. export type RenderTargetTextureSize = number | {
  12212. width: number;
  12213. height: number;
  12214. layers?: number;
  12215. };
  12216. interface ThinEngine {
  12217. /**
  12218. * Creates a new render target texture
  12219. * @param size defines the size of the texture
  12220. * @param options defines the options used to create the texture
  12221. * @returns a new render target texture stored in an InternalTexture
  12222. */
  12223. createRenderTargetTexture(size: RenderTargetTextureSize, options: boolean | RenderTargetCreationOptions): InternalTexture;
  12224. /**
  12225. * Creates a depth stencil texture.
  12226. * This is only available in WebGL 2 or with the depth texture extension available.
  12227. * @param size The size of face edge in the texture.
  12228. * @param options The options defining the texture.
  12229. * @returns The texture
  12230. */
  12231. createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  12232. /** @hidden */
  12233. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  12234. }
  12235. }
  12236. declare module BABYLON {
  12237. /**
  12238. * Defines the kind of connection point for node based material
  12239. */
  12240. export enum NodeMaterialBlockConnectionPointTypes {
  12241. /** Float */
  12242. Float = 1,
  12243. /** Int */
  12244. Int = 2,
  12245. /** Vector2 */
  12246. Vector2 = 4,
  12247. /** Vector3 */
  12248. Vector3 = 8,
  12249. /** Vector4 */
  12250. Vector4 = 16,
  12251. /** Color3 */
  12252. Color3 = 32,
  12253. /** Color4 */
  12254. Color4 = 64,
  12255. /** Matrix */
  12256. Matrix = 128,
  12257. /** Custom object */
  12258. Object = 256,
  12259. /** Detect type based on connection */
  12260. AutoDetect = 1024,
  12261. /** Output type that will be defined by input type */
  12262. BasedOnInput = 2048
  12263. }
  12264. }
  12265. declare module BABYLON {
  12266. /**
  12267. * Enum used to define the target of a block
  12268. */
  12269. export enum NodeMaterialBlockTargets {
  12270. /** Vertex shader */
  12271. Vertex = 1,
  12272. /** Fragment shader */
  12273. Fragment = 2,
  12274. /** Neutral */
  12275. Neutral = 4,
  12276. /** Vertex and Fragment */
  12277. VertexAndFragment = 3
  12278. }
  12279. }
  12280. declare module BABYLON {
  12281. /**
  12282. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  12283. */
  12284. export enum NodeMaterialBlockConnectionPointMode {
  12285. /** Value is an uniform */
  12286. Uniform = 0,
  12287. /** Value is a mesh attribute */
  12288. Attribute = 1,
  12289. /** Value is a varying between vertex and fragment shaders */
  12290. Varying = 2,
  12291. /** Mode is undefined */
  12292. Undefined = 3
  12293. }
  12294. }
  12295. declare module BABYLON {
  12296. /**
  12297. * Enum used to define system values e.g. values automatically provided by the system
  12298. */
  12299. export enum NodeMaterialSystemValues {
  12300. /** World */
  12301. World = 1,
  12302. /** View */
  12303. View = 2,
  12304. /** Projection */
  12305. Projection = 3,
  12306. /** ViewProjection */
  12307. ViewProjection = 4,
  12308. /** WorldView */
  12309. WorldView = 5,
  12310. /** WorldViewProjection */
  12311. WorldViewProjection = 6,
  12312. /** CameraPosition */
  12313. CameraPosition = 7,
  12314. /** Fog Color */
  12315. FogColor = 8,
  12316. /** Delta time */
  12317. DeltaTime = 9
  12318. }
  12319. }
  12320. declare module BABYLON {
  12321. /**
  12322. * Represents a camera frustum
  12323. */
  12324. export class Frustum {
  12325. /**
  12326. * Gets the planes representing the frustum
  12327. * @param transform matrix to be applied to the returned planes
  12328. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  12329. */
  12330. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  12331. /**
  12332. * Gets the near frustum plane transformed by the transform matrix
  12333. * @param transform transformation matrix to be applied to the resulting frustum plane
  12334. * @param frustumPlane the resuling frustum plane
  12335. */
  12336. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  12337. /**
  12338. * Gets the far frustum plane transformed by the transform matrix
  12339. * @param transform transformation matrix to be applied to the resulting frustum plane
  12340. * @param frustumPlane the resuling frustum plane
  12341. */
  12342. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  12343. /**
  12344. * Gets the left frustum plane transformed by the transform matrix
  12345. * @param transform transformation matrix to be applied to the resulting frustum plane
  12346. * @param frustumPlane the resuling frustum plane
  12347. */
  12348. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  12349. /**
  12350. * Gets the right frustum plane transformed by the transform matrix
  12351. * @param transform transformation matrix to be applied to the resulting frustum plane
  12352. * @param frustumPlane the resuling frustum plane
  12353. */
  12354. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  12355. /**
  12356. * Gets the top frustum plane transformed by the transform matrix
  12357. * @param transform transformation matrix to be applied to the resulting frustum plane
  12358. * @param frustumPlane the resuling frustum plane
  12359. */
  12360. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  12361. /**
  12362. * Gets the bottom frustum plane transformed by the transform matrix
  12363. * @param transform transformation matrix to be applied to the resulting frustum plane
  12364. * @param frustumPlane the resuling frustum plane
  12365. */
  12366. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  12367. /**
  12368. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  12369. * @param transform transformation matrix to be applied to the resulting frustum planes
  12370. * @param frustumPlanes the resuling frustum planes
  12371. */
  12372. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  12373. }
  12374. }
  12375. declare module BABYLON {
  12376. /**
  12377. * Contains position and normal vectors for a vertex
  12378. */
  12379. export class PositionNormalVertex {
  12380. /** the position of the vertex (defaut: 0,0,0) */
  12381. position: Vector3;
  12382. /** the normal of the vertex (defaut: 0,1,0) */
  12383. normal: Vector3;
  12384. /**
  12385. * Creates a PositionNormalVertex
  12386. * @param position the position of the vertex (defaut: 0,0,0)
  12387. * @param normal the normal of the vertex (defaut: 0,1,0)
  12388. */
  12389. constructor(
  12390. /** the position of the vertex (defaut: 0,0,0) */
  12391. position?: Vector3,
  12392. /** the normal of the vertex (defaut: 0,1,0) */
  12393. normal?: Vector3);
  12394. /**
  12395. * Clones the PositionNormalVertex
  12396. * @returns the cloned PositionNormalVertex
  12397. */
  12398. clone(): PositionNormalVertex;
  12399. }
  12400. /**
  12401. * Contains position, normal and uv vectors for a vertex
  12402. */
  12403. export class PositionNormalTextureVertex {
  12404. /** the position of the vertex (defaut: 0,0,0) */
  12405. position: Vector3;
  12406. /** the normal of the vertex (defaut: 0,1,0) */
  12407. normal: Vector3;
  12408. /** the uv of the vertex (default: 0,0) */
  12409. uv: Vector2;
  12410. /**
  12411. * Creates a PositionNormalTextureVertex
  12412. * @param position the position of the vertex (defaut: 0,0,0)
  12413. * @param normal the normal of the vertex (defaut: 0,1,0)
  12414. * @param uv the uv of the vertex (default: 0,0)
  12415. */
  12416. constructor(
  12417. /** the position of the vertex (defaut: 0,0,0) */
  12418. position?: Vector3,
  12419. /** the normal of the vertex (defaut: 0,1,0) */
  12420. normal?: Vector3,
  12421. /** the uv of the vertex (default: 0,0) */
  12422. uv?: Vector2);
  12423. /**
  12424. * Clones the PositionNormalTextureVertex
  12425. * @returns the cloned PositionNormalTextureVertex
  12426. */
  12427. clone(): PositionNormalTextureVertex;
  12428. }
  12429. }
  12430. declare module BABYLON {
  12431. /**
  12432. * Enum defining the type of animations supported by InputBlock
  12433. */
  12434. export enum AnimatedInputBlockTypes {
  12435. /** No animation */
  12436. None = 0,
  12437. /** Time based animation. Will only work for floats */
  12438. Time = 1
  12439. }
  12440. }
  12441. declare module BABYLON {
  12442. /**
  12443. * Block used to expose an input value
  12444. */
  12445. export class InputBlock extends NodeMaterialBlock {
  12446. private _mode;
  12447. private _associatedVariableName;
  12448. private _storedValue;
  12449. private _valueCallback;
  12450. private _type;
  12451. private _animationType;
  12452. /** Gets or set a value used to limit the range of float values */
  12453. min: number;
  12454. /** Gets or set a value used to limit the range of float values */
  12455. max: number;
  12456. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  12457. isBoolean: boolean;
  12458. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  12459. matrixMode: number;
  12460. /** @hidden */
  12461. _systemValue: Nullable<NodeMaterialSystemValues>;
  12462. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  12463. isConstant: boolean;
  12464. /** Gets or sets the group to use to display this block in the Inspector */
  12465. groupInInspector: string;
  12466. /** Gets an observable raised when the value is changed */
  12467. onValueChangedObservable: Observable<InputBlock>;
  12468. /** Gets or sets a boolean indicating if content needs to be converted to gamma space (for color3/4 only) */
  12469. convertToGammaSpace: boolean;
  12470. /** Gets or sets a boolean indicating if content needs to be converted to linear space (for color3/4 only) */
  12471. convertToLinearSpace: boolean;
  12472. /**
  12473. * Gets or sets the connection point type (default is float)
  12474. */
  12475. get type(): NodeMaterialBlockConnectionPointTypes;
  12476. /**
  12477. * Creates a new InputBlock
  12478. * @param name defines the block name
  12479. * @param target defines the target of that block (Vertex by default)
  12480. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  12481. */
  12482. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  12483. /**
  12484. * Validates if a name is a reserve word.
  12485. * @param newName the new name to be given to the node.
  12486. * @returns false if the name is a reserve word, else true.
  12487. */
  12488. validateBlockName(newName: string): boolean;
  12489. /**
  12490. * Gets the output component
  12491. */
  12492. get output(): NodeMaterialConnectionPoint;
  12493. /**
  12494. * Set the source of this connection point to a vertex attribute
  12495. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  12496. * @returns the current connection point
  12497. */
  12498. setAsAttribute(attributeName?: string): InputBlock;
  12499. /**
  12500. * Set the source of this connection point to a system value
  12501. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  12502. * @returns the current connection point
  12503. */
  12504. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  12505. /**
  12506. * Gets or sets the value of that point.
  12507. * Please note that this value will be ignored if valueCallback is defined
  12508. */
  12509. get value(): any;
  12510. set value(value: any);
  12511. /**
  12512. * Gets or sets a callback used to get the value of that point.
  12513. * Please note that setting this value will force the connection point to ignore the value property
  12514. */
  12515. get valueCallback(): () => any;
  12516. set valueCallback(value: () => any);
  12517. /**
  12518. * Gets or sets the associated variable name in the shader
  12519. */
  12520. get associatedVariableName(): string;
  12521. set associatedVariableName(value: string);
  12522. /** Gets or sets the type of animation applied to the input */
  12523. get animationType(): AnimatedInputBlockTypes;
  12524. set animationType(value: AnimatedInputBlockTypes);
  12525. /**
  12526. * Gets a boolean indicating that this connection point not defined yet
  12527. */
  12528. get isUndefined(): boolean;
  12529. /**
  12530. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  12531. * In this case the connection point name must be the name of the uniform to use.
  12532. * Can only be set on inputs
  12533. */
  12534. get isUniform(): boolean;
  12535. set isUniform(value: boolean);
  12536. /**
  12537. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  12538. * In this case the connection point name must be the name of the attribute to use
  12539. * Can only be set on inputs
  12540. */
  12541. get isAttribute(): boolean;
  12542. set isAttribute(value: boolean);
  12543. /**
  12544. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  12545. * Can only be set on exit points
  12546. */
  12547. get isVarying(): boolean;
  12548. set isVarying(value: boolean);
  12549. /**
  12550. * Gets a boolean indicating that the current connection point is a system value
  12551. */
  12552. get isSystemValue(): boolean;
  12553. /**
  12554. * Gets or sets the current well known value or null if not defined as a system value
  12555. */
  12556. get systemValue(): Nullable<NodeMaterialSystemValues>;
  12557. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  12558. /**
  12559. * Gets the current class name
  12560. * @returns the class name
  12561. */
  12562. getClassName(): string;
  12563. /**
  12564. * Animate the input if animationType !== None
  12565. * @param scene defines the rendering scene
  12566. */
  12567. animate(scene: Scene): void;
  12568. private _emitDefine;
  12569. initialize(state: NodeMaterialBuildState): void;
  12570. /**
  12571. * Set the input block to its default value (based on its type)
  12572. */
  12573. setDefaultValue(): void;
  12574. private _emitConstant;
  12575. /** @hidden */
  12576. get _noContextSwitch(): boolean;
  12577. private _emit;
  12578. /** @hidden */
  12579. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  12580. /** @hidden */
  12581. _transmit(effect: Effect, scene: Scene): void;
  12582. protected _buildBlock(state: NodeMaterialBuildState): void;
  12583. protected _dumpPropertiesCode(): string;
  12584. dispose(): void;
  12585. serialize(): any;
  12586. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  12587. }
  12588. }
  12589. declare module BABYLON {
  12590. /**
  12591. * Enum used to define the compatibility state between two connection points
  12592. */
  12593. export enum NodeMaterialConnectionPointCompatibilityStates {
  12594. /** Points are compatibles */
  12595. Compatible = 0,
  12596. /** Points are incompatible because of their types */
  12597. TypeIncompatible = 1,
  12598. /** Points are incompatible because of their targets (vertex vs fragment) */
  12599. TargetIncompatible = 2
  12600. }
  12601. /**
  12602. * Defines the direction of a connection point
  12603. */
  12604. export enum NodeMaterialConnectionPointDirection {
  12605. /** Input */
  12606. Input = 0,
  12607. /** Output */
  12608. Output = 1
  12609. }
  12610. /**
  12611. * Defines a connection point for a block
  12612. */
  12613. export class NodeMaterialConnectionPoint {
  12614. /**
  12615. * Checks if two types are equivalent
  12616. * @param type1 type 1 to check
  12617. * @param type2 type 2 to check
  12618. * @returns true if both types are equivalent, else false
  12619. */
  12620. static AreEquivalentTypes(type1: number, type2: number): boolean;
  12621. /** @hidden */
  12622. _ownerBlock: NodeMaterialBlock;
  12623. /** @hidden */
  12624. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  12625. private _endpoints;
  12626. private _associatedVariableName;
  12627. private _direction;
  12628. /** @hidden */
  12629. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  12630. /** @hidden */
  12631. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  12632. /** @hidden */
  12633. _acceptedConnectionPointType: Nullable<NodeMaterialConnectionPoint>;
  12634. private _type;
  12635. /** @hidden */
  12636. _enforceAssociatedVariableName: boolean;
  12637. /** Gets the direction of the point */
  12638. get direction(): NodeMaterialConnectionPointDirection;
  12639. /** Indicates that this connection point needs dual validation before being connected to another point */
  12640. needDualDirectionValidation: boolean;
  12641. /**
  12642. * Gets or sets the additional types supported by this connection point
  12643. */
  12644. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  12645. /**
  12646. * Gets or sets the additional types excluded by this connection point
  12647. */
  12648. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  12649. /**
  12650. * Observable triggered when this point is connected
  12651. */
  12652. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  12653. /**
  12654. * Gets or sets the associated variable name in the shader
  12655. */
  12656. get associatedVariableName(): string;
  12657. set associatedVariableName(value: string);
  12658. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  12659. get innerType(): NodeMaterialBlockConnectionPointTypes;
  12660. /**
  12661. * Gets or sets the connection point type (default is float)
  12662. */
  12663. get type(): NodeMaterialBlockConnectionPointTypes;
  12664. set type(value: NodeMaterialBlockConnectionPointTypes);
  12665. /**
  12666. * Gets or sets the connection point name
  12667. */
  12668. name: string;
  12669. /**
  12670. * Gets or sets the connection point name
  12671. */
  12672. displayName: string;
  12673. /**
  12674. * Gets or sets a boolean indicating that this connection point can be omitted
  12675. */
  12676. isOptional: boolean;
  12677. /**
  12678. * Gets or sets a boolean indicating that this connection point is exposed on a frame
  12679. */
  12680. isExposedOnFrame: boolean;
  12681. /**
  12682. * Gets or sets number indicating the position that the port is exposed to on a frame
  12683. */
  12684. exposedPortPosition: number;
  12685. /**
  12686. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  12687. */
  12688. define: string;
  12689. /** @hidden */
  12690. _prioritizeVertex: boolean;
  12691. private _target;
  12692. /** Gets or sets the target of that connection point */
  12693. get target(): NodeMaterialBlockTargets;
  12694. set target(value: NodeMaterialBlockTargets);
  12695. /**
  12696. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  12697. */
  12698. get isConnected(): boolean;
  12699. /**
  12700. * Gets a boolean indicating that the current point is connected to an input block
  12701. */
  12702. get isConnectedToInputBlock(): boolean;
  12703. /**
  12704. * Gets a the connected input block (if any)
  12705. */
  12706. get connectInputBlock(): Nullable<InputBlock>;
  12707. /** Get the other side of the connection (if any) */
  12708. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  12709. /** Get the block that owns this connection point */
  12710. get ownerBlock(): NodeMaterialBlock;
  12711. /** Get the block connected on the other side of this connection (if any) */
  12712. get sourceBlock(): Nullable<NodeMaterialBlock>;
  12713. /** Get the block connected on the endpoints of this connection (if any) */
  12714. get connectedBlocks(): Array<NodeMaterialBlock>;
  12715. /** Gets the list of connected endpoints */
  12716. get endpoints(): NodeMaterialConnectionPoint[];
  12717. /** Gets a boolean indicating if that output point is connected to at least one input */
  12718. get hasEndpoints(): boolean;
  12719. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  12720. get isConnectedInVertexShader(): boolean;
  12721. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  12722. get isConnectedInFragmentShader(): boolean;
  12723. /**
  12724. * Creates a block suitable to be used as an input for this input point.
  12725. * If null is returned, a block based on the point type will be created.
  12726. * @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
  12727. */
  12728. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  12729. /**
  12730. * Creates a new connection point
  12731. * @param name defines the connection point name
  12732. * @param ownerBlock defines the block hosting this connection point
  12733. * @param direction defines the direction of the connection point
  12734. */
  12735. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  12736. /**
  12737. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  12738. * @returns the class name
  12739. */
  12740. getClassName(): string;
  12741. /**
  12742. * Gets a boolean indicating if the current point can be connected to another point
  12743. * @param connectionPoint defines the other connection point
  12744. * @returns a boolean
  12745. */
  12746. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  12747. /**
  12748. * Gets a number indicating if the current point can be connected to another point
  12749. * @param connectionPoint defines the other connection point
  12750. * @returns a number defining the compatibility state
  12751. */
  12752. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  12753. /**
  12754. * Connect this point to another connection point
  12755. * @param connectionPoint defines the other connection point
  12756. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  12757. * @returns the current connection point
  12758. */
  12759. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  12760. /**
  12761. * Disconnect this point from one of his endpoint
  12762. * @param endpoint defines the other connection point
  12763. * @returns the current connection point
  12764. */
  12765. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  12766. /**
  12767. * Serializes this point in a JSON representation
  12768. * @param isInput defines if the connection point is an input (default is true)
  12769. * @returns the serialized point object
  12770. */
  12771. serialize(isInput?: boolean): any;
  12772. /**
  12773. * Release resources
  12774. */
  12775. dispose(): void;
  12776. }
  12777. }
  12778. declare module BABYLON {
  12779. /**
  12780. * Enum used to define the material modes
  12781. */
  12782. export enum NodeMaterialModes {
  12783. /** Regular material */
  12784. Material = 0,
  12785. /** For post process */
  12786. PostProcess = 1,
  12787. /** For particle system */
  12788. Particle = 2,
  12789. /** For procedural texture */
  12790. ProceduralTexture = 3
  12791. }
  12792. }
  12793. declare module BABYLON {
  12794. /** @hidden */
  12795. export var helperFunctions: {
  12796. name: string;
  12797. shader: string;
  12798. };
  12799. }
  12800. declare module BABYLON {
  12801. /**
  12802. * Block used to read a texture from a sampler
  12803. */
  12804. export class TextureBlock extends NodeMaterialBlock {
  12805. private _defineName;
  12806. private _linearDefineName;
  12807. private _gammaDefineName;
  12808. private _tempTextureRead;
  12809. private _samplerName;
  12810. private _transformedUVName;
  12811. private _textureTransformName;
  12812. private _textureInfoName;
  12813. private _mainUVName;
  12814. private _mainUVDefineName;
  12815. private _fragmentOnly;
  12816. /**
  12817. * Gets or sets the texture associated with the node
  12818. */
  12819. texture: Nullable<Texture>;
  12820. /**
  12821. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  12822. */
  12823. convertToGammaSpace: boolean;
  12824. /**
  12825. * Gets or sets a boolean indicating if content needs to be converted to linear space
  12826. */
  12827. convertToLinearSpace: boolean;
  12828. /**
  12829. * Create a new TextureBlock
  12830. * @param name defines the block name
  12831. */
  12832. constructor(name: string, fragmentOnly?: boolean);
  12833. /**
  12834. * Gets the current class name
  12835. * @returns the class name
  12836. */
  12837. getClassName(): string;
  12838. /**
  12839. * Gets the uv input component
  12840. */
  12841. get uv(): NodeMaterialConnectionPoint;
  12842. /**
  12843. * Gets the rgba output component
  12844. */
  12845. get rgba(): NodeMaterialConnectionPoint;
  12846. /**
  12847. * Gets the rgb output component
  12848. */
  12849. get rgb(): NodeMaterialConnectionPoint;
  12850. /**
  12851. * Gets the r output component
  12852. */
  12853. get r(): NodeMaterialConnectionPoint;
  12854. /**
  12855. * Gets the g output component
  12856. */
  12857. get g(): NodeMaterialConnectionPoint;
  12858. /**
  12859. * Gets the b output component
  12860. */
  12861. get b(): NodeMaterialConnectionPoint;
  12862. /**
  12863. * Gets the a output component
  12864. */
  12865. get a(): NodeMaterialConnectionPoint;
  12866. get target(): NodeMaterialBlockTargets;
  12867. autoConfigure(material: NodeMaterial): void;
  12868. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  12869. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  12870. isReady(): boolean;
  12871. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  12872. private get _isMixed();
  12873. private _injectVertexCode;
  12874. private _writeTextureRead;
  12875. private _writeOutput;
  12876. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  12877. protected _dumpPropertiesCode(): string;
  12878. serialize(): any;
  12879. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  12880. }
  12881. }
  12882. declare module BABYLON {
  12883. /** @hidden */
  12884. export var reflectionFunction: {
  12885. name: string;
  12886. shader: string;
  12887. };
  12888. }
  12889. declare module BABYLON {
  12890. /**
  12891. * Base block used to read a reflection texture from a sampler
  12892. */
  12893. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  12894. /** @hidden */
  12895. _define3DName: string;
  12896. /** @hidden */
  12897. _defineCubicName: string;
  12898. /** @hidden */
  12899. _defineExplicitName: string;
  12900. /** @hidden */
  12901. _defineProjectionName: string;
  12902. /** @hidden */
  12903. _defineLocalCubicName: string;
  12904. /** @hidden */
  12905. _defineSphericalName: string;
  12906. /** @hidden */
  12907. _definePlanarName: string;
  12908. /** @hidden */
  12909. _defineEquirectangularName: string;
  12910. /** @hidden */
  12911. _defineMirroredEquirectangularFixedName: string;
  12912. /** @hidden */
  12913. _defineEquirectangularFixedName: string;
  12914. /** @hidden */
  12915. _defineSkyboxName: string;
  12916. /** @hidden */
  12917. _defineOppositeZ: string;
  12918. /** @hidden */
  12919. _cubeSamplerName: string;
  12920. /** @hidden */
  12921. _2DSamplerName: string;
  12922. protected _positionUVWName: string;
  12923. protected _directionWName: string;
  12924. protected _reflectionVectorName: string;
  12925. /** @hidden */
  12926. _reflectionCoordsName: string;
  12927. /** @hidden */
  12928. _reflectionMatrixName: string;
  12929. protected _reflectionColorName: string;
  12930. /**
  12931. * Gets or sets the texture associated with the node
  12932. */
  12933. texture: Nullable<BaseTexture>;
  12934. /**
  12935. * Create a new ReflectionTextureBaseBlock
  12936. * @param name defines the block name
  12937. */
  12938. constructor(name: string);
  12939. /**
  12940. * Gets the current class name
  12941. * @returns the class name
  12942. */
  12943. getClassName(): string;
  12944. /**
  12945. * Gets the world position input component
  12946. */
  12947. abstract get position(): NodeMaterialConnectionPoint;
  12948. /**
  12949. * Gets the world position input component
  12950. */
  12951. abstract get worldPosition(): NodeMaterialConnectionPoint;
  12952. /**
  12953. * Gets the world normal input component
  12954. */
  12955. abstract get worldNormal(): NodeMaterialConnectionPoint;
  12956. /**
  12957. * Gets the world input component
  12958. */
  12959. abstract get world(): NodeMaterialConnectionPoint;
  12960. /**
  12961. * Gets the camera (or eye) position component
  12962. */
  12963. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  12964. /**
  12965. * Gets the view input component
  12966. */
  12967. abstract get view(): NodeMaterialConnectionPoint;
  12968. protected _getTexture(): Nullable<BaseTexture>;
  12969. autoConfigure(material: NodeMaterial): void;
  12970. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  12971. isReady(): boolean;
  12972. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  12973. /**
  12974. * Gets the code to inject in the vertex shader
  12975. * @param state current state of the node material building
  12976. * @returns the shader code
  12977. */
  12978. handleVertexSide(state: NodeMaterialBuildState): string;
  12979. /**
  12980. * Handles the inits for the fragment code path
  12981. * @param state node material build state
  12982. */
  12983. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  12984. /**
  12985. * Generates the reflection coords code for the fragment code path
  12986. * @param worldNormalVarName name of the world normal variable
  12987. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  12988. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  12989. * @returns the shader code
  12990. */
  12991. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  12992. /**
  12993. * Generates the reflection color code for the fragment code path
  12994. * @param lodVarName name of the lod variable
  12995. * @param swizzleLookupTexture swizzle to use for the final color variable
  12996. * @returns the shader code
  12997. */
  12998. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  12999. /**
  13000. * Generates the code corresponding to the connected output points
  13001. * @param state node material build state
  13002. * @param varName name of the variable to output
  13003. * @returns the shader code
  13004. */
  13005. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  13006. protected _buildBlock(state: NodeMaterialBuildState): this;
  13007. protected _dumpPropertiesCode(): string;
  13008. serialize(): any;
  13009. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  13010. }
  13011. }
  13012. declare module BABYLON {
  13013. /**
  13014. * Defines a connection point to be used for points with a custom object type
  13015. */
  13016. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  13017. private _blockType;
  13018. private _blockName;
  13019. private _nameForCheking?;
  13020. /**
  13021. * Creates a new connection point
  13022. * @param name defines the connection point name
  13023. * @param ownerBlock defines the block hosting this connection point
  13024. * @param direction defines the direction of the connection point
  13025. */
  13026. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  13027. /**
  13028. * Gets a number indicating if the current point can be connected to another point
  13029. * @param connectionPoint defines the other connection point
  13030. * @returns a number defining the compatibility state
  13031. */
  13032. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  13033. /**
  13034. * Creates a block suitable to be used as an input for this input point.
  13035. * If null is returned, a block based on the point type will be created.
  13036. * @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
  13037. */
  13038. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  13039. }
  13040. }
  13041. declare module BABYLON {
  13042. /**
  13043. * Enum defining the type of properties that can be edited in the property pages in the NME
  13044. */
  13045. export enum PropertyTypeForEdition {
  13046. /** property is a boolean */
  13047. Boolean = 0,
  13048. /** property is a float */
  13049. Float = 1,
  13050. /** property is a Vector2 */
  13051. Vector2 = 2,
  13052. /** property is a list of values */
  13053. List = 3
  13054. }
  13055. /**
  13056. * Interface that defines an option in a variable of type list
  13057. */
  13058. export interface IEditablePropertyListOption {
  13059. /** label of the option */
  13060. "label": string;
  13061. /** value of the option */
  13062. "value": number;
  13063. }
  13064. /**
  13065. * Interface that defines the options available for an editable property
  13066. */
  13067. export interface IEditablePropertyOption {
  13068. /** min value */
  13069. "min"?: number;
  13070. /** max value */
  13071. "max"?: number;
  13072. /** notifiers: indicates which actions to take when the property is changed */
  13073. "notifiers"?: {
  13074. /** the material should be rebuilt */
  13075. "rebuild"?: boolean;
  13076. /** the preview should be updated */
  13077. "update"?: boolean;
  13078. };
  13079. /** list of the options for a variable of type list */
  13080. "options"?: IEditablePropertyListOption[];
  13081. }
  13082. /**
  13083. * Interface that describes an editable property
  13084. */
  13085. export interface IPropertyDescriptionForEdition {
  13086. /** name of the property */
  13087. "propertyName": string;
  13088. /** display name of the property */
  13089. "displayName": string;
  13090. /** type of the property */
  13091. "type": PropertyTypeForEdition;
  13092. /** group of the property - all properties with the same group value will be displayed in a specific section */
  13093. "groupName": string;
  13094. /** options for the property */
  13095. "options": IEditablePropertyOption;
  13096. }
  13097. /**
  13098. * Decorator that flags a property in a node material block as being editable
  13099. */
  13100. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  13101. }
  13102. declare module BABYLON {
  13103. /**
  13104. * Block used to implement the refraction part of the sub surface module of the PBR material
  13105. */
  13106. export class RefractionBlock extends NodeMaterialBlock {
  13107. /** @hidden */
  13108. _define3DName: string;
  13109. /** @hidden */
  13110. _refractionMatrixName: string;
  13111. /** @hidden */
  13112. _defineLODRefractionAlpha: string;
  13113. /** @hidden */
  13114. _defineLinearSpecularRefraction: string;
  13115. /** @hidden */
  13116. _defineOppositeZ: string;
  13117. /** @hidden */
  13118. _cubeSamplerName: string;
  13119. /** @hidden */
  13120. _2DSamplerName: string;
  13121. /** @hidden */
  13122. _vRefractionMicrosurfaceInfosName: string;
  13123. /** @hidden */
  13124. _vRefractionInfosName: string;
  13125. /** @hidden */
  13126. _vRefractionFilteringInfoName: string;
  13127. private _scene;
  13128. /**
  13129. * The properties below are set by the main PBR block prior to calling methods of this class.
  13130. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  13131. * It's less burden on the user side in the editor part.
  13132. */
  13133. /** @hidden */
  13134. viewConnectionPoint: NodeMaterialConnectionPoint;
  13135. /** @hidden */
  13136. indexOfRefractionConnectionPoint: NodeMaterialConnectionPoint;
  13137. /**
  13138. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  13139. * Materials half opaque for instance using refraction could benefit from this control.
  13140. */
  13141. linkRefractionWithTransparency: boolean;
  13142. /**
  13143. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  13144. */
  13145. invertRefractionY: boolean;
  13146. /**
  13147. * Gets or sets the texture associated with the node
  13148. */
  13149. texture: Nullable<BaseTexture>;
  13150. /**
  13151. * Create a new RefractionBlock
  13152. * @param name defines the block name
  13153. */
  13154. constructor(name: string);
  13155. /**
  13156. * Gets the current class name
  13157. * @returns the class name
  13158. */
  13159. getClassName(): string;
  13160. /**
  13161. * Gets the intensity input component
  13162. */
  13163. get intensity(): NodeMaterialConnectionPoint;
  13164. /**
  13165. * Gets the tint at distance input component
  13166. */
  13167. get tintAtDistance(): NodeMaterialConnectionPoint;
  13168. /**
  13169. * Gets the view input component
  13170. */
  13171. get view(): NodeMaterialConnectionPoint;
  13172. /**
  13173. * Gets the refraction object output component
  13174. */
  13175. get refraction(): NodeMaterialConnectionPoint;
  13176. /**
  13177. * Returns true if the block has a texture
  13178. */
  13179. get hasTexture(): boolean;
  13180. protected _getTexture(): Nullable<BaseTexture>;
  13181. autoConfigure(material: NodeMaterial): void;
  13182. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  13183. isReady(): boolean;
  13184. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  13185. /**
  13186. * Gets the main code of the block (fragment side)
  13187. * @param state current state of the node material building
  13188. * @returns the shader code
  13189. */
  13190. getCode(state: NodeMaterialBuildState): string;
  13191. protected _buildBlock(state: NodeMaterialBuildState): this;
  13192. protected _dumpPropertiesCode(): string;
  13193. serialize(): any;
  13194. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  13195. }
  13196. }
  13197. declare module BABYLON {
  13198. /**
  13199. * Base block used as input for post process
  13200. */
  13201. export class CurrentScreenBlock extends NodeMaterialBlock {
  13202. private _samplerName;
  13203. private _linearDefineName;
  13204. private _gammaDefineName;
  13205. private _mainUVName;
  13206. private _tempTextureRead;
  13207. /**
  13208. * Gets or sets the texture associated with the node
  13209. */
  13210. texture: Nullable<BaseTexture>;
  13211. /**
  13212. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  13213. */
  13214. convertToGammaSpace: boolean;
  13215. /**
  13216. * Gets or sets a boolean indicating if content needs to be converted to linear space
  13217. */
  13218. convertToLinearSpace: boolean;
  13219. /**
  13220. * Create a new CurrentScreenBlock
  13221. * @param name defines the block name
  13222. */
  13223. constructor(name: string);
  13224. /**
  13225. * Gets the current class name
  13226. * @returns the class name
  13227. */
  13228. getClassName(): string;
  13229. /**
  13230. * Gets the uv input component
  13231. */
  13232. get uv(): NodeMaterialConnectionPoint;
  13233. /**
  13234. * Gets the rgba output component
  13235. */
  13236. get rgba(): NodeMaterialConnectionPoint;
  13237. /**
  13238. * Gets the rgb output component
  13239. */
  13240. get rgb(): NodeMaterialConnectionPoint;
  13241. /**
  13242. * Gets the r output component
  13243. */
  13244. get r(): NodeMaterialConnectionPoint;
  13245. /**
  13246. * Gets the g output component
  13247. */
  13248. get g(): NodeMaterialConnectionPoint;
  13249. /**
  13250. * Gets the b output component
  13251. */
  13252. get b(): NodeMaterialConnectionPoint;
  13253. /**
  13254. * Gets the a output component
  13255. */
  13256. get a(): NodeMaterialConnectionPoint;
  13257. /**
  13258. * Initialize the block and prepare the context for build
  13259. * @param state defines the state that will be used for the build
  13260. */
  13261. initialize(state: NodeMaterialBuildState): void;
  13262. get target(): NodeMaterialBlockTargets;
  13263. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  13264. isReady(): boolean;
  13265. private _injectVertexCode;
  13266. private _writeTextureRead;
  13267. private _writeOutput;
  13268. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  13269. serialize(): any;
  13270. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  13271. }
  13272. }
  13273. declare module BABYLON {
  13274. /**
  13275. * Base block used for the particle texture
  13276. */
  13277. export class ParticleTextureBlock extends NodeMaterialBlock {
  13278. private _samplerName;
  13279. private _linearDefineName;
  13280. private _gammaDefineName;
  13281. private _tempTextureRead;
  13282. /**
  13283. * Gets or sets the texture associated with the node
  13284. */
  13285. texture: Nullable<BaseTexture>;
  13286. /**
  13287. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  13288. */
  13289. convertToGammaSpace: boolean;
  13290. /**
  13291. * Gets or sets a boolean indicating if content needs to be converted to linear space
  13292. */
  13293. convertToLinearSpace: boolean;
  13294. /**
  13295. * Create a new ParticleTextureBlock
  13296. * @param name defines the block name
  13297. */
  13298. constructor(name: string);
  13299. /**
  13300. * Gets the current class name
  13301. * @returns the class name
  13302. */
  13303. getClassName(): string;
  13304. /**
  13305. * Gets the uv input component
  13306. */
  13307. get uv(): NodeMaterialConnectionPoint;
  13308. /**
  13309. * Gets the rgba output component
  13310. */
  13311. get rgba(): NodeMaterialConnectionPoint;
  13312. /**
  13313. * Gets the rgb output component
  13314. */
  13315. get rgb(): NodeMaterialConnectionPoint;
  13316. /**
  13317. * Gets the r output component
  13318. */
  13319. get r(): NodeMaterialConnectionPoint;
  13320. /**
  13321. * Gets the g output component
  13322. */
  13323. get g(): NodeMaterialConnectionPoint;
  13324. /**
  13325. * Gets the b output component
  13326. */
  13327. get b(): NodeMaterialConnectionPoint;
  13328. /**
  13329. * Gets the a output component
  13330. */
  13331. get a(): NodeMaterialConnectionPoint;
  13332. /**
  13333. * Initialize the block and prepare the context for build
  13334. * @param state defines the state that will be used for the build
  13335. */
  13336. initialize(state: NodeMaterialBuildState): void;
  13337. autoConfigure(material: NodeMaterial): void;
  13338. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  13339. isReady(): boolean;
  13340. private _writeOutput;
  13341. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  13342. serialize(): any;
  13343. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  13344. }
  13345. }
  13346. declare module BABYLON {
  13347. /**
  13348. * Class used to store shared data between 2 NodeMaterialBuildState
  13349. */
  13350. export class NodeMaterialBuildStateSharedData {
  13351. /**
  13352. * Gets the list of emitted varyings
  13353. */
  13354. temps: string[];
  13355. /**
  13356. * Gets the list of emitted varyings
  13357. */
  13358. varyings: string[];
  13359. /**
  13360. * Gets the varying declaration string
  13361. */
  13362. varyingDeclaration: string;
  13363. /**
  13364. * Input blocks
  13365. */
  13366. inputBlocks: InputBlock[];
  13367. /**
  13368. * Input blocks
  13369. */
  13370. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  13371. /**
  13372. * Bindable blocks (Blocks that need to set data to the effect)
  13373. */
  13374. bindableBlocks: NodeMaterialBlock[];
  13375. /**
  13376. * List of blocks that can provide a compilation fallback
  13377. */
  13378. blocksWithFallbacks: NodeMaterialBlock[];
  13379. /**
  13380. * List of blocks that can provide a define update
  13381. */
  13382. blocksWithDefines: NodeMaterialBlock[];
  13383. /**
  13384. * List of blocks that can provide a repeatable content
  13385. */
  13386. repeatableContentBlocks: NodeMaterialBlock[];
  13387. /**
  13388. * List of blocks that can provide a dynamic list of uniforms
  13389. */
  13390. dynamicUniformBlocks: NodeMaterialBlock[];
  13391. /**
  13392. * List of blocks that can block the isReady function for the material
  13393. */
  13394. blockingBlocks: NodeMaterialBlock[];
  13395. /**
  13396. * Gets the list of animated inputs
  13397. */
  13398. animatedInputs: InputBlock[];
  13399. /**
  13400. * Build Id used to avoid multiple recompilations
  13401. */
  13402. buildId: number;
  13403. /** List of emitted variables */
  13404. variableNames: {
  13405. [key: string]: number;
  13406. };
  13407. /** List of emitted defines */
  13408. defineNames: {
  13409. [key: string]: number;
  13410. };
  13411. /** Should emit comments? */
  13412. emitComments: boolean;
  13413. /** Emit build activity */
  13414. verbose: boolean;
  13415. /** Gets or sets the hosting scene */
  13416. scene: Scene;
  13417. /**
  13418. * Gets the compilation hints emitted at compilation time
  13419. */
  13420. hints: {
  13421. needWorldViewMatrix: boolean;
  13422. needWorldViewProjectionMatrix: boolean;
  13423. needAlphaBlending: boolean;
  13424. needAlphaTesting: boolean;
  13425. };
  13426. /**
  13427. * List of compilation checks
  13428. */
  13429. checks: {
  13430. emitVertex: boolean;
  13431. emitFragment: boolean;
  13432. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  13433. };
  13434. /**
  13435. * Is vertex program allowed to be empty?
  13436. */
  13437. allowEmptyVertexProgram: boolean;
  13438. /** Creates a new shared data */
  13439. constructor();
  13440. /**
  13441. * Emits console errors and exceptions if there is a failing check
  13442. */
  13443. emitErrors(): void;
  13444. }
  13445. }
  13446. declare module BABYLON {
  13447. /**
  13448. * Class used to store node based material build state
  13449. */
  13450. export class NodeMaterialBuildState {
  13451. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  13452. supportUniformBuffers: boolean;
  13453. /**
  13454. * Gets the list of emitted attributes
  13455. */
  13456. attributes: string[];
  13457. /**
  13458. * Gets the list of emitted uniforms
  13459. */
  13460. uniforms: string[];
  13461. /**
  13462. * Gets the list of emitted constants
  13463. */
  13464. constants: string[];
  13465. /**
  13466. * Gets the list of emitted samplers
  13467. */
  13468. samplers: string[];
  13469. /**
  13470. * Gets the list of emitted functions
  13471. */
  13472. functions: {
  13473. [key: string]: string;
  13474. };
  13475. /**
  13476. * Gets the list of emitted extensions
  13477. */
  13478. extensions: {
  13479. [key: string]: string;
  13480. };
  13481. /**
  13482. * Gets the target of the compilation state
  13483. */
  13484. target: NodeMaterialBlockTargets;
  13485. /**
  13486. * Gets the list of emitted counters
  13487. */
  13488. counters: {
  13489. [key: string]: number;
  13490. };
  13491. /**
  13492. * Shared data between multiple NodeMaterialBuildState instances
  13493. */
  13494. sharedData: NodeMaterialBuildStateSharedData;
  13495. /** @hidden */
  13496. _vertexState: NodeMaterialBuildState;
  13497. /** @hidden */
  13498. _attributeDeclaration: string;
  13499. /** @hidden */
  13500. _uniformDeclaration: string;
  13501. /** @hidden */
  13502. _constantDeclaration: string;
  13503. /** @hidden */
  13504. _samplerDeclaration: string;
  13505. /** @hidden */
  13506. _varyingTransfer: string;
  13507. /** @hidden */
  13508. _injectAtEnd: string;
  13509. private _repeatableContentAnchorIndex;
  13510. /** @hidden */
  13511. _builtCompilationString: string;
  13512. /**
  13513. * Gets the emitted compilation strings
  13514. */
  13515. compilationString: string;
  13516. /**
  13517. * Finalize the compilation strings
  13518. * @param state defines the current compilation state
  13519. */
  13520. finalize(state: NodeMaterialBuildState): void;
  13521. /** @hidden */
  13522. get _repeatableContentAnchor(): string;
  13523. /** @hidden */
  13524. _getFreeVariableName(prefix: string): string;
  13525. /** @hidden */
  13526. _getFreeDefineName(prefix: string): string;
  13527. /** @hidden */
  13528. _excludeVariableName(name: string): void;
  13529. /** @hidden */
  13530. _emit2DSampler(name: string): void;
  13531. /** @hidden */
  13532. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  13533. /** @hidden */
  13534. _emitExtension(name: string, extension: string, define?: string): void;
  13535. /** @hidden */
  13536. _emitFunction(name: string, code: string, comments: string): void;
  13537. /** @hidden */
  13538. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  13539. replaceStrings?: {
  13540. search: RegExp;
  13541. replace: string;
  13542. }[];
  13543. repeatKey?: string;
  13544. }): string;
  13545. /** @hidden */
  13546. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  13547. repeatKey?: string;
  13548. removeAttributes?: boolean;
  13549. removeUniforms?: boolean;
  13550. removeVaryings?: boolean;
  13551. removeIfDef?: boolean;
  13552. replaceStrings?: {
  13553. search: RegExp;
  13554. replace: string;
  13555. }[];
  13556. }, storeKey?: string): void;
  13557. /** @hidden */
  13558. _registerTempVariable(name: string): boolean;
  13559. /** @hidden */
  13560. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  13561. /** @hidden */
  13562. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  13563. /** @hidden */
  13564. _emitFloat(value: number): string;
  13565. }
  13566. }
  13567. declare module BABYLON {
  13568. /**
  13569. * Helper class used to generate session unique ID
  13570. */
  13571. export class UniqueIdGenerator {
  13572. private static _UniqueIdCounter;
  13573. /**
  13574. * Gets an unique (relatively to the current scene) Id
  13575. */
  13576. static get UniqueId(): number;
  13577. }
  13578. }
  13579. declare module BABYLON {
  13580. /**
  13581. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  13582. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  13583. */
  13584. export class EffectFallbacks implements IEffectFallbacks {
  13585. private _defines;
  13586. private _currentRank;
  13587. private _maxRank;
  13588. private _mesh;
  13589. /**
  13590. * Removes the fallback from the bound mesh.
  13591. */
  13592. unBindMesh(): void;
  13593. /**
  13594. * Adds a fallback on the specified property.
  13595. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  13596. * @param define The name of the define in the shader
  13597. */
  13598. addFallback(rank: number, define: string): void;
  13599. /**
  13600. * Sets the mesh to use CPU skinning when needing to fallback.
  13601. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  13602. * @param mesh The mesh to use the fallbacks.
  13603. */
  13604. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  13605. /**
  13606. * Checks to see if more fallbacks are still availible.
  13607. */
  13608. get hasMoreFallbacks(): boolean;
  13609. /**
  13610. * Removes the defines that should be removed when falling back.
  13611. * @param currentDefines defines the current define statements for the shader.
  13612. * @param effect defines the current effect we try to compile
  13613. * @returns The resulting defines with defines of the current rank removed.
  13614. */
  13615. reduce(currentDefines: string, effect: Effect): string;
  13616. }
  13617. }
  13618. declare module BABYLON {
  13619. /**
  13620. * Defines a block that can be used inside a node based material
  13621. */
  13622. export class NodeMaterialBlock {
  13623. private _buildId;
  13624. private _buildTarget;
  13625. private _target;
  13626. private _isFinalMerger;
  13627. private _isInput;
  13628. private _name;
  13629. protected _isUnique: boolean;
  13630. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  13631. inputsAreExclusive: boolean;
  13632. /** @hidden */
  13633. _codeVariableName: string;
  13634. /** @hidden */
  13635. _inputs: NodeMaterialConnectionPoint[];
  13636. /** @hidden */
  13637. _outputs: NodeMaterialConnectionPoint[];
  13638. /** @hidden */
  13639. _preparationId: number;
  13640. /** @hidden */
  13641. readonly _originalTargetIsNeutral: boolean;
  13642. /**
  13643. * Gets the name of the block
  13644. */
  13645. get name(): string;
  13646. /**
  13647. * Sets the name of the block. Will check if the name is valid.
  13648. */
  13649. set name(newName: string);
  13650. /**
  13651. * Gets or sets the unique id of the node
  13652. */
  13653. uniqueId: number;
  13654. /**
  13655. * Gets or sets the comments associated with this block
  13656. */
  13657. comments: string;
  13658. /**
  13659. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  13660. */
  13661. get isUnique(): boolean;
  13662. /**
  13663. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  13664. */
  13665. get isFinalMerger(): boolean;
  13666. /**
  13667. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  13668. */
  13669. get isInput(): boolean;
  13670. /**
  13671. * Gets or sets the build Id
  13672. */
  13673. get buildId(): number;
  13674. set buildId(value: number);
  13675. /**
  13676. * Gets or sets the target of the block
  13677. */
  13678. get target(): NodeMaterialBlockTargets;
  13679. set target(value: NodeMaterialBlockTargets);
  13680. /**
  13681. * Gets the list of input points
  13682. */
  13683. get inputs(): NodeMaterialConnectionPoint[];
  13684. /** Gets the list of output points */
  13685. get outputs(): NodeMaterialConnectionPoint[];
  13686. /**
  13687. * Find an input by its name
  13688. * @param name defines the name of the input to look for
  13689. * @returns the input or null if not found
  13690. */
  13691. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  13692. /**
  13693. * Find an output by its name
  13694. * @param name defines the name of the outputto look for
  13695. * @returns the output or null if not found
  13696. */
  13697. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  13698. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  13699. visibleInInspector: boolean;
  13700. /** Gets or sets a boolean indicating that this input can be edited from a collapsed frame*/
  13701. visibleOnFrame: boolean;
  13702. /**
  13703. * Creates a new NodeMaterialBlock
  13704. * @param name defines the block name
  13705. * @param target defines the target of that block (Vertex by default)
  13706. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  13707. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  13708. */
  13709. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  13710. /**
  13711. * Initialize the block and prepare the context for build
  13712. * @param state defines the state that will be used for the build
  13713. */
  13714. initialize(state: NodeMaterialBuildState): void;
  13715. /**
  13716. * Bind data to effect. Will only be called for blocks with isBindable === true
  13717. * @param effect defines the effect to bind data to
  13718. * @param nodeMaterial defines the hosting NodeMaterial
  13719. * @param mesh defines the mesh that will be rendered
  13720. * @param subMesh defines the submesh that will be rendered
  13721. */
  13722. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  13723. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  13724. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  13725. protected _writeFloat(value: number): string;
  13726. /**
  13727. * Gets the current class name e.g. "NodeMaterialBlock"
  13728. * @returns the class name
  13729. */
  13730. getClassName(): string;
  13731. /**
  13732. * Register a new input. Must be called inside a block constructor
  13733. * @param name defines the connection point name
  13734. * @param type defines the connection point type
  13735. * @param isOptional defines a boolean indicating that this input can be omitted
  13736. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  13737. * @param point an already created connection point. If not provided, create a new one
  13738. * @returns the current block
  13739. */
  13740. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  13741. /**
  13742. * Register a new output. Must be called inside a block constructor
  13743. * @param name defines the connection point name
  13744. * @param type defines the connection point type
  13745. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  13746. * @param point an already created connection point. If not provided, create a new one
  13747. * @returns the current block
  13748. */
  13749. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  13750. /**
  13751. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  13752. * @param forOutput defines an optional connection point to check compatibility with
  13753. * @returns the first available input or null
  13754. */
  13755. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  13756. /**
  13757. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  13758. * @param forBlock defines an optional block to check compatibility with
  13759. * @returns the first available input or null
  13760. */
  13761. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  13762. /**
  13763. * Gets the sibling of the given output
  13764. * @param current defines the current output
  13765. * @returns the next output in the list or null
  13766. */
  13767. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  13768. /**
  13769. * Connect current block with another block
  13770. * @param other defines the block to connect with
  13771. * @param options define the various options to help pick the right connections
  13772. * @returns the current block
  13773. */
  13774. connectTo(other: NodeMaterialBlock, options?: {
  13775. input?: string;
  13776. output?: string;
  13777. outputSwizzle?: string;
  13778. }): this | undefined;
  13779. protected _buildBlock(state: NodeMaterialBuildState): void;
  13780. /**
  13781. * Add uniforms, samplers and uniform buffers at compilation time
  13782. * @param state defines the state to update
  13783. * @param nodeMaterial defines the node material requesting the update
  13784. * @param defines defines the material defines to update
  13785. * @param uniformBuffers defines the list of uniform buffer names
  13786. */
  13787. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  13788. /**
  13789. * Add potential fallbacks if shader compilation fails
  13790. * @param mesh defines the mesh to be rendered
  13791. * @param fallbacks defines the current prioritized list of fallbacks
  13792. */
  13793. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  13794. /**
  13795. * Initialize defines for shader compilation
  13796. * @param mesh defines the mesh to be rendered
  13797. * @param nodeMaterial defines the node material requesting the update
  13798. * @param defines defines the material defines to update
  13799. * @param useInstances specifies that instances should be used
  13800. */
  13801. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  13802. /**
  13803. * Update defines for shader compilation
  13804. * @param mesh defines the mesh to be rendered
  13805. * @param nodeMaterial defines the node material requesting the update
  13806. * @param defines defines the material defines to update
  13807. * @param useInstances specifies that instances should be used
  13808. * @param subMesh defines which submesh to render
  13809. */
  13810. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  13811. /**
  13812. * Lets the block try to connect some inputs automatically
  13813. * @param material defines the hosting NodeMaterial
  13814. */
  13815. autoConfigure(material: NodeMaterial): void;
  13816. /**
  13817. * Function called when a block is declared as repeatable content generator
  13818. * @param vertexShaderState defines the current compilation state for the vertex shader
  13819. * @param fragmentShaderState defines the current compilation state for the fragment shader
  13820. * @param mesh defines the mesh to be rendered
  13821. * @param defines defines the material defines to update
  13822. */
  13823. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  13824. /**
  13825. * Checks if the block is ready
  13826. * @param mesh defines the mesh to be rendered
  13827. * @param nodeMaterial defines the node material requesting the update
  13828. * @param defines defines the material defines to update
  13829. * @param useInstances specifies that instances should be used
  13830. * @returns true if the block is ready
  13831. */
  13832. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  13833. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number, looseCoupling?: boolean): void;
  13834. private _processBuild;
  13835. /**
  13836. * Validates the new name for the block node.
  13837. * @param newName the new name to be given to the node.
  13838. * @returns false if the name is a reserve word, else true.
  13839. */
  13840. validateBlockName(newName: string): boolean;
  13841. /**
  13842. * Compile the current node and generate the shader code
  13843. * @param state defines the current compilation state (uniforms, samplers, current string)
  13844. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  13845. * @returns true if already built
  13846. */
  13847. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  13848. protected _inputRename(name: string): string;
  13849. protected _outputRename(name: string): string;
  13850. protected _dumpPropertiesCode(): string;
  13851. /** @hidden */
  13852. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  13853. /** @hidden */
  13854. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  13855. /**
  13856. * Clone the current block to a new identical block
  13857. * @param scene defines the hosting scene
  13858. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  13859. * @returns a copy of the current block
  13860. */
  13861. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  13862. /**
  13863. * Serializes this block in a JSON representation
  13864. * @returns the serialized block object
  13865. */
  13866. serialize(): any;
  13867. /** @hidden */
  13868. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  13869. private _deserializePortDisplayNamesAndExposedOnFrame;
  13870. /**
  13871. * Release resources
  13872. */
  13873. dispose(): void;
  13874. }
  13875. }
  13876. declare module BABYLON {
  13877. /**
  13878. * Base class of materials working in push mode in babylon JS
  13879. * @hidden
  13880. */
  13881. export class PushMaterial extends Material {
  13882. protected _activeEffect: Effect;
  13883. protected _normalMatrix: Matrix;
  13884. constructor(name: string, scene: Scene);
  13885. getEffect(): Effect;
  13886. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  13887. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  13888. /**
  13889. * Binds the given world matrix to the active effect
  13890. *
  13891. * @param world the matrix to bind
  13892. */
  13893. bindOnlyWorldMatrix(world: Matrix): void;
  13894. /**
  13895. * Binds the given normal matrix to the active effect
  13896. *
  13897. * @param normalMatrix the matrix to bind
  13898. */
  13899. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  13900. bind(world: Matrix, mesh?: Mesh): void;
  13901. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  13902. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  13903. }
  13904. }
  13905. declare module BABYLON {
  13906. /**
  13907. * Root class for all node material optimizers
  13908. */
  13909. export class NodeMaterialOptimizer {
  13910. /**
  13911. * Function used to optimize a NodeMaterial graph
  13912. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  13913. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  13914. */
  13915. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  13916. }
  13917. }
  13918. declare module BABYLON {
  13919. /**
  13920. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  13921. */
  13922. export class TransformBlock extends NodeMaterialBlock {
  13923. /**
  13924. * Defines the value to use to complement W value to transform it to a Vector4
  13925. */
  13926. complementW: number;
  13927. /**
  13928. * Defines the value to use to complement z value to transform it to a Vector4
  13929. */
  13930. complementZ: number;
  13931. /**
  13932. * Creates a new TransformBlock
  13933. * @param name defines the block name
  13934. */
  13935. constructor(name: string);
  13936. /**
  13937. * Gets the current class name
  13938. * @returns the class name
  13939. */
  13940. getClassName(): string;
  13941. /**
  13942. * Gets the vector input
  13943. */
  13944. get vector(): NodeMaterialConnectionPoint;
  13945. /**
  13946. * Gets the output component
  13947. */
  13948. get output(): NodeMaterialConnectionPoint;
  13949. /**
  13950. * Gets the xyz output component
  13951. */
  13952. get xyz(): NodeMaterialConnectionPoint;
  13953. /**
  13954. * Gets the matrix transform input
  13955. */
  13956. get transform(): NodeMaterialConnectionPoint;
  13957. protected _buildBlock(state: NodeMaterialBuildState): this;
  13958. /**
  13959. * Update defines for shader compilation
  13960. * @param mesh defines the mesh to be rendered
  13961. * @param nodeMaterial defines the node material requesting the update
  13962. * @param defines defines the material defines to update
  13963. * @param useInstances specifies that instances should be used
  13964. * @param subMesh defines which submesh to render
  13965. */
  13966. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  13967. serialize(): any;
  13968. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  13969. protected _dumpPropertiesCode(): string;
  13970. }
  13971. }
  13972. declare module BABYLON {
  13973. /**
  13974. * Block used to output the vertex position
  13975. */
  13976. export class VertexOutputBlock extends NodeMaterialBlock {
  13977. /**
  13978. * Creates a new VertexOutputBlock
  13979. * @param name defines the block name
  13980. */
  13981. constructor(name: string);
  13982. /**
  13983. * Gets the current class name
  13984. * @returns the class name
  13985. */
  13986. getClassName(): string;
  13987. /**
  13988. * Gets the vector input component
  13989. */
  13990. get vector(): NodeMaterialConnectionPoint;
  13991. protected _buildBlock(state: NodeMaterialBuildState): this;
  13992. }
  13993. }
  13994. declare module BABYLON {
  13995. /**
  13996. * Block used to output the final color
  13997. */
  13998. export class FragmentOutputBlock extends NodeMaterialBlock {
  13999. /**
  14000. * Create a new FragmentOutputBlock
  14001. * @param name defines the block name
  14002. */
  14003. constructor(name: string);
  14004. /**
  14005. * Gets the current class name
  14006. * @returns the class name
  14007. */
  14008. getClassName(): string;
  14009. /**
  14010. * Gets the rgba input component
  14011. */
  14012. get rgba(): NodeMaterialConnectionPoint;
  14013. /**
  14014. * Gets the rgb input component
  14015. */
  14016. get rgb(): NodeMaterialConnectionPoint;
  14017. /**
  14018. * Gets the a input component
  14019. */
  14020. get a(): NodeMaterialConnectionPoint;
  14021. protected _buildBlock(state: NodeMaterialBuildState): this;
  14022. }
  14023. }
  14024. declare module BABYLON {
  14025. /**
  14026. * Block used for the particle ramp gradient section
  14027. */
  14028. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  14029. /**
  14030. * Create a new ParticleRampGradientBlock
  14031. * @param name defines the block name
  14032. */
  14033. constructor(name: string);
  14034. /**
  14035. * Gets the current class name
  14036. * @returns the class name
  14037. */
  14038. getClassName(): string;
  14039. /**
  14040. * Gets the color input component
  14041. */
  14042. get color(): NodeMaterialConnectionPoint;
  14043. /**
  14044. * Gets the rampColor output component
  14045. */
  14046. get rampColor(): NodeMaterialConnectionPoint;
  14047. /**
  14048. * Initialize the block and prepare the context for build
  14049. * @param state defines the state that will be used for the build
  14050. */
  14051. initialize(state: NodeMaterialBuildState): void;
  14052. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  14053. }
  14054. }
  14055. declare module BABYLON {
  14056. /**
  14057. * Block used for the particle blend multiply section
  14058. */
  14059. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  14060. /**
  14061. * Create a new ParticleBlendMultiplyBlock
  14062. * @param name defines the block name
  14063. */
  14064. constructor(name: string);
  14065. /**
  14066. * Gets the current class name
  14067. * @returns the class name
  14068. */
  14069. getClassName(): string;
  14070. /**
  14071. * Gets the color input component
  14072. */
  14073. get color(): NodeMaterialConnectionPoint;
  14074. /**
  14075. * Gets the alphaTexture input component
  14076. */
  14077. get alphaTexture(): NodeMaterialConnectionPoint;
  14078. /**
  14079. * Gets the alphaColor input component
  14080. */
  14081. get alphaColor(): NodeMaterialConnectionPoint;
  14082. /**
  14083. * Gets the blendColor output component
  14084. */
  14085. get blendColor(): NodeMaterialConnectionPoint;
  14086. /**
  14087. * Initialize the block and prepare the context for build
  14088. * @param state defines the state that will be used for the build
  14089. */
  14090. initialize(state: NodeMaterialBuildState): void;
  14091. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  14092. }
  14093. }
  14094. declare module BABYLON {
  14095. /**
  14096. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  14097. */
  14098. export class VectorMergerBlock extends NodeMaterialBlock {
  14099. /**
  14100. * Create a new VectorMergerBlock
  14101. * @param name defines the block name
  14102. */
  14103. constructor(name: string);
  14104. /**
  14105. * Gets the current class name
  14106. * @returns the class name
  14107. */
  14108. getClassName(): string;
  14109. /**
  14110. * Gets the xyz component (input)
  14111. */
  14112. get xyzIn(): NodeMaterialConnectionPoint;
  14113. /**
  14114. * Gets the xy component (input)
  14115. */
  14116. get xyIn(): NodeMaterialConnectionPoint;
  14117. /**
  14118. * Gets the x component (input)
  14119. */
  14120. get x(): NodeMaterialConnectionPoint;
  14121. /**
  14122. * Gets the y component (input)
  14123. */
  14124. get y(): NodeMaterialConnectionPoint;
  14125. /**
  14126. * Gets the z component (input)
  14127. */
  14128. get z(): NodeMaterialConnectionPoint;
  14129. /**
  14130. * Gets the w component (input)
  14131. */
  14132. get w(): NodeMaterialConnectionPoint;
  14133. /**
  14134. * Gets the xyzw component (output)
  14135. */
  14136. get xyzw(): NodeMaterialConnectionPoint;
  14137. /**
  14138. * Gets the xyz component (output)
  14139. */
  14140. get xyzOut(): NodeMaterialConnectionPoint;
  14141. /**
  14142. * Gets the xy component (output)
  14143. */
  14144. get xyOut(): NodeMaterialConnectionPoint;
  14145. /**
  14146. * Gets the xy component (output)
  14147. * @deprecated Please use xyOut instead.
  14148. */
  14149. get xy(): NodeMaterialConnectionPoint;
  14150. /**
  14151. * Gets the xyz component (output)
  14152. * @deprecated Please use xyzOut instead.
  14153. */
  14154. get xyz(): NodeMaterialConnectionPoint;
  14155. protected _buildBlock(state: NodeMaterialBuildState): this;
  14156. }
  14157. }
  14158. declare module BABYLON {
  14159. /**
  14160. * Block used to remap a float from a range to a new one
  14161. */
  14162. export class RemapBlock extends NodeMaterialBlock {
  14163. /**
  14164. * Gets or sets the source range
  14165. */
  14166. sourceRange: Vector2;
  14167. /**
  14168. * Gets or sets the target range
  14169. */
  14170. targetRange: Vector2;
  14171. /**
  14172. * Creates a new RemapBlock
  14173. * @param name defines the block name
  14174. */
  14175. constructor(name: string);
  14176. /**
  14177. * Gets the current class name
  14178. * @returns the class name
  14179. */
  14180. getClassName(): string;
  14181. /**
  14182. * Gets the input component
  14183. */
  14184. get input(): NodeMaterialConnectionPoint;
  14185. /**
  14186. * Gets the source min input component
  14187. */
  14188. get sourceMin(): NodeMaterialConnectionPoint;
  14189. /**
  14190. * Gets the source max input component
  14191. */
  14192. get sourceMax(): NodeMaterialConnectionPoint;
  14193. /**
  14194. * Gets the target min input component
  14195. */
  14196. get targetMin(): NodeMaterialConnectionPoint;
  14197. /**
  14198. * Gets the target max input component
  14199. */
  14200. get targetMax(): NodeMaterialConnectionPoint;
  14201. /**
  14202. * Gets the output component
  14203. */
  14204. get output(): NodeMaterialConnectionPoint;
  14205. protected _buildBlock(state: NodeMaterialBuildState): this;
  14206. protected _dumpPropertiesCode(): string;
  14207. serialize(): any;
  14208. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  14209. }
  14210. }
  14211. declare module BABYLON {
  14212. /**
  14213. * Block used to multiply 2 values
  14214. */
  14215. export class MultiplyBlock extends NodeMaterialBlock {
  14216. /**
  14217. * Creates a new MultiplyBlock
  14218. * @param name defines the block name
  14219. */
  14220. constructor(name: string);
  14221. /**
  14222. * Gets the current class name
  14223. * @returns the class name
  14224. */
  14225. getClassName(): string;
  14226. /**
  14227. * Gets the left operand input component
  14228. */
  14229. get left(): NodeMaterialConnectionPoint;
  14230. /**
  14231. * Gets the right operand input component
  14232. */
  14233. get right(): NodeMaterialConnectionPoint;
  14234. /**
  14235. * Gets the output component
  14236. */
  14237. get output(): NodeMaterialConnectionPoint;
  14238. protected _buildBlock(state: NodeMaterialBuildState): this;
  14239. }
  14240. }
  14241. declare module BABYLON {
  14242. /** Interface used by value gradients (color, factor, ...) */
  14243. export interface IValueGradient {
  14244. /**
  14245. * Gets or sets the gradient value (between 0 and 1)
  14246. */
  14247. gradient: number;
  14248. }
  14249. /** Class used to store color4 gradient */
  14250. export class ColorGradient implements IValueGradient {
  14251. /**
  14252. * Gets or sets the gradient value (between 0 and 1)
  14253. */
  14254. gradient: number;
  14255. /**
  14256. * Gets or sets first associated color
  14257. */
  14258. color1: Color4;
  14259. /**
  14260. * Gets or sets second associated color
  14261. */
  14262. color2?: Color4 | undefined;
  14263. /**
  14264. * Creates a new color4 gradient
  14265. * @param gradient gets or sets the gradient value (between 0 and 1)
  14266. * @param color1 gets or sets first associated color
  14267. * @param color2 gets or sets first second color
  14268. */
  14269. constructor(
  14270. /**
  14271. * Gets or sets the gradient value (between 0 and 1)
  14272. */
  14273. gradient: number,
  14274. /**
  14275. * Gets or sets first associated color
  14276. */
  14277. color1: Color4,
  14278. /**
  14279. * Gets or sets second associated color
  14280. */
  14281. color2?: Color4 | undefined);
  14282. /**
  14283. * Will get a color picked randomly between color1 and color2.
  14284. * If color2 is undefined then color1 will be used
  14285. * @param result defines the target Color4 to store the result in
  14286. */
  14287. getColorToRef(result: Color4): void;
  14288. }
  14289. /** Class used to store color 3 gradient */
  14290. export class Color3Gradient implements IValueGradient {
  14291. /**
  14292. * Gets or sets the gradient value (between 0 and 1)
  14293. */
  14294. gradient: number;
  14295. /**
  14296. * Gets or sets the associated color
  14297. */
  14298. color: Color3;
  14299. /**
  14300. * Creates a new color3 gradient
  14301. * @param gradient gets or sets the gradient value (between 0 and 1)
  14302. * @param color gets or sets associated color
  14303. */
  14304. constructor(
  14305. /**
  14306. * Gets or sets the gradient value (between 0 and 1)
  14307. */
  14308. gradient: number,
  14309. /**
  14310. * Gets or sets the associated color
  14311. */
  14312. color: Color3);
  14313. }
  14314. /** Class used to store factor gradient */
  14315. export class FactorGradient implements IValueGradient {
  14316. /**
  14317. * Gets or sets the gradient value (between 0 and 1)
  14318. */
  14319. gradient: number;
  14320. /**
  14321. * Gets or sets first associated factor
  14322. */
  14323. factor1: number;
  14324. /**
  14325. * Gets or sets second associated factor
  14326. */
  14327. factor2?: number | undefined;
  14328. /**
  14329. * Creates a new factor gradient
  14330. * @param gradient gets or sets the gradient value (between 0 and 1)
  14331. * @param factor1 gets or sets first associated factor
  14332. * @param factor2 gets or sets second associated factor
  14333. */
  14334. constructor(
  14335. /**
  14336. * Gets or sets the gradient value (between 0 and 1)
  14337. */
  14338. gradient: number,
  14339. /**
  14340. * Gets or sets first associated factor
  14341. */
  14342. factor1: number,
  14343. /**
  14344. * Gets or sets second associated factor
  14345. */
  14346. factor2?: number | undefined);
  14347. /**
  14348. * Will get a number picked randomly between factor1 and factor2.
  14349. * If factor2 is undefined then factor1 will be used
  14350. * @returns the picked number
  14351. */
  14352. getFactor(): number;
  14353. }
  14354. /**
  14355. * Helper used to simplify some generic gradient tasks
  14356. */
  14357. export class GradientHelper {
  14358. /**
  14359. * Gets the current gradient from an array of IValueGradient
  14360. * @param ratio defines the current ratio to get
  14361. * @param gradients defines the array of IValueGradient
  14362. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  14363. */
  14364. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  14365. }
  14366. }
  14367. declare module BABYLON {
  14368. interface ThinEngine {
  14369. /**
  14370. * Creates a raw texture
  14371. * @param data defines the data to store in the texture
  14372. * @param width defines the width of the texture
  14373. * @param height defines the height of the texture
  14374. * @param format defines the format of the data
  14375. * @param generateMipMaps defines if the engine should generate the mip levels
  14376. * @param invertY defines if data must be stored with Y axis inverted
  14377. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  14378. * @param compression defines the compression used (null by default)
  14379. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  14380. * @returns the raw texture inside an InternalTexture
  14381. */
  14382. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  14383. /**
  14384. * Update a raw texture
  14385. * @param texture defines the texture to update
  14386. * @param data defines the data to store in the texture
  14387. * @param format defines the format of the data
  14388. * @param invertY defines if data must be stored with Y axis inverted
  14389. */
  14390. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  14391. /**
  14392. * Update a raw texture
  14393. * @param texture defines the texture to update
  14394. * @param data defines the data to store in the texture
  14395. * @param format defines the format of the data
  14396. * @param invertY defines if data must be stored with Y axis inverted
  14397. * @param compression defines the compression used (null by default)
  14398. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  14399. */
  14400. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  14401. /**
  14402. * Creates a new raw cube texture
  14403. * @param data defines the array of data to use to create each face
  14404. * @param size defines the size of the textures
  14405. * @param format defines the format of the data
  14406. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  14407. * @param generateMipMaps defines if the engine should generate the mip levels
  14408. * @param invertY defines if data must be stored with Y axis inverted
  14409. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  14410. * @param compression defines the compression used (null by default)
  14411. * @returns the cube texture as an InternalTexture
  14412. */
  14413. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  14414. /**
  14415. * Update a raw cube texture
  14416. * @param texture defines the texture to udpdate
  14417. * @param data defines the data to store
  14418. * @param format defines the data format
  14419. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  14420. * @param invertY defines if data must be stored with Y axis inverted
  14421. */
  14422. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  14423. /**
  14424. * Update a raw cube texture
  14425. * @param texture defines the texture to udpdate
  14426. * @param data defines the data to store
  14427. * @param format defines the data format
  14428. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  14429. * @param invertY defines if data must be stored with Y axis inverted
  14430. * @param compression defines the compression used (null by default)
  14431. */
  14432. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  14433. /**
  14434. * Update a raw cube texture
  14435. * @param texture defines the texture to udpdate
  14436. * @param data defines the data to store
  14437. * @param format defines the data format
  14438. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  14439. * @param invertY defines if data must be stored with Y axis inverted
  14440. * @param compression defines the compression used (null by default)
  14441. * @param level defines which level of the texture to update
  14442. */
  14443. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  14444. /**
  14445. * Creates a new raw cube texture from a specified url
  14446. * @param url defines the url where the data is located
  14447. * @param scene defines the current scene
  14448. * @param size defines the size of the textures
  14449. * @param format defines the format of the data
  14450. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  14451. * @param noMipmap defines if the engine should avoid generating the mip levels
  14452. * @param callback defines a callback used to extract texture data from loaded data
  14453. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  14454. * @param onLoad defines a callback called when texture is loaded
  14455. * @param onError defines a callback called if there is an error
  14456. * @returns the cube texture as an InternalTexture
  14457. */
  14458. 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;
  14459. /**
  14460. * Creates a new raw cube texture from a specified url
  14461. * @param url defines the url where the data is located
  14462. * @param scene defines the current scene
  14463. * @param size defines the size of the textures
  14464. * @param format defines the format of the data
  14465. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  14466. * @param noMipmap defines if the engine should avoid generating the mip levels
  14467. * @param callback defines a callback used to extract texture data from loaded data
  14468. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  14469. * @param onLoad defines a callback called when texture is loaded
  14470. * @param onError defines a callback called if there is an error
  14471. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  14472. * @param invertY defines if data must be stored with Y axis inverted
  14473. * @returns the cube texture as an InternalTexture
  14474. */
  14475. 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;
  14476. /**
  14477. * Creates a new raw 3D texture
  14478. * @param data defines the data used to create the texture
  14479. * @param width defines the width of the texture
  14480. * @param height defines the height of the texture
  14481. * @param depth defines the depth of the texture
  14482. * @param format defines the format of the texture
  14483. * @param generateMipMaps defines if the engine must generate mip levels
  14484. * @param invertY defines if data must be stored with Y axis inverted
  14485. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  14486. * @param compression defines the compressed used (can be null)
  14487. * @param textureType defines the compressed used (can be null)
  14488. * @returns a new raw 3D texture (stored in an InternalTexture)
  14489. */
  14490. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  14491. /**
  14492. * Update a raw 3D texture
  14493. * @param texture defines the texture to update
  14494. * @param data defines the data to store
  14495. * @param format defines the data format
  14496. * @param invertY defines if data must be stored with Y axis inverted
  14497. */
  14498. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  14499. /**
  14500. * Update a raw 3D texture
  14501. * @param texture defines the texture to update
  14502. * @param data defines the data to store
  14503. * @param format defines the data format
  14504. * @param invertY defines if data must be stored with Y axis inverted
  14505. * @param compression defines the used compression (can be null)
  14506. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  14507. */
  14508. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  14509. /**
  14510. * Creates a new raw 2D array texture
  14511. * @param data defines the data used to create the texture
  14512. * @param width defines the width of the texture
  14513. * @param height defines the height of the texture
  14514. * @param depth defines the number of layers of the texture
  14515. * @param format defines the format of the texture
  14516. * @param generateMipMaps defines if the engine must generate mip levels
  14517. * @param invertY defines if data must be stored with Y axis inverted
  14518. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  14519. * @param compression defines the compressed used (can be null)
  14520. * @param textureType defines the compressed used (can be null)
  14521. * @returns a new raw 2D array texture (stored in an InternalTexture)
  14522. */
  14523. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  14524. /**
  14525. * Update a raw 2D array texture
  14526. * @param texture defines the texture to update
  14527. * @param data defines the data to store
  14528. * @param format defines the data format
  14529. * @param invertY defines if data must be stored with Y axis inverted
  14530. */
  14531. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  14532. /**
  14533. * Update a raw 2D array texture
  14534. * @param texture defines the texture to update
  14535. * @param data defines the data to store
  14536. * @param format defines the data format
  14537. * @param invertY defines if data must be stored with Y axis inverted
  14538. * @param compression defines the used compression (can be null)
  14539. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  14540. */
  14541. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  14542. }
  14543. }
  14544. declare module BABYLON {
  14545. /**
  14546. * Raw texture can help creating a texture directly from an array of data.
  14547. * This can be super useful if you either get the data from an uncompressed source or
  14548. * if you wish to create your texture pixel by pixel.
  14549. */
  14550. export class RawTexture extends Texture {
  14551. /**
  14552. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  14553. */
  14554. format: number;
  14555. /**
  14556. * Instantiates a new RawTexture.
  14557. * Raw texture can help creating a texture directly from an array of data.
  14558. * This can be super useful if you either get the data from an uncompressed source or
  14559. * if you wish to create your texture pixel by pixel.
  14560. * @param data define the array of data to use to create the texture
  14561. * @param width define the width of the texture
  14562. * @param height define the height of the texture
  14563. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  14564. * @param sceneOrEngine defines the scene or engine the texture will belong to
  14565. * @param generateMipMaps define whether mip maps should be generated or not
  14566. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  14567. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  14568. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  14569. */
  14570. constructor(data: ArrayBufferView, width: number, height: number,
  14571. /**
  14572. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  14573. */
  14574. format: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  14575. /**
  14576. * Updates the texture underlying data.
  14577. * @param data Define the new data of the texture
  14578. */
  14579. update(data: ArrayBufferView): void;
  14580. /**
  14581. * Creates a luminance texture from some data.
  14582. * @param data Define the texture data
  14583. * @param width Define the width of the texture
  14584. * @param height Define the height of the texture
  14585. * @param sceneOrEngine defines the scene or engine the texture will belong to
  14586. * @param generateMipMaps Define whether or not to create mip maps for the texture
  14587. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  14588. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  14589. * @returns the luminance texture
  14590. */
  14591. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  14592. /**
  14593. * Creates a luminance alpha texture from some data.
  14594. * @param data Define the texture data
  14595. * @param width Define the width of the texture
  14596. * @param height Define the height of the texture
  14597. * @param sceneOrEngine defines the scene or engine the texture will belong to
  14598. * @param generateMipMaps Define whether or not to create mip maps for the texture
  14599. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  14600. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  14601. * @returns the luminance alpha texture
  14602. */
  14603. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  14604. /**
  14605. * Creates an alpha texture from some data.
  14606. * @param data Define the texture data
  14607. * @param width Define the width of the texture
  14608. * @param height Define the height of the texture
  14609. * @param sceneOrEngine defines the scene or engine the texture will belong to
  14610. * @param generateMipMaps Define whether or not to create mip maps for the texture
  14611. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  14612. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  14613. * @returns the alpha texture
  14614. */
  14615. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  14616. /**
  14617. * Creates a RGB texture from some data.
  14618. * @param data Define the texture data
  14619. * @param width Define the width of the texture
  14620. * @param height Define the height of the texture
  14621. * @param sceneOrEngine defines the scene or engine the texture will belong to
  14622. * @param generateMipMaps Define whether or not to create mip maps for the texture
  14623. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  14624. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  14625. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  14626. * @returns the RGB alpha texture
  14627. */
  14628. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  14629. /**
  14630. * Creates a RGBA texture from some data.
  14631. * @param data Define the texture data
  14632. * @param width Define the width of the texture
  14633. * @param height Define the height of the texture
  14634. * @param sceneOrEngine defines the scene or engine the texture will belong to
  14635. * @param generateMipMaps Define whether or not to create mip maps for the texture
  14636. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  14637. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  14638. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  14639. * @returns the RGBA texture
  14640. */
  14641. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  14642. /**
  14643. * Creates a R texture from some data.
  14644. * @param data Define the texture data
  14645. * @param width Define the width of the texture
  14646. * @param height Define the height of the texture
  14647. * @param sceneOrEngine defines the scene or engine the texture will belong to
  14648. * @param generateMipMaps Define whether or not to create mip maps for the texture
  14649. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  14650. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  14651. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  14652. * @returns the R texture
  14653. */
  14654. static CreateRTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  14655. }
  14656. }
  14657. declare module BABYLON {
  14658. interface ThinEngine {
  14659. /**
  14660. * Update a dynamic index buffer
  14661. * @param indexBuffer defines the target index buffer
  14662. * @param indices defines the data to update
  14663. * @param offset defines the offset in the target index buffer where update should start
  14664. */
  14665. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  14666. /**
  14667. * Updates a dynamic vertex buffer.
  14668. * @param vertexBuffer the vertex buffer to update
  14669. * @param data the data used to update the vertex buffer
  14670. * @param byteOffset the byte offset of the data
  14671. * @param byteLength the byte length of the data
  14672. */
  14673. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  14674. }
  14675. }
  14676. declare module BABYLON {
  14677. interface AbstractScene {
  14678. /**
  14679. * The list of procedural textures added to the scene
  14680. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14681. */
  14682. proceduralTextures: Array<ProceduralTexture>;
  14683. }
  14684. /**
  14685. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  14686. * in a given scene.
  14687. */
  14688. export class ProceduralTextureSceneComponent implements ISceneComponent {
  14689. /**
  14690. * The component name helpfull to identify the component in the list of scene components.
  14691. */
  14692. readonly name: string;
  14693. /**
  14694. * The scene the component belongs to.
  14695. */
  14696. scene: Scene;
  14697. /**
  14698. * Creates a new instance of the component for the given scene
  14699. * @param scene Defines the scene to register the component in
  14700. */
  14701. constructor(scene: Scene);
  14702. /**
  14703. * Registers the component in a given scene
  14704. */
  14705. register(): void;
  14706. /**
  14707. * Rebuilds the elements related to this component in case of
  14708. * context lost for instance.
  14709. */
  14710. rebuild(): void;
  14711. /**
  14712. * Disposes the component and the associated ressources.
  14713. */
  14714. dispose(): void;
  14715. private _beforeClear;
  14716. }
  14717. }
  14718. declare module BABYLON {
  14719. interface ThinEngine {
  14720. /**
  14721. * Creates a new render target cube texture
  14722. * @param size defines the size of the texture
  14723. * @param options defines the options used to create the texture
  14724. * @returns a new render target cube texture stored in an InternalTexture
  14725. */
  14726. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  14727. }
  14728. }
  14729. declare module BABYLON {
  14730. /** @hidden */
  14731. export var proceduralVertexShader: {
  14732. name: string;
  14733. shader: string;
  14734. };
  14735. }
  14736. declare module BABYLON {
  14737. /**
  14738. * 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.
  14739. * This is the base class of any Procedural texture and contains most of the shareable code.
  14740. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14741. */
  14742. export class ProceduralTexture extends Texture {
  14743. /**
  14744. * Define if the texture is enabled or not (disabled texture will not render)
  14745. */
  14746. isEnabled: boolean;
  14747. /**
  14748. * Define if the texture must be cleared before rendering (default is true)
  14749. */
  14750. autoClear: boolean;
  14751. /**
  14752. * Callback called when the texture is generated
  14753. */
  14754. onGenerated: () => void;
  14755. /**
  14756. * Event raised when the texture is generated
  14757. */
  14758. onGeneratedObservable: Observable<ProceduralTexture>;
  14759. /**
  14760. * Event raised before the texture is generated
  14761. */
  14762. onBeforeGenerationObservable: Observable<ProceduralTexture>;
  14763. /**
  14764. * Gets or sets the node material used to create this texture (null if the texture was manually created)
  14765. */
  14766. nodeMaterialSource: Nullable<NodeMaterial>;
  14767. /** @hidden */
  14768. _generateMipMaps: boolean;
  14769. /** @hidden **/
  14770. _effect: Effect;
  14771. /** @hidden */
  14772. _textures: {
  14773. [key: string]: Texture;
  14774. };
  14775. /** @hidden */
  14776. protected _fallbackTexture: Nullable<Texture>;
  14777. private _size;
  14778. private _textureType;
  14779. private _currentRefreshId;
  14780. private _frameId;
  14781. private _refreshRate;
  14782. private _vertexBuffers;
  14783. private _indexBuffer;
  14784. private _uniforms;
  14785. private _samplers;
  14786. private _fragment;
  14787. private _floats;
  14788. private _ints;
  14789. private _floatsArrays;
  14790. private _colors3;
  14791. private _colors4;
  14792. private _vectors2;
  14793. private _vectors3;
  14794. private _matrices;
  14795. private _fallbackTextureUsed;
  14796. private _fullEngine;
  14797. private _cachedDefines;
  14798. private _contentUpdateId;
  14799. private _contentData;
  14800. /**
  14801. * Instantiates a new procedural texture.
  14802. * 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.
  14803. * This is the base class of any Procedural texture and contains most of the shareable code.
  14804. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14805. * @param name Define the name of the texture
  14806. * @param size Define the size of the texture to create
  14807. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  14808. * @param scene Define the scene the texture belongs to
  14809. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  14810. * @param generateMipMaps Define if the texture should creates mip maps or not
  14811. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  14812. * @param textureType The FBO internal texture type
  14813. */
  14814. constructor(name: string, size: RenderTargetTextureSize, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean, textureType?: number);
  14815. /**
  14816. * The effect that is created when initializing the post process.
  14817. * @returns The created effect corresponding the the postprocess.
  14818. */
  14819. getEffect(): Effect;
  14820. /**
  14821. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  14822. * @returns an ArrayBufferView promise (Uint8Array or Float32Array)
  14823. */
  14824. getContent(): Nullable<Promise<ArrayBufferView>>;
  14825. private _createIndexBuffer;
  14826. /** @hidden */
  14827. _rebuild(): void;
  14828. /**
  14829. * Resets the texture in order to recreate its associated resources.
  14830. * This can be called in case of context loss
  14831. */
  14832. reset(): void;
  14833. protected _getDefines(): string;
  14834. /**
  14835. * Is the texture ready to be used ? (rendered at least once)
  14836. * @returns true if ready, otherwise, false.
  14837. */
  14838. isReady(): boolean;
  14839. /**
  14840. * Resets the refresh counter of the texture and start bak from scratch.
  14841. * Could be useful to regenerate the texture if it is setup to render only once.
  14842. */
  14843. resetRefreshCounter(): void;
  14844. /**
  14845. * Set the fragment shader to use in order to render the texture.
  14846. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  14847. */
  14848. setFragment(fragment: any): void;
  14849. /**
  14850. * Define the refresh rate of the texture or the rendering frequency.
  14851. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  14852. */
  14853. get refreshRate(): number;
  14854. set refreshRate(value: number);
  14855. /** @hidden */
  14856. _shouldRender(): boolean;
  14857. /**
  14858. * Get the size the texture is rendering at.
  14859. * @returns the size (on cube texture it is always squared)
  14860. */
  14861. getRenderSize(): RenderTargetTextureSize;
  14862. /**
  14863. * Resize the texture to new value.
  14864. * @param size Define the new size the texture should have
  14865. * @param generateMipMaps Define whether the new texture should create mip maps
  14866. */
  14867. resize(size: number, generateMipMaps: boolean): void;
  14868. private _checkUniform;
  14869. /**
  14870. * Set a texture in the shader program used to render.
  14871. * @param name Define the name of the uniform samplers as defined in the shader
  14872. * @param texture Define the texture to bind to this sampler
  14873. * @return the texture itself allowing "fluent" like uniform updates
  14874. */
  14875. setTexture(name: string, texture: Texture): ProceduralTexture;
  14876. /**
  14877. * Set a float in the shader.
  14878. * @param name Define the name of the uniform as defined in the shader
  14879. * @param value Define the value to give to the uniform
  14880. * @return the texture itself allowing "fluent" like uniform updates
  14881. */
  14882. setFloat(name: string, value: number): ProceduralTexture;
  14883. /**
  14884. * Set a int in the shader.
  14885. * @param name Define the name of the uniform as defined in the shader
  14886. * @param value Define the value to give to the uniform
  14887. * @return the texture itself allowing "fluent" like uniform updates
  14888. */
  14889. setInt(name: string, value: number): ProceduralTexture;
  14890. /**
  14891. * Set an array of floats in the shader.
  14892. * @param name Define the name of the uniform as defined in the shader
  14893. * @param value Define the value to give to the uniform
  14894. * @return the texture itself allowing "fluent" like uniform updates
  14895. */
  14896. setFloats(name: string, value: number[]): ProceduralTexture;
  14897. /**
  14898. * Set a vec3 in the shader from a Color3.
  14899. * @param name Define the name of the uniform as defined in the shader
  14900. * @param value Define the value to give to the uniform
  14901. * @return the texture itself allowing "fluent" like uniform updates
  14902. */
  14903. setColor3(name: string, value: Color3): ProceduralTexture;
  14904. /**
  14905. * Set a vec4 in the shader from a Color4.
  14906. * @param name Define the name of the uniform as defined in the shader
  14907. * @param value Define the value to give to the uniform
  14908. * @return the texture itself allowing "fluent" like uniform updates
  14909. */
  14910. setColor4(name: string, value: Color4): ProceduralTexture;
  14911. /**
  14912. * Set a vec2 in the shader from a Vector2.
  14913. * @param name Define the name of the uniform as defined in the shader
  14914. * @param value Define the value to give to the uniform
  14915. * @return the texture itself allowing "fluent" like uniform updates
  14916. */
  14917. setVector2(name: string, value: Vector2): ProceduralTexture;
  14918. /**
  14919. * Set a vec3 in the shader from a Vector3.
  14920. * @param name Define the name of the uniform as defined in the shader
  14921. * @param value Define the value to give to the uniform
  14922. * @return the texture itself allowing "fluent" like uniform updates
  14923. */
  14924. setVector3(name: string, value: Vector3): ProceduralTexture;
  14925. /**
  14926. * Set a mat4 in the shader from a MAtrix.
  14927. * @param name Define the name of the uniform as defined in the shader
  14928. * @param value Define the value to give to the uniform
  14929. * @return the texture itself allowing "fluent" like uniform updates
  14930. */
  14931. setMatrix(name: string, value: Matrix): ProceduralTexture;
  14932. /**
  14933. * Render the texture to its associated render target.
  14934. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  14935. */
  14936. render(useCameraPostProcess?: boolean): void;
  14937. /**
  14938. * Clone the texture.
  14939. * @returns the cloned texture
  14940. */
  14941. clone(): ProceduralTexture;
  14942. /**
  14943. * Dispose the texture and release its asoociated resources.
  14944. */
  14945. dispose(): void;
  14946. }
  14947. }
  14948. declare module BABYLON {
  14949. /**
  14950. * This represents the base class for particle system in Babylon.
  14951. * 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.
  14952. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  14953. * @example https://doc.babylonjs.com/babylon101/particles
  14954. */
  14955. export class BaseParticleSystem {
  14956. /**
  14957. * Source color is added to the destination color without alpha affecting the result
  14958. */
  14959. static BLENDMODE_ONEONE: number;
  14960. /**
  14961. * Blend current color and particle color using particle’s alpha
  14962. */
  14963. static BLENDMODE_STANDARD: number;
  14964. /**
  14965. * Add current color and particle color multiplied by particle’s alpha
  14966. */
  14967. static BLENDMODE_ADD: number;
  14968. /**
  14969. * Multiply current color with particle color
  14970. */
  14971. static BLENDMODE_MULTIPLY: number;
  14972. /**
  14973. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  14974. */
  14975. static BLENDMODE_MULTIPLYADD: number;
  14976. /**
  14977. * List of animations used by the particle system.
  14978. */
  14979. animations: Animation[];
  14980. /**
  14981. * Gets or sets the unique id of the particle system
  14982. */
  14983. uniqueId: number;
  14984. /**
  14985. * The id of the Particle system.
  14986. */
  14987. id: string;
  14988. /**
  14989. * The friendly name of the Particle system.
  14990. */
  14991. name: string;
  14992. /**
  14993. * Snippet ID if the particle system was created from the snippet server
  14994. */
  14995. snippetId: string;
  14996. /**
  14997. * The rendering group used by the Particle system to chose when to render.
  14998. */
  14999. renderingGroupId: number;
  15000. /**
  15001. * The emitter represents the Mesh or position we are attaching the particle system to.
  15002. */
  15003. emitter: Nullable<AbstractMesh | Vector3>;
  15004. /**
  15005. * The maximum number of particles to emit per frame
  15006. */
  15007. emitRate: number;
  15008. /**
  15009. * If you want to launch only a few particles at once, that can be done, as well.
  15010. */
  15011. manualEmitCount: number;
  15012. /**
  15013. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  15014. */
  15015. updateSpeed: number;
  15016. /**
  15017. * The amount of time the particle system is running (depends of the overall update speed).
  15018. */
  15019. targetStopDuration: number;
  15020. /**
  15021. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  15022. */
  15023. disposeOnStop: boolean;
  15024. /**
  15025. * Minimum power of emitting particles.
  15026. */
  15027. minEmitPower: number;
  15028. /**
  15029. * Maximum power of emitting particles.
  15030. */
  15031. maxEmitPower: number;
  15032. /**
  15033. * Minimum life time of emitting particles.
  15034. */
  15035. minLifeTime: number;
  15036. /**
  15037. * Maximum life time of emitting particles.
  15038. */
  15039. maxLifeTime: number;
  15040. /**
  15041. * Minimum Size of emitting particles.
  15042. */
  15043. minSize: number;
  15044. /**
  15045. * Maximum Size of emitting particles.
  15046. */
  15047. maxSize: number;
  15048. /**
  15049. * Minimum scale of emitting particles on X axis.
  15050. */
  15051. minScaleX: number;
  15052. /**
  15053. * Maximum scale of emitting particles on X axis.
  15054. */
  15055. maxScaleX: number;
  15056. /**
  15057. * Minimum scale of emitting particles on Y axis.
  15058. */
  15059. minScaleY: number;
  15060. /**
  15061. * Maximum scale of emitting particles on Y axis.
  15062. */
  15063. maxScaleY: number;
  15064. /**
  15065. * Gets or sets the minimal initial rotation in radians.
  15066. */
  15067. minInitialRotation: number;
  15068. /**
  15069. * Gets or sets the maximal initial rotation in radians.
  15070. */
  15071. maxInitialRotation: number;
  15072. /**
  15073. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  15074. */
  15075. minAngularSpeed: number;
  15076. /**
  15077. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  15078. */
  15079. maxAngularSpeed: number;
  15080. /**
  15081. * The texture used to render each particle. (this can be a spritesheet)
  15082. */
  15083. particleTexture: Nullable<BaseTexture>;
  15084. /**
  15085. * The layer mask we are rendering the particles through.
  15086. */
  15087. layerMask: number;
  15088. /**
  15089. * This can help using your own shader to render the particle system.
  15090. * The according effect will be created
  15091. */
  15092. customShader: any;
  15093. /**
  15094. * By default particle system starts as soon as they are created. This prevents the
  15095. * automatic start to happen and let you decide when to start emitting particles.
  15096. */
  15097. preventAutoStart: boolean;
  15098. private _noiseTexture;
  15099. /**
  15100. * Gets or sets a texture used to add random noise to particle positions
  15101. */
  15102. get noiseTexture(): Nullable<ProceduralTexture>;
  15103. set noiseTexture(value: Nullable<ProceduralTexture>);
  15104. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  15105. noiseStrength: Vector3;
  15106. /**
  15107. * Callback triggered when the particle animation is ending.
  15108. */
  15109. onAnimationEnd: Nullable<() => void>;
  15110. /**
  15111. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  15112. */
  15113. blendMode: number;
  15114. /**
  15115. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  15116. * to override the particles.
  15117. */
  15118. forceDepthWrite: boolean;
  15119. /** 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 */
  15120. preWarmCycles: number;
  15121. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  15122. preWarmStepOffset: number;
  15123. /**
  15124. * 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)
  15125. */
  15126. spriteCellChangeSpeed: number;
  15127. /**
  15128. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  15129. */
  15130. startSpriteCellID: number;
  15131. /**
  15132. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  15133. */
  15134. endSpriteCellID: number;
  15135. /**
  15136. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  15137. */
  15138. spriteCellWidth: number;
  15139. /**
  15140. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  15141. */
  15142. spriteCellHeight: number;
  15143. /**
  15144. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  15145. */
  15146. spriteRandomStartCell: boolean;
  15147. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  15148. translationPivot: Vector2;
  15149. /** @hidden */
  15150. protected _isAnimationSheetEnabled: boolean;
  15151. /**
  15152. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  15153. */
  15154. beginAnimationOnStart: boolean;
  15155. /**
  15156. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  15157. */
  15158. beginAnimationFrom: number;
  15159. /**
  15160. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  15161. */
  15162. beginAnimationTo: number;
  15163. /**
  15164. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  15165. */
  15166. beginAnimationLoop: boolean;
  15167. /**
  15168. * Gets or sets a world offset applied to all particles
  15169. */
  15170. worldOffset: Vector3;
  15171. /**
  15172. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  15173. */
  15174. get isAnimationSheetEnabled(): boolean;
  15175. set isAnimationSheetEnabled(value: boolean);
  15176. /**
  15177. * Get hosting scene
  15178. * @returns the scene
  15179. */
  15180. getScene(): Nullable<Scene>;
  15181. /**
  15182. * You can use gravity if you want to give an orientation to your particles.
  15183. */
  15184. gravity: Vector3;
  15185. protected _colorGradients: Nullable<Array<ColorGradient>>;
  15186. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  15187. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  15188. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  15189. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  15190. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  15191. protected _dragGradients: Nullable<Array<FactorGradient>>;
  15192. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  15193. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  15194. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  15195. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  15196. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  15197. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  15198. /**
  15199. * Defines the delay in milliseconds before starting the system (0 by default)
  15200. */
  15201. startDelay: number;
  15202. /**
  15203. * Gets the current list of drag gradients.
  15204. * You must use addDragGradient and removeDragGradient to udpate this list
  15205. * @returns the list of drag gradients
  15206. */
  15207. getDragGradients(): Nullable<Array<FactorGradient>>;
  15208. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  15209. limitVelocityDamping: number;
  15210. /**
  15211. * Gets the current list of limit velocity gradients.
  15212. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  15213. * @returns the list of limit velocity gradients
  15214. */
  15215. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  15216. /**
  15217. * Gets the current list of color gradients.
  15218. * You must use addColorGradient and removeColorGradient to udpate this list
  15219. * @returns the list of color gradients
  15220. */
  15221. getColorGradients(): Nullable<Array<ColorGradient>>;
  15222. /**
  15223. * Gets the current list of size gradients.
  15224. * You must use addSizeGradient and removeSizeGradient to udpate this list
  15225. * @returns the list of size gradients
  15226. */
  15227. getSizeGradients(): Nullable<Array<FactorGradient>>;
  15228. /**
  15229. * Gets the current list of color remap gradients.
  15230. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  15231. * @returns the list of color remap gradients
  15232. */
  15233. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  15234. /**
  15235. * Gets the current list of alpha remap gradients.
  15236. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  15237. * @returns the list of alpha remap gradients
  15238. */
  15239. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  15240. /**
  15241. * Gets the current list of life time gradients.
  15242. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  15243. * @returns the list of life time gradients
  15244. */
  15245. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  15246. /**
  15247. * Gets the current list of angular speed gradients.
  15248. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  15249. * @returns the list of angular speed gradients
  15250. */
  15251. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  15252. /**
  15253. * Gets the current list of velocity gradients.
  15254. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  15255. * @returns the list of velocity gradients
  15256. */
  15257. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  15258. /**
  15259. * Gets the current list of start size gradients.
  15260. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  15261. * @returns the list of start size gradients
  15262. */
  15263. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  15264. /**
  15265. * Gets the current list of emit rate gradients.
  15266. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  15267. * @returns the list of emit rate gradients
  15268. */
  15269. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  15270. /**
  15271. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15272. * This only works when particleEmitterTyps is a BoxParticleEmitter
  15273. */
  15274. get direction1(): Vector3;
  15275. set direction1(value: Vector3);
  15276. /**
  15277. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15278. * This only works when particleEmitterTyps is a BoxParticleEmitter
  15279. */
  15280. get direction2(): Vector3;
  15281. set direction2(value: Vector3);
  15282. /**
  15283. * 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.
  15284. * This only works when particleEmitterTyps is a BoxParticleEmitter
  15285. */
  15286. get minEmitBox(): Vector3;
  15287. set minEmitBox(value: Vector3);
  15288. /**
  15289. * 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.
  15290. * This only works when particleEmitterTyps is a BoxParticleEmitter
  15291. */
  15292. get maxEmitBox(): Vector3;
  15293. set maxEmitBox(value: Vector3);
  15294. /**
  15295. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  15296. */
  15297. color1: Color4;
  15298. /**
  15299. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  15300. */
  15301. color2: Color4;
  15302. /**
  15303. * Color the particle will have at the end of its lifetime
  15304. */
  15305. colorDead: Color4;
  15306. /**
  15307. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  15308. */
  15309. textureMask: Color4;
  15310. /**
  15311. * The particle emitter type defines the emitter used by the particle system.
  15312. * It can be for example box, sphere, or cone...
  15313. */
  15314. particleEmitterType: IParticleEmitterType;
  15315. /** @hidden */
  15316. _isSubEmitter: boolean;
  15317. /**
  15318. * Gets or sets the billboard mode to use when isBillboardBased = true.
  15319. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  15320. */
  15321. billboardMode: number;
  15322. protected _isBillboardBased: boolean;
  15323. /**
  15324. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  15325. */
  15326. get isBillboardBased(): boolean;
  15327. set isBillboardBased(value: boolean);
  15328. /**
  15329. * The scene the particle system belongs to.
  15330. */
  15331. protected _scene: Nullable<Scene>;
  15332. /**
  15333. * The engine the particle system belongs to.
  15334. */
  15335. protected _engine: ThinEngine;
  15336. /**
  15337. * Local cache of defines for image processing.
  15338. */
  15339. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  15340. /**
  15341. * Default configuration related to image processing available in the standard Material.
  15342. */
  15343. protected _imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  15344. /**
  15345. * Gets the image processing configuration used either in this material.
  15346. */
  15347. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  15348. /**
  15349. * Sets the Default image processing configuration used either in the this material.
  15350. *
  15351. * If sets to null, the scene one is in use.
  15352. */
  15353. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  15354. /**
  15355. * Attaches a new image processing configuration to the Standard Material.
  15356. * @param configuration
  15357. */
  15358. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  15359. /** @hidden */
  15360. protected _reset(): void;
  15361. /** @hidden */
  15362. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  15363. /**
  15364. * Instantiates a particle system.
  15365. * 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.
  15366. * @param name The name of the particle system
  15367. */
  15368. constructor(name: string);
  15369. /**
  15370. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  15371. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  15372. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  15373. * @returns the emitter
  15374. */
  15375. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  15376. /**
  15377. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  15378. * @param radius The radius of the hemisphere to emit from
  15379. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  15380. * @returns the emitter
  15381. */
  15382. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  15383. /**
  15384. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  15385. * @param radius The radius of the sphere to emit from
  15386. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  15387. * @returns the emitter
  15388. */
  15389. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  15390. /**
  15391. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  15392. * @param radius The radius of the sphere to emit from
  15393. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  15394. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  15395. * @returns the emitter
  15396. */
  15397. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  15398. /**
  15399. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  15400. * @param radius The radius of the emission cylinder
  15401. * @param height The height of the emission cylinder
  15402. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  15403. * @param directionRandomizer How much to randomize the particle direction [0-1]
  15404. * @returns the emitter
  15405. */
  15406. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  15407. /**
  15408. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  15409. * @param radius The radius of the cylinder to emit from
  15410. * @param height The height of the emission cylinder
  15411. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15412. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  15413. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  15414. * @returns the emitter
  15415. */
  15416. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  15417. /**
  15418. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  15419. * @param radius The radius of the cone to emit from
  15420. * @param angle The base angle of the cone
  15421. * @returns the emitter
  15422. */
  15423. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  15424. /**
  15425. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  15426. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  15427. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  15428. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  15429. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  15430. * @returns the emitter
  15431. */
  15432. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  15433. }
  15434. }
  15435. declare module BABYLON {
  15436. /**
  15437. * Type of sub emitter
  15438. */
  15439. export enum SubEmitterType {
  15440. /**
  15441. * Attached to the particle over it's lifetime
  15442. */
  15443. ATTACHED = 0,
  15444. /**
  15445. * Created when the particle dies
  15446. */
  15447. END = 1
  15448. }
  15449. /**
  15450. * Sub emitter class used to emit particles from an existing particle
  15451. */
  15452. export class SubEmitter {
  15453. /**
  15454. * the particle system to be used by the sub emitter
  15455. */
  15456. particleSystem: ParticleSystem;
  15457. /**
  15458. * Type of the submitter (Default: END)
  15459. */
  15460. type: SubEmitterType;
  15461. /**
  15462. * 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)
  15463. * Note: This only is supported when using an emitter of type Mesh
  15464. */
  15465. inheritDirection: boolean;
  15466. /**
  15467. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  15468. */
  15469. inheritedVelocityAmount: number;
  15470. /**
  15471. * Creates a sub emitter
  15472. * @param particleSystem the particle system to be used by the sub emitter
  15473. */
  15474. constructor(
  15475. /**
  15476. * the particle system to be used by the sub emitter
  15477. */
  15478. particleSystem: ParticleSystem);
  15479. /**
  15480. * Clones the sub emitter
  15481. * @returns the cloned sub emitter
  15482. */
  15483. clone(): SubEmitter;
  15484. /**
  15485. * Serialize current object to a JSON object
  15486. * @returns the serialized object
  15487. */
  15488. serialize(): any;
  15489. /** @hidden */
  15490. static _ParseParticleSystem(system: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): ParticleSystem;
  15491. /**
  15492. * Creates a new SubEmitter from a serialized JSON version
  15493. * @param serializationObject defines the JSON object to read from
  15494. * @param sceneOrEngine defines the hosting scene or the hosting engine
  15495. * @param rootUrl defines the rootUrl for data loading
  15496. * @returns a new SubEmitter
  15497. */
  15498. static Parse(serializationObject: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): SubEmitter;
  15499. /** Release associated resources */
  15500. dispose(): void;
  15501. }
  15502. }
  15503. declare module BABYLON {
  15504. /** @hidden */
  15505. export var clipPlaneFragmentDeclaration: {
  15506. name: string;
  15507. shader: string;
  15508. };
  15509. }
  15510. declare module BABYLON {
  15511. /** @hidden */
  15512. export var imageProcessingDeclaration: {
  15513. name: string;
  15514. shader: string;
  15515. };
  15516. }
  15517. declare module BABYLON {
  15518. /** @hidden */
  15519. export var imageProcessingFunctions: {
  15520. name: string;
  15521. shader: string;
  15522. };
  15523. }
  15524. declare module BABYLON {
  15525. /** @hidden */
  15526. export var clipPlaneFragment: {
  15527. name: string;
  15528. shader: string;
  15529. };
  15530. }
  15531. declare module BABYLON {
  15532. /** @hidden */
  15533. export var particlesPixelShader: {
  15534. name: string;
  15535. shader: string;
  15536. };
  15537. }
  15538. declare module BABYLON {
  15539. /** @hidden */
  15540. export var clipPlaneVertexDeclaration: {
  15541. name: string;
  15542. shader: string;
  15543. };
  15544. }
  15545. declare module BABYLON {
  15546. /** @hidden */
  15547. export var clipPlaneVertex: {
  15548. name: string;
  15549. shader: string;
  15550. };
  15551. }
  15552. declare module BABYLON {
  15553. /** @hidden */
  15554. export var particlesVertexShader: {
  15555. name: string;
  15556. shader: string;
  15557. };
  15558. }
  15559. declare module BABYLON {
  15560. /**
  15561. * Interface used to define entities containing multiple clip planes
  15562. */
  15563. export interface IClipPlanesHolder {
  15564. /**
  15565. * Gets or sets the active clipplane 1
  15566. */
  15567. clipPlane: Nullable<Plane>;
  15568. /**
  15569. * Gets or sets the active clipplane 2
  15570. */
  15571. clipPlane2: Nullable<Plane>;
  15572. /**
  15573. * Gets or sets the active clipplane 3
  15574. */
  15575. clipPlane3: Nullable<Plane>;
  15576. /**
  15577. * Gets or sets the active clipplane 4
  15578. */
  15579. clipPlane4: Nullable<Plane>;
  15580. /**
  15581. * Gets or sets the active clipplane 5
  15582. */
  15583. clipPlane5: Nullable<Plane>;
  15584. /**
  15585. * Gets or sets the active clipplane 6
  15586. */
  15587. clipPlane6: Nullable<Plane>;
  15588. }
  15589. }
  15590. declare module BABYLON {
  15591. /**
  15592. * "Static Class" containing a few commonly used helper while dealing with material for rendering purpose.
  15593. *
  15594. * It is complementary with MaterialHelper but provides completely independent functions (for tree shaking sake)
  15595. *
  15596. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  15597. */
  15598. export class ThinMaterialHelper {
  15599. /**
  15600. * Binds the clip plane information from the holder to the effect.
  15601. * @param effect The effect we are binding the data to
  15602. * @param holder The entity containing the clip plane information
  15603. */
  15604. static BindClipPlane(effect: Effect, holder: IClipPlanesHolder): void;
  15605. }
  15606. }
  15607. declare module BABYLON {
  15608. interface ThinEngine {
  15609. /**
  15610. * Sets alpha constants used by some alpha blending modes
  15611. * @param r defines the red component
  15612. * @param g defines the green component
  15613. * @param b defines the blue component
  15614. * @param a defines the alpha component
  15615. */
  15616. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  15617. /**
  15618. * Sets the current alpha mode
  15619. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  15620. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  15621. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  15622. */
  15623. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  15624. /**
  15625. * Gets the current alpha mode
  15626. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  15627. * @returns the current alpha mode
  15628. */
  15629. getAlphaMode(): number;
  15630. /**
  15631. * Sets the current alpha equation
  15632. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  15633. */
  15634. setAlphaEquation(equation: number): void;
  15635. /**
  15636. * Gets the current alpha equation.
  15637. * @returns the current alpha equation
  15638. */
  15639. getAlphaEquation(): number;
  15640. }
  15641. }
  15642. declare module BABYLON {
  15643. /**
  15644. * This represents a particle system in Babylon.
  15645. * 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.
  15646. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  15647. * @example https://doc.babylonjs.com/babylon101/particles
  15648. */
  15649. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  15650. /**
  15651. * Billboard mode will only apply to Y axis
  15652. */
  15653. static readonly BILLBOARDMODE_Y: number;
  15654. /**
  15655. * Billboard mode will apply to all axes
  15656. */
  15657. static readonly BILLBOARDMODE_ALL: number;
  15658. /**
  15659. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  15660. */
  15661. static readonly BILLBOARDMODE_STRETCHED: number;
  15662. /**
  15663. * This function can be defined to provide custom update for active particles.
  15664. * This function will be called instead of regular update (age, position, color, etc.).
  15665. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  15666. */
  15667. updateFunction: (particles: Particle[]) => void;
  15668. private _emitterWorldMatrix;
  15669. /**
  15670. * This function can be defined to specify initial direction for every new particle.
  15671. * It by default use the emitterType defined function
  15672. */
  15673. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  15674. /**
  15675. * This function can be defined to specify initial position for every new particle.
  15676. * It by default use the emitterType defined function
  15677. */
  15678. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  15679. /**
  15680. * @hidden
  15681. */
  15682. _inheritedVelocityOffset: Vector3;
  15683. /**
  15684. * An event triggered when the system is disposed
  15685. */
  15686. onDisposeObservable: Observable<IParticleSystem>;
  15687. /**
  15688. * An event triggered when the system is stopped
  15689. */
  15690. onStoppedObservable: Observable<IParticleSystem>;
  15691. private _onDisposeObserver;
  15692. /**
  15693. * Sets a callback that will be triggered when the system is disposed
  15694. */
  15695. set onDispose(callback: () => void);
  15696. private _particles;
  15697. private _epsilon;
  15698. private _capacity;
  15699. private _stockParticles;
  15700. private _newPartsExcess;
  15701. private _vertexData;
  15702. private _vertexBuffer;
  15703. private _vertexBuffers;
  15704. private _spriteBuffer;
  15705. private _indexBuffer;
  15706. private _effect;
  15707. private _customEffect;
  15708. private _cachedDefines;
  15709. private _scaledColorStep;
  15710. private _colorDiff;
  15711. private _scaledDirection;
  15712. private _scaledGravity;
  15713. private _currentRenderId;
  15714. private _alive;
  15715. private _useInstancing;
  15716. private _vertexArrayObject;
  15717. private _started;
  15718. private _stopped;
  15719. private _actualFrame;
  15720. private _scaledUpdateSpeed;
  15721. private _vertexBufferSize;
  15722. /** @hidden */
  15723. _currentEmitRateGradient: Nullable<FactorGradient>;
  15724. /** @hidden */
  15725. _currentEmitRate1: number;
  15726. /** @hidden */
  15727. _currentEmitRate2: number;
  15728. /** @hidden */
  15729. _currentStartSizeGradient: Nullable<FactorGradient>;
  15730. /** @hidden */
  15731. _currentStartSize1: number;
  15732. /** @hidden */
  15733. _currentStartSize2: number;
  15734. private readonly _rawTextureWidth;
  15735. private _rampGradientsTexture;
  15736. private _useRampGradients;
  15737. /** Gets or sets a matrix to use to compute projection */
  15738. defaultProjectionMatrix: Matrix;
  15739. /** Gets or sets a matrix to use to compute view */
  15740. defaultViewMatrix: Matrix;
  15741. /** Gets or sets a boolean indicating that ramp gradients must be used
  15742. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  15743. */
  15744. get useRampGradients(): boolean;
  15745. set useRampGradients(value: boolean);
  15746. /**
  15747. * 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.
  15748. * 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: [])
  15749. */
  15750. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  15751. private _subEmitters;
  15752. /**
  15753. * @hidden
  15754. * If the particle systems emitter should be disposed when the particle system is disposed
  15755. */
  15756. _disposeEmitterOnDispose: boolean;
  15757. /**
  15758. * The current active Sub-systems, this property is used by the root particle system only.
  15759. */
  15760. activeSubSystems: Array<ParticleSystem>;
  15761. /**
  15762. * Specifies if the particles are updated in emitter local space or world space
  15763. */
  15764. isLocal: boolean;
  15765. private _rootParticleSystem;
  15766. /**
  15767. * Gets the current list of active particles
  15768. */
  15769. get particles(): Particle[];
  15770. /**
  15771. * Gets the number of particles active at the same time.
  15772. * @returns The number of active particles.
  15773. */
  15774. getActiveCount(): number;
  15775. /**
  15776. * Returns the string "ParticleSystem"
  15777. * @returns a string containing the class name
  15778. */
  15779. getClassName(): string;
  15780. /**
  15781. * Gets a boolean indicating that the system is stopping
  15782. * @returns true if the system is currently stopping
  15783. */
  15784. isStopping(): boolean;
  15785. /**
  15786. * Gets the custom effect used to render the particles
  15787. * @param blendMode Blend mode for which the effect should be retrieved
  15788. * @returns The effect
  15789. */
  15790. getCustomEffect(blendMode?: number): Nullable<Effect>;
  15791. /**
  15792. * Sets the custom effect used to render the particles
  15793. * @param effect The effect to set
  15794. * @param blendMode Blend mode for which the effect should be set
  15795. */
  15796. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  15797. /** @hidden */
  15798. private _onBeforeDrawParticlesObservable;
  15799. /**
  15800. * Observable that will be called just before the particles are drawn
  15801. */
  15802. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  15803. /**
  15804. * Gets the name of the particle vertex shader
  15805. */
  15806. get vertexShaderName(): string;
  15807. /**
  15808. * Instantiates a particle system.
  15809. * 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.
  15810. * @param name The name of the particle system
  15811. * @param capacity The max number of particles alive at the same time
  15812. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  15813. * @param customEffect a custom effect used to change the way particles are rendered by default
  15814. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  15815. * @param epsilon Offset used to render the particles
  15816. */
  15817. constructor(name: string, capacity: number, sceneOrEngine: Scene | ThinEngine, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  15818. private _addFactorGradient;
  15819. private _removeFactorGradient;
  15820. /**
  15821. * Adds a new life time gradient
  15822. * @param gradient defines the gradient to use (between 0 and 1)
  15823. * @param factor defines the life time factor to affect to the specified gradient
  15824. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15825. * @returns the current particle system
  15826. */
  15827. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15828. /**
  15829. * Remove a specific life time gradient
  15830. * @param gradient defines the gradient to remove
  15831. * @returns the current particle system
  15832. */
  15833. removeLifeTimeGradient(gradient: number): IParticleSystem;
  15834. /**
  15835. * Adds a new size gradient
  15836. * @param gradient defines the gradient to use (between 0 and 1)
  15837. * @param factor defines the size factor to affect to the specified gradient
  15838. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15839. * @returns the current particle system
  15840. */
  15841. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15842. /**
  15843. * Remove a specific size gradient
  15844. * @param gradient defines the gradient to remove
  15845. * @returns the current particle system
  15846. */
  15847. removeSizeGradient(gradient: number): IParticleSystem;
  15848. /**
  15849. * Adds a new color remap gradient
  15850. * @param gradient defines the gradient to use (between 0 and 1)
  15851. * @param min defines the color remap minimal range
  15852. * @param max defines the color remap maximal range
  15853. * @returns the current particle system
  15854. */
  15855. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  15856. /**
  15857. * Remove a specific color remap gradient
  15858. * @param gradient defines the gradient to remove
  15859. * @returns the current particle system
  15860. */
  15861. removeColorRemapGradient(gradient: number): IParticleSystem;
  15862. /**
  15863. * Adds a new alpha remap gradient
  15864. * @param gradient defines the gradient to use (between 0 and 1)
  15865. * @param min defines the alpha remap minimal range
  15866. * @param max defines the alpha remap maximal range
  15867. * @returns the current particle system
  15868. */
  15869. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  15870. /**
  15871. * Remove a specific alpha remap gradient
  15872. * @param gradient defines the gradient to remove
  15873. * @returns the current particle system
  15874. */
  15875. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  15876. /**
  15877. * Adds a new angular speed gradient
  15878. * @param gradient defines the gradient to use (between 0 and 1)
  15879. * @param factor defines the angular speed to affect to the specified gradient
  15880. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15881. * @returns the current particle system
  15882. */
  15883. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15884. /**
  15885. * Remove a specific angular speed gradient
  15886. * @param gradient defines the gradient to remove
  15887. * @returns the current particle system
  15888. */
  15889. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  15890. /**
  15891. * Adds a new velocity gradient
  15892. * @param gradient defines the gradient to use (between 0 and 1)
  15893. * @param factor defines the velocity to affect to the specified gradient
  15894. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15895. * @returns the current particle system
  15896. */
  15897. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15898. /**
  15899. * Remove a specific velocity gradient
  15900. * @param gradient defines the gradient to remove
  15901. * @returns the current particle system
  15902. */
  15903. removeVelocityGradient(gradient: number): IParticleSystem;
  15904. /**
  15905. * Adds a new limit velocity gradient
  15906. * @param gradient defines the gradient to use (between 0 and 1)
  15907. * @param factor defines the limit velocity value to affect to the specified gradient
  15908. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15909. * @returns the current particle system
  15910. */
  15911. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15912. /**
  15913. * Remove a specific limit velocity gradient
  15914. * @param gradient defines the gradient to remove
  15915. * @returns the current particle system
  15916. */
  15917. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  15918. /**
  15919. * Adds a new drag gradient
  15920. * @param gradient defines the gradient to use (between 0 and 1)
  15921. * @param factor defines the drag value to affect to the specified gradient
  15922. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15923. * @returns the current particle system
  15924. */
  15925. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15926. /**
  15927. * Remove a specific drag gradient
  15928. * @param gradient defines the gradient to remove
  15929. * @returns the current particle system
  15930. */
  15931. removeDragGradient(gradient: number): IParticleSystem;
  15932. /**
  15933. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  15934. * @param gradient defines the gradient to use (between 0 and 1)
  15935. * @param factor defines the emit rate value to affect to the specified gradient
  15936. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15937. * @returns the current particle system
  15938. */
  15939. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15940. /**
  15941. * Remove a specific emit rate gradient
  15942. * @param gradient defines the gradient to remove
  15943. * @returns the current particle system
  15944. */
  15945. removeEmitRateGradient(gradient: number): IParticleSystem;
  15946. /**
  15947. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  15948. * @param gradient defines the gradient to use (between 0 and 1)
  15949. * @param factor defines the start size value to affect to the specified gradient
  15950. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15951. * @returns the current particle system
  15952. */
  15953. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15954. /**
  15955. * Remove a specific start size gradient
  15956. * @param gradient defines the gradient to remove
  15957. * @returns the current particle system
  15958. */
  15959. removeStartSizeGradient(gradient: number): IParticleSystem;
  15960. private _createRampGradientTexture;
  15961. /**
  15962. * Gets the current list of ramp gradients.
  15963. * You must use addRampGradient and removeRampGradient to udpate this list
  15964. * @returns the list of ramp gradients
  15965. */
  15966. getRampGradients(): Nullable<Array<Color3Gradient>>;
  15967. /** Force the system to rebuild all gradients that need to be resync */
  15968. forceRefreshGradients(): void;
  15969. private _syncRampGradientTexture;
  15970. /**
  15971. * Adds a new ramp gradient used to remap particle colors
  15972. * @param gradient defines the gradient to use (between 0 and 1)
  15973. * @param color defines the color to affect to the specified gradient
  15974. * @returns the current particle system
  15975. */
  15976. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  15977. /**
  15978. * Remove a specific ramp gradient
  15979. * @param gradient defines the gradient to remove
  15980. * @returns the current particle system
  15981. */
  15982. removeRampGradient(gradient: number): ParticleSystem;
  15983. /**
  15984. * Adds a new color gradient
  15985. * @param gradient defines the gradient to use (between 0 and 1)
  15986. * @param color1 defines the color to affect to the specified gradient
  15987. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  15988. * @returns this particle system
  15989. */
  15990. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  15991. /**
  15992. * Remove a specific color gradient
  15993. * @param gradient defines the gradient to remove
  15994. * @returns this particle system
  15995. */
  15996. removeColorGradient(gradient: number): IParticleSystem;
  15997. private _fetchR;
  15998. protected _reset(): void;
  15999. private _resetEffect;
  16000. private _createVertexBuffers;
  16001. private _createIndexBuffer;
  16002. /**
  16003. * Gets the maximum number of particles active at the same time.
  16004. * @returns The max number of active particles.
  16005. */
  16006. getCapacity(): number;
  16007. /**
  16008. * Gets whether there are still active particles in the system.
  16009. * @returns True if it is alive, otherwise false.
  16010. */
  16011. isAlive(): boolean;
  16012. /**
  16013. * Gets if the system has been started. (Note: this will still be true after stop is called)
  16014. * @returns True if it has been started, otherwise false.
  16015. */
  16016. isStarted(): boolean;
  16017. private _prepareSubEmitterInternalArray;
  16018. /**
  16019. * Starts the particle system and begins to emit
  16020. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  16021. */
  16022. start(delay?: number): void;
  16023. /**
  16024. * Stops the particle system.
  16025. * @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.
  16026. */
  16027. stop(stopSubEmitters?: boolean): void;
  16028. /**
  16029. * Remove all active particles
  16030. */
  16031. reset(): void;
  16032. /**
  16033. * @hidden (for internal use only)
  16034. */
  16035. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  16036. /**
  16037. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  16038. * Its lifetime will start back at 0.
  16039. */
  16040. recycleParticle: (particle: Particle) => void;
  16041. private _stopSubEmitters;
  16042. private _createParticle;
  16043. private _removeFromRoot;
  16044. private _emitFromParticle;
  16045. private _update;
  16046. /** @hidden */
  16047. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  16048. /** @hidden */
  16049. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  16050. /**
  16051. * Fill the defines array according to the current settings of the particle system
  16052. * @param defines Array to be updated
  16053. * @param blendMode blend mode to take into account when updating the array
  16054. */
  16055. fillDefines(defines: Array<string>, blendMode: number): void;
  16056. /**
  16057. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  16058. * @param uniforms Uniforms array to fill
  16059. * @param attributes Attributes array to fill
  16060. * @param samplers Samplers array to fill
  16061. */
  16062. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  16063. /** @hidden */
  16064. private _getEffect;
  16065. /**
  16066. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  16067. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  16068. */
  16069. animate(preWarmOnly?: boolean): void;
  16070. private _appendParticleVertices;
  16071. /**
  16072. * Rebuilds the particle system.
  16073. */
  16074. rebuild(): void;
  16075. /**
  16076. * Is this system ready to be used/rendered
  16077. * @return true if the system is ready
  16078. */
  16079. isReady(): boolean;
  16080. private _render;
  16081. /**
  16082. * Renders the particle system in its current state.
  16083. * @returns the current number of particles
  16084. */
  16085. render(): number;
  16086. /**
  16087. * Disposes the particle system and free the associated resources
  16088. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  16089. */
  16090. dispose(disposeTexture?: boolean): void;
  16091. /**
  16092. * Clones the particle system.
  16093. * @param name The name of the cloned object
  16094. * @param newEmitter The new emitter to use
  16095. * @returns the cloned particle system
  16096. */
  16097. clone(name: string, newEmitter: any): ParticleSystem;
  16098. /**
  16099. * Serializes the particle system to a JSON object
  16100. * @param serializeTexture defines if the texture must be serialized as well
  16101. * @returns the JSON object
  16102. */
  16103. serialize(serializeTexture?: boolean): any;
  16104. /** @hidden */
  16105. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  16106. /** @hidden */
  16107. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, sceneOrEngine: Scene | ThinEngine, rootUrl: string): void;
  16108. /**
  16109. * Parses a JSON object to create a particle system.
  16110. * @param parsedParticleSystem The JSON object to parse
  16111. * @param sceneOrEngine The scene or the engine to create the particle system in
  16112. * @param rootUrl The root url to use to load external dependencies like texture
  16113. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  16114. * @returns the Parsed particle system
  16115. */
  16116. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  16117. }
  16118. }
  16119. declare module BABYLON {
  16120. /**
  16121. * A particle represents one of the element emitted by a particle system.
  16122. * This is mainly define by its coordinates, direction, velocity and age.
  16123. */
  16124. export class Particle {
  16125. /**
  16126. * The particle system the particle belongs to.
  16127. */
  16128. particleSystem: ParticleSystem;
  16129. private static _Count;
  16130. /**
  16131. * Unique ID of the particle
  16132. */
  16133. id: number;
  16134. /**
  16135. * The world position of the particle in the scene.
  16136. */
  16137. position: Vector3;
  16138. /**
  16139. * The world direction of the particle in the scene.
  16140. */
  16141. direction: Vector3;
  16142. /**
  16143. * The color of the particle.
  16144. */
  16145. color: Color4;
  16146. /**
  16147. * The color change of the particle per step.
  16148. */
  16149. colorStep: Color4;
  16150. /**
  16151. * Defines how long will the life of the particle be.
  16152. */
  16153. lifeTime: number;
  16154. /**
  16155. * The current age of the particle.
  16156. */
  16157. age: number;
  16158. /**
  16159. * The current size of the particle.
  16160. */
  16161. size: number;
  16162. /**
  16163. * The current scale of the particle.
  16164. */
  16165. scale: Vector2;
  16166. /**
  16167. * The current angle of the particle.
  16168. */
  16169. angle: number;
  16170. /**
  16171. * Defines how fast is the angle changing.
  16172. */
  16173. angularSpeed: number;
  16174. /**
  16175. * Defines the cell index used by the particle to be rendered from a sprite.
  16176. */
  16177. cellIndex: number;
  16178. /**
  16179. * The information required to support color remapping
  16180. */
  16181. remapData: Vector4;
  16182. /** @hidden */
  16183. _randomCellOffset?: number;
  16184. /** @hidden */
  16185. _initialDirection: Nullable<Vector3>;
  16186. /** @hidden */
  16187. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  16188. /** @hidden */
  16189. _initialStartSpriteCellID: number;
  16190. /** @hidden */
  16191. _initialEndSpriteCellID: number;
  16192. /** @hidden */
  16193. _currentColorGradient: Nullable<ColorGradient>;
  16194. /** @hidden */
  16195. _currentColor1: Color4;
  16196. /** @hidden */
  16197. _currentColor2: Color4;
  16198. /** @hidden */
  16199. _currentSizeGradient: Nullable<FactorGradient>;
  16200. /** @hidden */
  16201. _currentSize1: number;
  16202. /** @hidden */
  16203. _currentSize2: number;
  16204. /** @hidden */
  16205. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  16206. /** @hidden */
  16207. _currentAngularSpeed1: number;
  16208. /** @hidden */
  16209. _currentAngularSpeed2: number;
  16210. /** @hidden */
  16211. _currentVelocityGradient: Nullable<FactorGradient>;
  16212. /** @hidden */
  16213. _currentVelocity1: number;
  16214. /** @hidden */
  16215. _currentVelocity2: number;
  16216. /** @hidden */
  16217. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  16218. /** @hidden */
  16219. _currentLimitVelocity1: number;
  16220. /** @hidden */
  16221. _currentLimitVelocity2: number;
  16222. /** @hidden */
  16223. _currentDragGradient: Nullable<FactorGradient>;
  16224. /** @hidden */
  16225. _currentDrag1: number;
  16226. /** @hidden */
  16227. _currentDrag2: number;
  16228. /** @hidden */
  16229. _randomNoiseCoordinates1: Vector3;
  16230. /** @hidden */
  16231. _randomNoiseCoordinates2: Vector3;
  16232. /** @hidden */
  16233. _localPosition?: Vector3;
  16234. /**
  16235. * Creates a new instance Particle
  16236. * @param particleSystem the particle system the particle belongs to
  16237. */
  16238. constructor(
  16239. /**
  16240. * The particle system the particle belongs to.
  16241. */
  16242. particleSystem: ParticleSystem);
  16243. private updateCellInfoFromSystem;
  16244. /**
  16245. * Defines how the sprite cell index is updated for the particle
  16246. */
  16247. updateCellIndex(): void;
  16248. /** @hidden */
  16249. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  16250. /** @hidden */
  16251. _inheritParticleInfoToSubEmitters(): void;
  16252. /** @hidden */
  16253. _reset(): void;
  16254. /**
  16255. * Copy the properties of particle to another one.
  16256. * @param other the particle to copy the information to.
  16257. */
  16258. copyTo(other: Particle): void;
  16259. }
  16260. }
  16261. declare module BABYLON {
  16262. /**
  16263. * Particle emitter represents a volume emitting particles.
  16264. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  16265. */
  16266. export interface IParticleEmitterType {
  16267. /**
  16268. * Called by the particle System when the direction is computed for the created particle.
  16269. * @param worldMatrix is the world matrix of the particle system
  16270. * @param directionToUpdate is the direction vector to update with the result
  16271. * @param particle is the particle we are computed the direction for
  16272. * @param isLocal defines if the direction should be set in local space
  16273. */
  16274. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16275. /**
  16276. * Called by the particle System when the position is computed for the created particle.
  16277. * @param worldMatrix is the world matrix of the particle system
  16278. * @param positionToUpdate is the position vector to update with the result
  16279. * @param particle is the particle we are computed the position for
  16280. * @param isLocal defines if the position should be set in local space
  16281. */
  16282. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16283. /**
  16284. * Clones the current emitter and returns a copy of it
  16285. * @returns the new emitter
  16286. */
  16287. clone(): IParticleEmitterType;
  16288. /**
  16289. * Called by the GPUParticleSystem to setup the update shader
  16290. * @param effect defines the update shader
  16291. */
  16292. applyToShader(effect: Effect): void;
  16293. /**
  16294. * Returns a string to use to update the GPU particles update shader
  16295. * @returns the effect defines string
  16296. */
  16297. getEffectDefines(): string;
  16298. /**
  16299. * Returns a string representing the class name
  16300. * @returns a string containing the class name
  16301. */
  16302. getClassName(): string;
  16303. /**
  16304. * Serializes the particle system to a JSON object.
  16305. * @returns the JSON object
  16306. */
  16307. serialize(): any;
  16308. /**
  16309. * Parse properties from a JSON object
  16310. * @param serializationObject defines the JSON object
  16311. * @param scene defines the hosting scene
  16312. */
  16313. parse(serializationObject: any, scene: Nullable<Scene>): void;
  16314. }
  16315. }
  16316. declare module BABYLON {
  16317. /**
  16318. * Particle emitter emitting particles from the inside of a box.
  16319. * It emits the particles randomly between 2 given directions.
  16320. */
  16321. export class BoxParticleEmitter implements IParticleEmitterType {
  16322. /**
  16323. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16324. */
  16325. direction1: Vector3;
  16326. /**
  16327. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16328. */
  16329. direction2: Vector3;
  16330. /**
  16331. * 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.
  16332. */
  16333. minEmitBox: Vector3;
  16334. /**
  16335. * 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.
  16336. */
  16337. maxEmitBox: Vector3;
  16338. /**
  16339. * Creates a new instance BoxParticleEmitter
  16340. */
  16341. constructor();
  16342. /**
  16343. * Called by the particle System when the direction is computed for the created particle.
  16344. * @param worldMatrix is the world matrix of the particle system
  16345. * @param directionToUpdate is the direction vector to update with the result
  16346. * @param particle is the particle we are computed the direction for
  16347. * @param isLocal defines if the direction should be set in local space
  16348. */
  16349. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16350. /**
  16351. * Called by the particle System when the position is computed for the created particle.
  16352. * @param worldMatrix is the world matrix of the particle system
  16353. * @param positionToUpdate is the position vector to update with the result
  16354. * @param particle is the particle we are computed the position for
  16355. * @param isLocal defines if the position should be set in local space
  16356. */
  16357. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16358. /**
  16359. * Clones the current emitter and returns a copy of it
  16360. * @returns the new emitter
  16361. */
  16362. clone(): BoxParticleEmitter;
  16363. /**
  16364. * Called by the GPUParticleSystem to setup the update shader
  16365. * @param effect defines the update shader
  16366. */
  16367. applyToShader(effect: Effect): void;
  16368. /**
  16369. * Returns a string to use to update the GPU particles update shader
  16370. * @returns a string containng the defines string
  16371. */
  16372. getEffectDefines(): string;
  16373. /**
  16374. * Returns the string "BoxParticleEmitter"
  16375. * @returns a string containing the class name
  16376. */
  16377. getClassName(): string;
  16378. /**
  16379. * Serializes the particle system to a JSON object.
  16380. * @returns the JSON object
  16381. */
  16382. serialize(): any;
  16383. /**
  16384. * Parse properties from a JSON object
  16385. * @param serializationObject defines the JSON object
  16386. */
  16387. parse(serializationObject: any): void;
  16388. }
  16389. }
  16390. declare module BABYLON {
  16391. /**
  16392. * Particle emitter emitting particles from the inside of a cone.
  16393. * It emits the particles alongside the cone volume from the base to the particle.
  16394. * The emission direction might be randomized.
  16395. */
  16396. export class ConeParticleEmitter implements IParticleEmitterType {
  16397. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  16398. directionRandomizer: number;
  16399. private _radius;
  16400. private _angle;
  16401. private _height;
  16402. /**
  16403. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  16404. */
  16405. radiusRange: number;
  16406. /**
  16407. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  16408. */
  16409. heightRange: number;
  16410. /**
  16411. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  16412. */
  16413. emitFromSpawnPointOnly: boolean;
  16414. /**
  16415. * Gets or sets the radius of the emission cone
  16416. */
  16417. get radius(): number;
  16418. set radius(value: number);
  16419. /**
  16420. * Gets or sets the angle of the emission cone
  16421. */
  16422. get angle(): number;
  16423. set angle(value: number);
  16424. private _buildHeight;
  16425. /**
  16426. * Creates a new instance ConeParticleEmitter
  16427. * @param radius the radius of the emission cone (1 by default)
  16428. * @param angle the cone base angle (PI by default)
  16429. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  16430. */
  16431. constructor(radius?: number, angle?: number,
  16432. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  16433. directionRandomizer?: number);
  16434. /**
  16435. * Called by the particle System when the direction is computed for the created particle.
  16436. * @param worldMatrix is the world matrix of the particle system
  16437. * @param directionToUpdate is the direction vector to update with the result
  16438. * @param particle is the particle we are computed the direction for
  16439. * @param isLocal defines if the direction should be set in local space
  16440. */
  16441. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16442. /**
  16443. * Called by the particle System when the position is computed for the created particle.
  16444. * @param worldMatrix is the world matrix of the particle system
  16445. * @param positionToUpdate is the position vector to update with the result
  16446. * @param particle is the particle we are computed the position for
  16447. * @param isLocal defines if the position should be set in local space
  16448. */
  16449. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16450. /**
  16451. * Clones the current emitter and returns a copy of it
  16452. * @returns the new emitter
  16453. */
  16454. clone(): ConeParticleEmitter;
  16455. /**
  16456. * Called by the GPUParticleSystem to setup the update shader
  16457. * @param effect defines the update shader
  16458. */
  16459. applyToShader(effect: Effect): void;
  16460. /**
  16461. * Returns a string to use to update the GPU particles update shader
  16462. * @returns a string containng the defines string
  16463. */
  16464. getEffectDefines(): string;
  16465. /**
  16466. * Returns the string "ConeParticleEmitter"
  16467. * @returns a string containing the class name
  16468. */
  16469. getClassName(): string;
  16470. /**
  16471. * Serializes the particle system to a JSON object.
  16472. * @returns the JSON object
  16473. */
  16474. serialize(): any;
  16475. /**
  16476. * Parse properties from a JSON object
  16477. * @param serializationObject defines the JSON object
  16478. */
  16479. parse(serializationObject: any): void;
  16480. }
  16481. }
  16482. declare module BABYLON {
  16483. /**
  16484. * Particle emitter emitting particles from the inside of a cylinder.
  16485. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  16486. */
  16487. export class CylinderParticleEmitter implements IParticleEmitterType {
  16488. /**
  16489. * The radius of the emission cylinder.
  16490. */
  16491. radius: number;
  16492. /**
  16493. * The height of the emission cylinder.
  16494. */
  16495. height: number;
  16496. /**
  16497. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16498. */
  16499. radiusRange: number;
  16500. /**
  16501. * How much to randomize the particle direction [0-1].
  16502. */
  16503. directionRandomizer: number;
  16504. /**
  16505. * Creates a new instance CylinderParticleEmitter
  16506. * @param radius the radius of the emission cylinder (1 by default)
  16507. * @param height the height of the emission cylinder (1 by default)
  16508. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16509. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  16510. */
  16511. constructor(
  16512. /**
  16513. * The radius of the emission cylinder.
  16514. */
  16515. radius?: number,
  16516. /**
  16517. * The height of the emission cylinder.
  16518. */
  16519. height?: number,
  16520. /**
  16521. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16522. */
  16523. radiusRange?: number,
  16524. /**
  16525. * How much to randomize the particle direction [0-1].
  16526. */
  16527. directionRandomizer?: number);
  16528. /**
  16529. * Called by the particle System when the direction is computed for the created particle.
  16530. * @param worldMatrix is the world matrix of the particle system
  16531. * @param directionToUpdate is the direction vector to update with the result
  16532. * @param particle is the particle we are computed the direction for
  16533. * @param isLocal defines if the direction should be set in local space
  16534. */
  16535. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16536. /**
  16537. * Called by the particle System when the position is computed for the created particle.
  16538. * @param worldMatrix is the world matrix of the particle system
  16539. * @param positionToUpdate is the position vector to update with the result
  16540. * @param particle is the particle we are computed the position for
  16541. * @param isLocal defines if the position should be set in local space
  16542. */
  16543. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16544. /**
  16545. * Clones the current emitter and returns a copy of it
  16546. * @returns the new emitter
  16547. */
  16548. clone(): CylinderParticleEmitter;
  16549. /**
  16550. * Called by the GPUParticleSystem to setup the update shader
  16551. * @param effect defines the update shader
  16552. */
  16553. applyToShader(effect: Effect): void;
  16554. /**
  16555. * Returns a string to use to update the GPU particles update shader
  16556. * @returns a string containng the defines string
  16557. */
  16558. getEffectDefines(): string;
  16559. /**
  16560. * Returns the string "CylinderParticleEmitter"
  16561. * @returns a string containing the class name
  16562. */
  16563. getClassName(): string;
  16564. /**
  16565. * Serializes the particle system to a JSON object.
  16566. * @returns the JSON object
  16567. */
  16568. serialize(): any;
  16569. /**
  16570. * Parse properties from a JSON object
  16571. * @param serializationObject defines the JSON object
  16572. */
  16573. parse(serializationObject: any): void;
  16574. }
  16575. /**
  16576. * Particle emitter emitting particles from the inside of a cylinder.
  16577. * It emits the particles randomly between two vectors.
  16578. */
  16579. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  16580. /**
  16581. * The min limit of the emission direction.
  16582. */
  16583. direction1: Vector3;
  16584. /**
  16585. * The max limit of the emission direction.
  16586. */
  16587. direction2: Vector3;
  16588. /**
  16589. * Creates a new instance CylinderDirectedParticleEmitter
  16590. * @param radius the radius of the emission cylinder (1 by default)
  16591. * @param height the height of the emission cylinder (1 by default)
  16592. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16593. * @param direction1 the min limit of the emission direction (up vector by default)
  16594. * @param direction2 the max limit of the emission direction (up vector by default)
  16595. */
  16596. constructor(radius?: number, height?: number, radiusRange?: number,
  16597. /**
  16598. * The min limit of the emission direction.
  16599. */
  16600. direction1?: Vector3,
  16601. /**
  16602. * The max limit of the emission direction.
  16603. */
  16604. direction2?: Vector3);
  16605. /**
  16606. * Called by the particle System when the direction is computed for the created particle.
  16607. * @param worldMatrix is the world matrix of the particle system
  16608. * @param directionToUpdate is the direction vector to update with the result
  16609. * @param particle is the particle we are computed the direction for
  16610. */
  16611. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16612. /**
  16613. * Clones the current emitter and returns a copy of it
  16614. * @returns the new emitter
  16615. */
  16616. clone(): CylinderDirectedParticleEmitter;
  16617. /**
  16618. * Called by the GPUParticleSystem to setup the update shader
  16619. * @param effect defines the update shader
  16620. */
  16621. applyToShader(effect: Effect): void;
  16622. /**
  16623. * Returns a string to use to update the GPU particles update shader
  16624. * @returns a string containng the defines string
  16625. */
  16626. getEffectDefines(): string;
  16627. /**
  16628. * Returns the string "CylinderDirectedParticleEmitter"
  16629. * @returns a string containing the class name
  16630. */
  16631. getClassName(): string;
  16632. /**
  16633. * Serializes the particle system to a JSON object.
  16634. * @returns the JSON object
  16635. */
  16636. serialize(): any;
  16637. /**
  16638. * Parse properties from a JSON object
  16639. * @param serializationObject defines the JSON object
  16640. */
  16641. parse(serializationObject: any): void;
  16642. }
  16643. }
  16644. declare module BABYLON {
  16645. /**
  16646. * Particle emitter emitting particles from the inside of a hemisphere.
  16647. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  16648. */
  16649. export class HemisphericParticleEmitter implements IParticleEmitterType {
  16650. /**
  16651. * The radius of the emission hemisphere.
  16652. */
  16653. radius: number;
  16654. /**
  16655. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16656. */
  16657. radiusRange: number;
  16658. /**
  16659. * How much to randomize the particle direction [0-1].
  16660. */
  16661. directionRandomizer: number;
  16662. /**
  16663. * Creates a new instance HemisphericParticleEmitter
  16664. * @param radius the radius of the emission hemisphere (1 by default)
  16665. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16666. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  16667. */
  16668. constructor(
  16669. /**
  16670. * The radius of the emission hemisphere.
  16671. */
  16672. radius?: number,
  16673. /**
  16674. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16675. */
  16676. radiusRange?: number,
  16677. /**
  16678. * How much to randomize the particle direction [0-1].
  16679. */
  16680. directionRandomizer?: number);
  16681. /**
  16682. * Called by the particle System when the direction is computed for the created particle.
  16683. * @param worldMatrix is the world matrix of the particle system
  16684. * @param directionToUpdate is the direction vector to update with the result
  16685. * @param particle is the particle we are computed the direction for
  16686. * @param isLocal defines if the direction should be set in local space
  16687. */
  16688. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16689. /**
  16690. * Called by the particle System when the position is computed for the created particle.
  16691. * @param worldMatrix is the world matrix of the particle system
  16692. * @param positionToUpdate is the position vector to update with the result
  16693. * @param particle is the particle we are computed the position for
  16694. * @param isLocal defines if the position should be set in local space
  16695. */
  16696. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16697. /**
  16698. * Clones the current emitter and returns a copy of it
  16699. * @returns the new emitter
  16700. */
  16701. clone(): HemisphericParticleEmitter;
  16702. /**
  16703. * Called by the GPUParticleSystem to setup the update shader
  16704. * @param effect defines the update shader
  16705. */
  16706. applyToShader(effect: Effect): void;
  16707. /**
  16708. * Returns a string to use to update the GPU particles update shader
  16709. * @returns a string containng the defines string
  16710. */
  16711. getEffectDefines(): string;
  16712. /**
  16713. * Returns the string "HemisphericParticleEmitter"
  16714. * @returns a string containing the class name
  16715. */
  16716. getClassName(): string;
  16717. /**
  16718. * Serializes the particle system to a JSON object.
  16719. * @returns the JSON object
  16720. */
  16721. serialize(): any;
  16722. /**
  16723. * Parse properties from a JSON object
  16724. * @param serializationObject defines the JSON object
  16725. */
  16726. parse(serializationObject: any): void;
  16727. }
  16728. }
  16729. declare module BABYLON {
  16730. /**
  16731. * Particle emitter emitting particles from a point.
  16732. * It emits the particles randomly between 2 given directions.
  16733. */
  16734. export class PointParticleEmitter implements IParticleEmitterType {
  16735. /**
  16736. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16737. */
  16738. direction1: Vector3;
  16739. /**
  16740. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16741. */
  16742. direction2: Vector3;
  16743. /**
  16744. * Creates a new instance PointParticleEmitter
  16745. */
  16746. constructor();
  16747. /**
  16748. * Called by the particle System when the direction is computed for the created particle.
  16749. * @param worldMatrix is the world matrix of the particle system
  16750. * @param directionToUpdate is the direction vector to update with the result
  16751. * @param particle is the particle we are computed the direction for
  16752. * @param isLocal defines if the direction should be set in local space
  16753. */
  16754. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16755. /**
  16756. * Called by the particle System when the position is computed for the created particle.
  16757. * @param worldMatrix is the world matrix of the particle system
  16758. * @param positionToUpdate is the position vector to update with the result
  16759. * @param particle is the particle we are computed the position for
  16760. * @param isLocal defines if the position should be set in local space
  16761. */
  16762. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16763. /**
  16764. * Clones the current emitter and returns a copy of it
  16765. * @returns the new emitter
  16766. */
  16767. clone(): PointParticleEmitter;
  16768. /**
  16769. * Called by the GPUParticleSystem to setup the update shader
  16770. * @param effect defines the update shader
  16771. */
  16772. applyToShader(effect: Effect): void;
  16773. /**
  16774. * Returns a string to use to update the GPU particles update shader
  16775. * @returns a string containng the defines string
  16776. */
  16777. getEffectDefines(): string;
  16778. /**
  16779. * Returns the string "PointParticleEmitter"
  16780. * @returns a string containing the class name
  16781. */
  16782. getClassName(): string;
  16783. /**
  16784. * Serializes the particle system to a JSON object.
  16785. * @returns the JSON object
  16786. */
  16787. serialize(): any;
  16788. /**
  16789. * Parse properties from a JSON object
  16790. * @param serializationObject defines the JSON object
  16791. */
  16792. parse(serializationObject: any): void;
  16793. }
  16794. }
  16795. declare module BABYLON {
  16796. /**
  16797. * Particle emitter emitting particles from the inside of a sphere.
  16798. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  16799. */
  16800. export class SphereParticleEmitter implements IParticleEmitterType {
  16801. /**
  16802. * The radius of the emission sphere.
  16803. */
  16804. radius: number;
  16805. /**
  16806. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16807. */
  16808. radiusRange: number;
  16809. /**
  16810. * How much to randomize the particle direction [0-1].
  16811. */
  16812. directionRandomizer: number;
  16813. /**
  16814. * Creates a new instance SphereParticleEmitter
  16815. * @param radius the radius of the emission sphere (1 by default)
  16816. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16817. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  16818. */
  16819. constructor(
  16820. /**
  16821. * The radius of the emission sphere.
  16822. */
  16823. radius?: number,
  16824. /**
  16825. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16826. */
  16827. radiusRange?: number,
  16828. /**
  16829. * How much to randomize the particle direction [0-1].
  16830. */
  16831. directionRandomizer?: number);
  16832. /**
  16833. * Called by the particle System when the direction is computed for the created particle.
  16834. * @param worldMatrix is the world matrix of the particle system
  16835. * @param directionToUpdate is the direction vector to update with the result
  16836. * @param particle is the particle we are computed the direction for
  16837. * @param isLocal defines if the direction should be set in local space
  16838. */
  16839. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16840. /**
  16841. * Called by the particle System when the position is computed for the created particle.
  16842. * @param worldMatrix is the world matrix of the particle system
  16843. * @param positionToUpdate is the position vector to update with the result
  16844. * @param particle is the particle we are computed the position for
  16845. * @param isLocal defines if the position should be set in local space
  16846. */
  16847. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16848. /**
  16849. * Clones the current emitter and returns a copy of it
  16850. * @returns the new emitter
  16851. */
  16852. clone(): SphereParticleEmitter;
  16853. /**
  16854. * Called by the GPUParticleSystem to setup the update shader
  16855. * @param effect defines the update shader
  16856. */
  16857. applyToShader(effect: Effect): void;
  16858. /**
  16859. * Returns a string to use to update the GPU particles update shader
  16860. * @returns a string containng the defines string
  16861. */
  16862. getEffectDefines(): string;
  16863. /**
  16864. * Returns the string "SphereParticleEmitter"
  16865. * @returns a string containing the class name
  16866. */
  16867. getClassName(): string;
  16868. /**
  16869. * Serializes the particle system to a JSON object.
  16870. * @returns the JSON object
  16871. */
  16872. serialize(): any;
  16873. /**
  16874. * Parse properties from a JSON object
  16875. * @param serializationObject defines the JSON object
  16876. */
  16877. parse(serializationObject: any): void;
  16878. }
  16879. /**
  16880. * Particle emitter emitting particles from the inside of a sphere.
  16881. * It emits the particles randomly between two vectors.
  16882. */
  16883. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  16884. /**
  16885. * The min limit of the emission direction.
  16886. */
  16887. direction1: Vector3;
  16888. /**
  16889. * The max limit of the emission direction.
  16890. */
  16891. direction2: Vector3;
  16892. /**
  16893. * Creates a new instance SphereDirectedParticleEmitter
  16894. * @param radius the radius of the emission sphere (1 by default)
  16895. * @param direction1 the min limit of the emission direction (up vector by default)
  16896. * @param direction2 the max limit of the emission direction (up vector by default)
  16897. */
  16898. constructor(radius?: number,
  16899. /**
  16900. * The min limit of the emission direction.
  16901. */
  16902. direction1?: Vector3,
  16903. /**
  16904. * The max limit of the emission direction.
  16905. */
  16906. direction2?: Vector3);
  16907. /**
  16908. * Called by the particle System when the direction is computed for the created particle.
  16909. * @param worldMatrix is the world matrix of the particle system
  16910. * @param directionToUpdate is the direction vector to update with the result
  16911. * @param particle is the particle we are computed the direction for
  16912. */
  16913. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16914. /**
  16915. * Clones the current emitter and returns a copy of it
  16916. * @returns the new emitter
  16917. */
  16918. clone(): SphereDirectedParticleEmitter;
  16919. /**
  16920. * Called by the GPUParticleSystem to setup the update shader
  16921. * @param effect defines the update shader
  16922. */
  16923. applyToShader(effect: Effect): void;
  16924. /**
  16925. * Returns a string to use to update the GPU particles update shader
  16926. * @returns a string containng the defines string
  16927. */
  16928. getEffectDefines(): string;
  16929. /**
  16930. * Returns the string "SphereDirectedParticleEmitter"
  16931. * @returns a string containing the class name
  16932. */
  16933. getClassName(): string;
  16934. /**
  16935. * Serializes the particle system to a JSON object.
  16936. * @returns the JSON object
  16937. */
  16938. serialize(): any;
  16939. /**
  16940. * Parse properties from a JSON object
  16941. * @param serializationObject defines the JSON object
  16942. */
  16943. parse(serializationObject: any): void;
  16944. }
  16945. }
  16946. declare module BABYLON {
  16947. /**
  16948. * Particle emitter emitting particles from a custom list of positions.
  16949. */
  16950. export class CustomParticleEmitter implements IParticleEmitterType {
  16951. /**
  16952. * Gets or sets the position generator that will create the inital position of each particle.
  16953. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  16954. */
  16955. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  16956. /**
  16957. * Gets or sets the destination generator that will create the final destination of each particle.
  16958. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  16959. */
  16960. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  16961. /**
  16962. * Creates a new instance CustomParticleEmitter
  16963. */
  16964. constructor();
  16965. /**
  16966. * Called by the particle System when the direction is computed for the created particle.
  16967. * @param worldMatrix is the world matrix of the particle system
  16968. * @param directionToUpdate is the direction vector to update with the result
  16969. * @param particle is the particle we are computed the direction for
  16970. * @param isLocal defines if the direction should be set in local space
  16971. */
  16972. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16973. /**
  16974. * Called by the particle System when the position is computed for the created particle.
  16975. * @param worldMatrix is the world matrix of the particle system
  16976. * @param positionToUpdate is the position vector to update with the result
  16977. * @param particle is the particle we are computed the position for
  16978. * @param isLocal defines if the position should be set in local space
  16979. */
  16980. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16981. /**
  16982. * Clones the current emitter and returns a copy of it
  16983. * @returns the new emitter
  16984. */
  16985. clone(): CustomParticleEmitter;
  16986. /**
  16987. * Called by the GPUParticleSystem to setup the update shader
  16988. * @param effect defines the update shader
  16989. */
  16990. applyToShader(effect: Effect): void;
  16991. /**
  16992. * Returns a string to use to update the GPU particles update shader
  16993. * @returns a string containng the defines string
  16994. */
  16995. getEffectDefines(): string;
  16996. /**
  16997. * Returns the string "PointParticleEmitter"
  16998. * @returns a string containing the class name
  16999. */
  17000. getClassName(): string;
  17001. /**
  17002. * Serializes the particle system to a JSON object.
  17003. * @returns the JSON object
  17004. */
  17005. serialize(): any;
  17006. /**
  17007. * Parse properties from a JSON object
  17008. * @param serializationObject defines the JSON object
  17009. */
  17010. parse(serializationObject: any): void;
  17011. }
  17012. }
  17013. declare module BABYLON {
  17014. /**
  17015. * Particle emitter emitting particles from the inside of a box.
  17016. * It emits the particles randomly between 2 given directions.
  17017. */
  17018. export class MeshParticleEmitter implements IParticleEmitterType {
  17019. private _indices;
  17020. private _positions;
  17021. private _normals;
  17022. private _storedNormal;
  17023. private _mesh;
  17024. /**
  17025. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17026. */
  17027. direction1: Vector3;
  17028. /**
  17029. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17030. */
  17031. direction2: Vector3;
  17032. /**
  17033. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  17034. */
  17035. useMeshNormalsForDirection: boolean;
  17036. /** Defines the mesh to use as source */
  17037. get mesh(): Nullable<AbstractMesh>;
  17038. set mesh(value: Nullable<AbstractMesh>);
  17039. /**
  17040. * Creates a new instance MeshParticleEmitter
  17041. * @param mesh defines the mesh to use as source
  17042. */
  17043. constructor(mesh?: Nullable<AbstractMesh>);
  17044. /**
  17045. * Called by the particle System when the direction is computed for the created particle.
  17046. * @param worldMatrix is the world matrix of the particle system
  17047. * @param directionToUpdate is the direction vector to update with the result
  17048. * @param particle is the particle we are computed the direction for
  17049. * @param isLocal defines if the direction should be set in local space
  17050. */
  17051. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  17052. /**
  17053. * Called by the particle System when the position is computed for the created particle.
  17054. * @param worldMatrix is the world matrix of the particle system
  17055. * @param positionToUpdate is the position vector to update with the result
  17056. * @param particle is the particle we are computed the position for
  17057. * @param isLocal defines if the position should be set in local space
  17058. */
  17059. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  17060. /**
  17061. * Clones the current emitter and returns a copy of it
  17062. * @returns the new emitter
  17063. */
  17064. clone(): MeshParticleEmitter;
  17065. /**
  17066. * Called by the GPUParticleSystem to setup the update shader
  17067. * @param effect defines the update shader
  17068. */
  17069. applyToShader(effect: Effect): void;
  17070. /**
  17071. * Returns a string to use to update the GPU particles update shader
  17072. * @returns a string containng the defines string
  17073. */
  17074. getEffectDefines(): string;
  17075. /**
  17076. * Returns the string "BoxParticleEmitter"
  17077. * @returns a string containing the class name
  17078. */
  17079. getClassName(): string;
  17080. /**
  17081. * Serializes the particle system to a JSON object.
  17082. * @returns the JSON object
  17083. */
  17084. serialize(): any;
  17085. /**
  17086. * Parse properties from a JSON object
  17087. * @param serializationObject defines the JSON object
  17088. * @param scene defines the hosting scene
  17089. */
  17090. parse(serializationObject: any, scene: Nullable<Scene>): void;
  17091. }
  17092. }
  17093. declare module BABYLON {
  17094. /**
  17095. * Interface representing a particle system in Babylon.js.
  17096. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  17097. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  17098. */
  17099. export interface IParticleSystem {
  17100. /**
  17101. * List of animations used by the particle system.
  17102. */
  17103. animations: Animation[];
  17104. /**
  17105. * The id of the Particle system.
  17106. */
  17107. id: string;
  17108. /**
  17109. * The name of the Particle system.
  17110. */
  17111. name: string;
  17112. /**
  17113. * The emitter represents the Mesh or position we are attaching the particle system to.
  17114. */
  17115. emitter: Nullable<AbstractMesh | Vector3>;
  17116. /**
  17117. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  17118. */
  17119. isBillboardBased: boolean;
  17120. /**
  17121. * The rendering group used by the Particle system to chose when to render.
  17122. */
  17123. renderingGroupId: number;
  17124. /**
  17125. * The layer mask we are rendering the particles through.
  17126. */
  17127. layerMask: number;
  17128. /**
  17129. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  17130. */
  17131. updateSpeed: number;
  17132. /**
  17133. * The amount of time the particle system is running (depends of the overall update speed).
  17134. */
  17135. targetStopDuration: number;
  17136. /**
  17137. * The texture used to render each particle. (this can be a spritesheet)
  17138. */
  17139. particleTexture: Nullable<BaseTexture>;
  17140. /**
  17141. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  17142. */
  17143. blendMode: number;
  17144. /**
  17145. * Minimum life time of emitting particles.
  17146. */
  17147. minLifeTime: number;
  17148. /**
  17149. * Maximum life time of emitting particles.
  17150. */
  17151. maxLifeTime: number;
  17152. /**
  17153. * Minimum Size of emitting particles.
  17154. */
  17155. minSize: number;
  17156. /**
  17157. * Maximum Size of emitting particles.
  17158. */
  17159. maxSize: number;
  17160. /**
  17161. * Minimum scale of emitting particles on X axis.
  17162. */
  17163. minScaleX: number;
  17164. /**
  17165. * Maximum scale of emitting particles on X axis.
  17166. */
  17167. maxScaleX: number;
  17168. /**
  17169. * Minimum scale of emitting particles on Y axis.
  17170. */
  17171. minScaleY: number;
  17172. /**
  17173. * Maximum scale of emitting particles on Y axis.
  17174. */
  17175. maxScaleY: number;
  17176. /**
  17177. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  17178. */
  17179. color1: Color4;
  17180. /**
  17181. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  17182. */
  17183. color2: Color4;
  17184. /**
  17185. * Color the particle will have at the end of its lifetime.
  17186. */
  17187. colorDead: Color4;
  17188. /**
  17189. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  17190. */
  17191. emitRate: number;
  17192. /**
  17193. * You can use gravity if you want to give an orientation to your particles.
  17194. */
  17195. gravity: Vector3;
  17196. /**
  17197. * Minimum power of emitting particles.
  17198. */
  17199. minEmitPower: number;
  17200. /**
  17201. * Maximum power of emitting particles.
  17202. */
  17203. maxEmitPower: number;
  17204. /**
  17205. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  17206. */
  17207. minAngularSpeed: number;
  17208. /**
  17209. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  17210. */
  17211. maxAngularSpeed: number;
  17212. /**
  17213. * Gets or sets the minimal initial rotation in radians.
  17214. */
  17215. minInitialRotation: number;
  17216. /**
  17217. * Gets or sets the maximal initial rotation in radians.
  17218. */
  17219. maxInitialRotation: number;
  17220. /**
  17221. * The particle emitter type defines the emitter used by the particle system.
  17222. * It can be for example box, sphere, or cone...
  17223. */
  17224. particleEmitterType: Nullable<IParticleEmitterType>;
  17225. /**
  17226. * Defines the delay in milliseconds before starting the system (0 by default)
  17227. */
  17228. startDelay: number;
  17229. /**
  17230. * 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
  17231. */
  17232. preWarmCycles: number;
  17233. /**
  17234. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  17235. */
  17236. preWarmStepOffset: number;
  17237. /**
  17238. * 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)
  17239. */
  17240. spriteCellChangeSpeed: number;
  17241. /**
  17242. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  17243. */
  17244. startSpriteCellID: number;
  17245. /**
  17246. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  17247. */
  17248. endSpriteCellID: number;
  17249. /**
  17250. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  17251. */
  17252. spriteCellWidth: number;
  17253. /**
  17254. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  17255. */
  17256. spriteCellHeight: number;
  17257. /**
  17258. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  17259. */
  17260. spriteRandomStartCell: boolean;
  17261. /**
  17262. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  17263. */
  17264. isAnimationSheetEnabled: boolean;
  17265. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  17266. translationPivot: Vector2;
  17267. /**
  17268. * Gets or sets a texture used to add random noise to particle positions
  17269. */
  17270. noiseTexture: Nullable<BaseTexture>;
  17271. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  17272. noiseStrength: Vector3;
  17273. /**
  17274. * Gets or sets the billboard mode to use when isBillboardBased = true.
  17275. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  17276. */
  17277. billboardMode: number;
  17278. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  17279. limitVelocityDamping: number;
  17280. /**
  17281. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  17282. */
  17283. beginAnimationOnStart: boolean;
  17284. /**
  17285. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  17286. */
  17287. beginAnimationFrom: number;
  17288. /**
  17289. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  17290. */
  17291. beginAnimationTo: number;
  17292. /**
  17293. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  17294. */
  17295. beginAnimationLoop: boolean;
  17296. /**
  17297. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  17298. */
  17299. disposeOnStop: boolean;
  17300. /**
  17301. * Specifies if the particles are updated in emitter local space or world space
  17302. */
  17303. isLocal: boolean;
  17304. /** Snippet ID if the particle system was created from the snippet server */
  17305. snippetId: string;
  17306. /** Gets or sets a matrix to use to compute projection */
  17307. defaultProjectionMatrix: Matrix;
  17308. /**
  17309. * Gets the maximum number of particles active at the same time.
  17310. * @returns The max number of active particles.
  17311. */
  17312. getCapacity(): number;
  17313. /**
  17314. * Gets the number of particles active at the same time.
  17315. * @returns The number of active particles.
  17316. */
  17317. getActiveCount(): number;
  17318. /**
  17319. * Gets if the system has been started. (Note: this will still be true after stop is called)
  17320. * @returns True if it has been started, otherwise false.
  17321. */
  17322. isStarted(): boolean;
  17323. /**
  17324. * Animates the particle system for this frame.
  17325. */
  17326. animate(): void;
  17327. /**
  17328. * Renders the particle system in its current state.
  17329. * @returns the current number of particles
  17330. */
  17331. render(): number;
  17332. /**
  17333. * Dispose the particle system and frees its associated resources.
  17334. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  17335. */
  17336. dispose(disposeTexture?: boolean): void;
  17337. /**
  17338. * An event triggered when the system is disposed
  17339. */
  17340. onDisposeObservable: Observable<IParticleSystem>;
  17341. /**
  17342. * An event triggered when the system is stopped
  17343. */
  17344. onStoppedObservable: Observable<IParticleSystem>;
  17345. /**
  17346. * Clones the particle system.
  17347. * @param name The name of the cloned object
  17348. * @param newEmitter The new emitter to use
  17349. * @returns the cloned particle system
  17350. */
  17351. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  17352. /**
  17353. * Serializes the particle system to a JSON object
  17354. * @param serializeTexture defines if the texture must be serialized as well
  17355. * @returns the JSON object
  17356. */
  17357. serialize(serializeTexture: boolean): any;
  17358. /**
  17359. * Rebuild the particle system
  17360. */
  17361. rebuild(): void;
  17362. /** Force the system to rebuild all gradients that need to be resync */
  17363. forceRefreshGradients(): void;
  17364. /**
  17365. * Starts the particle system and begins to emit
  17366. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  17367. */
  17368. start(delay?: number): void;
  17369. /**
  17370. * Stops the particle system.
  17371. */
  17372. stop(): void;
  17373. /**
  17374. * Remove all active particles
  17375. */
  17376. reset(): void;
  17377. /**
  17378. * Gets a boolean indicating that the system is stopping
  17379. * @returns true if the system is currently stopping
  17380. */
  17381. isStopping(): boolean;
  17382. /**
  17383. * Is this system ready to be used/rendered
  17384. * @return true if the system is ready
  17385. */
  17386. isReady(): boolean;
  17387. /**
  17388. * Returns the string "ParticleSystem"
  17389. * @returns a string containing the class name
  17390. */
  17391. getClassName(): string;
  17392. /**
  17393. * Gets the custom effect used to render the particles
  17394. * @param blendMode Blend mode for which the effect should be retrieved
  17395. * @returns The effect
  17396. */
  17397. getCustomEffect(blendMode: number): Nullable<Effect>;
  17398. /**
  17399. * Sets the custom effect used to render the particles
  17400. * @param effect The effect to set
  17401. * @param blendMode Blend mode for which the effect should be set
  17402. */
  17403. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  17404. /**
  17405. * Fill the defines array according to the current settings of the particle system
  17406. * @param defines Array to be updated
  17407. * @param blendMode blend mode to take into account when updating the array
  17408. */
  17409. fillDefines(defines: Array<string>, blendMode: number): void;
  17410. /**
  17411. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  17412. * @param uniforms Uniforms array to fill
  17413. * @param attributes Attributes array to fill
  17414. * @param samplers Samplers array to fill
  17415. */
  17416. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  17417. /**
  17418. * Observable that will be called just before the particles are drawn
  17419. */
  17420. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  17421. /**
  17422. * Gets the name of the particle vertex shader
  17423. */
  17424. vertexShaderName: string;
  17425. /**
  17426. * Adds a new color gradient
  17427. * @param gradient defines the gradient to use (between 0 and 1)
  17428. * @param color1 defines the color to affect to the specified gradient
  17429. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  17430. * @returns the current particle system
  17431. */
  17432. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  17433. /**
  17434. * Remove a specific color gradient
  17435. * @param gradient defines the gradient to remove
  17436. * @returns the current particle system
  17437. */
  17438. removeColorGradient(gradient: number): IParticleSystem;
  17439. /**
  17440. * Adds a new size gradient
  17441. * @param gradient defines the gradient to use (between 0 and 1)
  17442. * @param factor defines the size factor to affect to the specified gradient
  17443. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17444. * @returns the current particle system
  17445. */
  17446. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17447. /**
  17448. * Remove a specific size gradient
  17449. * @param gradient defines the gradient to remove
  17450. * @returns the current particle system
  17451. */
  17452. removeSizeGradient(gradient: number): IParticleSystem;
  17453. /**
  17454. * Gets the current list of color gradients.
  17455. * You must use addColorGradient and removeColorGradient to udpate this list
  17456. * @returns the list of color gradients
  17457. */
  17458. getColorGradients(): Nullable<Array<ColorGradient>>;
  17459. /**
  17460. * Gets the current list of size gradients.
  17461. * You must use addSizeGradient and removeSizeGradient to udpate this list
  17462. * @returns the list of size gradients
  17463. */
  17464. getSizeGradients(): Nullable<Array<FactorGradient>>;
  17465. /**
  17466. * Gets the current list of angular speed gradients.
  17467. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  17468. * @returns the list of angular speed gradients
  17469. */
  17470. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  17471. /**
  17472. * Adds a new angular speed gradient
  17473. * @param gradient defines the gradient to use (between 0 and 1)
  17474. * @param factor defines the angular speed to affect to the specified gradient
  17475. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17476. * @returns the current particle system
  17477. */
  17478. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17479. /**
  17480. * Remove a specific angular speed gradient
  17481. * @param gradient defines the gradient to remove
  17482. * @returns the current particle system
  17483. */
  17484. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  17485. /**
  17486. * Gets the current list of velocity gradients.
  17487. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  17488. * @returns the list of velocity gradients
  17489. */
  17490. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  17491. /**
  17492. * Adds a new velocity gradient
  17493. * @param gradient defines the gradient to use (between 0 and 1)
  17494. * @param factor defines the velocity to affect to the specified gradient
  17495. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17496. * @returns the current particle system
  17497. */
  17498. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17499. /**
  17500. * Remove a specific velocity gradient
  17501. * @param gradient defines the gradient to remove
  17502. * @returns the current particle system
  17503. */
  17504. removeVelocityGradient(gradient: number): IParticleSystem;
  17505. /**
  17506. * Gets the current list of limit velocity gradients.
  17507. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  17508. * @returns the list of limit velocity gradients
  17509. */
  17510. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  17511. /**
  17512. * Adds a new limit velocity gradient
  17513. * @param gradient defines the gradient to use (between 0 and 1)
  17514. * @param factor defines the limit velocity to affect to the specified gradient
  17515. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17516. * @returns the current particle system
  17517. */
  17518. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17519. /**
  17520. * Remove a specific limit velocity gradient
  17521. * @param gradient defines the gradient to remove
  17522. * @returns the current particle system
  17523. */
  17524. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  17525. /**
  17526. * Adds a new drag gradient
  17527. * @param gradient defines the gradient to use (between 0 and 1)
  17528. * @param factor defines the drag to affect to the specified gradient
  17529. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17530. * @returns the current particle system
  17531. */
  17532. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17533. /**
  17534. * Remove a specific drag gradient
  17535. * @param gradient defines the gradient to remove
  17536. * @returns the current particle system
  17537. */
  17538. removeDragGradient(gradient: number): IParticleSystem;
  17539. /**
  17540. * Gets the current list of drag gradients.
  17541. * You must use addDragGradient and removeDragGradient to udpate this list
  17542. * @returns the list of drag gradients
  17543. */
  17544. getDragGradients(): Nullable<Array<FactorGradient>>;
  17545. /**
  17546. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  17547. * @param gradient defines the gradient to use (between 0 and 1)
  17548. * @param factor defines the emit rate to affect to the specified gradient
  17549. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17550. * @returns the current particle system
  17551. */
  17552. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17553. /**
  17554. * Remove a specific emit rate gradient
  17555. * @param gradient defines the gradient to remove
  17556. * @returns the current particle system
  17557. */
  17558. removeEmitRateGradient(gradient: number): IParticleSystem;
  17559. /**
  17560. * Gets the current list of emit rate gradients.
  17561. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  17562. * @returns the list of emit rate gradients
  17563. */
  17564. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  17565. /**
  17566. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  17567. * @param gradient defines the gradient to use (between 0 and 1)
  17568. * @param factor defines the start size to affect to the specified gradient
  17569. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17570. * @returns the current particle system
  17571. */
  17572. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17573. /**
  17574. * Remove a specific start size gradient
  17575. * @param gradient defines the gradient to remove
  17576. * @returns the current particle system
  17577. */
  17578. removeStartSizeGradient(gradient: number): IParticleSystem;
  17579. /**
  17580. * Gets the current list of start size gradients.
  17581. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  17582. * @returns the list of start size gradients
  17583. */
  17584. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  17585. /**
  17586. * Adds a new life time gradient
  17587. * @param gradient defines the gradient to use (between 0 and 1)
  17588. * @param factor defines the life time factor to affect to the specified gradient
  17589. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17590. * @returns the current particle system
  17591. */
  17592. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17593. /**
  17594. * Remove a specific life time gradient
  17595. * @param gradient defines the gradient to remove
  17596. * @returns the current particle system
  17597. */
  17598. removeLifeTimeGradient(gradient: number): IParticleSystem;
  17599. /**
  17600. * Gets the current list of life time gradients.
  17601. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  17602. * @returns the list of life time gradients
  17603. */
  17604. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  17605. /**
  17606. * Gets the current list of color gradients.
  17607. * You must use addColorGradient and removeColorGradient to udpate this list
  17608. * @returns the list of color gradients
  17609. */
  17610. getColorGradients(): Nullable<Array<ColorGradient>>;
  17611. /**
  17612. * Adds a new ramp gradient used to remap particle colors
  17613. * @param gradient defines the gradient to use (between 0 and 1)
  17614. * @param color defines the color to affect to the specified gradient
  17615. * @returns the current particle system
  17616. */
  17617. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  17618. /**
  17619. * Gets the current list of ramp gradients.
  17620. * You must use addRampGradient and removeRampGradient to udpate this list
  17621. * @returns the list of ramp gradients
  17622. */
  17623. getRampGradients(): Nullable<Array<Color3Gradient>>;
  17624. /** Gets or sets a boolean indicating that ramp gradients must be used
  17625. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  17626. */
  17627. useRampGradients: boolean;
  17628. /**
  17629. * Adds a new color remap gradient
  17630. * @param gradient defines the gradient to use (between 0 and 1)
  17631. * @param min defines the color remap minimal range
  17632. * @param max defines the color remap maximal range
  17633. * @returns the current particle system
  17634. */
  17635. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17636. /**
  17637. * Gets the current list of color remap gradients.
  17638. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  17639. * @returns the list of color remap gradients
  17640. */
  17641. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  17642. /**
  17643. * Adds a new alpha remap gradient
  17644. * @param gradient defines the gradient to use (between 0 and 1)
  17645. * @param min defines the alpha remap minimal range
  17646. * @param max defines the alpha remap maximal range
  17647. * @returns the current particle system
  17648. */
  17649. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17650. /**
  17651. * Gets the current list of alpha remap gradients.
  17652. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  17653. * @returns the list of alpha remap gradients
  17654. */
  17655. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  17656. /**
  17657. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  17658. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17659. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17660. * @returns the emitter
  17661. */
  17662. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  17663. /**
  17664. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  17665. * @param radius The radius of the hemisphere to emit from
  17666. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17667. * @returns the emitter
  17668. */
  17669. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  17670. /**
  17671. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  17672. * @param radius The radius of the sphere to emit from
  17673. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17674. * @returns the emitter
  17675. */
  17676. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  17677. /**
  17678. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  17679. * @param radius The radius of the sphere to emit from
  17680. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  17681. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  17682. * @returns the emitter
  17683. */
  17684. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  17685. /**
  17686. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  17687. * @param radius The radius of the emission cylinder
  17688. * @param height The height of the emission cylinder
  17689. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  17690. * @param directionRandomizer How much to randomize the particle direction [0-1]
  17691. * @returns the emitter
  17692. */
  17693. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  17694. /**
  17695. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  17696. * @param radius The radius of the cylinder to emit from
  17697. * @param height The height of the emission cylinder
  17698. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17699. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  17700. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  17701. * @returns the emitter
  17702. */
  17703. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  17704. /**
  17705. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  17706. * @param radius The radius of the cone to emit from
  17707. * @param angle The base angle of the cone
  17708. * @returns the emitter
  17709. */
  17710. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  17711. /**
  17712. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  17713. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17714. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17715. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17716. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17717. * @returns the emitter
  17718. */
  17719. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  17720. /**
  17721. * Get hosting scene
  17722. * @returns the scene
  17723. */
  17724. getScene(): Nullable<Scene>;
  17725. }
  17726. }
  17727. declare module BABYLON {
  17728. /**
  17729. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  17730. */
  17731. export class ColorSplitterBlock extends NodeMaterialBlock {
  17732. /**
  17733. * Create a new ColorSplitterBlock
  17734. * @param name defines the block name
  17735. */
  17736. constructor(name: string);
  17737. /**
  17738. * Gets the current class name
  17739. * @returns the class name
  17740. */
  17741. getClassName(): string;
  17742. /**
  17743. * Gets the rgba component (input)
  17744. */
  17745. get rgba(): NodeMaterialConnectionPoint;
  17746. /**
  17747. * Gets the rgb component (input)
  17748. */
  17749. get rgbIn(): NodeMaterialConnectionPoint;
  17750. /**
  17751. * Gets the rgb component (output)
  17752. */
  17753. get rgbOut(): NodeMaterialConnectionPoint;
  17754. /**
  17755. * Gets the r component (output)
  17756. */
  17757. get r(): NodeMaterialConnectionPoint;
  17758. /**
  17759. * Gets the g component (output)
  17760. */
  17761. get g(): NodeMaterialConnectionPoint;
  17762. /**
  17763. * Gets the b component (output)
  17764. */
  17765. get b(): NodeMaterialConnectionPoint;
  17766. /**
  17767. * Gets the a component (output)
  17768. */
  17769. get a(): NodeMaterialConnectionPoint;
  17770. protected _inputRename(name: string): string;
  17771. protected _outputRename(name: string): string;
  17772. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  17773. }
  17774. }
  17775. declare module BABYLON {
  17776. /**
  17777. * Operations supported by the Trigonometry block
  17778. */
  17779. export enum TrigonometryBlockOperations {
  17780. /** Cos */
  17781. Cos = 0,
  17782. /** Sin */
  17783. Sin = 1,
  17784. /** Abs */
  17785. Abs = 2,
  17786. /** Exp */
  17787. Exp = 3,
  17788. /** Exp2 */
  17789. Exp2 = 4,
  17790. /** Round */
  17791. Round = 5,
  17792. /** Floor */
  17793. Floor = 6,
  17794. /** Ceiling */
  17795. Ceiling = 7,
  17796. /** Square root */
  17797. Sqrt = 8,
  17798. /** Log */
  17799. Log = 9,
  17800. /** Tangent */
  17801. Tan = 10,
  17802. /** Arc tangent */
  17803. ArcTan = 11,
  17804. /** Arc cosinus */
  17805. ArcCos = 12,
  17806. /** Arc sinus */
  17807. ArcSin = 13,
  17808. /** Fraction */
  17809. Fract = 14,
  17810. /** Sign */
  17811. Sign = 15,
  17812. /** To radians (from degrees) */
  17813. Radians = 16,
  17814. /** To degrees (from radians) */
  17815. Degrees = 17
  17816. }
  17817. /**
  17818. * Block used to apply trigonometry operation to floats
  17819. */
  17820. export class TrigonometryBlock extends NodeMaterialBlock {
  17821. /**
  17822. * Gets or sets the operation applied by the block
  17823. */
  17824. operation: TrigonometryBlockOperations;
  17825. /**
  17826. * Creates a new TrigonometryBlock
  17827. * @param name defines the block name
  17828. */
  17829. constructor(name: string);
  17830. /**
  17831. * Gets the current class name
  17832. * @returns the class name
  17833. */
  17834. getClassName(): string;
  17835. /**
  17836. * Gets the input component
  17837. */
  17838. get input(): NodeMaterialConnectionPoint;
  17839. /**
  17840. * Gets the output component
  17841. */
  17842. get output(): NodeMaterialConnectionPoint;
  17843. protected _buildBlock(state: NodeMaterialBuildState): this;
  17844. serialize(): any;
  17845. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  17846. protected _dumpPropertiesCode(): string;
  17847. }
  17848. }
  17849. declare module BABYLON {
  17850. /**
  17851. * Interface used to configure the node material editor
  17852. */
  17853. export interface INodeMaterialEditorOptions {
  17854. /** Define the URl to load node editor script */
  17855. editorURL?: string;
  17856. }
  17857. /** @hidden */
  17858. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  17859. NORMAL: boolean;
  17860. TANGENT: boolean;
  17861. UV1: boolean;
  17862. /** BONES */
  17863. NUM_BONE_INFLUENCERS: number;
  17864. BonesPerMesh: number;
  17865. BONETEXTURE: boolean;
  17866. /** MORPH TARGETS */
  17867. MORPHTARGETS: boolean;
  17868. MORPHTARGETS_NORMAL: boolean;
  17869. MORPHTARGETS_TANGENT: boolean;
  17870. MORPHTARGETS_UV: boolean;
  17871. NUM_MORPH_INFLUENCERS: number;
  17872. /** IMAGE PROCESSING */
  17873. IMAGEPROCESSING: boolean;
  17874. VIGNETTE: boolean;
  17875. VIGNETTEBLENDMODEMULTIPLY: boolean;
  17876. VIGNETTEBLENDMODEOPAQUE: boolean;
  17877. TONEMAPPING: boolean;
  17878. TONEMAPPING_ACES: boolean;
  17879. CONTRAST: boolean;
  17880. EXPOSURE: boolean;
  17881. COLORCURVES: boolean;
  17882. COLORGRADING: boolean;
  17883. COLORGRADING3D: boolean;
  17884. SAMPLER3DGREENDEPTH: boolean;
  17885. SAMPLER3DBGRMAP: boolean;
  17886. IMAGEPROCESSINGPOSTPROCESS: boolean;
  17887. /** MISC. */
  17888. BUMPDIRECTUV: number;
  17889. constructor();
  17890. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  17891. }
  17892. /**
  17893. * Class used to configure NodeMaterial
  17894. */
  17895. export interface INodeMaterialOptions {
  17896. /**
  17897. * Defines if blocks should emit comments
  17898. */
  17899. emitComments: boolean;
  17900. }
  17901. /**
  17902. * Class used to create a node based material built by assembling shader blocks
  17903. */
  17904. export class NodeMaterial extends PushMaterial {
  17905. private static _BuildIdGenerator;
  17906. private _options;
  17907. private _vertexCompilationState;
  17908. private _fragmentCompilationState;
  17909. private _sharedData;
  17910. private _buildId;
  17911. private _buildWasSuccessful;
  17912. private _cachedWorldViewMatrix;
  17913. private _cachedWorldViewProjectionMatrix;
  17914. private _optimizers;
  17915. private _animationFrame;
  17916. /** Define the Url to load node editor script */
  17917. static EditorURL: string;
  17918. /** Define the Url to load snippets */
  17919. static SnippetUrl: string;
  17920. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  17921. static IgnoreTexturesAtLoadTime: boolean;
  17922. private BJSNODEMATERIALEDITOR;
  17923. /** Get the inspector from bundle or global */
  17924. private _getGlobalNodeMaterialEditor;
  17925. /**
  17926. * Snippet ID if the material was created from the snippet server
  17927. */
  17928. snippetId: string;
  17929. /**
  17930. * Gets or sets data used by visual editor
  17931. * @see https://nme.babylonjs.com
  17932. */
  17933. editorData: any;
  17934. /**
  17935. * 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)
  17936. */
  17937. ignoreAlpha: boolean;
  17938. /**
  17939. * Defines the maximum number of lights that can be used in the material
  17940. */
  17941. maxSimultaneousLights: number;
  17942. /**
  17943. * Observable raised when the material is built
  17944. */
  17945. onBuildObservable: Observable<NodeMaterial>;
  17946. /**
  17947. * Gets or sets the root nodes of the material vertex shader
  17948. */
  17949. _vertexOutputNodes: NodeMaterialBlock[];
  17950. /**
  17951. * Gets or sets the root nodes of the material fragment (pixel) shader
  17952. */
  17953. _fragmentOutputNodes: NodeMaterialBlock[];
  17954. /** Gets or sets options to control the node material overall behavior */
  17955. get options(): INodeMaterialOptions;
  17956. set options(options: INodeMaterialOptions);
  17957. /**
  17958. * Default configuration related to image processing available in the standard Material.
  17959. */
  17960. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  17961. /**
  17962. * Gets the image processing configuration used either in this material.
  17963. */
  17964. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  17965. /**
  17966. * Sets the Default image processing configuration used either in the this material.
  17967. *
  17968. * If sets to null, the scene one is in use.
  17969. */
  17970. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  17971. /**
  17972. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  17973. */
  17974. attachedBlocks: NodeMaterialBlock[];
  17975. /**
  17976. * Specifies the mode of the node material
  17977. * @hidden
  17978. */
  17979. _mode: NodeMaterialModes;
  17980. /**
  17981. * Gets the mode property
  17982. */
  17983. get mode(): NodeMaterialModes;
  17984. /**
  17985. * A free comment about the material
  17986. */
  17987. comment: string;
  17988. /**
  17989. * Create a new node based material
  17990. * @param name defines the material name
  17991. * @param scene defines the hosting scene
  17992. * @param options defines creation option
  17993. */
  17994. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  17995. /**
  17996. * Gets the current class name of the material e.g. "NodeMaterial"
  17997. * @returns the class name
  17998. */
  17999. getClassName(): string;
  18000. /**
  18001. * Keep track of the image processing observer to allow dispose and replace.
  18002. */
  18003. private _imageProcessingObserver;
  18004. /**
  18005. * Attaches a new image processing configuration to the Standard Material.
  18006. * @param configuration
  18007. */
  18008. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  18009. /**
  18010. * Get a block by its name
  18011. * @param name defines the name of the block to retrieve
  18012. * @returns the required block or null if not found
  18013. */
  18014. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  18015. /**
  18016. * Get a block by its name
  18017. * @param predicate defines the predicate used to find the good candidate
  18018. * @returns the required block or null if not found
  18019. */
  18020. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  18021. /**
  18022. * Get an input block by its name
  18023. * @param predicate defines the predicate used to find the good candidate
  18024. * @returns the required input block or null if not found
  18025. */
  18026. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  18027. /**
  18028. * Gets the list of input blocks attached to this material
  18029. * @returns an array of InputBlocks
  18030. */
  18031. getInputBlocks(): InputBlock[];
  18032. /**
  18033. * Adds a new optimizer to the list of optimizers
  18034. * @param optimizer defines the optimizers to add
  18035. * @returns the current material
  18036. */
  18037. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  18038. /**
  18039. * Remove an optimizer from the list of optimizers
  18040. * @param optimizer defines the optimizers to remove
  18041. * @returns the current material
  18042. */
  18043. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  18044. /**
  18045. * Add a new block to the list of output nodes
  18046. * @param node defines the node to add
  18047. * @returns the current material
  18048. */
  18049. addOutputNode(node: NodeMaterialBlock): this;
  18050. /**
  18051. * Remove a block from the list of root nodes
  18052. * @param node defines the node to remove
  18053. * @returns the current material
  18054. */
  18055. removeOutputNode(node: NodeMaterialBlock): this;
  18056. private _addVertexOutputNode;
  18057. private _removeVertexOutputNode;
  18058. private _addFragmentOutputNode;
  18059. private _removeFragmentOutputNode;
  18060. /**
  18061. * Specifies if the material will require alpha blending
  18062. * @returns a boolean specifying if alpha blending is needed
  18063. */
  18064. needAlphaBlending(): boolean;
  18065. /**
  18066. * Specifies if this material should be rendered in alpha test mode
  18067. * @returns a boolean specifying if an alpha test is needed.
  18068. */
  18069. needAlphaTesting(): boolean;
  18070. private _initializeBlock;
  18071. private _resetDualBlocks;
  18072. /**
  18073. * Remove a block from the current node material
  18074. * @param block defines the block to remove
  18075. */
  18076. removeBlock(block: NodeMaterialBlock): void;
  18077. /**
  18078. * Build the material and generates the inner effect
  18079. * @param verbose defines if the build should log activity
  18080. */
  18081. build(verbose?: boolean): void;
  18082. /**
  18083. * Runs an otpimization phase to try to improve the shader code
  18084. */
  18085. optimize(): void;
  18086. private _prepareDefinesForAttributes;
  18087. /**
  18088. * Create a post process from the material
  18089. * @param camera The camera to apply the render pass to.
  18090. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  18091. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  18092. * @param engine The engine which the post process will be applied. (default: current engine)
  18093. * @param reusable If the post process can be reused on the same frame. (default: false)
  18094. * @param textureType Type of textures used when performing the post process. (default: 0)
  18095. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  18096. * @returns the post process created
  18097. */
  18098. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): Nullable<PostProcess>;
  18099. /**
  18100. * Create the post process effect from the material
  18101. * @param postProcess The post process to create the effect for
  18102. */
  18103. createEffectForPostProcess(postProcess: PostProcess): void;
  18104. private _createEffectForPostProcess;
  18105. /**
  18106. * Create a new procedural texture based on this node material
  18107. * @param size defines the size of the texture
  18108. * @param scene defines the hosting scene
  18109. * @returns the new procedural texture attached to this node material
  18110. */
  18111. createProceduralTexture(size: number | {
  18112. width: number;
  18113. height: number;
  18114. layers?: number;
  18115. }, scene: Scene): Nullable<ProceduralTexture>;
  18116. private _createEffectForParticles;
  18117. private _checkInternals;
  18118. /**
  18119. * Create the effect to be used as the custom effect for a particle system
  18120. * @param particleSystem Particle system to create the effect for
  18121. * @param onCompiled defines a function to call when the effect creation is successful
  18122. * @param onError defines a function to call when the effect creation has failed
  18123. */
  18124. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  18125. private _processDefines;
  18126. /**
  18127. * Get if the submesh is ready to be used and all its information available.
  18128. * Child classes can use it to update shaders
  18129. * @param mesh defines the mesh to check
  18130. * @param subMesh defines which submesh to check
  18131. * @param useInstances specifies that instances should be used
  18132. * @returns a boolean indicating that the submesh is ready or not
  18133. */
  18134. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  18135. /**
  18136. * Get a string representing the shaders built by the current node graph
  18137. */
  18138. get compiledShaders(): string;
  18139. /**
  18140. * Binds the world matrix to the material
  18141. * @param world defines the world transformation matrix
  18142. */
  18143. bindOnlyWorldMatrix(world: Matrix): void;
  18144. /**
  18145. * Binds the submesh to this material by preparing the effect and shader to draw
  18146. * @param world defines the world transformation matrix
  18147. * @param mesh defines the mesh containing the submesh
  18148. * @param subMesh defines the submesh to bind the material to
  18149. */
  18150. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  18151. /**
  18152. * Gets the active textures from the material
  18153. * @returns an array of textures
  18154. */
  18155. getActiveTextures(): BaseTexture[];
  18156. /**
  18157. * Gets the list of texture blocks
  18158. * @returns an array of texture blocks
  18159. */
  18160. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  18161. /**
  18162. * Specifies if the material uses a texture
  18163. * @param texture defines the texture to check against the material
  18164. * @returns a boolean specifying if the material uses the texture
  18165. */
  18166. hasTexture(texture: BaseTexture): boolean;
  18167. /**
  18168. * Disposes the material
  18169. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  18170. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  18171. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  18172. */
  18173. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  18174. /** Creates the node editor window. */
  18175. private _createNodeEditor;
  18176. /**
  18177. * Launch the node material editor
  18178. * @param config Define the configuration of the editor
  18179. * @return a promise fulfilled when the node editor is visible
  18180. */
  18181. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  18182. /**
  18183. * Clear the current material
  18184. */
  18185. clear(): void;
  18186. /**
  18187. * Clear the current material and set it to a default state
  18188. */
  18189. setToDefault(): void;
  18190. /**
  18191. * Clear the current material and set it to a default state for post process
  18192. */
  18193. setToDefaultPostProcess(): void;
  18194. /**
  18195. * Clear the current material and set it to a default state for procedural texture
  18196. */
  18197. setToDefaultProceduralTexture(): void;
  18198. /**
  18199. * Clear the current material and set it to a default state for particle
  18200. */
  18201. setToDefaultParticle(): void;
  18202. /**
  18203. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  18204. * @param url defines the url to load from
  18205. * @returns a promise that will fullfil when the material is fully loaded
  18206. */
  18207. loadAsync(url: string): Promise<void>;
  18208. private _gatherBlocks;
  18209. /**
  18210. * Generate a string containing the code declaration required to create an equivalent of this material
  18211. * @returns a string
  18212. */
  18213. generateCode(): string;
  18214. /**
  18215. * Serializes this material in a JSON representation
  18216. * @returns the serialized material object
  18217. */
  18218. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  18219. private _restoreConnections;
  18220. /**
  18221. * Clear the current graph and load a new one from a serialization object
  18222. * @param source defines the JSON representation of the material
  18223. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  18224. * @param merge defines whether or not the source must be merged or replace the current content
  18225. */
  18226. loadFromSerialization(source: any, rootUrl?: string, merge?: boolean): void;
  18227. /**
  18228. * Makes a duplicate of the current material.
  18229. * @param name - name to use for the new material.
  18230. */
  18231. clone(name: string): NodeMaterial;
  18232. /**
  18233. * Creates a node material from parsed material data
  18234. * @param source defines the JSON representation of the material
  18235. * @param scene defines the hosting scene
  18236. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  18237. * @returns a new node material
  18238. */
  18239. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  18240. /**
  18241. * Creates a node material from a snippet saved in a remote file
  18242. * @param name defines the name of the material to create
  18243. * @param url defines the url to load from
  18244. * @param scene defines the hosting scene
  18245. * @returns a promise that will resolve to the new node material
  18246. */
  18247. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  18248. /**
  18249. * Creates a node material from a snippet saved by the node material editor
  18250. * @param snippetId defines the snippet to load
  18251. * @param scene defines the hosting scene
  18252. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  18253. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  18254. * @returns a promise that will resolve to the new node material
  18255. */
  18256. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  18257. /**
  18258. * Creates a new node material set to default basic configuration
  18259. * @param name defines the name of the material
  18260. * @param scene defines the hosting scene
  18261. * @returns a new NodeMaterial
  18262. */
  18263. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  18264. }
  18265. }
  18266. declare module BABYLON {
  18267. interface ThinEngine {
  18268. /**
  18269. * Unbind a list of render target textures from the webGL context
  18270. * This is used only when drawBuffer extension or webGL2 are active
  18271. * @param textures defines the render target textures to unbind
  18272. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  18273. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  18274. */
  18275. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  18276. /**
  18277. * Create a multi render target texture
  18278. * @see https://doc.babylonjs.com/features/webgl2#multiple-render-target
  18279. * @param size defines the size of the texture
  18280. * @param options defines the creation options
  18281. * @returns the cube texture as an InternalTexture
  18282. */
  18283. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  18284. /**
  18285. * Update the sample count for a given multiple render target texture
  18286. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  18287. * @param textures defines the textures to update
  18288. * @param samples defines the sample count to set
  18289. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  18290. */
  18291. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  18292. /**
  18293. * Select a subsets of attachments to draw to.
  18294. * @param attachments gl attachments
  18295. */
  18296. bindAttachments(attachments: number[]): void;
  18297. /**
  18298. * Creates a layout object to draw/clear on specific textures in a MRT
  18299. * @param textureStatus textureStatus[i] indicates if the i-th is active
  18300. * @returns A layout to be fed to the engine, calling `bindAttachments`.
  18301. */
  18302. buildTextureLayout(textureStatus: boolean[]): number[];
  18303. /**
  18304. * Restores the webgl state to only draw on the main color attachment
  18305. */
  18306. restoreSingleAttachment(): void;
  18307. /**
  18308. * Clears a list of attachments
  18309. * @param attachments list of the attachments
  18310. * @param colorMain clear color for the main attachment (the first one)
  18311. * @param colorOthers clear color for the other attachments
  18312. * @param clearDepth true to clear the depth buffer. Used only for the first attachment
  18313. * @param clearStencil true to clear the stencil buffer. Used only for the first attachment
  18314. */
  18315. clearAttachments(attachments: number[], colorMain: Nullable<IColor4Like>, colorOthers: Nullable<IColor4Like>, clearDepth: boolean, clearStencil: boolean): void;
  18316. }
  18317. }
  18318. declare module BABYLON {
  18319. /**
  18320. * Creation options of the multi render target texture.
  18321. */
  18322. export interface IMultiRenderTargetOptions {
  18323. /**
  18324. * Define if the texture needs to create mip maps after render.
  18325. */
  18326. generateMipMaps?: boolean;
  18327. /**
  18328. * Define the types of all the draw buffers we want to create
  18329. */
  18330. types?: number[];
  18331. /**
  18332. * Define the sampling modes of all the draw buffers we want to create
  18333. */
  18334. samplingModes?: number[];
  18335. /**
  18336. * Define if a depth buffer is required
  18337. */
  18338. generateDepthBuffer?: boolean;
  18339. /**
  18340. * Define if a stencil buffer is required
  18341. */
  18342. generateStencilBuffer?: boolean;
  18343. /**
  18344. * Define if a depth texture is required instead of a depth buffer
  18345. */
  18346. generateDepthTexture?: boolean;
  18347. /**
  18348. * Define the number of desired draw buffers
  18349. */
  18350. textureCount?: number;
  18351. /**
  18352. * Define if aspect ratio should be adapted to the texture or stay the scene one
  18353. */
  18354. doNotChangeAspectRatio?: boolean;
  18355. /**
  18356. * Define the default type of the buffers we are creating
  18357. */
  18358. defaultType?: number;
  18359. }
  18360. /**
  18361. * A multi render target, like a render target provides the ability to render to a texture.
  18362. * Unlike the render target, it can render to several draw buffers in one draw.
  18363. * This is specially interesting in deferred rendering or for any effects requiring more than
  18364. * just one color from a single pass.
  18365. */
  18366. export class MultiRenderTarget extends RenderTargetTexture {
  18367. private _internalTextures;
  18368. private _textures;
  18369. private _multiRenderTargetOptions;
  18370. private _count;
  18371. /**
  18372. * Get if draw buffers are currently supported by the used hardware and browser.
  18373. */
  18374. get isSupported(): boolean;
  18375. /**
  18376. * Get the list of textures generated by the multi render target.
  18377. */
  18378. get textures(): Texture[];
  18379. /**
  18380. * Gets the number of textures in this MRT. This number can be different from `_textures.length` in case a depth texture is generated.
  18381. */
  18382. get count(): number;
  18383. /**
  18384. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  18385. */
  18386. get depthTexture(): Texture;
  18387. /**
  18388. * Set the wrapping mode on U of all the textures we are rendering to.
  18389. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  18390. */
  18391. set wrapU(wrap: number);
  18392. /**
  18393. * Set the wrapping mode on V of all the textures we are rendering to.
  18394. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  18395. */
  18396. set wrapV(wrap: number);
  18397. /**
  18398. * Instantiate a new multi render target texture.
  18399. * A multi render target, like a render target provides the ability to render to a texture.
  18400. * Unlike the render target, it can render to several draw buffers in one draw.
  18401. * This is specially interesting in deferred rendering or for any effects requiring more than
  18402. * just one color from a single pass.
  18403. * @param name Define the name of the texture
  18404. * @param size Define the size of the buffers to render to
  18405. * @param count Define the number of target we are rendering into
  18406. * @param scene Define the scene the texture belongs to
  18407. * @param options Define the options used to create the multi render target
  18408. */
  18409. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  18410. private _initTypes;
  18411. /** @hidden */
  18412. _rebuild(forceFullRebuild?: boolean): void;
  18413. private _createInternalTextures;
  18414. private _createTextures;
  18415. /**
  18416. * Replaces a texture within the MRT.
  18417. * @param texture The new texture to insert in the MRT
  18418. * @param index The index of the texture to replace
  18419. */
  18420. replaceTexture(texture: Texture, index: number): void;
  18421. /**
  18422. * Define the number of samples used if MSAA is enabled.
  18423. */
  18424. get samples(): number;
  18425. set samples(value: number);
  18426. /**
  18427. * Resize all the textures in the multi render target.
  18428. * Be careful as it will recreate all the data in the new texture.
  18429. * @param size Define the new size
  18430. */
  18431. resize(size: any): void;
  18432. /**
  18433. * Changes the number of render targets in this MRT
  18434. * Be careful as it will recreate all the data in the new texture.
  18435. * @param count new texture count
  18436. * @param options Specifies texture types and sampling modes for new textures
  18437. */
  18438. updateCount(count: number, options?: IMultiRenderTargetOptions): void;
  18439. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  18440. /**
  18441. * Dispose the render targets and their associated resources
  18442. */
  18443. dispose(): void;
  18444. /**
  18445. * Release all the underlying texture used as draw buffers.
  18446. */
  18447. releaseInternalTextures(): void;
  18448. }
  18449. }
  18450. declare module BABYLON {
  18451. /** @hidden */
  18452. export var imageProcessingPixelShader: {
  18453. name: string;
  18454. shader: string;
  18455. };
  18456. }
  18457. declare module BABYLON {
  18458. /**
  18459. * ImageProcessingPostProcess
  18460. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  18461. */
  18462. export class ImageProcessingPostProcess extends PostProcess {
  18463. /**
  18464. * Default configuration related to image processing available in the PBR Material.
  18465. */
  18466. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  18467. /**
  18468. * Gets the image processing configuration used either in this material.
  18469. */
  18470. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  18471. /**
  18472. * Sets the Default image processing configuration used either in the this material.
  18473. *
  18474. * If sets to null, the scene one is in use.
  18475. */
  18476. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  18477. /**
  18478. * Keep track of the image processing observer to allow dispose and replace.
  18479. */
  18480. private _imageProcessingObserver;
  18481. /**
  18482. * Attaches a new image processing configuration to the PBR Material.
  18483. * @param configuration
  18484. */
  18485. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  18486. /**
  18487. * If the post process is supported.
  18488. */
  18489. get isSupported(): boolean;
  18490. /**
  18491. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  18492. */
  18493. get colorCurves(): Nullable<ColorCurves>;
  18494. /**
  18495. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  18496. */
  18497. set colorCurves(value: Nullable<ColorCurves>);
  18498. /**
  18499. * Gets wether the color curves effect is enabled.
  18500. */
  18501. get colorCurvesEnabled(): boolean;
  18502. /**
  18503. * Sets wether the color curves effect is enabled.
  18504. */
  18505. set colorCurvesEnabled(value: boolean);
  18506. /**
  18507. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  18508. */
  18509. get colorGradingTexture(): Nullable<BaseTexture>;
  18510. /**
  18511. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  18512. */
  18513. set colorGradingTexture(value: Nullable<BaseTexture>);
  18514. /**
  18515. * Gets wether the color grading effect is enabled.
  18516. */
  18517. get colorGradingEnabled(): boolean;
  18518. /**
  18519. * Gets wether the color grading effect is enabled.
  18520. */
  18521. set colorGradingEnabled(value: boolean);
  18522. /**
  18523. * Gets exposure used in the effect.
  18524. */
  18525. get exposure(): number;
  18526. /**
  18527. * Sets exposure used in the effect.
  18528. */
  18529. set exposure(value: number);
  18530. /**
  18531. * Gets wether tonemapping is enabled or not.
  18532. */
  18533. get toneMappingEnabled(): boolean;
  18534. /**
  18535. * Sets wether tonemapping is enabled or not
  18536. */
  18537. set toneMappingEnabled(value: boolean);
  18538. /**
  18539. * Gets the type of tone mapping effect.
  18540. */
  18541. get toneMappingType(): number;
  18542. /**
  18543. * Sets the type of tone mapping effect.
  18544. */
  18545. set toneMappingType(value: number);
  18546. /**
  18547. * Gets contrast used in the effect.
  18548. */
  18549. get contrast(): number;
  18550. /**
  18551. * Sets contrast used in the effect.
  18552. */
  18553. set contrast(value: number);
  18554. /**
  18555. * Gets Vignette stretch size.
  18556. */
  18557. get vignetteStretch(): number;
  18558. /**
  18559. * Sets Vignette stretch size.
  18560. */
  18561. set vignetteStretch(value: number);
  18562. /**
  18563. * Gets Vignette centre X Offset.
  18564. */
  18565. get vignetteCentreX(): number;
  18566. /**
  18567. * Sets Vignette centre X Offset.
  18568. */
  18569. set vignetteCentreX(value: number);
  18570. /**
  18571. * Gets Vignette centre Y Offset.
  18572. */
  18573. get vignetteCentreY(): number;
  18574. /**
  18575. * Sets Vignette centre Y Offset.
  18576. */
  18577. set vignetteCentreY(value: number);
  18578. /**
  18579. * Gets Vignette weight or intensity of the vignette effect.
  18580. */
  18581. get vignetteWeight(): number;
  18582. /**
  18583. * Sets Vignette weight or intensity of the vignette effect.
  18584. */
  18585. set vignetteWeight(value: number);
  18586. /**
  18587. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  18588. * if vignetteEnabled is set to true.
  18589. */
  18590. get vignetteColor(): Color4;
  18591. /**
  18592. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  18593. * if vignetteEnabled is set to true.
  18594. */
  18595. set vignetteColor(value: Color4);
  18596. /**
  18597. * Gets Camera field of view used by the Vignette effect.
  18598. */
  18599. get vignetteCameraFov(): number;
  18600. /**
  18601. * Sets Camera field of view used by the Vignette effect.
  18602. */
  18603. set vignetteCameraFov(value: number);
  18604. /**
  18605. * Gets the vignette blend mode allowing different kind of effect.
  18606. */
  18607. get vignetteBlendMode(): number;
  18608. /**
  18609. * Sets the vignette blend mode allowing different kind of effect.
  18610. */
  18611. set vignetteBlendMode(value: number);
  18612. /**
  18613. * Gets wether the vignette effect is enabled.
  18614. */
  18615. get vignetteEnabled(): boolean;
  18616. /**
  18617. * Sets wether the vignette effect is enabled.
  18618. */
  18619. set vignetteEnabled(value: boolean);
  18620. private _fromLinearSpace;
  18621. /**
  18622. * Gets wether the input of the processing is in Gamma or Linear Space.
  18623. */
  18624. get fromLinearSpace(): boolean;
  18625. /**
  18626. * Sets wether the input of the processing is in Gamma or Linear Space.
  18627. */
  18628. set fromLinearSpace(value: boolean);
  18629. /**
  18630. * Defines cache preventing GC.
  18631. */
  18632. private _defines;
  18633. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  18634. /**
  18635. * "ImageProcessingPostProcess"
  18636. * @returns "ImageProcessingPostProcess"
  18637. */
  18638. getClassName(): string;
  18639. /**
  18640. * @hidden
  18641. */
  18642. _updateParameters(): void;
  18643. dispose(camera?: Camera): void;
  18644. }
  18645. }
  18646. declare module BABYLON {
  18647. /**
  18648. * Interface for defining prepass effects in the prepass post-process pipeline
  18649. */
  18650. export interface PrePassEffectConfiguration {
  18651. /**
  18652. * Name of the effect
  18653. */
  18654. name: string;
  18655. /**
  18656. * Post process to attach for this effect
  18657. */
  18658. postProcess?: PostProcess;
  18659. /**
  18660. * Textures required in the MRT
  18661. */
  18662. texturesRequired: number[];
  18663. /**
  18664. * Is the effect enabled
  18665. */
  18666. enabled: boolean;
  18667. /**
  18668. * Disposes the effect configuration
  18669. */
  18670. dispose?: () => void;
  18671. /**
  18672. * Creates the associated post process
  18673. */
  18674. createPostProcess?: () => PostProcess;
  18675. }
  18676. }
  18677. declare module BABYLON {
  18678. /**
  18679. * Options to be used when creating a FresnelParameters.
  18680. */
  18681. export type IFresnelParametersCreationOptions = {
  18682. /**
  18683. * Define the color used on edges (grazing angle)
  18684. */
  18685. leftColor?: Color3;
  18686. /**
  18687. * Define the color used on center
  18688. */
  18689. rightColor?: Color3;
  18690. /**
  18691. * Define bias applied to computed fresnel term
  18692. */
  18693. bias?: number;
  18694. /**
  18695. * Defined the power exponent applied to fresnel term
  18696. */
  18697. power?: number;
  18698. /**
  18699. * Define if the fresnel effect is enable or not.
  18700. */
  18701. isEnabled?: boolean;
  18702. };
  18703. /**
  18704. * Serialized format for FresnelParameters.
  18705. */
  18706. export type IFresnelParametersSerialized = {
  18707. /**
  18708. * Define the color used on edges (grazing angle) [as an array]
  18709. */
  18710. leftColor: number[];
  18711. /**
  18712. * Define the color used on center [as an array]
  18713. */
  18714. rightColor: number[];
  18715. /**
  18716. * Define bias applied to computed fresnel term
  18717. */
  18718. bias: number;
  18719. /**
  18720. * Defined the power exponent applied to fresnel term
  18721. */
  18722. power?: number;
  18723. /**
  18724. * Define if the fresnel effect is enable or not.
  18725. */
  18726. isEnabled: boolean;
  18727. };
  18728. /**
  18729. * This represents all the required information to add a fresnel effect on a material:
  18730. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  18731. */
  18732. export class FresnelParameters {
  18733. private _isEnabled;
  18734. /**
  18735. * Define if the fresnel effect is enable or not.
  18736. */
  18737. get isEnabled(): boolean;
  18738. set isEnabled(value: boolean);
  18739. /**
  18740. * Define the color used on edges (grazing angle)
  18741. */
  18742. leftColor: Color3;
  18743. /**
  18744. * Define the color used on center
  18745. */
  18746. rightColor: Color3;
  18747. /**
  18748. * Define bias applied to computed fresnel term
  18749. */
  18750. bias: number;
  18751. /**
  18752. * Defined the power exponent applied to fresnel term
  18753. */
  18754. power: number;
  18755. /**
  18756. * Creates a new FresnelParameters object.
  18757. *
  18758. * @param options provide your own settings to optionally to override defaults
  18759. */
  18760. constructor(options?: IFresnelParametersCreationOptions);
  18761. /**
  18762. * Clones the current fresnel and its valuues
  18763. * @returns a clone fresnel configuration
  18764. */
  18765. clone(): FresnelParameters;
  18766. /**
  18767. * Determines equality between FresnelParameters objects
  18768. * @param otherFresnelParameters defines the second operand
  18769. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  18770. */
  18771. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  18772. /**
  18773. * Serializes the current fresnel parameters to a JSON representation.
  18774. * @return the JSON serialization
  18775. */
  18776. serialize(): IFresnelParametersSerialized;
  18777. /**
  18778. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  18779. * @param parsedFresnelParameters Define the JSON representation
  18780. * @returns the parsed parameters
  18781. */
  18782. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  18783. }
  18784. }
  18785. declare module BABYLON {
  18786. /**
  18787. * This groups all the flags used to control the materials channel.
  18788. */
  18789. export class MaterialFlags {
  18790. private static _DiffuseTextureEnabled;
  18791. /**
  18792. * Are diffuse textures enabled in the application.
  18793. */
  18794. static get DiffuseTextureEnabled(): boolean;
  18795. static set DiffuseTextureEnabled(value: boolean);
  18796. private static _DetailTextureEnabled;
  18797. /**
  18798. * Are detail textures enabled in the application.
  18799. */
  18800. static get DetailTextureEnabled(): boolean;
  18801. static set DetailTextureEnabled(value: boolean);
  18802. private static _AmbientTextureEnabled;
  18803. /**
  18804. * Are ambient textures enabled in the application.
  18805. */
  18806. static get AmbientTextureEnabled(): boolean;
  18807. static set AmbientTextureEnabled(value: boolean);
  18808. private static _OpacityTextureEnabled;
  18809. /**
  18810. * Are opacity textures enabled in the application.
  18811. */
  18812. static get OpacityTextureEnabled(): boolean;
  18813. static set OpacityTextureEnabled(value: boolean);
  18814. private static _ReflectionTextureEnabled;
  18815. /**
  18816. * Are reflection textures enabled in the application.
  18817. */
  18818. static get ReflectionTextureEnabled(): boolean;
  18819. static set ReflectionTextureEnabled(value: boolean);
  18820. private static _EmissiveTextureEnabled;
  18821. /**
  18822. * Are emissive textures enabled in the application.
  18823. */
  18824. static get EmissiveTextureEnabled(): boolean;
  18825. static set EmissiveTextureEnabled(value: boolean);
  18826. private static _SpecularTextureEnabled;
  18827. /**
  18828. * Are specular textures enabled in the application.
  18829. */
  18830. static get SpecularTextureEnabled(): boolean;
  18831. static set SpecularTextureEnabled(value: boolean);
  18832. private static _BumpTextureEnabled;
  18833. /**
  18834. * Are bump textures enabled in the application.
  18835. */
  18836. static get BumpTextureEnabled(): boolean;
  18837. static set BumpTextureEnabled(value: boolean);
  18838. private static _LightmapTextureEnabled;
  18839. /**
  18840. * Are lightmap textures enabled in the application.
  18841. */
  18842. static get LightmapTextureEnabled(): boolean;
  18843. static set LightmapTextureEnabled(value: boolean);
  18844. private static _RefractionTextureEnabled;
  18845. /**
  18846. * Are refraction textures enabled in the application.
  18847. */
  18848. static get RefractionTextureEnabled(): boolean;
  18849. static set RefractionTextureEnabled(value: boolean);
  18850. private static _ColorGradingTextureEnabled;
  18851. /**
  18852. * Are color grading textures enabled in the application.
  18853. */
  18854. static get ColorGradingTextureEnabled(): boolean;
  18855. static set ColorGradingTextureEnabled(value: boolean);
  18856. private static _FresnelEnabled;
  18857. /**
  18858. * Are fresnels enabled in the application.
  18859. */
  18860. static get FresnelEnabled(): boolean;
  18861. static set FresnelEnabled(value: boolean);
  18862. private static _ClearCoatTextureEnabled;
  18863. /**
  18864. * Are clear coat textures enabled in the application.
  18865. */
  18866. static get ClearCoatTextureEnabled(): boolean;
  18867. static set ClearCoatTextureEnabled(value: boolean);
  18868. private static _ClearCoatBumpTextureEnabled;
  18869. /**
  18870. * Are clear coat bump textures enabled in the application.
  18871. */
  18872. static get ClearCoatBumpTextureEnabled(): boolean;
  18873. static set ClearCoatBumpTextureEnabled(value: boolean);
  18874. private static _ClearCoatTintTextureEnabled;
  18875. /**
  18876. * Are clear coat tint textures enabled in the application.
  18877. */
  18878. static get ClearCoatTintTextureEnabled(): boolean;
  18879. static set ClearCoatTintTextureEnabled(value: boolean);
  18880. private static _SheenTextureEnabled;
  18881. /**
  18882. * Are sheen textures enabled in the application.
  18883. */
  18884. static get SheenTextureEnabled(): boolean;
  18885. static set SheenTextureEnabled(value: boolean);
  18886. private static _AnisotropicTextureEnabled;
  18887. /**
  18888. * Are anisotropic textures enabled in the application.
  18889. */
  18890. static get AnisotropicTextureEnabled(): boolean;
  18891. static set AnisotropicTextureEnabled(value: boolean);
  18892. private static _ThicknessTextureEnabled;
  18893. /**
  18894. * Are thickness textures enabled in the application.
  18895. */
  18896. static get ThicknessTextureEnabled(): boolean;
  18897. static set ThicknessTextureEnabled(value: boolean);
  18898. }
  18899. }
  18900. declare module BABYLON {
  18901. /** @hidden */
  18902. export var defaultFragmentDeclaration: {
  18903. name: string;
  18904. shader: string;
  18905. };
  18906. }
  18907. declare module BABYLON {
  18908. /** @hidden */
  18909. export var sceneUboDeclaration: {
  18910. name: string;
  18911. shader: string;
  18912. };
  18913. }
  18914. declare module BABYLON {
  18915. /** @hidden */
  18916. export var meshUboDeclaration: {
  18917. name: string;
  18918. shader: string;
  18919. };
  18920. }
  18921. declare module BABYLON {
  18922. /** @hidden */
  18923. export var defaultUboDeclaration: {
  18924. name: string;
  18925. shader: string;
  18926. };
  18927. }
  18928. declare module BABYLON {
  18929. /** @hidden */
  18930. export var prePassDeclaration: {
  18931. name: string;
  18932. shader: string;
  18933. };
  18934. }
  18935. declare module BABYLON {
  18936. /** @hidden */
  18937. export var lightFragmentDeclaration: {
  18938. name: string;
  18939. shader: string;
  18940. };
  18941. }
  18942. declare module BABYLON {
  18943. /** @hidden */
  18944. export var lightUboDeclaration: {
  18945. name: string;
  18946. shader: string;
  18947. };
  18948. }
  18949. declare module BABYLON {
  18950. /** @hidden */
  18951. export var lightsFragmentFunctions: {
  18952. name: string;
  18953. shader: string;
  18954. };
  18955. }
  18956. declare module BABYLON {
  18957. /** @hidden */
  18958. export var shadowsFragmentFunctions: {
  18959. name: string;
  18960. shader: string;
  18961. };
  18962. }
  18963. declare module BABYLON {
  18964. /** @hidden */
  18965. export var fresnelFunction: {
  18966. name: string;
  18967. shader: string;
  18968. };
  18969. }
  18970. declare module BABYLON {
  18971. /** @hidden */
  18972. export var bumpFragmentMainFunctions: {
  18973. name: string;
  18974. shader: string;
  18975. };
  18976. }
  18977. declare module BABYLON {
  18978. /** @hidden */
  18979. export var bumpFragmentFunctions: {
  18980. name: string;
  18981. shader: string;
  18982. };
  18983. }
  18984. declare module BABYLON {
  18985. /** @hidden */
  18986. export var logDepthDeclaration: {
  18987. name: string;
  18988. shader: string;
  18989. };
  18990. }
  18991. declare module BABYLON {
  18992. /** @hidden */
  18993. export var fogFragmentDeclaration: {
  18994. name: string;
  18995. shader: string;
  18996. };
  18997. }
  18998. declare module BABYLON {
  18999. /** @hidden */
  19000. export var bumpFragment: {
  19001. name: string;
  19002. shader: string;
  19003. };
  19004. }
  19005. declare module BABYLON {
  19006. /** @hidden */
  19007. export var depthPrePass: {
  19008. name: string;
  19009. shader: string;
  19010. };
  19011. }
  19012. declare module BABYLON {
  19013. /** @hidden */
  19014. export var lightFragment: {
  19015. name: string;
  19016. shader: string;
  19017. };
  19018. }
  19019. declare module BABYLON {
  19020. /** @hidden */
  19021. export var logDepthFragment: {
  19022. name: string;
  19023. shader: string;
  19024. };
  19025. }
  19026. declare module BABYLON {
  19027. /** @hidden */
  19028. export var fogFragment: {
  19029. name: string;
  19030. shader: string;
  19031. };
  19032. }
  19033. declare module BABYLON {
  19034. /** @hidden */
  19035. export var defaultPixelShader: {
  19036. name: string;
  19037. shader: string;
  19038. };
  19039. }
  19040. declare module BABYLON {
  19041. /** @hidden */
  19042. export var defaultVertexDeclaration: {
  19043. name: string;
  19044. shader: string;
  19045. };
  19046. }
  19047. declare module BABYLON {
  19048. /** @hidden */
  19049. export var bonesDeclaration: {
  19050. name: string;
  19051. shader: string;
  19052. };
  19053. }
  19054. declare module BABYLON {
  19055. /** @hidden */
  19056. export var prePassVertexDeclaration: {
  19057. name: string;
  19058. shader: string;
  19059. };
  19060. }
  19061. declare module BABYLON {
  19062. /** @hidden */
  19063. export var bumpVertexDeclaration: {
  19064. name: string;
  19065. shader: string;
  19066. };
  19067. }
  19068. declare module BABYLON {
  19069. /** @hidden */
  19070. export var fogVertexDeclaration: {
  19071. name: string;
  19072. shader: string;
  19073. };
  19074. }
  19075. declare module BABYLON {
  19076. /** @hidden */
  19077. export var lightVxFragmentDeclaration: {
  19078. name: string;
  19079. shader: string;
  19080. };
  19081. }
  19082. declare module BABYLON {
  19083. /** @hidden */
  19084. export var lightVxUboDeclaration: {
  19085. name: string;
  19086. shader: string;
  19087. };
  19088. }
  19089. declare module BABYLON {
  19090. /** @hidden */
  19091. export var morphTargetsVertexGlobalDeclaration: {
  19092. name: string;
  19093. shader: string;
  19094. };
  19095. }
  19096. declare module BABYLON {
  19097. /** @hidden */
  19098. export var morphTargetsVertexDeclaration: {
  19099. name: string;
  19100. shader: string;
  19101. };
  19102. }
  19103. declare module BABYLON {
  19104. /** @hidden */
  19105. export var morphTargetsVertex: {
  19106. name: string;
  19107. shader: string;
  19108. };
  19109. }
  19110. declare module BABYLON {
  19111. /** @hidden */
  19112. export var instancesVertex: {
  19113. name: string;
  19114. shader: string;
  19115. };
  19116. }
  19117. declare module BABYLON {
  19118. /** @hidden */
  19119. export var bonesVertex: {
  19120. name: string;
  19121. shader: string;
  19122. };
  19123. }
  19124. declare module BABYLON {
  19125. /** @hidden */
  19126. export var prePassVertex: {
  19127. name: string;
  19128. shader: string;
  19129. };
  19130. }
  19131. declare module BABYLON {
  19132. /** @hidden */
  19133. export var bumpVertex: {
  19134. name: string;
  19135. shader: string;
  19136. };
  19137. }
  19138. declare module BABYLON {
  19139. /** @hidden */
  19140. export var fogVertex: {
  19141. name: string;
  19142. shader: string;
  19143. };
  19144. }
  19145. declare module BABYLON {
  19146. /** @hidden */
  19147. export var shadowsVertex: {
  19148. name: string;
  19149. shader: string;
  19150. };
  19151. }
  19152. declare module BABYLON {
  19153. /** @hidden */
  19154. export var pointCloudVertex: {
  19155. name: string;
  19156. shader: string;
  19157. };
  19158. }
  19159. declare module BABYLON {
  19160. /** @hidden */
  19161. export var logDepthVertex: {
  19162. name: string;
  19163. shader: string;
  19164. };
  19165. }
  19166. declare module BABYLON {
  19167. /** @hidden */
  19168. export var defaultVertexShader: {
  19169. name: string;
  19170. shader: string;
  19171. };
  19172. }
  19173. declare module BABYLON {
  19174. /**
  19175. * @hidden
  19176. */
  19177. export interface IMaterialDetailMapDefines {
  19178. DETAIL: boolean;
  19179. DETAILDIRECTUV: number;
  19180. DETAIL_NORMALBLENDMETHOD: number;
  19181. /** @hidden */
  19182. _areTexturesDirty: boolean;
  19183. }
  19184. /**
  19185. * Define the code related to the detail map parameters of a material
  19186. *
  19187. * Inspired from:
  19188. * 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
  19189. * Unreal: https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/HowTo/DetailTexturing/index.html
  19190. * Cryengine: https://docs.cryengine.com/display/SDKDOC2/Detail+Maps
  19191. */
  19192. export class DetailMapConfiguration {
  19193. private _texture;
  19194. /**
  19195. * The detail texture of the material.
  19196. */
  19197. texture: Nullable<BaseTexture>;
  19198. /**
  19199. * Defines how strongly the detail diffuse/albedo channel is blended with the regular diffuse/albedo texture
  19200. * Bigger values mean stronger blending
  19201. */
  19202. diffuseBlendLevel: number;
  19203. /**
  19204. * Defines how strongly the detail roughness channel is blended with the regular roughness value
  19205. * Bigger values mean stronger blending. Only used with PBR materials
  19206. */
  19207. roughnessBlendLevel: number;
  19208. /**
  19209. * Defines how strong the bump effect from the detail map is
  19210. * Bigger values mean stronger effect
  19211. */
  19212. bumpLevel: number;
  19213. private _normalBlendMethod;
  19214. /**
  19215. * The method used to blend the bump and detail normals together
  19216. */
  19217. normalBlendMethod: number;
  19218. private _isEnabled;
  19219. /**
  19220. * Enable or disable the detail map on this material
  19221. */
  19222. isEnabled: boolean;
  19223. /** @hidden */
  19224. private _internalMarkAllSubMeshesAsTexturesDirty;
  19225. /** @hidden */
  19226. _markAllSubMeshesAsTexturesDirty(): void;
  19227. /**
  19228. * Instantiate a new detail map
  19229. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  19230. */
  19231. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  19232. /**
  19233. * Gets whether the submesh is ready to be used or not.
  19234. * @param defines the list of "defines" to update.
  19235. * @param scene defines the scene the material belongs to.
  19236. * @returns - boolean indicating that the submesh is ready or not.
  19237. */
  19238. isReadyForSubMesh(defines: IMaterialDetailMapDefines, scene: Scene): boolean;
  19239. /**
  19240. * Update the defines for detail map usage
  19241. * @param defines the list of "defines" to update.
  19242. * @param scene defines the scene the material belongs to.
  19243. */
  19244. prepareDefines(defines: IMaterialDetailMapDefines, scene: Scene): void;
  19245. /**
  19246. * Binds the material data.
  19247. * @param uniformBuffer defines the Uniform buffer to fill in.
  19248. * @param scene defines the scene the material belongs to.
  19249. * @param isFrozen defines whether the material is frozen or not.
  19250. */
  19251. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  19252. /**
  19253. * Checks to see if a texture is used in the material.
  19254. * @param texture - Base texture to use.
  19255. * @returns - Boolean specifying if a texture is used in the material.
  19256. */
  19257. hasTexture(texture: BaseTexture): boolean;
  19258. /**
  19259. * Returns an array of the actively used textures.
  19260. * @param activeTextures Array of BaseTextures
  19261. */
  19262. getActiveTextures(activeTextures: BaseTexture[]): void;
  19263. /**
  19264. * Returns the animatable textures.
  19265. * @param animatables Array of animatable textures.
  19266. */
  19267. getAnimatables(animatables: IAnimatable[]): void;
  19268. /**
  19269. * Disposes the resources of the material.
  19270. * @param forceDisposeTextures - Forces the disposal of all textures.
  19271. */
  19272. dispose(forceDisposeTextures?: boolean): void;
  19273. /**
  19274. * Get the current class name useful for serialization or dynamic coding.
  19275. * @returns "DetailMap"
  19276. */
  19277. getClassName(): string;
  19278. /**
  19279. * Add the required uniforms to the current list.
  19280. * @param uniforms defines the current uniform list.
  19281. */
  19282. static AddUniforms(uniforms: string[]): void;
  19283. /**
  19284. * Add the required samplers to the current list.
  19285. * @param samplers defines the current sampler list.
  19286. */
  19287. static AddSamplers(samplers: string[]): void;
  19288. /**
  19289. * Add the required uniforms to the current buffer.
  19290. * @param uniformBuffer defines the current uniform buffer.
  19291. */
  19292. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  19293. /**
  19294. * Makes a duplicate of the current instance into another one.
  19295. * @param detailMap define the instance where to copy the info
  19296. */
  19297. copyTo(detailMap: DetailMapConfiguration): void;
  19298. /**
  19299. * Serializes this detail map instance
  19300. * @returns - An object with the serialized instance.
  19301. */
  19302. serialize(): any;
  19303. /**
  19304. * Parses a detail map setting from a serialized object.
  19305. * @param source - Serialized object.
  19306. * @param scene Defines the scene we are parsing for
  19307. * @param rootUrl Defines the rootUrl to load from
  19308. */
  19309. parse(source: any, scene: Scene, rootUrl: string): void;
  19310. }
  19311. }
  19312. declare module BABYLON {
  19313. /** @hidden */
  19314. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialDetailMapDefines {
  19315. MAINUV1: boolean;
  19316. MAINUV2: boolean;
  19317. DIFFUSE: boolean;
  19318. DIFFUSEDIRECTUV: number;
  19319. DETAIL: boolean;
  19320. DETAILDIRECTUV: number;
  19321. DETAIL_NORMALBLENDMETHOD: number;
  19322. AMBIENT: boolean;
  19323. AMBIENTDIRECTUV: number;
  19324. OPACITY: boolean;
  19325. OPACITYDIRECTUV: number;
  19326. OPACITYRGB: boolean;
  19327. REFLECTION: boolean;
  19328. EMISSIVE: boolean;
  19329. EMISSIVEDIRECTUV: number;
  19330. SPECULAR: boolean;
  19331. SPECULARDIRECTUV: number;
  19332. BUMP: boolean;
  19333. BUMPDIRECTUV: number;
  19334. PARALLAX: boolean;
  19335. PARALLAXOCCLUSION: boolean;
  19336. SPECULAROVERALPHA: boolean;
  19337. CLIPPLANE: boolean;
  19338. CLIPPLANE2: boolean;
  19339. CLIPPLANE3: boolean;
  19340. CLIPPLANE4: boolean;
  19341. CLIPPLANE5: boolean;
  19342. CLIPPLANE6: boolean;
  19343. ALPHATEST: boolean;
  19344. DEPTHPREPASS: boolean;
  19345. ALPHAFROMDIFFUSE: boolean;
  19346. POINTSIZE: boolean;
  19347. FOG: boolean;
  19348. SPECULARTERM: boolean;
  19349. DIFFUSEFRESNEL: boolean;
  19350. OPACITYFRESNEL: boolean;
  19351. REFLECTIONFRESNEL: boolean;
  19352. REFRACTIONFRESNEL: boolean;
  19353. EMISSIVEFRESNEL: boolean;
  19354. FRESNEL: boolean;
  19355. NORMAL: boolean;
  19356. UV1: boolean;
  19357. UV2: boolean;
  19358. VERTEXCOLOR: boolean;
  19359. VERTEXALPHA: boolean;
  19360. NUM_BONE_INFLUENCERS: number;
  19361. BonesPerMesh: number;
  19362. BONETEXTURE: boolean;
  19363. BONES_VELOCITY_ENABLED: boolean;
  19364. INSTANCES: boolean;
  19365. THIN_INSTANCES: boolean;
  19366. GLOSSINESS: boolean;
  19367. ROUGHNESS: boolean;
  19368. EMISSIVEASILLUMINATION: boolean;
  19369. LINKEMISSIVEWITHDIFFUSE: boolean;
  19370. REFLECTIONFRESNELFROMSPECULAR: boolean;
  19371. LIGHTMAP: boolean;
  19372. LIGHTMAPDIRECTUV: number;
  19373. OBJECTSPACE_NORMALMAP: boolean;
  19374. USELIGHTMAPASSHADOWMAP: boolean;
  19375. REFLECTIONMAP_3D: boolean;
  19376. REFLECTIONMAP_SPHERICAL: boolean;
  19377. REFLECTIONMAP_PLANAR: boolean;
  19378. REFLECTIONMAP_CUBIC: boolean;
  19379. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  19380. REFLECTIONMAP_PROJECTION: boolean;
  19381. REFLECTIONMAP_SKYBOX: boolean;
  19382. REFLECTIONMAP_EXPLICIT: boolean;
  19383. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  19384. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  19385. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  19386. REFLECTIONMAP_OPPOSITEZ: boolean;
  19387. INVERTCUBICMAP: boolean;
  19388. LOGARITHMICDEPTH: boolean;
  19389. REFRACTION: boolean;
  19390. REFRACTIONMAP_3D: boolean;
  19391. REFLECTIONOVERALPHA: boolean;
  19392. TWOSIDEDLIGHTING: boolean;
  19393. SHADOWFLOAT: boolean;
  19394. MORPHTARGETS: boolean;
  19395. MORPHTARGETS_NORMAL: boolean;
  19396. MORPHTARGETS_TANGENT: boolean;
  19397. MORPHTARGETS_UV: boolean;
  19398. NUM_MORPH_INFLUENCERS: number;
  19399. NONUNIFORMSCALING: boolean;
  19400. PREMULTIPLYALPHA: boolean;
  19401. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  19402. ALPHABLEND: boolean;
  19403. PREPASS: boolean;
  19404. PREPASS_IRRADIANCE: boolean;
  19405. PREPASS_IRRADIANCE_INDEX: number;
  19406. PREPASS_ALBEDO: boolean;
  19407. PREPASS_ALBEDO_INDEX: number;
  19408. PREPASS_DEPTHNORMAL: boolean;
  19409. PREPASS_DEPTHNORMAL_INDEX: number;
  19410. PREPASS_POSITION: boolean;
  19411. PREPASS_POSITION_INDEX: number;
  19412. PREPASS_VELOCITY: boolean;
  19413. PREPASS_VELOCITY_INDEX: number;
  19414. PREPASS_REFLECTIVITY: boolean;
  19415. PREPASS_REFLECTIVITY_INDEX: number;
  19416. SCENE_MRT_COUNT: number;
  19417. RGBDLIGHTMAP: boolean;
  19418. RGBDREFLECTION: boolean;
  19419. RGBDREFRACTION: boolean;
  19420. IMAGEPROCESSING: boolean;
  19421. VIGNETTE: boolean;
  19422. VIGNETTEBLENDMODEMULTIPLY: boolean;
  19423. VIGNETTEBLENDMODEOPAQUE: boolean;
  19424. TONEMAPPING: boolean;
  19425. TONEMAPPING_ACES: boolean;
  19426. CONTRAST: boolean;
  19427. COLORCURVES: boolean;
  19428. COLORGRADING: boolean;
  19429. COLORGRADING3D: boolean;
  19430. SAMPLER3DGREENDEPTH: boolean;
  19431. SAMPLER3DBGRMAP: boolean;
  19432. IMAGEPROCESSINGPOSTPROCESS: boolean;
  19433. MULTIVIEW: boolean;
  19434. /**
  19435. * If the reflection texture on this material is in linear color space
  19436. * @hidden
  19437. */
  19438. IS_REFLECTION_LINEAR: boolean;
  19439. /**
  19440. * If the refraction texture on this material is in linear color space
  19441. * @hidden
  19442. */
  19443. IS_REFRACTION_LINEAR: boolean;
  19444. EXPOSURE: boolean;
  19445. constructor();
  19446. setReflectionMode(modeToEnable: string): void;
  19447. }
  19448. /**
  19449. * This is the default material used in Babylon. It is the best trade off between quality
  19450. * and performances.
  19451. * @see https://doc.babylonjs.com/babylon101/materials
  19452. */
  19453. export class StandardMaterial extends PushMaterial {
  19454. private _diffuseTexture;
  19455. /**
  19456. * The basic texture of the material as viewed under a light.
  19457. */
  19458. diffuseTexture: Nullable<BaseTexture>;
  19459. private _ambientTexture;
  19460. /**
  19461. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  19462. */
  19463. ambientTexture: Nullable<BaseTexture>;
  19464. private _opacityTexture;
  19465. /**
  19466. * Define the transparency of the material from a texture.
  19467. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  19468. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  19469. */
  19470. opacityTexture: Nullable<BaseTexture>;
  19471. private _reflectionTexture;
  19472. /**
  19473. * Define the texture used to display the reflection.
  19474. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  19475. */
  19476. reflectionTexture: Nullable<BaseTexture>;
  19477. private _emissiveTexture;
  19478. /**
  19479. * Define texture of the material as if self lit.
  19480. * This will be mixed in the final result even in the absence of light.
  19481. */
  19482. emissiveTexture: Nullable<BaseTexture>;
  19483. private _specularTexture;
  19484. /**
  19485. * Define how the color and intensity of the highlight given by the light in the material.
  19486. */
  19487. specularTexture: Nullable<BaseTexture>;
  19488. private _bumpTexture;
  19489. /**
  19490. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  19491. * 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.
  19492. * @see https://doc.babylonjs.com/how_to/more_materials#bump-map
  19493. */
  19494. bumpTexture: Nullable<BaseTexture>;
  19495. private _lightmapTexture;
  19496. /**
  19497. * Complex lighting can be computationally expensive to compute at runtime.
  19498. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  19499. * @see https://doc.babylonjs.com/babylon101/lights#lightmaps
  19500. */
  19501. lightmapTexture: Nullable<BaseTexture>;
  19502. private _refractionTexture;
  19503. /**
  19504. * Define the texture used to display the refraction.
  19505. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  19506. */
  19507. refractionTexture: Nullable<BaseTexture>;
  19508. /**
  19509. * The color of the material lit by the environmental background lighting.
  19510. * @see https://doc.babylonjs.com/babylon101/materials#ambient-color-example
  19511. */
  19512. ambientColor: Color3;
  19513. /**
  19514. * The basic color of the material as viewed under a light.
  19515. */
  19516. diffuseColor: Color3;
  19517. /**
  19518. * Define how the color and intensity of the highlight given by the light in the material.
  19519. */
  19520. specularColor: Color3;
  19521. /**
  19522. * Define the color of the material as if self lit.
  19523. * This will be mixed in the final result even in the absence of light.
  19524. */
  19525. emissiveColor: Color3;
  19526. /**
  19527. * Defines how sharp are the highlights in the material.
  19528. * The bigger the value the sharper giving a more glossy feeling to the result.
  19529. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  19530. */
  19531. specularPower: number;
  19532. private _useAlphaFromDiffuseTexture;
  19533. /**
  19534. * Does the transparency come from the diffuse texture alpha channel.
  19535. */
  19536. useAlphaFromDiffuseTexture: boolean;
  19537. private _useEmissiveAsIllumination;
  19538. /**
  19539. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  19540. */
  19541. useEmissiveAsIllumination: boolean;
  19542. private _linkEmissiveWithDiffuse;
  19543. /**
  19544. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  19545. * the emissive level when the final color is close to one.
  19546. */
  19547. linkEmissiveWithDiffuse: boolean;
  19548. private _useSpecularOverAlpha;
  19549. /**
  19550. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  19551. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  19552. */
  19553. useSpecularOverAlpha: boolean;
  19554. private _useReflectionOverAlpha;
  19555. /**
  19556. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  19557. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  19558. */
  19559. useReflectionOverAlpha: boolean;
  19560. private _disableLighting;
  19561. /**
  19562. * Does lights from the scene impacts this material.
  19563. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  19564. */
  19565. disableLighting: boolean;
  19566. private _useObjectSpaceNormalMap;
  19567. /**
  19568. * Allows using an object space normal map (instead of tangent space).
  19569. */
  19570. useObjectSpaceNormalMap: boolean;
  19571. private _useParallax;
  19572. /**
  19573. * Is parallax enabled or not.
  19574. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  19575. */
  19576. useParallax: boolean;
  19577. private _useParallaxOcclusion;
  19578. /**
  19579. * Is parallax occlusion enabled or not.
  19580. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  19581. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  19582. */
  19583. useParallaxOcclusion: boolean;
  19584. /**
  19585. * 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.
  19586. */
  19587. parallaxScaleBias: number;
  19588. private _roughness;
  19589. /**
  19590. * Helps to define how blurry the reflections should appears in the material.
  19591. */
  19592. roughness: number;
  19593. /**
  19594. * In case of refraction, define the value of the index of refraction.
  19595. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  19596. */
  19597. indexOfRefraction: number;
  19598. /**
  19599. * Invert the refraction texture alongside the y axis.
  19600. * It can be useful with procedural textures or probe for instance.
  19601. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  19602. */
  19603. invertRefractionY: boolean;
  19604. /**
  19605. * Defines the alpha limits in alpha test mode.
  19606. */
  19607. alphaCutOff: number;
  19608. private _useLightmapAsShadowmap;
  19609. /**
  19610. * In case of light mapping, define whether the map contains light or shadow informations.
  19611. */
  19612. useLightmapAsShadowmap: boolean;
  19613. private _diffuseFresnelParameters;
  19614. /**
  19615. * Define the diffuse fresnel parameters of the material.
  19616. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19617. */
  19618. diffuseFresnelParameters: FresnelParameters;
  19619. private _opacityFresnelParameters;
  19620. /**
  19621. * Define the opacity fresnel parameters of the material.
  19622. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19623. */
  19624. opacityFresnelParameters: FresnelParameters;
  19625. private _reflectionFresnelParameters;
  19626. /**
  19627. * Define the reflection fresnel parameters of the material.
  19628. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19629. */
  19630. reflectionFresnelParameters: FresnelParameters;
  19631. private _refractionFresnelParameters;
  19632. /**
  19633. * Define the refraction fresnel parameters of the material.
  19634. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19635. */
  19636. refractionFresnelParameters: FresnelParameters;
  19637. private _emissiveFresnelParameters;
  19638. /**
  19639. * Define the emissive fresnel parameters of the material.
  19640. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19641. */
  19642. emissiveFresnelParameters: FresnelParameters;
  19643. private _useReflectionFresnelFromSpecular;
  19644. /**
  19645. * If true automatically deducts the fresnels values from the material specularity.
  19646. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19647. */
  19648. useReflectionFresnelFromSpecular: boolean;
  19649. private _useGlossinessFromSpecularMapAlpha;
  19650. /**
  19651. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  19652. */
  19653. useGlossinessFromSpecularMapAlpha: boolean;
  19654. private _maxSimultaneousLights;
  19655. /**
  19656. * Defines the maximum number of lights that can be used in the material
  19657. */
  19658. maxSimultaneousLights: number;
  19659. private _invertNormalMapX;
  19660. /**
  19661. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  19662. */
  19663. invertNormalMapX: boolean;
  19664. private _invertNormalMapY;
  19665. /**
  19666. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  19667. */
  19668. invertNormalMapY: boolean;
  19669. private _twoSidedLighting;
  19670. /**
  19671. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  19672. */
  19673. twoSidedLighting: boolean;
  19674. /**
  19675. * Default configuration related to image processing available in the standard Material.
  19676. */
  19677. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  19678. /**
  19679. * Gets the image processing configuration used either in this material.
  19680. */
  19681. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  19682. /**
  19683. * Sets the Default image processing configuration used either in the this material.
  19684. *
  19685. * If sets to null, the scene one is in use.
  19686. */
  19687. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  19688. /**
  19689. * Keep track of the image processing observer to allow dispose and replace.
  19690. */
  19691. private _imageProcessingObserver;
  19692. /**
  19693. * Attaches a new image processing configuration to the Standard Material.
  19694. * @param configuration
  19695. */
  19696. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  19697. /**
  19698. * Defines additionnal PrePass parameters for the material.
  19699. */
  19700. readonly prePassConfiguration: PrePassConfiguration;
  19701. /**
  19702. * Gets wether the color curves effect is enabled.
  19703. */
  19704. get cameraColorCurvesEnabled(): boolean;
  19705. /**
  19706. * Sets wether the color curves effect is enabled.
  19707. */
  19708. set cameraColorCurvesEnabled(value: boolean);
  19709. /**
  19710. * Gets wether the color grading effect is enabled.
  19711. */
  19712. get cameraColorGradingEnabled(): boolean;
  19713. /**
  19714. * Gets wether the color grading effect is enabled.
  19715. */
  19716. set cameraColorGradingEnabled(value: boolean);
  19717. /**
  19718. * Gets wether tonemapping is enabled or not.
  19719. */
  19720. get cameraToneMappingEnabled(): boolean;
  19721. /**
  19722. * Sets wether tonemapping is enabled or not
  19723. */
  19724. set cameraToneMappingEnabled(value: boolean);
  19725. /**
  19726. * The camera exposure used on this material.
  19727. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  19728. * This corresponds to a photographic exposure.
  19729. */
  19730. get cameraExposure(): number;
  19731. /**
  19732. * The camera exposure used on this material.
  19733. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  19734. * This corresponds to a photographic exposure.
  19735. */
  19736. set cameraExposure(value: number);
  19737. /**
  19738. * Gets The camera contrast used on this material.
  19739. */
  19740. get cameraContrast(): number;
  19741. /**
  19742. * Sets The camera contrast used on this material.
  19743. */
  19744. set cameraContrast(value: number);
  19745. /**
  19746. * Gets the Color Grading 2D Lookup Texture.
  19747. */
  19748. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  19749. /**
  19750. * Sets the Color Grading 2D Lookup Texture.
  19751. */
  19752. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  19753. /**
  19754. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  19755. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  19756. * 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;
  19757. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  19758. */
  19759. get cameraColorCurves(): Nullable<ColorCurves>;
  19760. /**
  19761. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  19762. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  19763. * 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;
  19764. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  19765. */
  19766. set cameraColorCurves(value: Nullable<ColorCurves>);
  19767. /**
  19768. * Can this material render to several textures at once
  19769. */
  19770. get canRenderToMRT(): boolean;
  19771. /**
  19772. * Defines the detail map parameters for the material.
  19773. */
  19774. readonly detailMap: DetailMapConfiguration;
  19775. protected _renderTargets: SmartArray<RenderTargetTexture>;
  19776. protected _worldViewProjectionMatrix: Matrix;
  19777. protected _globalAmbientColor: Color3;
  19778. protected _useLogarithmicDepth: boolean;
  19779. protected _rebuildInParallel: boolean;
  19780. /**
  19781. * Instantiates a new standard material.
  19782. * This is the default material used in Babylon. It is the best trade off between quality
  19783. * and performances.
  19784. * @see https://doc.babylonjs.com/babylon101/materials
  19785. * @param name Define the name of the material in the scene
  19786. * @param scene Define the scene the material belong to
  19787. */
  19788. constructor(name: string, scene: Scene);
  19789. /**
  19790. * Gets a boolean indicating that current material needs to register RTT
  19791. */
  19792. get hasRenderTargetTextures(): boolean;
  19793. /**
  19794. * Gets the current class name of the material e.g. "StandardMaterial"
  19795. * Mainly use in serialization.
  19796. * @returns the class name
  19797. */
  19798. getClassName(): string;
  19799. /**
  19800. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  19801. * You can try switching to logarithmic depth.
  19802. * @see https://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  19803. */
  19804. get useLogarithmicDepth(): boolean;
  19805. set useLogarithmicDepth(value: boolean);
  19806. /**
  19807. * Specifies if the material will require alpha blending
  19808. * @returns a boolean specifying if alpha blending is needed
  19809. */
  19810. needAlphaBlending(): boolean;
  19811. /**
  19812. * Specifies if this material should be rendered in alpha test mode
  19813. * @returns a boolean specifying if an alpha test is needed.
  19814. */
  19815. needAlphaTesting(): boolean;
  19816. /**
  19817. * Specifies whether or not the alpha value of the diffuse texture should be used for alpha blending.
  19818. */
  19819. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  19820. /**
  19821. * Specifies whether or not there is a usable alpha channel for transparency.
  19822. */
  19823. protected _hasAlphaChannel(): boolean;
  19824. /**
  19825. * Get the texture used for alpha test purpose.
  19826. * @returns the diffuse texture in case of the standard material.
  19827. */
  19828. getAlphaTestTexture(): Nullable<BaseTexture>;
  19829. /**
  19830. * Get if the submesh is ready to be used and all its information available.
  19831. * Child classes can use it to update shaders
  19832. * @param mesh defines the mesh to check
  19833. * @param subMesh defines which submesh to check
  19834. * @param useInstances specifies that instances should be used
  19835. * @returns a boolean indicating that the submesh is ready or not
  19836. */
  19837. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  19838. /**
  19839. * Builds the material UBO layouts.
  19840. * Used internally during the effect preparation.
  19841. */
  19842. buildUniformLayout(): void;
  19843. /**
  19844. * Unbinds the material from the mesh
  19845. */
  19846. unbind(): void;
  19847. /**
  19848. * Binds the submesh to this material by preparing the effect and shader to draw
  19849. * @param world defines the world transformation matrix
  19850. * @param mesh defines the mesh containing the submesh
  19851. * @param subMesh defines the submesh to bind the material to
  19852. */
  19853. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  19854. /**
  19855. * Get the list of animatables in the material.
  19856. * @returns the list of animatables object used in the material
  19857. */
  19858. getAnimatables(): IAnimatable[];
  19859. /**
  19860. * Gets the active textures from the material
  19861. * @returns an array of textures
  19862. */
  19863. getActiveTextures(): BaseTexture[];
  19864. /**
  19865. * Specifies if the material uses a texture
  19866. * @param texture defines the texture to check against the material
  19867. * @returns a boolean specifying if the material uses the texture
  19868. */
  19869. hasTexture(texture: BaseTexture): boolean;
  19870. /**
  19871. * Disposes the material
  19872. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  19873. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  19874. */
  19875. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  19876. /**
  19877. * Makes a duplicate of the material, and gives it a new name
  19878. * @param name defines the new name for the duplicated material
  19879. * @returns the cloned material
  19880. */
  19881. clone(name: string): StandardMaterial;
  19882. /**
  19883. * Serializes this material in a JSON representation
  19884. * @returns the serialized material object
  19885. */
  19886. serialize(): any;
  19887. /**
  19888. * Creates a standard material from parsed material data
  19889. * @param source defines the JSON representation of the material
  19890. * @param scene defines the hosting scene
  19891. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  19892. * @returns a new standard material
  19893. */
  19894. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  19895. /**
  19896. * Are diffuse textures enabled in the application.
  19897. */
  19898. static get DiffuseTextureEnabled(): boolean;
  19899. static set DiffuseTextureEnabled(value: boolean);
  19900. /**
  19901. * Are detail textures enabled in the application.
  19902. */
  19903. static get DetailTextureEnabled(): boolean;
  19904. static set DetailTextureEnabled(value: boolean);
  19905. /**
  19906. * Are ambient textures enabled in the application.
  19907. */
  19908. static get AmbientTextureEnabled(): boolean;
  19909. static set AmbientTextureEnabled(value: boolean);
  19910. /**
  19911. * Are opacity textures enabled in the application.
  19912. */
  19913. static get OpacityTextureEnabled(): boolean;
  19914. static set OpacityTextureEnabled(value: boolean);
  19915. /**
  19916. * Are reflection textures enabled in the application.
  19917. */
  19918. static get ReflectionTextureEnabled(): boolean;
  19919. static set ReflectionTextureEnabled(value: boolean);
  19920. /**
  19921. * Are emissive textures enabled in the application.
  19922. */
  19923. static get EmissiveTextureEnabled(): boolean;
  19924. static set EmissiveTextureEnabled(value: boolean);
  19925. /**
  19926. * Are specular textures enabled in the application.
  19927. */
  19928. static get SpecularTextureEnabled(): boolean;
  19929. static set SpecularTextureEnabled(value: boolean);
  19930. /**
  19931. * Are bump textures enabled in the application.
  19932. */
  19933. static get BumpTextureEnabled(): boolean;
  19934. static set BumpTextureEnabled(value: boolean);
  19935. /**
  19936. * Are lightmap textures enabled in the application.
  19937. */
  19938. static get LightmapTextureEnabled(): boolean;
  19939. static set LightmapTextureEnabled(value: boolean);
  19940. /**
  19941. * Are refraction textures enabled in the application.
  19942. */
  19943. static get RefractionTextureEnabled(): boolean;
  19944. static set RefractionTextureEnabled(value: boolean);
  19945. /**
  19946. * Are color grading textures enabled in the application.
  19947. */
  19948. static get ColorGradingTextureEnabled(): boolean;
  19949. static set ColorGradingTextureEnabled(value: boolean);
  19950. /**
  19951. * Are fresnels enabled in the application.
  19952. */
  19953. static get FresnelEnabled(): boolean;
  19954. static set FresnelEnabled(value: boolean);
  19955. }
  19956. }
  19957. declare module BABYLON {
  19958. /** @hidden */
  19959. export var rgbdDecodePixelShader: {
  19960. name: string;
  19961. shader: string;
  19962. };
  19963. }
  19964. declare module BABYLON {
  19965. /** @hidden */
  19966. export var passPixelShader: {
  19967. name: string;
  19968. shader: string;
  19969. };
  19970. }
  19971. declare module BABYLON {
  19972. /** @hidden */
  19973. export var passCubePixelShader: {
  19974. name: string;
  19975. shader: string;
  19976. };
  19977. }
  19978. declare module BABYLON {
  19979. /**
  19980. * PassPostProcess which produces an output the same as it's input
  19981. */
  19982. export class PassPostProcess extends PostProcess {
  19983. /**
  19984. * Gets a string identifying the name of the class
  19985. * @returns "PassPostProcess" string
  19986. */
  19987. getClassName(): string;
  19988. /**
  19989. * Creates the PassPostProcess
  19990. * @param name The name of the effect.
  19991. * @param options The required width/height ratio to downsize to before computing the render pass.
  19992. * @param camera The camera to apply the render pass to.
  19993. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  19994. * @param engine The engine which the post process will be applied. (default: current engine)
  19995. * @param reusable If the post process can be reused on the same frame. (default: false)
  19996. * @param textureType The type of texture to be used when performing the post processing.
  19997. * @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)
  19998. */
  19999. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  20000. /** @hidden */
  20001. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassPostProcess;
  20002. }
  20003. /**
  20004. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  20005. */
  20006. export class PassCubePostProcess extends PostProcess {
  20007. private _face;
  20008. /**
  20009. * Gets or sets the cube face to display.
  20010. * * 0 is +X
  20011. * * 1 is -X
  20012. * * 2 is +Y
  20013. * * 3 is -Y
  20014. * * 4 is +Z
  20015. * * 5 is -Z
  20016. */
  20017. get face(): number;
  20018. set face(value: number);
  20019. /**
  20020. * Gets a string identifying the name of the class
  20021. * @returns "PassCubePostProcess" string
  20022. */
  20023. getClassName(): string;
  20024. /**
  20025. * Creates the PassCubePostProcess
  20026. * @param name The name of the effect.
  20027. * @param options The required width/height ratio to downsize to before computing the render pass.
  20028. * @param camera The camera to apply the render pass to.
  20029. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  20030. * @param engine The engine which the post process will be applied. (default: current engine)
  20031. * @param reusable If the post process can be reused on the same frame. (default: false)
  20032. * @param textureType The type of texture to be used when performing the post processing.
  20033. * @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)
  20034. */
  20035. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  20036. /** @hidden */
  20037. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassCubePostProcess;
  20038. }
  20039. }
  20040. declare module BABYLON {
  20041. /**
  20042. * Class used to host texture specific utilities
  20043. */
  20044. export class TextureTools {
  20045. /**
  20046. * Uses the GPU to create a copy texture rescaled at a given size
  20047. * @param texture Texture to copy from
  20048. * @param width defines the desired width
  20049. * @param height defines the desired height
  20050. * @param useBilinearMode defines if bilinear mode has to be used
  20051. * @return the generated texture
  20052. */
  20053. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  20054. /**
  20055. * Apply a post process to a texture
  20056. * @param postProcessName name of the fragment post process
  20057. * @param internalTexture the texture to encode
  20058. * @param scene the scene hosting the texture
  20059. * @param type type of the output texture. If not provided, use the one from internalTexture
  20060. * @param samplingMode sampling moode to use to sample the source texture. If not provided, use the one from internalTexture
  20061. * @param format format of the output texture. If not provided, use the one from internalTexture
  20062. * @return a promise with the internalTexture having its texture replaced by the result of the processing
  20063. */
  20064. static ApplyPostProcess(postProcessName: string, internalTexture: InternalTexture, scene: Scene, type?: number, samplingMode?: number, format?: number): Promise<InternalTexture>;
  20065. }
  20066. }
  20067. declare module BABYLON {
  20068. /**
  20069. * Class used to host RGBD texture specific utilities
  20070. */
  20071. export class RGBDTextureTools {
  20072. /**
  20073. * Expand the RGBD Texture from RGBD to Half Float if possible.
  20074. * @param texture the texture to expand.
  20075. */
  20076. static ExpandRGBDTexture(texture: Texture): void;
  20077. /**
  20078. * Encode the texture to RGBD if possible.
  20079. * @param internalTexture the texture to encode
  20080. * @param scene the scene hosting the texture
  20081. * @param outputTextureType type of the texture in which the encoding is performed
  20082. * @return a promise with the internalTexture having its texture replaced by the result of the processing
  20083. */
  20084. static EncodeTextureToRGBD(internalTexture: InternalTexture, scene: Scene, outputTextureType?: number): Promise<InternalTexture>;
  20085. }
  20086. }
  20087. declare module BABYLON {
  20088. /**
  20089. * Class used to host texture specific utilities
  20090. */
  20091. export class BRDFTextureTools {
  20092. /**
  20093. * Prevents texture cache collision
  20094. */
  20095. private static _instanceNumber;
  20096. /**
  20097. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  20098. * @param scene defines the hosting scene
  20099. * @returns the environment BRDF texture
  20100. */
  20101. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  20102. private static _environmentBRDFBase64Texture;
  20103. }
  20104. }
  20105. declare module BABYLON {
  20106. /**
  20107. * @hidden
  20108. */
  20109. export interface IMaterialClearCoatDefines {
  20110. CLEARCOAT: boolean;
  20111. CLEARCOAT_DEFAULTIOR: boolean;
  20112. CLEARCOAT_TEXTURE: boolean;
  20113. CLEARCOAT_TEXTURE_ROUGHNESS: boolean;
  20114. CLEARCOAT_TEXTUREDIRECTUV: number;
  20115. CLEARCOAT_TEXTURE_ROUGHNESSDIRECTUV: number;
  20116. CLEARCOAT_BUMP: boolean;
  20117. CLEARCOAT_BUMPDIRECTUV: number;
  20118. CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  20119. CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  20120. CLEARCOAT_REMAP_F0: boolean;
  20121. CLEARCOAT_TINT: boolean;
  20122. CLEARCOAT_TINT_TEXTURE: boolean;
  20123. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  20124. /** @hidden */
  20125. _areTexturesDirty: boolean;
  20126. }
  20127. /**
  20128. * Define the code related to the clear coat parameters of the pbr material.
  20129. */
  20130. export class PBRClearCoatConfiguration {
  20131. /**
  20132. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  20133. * The default fits with a polyurethane material.
  20134. * @hidden
  20135. */
  20136. static readonly _DefaultIndexOfRefraction: number;
  20137. private _isEnabled;
  20138. /**
  20139. * Defines if the clear coat is enabled in the material.
  20140. */
  20141. isEnabled: boolean;
  20142. /**
  20143. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  20144. */
  20145. intensity: number;
  20146. /**
  20147. * Defines the clear coat layer roughness.
  20148. */
  20149. roughness: number;
  20150. private _indexOfRefraction;
  20151. /**
  20152. * Defines the index of refraction of the clear coat.
  20153. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  20154. * The default fits with a polyurethane material.
  20155. * Changing the default value is more performance intensive.
  20156. */
  20157. indexOfRefraction: number;
  20158. private _texture;
  20159. /**
  20160. * Stores the clear coat values in a texture (red channel is intensity and green channel is roughness)
  20161. * If useRoughnessFromMainTexture is false, the green channel of texture is not used and the green channel of textureRoughness is used instead
  20162. * if textureRoughness is not empty, else no texture roughness is used
  20163. */
  20164. texture: Nullable<BaseTexture>;
  20165. private _useRoughnessFromMainTexture;
  20166. /**
  20167. * Indicates that the green channel of the texture property will be used for roughness (default: true)
  20168. * If false, the green channel from textureRoughness is used for roughness
  20169. */
  20170. useRoughnessFromMainTexture: boolean;
  20171. private _textureRoughness;
  20172. /**
  20173. * Stores the clear coat roughness in a texture (green channel)
  20174. * Not used if useRoughnessFromMainTexture is true
  20175. */
  20176. textureRoughness: Nullable<BaseTexture>;
  20177. private _remapF0OnInterfaceChange;
  20178. /**
  20179. * Defines if the F0 value should be remapped to account for the interface change in the material.
  20180. */
  20181. remapF0OnInterfaceChange: boolean;
  20182. private _bumpTexture;
  20183. /**
  20184. * Define the clear coat specific bump texture.
  20185. */
  20186. bumpTexture: Nullable<BaseTexture>;
  20187. private _isTintEnabled;
  20188. /**
  20189. * Defines if the clear coat tint is enabled in the material.
  20190. */
  20191. isTintEnabled: boolean;
  20192. /**
  20193. * Defines the clear coat tint of the material.
  20194. * This is only use if tint is enabled
  20195. */
  20196. tintColor: Color3;
  20197. /**
  20198. * Defines the distance at which the tint color should be found in the
  20199. * clear coat media.
  20200. * This is only use if tint is enabled
  20201. */
  20202. tintColorAtDistance: number;
  20203. /**
  20204. * Defines the clear coat layer thickness.
  20205. * This is only use if tint is enabled
  20206. */
  20207. tintThickness: number;
  20208. private _tintTexture;
  20209. /**
  20210. * Stores the clear tint values in a texture.
  20211. * rgb is tint
  20212. * a is a thickness factor
  20213. */
  20214. tintTexture: Nullable<BaseTexture>;
  20215. /** @hidden */
  20216. private _internalMarkAllSubMeshesAsTexturesDirty;
  20217. /** @hidden */
  20218. _markAllSubMeshesAsTexturesDirty(): void;
  20219. /**
  20220. * Instantiate a new istance of clear coat configuration.
  20221. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  20222. */
  20223. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  20224. /**
  20225. * Gets wehter the submesh is ready to be used or not.
  20226. * @param defines the list of "defines" to update.
  20227. * @param scene defines the scene the material belongs to.
  20228. * @param engine defines the engine the material belongs to.
  20229. * @param disableBumpMap defines wether the material disables bump or not.
  20230. * @returns - boolean indicating that the submesh is ready or not.
  20231. */
  20232. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  20233. /**
  20234. * Checks to see if a texture is used in the material.
  20235. * @param defines the list of "defines" to update.
  20236. * @param scene defines the scene to the material belongs to.
  20237. */
  20238. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  20239. /**
  20240. * Binds the material data.
  20241. * @param uniformBuffer defines the Uniform buffer to fill in.
  20242. * @param scene defines the scene the material belongs to.
  20243. * @param engine defines the engine the material belongs to.
  20244. * @param disableBumpMap defines wether the material disables bump or not.
  20245. * @param isFrozen defines wether the material is frozen or not.
  20246. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  20247. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  20248. * @param subMesh the submesh to bind data for
  20249. */
  20250. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean, subMesh?: SubMesh): void;
  20251. /**
  20252. * Checks to see if a texture is used in the material.
  20253. * @param texture - Base texture to use.
  20254. * @returns - Boolean specifying if a texture is used in the material.
  20255. */
  20256. hasTexture(texture: BaseTexture): boolean;
  20257. /**
  20258. * Returns an array of the actively used textures.
  20259. * @param activeTextures Array of BaseTextures
  20260. */
  20261. getActiveTextures(activeTextures: BaseTexture[]): void;
  20262. /**
  20263. * Returns the animatable textures.
  20264. * @param animatables Array of animatable textures.
  20265. */
  20266. getAnimatables(animatables: IAnimatable[]): void;
  20267. /**
  20268. * Disposes the resources of the material.
  20269. * @param forceDisposeTextures - Forces the disposal of all textures.
  20270. */
  20271. dispose(forceDisposeTextures?: boolean): void;
  20272. /**
  20273. * Get the current class name of the texture useful for serialization or dynamic coding.
  20274. * @returns "PBRClearCoatConfiguration"
  20275. */
  20276. getClassName(): string;
  20277. /**
  20278. * Add fallbacks to the effect fallbacks list.
  20279. * @param defines defines the Base texture to use.
  20280. * @param fallbacks defines the current fallback list.
  20281. * @param currentRank defines the current fallback rank.
  20282. * @returns the new fallback rank.
  20283. */
  20284. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  20285. /**
  20286. * Add the required uniforms to the current list.
  20287. * @param uniforms defines the current uniform list.
  20288. */
  20289. static AddUniforms(uniforms: string[]): void;
  20290. /**
  20291. * Add the required samplers to the current list.
  20292. * @param samplers defines the current sampler list.
  20293. */
  20294. static AddSamplers(samplers: string[]): void;
  20295. /**
  20296. * Add the required uniforms to the current buffer.
  20297. * @param uniformBuffer defines the current uniform buffer.
  20298. */
  20299. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  20300. /**
  20301. * Makes a duplicate of the current configuration into another one.
  20302. * @param clearCoatConfiguration define the config where to copy the info
  20303. */
  20304. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  20305. /**
  20306. * Serializes this clear coat configuration.
  20307. * @returns - An object with the serialized config.
  20308. */
  20309. serialize(): any;
  20310. /**
  20311. * Parses a anisotropy Configuration from a serialized object.
  20312. * @param source - Serialized object.
  20313. * @param scene Defines the scene we are parsing for
  20314. * @param rootUrl Defines the rootUrl to load from
  20315. */
  20316. parse(source: any, scene: Scene, rootUrl: string): void;
  20317. }
  20318. }
  20319. declare module BABYLON {
  20320. /**
  20321. * @hidden
  20322. */
  20323. export interface IMaterialAnisotropicDefines {
  20324. ANISOTROPIC: boolean;
  20325. ANISOTROPIC_TEXTURE: boolean;
  20326. ANISOTROPIC_TEXTUREDIRECTUV: number;
  20327. MAINUV1: boolean;
  20328. _areTexturesDirty: boolean;
  20329. _needUVs: boolean;
  20330. }
  20331. /**
  20332. * Define the code related to the anisotropic parameters of the pbr material.
  20333. */
  20334. export class PBRAnisotropicConfiguration {
  20335. private _isEnabled;
  20336. /**
  20337. * Defines if the anisotropy is enabled in the material.
  20338. */
  20339. isEnabled: boolean;
  20340. /**
  20341. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  20342. */
  20343. intensity: number;
  20344. /**
  20345. * Defines if the effect is along the tangents, bitangents or in between.
  20346. * By default, the effect is "strectching" the highlights along the tangents.
  20347. */
  20348. direction: Vector2;
  20349. private _texture;
  20350. /**
  20351. * Stores the anisotropy values in a texture.
  20352. * rg is direction (like normal from -1 to 1)
  20353. * b is a intensity
  20354. */
  20355. texture: Nullable<BaseTexture>;
  20356. /** @hidden */
  20357. private _internalMarkAllSubMeshesAsTexturesDirty;
  20358. /** @hidden */
  20359. _markAllSubMeshesAsTexturesDirty(): void;
  20360. /**
  20361. * Instantiate a new istance of anisotropy configuration.
  20362. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  20363. */
  20364. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  20365. /**
  20366. * Specifies that the submesh is ready to be used.
  20367. * @param defines the list of "defines" to update.
  20368. * @param scene defines the scene the material belongs to.
  20369. * @returns - boolean indicating that the submesh is ready or not.
  20370. */
  20371. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  20372. /**
  20373. * Checks to see if a texture is used in the material.
  20374. * @param defines the list of "defines" to update.
  20375. * @param mesh the mesh we are preparing the defines for.
  20376. * @param scene defines the scene the material belongs to.
  20377. */
  20378. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  20379. /**
  20380. * Binds the material data.
  20381. * @param uniformBuffer defines the Uniform buffer to fill in.
  20382. * @param scene defines the scene the material belongs to.
  20383. * @param isFrozen defines wether the material is frozen or not.
  20384. */
  20385. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  20386. /**
  20387. * Checks to see if a texture is used in the material.
  20388. * @param texture - Base texture to use.
  20389. * @returns - Boolean specifying if a texture is used in the material.
  20390. */
  20391. hasTexture(texture: BaseTexture): boolean;
  20392. /**
  20393. * Returns an array of the actively used textures.
  20394. * @param activeTextures Array of BaseTextures
  20395. */
  20396. getActiveTextures(activeTextures: BaseTexture[]): void;
  20397. /**
  20398. * Returns the animatable textures.
  20399. * @param animatables Array of animatable textures.
  20400. */
  20401. getAnimatables(animatables: IAnimatable[]): void;
  20402. /**
  20403. * Disposes the resources of the material.
  20404. * @param forceDisposeTextures - Forces the disposal of all textures.
  20405. */
  20406. dispose(forceDisposeTextures?: boolean): void;
  20407. /**
  20408. * Get the current class name of the texture useful for serialization or dynamic coding.
  20409. * @returns "PBRAnisotropicConfiguration"
  20410. */
  20411. getClassName(): string;
  20412. /**
  20413. * Add fallbacks to the effect fallbacks list.
  20414. * @param defines defines the Base texture to use.
  20415. * @param fallbacks defines the current fallback list.
  20416. * @param currentRank defines the current fallback rank.
  20417. * @returns the new fallback rank.
  20418. */
  20419. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  20420. /**
  20421. * Add the required uniforms to the current list.
  20422. * @param uniforms defines the current uniform list.
  20423. */
  20424. static AddUniforms(uniforms: string[]): void;
  20425. /**
  20426. * Add the required uniforms to the current buffer.
  20427. * @param uniformBuffer defines the current uniform buffer.
  20428. */
  20429. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  20430. /**
  20431. * Add the required samplers to the current list.
  20432. * @param samplers defines the current sampler list.
  20433. */
  20434. static AddSamplers(samplers: string[]): void;
  20435. /**
  20436. * Makes a duplicate of the current configuration into another one.
  20437. * @param anisotropicConfiguration define the config where to copy the info
  20438. */
  20439. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  20440. /**
  20441. * Serializes this anisotropy configuration.
  20442. * @returns - An object with the serialized config.
  20443. */
  20444. serialize(): any;
  20445. /**
  20446. * Parses a anisotropy Configuration from a serialized object.
  20447. * @param source - Serialized object.
  20448. * @param scene Defines the scene we are parsing for
  20449. * @param rootUrl Defines the rootUrl to load from
  20450. */
  20451. parse(source: any, scene: Scene, rootUrl: string): void;
  20452. }
  20453. }
  20454. declare module BABYLON {
  20455. /**
  20456. * @hidden
  20457. */
  20458. export interface IMaterialBRDFDefines {
  20459. BRDF_V_HEIGHT_CORRELATED: boolean;
  20460. MS_BRDF_ENERGY_CONSERVATION: boolean;
  20461. SPHERICAL_HARMONICS: boolean;
  20462. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  20463. /** @hidden */
  20464. _areMiscDirty: boolean;
  20465. }
  20466. /**
  20467. * Define the code related to the BRDF parameters of the pbr material.
  20468. */
  20469. export class PBRBRDFConfiguration {
  20470. /**
  20471. * Default value used for the energy conservation.
  20472. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  20473. */
  20474. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  20475. /**
  20476. * Default value used for the Smith Visibility Height Correlated mode.
  20477. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  20478. */
  20479. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  20480. /**
  20481. * Default value used for the IBL diffuse part.
  20482. * This can help switching back to the polynomials mode globally which is a tiny bit
  20483. * less GPU intensive at the drawback of a lower quality.
  20484. */
  20485. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  20486. /**
  20487. * Default value used for activating energy conservation for the specular workflow.
  20488. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  20489. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  20490. */
  20491. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  20492. private _useEnergyConservation;
  20493. /**
  20494. * Defines if the material uses energy conservation.
  20495. */
  20496. useEnergyConservation: boolean;
  20497. private _useSmithVisibilityHeightCorrelated;
  20498. /**
  20499. * LEGACY Mode set to false
  20500. * Defines if the material uses height smith correlated visibility term.
  20501. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  20502. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  20503. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  20504. * Not relying on height correlated will also disable energy conservation.
  20505. */
  20506. useSmithVisibilityHeightCorrelated: boolean;
  20507. private _useSphericalHarmonics;
  20508. /**
  20509. * LEGACY Mode set to false
  20510. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  20511. * diffuse part of the IBL.
  20512. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  20513. * to the ground truth.
  20514. */
  20515. useSphericalHarmonics: boolean;
  20516. private _useSpecularGlossinessInputEnergyConservation;
  20517. /**
  20518. * Defines if the material uses energy conservation, when the specular workflow is active.
  20519. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  20520. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  20521. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  20522. */
  20523. useSpecularGlossinessInputEnergyConservation: boolean;
  20524. /** @hidden */
  20525. private _internalMarkAllSubMeshesAsMiscDirty;
  20526. /** @hidden */
  20527. _markAllSubMeshesAsMiscDirty(): void;
  20528. /**
  20529. * Instantiate a new istance of clear coat configuration.
  20530. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  20531. */
  20532. constructor(markAllSubMeshesAsMiscDirty: () => void);
  20533. /**
  20534. * Checks to see if a texture is used in the material.
  20535. * @param defines the list of "defines" to update.
  20536. */
  20537. prepareDefines(defines: IMaterialBRDFDefines): void;
  20538. /**
  20539. * Get the current class name of the texture useful for serialization or dynamic coding.
  20540. * @returns "PBRClearCoatConfiguration"
  20541. */
  20542. getClassName(): string;
  20543. /**
  20544. * Makes a duplicate of the current configuration into another one.
  20545. * @param brdfConfiguration define the config where to copy the info
  20546. */
  20547. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  20548. /**
  20549. * Serializes this BRDF configuration.
  20550. * @returns - An object with the serialized config.
  20551. */
  20552. serialize(): any;
  20553. /**
  20554. * Parses a anisotropy Configuration from a serialized object.
  20555. * @param source - Serialized object.
  20556. * @param scene Defines the scene we are parsing for
  20557. * @param rootUrl Defines the rootUrl to load from
  20558. */
  20559. parse(source: any, scene: Scene, rootUrl: string): void;
  20560. }
  20561. }
  20562. declare module BABYLON {
  20563. /**
  20564. * @hidden
  20565. */
  20566. export interface IMaterialSheenDefines {
  20567. SHEEN: boolean;
  20568. SHEEN_TEXTURE: boolean;
  20569. SHEEN_TEXTURE_ROUGHNESS: boolean;
  20570. SHEEN_TEXTUREDIRECTUV: number;
  20571. SHEEN_TEXTURE_ROUGHNESSDIRECTUV: number;
  20572. SHEEN_LINKWITHALBEDO: boolean;
  20573. SHEEN_ROUGHNESS: boolean;
  20574. SHEEN_ALBEDOSCALING: boolean;
  20575. SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  20576. SHEEN_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  20577. /** @hidden */
  20578. _areTexturesDirty: boolean;
  20579. }
  20580. /**
  20581. * Define the code related to the Sheen parameters of the pbr material.
  20582. */
  20583. export class PBRSheenConfiguration {
  20584. private _isEnabled;
  20585. /**
  20586. * Defines if the material uses sheen.
  20587. */
  20588. isEnabled: boolean;
  20589. private _linkSheenWithAlbedo;
  20590. /**
  20591. * Defines if the sheen is linked to the sheen color.
  20592. */
  20593. linkSheenWithAlbedo: boolean;
  20594. /**
  20595. * Defines the sheen intensity.
  20596. */
  20597. intensity: number;
  20598. /**
  20599. * Defines the sheen color.
  20600. */
  20601. color: Color3;
  20602. private _texture;
  20603. /**
  20604. * Stores the sheen tint values in a texture.
  20605. * rgb is tint
  20606. * 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)
  20607. * If the roughness property has been defined and useRoughnessFromTexture is false then the alpha channel is not used to modulate roughness
  20608. */
  20609. texture: Nullable<BaseTexture>;
  20610. private _useRoughnessFromMainTexture;
  20611. /**
  20612. * Indicates that the alpha channel of the texture property will be used for roughness.
  20613. * Has no effect if the roughness (and texture!) property is not defined
  20614. */
  20615. useRoughnessFromMainTexture: boolean;
  20616. private _roughness;
  20617. /**
  20618. * Defines the sheen roughness.
  20619. * It is not taken into account if linkSheenWithAlbedo is true.
  20620. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  20621. */
  20622. roughness: Nullable<number>;
  20623. private _textureRoughness;
  20624. /**
  20625. * Stores the sheen roughness in a texture.
  20626. * alpha channel is the roughness. This texture won't be used if the texture property is not empty and useRoughnessFromTexture is true
  20627. */
  20628. textureRoughness: Nullable<BaseTexture>;
  20629. private _albedoScaling;
  20630. /**
  20631. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  20632. * It allows the strength of the sheen effect to not depend on the base color of the material,
  20633. * making it easier to setup and tweak the effect
  20634. */
  20635. albedoScaling: boolean;
  20636. /** @hidden */
  20637. private _internalMarkAllSubMeshesAsTexturesDirty;
  20638. /** @hidden */
  20639. _markAllSubMeshesAsTexturesDirty(): void;
  20640. /**
  20641. * Instantiate a new istance of clear coat configuration.
  20642. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  20643. */
  20644. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  20645. /**
  20646. * Specifies that the submesh is ready to be used.
  20647. * @param defines the list of "defines" to update.
  20648. * @param scene defines the scene the material belongs to.
  20649. * @returns - boolean indicating that the submesh is ready or not.
  20650. */
  20651. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  20652. /**
  20653. * Checks to see if a texture is used in the material.
  20654. * @param defines the list of "defines" to update.
  20655. * @param scene defines the scene the material belongs to.
  20656. */
  20657. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  20658. /**
  20659. * Binds the material data.
  20660. * @param uniformBuffer defines the Uniform buffer to fill in.
  20661. * @param scene defines the scene the material belongs to.
  20662. * @param isFrozen defines wether the material is frozen or not.
  20663. * @param subMesh the submesh to bind data for
  20664. */
  20665. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean, subMesh?: SubMesh): void;
  20666. /**
  20667. * Checks to see if a texture is used in the material.
  20668. * @param texture - Base texture to use.
  20669. * @returns - Boolean specifying if a texture is used in the material.
  20670. */
  20671. hasTexture(texture: BaseTexture): boolean;
  20672. /**
  20673. * Returns an array of the actively used textures.
  20674. * @param activeTextures Array of BaseTextures
  20675. */
  20676. getActiveTextures(activeTextures: BaseTexture[]): void;
  20677. /**
  20678. * Returns the animatable textures.
  20679. * @param animatables Array of animatable textures.
  20680. */
  20681. getAnimatables(animatables: IAnimatable[]): void;
  20682. /**
  20683. * Disposes the resources of the material.
  20684. * @param forceDisposeTextures - Forces the disposal of all textures.
  20685. */
  20686. dispose(forceDisposeTextures?: boolean): void;
  20687. /**
  20688. * Get the current class name of the texture useful for serialization or dynamic coding.
  20689. * @returns "PBRSheenConfiguration"
  20690. */
  20691. getClassName(): string;
  20692. /**
  20693. * Add fallbacks to the effect fallbacks list.
  20694. * @param defines defines the Base texture to use.
  20695. * @param fallbacks defines the current fallback list.
  20696. * @param currentRank defines the current fallback rank.
  20697. * @returns the new fallback rank.
  20698. */
  20699. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  20700. /**
  20701. * Add the required uniforms to the current list.
  20702. * @param uniforms defines the current uniform list.
  20703. */
  20704. static AddUniforms(uniforms: string[]): void;
  20705. /**
  20706. * Add the required uniforms to the current buffer.
  20707. * @param uniformBuffer defines the current uniform buffer.
  20708. */
  20709. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  20710. /**
  20711. * Add the required samplers to the current list.
  20712. * @param samplers defines the current sampler list.
  20713. */
  20714. static AddSamplers(samplers: string[]): void;
  20715. /**
  20716. * Makes a duplicate of the current configuration into another one.
  20717. * @param sheenConfiguration define the config where to copy the info
  20718. */
  20719. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  20720. /**
  20721. * Serializes this BRDF configuration.
  20722. * @returns - An object with the serialized config.
  20723. */
  20724. serialize(): any;
  20725. /**
  20726. * Parses a anisotropy Configuration from a serialized object.
  20727. * @param source - Serialized object.
  20728. * @param scene Defines the scene we are parsing for
  20729. * @param rootUrl Defines the rootUrl to load from
  20730. */
  20731. parse(source: any, scene: Scene, rootUrl: string): void;
  20732. }
  20733. }
  20734. declare module BABYLON {
  20735. /**
  20736. * @hidden
  20737. */
  20738. export interface IMaterialSubSurfaceDefines {
  20739. SUBSURFACE: boolean;
  20740. SS_REFRACTION: boolean;
  20741. SS_TRANSLUCENCY: boolean;
  20742. SS_SCATTERING: boolean;
  20743. SS_THICKNESSANDMASK_TEXTURE: boolean;
  20744. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  20745. SS_REFRACTIONMAP_3D: boolean;
  20746. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  20747. SS_LODINREFRACTIONALPHA: boolean;
  20748. SS_GAMMAREFRACTION: boolean;
  20749. SS_RGBDREFRACTION: boolean;
  20750. SS_LINEARSPECULARREFRACTION: boolean;
  20751. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  20752. SS_ALBEDOFORREFRACTIONTINT: boolean;
  20753. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  20754. SS_MASK_FROM_THICKNESS_TEXTURE_GLTF: boolean;
  20755. /** @hidden */
  20756. _areTexturesDirty: boolean;
  20757. }
  20758. /**
  20759. * Define the code related to the sub surface parameters of the pbr material.
  20760. */
  20761. export class PBRSubSurfaceConfiguration {
  20762. private _isRefractionEnabled;
  20763. /**
  20764. * Defines if the refraction is enabled in the material.
  20765. */
  20766. isRefractionEnabled: boolean;
  20767. private _isTranslucencyEnabled;
  20768. /**
  20769. * Defines if the translucency is enabled in the material.
  20770. */
  20771. isTranslucencyEnabled: boolean;
  20772. private _isScatteringEnabled;
  20773. /**
  20774. * Defines if the sub surface scattering is enabled in the material.
  20775. */
  20776. isScatteringEnabled: boolean;
  20777. private _scatteringDiffusionProfileIndex;
  20778. /**
  20779. * Diffusion profile for subsurface scattering.
  20780. * Useful for better scattering in the skins or foliages.
  20781. */
  20782. get scatteringDiffusionProfile(): Nullable<Color3>;
  20783. set scatteringDiffusionProfile(c: Nullable<Color3>);
  20784. /**
  20785. * Defines the refraction intensity of the material.
  20786. * The refraction when enabled replaces the Diffuse part of the material.
  20787. * The intensity helps transitionning between diffuse and refraction.
  20788. */
  20789. refractionIntensity: number;
  20790. /**
  20791. * Defines the translucency intensity of the material.
  20792. * When translucency has been enabled, this defines how much of the "translucency"
  20793. * is addded to the diffuse part of the material.
  20794. */
  20795. translucencyIntensity: number;
  20796. /**
  20797. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  20798. */
  20799. useAlbedoToTintRefraction: boolean;
  20800. private _thicknessTexture;
  20801. /**
  20802. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  20803. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  20804. * 0 would mean minimumThickness
  20805. * 1 would mean maximumThickness
  20806. * The other channels might be use as a mask to vary the different effects intensity.
  20807. */
  20808. thicknessTexture: Nullable<BaseTexture>;
  20809. private _refractionTexture;
  20810. /**
  20811. * Defines the texture to use for refraction.
  20812. */
  20813. refractionTexture: Nullable<BaseTexture>;
  20814. private _indexOfRefraction;
  20815. /**
  20816. * Index of refraction of the material base layer.
  20817. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  20818. *
  20819. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  20820. *
  20821. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  20822. */
  20823. indexOfRefraction: number;
  20824. private _volumeIndexOfRefraction;
  20825. /**
  20826. * Index of refraction of the material's volume.
  20827. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  20828. *
  20829. * This ONLY impacts refraction. If not provided or given a non-valid value,
  20830. * the volume will use the same IOR as the surface.
  20831. */
  20832. get volumeIndexOfRefraction(): number;
  20833. set volumeIndexOfRefraction(value: number);
  20834. private _invertRefractionY;
  20835. /**
  20836. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  20837. */
  20838. invertRefractionY: boolean;
  20839. private _linkRefractionWithTransparency;
  20840. /**
  20841. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  20842. * Materials half opaque for instance using refraction could benefit from this control.
  20843. */
  20844. linkRefractionWithTransparency: boolean;
  20845. /**
  20846. * Defines the minimum thickness stored in the thickness map.
  20847. * If no thickness map is defined, this value will be used to simulate thickness.
  20848. */
  20849. minimumThickness: number;
  20850. /**
  20851. * Defines the maximum thickness stored in the thickness map.
  20852. */
  20853. maximumThickness: number;
  20854. /**
  20855. * Defines the volume tint of the material.
  20856. * This is used for both translucency and scattering.
  20857. */
  20858. tintColor: Color3;
  20859. /**
  20860. * Defines the distance at which the tint color should be found in the media.
  20861. * This is used for refraction only.
  20862. */
  20863. tintColorAtDistance: number;
  20864. /**
  20865. * Defines how far each channel transmit through the media.
  20866. * It is defined as a color to simplify it selection.
  20867. */
  20868. diffusionDistance: Color3;
  20869. private _useMaskFromThicknessTexture;
  20870. /**
  20871. * Stores the intensity of the different subsurface effects in the thickness texture.
  20872. * * the green channel is the translucency intensity.
  20873. * * the blue channel is the scattering intensity.
  20874. * * the alpha channel is the refraction intensity.
  20875. */
  20876. useMaskFromThicknessTexture: boolean;
  20877. private _scene;
  20878. private _useMaskFromThicknessTextureGltf;
  20879. /**
  20880. * Stores the intensity of the different subsurface effects in the thickness texture. This variation
  20881. * matches the channel-packing that is used by glTF.
  20882. * * the red channel is the transmission/translucency intensity.
  20883. * * the green channel is the thickness.
  20884. */
  20885. useMaskFromThicknessTextureGltf: boolean;
  20886. /** @hidden */
  20887. private _internalMarkAllSubMeshesAsTexturesDirty;
  20888. private _internalMarkScenePrePassDirty;
  20889. /** @hidden */
  20890. _markAllSubMeshesAsTexturesDirty(): void;
  20891. /** @hidden */
  20892. _markScenePrePassDirty(): void;
  20893. /**
  20894. * Instantiate a new istance of sub surface configuration.
  20895. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  20896. * @param markScenePrePassDirty Callback to flag the scene as prepass dirty
  20897. * @param scene The scene
  20898. */
  20899. constructor(markAllSubMeshesAsTexturesDirty: () => void, markScenePrePassDirty: () => void, scene: Scene);
  20900. /**
  20901. * Gets wehter the submesh is ready to be used or not.
  20902. * @param defines the list of "defines" to update.
  20903. * @param scene defines the scene the material belongs to.
  20904. * @returns - boolean indicating that the submesh is ready or not.
  20905. */
  20906. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  20907. /**
  20908. * Checks to see if a texture is used in the material.
  20909. * @param defines the list of "defines" to update.
  20910. * @param scene defines the scene to the material belongs to.
  20911. */
  20912. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  20913. /**
  20914. * Binds the material data.
  20915. * @param uniformBuffer defines the Uniform buffer to fill in.
  20916. * @param scene defines the scene the material belongs to.
  20917. * @param engine defines the engine the material belongs to.
  20918. * @param isFrozen defines whether the material is frozen or not.
  20919. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  20920. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  20921. */
  20922. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  20923. /**
  20924. * Unbinds the material from the mesh.
  20925. * @param activeEffect defines the effect that should be unbound from.
  20926. * @returns true if unbound, otherwise false
  20927. */
  20928. unbind(activeEffect: Effect): boolean;
  20929. /**
  20930. * Returns the texture used for refraction or null if none is used.
  20931. * @param scene defines the scene the material belongs to.
  20932. * @returns - Refraction texture if present. If no refraction texture and refraction
  20933. * is linked with transparency, returns environment texture. Otherwise, returns null.
  20934. */
  20935. private _getRefractionTexture;
  20936. /**
  20937. * Returns true if alpha blending should be disabled.
  20938. */
  20939. get disableAlphaBlending(): boolean;
  20940. /**
  20941. * Fills the list of render target textures.
  20942. * @param renderTargets the list of render targets to update
  20943. */
  20944. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  20945. /**
  20946. * Checks to see if a texture is used in the material.
  20947. * @param texture - Base texture to use.
  20948. * @returns - Boolean specifying if a texture is used in the material.
  20949. */
  20950. hasTexture(texture: BaseTexture): boolean;
  20951. /**
  20952. * Gets a boolean indicating that current material needs to register RTT
  20953. * @returns true if this uses a render target otherwise false.
  20954. */
  20955. hasRenderTargetTextures(): boolean;
  20956. /**
  20957. * Returns an array of the actively used textures.
  20958. * @param activeTextures Array of BaseTextures
  20959. */
  20960. getActiveTextures(activeTextures: BaseTexture[]): void;
  20961. /**
  20962. * Returns the animatable textures.
  20963. * @param animatables Array of animatable textures.
  20964. */
  20965. getAnimatables(animatables: IAnimatable[]): void;
  20966. /**
  20967. * Disposes the resources of the material.
  20968. * @param forceDisposeTextures - Forces the disposal of all textures.
  20969. */
  20970. dispose(forceDisposeTextures?: boolean): void;
  20971. /**
  20972. * Get the current class name of the texture useful for serialization or dynamic coding.
  20973. * @returns "PBRSubSurfaceConfiguration"
  20974. */
  20975. getClassName(): string;
  20976. /**
  20977. * Add fallbacks to the effect fallbacks list.
  20978. * @param defines defines the Base texture to use.
  20979. * @param fallbacks defines the current fallback list.
  20980. * @param currentRank defines the current fallback rank.
  20981. * @returns the new fallback rank.
  20982. */
  20983. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  20984. /**
  20985. * Add the required uniforms to the current list.
  20986. * @param uniforms defines the current uniform list.
  20987. */
  20988. static AddUniforms(uniforms: string[]): void;
  20989. /**
  20990. * Add the required samplers to the current list.
  20991. * @param samplers defines the current sampler list.
  20992. */
  20993. static AddSamplers(samplers: string[]): void;
  20994. /**
  20995. * Add the required uniforms to the current buffer.
  20996. * @param uniformBuffer defines the current uniform buffer.
  20997. */
  20998. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  20999. /**
  21000. * Makes a duplicate of the current configuration into another one.
  21001. * @param configuration define the config where to copy the info
  21002. */
  21003. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  21004. /**
  21005. * Serializes this Sub Surface configuration.
  21006. * @returns - An object with the serialized config.
  21007. */
  21008. serialize(): any;
  21009. /**
  21010. * Parses a anisotropy Configuration from a serialized object.
  21011. * @param source - Serialized object.
  21012. * @param scene Defines the scene we are parsing for
  21013. * @param rootUrl Defines the rootUrl to load from
  21014. */
  21015. parse(source: any, scene: Scene, rootUrl: string): void;
  21016. }
  21017. }
  21018. declare module BABYLON {
  21019. /**
  21020. * Class representing spherical harmonics coefficients to the 3rd degree
  21021. */
  21022. export class SphericalHarmonics {
  21023. /**
  21024. * Defines whether or not the harmonics have been prescaled for rendering.
  21025. */
  21026. preScaled: boolean;
  21027. /**
  21028. * The l0,0 coefficients of the spherical harmonics
  21029. */
  21030. l00: Vector3;
  21031. /**
  21032. * The l1,-1 coefficients of the spherical harmonics
  21033. */
  21034. l1_1: Vector3;
  21035. /**
  21036. * The l1,0 coefficients of the spherical harmonics
  21037. */
  21038. l10: Vector3;
  21039. /**
  21040. * The l1,1 coefficients of the spherical harmonics
  21041. */
  21042. l11: Vector3;
  21043. /**
  21044. * The l2,-2 coefficients of the spherical harmonics
  21045. */
  21046. l2_2: Vector3;
  21047. /**
  21048. * The l2,-1 coefficients of the spherical harmonics
  21049. */
  21050. l2_1: Vector3;
  21051. /**
  21052. * The l2,0 coefficients of the spherical harmonics
  21053. */
  21054. l20: Vector3;
  21055. /**
  21056. * The l2,1 coefficients of the spherical harmonics
  21057. */
  21058. l21: Vector3;
  21059. /**
  21060. * The l2,2 coefficients of the spherical harmonics
  21061. */
  21062. l22: Vector3;
  21063. /**
  21064. * Adds a light to the spherical harmonics
  21065. * @param direction the direction of the light
  21066. * @param color the color of the light
  21067. * @param deltaSolidAngle the delta solid angle of the light
  21068. */
  21069. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  21070. /**
  21071. * Scales the spherical harmonics by the given amount
  21072. * @param scale the amount to scale
  21073. */
  21074. scaleInPlace(scale: number): void;
  21075. /**
  21076. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  21077. *
  21078. * ```
  21079. * E_lm = A_l * L_lm
  21080. * ```
  21081. *
  21082. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  21083. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  21084. * the scaling factors are given in equation 9.
  21085. */
  21086. convertIncidentRadianceToIrradiance(): void;
  21087. /**
  21088. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  21089. *
  21090. * ```
  21091. * L = (1/pi) * E * rho
  21092. * ```
  21093. *
  21094. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  21095. */
  21096. convertIrradianceToLambertianRadiance(): void;
  21097. /**
  21098. * Integrates the reconstruction coefficients directly in to the SH preventing further
  21099. * required operations at run time.
  21100. *
  21101. * This is simply done by scaling back the SH with Ylm constants parameter.
  21102. * The trigonometric part being applied by the shader at run time.
  21103. */
  21104. preScaleForRendering(): void;
  21105. /**
  21106. * Constructs a spherical harmonics from an array.
  21107. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  21108. * @returns the spherical harmonics
  21109. */
  21110. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  21111. /**
  21112. * Gets the spherical harmonics from polynomial
  21113. * @param polynomial the spherical polynomial
  21114. * @returns the spherical harmonics
  21115. */
  21116. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  21117. }
  21118. /**
  21119. * Class representing spherical polynomial coefficients to the 3rd degree
  21120. */
  21121. export class SphericalPolynomial {
  21122. private _harmonics;
  21123. /**
  21124. * The spherical harmonics used to create the polynomials.
  21125. */
  21126. get preScaledHarmonics(): SphericalHarmonics;
  21127. /**
  21128. * The x coefficients of the spherical polynomial
  21129. */
  21130. x: Vector3;
  21131. /**
  21132. * The y coefficients of the spherical polynomial
  21133. */
  21134. y: Vector3;
  21135. /**
  21136. * The z coefficients of the spherical polynomial
  21137. */
  21138. z: Vector3;
  21139. /**
  21140. * The xx coefficients of the spherical polynomial
  21141. */
  21142. xx: Vector3;
  21143. /**
  21144. * The yy coefficients of the spherical polynomial
  21145. */
  21146. yy: Vector3;
  21147. /**
  21148. * The zz coefficients of the spherical polynomial
  21149. */
  21150. zz: Vector3;
  21151. /**
  21152. * The xy coefficients of the spherical polynomial
  21153. */
  21154. xy: Vector3;
  21155. /**
  21156. * The yz coefficients of the spherical polynomial
  21157. */
  21158. yz: Vector3;
  21159. /**
  21160. * The zx coefficients of the spherical polynomial
  21161. */
  21162. zx: Vector3;
  21163. /**
  21164. * Adds an ambient color to the spherical polynomial
  21165. * @param color the color to add
  21166. */
  21167. addAmbient(color: Color3): void;
  21168. /**
  21169. * Scales the spherical polynomial by the given amount
  21170. * @param scale the amount to scale
  21171. */
  21172. scaleInPlace(scale: number): void;
  21173. /**
  21174. * Gets the spherical polynomial from harmonics
  21175. * @param harmonics the spherical harmonics
  21176. * @returns the spherical polynomial
  21177. */
  21178. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  21179. /**
  21180. * Constructs a spherical polynomial from an array.
  21181. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  21182. * @returns the spherical polynomial
  21183. */
  21184. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  21185. }
  21186. }
  21187. declare module BABYLON {
  21188. /**
  21189. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  21190. */
  21191. export interface CubeMapInfo {
  21192. /**
  21193. * The pixel array for the front face.
  21194. * This is stored in format, left to right, up to down format.
  21195. */
  21196. front: Nullable<ArrayBufferView>;
  21197. /**
  21198. * The pixel array for the back face.
  21199. * This is stored in format, left to right, up to down format.
  21200. */
  21201. back: Nullable<ArrayBufferView>;
  21202. /**
  21203. * The pixel array for the left face.
  21204. * This is stored in format, left to right, up to down format.
  21205. */
  21206. left: Nullable<ArrayBufferView>;
  21207. /**
  21208. * The pixel array for the right face.
  21209. * This is stored in format, left to right, up to down format.
  21210. */
  21211. right: Nullable<ArrayBufferView>;
  21212. /**
  21213. * The pixel array for the up face.
  21214. * This is stored in format, left to right, up to down format.
  21215. */
  21216. up: Nullable<ArrayBufferView>;
  21217. /**
  21218. * The pixel array for the down face.
  21219. * This is stored in format, left to right, up to down format.
  21220. */
  21221. down: Nullable<ArrayBufferView>;
  21222. /**
  21223. * The size of the cubemap stored.
  21224. *
  21225. * Each faces will be size * size pixels.
  21226. */
  21227. size: number;
  21228. /**
  21229. * The format of the texture.
  21230. *
  21231. * RGBA, RGB.
  21232. */
  21233. format: number;
  21234. /**
  21235. * The type of the texture data.
  21236. *
  21237. * UNSIGNED_INT, FLOAT.
  21238. */
  21239. type: number;
  21240. /**
  21241. * Specifies whether the texture is in gamma space.
  21242. */
  21243. gammaSpace: boolean;
  21244. }
  21245. /**
  21246. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  21247. */
  21248. export class PanoramaToCubeMapTools {
  21249. private static FACE_LEFT;
  21250. private static FACE_RIGHT;
  21251. private static FACE_FRONT;
  21252. private static FACE_BACK;
  21253. private static FACE_DOWN;
  21254. private static FACE_UP;
  21255. /**
  21256. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  21257. *
  21258. * @param float32Array The source data.
  21259. * @param inputWidth The width of the input panorama.
  21260. * @param inputHeight The height of the input panorama.
  21261. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  21262. * @return The cubemap data
  21263. */
  21264. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  21265. private static CreateCubemapTexture;
  21266. private static CalcProjectionSpherical;
  21267. }
  21268. }
  21269. declare module BABYLON {
  21270. /**
  21271. * Helper class dealing with the extraction of spherical polynomial dataArray
  21272. * from a cube map.
  21273. */
  21274. export class CubeMapToSphericalPolynomialTools {
  21275. private static FileFaces;
  21276. /**
  21277. * Converts a texture to the according Spherical Polynomial data.
  21278. * This extracts the first 3 orders only as they are the only one used in the lighting.
  21279. *
  21280. * @param texture The texture to extract the information from.
  21281. * @return The Spherical Polynomial data.
  21282. */
  21283. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<Promise<SphericalPolynomial>>;
  21284. /**
  21285. * Converts a cubemap to the according Spherical Polynomial data.
  21286. * This extracts the first 3 orders only as they are the only one used in the lighting.
  21287. *
  21288. * @param cubeInfo The Cube map to extract the information from.
  21289. * @return The Spherical Polynomial data.
  21290. */
  21291. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  21292. }
  21293. }
  21294. declare module BABYLON {
  21295. interface BaseTexture {
  21296. /**
  21297. * Get the polynomial representation of the texture data.
  21298. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  21299. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  21300. */
  21301. sphericalPolynomial: Nullable<SphericalPolynomial>;
  21302. }
  21303. }
  21304. declare module BABYLON {
  21305. /** @hidden */
  21306. export var pbrFragmentDeclaration: {
  21307. name: string;
  21308. shader: string;
  21309. };
  21310. }
  21311. declare module BABYLON {
  21312. /** @hidden */
  21313. export var pbrUboDeclaration: {
  21314. name: string;
  21315. shader: string;
  21316. };
  21317. }
  21318. declare module BABYLON {
  21319. /** @hidden */
  21320. export var pbrFragmentExtraDeclaration: {
  21321. name: string;
  21322. shader: string;
  21323. };
  21324. }
  21325. declare module BABYLON {
  21326. /** @hidden */
  21327. export var pbrFragmentSamplersDeclaration: {
  21328. name: string;
  21329. shader: string;
  21330. };
  21331. }
  21332. declare module BABYLON {
  21333. /** @hidden */
  21334. export var subSurfaceScatteringFunctions: {
  21335. name: string;
  21336. shader: string;
  21337. };
  21338. }
  21339. declare module BABYLON {
  21340. /** @hidden */
  21341. export var importanceSampling: {
  21342. name: string;
  21343. shader: string;
  21344. };
  21345. }
  21346. declare module BABYLON {
  21347. /** @hidden */
  21348. export var pbrHelperFunctions: {
  21349. name: string;
  21350. shader: string;
  21351. };
  21352. }
  21353. declare module BABYLON {
  21354. /** @hidden */
  21355. export var harmonicsFunctions: {
  21356. name: string;
  21357. shader: string;
  21358. };
  21359. }
  21360. declare module BABYLON {
  21361. /** @hidden */
  21362. export var pbrDirectLightingSetupFunctions: {
  21363. name: string;
  21364. shader: string;
  21365. };
  21366. }
  21367. declare module BABYLON {
  21368. /** @hidden */
  21369. export var pbrDirectLightingFalloffFunctions: {
  21370. name: string;
  21371. shader: string;
  21372. };
  21373. }
  21374. declare module BABYLON {
  21375. /** @hidden */
  21376. export var pbrBRDFFunctions: {
  21377. name: string;
  21378. shader: string;
  21379. };
  21380. }
  21381. declare module BABYLON {
  21382. /** @hidden */
  21383. export var hdrFilteringFunctions: {
  21384. name: string;
  21385. shader: string;
  21386. };
  21387. }
  21388. declare module BABYLON {
  21389. /** @hidden */
  21390. export var pbrDirectLightingFunctions: {
  21391. name: string;
  21392. shader: string;
  21393. };
  21394. }
  21395. declare module BABYLON {
  21396. /** @hidden */
  21397. export var pbrIBLFunctions: {
  21398. name: string;
  21399. shader: string;
  21400. };
  21401. }
  21402. declare module BABYLON {
  21403. /** @hidden */
  21404. export var pbrBlockAlbedoOpacity: {
  21405. name: string;
  21406. shader: string;
  21407. };
  21408. }
  21409. declare module BABYLON {
  21410. /** @hidden */
  21411. export var pbrBlockReflectivity: {
  21412. name: string;
  21413. shader: string;
  21414. };
  21415. }
  21416. declare module BABYLON {
  21417. /** @hidden */
  21418. export var pbrBlockAmbientOcclusion: {
  21419. name: string;
  21420. shader: string;
  21421. };
  21422. }
  21423. declare module BABYLON {
  21424. /** @hidden */
  21425. export var pbrBlockAlphaFresnel: {
  21426. name: string;
  21427. shader: string;
  21428. };
  21429. }
  21430. declare module BABYLON {
  21431. /** @hidden */
  21432. export var pbrBlockAnisotropic: {
  21433. name: string;
  21434. shader: string;
  21435. };
  21436. }
  21437. declare module BABYLON {
  21438. /** @hidden */
  21439. export var pbrBlockReflection: {
  21440. name: string;
  21441. shader: string;
  21442. };
  21443. }
  21444. declare module BABYLON {
  21445. /** @hidden */
  21446. export var pbrBlockSheen: {
  21447. name: string;
  21448. shader: string;
  21449. };
  21450. }
  21451. declare module BABYLON {
  21452. /** @hidden */
  21453. export var pbrBlockClearcoat: {
  21454. name: string;
  21455. shader: string;
  21456. };
  21457. }
  21458. declare module BABYLON {
  21459. /** @hidden */
  21460. export var pbrBlockSubSurface: {
  21461. name: string;
  21462. shader: string;
  21463. };
  21464. }
  21465. declare module BABYLON {
  21466. /** @hidden */
  21467. export var pbrBlockNormalGeometric: {
  21468. name: string;
  21469. shader: string;
  21470. };
  21471. }
  21472. declare module BABYLON {
  21473. /** @hidden */
  21474. export var pbrBlockNormalFinal: {
  21475. name: string;
  21476. shader: string;
  21477. };
  21478. }
  21479. declare module BABYLON {
  21480. /** @hidden */
  21481. export var pbrBlockLightmapInit: {
  21482. name: string;
  21483. shader: string;
  21484. };
  21485. }
  21486. declare module BABYLON {
  21487. /** @hidden */
  21488. export var pbrBlockGeometryInfo: {
  21489. name: string;
  21490. shader: string;
  21491. };
  21492. }
  21493. declare module BABYLON {
  21494. /** @hidden */
  21495. export var pbrBlockReflectance0: {
  21496. name: string;
  21497. shader: string;
  21498. };
  21499. }
  21500. declare module BABYLON {
  21501. /** @hidden */
  21502. export var pbrBlockReflectance: {
  21503. name: string;
  21504. shader: string;
  21505. };
  21506. }
  21507. declare module BABYLON {
  21508. /** @hidden */
  21509. export var pbrBlockDirectLighting: {
  21510. name: string;
  21511. shader: string;
  21512. };
  21513. }
  21514. declare module BABYLON {
  21515. /** @hidden */
  21516. export var pbrBlockFinalLitComponents: {
  21517. name: string;
  21518. shader: string;
  21519. };
  21520. }
  21521. declare module BABYLON {
  21522. /** @hidden */
  21523. export var pbrBlockFinalUnlitComponents: {
  21524. name: string;
  21525. shader: string;
  21526. };
  21527. }
  21528. declare module BABYLON {
  21529. /** @hidden */
  21530. export var pbrBlockFinalColorComposition: {
  21531. name: string;
  21532. shader: string;
  21533. };
  21534. }
  21535. declare module BABYLON {
  21536. /** @hidden */
  21537. export var pbrBlockImageProcessing: {
  21538. name: string;
  21539. shader: string;
  21540. };
  21541. }
  21542. declare module BABYLON {
  21543. /** @hidden */
  21544. export var pbrDebug: {
  21545. name: string;
  21546. shader: string;
  21547. };
  21548. }
  21549. declare module BABYLON {
  21550. /** @hidden */
  21551. export var pbrPixelShader: {
  21552. name: string;
  21553. shader: string;
  21554. };
  21555. }
  21556. declare module BABYLON {
  21557. /** @hidden */
  21558. export var pbrVertexDeclaration: {
  21559. name: string;
  21560. shader: string;
  21561. };
  21562. }
  21563. declare module BABYLON {
  21564. /** @hidden */
  21565. export var pbrVertexShader: {
  21566. name: string;
  21567. shader: string;
  21568. };
  21569. }
  21570. declare module BABYLON {
  21571. /**
  21572. * Manages the defines for the PBR Material.
  21573. * @hidden
  21574. */
  21575. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  21576. PBR: boolean;
  21577. NUM_SAMPLES: string;
  21578. REALTIME_FILTERING: boolean;
  21579. MAINUV1: boolean;
  21580. MAINUV2: boolean;
  21581. UV1: boolean;
  21582. UV2: boolean;
  21583. ALBEDO: boolean;
  21584. GAMMAALBEDO: boolean;
  21585. ALBEDODIRECTUV: number;
  21586. VERTEXCOLOR: boolean;
  21587. DETAIL: boolean;
  21588. DETAILDIRECTUV: number;
  21589. DETAIL_NORMALBLENDMETHOD: number;
  21590. AMBIENT: boolean;
  21591. AMBIENTDIRECTUV: number;
  21592. AMBIENTINGRAYSCALE: boolean;
  21593. OPACITY: boolean;
  21594. VERTEXALPHA: boolean;
  21595. OPACITYDIRECTUV: number;
  21596. OPACITYRGB: boolean;
  21597. ALPHATEST: boolean;
  21598. DEPTHPREPASS: boolean;
  21599. ALPHABLEND: boolean;
  21600. ALPHAFROMALBEDO: boolean;
  21601. ALPHATESTVALUE: string;
  21602. SPECULAROVERALPHA: boolean;
  21603. RADIANCEOVERALPHA: boolean;
  21604. ALPHAFRESNEL: boolean;
  21605. LINEARALPHAFRESNEL: boolean;
  21606. PREMULTIPLYALPHA: boolean;
  21607. EMISSIVE: boolean;
  21608. EMISSIVEDIRECTUV: number;
  21609. REFLECTIVITY: boolean;
  21610. REFLECTIVITYDIRECTUV: number;
  21611. SPECULARTERM: boolean;
  21612. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  21613. MICROSURFACEAUTOMATIC: boolean;
  21614. LODBASEDMICROSFURACE: boolean;
  21615. MICROSURFACEMAP: boolean;
  21616. MICROSURFACEMAPDIRECTUV: number;
  21617. METALLICWORKFLOW: boolean;
  21618. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  21619. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  21620. METALLNESSSTOREINMETALMAPBLUE: boolean;
  21621. AOSTOREINMETALMAPRED: boolean;
  21622. METALLIC_REFLECTANCE: boolean;
  21623. METALLIC_REFLECTANCEDIRECTUV: number;
  21624. ENVIRONMENTBRDF: boolean;
  21625. ENVIRONMENTBRDF_RGBD: boolean;
  21626. NORMAL: boolean;
  21627. TANGENT: boolean;
  21628. BUMP: boolean;
  21629. BUMPDIRECTUV: number;
  21630. OBJECTSPACE_NORMALMAP: boolean;
  21631. PARALLAX: boolean;
  21632. PARALLAXOCCLUSION: boolean;
  21633. NORMALXYSCALE: boolean;
  21634. LIGHTMAP: boolean;
  21635. LIGHTMAPDIRECTUV: number;
  21636. USELIGHTMAPASSHADOWMAP: boolean;
  21637. GAMMALIGHTMAP: boolean;
  21638. RGBDLIGHTMAP: boolean;
  21639. REFLECTION: boolean;
  21640. REFLECTIONMAP_3D: boolean;
  21641. REFLECTIONMAP_SPHERICAL: boolean;
  21642. REFLECTIONMAP_PLANAR: boolean;
  21643. REFLECTIONMAP_CUBIC: boolean;
  21644. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  21645. REFLECTIONMAP_PROJECTION: boolean;
  21646. REFLECTIONMAP_SKYBOX: boolean;
  21647. REFLECTIONMAP_EXPLICIT: boolean;
  21648. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  21649. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  21650. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  21651. INVERTCUBICMAP: boolean;
  21652. USESPHERICALFROMREFLECTIONMAP: boolean;
  21653. USEIRRADIANCEMAP: boolean;
  21654. SPHERICAL_HARMONICS: boolean;
  21655. USESPHERICALINVERTEX: boolean;
  21656. REFLECTIONMAP_OPPOSITEZ: boolean;
  21657. LODINREFLECTIONALPHA: boolean;
  21658. GAMMAREFLECTION: boolean;
  21659. RGBDREFLECTION: boolean;
  21660. LINEARSPECULARREFLECTION: boolean;
  21661. RADIANCEOCCLUSION: boolean;
  21662. HORIZONOCCLUSION: boolean;
  21663. INSTANCES: boolean;
  21664. THIN_INSTANCES: boolean;
  21665. PREPASS: boolean;
  21666. PREPASS_IRRADIANCE: boolean;
  21667. PREPASS_IRRADIANCE_INDEX: number;
  21668. PREPASS_ALBEDO: boolean;
  21669. PREPASS_ALBEDO_INDEX: number;
  21670. PREPASS_DEPTHNORMAL: boolean;
  21671. PREPASS_DEPTHNORMAL_INDEX: number;
  21672. PREPASS_POSITION: boolean;
  21673. PREPASS_POSITION_INDEX: number;
  21674. PREPASS_VELOCITY: boolean;
  21675. PREPASS_VELOCITY_INDEX: number;
  21676. PREPASS_REFLECTIVITY: boolean;
  21677. PREPASS_REFLECTIVITY_INDEX: number;
  21678. SCENE_MRT_COUNT: number;
  21679. NUM_BONE_INFLUENCERS: number;
  21680. BonesPerMesh: number;
  21681. BONETEXTURE: boolean;
  21682. BONES_VELOCITY_ENABLED: boolean;
  21683. NONUNIFORMSCALING: boolean;
  21684. MORPHTARGETS: boolean;
  21685. MORPHTARGETS_NORMAL: boolean;
  21686. MORPHTARGETS_TANGENT: boolean;
  21687. MORPHTARGETS_UV: boolean;
  21688. NUM_MORPH_INFLUENCERS: number;
  21689. IMAGEPROCESSING: boolean;
  21690. VIGNETTE: boolean;
  21691. VIGNETTEBLENDMODEMULTIPLY: boolean;
  21692. VIGNETTEBLENDMODEOPAQUE: boolean;
  21693. TONEMAPPING: boolean;
  21694. TONEMAPPING_ACES: boolean;
  21695. CONTRAST: boolean;
  21696. COLORCURVES: boolean;
  21697. COLORGRADING: boolean;
  21698. COLORGRADING3D: boolean;
  21699. SAMPLER3DGREENDEPTH: boolean;
  21700. SAMPLER3DBGRMAP: boolean;
  21701. IMAGEPROCESSINGPOSTPROCESS: boolean;
  21702. EXPOSURE: boolean;
  21703. MULTIVIEW: boolean;
  21704. USEPHYSICALLIGHTFALLOFF: boolean;
  21705. USEGLTFLIGHTFALLOFF: boolean;
  21706. TWOSIDEDLIGHTING: boolean;
  21707. SHADOWFLOAT: boolean;
  21708. CLIPPLANE: boolean;
  21709. CLIPPLANE2: boolean;
  21710. CLIPPLANE3: boolean;
  21711. CLIPPLANE4: boolean;
  21712. CLIPPLANE5: boolean;
  21713. CLIPPLANE6: boolean;
  21714. POINTSIZE: boolean;
  21715. FOG: boolean;
  21716. LOGARITHMICDEPTH: boolean;
  21717. FORCENORMALFORWARD: boolean;
  21718. SPECULARAA: boolean;
  21719. CLEARCOAT: boolean;
  21720. CLEARCOAT_DEFAULTIOR: boolean;
  21721. CLEARCOAT_TEXTURE: boolean;
  21722. CLEARCOAT_TEXTURE_ROUGHNESS: boolean;
  21723. CLEARCOAT_TEXTUREDIRECTUV: number;
  21724. CLEARCOAT_TEXTURE_ROUGHNESSDIRECTUV: number;
  21725. CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  21726. CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  21727. CLEARCOAT_BUMP: boolean;
  21728. CLEARCOAT_BUMPDIRECTUV: number;
  21729. CLEARCOAT_REMAP_F0: boolean;
  21730. CLEARCOAT_TINT: boolean;
  21731. CLEARCOAT_TINT_TEXTURE: boolean;
  21732. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  21733. ANISOTROPIC: boolean;
  21734. ANISOTROPIC_TEXTURE: boolean;
  21735. ANISOTROPIC_TEXTUREDIRECTUV: number;
  21736. BRDF_V_HEIGHT_CORRELATED: boolean;
  21737. MS_BRDF_ENERGY_CONSERVATION: boolean;
  21738. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  21739. SHEEN: boolean;
  21740. SHEEN_TEXTURE: boolean;
  21741. SHEEN_TEXTURE_ROUGHNESS: boolean;
  21742. SHEEN_TEXTUREDIRECTUV: number;
  21743. SHEEN_TEXTURE_ROUGHNESSDIRECTUV: number;
  21744. SHEEN_LINKWITHALBEDO: boolean;
  21745. SHEEN_ROUGHNESS: boolean;
  21746. SHEEN_ALBEDOSCALING: boolean;
  21747. SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  21748. SHEEN_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  21749. SUBSURFACE: boolean;
  21750. SS_REFRACTION: boolean;
  21751. SS_TRANSLUCENCY: boolean;
  21752. SS_SCATTERING: boolean;
  21753. SS_THICKNESSANDMASK_TEXTURE: boolean;
  21754. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  21755. SS_REFRACTIONMAP_3D: boolean;
  21756. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  21757. SS_LODINREFRACTIONALPHA: boolean;
  21758. SS_GAMMAREFRACTION: boolean;
  21759. SS_RGBDREFRACTION: boolean;
  21760. SS_LINEARSPECULARREFRACTION: boolean;
  21761. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  21762. SS_ALBEDOFORREFRACTIONTINT: boolean;
  21763. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  21764. SS_MASK_FROM_THICKNESS_TEXTURE_GLTF: boolean;
  21765. UNLIT: boolean;
  21766. DEBUGMODE: number;
  21767. /**
  21768. * Initializes the PBR Material defines.
  21769. */
  21770. constructor();
  21771. /**
  21772. * Resets the PBR Material defines.
  21773. */
  21774. reset(): void;
  21775. }
  21776. /**
  21777. * The Physically based material base class of BJS.
  21778. *
  21779. * This offers the main features of a standard PBR material.
  21780. * For more information, please refer to the documentation :
  21781. * https://doc.babylonjs.com/how_to/physically_based_rendering
  21782. */
  21783. export abstract class PBRBaseMaterial extends PushMaterial {
  21784. /**
  21785. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  21786. */
  21787. static readonly PBRMATERIAL_OPAQUE: number;
  21788. /**
  21789. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  21790. */
  21791. static readonly PBRMATERIAL_ALPHATEST: number;
  21792. /**
  21793. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  21794. */
  21795. static readonly PBRMATERIAL_ALPHABLEND: number;
  21796. /**
  21797. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  21798. * They are also discarded below the alpha cutoff threshold to improve performances.
  21799. */
  21800. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  21801. /**
  21802. * Defines the default value of how much AO map is occluding the analytical lights
  21803. * (point spot...).
  21804. */
  21805. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  21806. /**
  21807. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  21808. */
  21809. static readonly LIGHTFALLOFF_PHYSICAL: number;
  21810. /**
  21811. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  21812. * to enhance interoperability with other engines.
  21813. */
  21814. static readonly LIGHTFALLOFF_GLTF: number;
  21815. /**
  21816. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  21817. * to enhance interoperability with other materials.
  21818. */
  21819. static readonly LIGHTFALLOFF_STANDARD: number;
  21820. /**
  21821. * Intensity of the direct lights e.g. the four lights available in your scene.
  21822. * This impacts both the direct diffuse and specular highlights.
  21823. */
  21824. protected _directIntensity: number;
  21825. /**
  21826. * Intensity of the emissive part of the material.
  21827. * This helps controlling the emissive effect without modifying the emissive color.
  21828. */
  21829. protected _emissiveIntensity: number;
  21830. /**
  21831. * Intensity of the environment e.g. how much the environment will light the object
  21832. * either through harmonics for rough material or through the refelction for shiny ones.
  21833. */
  21834. protected _environmentIntensity: number;
  21835. /**
  21836. * This is a special control allowing the reduction of the specular highlights coming from the
  21837. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  21838. */
  21839. protected _specularIntensity: number;
  21840. /**
  21841. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  21842. */
  21843. private _lightingInfos;
  21844. /**
  21845. * Debug Control allowing disabling the bump map on this material.
  21846. */
  21847. protected _disableBumpMap: boolean;
  21848. /**
  21849. * AKA Diffuse Texture in standard nomenclature.
  21850. */
  21851. protected _albedoTexture: Nullable<BaseTexture>;
  21852. /**
  21853. * AKA Occlusion Texture in other nomenclature.
  21854. */
  21855. protected _ambientTexture: Nullable<BaseTexture>;
  21856. /**
  21857. * AKA Occlusion Texture Intensity in other nomenclature.
  21858. */
  21859. protected _ambientTextureStrength: number;
  21860. /**
  21861. * Defines how much the AO map is occluding the analytical lights (point spot...).
  21862. * 1 means it completely occludes it
  21863. * 0 mean it has no impact
  21864. */
  21865. protected _ambientTextureImpactOnAnalyticalLights: number;
  21866. /**
  21867. * Stores the alpha values in a texture.
  21868. */
  21869. protected _opacityTexture: Nullable<BaseTexture>;
  21870. /**
  21871. * Stores the reflection values in a texture.
  21872. */
  21873. protected _reflectionTexture: Nullable<BaseTexture>;
  21874. /**
  21875. * Stores the emissive values in a texture.
  21876. */
  21877. protected _emissiveTexture: Nullable<BaseTexture>;
  21878. /**
  21879. * AKA Specular texture in other nomenclature.
  21880. */
  21881. protected _reflectivityTexture: Nullable<BaseTexture>;
  21882. /**
  21883. * Used to switch from specular/glossiness to metallic/roughness workflow.
  21884. */
  21885. protected _metallicTexture: Nullable<BaseTexture>;
  21886. /**
  21887. * Specifies the metallic scalar of the metallic/roughness workflow.
  21888. * Can also be used to scale the metalness values of the metallic texture.
  21889. */
  21890. protected _metallic: Nullable<number>;
  21891. /**
  21892. * Specifies the roughness scalar of the metallic/roughness workflow.
  21893. * Can also be used to scale the roughness values of the metallic texture.
  21894. */
  21895. protected _roughness: Nullable<number>;
  21896. /**
  21897. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  21898. * By default the indexOfrefraction is used to compute F0;
  21899. *
  21900. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  21901. *
  21902. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  21903. * F90 = metallicReflectanceColor;
  21904. */
  21905. protected _metallicF0Factor: number;
  21906. /**
  21907. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  21908. * By default the F90 is always 1;
  21909. *
  21910. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  21911. *
  21912. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  21913. * F90 = metallicReflectanceColor;
  21914. */
  21915. protected _metallicReflectanceColor: Color3;
  21916. /**
  21917. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  21918. * This is multiply against the scalar values defined in the material.
  21919. */
  21920. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  21921. /**
  21922. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  21923. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  21924. */
  21925. protected _microSurfaceTexture: Nullable<BaseTexture>;
  21926. /**
  21927. * Stores surface normal data used to displace a mesh in a texture.
  21928. */
  21929. protected _bumpTexture: Nullable<BaseTexture>;
  21930. /**
  21931. * Stores the pre-calculated light information of a mesh in a texture.
  21932. */
  21933. protected _lightmapTexture: Nullable<BaseTexture>;
  21934. /**
  21935. * The color of a material in ambient lighting.
  21936. */
  21937. protected _ambientColor: Color3;
  21938. /**
  21939. * AKA Diffuse Color in other nomenclature.
  21940. */
  21941. protected _albedoColor: Color3;
  21942. /**
  21943. * AKA Specular Color in other nomenclature.
  21944. */
  21945. protected _reflectivityColor: Color3;
  21946. /**
  21947. * The color applied when light is reflected from a material.
  21948. */
  21949. protected _reflectionColor: Color3;
  21950. /**
  21951. * The color applied when light is emitted from a material.
  21952. */
  21953. protected _emissiveColor: Color3;
  21954. /**
  21955. * AKA Glossiness in other nomenclature.
  21956. */
  21957. protected _microSurface: number;
  21958. /**
  21959. * Specifies that the material will use the light map as a show map.
  21960. */
  21961. protected _useLightmapAsShadowmap: boolean;
  21962. /**
  21963. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  21964. * makes the reflect vector face the model (under horizon).
  21965. */
  21966. protected _useHorizonOcclusion: boolean;
  21967. /**
  21968. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  21969. * too much the area relying on ambient texture to define their ambient occlusion.
  21970. */
  21971. protected _useRadianceOcclusion: boolean;
  21972. /**
  21973. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  21974. */
  21975. protected _useAlphaFromAlbedoTexture: boolean;
  21976. /**
  21977. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  21978. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  21979. */
  21980. protected _useSpecularOverAlpha: boolean;
  21981. /**
  21982. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  21983. */
  21984. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  21985. /**
  21986. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  21987. */
  21988. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  21989. /**
  21990. * Specifies if the metallic texture contains the roughness information in its green channel.
  21991. */
  21992. protected _useRoughnessFromMetallicTextureGreen: boolean;
  21993. /**
  21994. * Specifies if the metallic texture contains the metallness information in its blue channel.
  21995. */
  21996. protected _useMetallnessFromMetallicTextureBlue: boolean;
  21997. /**
  21998. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  21999. */
  22000. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  22001. /**
  22002. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  22003. */
  22004. protected _useAmbientInGrayScale: boolean;
  22005. /**
  22006. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  22007. * The material will try to infer what glossiness each pixel should be.
  22008. */
  22009. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  22010. /**
  22011. * Defines the falloff type used in this material.
  22012. * It by default is Physical.
  22013. */
  22014. protected _lightFalloff: number;
  22015. /**
  22016. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  22017. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  22018. */
  22019. protected _useRadianceOverAlpha: boolean;
  22020. /**
  22021. * Allows using an object space normal map (instead of tangent space).
  22022. */
  22023. protected _useObjectSpaceNormalMap: boolean;
  22024. /**
  22025. * Allows using the bump map in parallax mode.
  22026. */
  22027. protected _useParallax: boolean;
  22028. /**
  22029. * Allows using the bump map in parallax occlusion mode.
  22030. */
  22031. protected _useParallaxOcclusion: boolean;
  22032. /**
  22033. * Controls the scale bias of the parallax mode.
  22034. */
  22035. protected _parallaxScaleBias: number;
  22036. /**
  22037. * If sets to true, disables all the lights affecting the material.
  22038. */
  22039. protected _disableLighting: boolean;
  22040. /**
  22041. * Number of Simultaneous lights allowed on the material.
  22042. */
  22043. protected _maxSimultaneousLights: number;
  22044. /**
  22045. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  22046. */
  22047. protected _invertNormalMapX: boolean;
  22048. /**
  22049. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  22050. */
  22051. protected _invertNormalMapY: boolean;
  22052. /**
  22053. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  22054. */
  22055. protected _twoSidedLighting: boolean;
  22056. /**
  22057. * Defines the alpha limits in alpha test mode.
  22058. */
  22059. protected _alphaCutOff: number;
  22060. /**
  22061. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  22062. */
  22063. protected _forceAlphaTest: boolean;
  22064. /**
  22065. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  22066. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  22067. */
  22068. protected _useAlphaFresnel: boolean;
  22069. /**
  22070. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  22071. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  22072. */
  22073. protected _useLinearAlphaFresnel: boolean;
  22074. /**
  22075. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  22076. * from cos thetav and roughness:
  22077. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  22078. */
  22079. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  22080. /**
  22081. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  22082. */
  22083. protected _forceIrradianceInFragment: boolean;
  22084. private _realTimeFiltering;
  22085. /**
  22086. * Enables realtime filtering on the texture.
  22087. */
  22088. get realTimeFiltering(): boolean;
  22089. set realTimeFiltering(b: boolean);
  22090. private _realTimeFilteringQuality;
  22091. /**
  22092. * Quality switch for realtime filtering
  22093. */
  22094. get realTimeFilteringQuality(): number;
  22095. set realTimeFilteringQuality(n: number);
  22096. /**
  22097. * Can this material render to several textures at once
  22098. */
  22099. get canRenderToMRT(): boolean;
  22100. /**
  22101. * Force normal to face away from face.
  22102. */
  22103. protected _forceNormalForward: boolean;
  22104. /**
  22105. * Enables specular anti aliasing in the PBR shader.
  22106. * It will both interacts on the Geometry for analytical and IBL lighting.
  22107. * It also prefilter the roughness map based on the bump values.
  22108. */
  22109. protected _enableSpecularAntiAliasing: boolean;
  22110. /**
  22111. * Default configuration related to image processing available in the PBR Material.
  22112. */
  22113. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  22114. /**
  22115. * Keep track of the image processing observer to allow dispose and replace.
  22116. */
  22117. private _imageProcessingObserver;
  22118. /**
  22119. * Attaches a new image processing configuration to the PBR Material.
  22120. * @param configuration
  22121. */
  22122. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  22123. /**
  22124. * Stores the available render targets.
  22125. */
  22126. private _renderTargets;
  22127. /**
  22128. * Sets the global ambient color for the material used in lighting calculations.
  22129. */
  22130. private _globalAmbientColor;
  22131. /**
  22132. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  22133. */
  22134. private _useLogarithmicDepth;
  22135. /**
  22136. * If set to true, no lighting calculations will be applied.
  22137. */
  22138. private _unlit;
  22139. private _debugMode;
  22140. /**
  22141. * @hidden
  22142. * This is reserved for the inspector.
  22143. * Defines the material debug mode.
  22144. * It helps seeing only some components of the material while troubleshooting.
  22145. */
  22146. debugMode: number;
  22147. /**
  22148. * @hidden
  22149. * This is reserved for the inspector.
  22150. * Specify from where on screen the debug mode should start.
  22151. * The value goes from -1 (full screen) to 1 (not visible)
  22152. * It helps with side by side comparison against the final render
  22153. * This defaults to -1
  22154. */
  22155. private debugLimit;
  22156. /**
  22157. * @hidden
  22158. * This is reserved for the inspector.
  22159. * As the default viewing range might not be enough (if the ambient is really small for instance)
  22160. * You can use the factor to better multiply the final value.
  22161. */
  22162. private debugFactor;
  22163. /**
  22164. * Defines the clear coat layer parameters for the material.
  22165. */
  22166. readonly clearCoat: PBRClearCoatConfiguration;
  22167. /**
  22168. * Defines the anisotropic parameters for the material.
  22169. */
  22170. readonly anisotropy: PBRAnisotropicConfiguration;
  22171. /**
  22172. * Defines the BRDF parameters for the material.
  22173. */
  22174. readonly brdf: PBRBRDFConfiguration;
  22175. /**
  22176. * Defines the Sheen parameters for the material.
  22177. */
  22178. readonly sheen: PBRSheenConfiguration;
  22179. /**
  22180. * Defines the SubSurface parameters for the material.
  22181. */
  22182. readonly subSurface: PBRSubSurfaceConfiguration;
  22183. /**
  22184. * Defines additionnal PrePass parameters for the material.
  22185. */
  22186. readonly prePassConfiguration: PrePassConfiguration;
  22187. /**
  22188. * Defines the detail map parameters for the material.
  22189. */
  22190. readonly detailMap: DetailMapConfiguration;
  22191. protected _rebuildInParallel: boolean;
  22192. /**
  22193. * Instantiates a new PBRMaterial instance.
  22194. *
  22195. * @param name The material name
  22196. * @param scene The scene the material will be use in.
  22197. */
  22198. constructor(name: string, scene: Scene);
  22199. /**
  22200. * Gets a boolean indicating that current material needs to register RTT
  22201. */
  22202. get hasRenderTargetTextures(): boolean;
  22203. /**
  22204. * Gets the name of the material class.
  22205. */
  22206. getClassName(): string;
  22207. /**
  22208. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  22209. */
  22210. get useLogarithmicDepth(): boolean;
  22211. /**
  22212. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  22213. */
  22214. set useLogarithmicDepth(value: boolean);
  22215. /**
  22216. * Returns true if alpha blending should be disabled.
  22217. */
  22218. protected get _disableAlphaBlending(): boolean;
  22219. /**
  22220. * Specifies whether or not this material should be rendered in alpha blend mode.
  22221. */
  22222. needAlphaBlending(): boolean;
  22223. /**
  22224. * Specifies whether or not this material should be rendered in alpha test mode.
  22225. */
  22226. needAlphaTesting(): boolean;
  22227. /**
  22228. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  22229. */
  22230. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  22231. /**
  22232. * Specifies whether or not there is a usable alpha channel for transparency.
  22233. */
  22234. protected _hasAlphaChannel(): boolean;
  22235. /**
  22236. * Gets the texture used for the alpha test.
  22237. */
  22238. getAlphaTestTexture(): Nullable<BaseTexture>;
  22239. /**
  22240. * Specifies that the submesh is ready to be used.
  22241. * @param mesh - BJS mesh.
  22242. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  22243. * @param useInstances - Specifies that instances should be used.
  22244. * @returns - boolean indicating that the submesh is ready or not.
  22245. */
  22246. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  22247. /**
  22248. * Specifies if the material uses metallic roughness workflow.
  22249. * @returns boolean specifiying if the material uses metallic roughness workflow.
  22250. */
  22251. isMetallicWorkflow(): boolean;
  22252. private _prepareEffect;
  22253. private _prepareDefines;
  22254. /**
  22255. * Force shader compilation
  22256. */
  22257. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  22258. /**
  22259. * Initializes the uniform buffer layout for the shader.
  22260. */
  22261. buildUniformLayout(): void;
  22262. /**
  22263. * Unbinds the material from the mesh
  22264. */
  22265. unbind(): void;
  22266. /**
  22267. * Binds the submesh data.
  22268. * @param world - The world matrix.
  22269. * @param mesh - The BJS mesh.
  22270. * @param subMesh - A submesh of the BJS mesh.
  22271. */
  22272. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  22273. /**
  22274. * Returns the animatable textures.
  22275. * @returns - Array of animatable textures.
  22276. */
  22277. getAnimatables(): IAnimatable[];
  22278. /**
  22279. * Returns the texture used for reflections.
  22280. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  22281. */
  22282. private _getReflectionTexture;
  22283. /**
  22284. * Returns an array of the actively used textures.
  22285. * @returns - Array of BaseTextures
  22286. */
  22287. getActiveTextures(): BaseTexture[];
  22288. /**
  22289. * Checks to see if a texture is used in the material.
  22290. * @param texture - Base texture to use.
  22291. * @returns - Boolean specifying if a texture is used in the material.
  22292. */
  22293. hasTexture(texture: BaseTexture): boolean;
  22294. /**
  22295. * Sets the required values to the prepass renderer.
  22296. * @param prePassRenderer defines the prepass renderer to setup
  22297. */
  22298. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  22299. /**
  22300. * Disposes the resources of the material.
  22301. * @param forceDisposeEffect - Forces the disposal of effects.
  22302. * @param forceDisposeTextures - Forces the disposal of all textures.
  22303. */
  22304. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  22305. }
  22306. }
  22307. declare module BABYLON {
  22308. /**
  22309. * The Physically based material of BJS.
  22310. *
  22311. * This offers the main features of a standard PBR material.
  22312. * For more information, please refer to the documentation :
  22313. * https://doc.babylonjs.com/how_to/physically_based_rendering
  22314. */
  22315. export class PBRMaterial extends PBRBaseMaterial {
  22316. /**
  22317. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  22318. */
  22319. static readonly PBRMATERIAL_OPAQUE: number;
  22320. /**
  22321. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  22322. */
  22323. static readonly PBRMATERIAL_ALPHATEST: number;
  22324. /**
  22325. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  22326. */
  22327. static readonly PBRMATERIAL_ALPHABLEND: number;
  22328. /**
  22329. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  22330. * They are also discarded below the alpha cutoff threshold to improve performances.
  22331. */
  22332. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  22333. /**
  22334. * Defines the default value of how much AO map is occluding the analytical lights
  22335. * (point spot...).
  22336. */
  22337. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  22338. /**
  22339. * Intensity of the direct lights e.g. the four lights available in your scene.
  22340. * This impacts both the direct diffuse and specular highlights.
  22341. */
  22342. directIntensity: number;
  22343. /**
  22344. * Intensity of the emissive part of the material.
  22345. * This helps controlling the emissive effect without modifying the emissive color.
  22346. */
  22347. emissiveIntensity: number;
  22348. /**
  22349. * Intensity of the environment e.g. how much the environment will light the object
  22350. * either through harmonics for rough material or through the refelction for shiny ones.
  22351. */
  22352. environmentIntensity: number;
  22353. /**
  22354. * This is a special control allowing the reduction of the specular highlights coming from the
  22355. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  22356. */
  22357. specularIntensity: number;
  22358. /**
  22359. * Debug Control allowing disabling the bump map on this material.
  22360. */
  22361. disableBumpMap: boolean;
  22362. /**
  22363. * AKA Diffuse Texture in standard nomenclature.
  22364. */
  22365. albedoTexture: BaseTexture;
  22366. /**
  22367. * AKA Occlusion Texture in other nomenclature.
  22368. */
  22369. ambientTexture: BaseTexture;
  22370. /**
  22371. * AKA Occlusion Texture Intensity in other nomenclature.
  22372. */
  22373. ambientTextureStrength: number;
  22374. /**
  22375. * Defines how much the AO map is occluding the analytical lights (point spot...).
  22376. * 1 means it completely occludes it
  22377. * 0 mean it has no impact
  22378. */
  22379. ambientTextureImpactOnAnalyticalLights: number;
  22380. /**
  22381. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  22382. */
  22383. opacityTexture: BaseTexture;
  22384. /**
  22385. * Stores the reflection values in a texture.
  22386. */
  22387. reflectionTexture: Nullable<BaseTexture>;
  22388. /**
  22389. * Stores the emissive values in a texture.
  22390. */
  22391. emissiveTexture: BaseTexture;
  22392. /**
  22393. * AKA Specular texture in other nomenclature.
  22394. */
  22395. reflectivityTexture: BaseTexture;
  22396. /**
  22397. * Used to switch from specular/glossiness to metallic/roughness workflow.
  22398. */
  22399. metallicTexture: BaseTexture;
  22400. /**
  22401. * Specifies the metallic scalar of the metallic/roughness workflow.
  22402. * Can also be used to scale the metalness values of the metallic texture.
  22403. */
  22404. metallic: Nullable<number>;
  22405. /**
  22406. * Specifies the roughness scalar of the metallic/roughness workflow.
  22407. * Can also be used to scale the roughness values of the metallic texture.
  22408. */
  22409. roughness: Nullable<number>;
  22410. /**
  22411. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  22412. * By default the indexOfrefraction is used to compute F0;
  22413. *
  22414. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  22415. *
  22416. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  22417. * F90 = metallicReflectanceColor;
  22418. */
  22419. metallicF0Factor: number;
  22420. /**
  22421. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  22422. * By default the F90 is always 1;
  22423. *
  22424. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  22425. *
  22426. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  22427. * F90 = metallicReflectanceColor;
  22428. */
  22429. metallicReflectanceColor: Color3;
  22430. /**
  22431. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  22432. * This is multiply against the scalar values defined in the material.
  22433. */
  22434. metallicReflectanceTexture: Nullable<BaseTexture>;
  22435. /**
  22436. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  22437. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  22438. */
  22439. microSurfaceTexture: BaseTexture;
  22440. /**
  22441. * Stores surface normal data used to displace a mesh in a texture.
  22442. */
  22443. bumpTexture: BaseTexture;
  22444. /**
  22445. * Stores the pre-calculated light information of a mesh in a texture.
  22446. */
  22447. lightmapTexture: BaseTexture;
  22448. /**
  22449. * Stores the refracted light information in a texture.
  22450. */
  22451. get refractionTexture(): Nullable<BaseTexture>;
  22452. set refractionTexture(value: Nullable<BaseTexture>);
  22453. /**
  22454. * The color of a material in ambient lighting.
  22455. */
  22456. ambientColor: Color3;
  22457. /**
  22458. * AKA Diffuse Color in other nomenclature.
  22459. */
  22460. albedoColor: Color3;
  22461. /**
  22462. * AKA Specular Color in other nomenclature.
  22463. */
  22464. reflectivityColor: Color3;
  22465. /**
  22466. * The color reflected from the material.
  22467. */
  22468. reflectionColor: Color3;
  22469. /**
  22470. * The color emitted from the material.
  22471. */
  22472. emissiveColor: Color3;
  22473. /**
  22474. * AKA Glossiness in other nomenclature.
  22475. */
  22476. microSurface: number;
  22477. /**
  22478. * Index of refraction of the material base layer.
  22479. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  22480. *
  22481. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  22482. *
  22483. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  22484. */
  22485. get indexOfRefraction(): number;
  22486. set indexOfRefraction(value: number);
  22487. /**
  22488. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  22489. */
  22490. get invertRefractionY(): boolean;
  22491. set invertRefractionY(value: boolean);
  22492. /**
  22493. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  22494. * Materials half opaque for instance using refraction could benefit from this control.
  22495. */
  22496. get linkRefractionWithTransparency(): boolean;
  22497. set linkRefractionWithTransparency(value: boolean);
  22498. /**
  22499. * If true, the light map contains occlusion information instead of lighting info.
  22500. */
  22501. useLightmapAsShadowmap: boolean;
  22502. /**
  22503. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  22504. */
  22505. useAlphaFromAlbedoTexture: boolean;
  22506. /**
  22507. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  22508. */
  22509. forceAlphaTest: boolean;
  22510. /**
  22511. * Defines the alpha limits in alpha test mode.
  22512. */
  22513. alphaCutOff: number;
  22514. /**
  22515. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  22516. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  22517. */
  22518. useSpecularOverAlpha: boolean;
  22519. /**
  22520. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  22521. */
  22522. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  22523. /**
  22524. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  22525. */
  22526. useRoughnessFromMetallicTextureAlpha: boolean;
  22527. /**
  22528. * Specifies if the metallic texture contains the roughness information in its green channel.
  22529. */
  22530. useRoughnessFromMetallicTextureGreen: boolean;
  22531. /**
  22532. * Specifies if the metallic texture contains the metallness information in its blue channel.
  22533. */
  22534. useMetallnessFromMetallicTextureBlue: boolean;
  22535. /**
  22536. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  22537. */
  22538. useAmbientOcclusionFromMetallicTextureRed: boolean;
  22539. /**
  22540. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  22541. */
  22542. useAmbientInGrayScale: boolean;
  22543. /**
  22544. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  22545. * The material will try to infer what glossiness each pixel should be.
  22546. */
  22547. useAutoMicroSurfaceFromReflectivityMap: boolean;
  22548. /**
  22549. * BJS is using an harcoded light falloff based on a manually sets up range.
  22550. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  22551. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  22552. */
  22553. get usePhysicalLightFalloff(): boolean;
  22554. /**
  22555. * BJS is using an harcoded light falloff based on a manually sets up range.
  22556. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  22557. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  22558. */
  22559. set usePhysicalLightFalloff(value: boolean);
  22560. /**
  22561. * In order to support the falloff compatibility with gltf, a special mode has been added
  22562. * to reproduce the gltf light falloff.
  22563. */
  22564. get useGLTFLightFalloff(): boolean;
  22565. /**
  22566. * In order to support the falloff compatibility with gltf, a special mode has been added
  22567. * to reproduce the gltf light falloff.
  22568. */
  22569. set useGLTFLightFalloff(value: boolean);
  22570. /**
  22571. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  22572. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  22573. */
  22574. useRadianceOverAlpha: boolean;
  22575. /**
  22576. * Allows using an object space normal map (instead of tangent space).
  22577. */
  22578. useObjectSpaceNormalMap: boolean;
  22579. /**
  22580. * Allows using the bump map in parallax mode.
  22581. */
  22582. useParallax: boolean;
  22583. /**
  22584. * Allows using the bump map in parallax occlusion mode.
  22585. */
  22586. useParallaxOcclusion: boolean;
  22587. /**
  22588. * Controls the scale bias of the parallax mode.
  22589. */
  22590. parallaxScaleBias: number;
  22591. /**
  22592. * If sets to true, disables all the lights affecting the material.
  22593. */
  22594. disableLighting: boolean;
  22595. /**
  22596. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  22597. */
  22598. forceIrradianceInFragment: boolean;
  22599. /**
  22600. * Number of Simultaneous lights allowed on the material.
  22601. */
  22602. maxSimultaneousLights: number;
  22603. /**
  22604. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  22605. */
  22606. invertNormalMapX: boolean;
  22607. /**
  22608. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  22609. */
  22610. invertNormalMapY: boolean;
  22611. /**
  22612. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  22613. */
  22614. twoSidedLighting: boolean;
  22615. /**
  22616. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  22617. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  22618. */
  22619. useAlphaFresnel: boolean;
  22620. /**
  22621. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  22622. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  22623. */
  22624. useLinearAlphaFresnel: boolean;
  22625. /**
  22626. * Let user defines the brdf lookup texture used for IBL.
  22627. * A default 8bit version is embedded but you could point at :
  22628. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  22629. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  22630. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  22631. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  22632. */
  22633. environmentBRDFTexture: Nullable<BaseTexture>;
  22634. /**
  22635. * Force normal to face away from face.
  22636. */
  22637. forceNormalForward: boolean;
  22638. /**
  22639. * Enables specular anti aliasing in the PBR shader.
  22640. * It will both interacts on the Geometry for analytical and IBL lighting.
  22641. * It also prefilter the roughness map based on the bump values.
  22642. */
  22643. enableSpecularAntiAliasing: boolean;
  22644. /**
  22645. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  22646. * makes the reflect vector face the model (under horizon).
  22647. */
  22648. useHorizonOcclusion: boolean;
  22649. /**
  22650. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  22651. * too much the area relying on ambient texture to define their ambient occlusion.
  22652. */
  22653. useRadianceOcclusion: boolean;
  22654. /**
  22655. * If set to true, no lighting calculations will be applied.
  22656. */
  22657. unlit: boolean;
  22658. /**
  22659. * Gets the image processing configuration used either in this material.
  22660. */
  22661. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  22662. /**
  22663. * Sets the Default image processing configuration used either in the this material.
  22664. *
  22665. * If sets to null, the scene one is in use.
  22666. */
  22667. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  22668. /**
  22669. * Gets wether the color curves effect is enabled.
  22670. */
  22671. get cameraColorCurvesEnabled(): boolean;
  22672. /**
  22673. * Sets wether the color curves effect is enabled.
  22674. */
  22675. set cameraColorCurvesEnabled(value: boolean);
  22676. /**
  22677. * Gets wether the color grading effect is enabled.
  22678. */
  22679. get cameraColorGradingEnabled(): boolean;
  22680. /**
  22681. * Gets wether the color grading effect is enabled.
  22682. */
  22683. set cameraColorGradingEnabled(value: boolean);
  22684. /**
  22685. * Gets wether tonemapping is enabled or not.
  22686. */
  22687. get cameraToneMappingEnabled(): boolean;
  22688. /**
  22689. * Sets wether tonemapping is enabled or not
  22690. */
  22691. set cameraToneMappingEnabled(value: boolean);
  22692. /**
  22693. * The camera exposure used on this material.
  22694. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  22695. * This corresponds to a photographic exposure.
  22696. */
  22697. get cameraExposure(): number;
  22698. /**
  22699. * The camera exposure used on this material.
  22700. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  22701. * This corresponds to a photographic exposure.
  22702. */
  22703. set cameraExposure(value: number);
  22704. /**
  22705. * Gets The camera contrast used on this material.
  22706. */
  22707. get cameraContrast(): number;
  22708. /**
  22709. * Sets The camera contrast used on this material.
  22710. */
  22711. set cameraContrast(value: number);
  22712. /**
  22713. * Gets the Color Grading 2D Lookup Texture.
  22714. */
  22715. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  22716. /**
  22717. * Sets the Color Grading 2D Lookup Texture.
  22718. */
  22719. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  22720. /**
  22721. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  22722. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  22723. * 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;
  22724. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  22725. */
  22726. get cameraColorCurves(): Nullable<ColorCurves>;
  22727. /**
  22728. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  22729. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  22730. * 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;
  22731. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  22732. */
  22733. set cameraColorCurves(value: Nullable<ColorCurves>);
  22734. /**
  22735. * Instantiates a new PBRMaterial instance.
  22736. *
  22737. * @param name The material name
  22738. * @param scene The scene the material will be use in.
  22739. */
  22740. constructor(name: string, scene: Scene);
  22741. /**
  22742. * Returns the name of this material class.
  22743. */
  22744. getClassName(): string;
  22745. /**
  22746. * Makes a duplicate of the current material.
  22747. * @param name - name to use for the new material.
  22748. */
  22749. clone(name: string): PBRMaterial;
  22750. /**
  22751. * Serializes this PBR Material.
  22752. * @returns - An object with the serialized material.
  22753. */
  22754. serialize(): any;
  22755. /**
  22756. * Parses a PBR Material from a serialized object.
  22757. * @param source - Serialized object.
  22758. * @param scene - BJS scene instance.
  22759. * @param rootUrl - url for the scene object
  22760. * @returns - PBRMaterial
  22761. */
  22762. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  22763. }
  22764. }
  22765. declare module BABYLON {
  22766. /** @hidden */
  22767. export var mrtFragmentDeclaration: {
  22768. name: string;
  22769. shader: string;
  22770. };
  22771. }
  22772. declare module BABYLON {
  22773. /** @hidden */
  22774. export var geometryPixelShader: {
  22775. name: string;
  22776. shader: string;
  22777. };
  22778. }
  22779. declare module BABYLON {
  22780. /** @hidden */
  22781. export var instancesDeclaration: {
  22782. name: string;
  22783. shader: string;
  22784. };
  22785. }
  22786. declare module BABYLON {
  22787. /** @hidden */
  22788. export var geometryVertexShader: {
  22789. name: string;
  22790. shader: string;
  22791. };
  22792. }
  22793. declare module BABYLON {
  22794. /** @hidden */
  22795. interface ISavedTransformationMatrix {
  22796. world: Matrix;
  22797. viewProjection: Matrix;
  22798. }
  22799. /**
  22800. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  22801. */
  22802. export class GeometryBufferRenderer {
  22803. /**
  22804. * Constant used to retrieve the depth + normal texture index in the G-Buffer textures array
  22805. * using getIndex(GeometryBufferRenderer.DEPTHNORMAL_TEXTURE_INDEX)
  22806. */
  22807. static readonly DEPTHNORMAL_TEXTURE_TYPE: number;
  22808. /**
  22809. * Constant used to retrieve the position texture index in the G-Buffer textures array
  22810. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  22811. */
  22812. static readonly POSITION_TEXTURE_TYPE: number;
  22813. /**
  22814. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  22815. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  22816. */
  22817. static readonly VELOCITY_TEXTURE_TYPE: number;
  22818. /**
  22819. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  22820. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  22821. */
  22822. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  22823. /**
  22824. * Dictionary used to store the previous transformation matrices of each rendered mesh
  22825. * in order to compute objects velocities when enableVelocity is set to "true"
  22826. * @hidden
  22827. */
  22828. _previousTransformationMatrices: {
  22829. [index: number]: ISavedTransformationMatrix;
  22830. };
  22831. /**
  22832. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  22833. * in order to compute objects velocities when enableVelocity is set to "true"
  22834. * @hidden
  22835. */
  22836. _previousBonesTransformationMatrices: {
  22837. [index: number]: Float32Array;
  22838. };
  22839. /**
  22840. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  22841. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  22842. */
  22843. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  22844. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  22845. renderTransparentMeshes: boolean;
  22846. private _scene;
  22847. private _resizeObserver;
  22848. private _multiRenderTarget;
  22849. private _ratio;
  22850. private _enablePosition;
  22851. private _enableVelocity;
  22852. private _enableReflectivity;
  22853. private _positionIndex;
  22854. private _velocityIndex;
  22855. private _reflectivityIndex;
  22856. private _depthNormalIndex;
  22857. private _linkedWithPrePass;
  22858. private _prePassRenderer;
  22859. private _attachments;
  22860. protected _effect: Effect;
  22861. protected _cachedDefines: string;
  22862. /**
  22863. * @hidden
  22864. * Sets up internal structures to share outputs with PrePassRenderer
  22865. * This method should only be called by the PrePassRenderer itself
  22866. */
  22867. _linkPrePassRenderer(prePassRenderer: PrePassRenderer): void;
  22868. /**
  22869. * @hidden
  22870. * Separates internal structures from PrePassRenderer so the geometry buffer can now operate by itself.
  22871. * This method should only be called by the PrePassRenderer itself
  22872. */
  22873. _unlinkPrePassRenderer(): void;
  22874. /**
  22875. * @hidden
  22876. * Resets the geometry buffer layout
  22877. */
  22878. _resetLayout(): void;
  22879. /**
  22880. * @hidden
  22881. * Replaces a texture in the geometry buffer renderer
  22882. * Useful when linking textures of the prepass renderer
  22883. */
  22884. _forceTextureType(geometryBufferType: number, index: number): void;
  22885. /**
  22886. * @hidden
  22887. * Sets texture attachments
  22888. * Useful when linking textures of the prepass renderer
  22889. */
  22890. _setAttachments(attachments: number[]): void;
  22891. /**
  22892. * @hidden
  22893. * Replaces the first texture which is hard coded as a depth texture in the geometry buffer
  22894. * Useful when linking textures of the prepass renderer
  22895. */
  22896. _linkInternalTexture(internalTexture: InternalTexture): void;
  22897. /**
  22898. * Gets the render list (meshes to be rendered) used in the G buffer.
  22899. */
  22900. get renderList(): Nullable<AbstractMesh[]>;
  22901. /**
  22902. * Set the render list (meshes to be rendered) used in the G buffer.
  22903. */
  22904. set renderList(meshes: Nullable<AbstractMesh[]>);
  22905. /**
  22906. * Gets wether or not G buffer are supported by the running hardware.
  22907. * This requires draw buffer supports
  22908. */
  22909. get isSupported(): boolean;
  22910. /**
  22911. * Returns the index of the given texture type in the G-Buffer textures array
  22912. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  22913. * @returns the index of the given texture type in the G-Buffer textures array
  22914. */
  22915. getTextureIndex(textureType: number): number;
  22916. /**
  22917. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  22918. */
  22919. get enablePosition(): boolean;
  22920. /**
  22921. * Sets whether or not objects positions are enabled for the G buffer.
  22922. */
  22923. set enablePosition(enable: boolean);
  22924. /**
  22925. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  22926. */
  22927. get enableVelocity(): boolean;
  22928. /**
  22929. * Sets wether or not objects velocities are enabled for the G buffer.
  22930. */
  22931. set enableVelocity(enable: boolean);
  22932. /**
  22933. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  22934. */
  22935. get enableReflectivity(): boolean;
  22936. /**
  22937. * Sets wether or not objects roughness are enabled for the G buffer.
  22938. */
  22939. set enableReflectivity(enable: boolean);
  22940. /**
  22941. * Gets the scene associated with the buffer.
  22942. */
  22943. get scene(): Scene;
  22944. /**
  22945. * Gets the ratio used by the buffer during its creation.
  22946. * How big is the buffer related to the main canvas.
  22947. */
  22948. get ratio(): number;
  22949. /** @hidden */
  22950. static _SceneComponentInitialization: (scene: Scene) => void;
  22951. /**
  22952. * Creates a new G Buffer for the scene
  22953. * @param scene The scene the buffer belongs to
  22954. * @param ratio How big is the buffer related to the main canvas.
  22955. */
  22956. constructor(scene: Scene, ratio?: number);
  22957. /**
  22958. * Checks wether everything is ready to render a submesh to the G buffer.
  22959. * @param subMesh the submesh to check readiness for
  22960. * @param useInstances is the mesh drawn using instance or not
  22961. * @returns true if ready otherwise false
  22962. */
  22963. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  22964. /**
  22965. * Gets the current underlying G Buffer.
  22966. * @returns the buffer
  22967. */
  22968. getGBuffer(): MultiRenderTarget;
  22969. /**
  22970. * Gets the number of samples used to render the buffer (anti aliasing).
  22971. */
  22972. get samples(): number;
  22973. /**
  22974. * Sets the number of samples used to render the buffer (anti aliasing).
  22975. */
  22976. set samples(value: number);
  22977. /**
  22978. * Disposes the renderer and frees up associated resources.
  22979. */
  22980. dispose(): void;
  22981. private _assignRenderTargetIndices;
  22982. protected _createRenderTargets(): void;
  22983. private _copyBonesTransformationMatrices;
  22984. }
  22985. }
  22986. declare module BABYLON {
  22987. /**
  22988. * Renders a pre pass of the scene
  22989. * This means every mesh in the scene will be rendered to a render target texture
  22990. * And then this texture will be composited to the rendering canvas with post processes
  22991. * It is necessary for effects like subsurface scattering or deferred shading
  22992. */
  22993. export class PrePassRenderer {
  22994. /** @hidden */
  22995. static _SceneComponentInitialization: (scene: Scene) => void;
  22996. private _textureFormats;
  22997. /**
  22998. * To save performance, we can excluded skinned meshes from the prepass
  22999. */
  23000. excludedSkinnedMesh: AbstractMesh[];
  23001. /**
  23002. * Force material to be excluded from the prepass
  23003. * Can be useful when `useGeometryBufferFallback` is set to `true`
  23004. * and you don't want a material to show in the effect.
  23005. */
  23006. excludedMaterials: Material[];
  23007. private _textureIndices;
  23008. private _scene;
  23009. private _engine;
  23010. private _isDirty;
  23011. /**
  23012. * Number of textures in the multi render target texture where the scene is directly rendered
  23013. */
  23014. mrtCount: number;
  23015. /**
  23016. * The render target where the scene is directly rendered
  23017. */
  23018. prePassRT: MultiRenderTarget;
  23019. private _multiRenderAttachments;
  23020. private _defaultAttachments;
  23021. private _postProcesses;
  23022. private readonly _clearColor;
  23023. /**
  23024. * Image processing post process for composition
  23025. */
  23026. imageProcessingPostProcess: ImageProcessingPostProcess;
  23027. /**
  23028. * Configuration for prepass effects
  23029. */
  23030. private _effectConfigurations;
  23031. private _mrtFormats;
  23032. private _mrtLayout;
  23033. private _enabled;
  23034. /**
  23035. * Indicates if the prepass is enabled
  23036. */
  23037. get enabled(): boolean;
  23038. /**
  23039. * How many samples are used for MSAA of the scene render target
  23040. */
  23041. get samples(): number;
  23042. set samples(n: number);
  23043. private _geometryBuffer;
  23044. private _useGeometryBufferFallback;
  23045. /**
  23046. * Uses the geometry buffer renderer as a fallback for non prepass capable effects
  23047. */
  23048. get useGeometryBufferFallback(): boolean;
  23049. set useGeometryBufferFallback(value: boolean);
  23050. /**
  23051. * Set to true to disable gamma transform in PrePass.
  23052. * Can be useful in case you already proceed to gamma transform on a material level
  23053. * and your post processes don't need to be in linear color space.
  23054. */
  23055. disableGammaTransform: boolean;
  23056. /**
  23057. * Instanciates a prepass renderer
  23058. * @param scene The scene
  23059. */
  23060. constructor(scene: Scene);
  23061. private _initializeAttachments;
  23062. private _createCompositionEffect;
  23063. /**
  23064. * Indicates if rendering a prepass is supported
  23065. */
  23066. get isSupported(): boolean;
  23067. /**
  23068. * Sets the proper output textures to draw in the engine.
  23069. * @param effect The effect that is drawn. It can be or not be compatible with drawing to several output textures.
  23070. * @param subMesh Submesh on which the effect is applied
  23071. */
  23072. bindAttachmentsForEffect(effect: Effect, subMesh: SubMesh): void;
  23073. /**
  23074. * Restores attachments for single texture draw.
  23075. */
  23076. restoreAttachments(): void;
  23077. /**
  23078. * @hidden
  23079. */
  23080. _beforeCameraDraw(): void;
  23081. /**
  23082. * @hidden
  23083. */
  23084. _afterCameraDraw(): void;
  23085. private _checkRTSize;
  23086. private _bindFrameBuffer;
  23087. /**
  23088. * Clears the scene render target (in the sense of settings pixels to the scene clear color value)
  23089. */
  23090. clear(): void;
  23091. private _setState;
  23092. private _updateGeometryBufferLayout;
  23093. /**
  23094. * Adds an effect configuration to the prepass.
  23095. * If an effect has already been added, it won't add it twice and will return the configuration
  23096. * already present.
  23097. * @param cfg the effect configuration
  23098. * @return the effect configuration now used by the prepass
  23099. */
  23100. addEffectConfiguration(cfg: PrePassEffectConfiguration): PrePassEffectConfiguration;
  23101. /**
  23102. * Returns the index of a texture in the multi render target texture array.
  23103. * @param type Texture type
  23104. * @return The index
  23105. */
  23106. getIndex(type: number): number;
  23107. private _enable;
  23108. private _disable;
  23109. private _resetLayout;
  23110. private _resetPostProcessChain;
  23111. private _bindPostProcessChain;
  23112. /**
  23113. * Marks the prepass renderer as dirty, triggering a check if the prepass is necessary for the next rendering.
  23114. */
  23115. markAsDirty(): void;
  23116. /**
  23117. * Enables a texture on the MultiRenderTarget for prepass
  23118. */
  23119. private _enableTextures;
  23120. private _update;
  23121. private _markAllMaterialsAsPrePassDirty;
  23122. /**
  23123. * Disposes the prepass renderer.
  23124. */
  23125. dispose(): void;
  23126. }
  23127. }
  23128. declare module BABYLON {
  23129. /**
  23130. * Size options for a post process
  23131. */
  23132. export type PostProcessOptions = {
  23133. width: number;
  23134. height: number;
  23135. };
  23136. /**
  23137. * PostProcess can be used to apply a shader to a texture after it has been rendered
  23138. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  23139. */
  23140. export class PostProcess {
  23141. /**
  23142. * Gets or sets the unique id of the post process
  23143. */
  23144. uniqueId: number;
  23145. /** Name of the PostProcess. */
  23146. name: string;
  23147. /**
  23148. * Width of the texture to apply the post process on
  23149. */
  23150. width: number;
  23151. /**
  23152. * Height of the texture to apply the post process on
  23153. */
  23154. height: number;
  23155. /**
  23156. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  23157. */
  23158. nodeMaterialSource: Nullable<NodeMaterial>;
  23159. /**
  23160. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  23161. * @hidden
  23162. */
  23163. _outputTexture: Nullable<InternalTexture>;
  23164. /**
  23165. * Sampling mode used by the shader
  23166. * See https://doc.babylonjs.com/classes/3.1/texture
  23167. */
  23168. renderTargetSamplingMode: number;
  23169. /**
  23170. * Clear color to use when screen clearing
  23171. */
  23172. clearColor: Color4;
  23173. /**
  23174. * If the buffer needs to be cleared before applying the post process. (default: true)
  23175. * Should be set to false if shader will overwrite all previous pixels.
  23176. */
  23177. autoClear: boolean;
  23178. /**
  23179. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  23180. */
  23181. alphaMode: number;
  23182. /**
  23183. * Sets the setAlphaBlendConstants of the babylon engine
  23184. */
  23185. alphaConstants: Color4;
  23186. /**
  23187. * Animations to be used for the post processing
  23188. */
  23189. animations: Animation[];
  23190. /**
  23191. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  23192. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  23193. */
  23194. enablePixelPerfectMode: boolean;
  23195. /**
  23196. * Force the postprocess to be applied without taking in account viewport
  23197. */
  23198. forceFullscreenViewport: boolean;
  23199. /**
  23200. * List of inspectable custom properties (used by the Inspector)
  23201. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  23202. */
  23203. inspectableCustomProperties: IInspectable[];
  23204. /**
  23205. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  23206. *
  23207. * | Value | Type | Description |
  23208. * | ----- | ----------------------------------- | ----------- |
  23209. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  23210. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  23211. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  23212. *
  23213. */
  23214. scaleMode: number;
  23215. /**
  23216. * Force textures to be a power of two (default: false)
  23217. */
  23218. alwaysForcePOT: boolean;
  23219. private _samples;
  23220. /**
  23221. * Number of sample textures (default: 1)
  23222. */
  23223. get samples(): number;
  23224. set samples(n: number);
  23225. /**
  23226. * Modify the scale of the post process to be the same as the viewport (default: false)
  23227. */
  23228. adaptScaleToCurrentViewport: boolean;
  23229. private _camera;
  23230. protected _scene: Scene;
  23231. private _engine;
  23232. private _options;
  23233. private _reusable;
  23234. private _textureType;
  23235. private _textureFormat;
  23236. /**
  23237. * Smart array of input and output textures for the post process.
  23238. * @hidden
  23239. */
  23240. _textures: SmartArray<InternalTexture>;
  23241. /**
  23242. * The index in _textures that corresponds to the output texture.
  23243. * @hidden
  23244. */
  23245. _currentRenderTextureInd: number;
  23246. private _effect;
  23247. private _samplers;
  23248. private _fragmentUrl;
  23249. private _vertexUrl;
  23250. private _parameters;
  23251. private _scaleRatio;
  23252. protected _indexParameters: any;
  23253. private _shareOutputWithPostProcess;
  23254. private _texelSize;
  23255. private _forcedOutputTexture;
  23256. /**
  23257. * Prepass configuration in case this post process needs a texture from prepass
  23258. * @hidden
  23259. */
  23260. _prePassEffectConfiguration: PrePassEffectConfiguration;
  23261. /**
  23262. * Returns the fragment url or shader name used in the post process.
  23263. * @returns the fragment url or name in the shader store.
  23264. */
  23265. getEffectName(): string;
  23266. /**
  23267. * An event triggered when the postprocess is activated.
  23268. */
  23269. onActivateObservable: Observable<Camera>;
  23270. private _onActivateObserver;
  23271. /**
  23272. * A function that is added to the onActivateObservable
  23273. */
  23274. set onActivate(callback: Nullable<(camera: Camera) => void>);
  23275. /**
  23276. * An event triggered when the postprocess changes its size.
  23277. */
  23278. onSizeChangedObservable: Observable<PostProcess>;
  23279. private _onSizeChangedObserver;
  23280. /**
  23281. * A function that is added to the onSizeChangedObservable
  23282. */
  23283. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  23284. /**
  23285. * An event triggered when the postprocess applies its effect.
  23286. */
  23287. onApplyObservable: Observable<Effect>;
  23288. private _onApplyObserver;
  23289. /**
  23290. * A function that is added to the onApplyObservable
  23291. */
  23292. set onApply(callback: (effect: Effect) => void);
  23293. /**
  23294. * An event triggered before rendering the postprocess
  23295. */
  23296. onBeforeRenderObservable: Observable<Effect>;
  23297. private _onBeforeRenderObserver;
  23298. /**
  23299. * A function that is added to the onBeforeRenderObservable
  23300. */
  23301. set onBeforeRender(callback: (effect: Effect) => void);
  23302. /**
  23303. * An event triggered after rendering the postprocess
  23304. */
  23305. onAfterRenderObservable: Observable<Effect>;
  23306. private _onAfterRenderObserver;
  23307. /**
  23308. * A function that is added to the onAfterRenderObservable
  23309. */
  23310. set onAfterRender(callback: (efect: Effect) => void);
  23311. /**
  23312. * 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
  23313. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  23314. */
  23315. get inputTexture(): InternalTexture;
  23316. set inputTexture(value: InternalTexture);
  23317. /**
  23318. * Since inputTexture should always be defined, if we previously manually set `inputTexture`,
  23319. * the only way to unset it is to use this function to restore its internal state
  23320. */
  23321. restoreDefaultInputTexture(): void;
  23322. /**
  23323. * Gets the camera which post process is applied to.
  23324. * @returns The camera the post process is applied to.
  23325. */
  23326. getCamera(): Camera;
  23327. /**
  23328. * Gets the texel size of the postprocess.
  23329. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  23330. */
  23331. get texelSize(): Vector2;
  23332. /**
  23333. * Creates a new instance PostProcess
  23334. * @param name The name of the PostProcess.
  23335. * @param fragmentUrl The url of the fragment shader to be used.
  23336. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  23337. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  23338. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  23339. * @param camera The camera to apply the render pass to.
  23340. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  23341. * @param engine The engine which the post process will be applied. (default: current engine)
  23342. * @param reusable If the post process can be reused on the same frame. (default: false)
  23343. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  23344. * @param textureType Type of textures used when performing the post process. (default: 0)
  23345. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  23346. * @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
  23347. * @param blockCompilation If the shader should not be compiled immediatly. (default: false)
  23348. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  23349. */
  23350. 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);
  23351. /**
  23352. * Gets a string identifying the name of the class
  23353. * @returns "PostProcess" string
  23354. */
  23355. getClassName(): string;
  23356. /**
  23357. * Gets the engine which this post process belongs to.
  23358. * @returns The engine the post process was enabled with.
  23359. */
  23360. getEngine(): Engine;
  23361. /**
  23362. * The effect that is created when initializing the post process.
  23363. * @returns The created effect corresponding the the postprocess.
  23364. */
  23365. getEffect(): Effect;
  23366. /**
  23367. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  23368. * @param postProcess The post process to share the output with.
  23369. * @returns This post process.
  23370. */
  23371. shareOutputWith(postProcess: PostProcess): PostProcess;
  23372. /**
  23373. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  23374. * This should be called if the post process that shares output with this post process is disabled/disposed.
  23375. */
  23376. useOwnOutput(): void;
  23377. /**
  23378. * Updates the effect with the current post process compile time values and recompiles the shader.
  23379. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  23380. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  23381. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  23382. * @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
  23383. * @param onCompiled Called when the shader has been compiled.
  23384. * @param onError Called if there is an error when compiling a shader.
  23385. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  23386. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  23387. */
  23388. 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;
  23389. /**
  23390. * The post process is reusable if it can be used multiple times within one frame.
  23391. * @returns If the post process is reusable
  23392. */
  23393. isReusable(): boolean;
  23394. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  23395. markTextureDirty(): void;
  23396. /**
  23397. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  23398. * 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.
  23399. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  23400. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  23401. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  23402. * @returns The target texture that was bound to be written to.
  23403. */
  23404. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  23405. /**
  23406. * If the post process is supported.
  23407. */
  23408. get isSupported(): boolean;
  23409. /**
  23410. * The aspect ratio of the output texture.
  23411. */
  23412. get aspectRatio(): number;
  23413. /**
  23414. * Get a value indicating if the post-process is ready to be used
  23415. * @returns true if the post-process is ready (shader is compiled)
  23416. */
  23417. isReady(): boolean;
  23418. /**
  23419. * Binds all textures and uniforms to the shader, this will be run on every pass.
  23420. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  23421. */
  23422. apply(): Nullable<Effect>;
  23423. private _disposeTextures;
  23424. /**
  23425. * Sets the required values to the prepass renderer.
  23426. * @param prePassRenderer defines the prepass renderer to setup.
  23427. * @returns true if the pre pass is needed.
  23428. */
  23429. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  23430. /**
  23431. * Disposes the post process.
  23432. * @param camera The camera to dispose the post process on.
  23433. */
  23434. dispose(camera?: Camera): void;
  23435. /**
  23436. * Serializes the particle system to a JSON object
  23437. * @returns the JSON object
  23438. */
  23439. serialize(): any;
  23440. /**
  23441. * Creates a material from parsed material data
  23442. * @param parsedPostProcess defines parsed post process data
  23443. * @param scene defines the hosting scene
  23444. * @param rootUrl defines the root URL to use to load textures
  23445. * @returns a new post process
  23446. */
  23447. static Parse(parsedPostProcess: any, scene: Scene, rootUrl: string): Nullable<PostProcess>;
  23448. }
  23449. }
  23450. declare module BABYLON {
  23451. /** @hidden */
  23452. export var kernelBlurVaryingDeclaration: {
  23453. name: string;
  23454. shader: string;
  23455. };
  23456. }
  23457. declare module BABYLON {
  23458. /** @hidden */
  23459. export var packingFunctions: {
  23460. name: string;
  23461. shader: string;
  23462. };
  23463. }
  23464. declare module BABYLON {
  23465. /** @hidden */
  23466. export var kernelBlurFragment: {
  23467. name: string;
  23468. shader: string;
  23469. };
  23470. }
  23471. declare module BABYLON {
  23472. /** @hidden */
  23473. export var kernelBlurFragment2: {
  23474. name: string;
  23475. shader: string;
  23476. };
  23477. }
  23478. declare module BABYLON {
  23479. /** @hidden */
  23480. export var kernelBlurPixelShader: {
  23481. name: string;
  23482. shader: string;
  23483. };
  23484. }
  23485. declare module BABYLON {
  23486. /** @hidden */
  23487. export var kernelBlurVertex: {
  23488. name: string;
  23489. shader: string;
  23490. };
  23491. }
  23492. declare module BABYLON {
  23493. /** @hidden */
  23494. export var kernelBlurVertexShader: {
  23495. name: string;
  23496. shader: string;
  23497. };
  23498. }
  23499. declare module BABYLON {
  23500. /**
  23501. * The Blur Post Process which blurs an image based on a kernel and direction.
  23502. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  23503. */
  23504. export class BlurPostProcess extends PostProcess {
  23505. private blockCompilation;
  23506. protected _kernel: number;
  23507. protected _idealKernel: number;
  23508. protected _packedFloat: boolean;
  23509. private _staticDefines;
  23510. /** The direction in which to blur the image. */
  23511. direction: Vector2;
  23512. /**
  23513. * Sets the length in pixels of the blur sample region
  23514. */
  23515. set kernel(v: number);
  23516. /**
  23517. * Gets the length in pixels of the blur sample region
  23518. */
  23519. get kernel(): number;
  23520. /**
  23521. * Sets wether or not the blur needs to unpack/repack floats
  23522. */
  23523. set packedFloat(v: boolean);
  23524. /**
  23525. * Gets wether or not the blur is unpacking/repacking floats
  23526. */
  23527. get packedFloat(): boolean;
  23528. /**
  23529. * Gets a string identifying the name of the class
  23530. * @returns "BlurPostProcess" string
  23531. */
  23532. getClassName(): string;
  23533. /**
  23534. * Creates a new instance BlurPostProcess
  23535. * @param name The name of the effect.
  23536. * @param direction The direction in which to blur the image.
  23537. * @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.
  23538. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  23539. * @param camera The camera to apply the render pass to.
  23540. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  23541. * @param engine The engine which the post process will be applied. (default: current engine)
  23542. * @param reusable If the post process can be reused on the same frame. (default: false)
  23543. * @param textureType Type of textures used when performing the post process. (default: 0)
  23544. * @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)
  23545. */
  23546. 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);
  23547. /**
  23548. * Updates the effect with the current post process compile time values and recompiles the shader.
  23549. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  23550. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  23551. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  23552. * @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
  23553. * @param onCompiled Called when the shader has been compiled.
  23554. * @param onError Called if there is an error when compiling a shader.
  23555. */
  23556. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  23557. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  23558. /**
  23559. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  23560. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  23561. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  23562. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  23563. * The gaps between physical kernels are compensated for in the weighting of the samples
  23564. * @param idealKernel Ideal blur kernel.
  23565. * @return Nearest best kernel.
  23566. */
  23567. protected _nearestBestKernel(idealKernel: number): number;
  23568. /**
  23569. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  23570. * @param x The point on the Gaussian distribution to sample.
  23571. * @return the value of the Gaussian function at x.
  23572. */
  23573. protected _gaussianWeight(x: number): number;
  23574. /**
  23575. * Generates a string that can be used as a floating point number in GLSL.
  23576. * @param x Value to print.
  23577. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  23578. * @return GLSL float string.
  23579. */
  23580. protected _glslFloat(x: number, decimalFigures?: number): string;
  23581. /** @hidden */
  23582. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlurPostProcess>;
  23583. }
  23584. }
  23585. declare module BABYLON {
  23586. /**
  23587. * Mirror texture can be used to simulate the view from a mirror in a scene.
  23588. * It will dynamically be rendered every frame to adapt to the camera point of view.
  23589. * You can then easily use it as a reflectionTexture on a flat surface.
  23590. * In case the surface is not a plane, please consider relying on reflection probes.
  23591. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  23592. */
  23593. export class MirrorTexture extends RenderTargetTexture {
  23594. private scene;
  23595. /**
  23596. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  23597. * 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.
  23598. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  23599. */
  23600. mirrorPlane: Plane;
  23601. /**
  23602. * Define the blur ratio used to blur the reflection if needed.
  23603. */
  23604. set blurRatio(value: number);
  23605. get blurRatio(): number;
  23606. /**
  23607. * Define the adaptive blur kernel used to blur the reflection if needed.
  23608. * This will autocompute the closest best match for the `blurKernel`
  23609. */
  23610. set adaptiveBlurKernel(value: number);
  23611. /**
  23612. * Define the blur kernel used to blur the reflection if needed.
  23613. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  23614. */
  23615. set blurKernel(value: number);
  23616. /**
  23617. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  23618. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  23619. */
  23620. set blurKernelX(value: number);
  23621. get blurKernelX(): number;
  23622. /**
  23623. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  23624. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  23625. */
  23626. set blurKernelY(value: number);
  23627. get blurKernelY(): number;
  23628. private _autoComputeBlurKernel;
  23629. protected _onRatioRescale(): void;
  23630. private _updateGammaSpace;
  23631. private _imageProcessingConfigChangeObserver;
  23632. private _transformMatrix;
  23633. private _mirrorMatrix;
  23634. private _savedViewMatrix;
  23635. private _blurX;
  23636. private _blurY;
  23637. private _adaptiveBlurKernel;
  23638. private _blurKernelX;
  23639. private _blurKernelY;
  23640. private _blurRatio;
  23641. /**
  23642. * Instantiates a Mirror Texture.
  23643. * Mirror texture can be used to simulate the view from a mirror in a scene.
  23644. * It will dynamically be rendered every frame to adapt to the camera point of view.
  23645. * You can then easily use it as a reflectionTexture on a flat surface.
  23646. * In case the surface is not a plane, please consider relying on reflection probes.
  23647. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  23648. * @param name
  23649. * @param size
  23650. * @param scene
  23651. * @param generateMipMaps
  23652. * @param type
  23653. * @param samplingMode
  23654. * @param generateDepthBuffer
  23655. */
  23656. constructor(name: string, size: number | {
  23657. width: number;
  23658. height: number;
  23659. } | {
  23660. ratio: number;
  23661. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  23662. private _preparePostProcesses;
  23663. /**
  23664. * Clone the mirror texture.
  23665. * @returns the cloned texture
  23666. */
  23667. clone(): MirrorTexture;
  23668. /**
  23669. * Serialize the texture to a JSON representation you could use in Parse later on
  23670. * @returns the serialized JSON representation
  23671. */
  23672. serialize(): any;
  23673. /**
  23674. * Dispose the texture and release its associated resources.
  23675. */
  23676. dispose(): void;
  23677. }
  23678. }
  23679. declare module BABYLON {
  23680. /**
  23681. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  23682. * @see https://doc.babylonjs.com/babylon101/materials#texture
  23683. */
  23684. export class Texture extends BaseTexture {
  23685. /**
  23686. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  23687. */
  23688. static SerializeBuffers: boolean;
  23689. /**
  23690. * Gets or sets a general boolean used to indicate that texture buffers must be saved as part of the serialization process.
  23691. * If no buffer exists, one will be created as base64 string from the internal webgl data.
  23692. */
  23693. static ForceSerializeBuffers: boolean;
  23694. /** @hidden */
  23695. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  23696. /** @hidden */
  23697. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  23698. /** @hidden */
  23699. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  23700. /** nearest is mag = nearest and min = nearest and mip = linear */
  23701. static readonly NEAREST_SAMPLINGMODE: number;
  23702. /** nearest is mag = nearest and min = nearest and mip = linear */
  23703. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  23704. /** Bilinear is mag = linear and min = linear and mip = nearest */
  23705. static readonly BILINEAR_SAMPLINGMODE: number;
  23706. /** Bilinear is mag = linear and min = linear and mip = nearest */
  23707. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  23708. /** Trilinear is mag = linear and min = linear and mip = linear */
  23709. static readonly TRILINEAR_SAMPLINGMODE: number;
  23710. /** Trilinear is mag = linear and min = linear and mip = linear */
  23711. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  23712. /** mag = nearest and min = nearest and mip = nearest */
  23713. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  23714. /** mag = nearest and min = linear and mip = nearest */
  23715. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  23716. /** mag = nearest and min = linear and mip = linear */
  23717. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  23718. /** mag = nearest and min = linear and mip = none */
  23719. static readonly NEAREST_LINEAR: number;
  23720. /** mag = nearest and min = nearest and mip = none */
  23721. static readonly NEAREST_NEAREST: number;
  23722. /** mag = linear and min = nearest and mip = nearest */
  23723. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  23724. /** mag = linear and min = nearest and mip = linear */
  23725. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  23726. /** mag = linear and min = linear and mip = none */
  23727. static readonly LINEAR_LINEAR: number;
  23728. /** mag = linear and min = nearest and mip = none */
  23729. static readonly LINEAR_NEAREST: number;
  23730. /** Explicit coordinates mode */
  23731. static readonly EXPLICIT_MODE: number;
  23732. /** Spherical coordinates mode */
  23733. static readonly SPHERICAL_MODE: number;
  23734. /** Planar coordinates mode */
  23735. static readonly PLANAR_MODE: number;
  23736. /** Cubic coordinates mode */
  23737. static readonly CUBIC_MODE: number;
  23738. /** Projection coordinates mode */
  23739. static readonly PROJECTION_MODE: number;
  23740. /** Inverse Cubic coordinates mode */
  23741. static readonly SKYBOX_MODE: number;
  23742. /** Inverse Cubic coordinates mode */
  23743. static readonly INVCUBIC_MODE: number;
  23744. /** Equirectangular coordinates mode */
  23745. static readonly EQUIRECTANGULAR_MODE: number;
  23746. /** Equirectangular Fixed coordinates mode */
  23747. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  23748. /** Equirectangular Fixed Mirrored coordinates mode */
  23749. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  23750. /** Texture is not repeating outside of 0..1 UVs */
  23751. static readonly CLAMP_ADDRESSMODE: number;
  23752. /** Texture is repeating outside of 0..1 UVs */
  23753. static readonly WRAP_ADDRESSMODE: number;
  23754. /** Texture is repeating and mirrored */
  23755. static readonly MIRROR_ADDRESSMODE: number;
  23756. /**
  23757. * 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
  23758. */
  23759. static UseSerializedUrlIfAny: boolean;
  23760. /**
  23761. * Define the url of the texture.
  23762. */
  23763. url: Nullable<string>;
  23764. /**
  23765. * Define an offset on the texture to offset the u coordinates of the UVs
  23766. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  23767. */
  23768. uOffset: number;
  23769. /**
  23770. * Define an offset on the texture to offset the v coordinates of the UVs
  23771. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  23772. */
  23773. vOffset: number;
  23774. /**
  23775. * Define an offset on the texture to scale the u coordinates of the UVs
  23776. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  23777. */
  23778. uScale: number;
  23779. /**
  23780. * Define an offset on the texture to scale the v coordinates of the UVs
  23781. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  23782. */
  23783. vScale: number;
  23784. /**
  23785. * Define an offset on the texture to rotate around the u coordinates of the UVs
  23786. * @see https://doc.babylonjs.com/how_to/more_materials
  23787. */
  23788. uAng: number;
  23789. /**
  23790. * Define an offset on the texture to rotate around the v coordinates of the UVs
  23791. * @see https://doc.babylonjs.com/how_to/more_materials
  23792. */
  23793. vAng: number;
  23794. /**
  23795. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  23796. * @see https://doc.babylonjs.com/how_to/more_materials
  23797. */
  23798. wAng: number;
  23799. /**
  23800. * Defines the center of rotation (U)
  23801. */
  23802. uRotationCenter: number;
  23803. /**
  23804. * Defines the center of rotation (V)
  23805. */
  23806. vRotationCenter: number;
  23807. /**
  23808. * Defines the center of rotation (W)
  23809. */
  23810. wRotationCenter: number;
  23811. /**
  23812. * Sets this property to true to avoid deformations when rotating the texture with non-uniform scaling
  23813. */
  23814. homogeneousRotationInUVTransform: boolean;
  23815. /**
  23816. * Are mip maps generated for this texture or not.
  23817. */
  23818. get noMipmap(): boolean;
  23819. /**
  23820. * List of inspectable custom properties (used by the Inspector)
  23821. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  23822. */
  23823. inspectableCustomProperties: Nullable<IInspectable[]>;
  23824. private _noMipmap;
  23825. /** @hidden */
  23826. _invertY: boolean;
  23827. private _rowGenerationMatrix;
  23828. private _cachedTextureMatrix;
  23829. private _projectionModeMatrix;
  23830. private _t0;
  23831. private _t1;
  23832. private _t2;
  23833. private _cachedUOffset;
  23834. private _cachedVOffset;
  23835. private _cachedUScale;
  23836. private _cachedVScale;
  23837. private _cachedUAng;
  23838. private _cachedVAng;
  23839. private _cachedWAng;
  23840. private _cachedProjectionMatrixId;
  23841. private _cachedURotationCenter;
  23842. private _cachedVRotationCenter;
  23843. private _cachedWRotationCenter;
  23844. private _cachedHomogeneousRotationInUVTransform;
  23845. private _cachedCoordinatesMode;
  23846. /** @hidden */
  23847. protected _initialSamplingMode: number;
  23848. /** @hidden */
  23849. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  23850. private _deleteBuffer;
  23851. protected _format: Nullable<number>;
  23852. private _delayedOnLoad;
  23853. private _delayedOnError;
  23854. private _mimeType?;
  23855. private _loaderOptions?;
  23856. /** Returns the texture mime type if it was defined by a loader (undefined else) */
  23857. get mimeType(): string | undefined;
  23858. /**
  23859. * Observable triggered once the texture has been loaded.
  23860. */
  23861. onLoadObservable: Observable<Texture>;
  23862. protected _isBlocking: boolean;
  23863. /**
  23864. * Is the texture preventing material to render while loading.
  23865. * If false, a default texture will be used instead of the loading one during the preparation step.
  23866. */
  23867. set isBlocking(value: boolean);
  23868. get isBlocking(): boolean;
  23869. /**
  23870. * Get the current sampling mode associated with the texture.
  23871. */
  23872. get samplingMode(): number;
  23873. /**
  23874. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  23875. */
  23876. get invertY(): boolean;
  23877. /**
  23878. * Instantiates a new texture.
  23879. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  23880. * @see https://doc.babylonjs.com/babylon101/materials#texture
  23881. * @param url defines the url of the picture to load as a texture
  23882. * @param sceneOrEngine defines the scene or engine the texture will belong to
  23883. * @param noMipmap defines if the texture will require mip maps or not
  23884. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  23885. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23886. * @param onLoad defines a callback triggered when the texture has been loaded
  23887. * @param onError defines a callback triggered when an error occurred during the loading session
  23888. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  23889. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  23890. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23891. * @param mimeType defines an optional mime type information
  23892. * @param loaderOptions options to be passed to the loader
  23893. */
  23894. 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);
  23895. /**
  23896. * Update the url (and optional buffer) of this texture if url was null during construction.
  23897. * @param url the url of the texture
  23898. * @param buffer the buffer of the texture (defaults to null)
  23899. * @param onLoad callback called when the texture is loaded (defaults to null)
  23900. */
  23901. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  23902. /**
  23903. * Finish the loading sequence of a texture flagged as delayed load.
  23904. * @hidden
  23905. */
  23906. delayLoad(): void;
  23907. private _prepareRowForTextureGeneration;
  23908. /**
  23909. * Checks if the texture has the same transform matrix than another texture
  23910. * @param texture texture to check against
  23911. * @returns true if the transforms are the same, else false
  23912. */
  23913. checkTransformsAreIdentical(texture: Nullable<Texture>): boolean;
  23914. /**
  23915. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  23916. * @returns the transform matrix of the texture.
  23917. */
  23918. getTextureMatrix(uBase?: number): Matrix;
  23919. /**
  23920. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  23921. * @returns The reflection texture transform
  23922. */
  23923. getReflectionTextureMatrix(): Matrix;
  23924. /**
  23925. * Clones the texture.
  23926. * @returns the cloned texture
  23927. */
  23928. clone(): Texture;
  23929. /**
  23930. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  23931. * @returns The JSON representation of the texture
  23932. */
  23933. serialize(): any;
  23934. /**
  23935. * Get the current class name of the texture useful for serialization or dynamic coding.
  23936. * @returns "Texture"
  23937. */
  23938. getClassName(): string;
  23939. /**
  23940. * Dispose the texture and release its associated resources.
  23941. */
  23942. dispose(): void;
  23943. /**
  23944. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  23945. * @param parsedTexture Define the JSON representation of the texture
  23946. * @param scene Define the scene the parsed texture should be instantiated in
  23947. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  23948. * @returns The parsed texture if successful
  23949. */
  23950. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  23951. /**
  23952. * Creates a texture from its base 64 representation.
  23953. * @param data Define the base64 payload without the data: prefix
  23954. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  23955. * @param scene Define the scene the texture should belong to
  23956. * @param noMipmap Forces the texture to not create mip map information if true
  23957. * @param invertY define if the texture needs to be inverted on the y axis during loading
  23958. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23959. * @param onLoad define a callback triggered when the texture has been loaded
  23960. * @param onError define a callback triggered when an error occurred during the loading session
  23961. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23962. * @returns the created texture
  23963. */
  23964. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  23965. /**
  23966. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  23967. * @param data Define the base64 payload without the data: prefix
  23968. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  23969. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  23970. * @param scene Define the scene the texture should belong to
  23971. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  23972. * @param noMipmap Forces the texture to not create mip map information if true
  23973. * @param invertY define if the texture needs to be inverted on the y axis during loading
  23974. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23975. * @param onLoad define a callback triggered when the texture has been loaded
  23976. * @param onError define a callback triggered when an error occurred during the loading session
  23977. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23978. * @returns the created texture
  23979. */
  23980. 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;
  23981. }
  23982. }
  23983. declare module BABYLON {
  23984. /**
  23985. * ThinSprite Class used to represent a thin sprite
  23986. * This is the base class for sprites but can also directly be used with ThinEngine
  23987. * @see https://doc.babylonjs.com/babylon101/sprites
  23988. */
  23989. export class ThinSprite {
  23990. /** Gets or sets the cell index in the sprite sheet */
  23991. cellIndex: number;
  23992. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  23993. cellRef: string;
  23994. /** Gets or sets the current world position */
  23995. position: IVector3Like;
  23996. /** Gets or sets the main color */
  23997. color: IColor4Like;
  23998. /** Gets or sets the width */
  23999. width: number;
  24000. /** Gets or sets the height */
  24001. height: number;
  24002. /** Gets or sets rotation angle */
  24003. angle: number;
  24004. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  24005. invertU: boolean;
  24006. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  24007. invertV: boolean;
  24008. /** Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true */
  24009. isVisible: boolean;
  24010. /**
  24011. * Returns a boolean indicating if the animation is started
  24012. */
  24013. get animationStarted(): boolean;
  24014. /** Gets the initial key for the animation (setting it will restart the animation) */
  24015. get fromIndex(): number;
  24016. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  24017. get toIndex(): number;
  24018. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  24019. get loopAnimation(): boolean;
  24020. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  24021. get delay(): number;
  24022. /** @hidden */
  24023. _xOffset: number;
  24024. /** @hidden */
  24025. _yOffset: number;
  24026. /** @hidden */
  24027. _xSize: number;
  24028. /** @hidden */
  24029. _ySize: number;
  24030. private _animationStarted;
  24031. protected _loopAnimation: boolean;
  24032. protected _fromIndex: number;
  24033. protected _toIndex: number;
  24034. protected _delay: number;
  24035. private _direction;
  24036. private _time;
  24037. private _onBaseAnimationEnd;
  24038. /**
  24039. * Creates a new Thin Sprite
  24040. */
  24041. constructor();
  24042. /**
  24043. * Starts an animation
  24044. * @param from defines the initial key
  24045. * @param to defines the end key
  24046. * @param loop defines if the animation must loop
  24047. * @param delay defines the start delay (in ms)
  24048. * @param onAnimationEnd defines a callback for when the animation ends
  24049. */
  24050. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: Nullable<() => void>): void;
  24051. /** Stops current animation (if any) */
  24052. stopAnimation(): void;
  24053. /** @hidden */
  24054. _animate(deltaTime: number): void;
  24055. }
  24056. }
  24057. declare module BABYLON {
  24058. /** @hidden */
  24059. export var imageProcessingCompatibility: {
  24060. name: string;
  24061. shader: string;
  24062. };
  24063. }
  24064. declare module BABYLON {
  24065. /** @hidden */
  24066. export var spritesPixelShader: {
  24067. name: string;
  24068. shader: string;
  24069. };
  24070. }
  24071. declare module BABYLON {
  24072. /** @hidden */
  24073. export var spritesVertexShader: {
  24074. name: string;
  24075. shader: string;
  24076. };
  24077. }
  24078. declare module BABYLON {
  24079. /**
  24080. * Class used to render sprites.
  24081. *
  24082. * It can be used either to render Sprites or ThinSriptes with ThinEngine only.
  24083. */
  24084. export class SpriteRenderer {
  24085. /**
  24086. * Defines the texture of the spritesheet
  24087. */
  24088. texture: Nullable<ThinTexture>;
  24089. /**
  24090. * Defines the default width of a cell in the spritesheet
  24091. */
  24092. cellWidth: number;
  24093. /**
  24094. * Defines the default height of a cell in the spritesheet
  24095. */
  24096. cellHeight: number;
  24097. /**
  24098. * Blend mode use to render the particle, it can be any of
  24099. * the static Constants.ALPHA_x properties provided in this class.
  24100. * Default value is Constants.ALPHA_COMBINE
  24101. */
  24102. blendMode: number;
  24103. /**
  24104. * Gets or sets a boolean indicating if alpha mode is automatically
  24105. * reset.
  24106. */
  24107. autoResetAlpha: boolean;
  24108. /**
  24109. * Disables writing to the depth buffer when rendering the sprites.
  24110. * It can be handy to disable depth writing when using textures without alpha channel
  24111. * and setting some specific blend modes.
  24112. */
  24113. disableDepthWrite: boolean;
  24114. /**
  24115. * Gets or sets a boolean indicating if the manager must consider scene fog when rendering
  24116. */
  24117. fogEnabled: boolean;
  24118. /**
  24119. * Gets the capacity of the manager
  24120. */
  24121. get capacity(): number;
  24122. private readonly _engine;
  24123. private readonly _useVAO;
  24124. private readonly _useInstancing;
  24125. private readonly _scene;
  24126. private readonly _capacity;
  24127. private readonly _epsilon;
  24128. private _vertexBufferSize;
  24129. private _vertexData;
  24130. private _buffer;
  24131. private _vertexBuffers;
  24132. private _spriteBuffer;
  24133. private _indexBuffer;
  24134. private _effectBase;
  24135. private _effectFog;
  24136. private _vertexArrayObject;
  24137. /**
  24138. * Creates a new sprite Renderer
  24139. * @param engine defines the engine the renderer works with
  24140. * @param capacity defines the maximum allowed number of sprites
  24141. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  24142. * @param scene defines the hosting scene
  24143. */
  24144. constructor(engine: ThinEngine, capacity: number, epsilon?: number, scene?: Nullable<Scene>);
  24145. /**
  24146. * Render all child sprites
  24147. * @param sprites defines the list of sprites to render
  24148. * @param deltaTime defines the time since last frame
  24149. * @param viewMatrix defines the viewMatrix to use to render the sprites
  24150. * @param projectionMatrix defines the projectionMatrix to use to render the sprites
  24151. * @param customSpriteUpdate defines a custom function to update the sprites data before they render
  24152. */
  24153. render(sprites: ThinSprite[], deltaTime: number, viewMatrix: IMatrixLike, projectionMatrix: IMatrixLike, customSpriteUpdate?: Nullable<(sprite: ThinSprite, baseSize: ISize) => void>): void;
  24154. private _appendSpriteVertex;
  24155. /**
  24156. * Release associated resources
  24157. */
  24158. dispose(): void;
  24159. }
  24160. }
  24161. declare module BABYLON {
  24162. /**
  24163. * Defines the minimum interface to fullfil in order to be a sprite manager.
  24164. */
  24165. export interface ISpriteManager extends IDisposable {
  24166. /**
  24167. * Gets manager's name
  24168. */
  24169. name: string;
  24170. /**
  24171. * Restricts the camera to viewing objects with the same layerMask.
  24172. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  24173. */
  24174. layerMask: number;
  24175. /**
  24176. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  24177. */
  24178. isPickable: boolean;
  24179. /**
  24180. * Gets the hosting scene
  24181. */
  24182. scene: Scene;
  24183. /**
  24184. * Specifies the rendering group id for this mesh (0 by default)
  24185. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  24186. */
  24187. renderingGroupId: number;
  24188. /**
  24189. * Defines the list of sprites managed by the manager.
  24190. */
  24191. sprites: Array<Sprite>;
  24192. /**
  24193. * Gets or sets the spritesheet texture
  24194. */
  24195. texture: Texture;
  24196. /** Defines the default width of a cell in the spritesheet */
  24197. cellWidth: number;
  24198. /** Defines the default height of a cell in the spritesheet */
  24199. cellHeight: number;
  24200. /**
  24201. * Tests the intersection of a sprite with a specific ray.
  24202. * @param ray The ray we are sending to test the collision
  24203. * @param camera The camera space we are sending rays in
  24204. * @param predicate A predicate allowing excluding sprites from the list of object to test
  24205. * @param fastCheck defines if the first intersection will be used (and not the closest)
  24206. * @returns picking info or null.
  24207. */
  24208. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  24209. /**
  24210. * Intersects the sprites with a ray
  24211. * @param ray defines the ray to intersect with
  24212. * @param camera defines the current active camera
  24213. * @param predicate defines a predicate used to select candidate sprites
  24214. * @returns null if no hit or a PickingInfo array
  24215. */
  24216. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  24217. /**
  24218. * Renders the list of sprites on screen.
  24219. */
  24220. render(): void;
  24221. }
  24222. /**
  24223. * Class used to manage multiple sprites on the same spritesheet
  24224. * @see https://doc.babylonjs.com/babylon101/sprites
  24225. */
  24226. export class SpriteManager implements ISpriteManager {
  24227. /** defines the manager's name */
  24228. name: string;
  24229. /** Define the Url to load snippets */
  24230. static SnippetUrl: string;
  24231. /** Snippet ID if the manager was created from the snippet server */
  24232. snippetId: string;
  24233. /** Gets the list of sprites */
  24234. sprites: Sprite[];
  24235. /** Gets or sets the rendering group id (0 by default) */
  24236. renderingGroupId: number;
  24237. /** Gets or sets camera layer mask */
  24238. layerMask: number;
  24239. /** Gets or sets a boolean indicating if the sprites are pickable */
  24240. isPickable: boolean;
  24241. /**
  24242. * An event triggered when the manager is disposed.
  24243. */
  24244. onDisposeObservable: Observable<SpriteManager>;
  24245. /**
  24246. * Callback called when the manager is disposed
  24247. */
  24248. set onDispose(callback: () => void);
  24249. /**
  24250. * Gets or sets the unique id of the sprite
  24251. */
  24252. uniqueId: number;
  24253. /**
  24254. * Gets the array of sprites
  24255. */
  24256. get children(): Sprite[];
  24257. /**
  24258. * Gets the hosting scene
  24259. */
  24260. get scene(): Scene;
  24261. /**
  24262. * Gets the capacity of the manager
  24263. */
  24264. get capacity(): number;
  24265. /**
  24266. * Gets or sets the spritesheet texture
  24267. */
  24268. get texture(): Texture;
  24269. set texture(value: Texture);
  24270. /** Defines the default width of a cell in the spritesheet */
  24271. get cellWidth(): number;
  24272. set cellWidth(value: number);
  24273. /** Defines the default height of a cell in the spritesheet */
  24274. get cellHeight(): number;
  24275. set cellHeight(value: number);
  24276. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  24277. get fogEnabled(): boolean;
  24278. set fogEnabled(value: boolean);
  24279. /**
  24280. * Blend mode use to render the particle, it can be any of
  24281. * the static Constants.ALPHA_x properties provided in this class.
  24282. * Default value is Constants.ALPHA_COMBINE
  24283. */
  24284. get blendMode(): number;
  24285. set blendMode(blendMode: number);
  24286. /** Disables writing to the depth buffer when rendering the sprites.
  24287. * It can be handy to disable depth writing when using textures without alpha channel
  24288. * and setting some specific blend modes.
  24289. */
  24290. disableDepthWrite: boolean;
  24291. private _spriteRenderer;
  24292. /** Associative array from JSON sprite data file */
  24293. private _cellData;
  24294. /** Array of sprite names from JSON sprite data file */
  24295. private _spriteMap;
  24296. /** True when packed cell data from JSON file is ready*/
  24297. private _packedAndReady;
  24298. private _textureContent;
  24299. private _onDisposeObserver;
  24300. private _fromPacked;
  24301. private _scene;
  24302. /**
  24303. * Creates a new sprite manager
  24304. * @param name defines the manager's name
  24305. * @param imgUrl defines the sprite sheet url
  24306. * @param capacity defines the maximum allowed number of sprites
  24307. * @param cellSize defines the size of a sprite cell
  24308. * @param scene defines the hosting scene
  24309. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  24310. * @param samplingMode defines the smapling mode to use with spritesheet
  24311. * @param fromPacked set to false; do not alter
  24312. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  24313. */
  24314. constructor(
  24315. /** defines the manager's name */
  24316. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  24317. /**
  24318. * Returns the string "SpriteManager"
  24319. * @returns "SpriteManager"
  24320. */
  24321. getClassName(): string;
  24322. private _makePacked;
  24323. private _checkTextureAlpha;
  24324. /**
  24325. * Intersects the sprites with a ray
  24326. * @param ray defines the ray to intersect with
  24327. * @param camera defines the current active camera
  24328. * @param predicate defines a predicate used to select candidate sprites
  24329. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  24330. * @returns null if no hit or a PickingInfo
  24331. */
  24332. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  24333. /**
  24334. * Intersects the sprites with a ray
  24335. * @param ray defines the ray to intersect with
  24336. * @param camera defines the current active camera
  24337. * @param predicate defines a predicate used to select candidate sprites
  24338. * @returns null if no hit or a PickingInfo array
  24339. */
  24340. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  24341. /**
  24342. * Render all child sprites
  24343. */
  24344. render(): void;
  24345. private _customUpdate;
  24346. /**
  24347. * Release associated resources
  24348. */
  24349. dispose(): void;
  24350. /**
  24351. * Serializes the sprite manager to a JSON object
  24352. * @param serializeTexture defines if the texture must be serialized as well
  24353. * @returns the JSON object
  24354. */
  24355. serialize(serializeTexture?: boolean): any;
  24356. /**
  24357. * Parses a JSON object to create a new sprite manager.
  24358. * @param parsedManager The JSON object to parse
  24359. * @param scene The scene to create the sprite managerin
  24360. * @param rootUrl The root url to use to load external dependencies like texture
  24361. * @returns the new sprite manager
  24362. */
  24363. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  24364. /**
  24365. * Creates a sprite manager from a snippet saved in a remote file
  24366. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  24367. * @param url defines the url to load from
  24368. * @param scene defines the hosting scene
  24369. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  24370. * @returns a promise that will resolve to the new sprite manager
  24371. */
  24372. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  24373. /**
  24374. * Creates a sprite manager from a snippet saved by the sprite editor
  24375. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  24376. * @param scene defines the hosting scene
  24377. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  24378. * @returns a promise that will resolve to the new sprite manager
  24379. */
  24380. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  24381. }
  24382. }
  24383. declare module BABYLON {
  24384. /**
  24385. * Class used to represent a sprite
  24386. * @see https://doc.babylonjs.com/babylon101/sprites
  24387. */
  24388. export class Sprite extends ThinSprite implements IAnimatable {
  24389. /** defines the name */
  24390. name: string;
  24391. /** Gets or sets the current world position */
  24392. position: Vector3;
  24393. /** Gets or sets the main color */
  24394. color: Color4;
  24395. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  24396. disposeWhenFinishedAnimating: boolean;
  24397. /** Gets the list of attached animations */
  24398. animations: Nullable<Array<Animation>>;
  24399. /** Gets or sets a boolean indicating if the sprite can be picked */
  24400. isPickable: boolean;
  24401. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  24402. useAlphaForPicking: boolean;
  24403. /**
  24404. * Gets or sets the associated action manager
  24405. */
  24406. actionManager: Nullable<ActionManager>;
  24407. /**
  24408. * An event triggered when the control has been disposed
  24409. */
  24410. onDisposeObservable: Observable<Sprite>;
  24411. private _manager;
  24412. private _onAnimationEnd;
  24413. /**
  24414. * Gets or sets the sprite size
  24415. */
  24416. get size(): number;
  24417. set size(value: number);
  24418. /**
  24419. * Gets or sets the unique id of the sprite
  24420. */
  24421. uniqueId: number;
  24422. /**
  24423. * Gets the manager of this sprite
  24424. */
  24425. get manager(): ISpriteManager;
  24426. /**
  24427. * Creates a new Sprite
  24428. * @param name defines the name
  24429. * @param manager defines the manager
  24430. */
  24431. constructor(
  24432. /** defines the name */
  24433. name: string, manager: ISpriteManager);
  24434. /**
  24435. * Returns the string "Sprite"
  24436. * @returns "Sprite"
  24437. */
  24438. getClassName(): string;
  24439. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  24440. get fromIndex(): number;
  24441. set fromIndex(value: number);
  24442. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  24443. get toIndex(): number;
  24444. set toIndex(value: number);
  24445. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  24446. get loopAnimation(): boolean;
  24447. set loopAnimation(value: boolean);
  24448. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  24449. get delay(): number;
  24450. set delay(value: number);
  24451. /**
  24452. * Starts an animation
  24453. * @param from defines the initial key
  24454. * @param to defines the end key
  24455. * @param loop defines if the animation must loop
  24456. * @param delay defines the start delay (in ms)
  24457. * @param onAnimationEnd defines a callback to call when animation ends
  24458. */
  24459. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd?: Nullable<() => void>): void;
  24460. private _endAnimation;
  24461. /** Release associated resources */
  24462. dispose(): void;
  24463. /**
  24464. * Serializes the sprite to a JSON object
  24465. * @returns the JSON object
  24466. */
  24467. serialize(): any;
  24468. /**
  24469. * Parses a JSON object to create a new sprite
  24470. * @param parsedSprite The JSON object to parse
  24471. * @param manager defines the hosting manager
  24472. * @returns the new sprite
  24473. */
  24474. static Parse(parsedSprite: any, manager: SpriteManager): Sprite;
  24475. }
  24476. }
  24477. declare module BABYLON {
  24478. /**
  24479. * Information about the result of picking within a scene
  24480. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  24481. */
  24482. export class PickingInfo {
  24483. /** @hidden */
  24484. _pickingUnavailable: boolean;
  24485. /**
  24486. * If the pick collided with an object
  24487. */
  24488. hit: boolean;
  24489. /**
  24490. * Distance away where the pick collided
  24491. */
  24492. distance: number;
  24493. /**
  24494. * The location of pick collision
  24495. */
  24496. pickedPoint: Nullable<Vector3>;
  24497. /**
  24498. * The mesh corresponding the the pick collision
  24499. */
  24500. pickedMesh: Nullable<AbstractMesh>;
  24501. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  24502. bu: number;
  24503. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  24504. bv: number;
  24505. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  24506. faceId: number;
  24507. /** The index of the face on the subMesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  24508. subMeshFaceId: number;
  24509. /** Id of the the submesh that was picked */
  24510. subMeshId: number;
  24511. /** If a sprite was picked, this will be the sprite the pick collided with */
  24512. pickedSprite: Nullable<Sprite>;
  24513. /** If we are pikcing a mesh with thin instance, this will give you the picked thin instance */
  24514. thinInstanceIndex: number;
  24515. /**
  24516. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  24517. */
  24518. originMesh: Nullable<AbstractMesh>;
  24519. /**
  24520. * The ray that was used to perform the picking.
  24521. */
  24522. ray: Nullable<Ray>;
  24523. /**
  24524. * Gets the normal correspodning to the face the pick collided with
  24525. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  24526. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  24527. * @returns The normal correspodning to the face the pick collided with
  24528. */
  24529. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  24530. /**
  24531. * Gets the texture coordinates of where the pick occured
  24532. * @returns the vector containing the coordnates of the texture
  24533. */
  24534. getTextureCoordinates(): Nullable<Vector2>;
  24535. }
  24536. }
  24537. declare module BABYLON {
  24538. /**
  24539. * Gather the list of pointer event types as constants.
  24540. */
  24541. export class PointerEventTypes {
  24542. /**
  24543. * 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.
  24544. */
  24545. static readonly POINTERDOWN: number;
  24546. /**
  24547. * The pointerup event is fired when a pointer is no longer active.
  24548. */
  24549. static readonly POINTERUP: number;
  24550. /**
  24551. * The pointermove event is fired when a pointer changes coordinates.
  24552. */
  24553. static readonly POINTERMOVE: number;
  24554. /**
  24555. * The pointerwheel event is fired when a mouse wheel has been rotated.
  24556. */
  24557. static readonly POINTERWHEEL: number;
  24558. /**
  24559. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  24560. */
  24561. static readonly POINTERPICK: number;
  24562. /**
  24563. * The pointertap event is fired when a the object has been touched and released without drag.
  24564. */
  24565. static readonly POINTERTAP: number;
  24566. /**
  24567. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  24568. */
  24569. static readonly POINTERDOUBLETAP: number;
  24570. }
  24571. /**
  24572. * Base class of pointer info types.
  24573. */
  24574. export class PointerInfoBase {
  24575. /**
  24576. * Defines the type of event (PointerEventTypes)
  24577. */
  24578. type: number;
  24579. /**
  24580. * Defines the related dom event
  24581. */
  24582. event: PointerEvent | MouseWheelEvent;
  24583. /**
  24584. * Instantiates the base class of pointers info.
  24585. * @param type Defines the type of event (PointerEventTypes)
  24586. * @param event Defines the related dom event
  24587. */
  24588. constructor(
  24589. /**
  24590. * Defines the type of event (PointerEventTypes)
  24591. */
  24592. type: number,
  24593. /**
  24594. * Defines the related dom event
  24595. */
  24596. event: PointerEvent | MouseWheelEvent);
  24597. }
  24598. /**
  24599. * This class is used to store pointer related info for the onPrePointerObservable event.
  24600. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  24601. */
  24602. export class PointerInfoPre extends PointerInfoBase {
  24603. /**
  24604. * Ray from a pointer if availible (eg. 6dof controller)
  24605. */
  24606. ray: Nullable<Ray>;
  24607. /**
  24608. * Defines the local position of the pointer on the canvas.
  24609. */
  24610. localPosition: Vector2;
  24611. /**
  24612. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  24613. */
  24614. skipOnPointerObservable: boolean;
  24615. /**
  24616. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  24617. * @param type Defines the type of event (PointerEventTypes)
  24618. * @param event Defines the related dom event
  24619. * @param localX Defines the local x coordinates of the pointer when the event occured
  24620. * @param localY Defines the local y coordinates of the pointer when the event occured
  24621. */
  24622. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  24623. }
  24624. /**
  24625. * This type contains all the data related to a pointer event in Babylon.js.
  24626. * 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.
  24627. */
  24628. export class PointerInfo extends PointerInfoBase {
  24629. /**
  24630. * Defines the picking info associated to the info (if any)\
  24631. */
  24632. pickInfo: Nullable<PickingInfo>;
  24633. /**
  24634. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  24635. * @param type Defines the type of event (PointerEventTypes)
  24636. * @param event Defines the related dom event
  24637. * @param pickInfo Defines the picking info associated to the info (if any)\
  24638. */
  24639. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  24640. /**
  24641. * Defines the picking info associated to the info (if any)\
  24642. */
  24643. pickInfo: Nullable<PickingInfo>);
  24644. }
  24645. /**
  24646. * Data relating to a touch event on the screen.
  24647. */
  24648. export interface PointerTouch {
  24649. /**
  24650. * X coordinate of touch.
  24651. */
  24652. x: number;
  24653. /**
  24654. * Y coordinate of touch.
  24655. */
  24656. y: number;
  24657. /**
  24658. * Id of touch. Unique for each finger.
  24659. */
  24660. pointerId: number;
  24661. /**
  24662. * Event type passed from DOM.
  24663. */
  24664. type: any;
  24665. }
  24666. }
  24667. declare module BABYLON {
  24668. /**
  24669. * Manage the mouse inputs to control the movement of a free camera.
  24670. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  24671. */
  24672. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  24673. /**
  24674. * Define if touch is enabled in the mouse input
  24675. */
  24676. touchEnabled: boolean;
  24677. /**
  24678. * Defines the camera the input is attached to.
  24679. */
  24680. camera: FreeCamera;
  24681. /**
  24682. * Defines the buttons associated with the input to handle camera move.
  24683. */
  24684. buttons: number[];
  24685. /**
  24686. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  24687. */
  24688. angularSensibility: number;
  24689. private _pointerInput;
  24690. private _onMouseMove;
  24691. private _observer;
  24692. private previousPosition;
  24693. /**
  24694. * Observable for when a pointer move event occurs containing the move offset
  24695. */
  24696. onPointerMovedObservable: Observable<{
  24697. offsetX: number;
  24698. offsetY: number;
  24699. }>;
  24700. /**
  24701. * @hidden
  24702. * If the camera should be rotated automatically based on pointer movement
  24703. */
  24704. _allowCameraRotation: boolean;
  24705. /**
  24706. * Manage the mouse inputs to control the movement of a free camera.
  24707. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  24708. * @param touchEnabled Defines if touch is enabled or not
  24709. */
  24710. constructor(
  24711. /**
  24712. * Define if touch is enabled in the mouse input
  24713. */
  24714. touchEnabled?: boolean);
  24715. /**
  24716. * Attach the input controls to a specific dom element to get the input from.
  24717. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  24718. */
  24719. attachControl(noPreventDefault?: boolean): void;
  24720. /**
  24721. * Called on JS contextmenu event.
  24722. * Override this method to provide functionality.
  24723. */
  24724. protected onContextMenu(evt: PointerEvent): void;
  24725. /**
  24726. * Detach the current controls from the specified dom element.
  24727. */
  24728. detachControl(): void;
  24729. /**
  24730. * Gets the class name of the current intput.
  24731. * @returns the class name
  24732. */
  24733. getClassName(): string;
  24734. /**
  24735. * Get the friendly name associated with the input class.
  24736. * @returns the input friendly name
  24737. */
  24738. getSimpleName(): string;
  24739. }
  24740. }
  24741. declare module BABYLON {
  24742. /**
  24743. * Base class for mouse wheel input..
  24744. * See FollowCameraMouseWheelInput in src/Cameras/Inputs/freeCameraMouseWheelInput.ts
  24745. * for example usage.
  24746. */
  24747. export abstract class BaseCameraMouseWheelInput implements ICameraInput<Camera> {
  24748. /**
  24749. * Defines the camera the input is attached to.
  24750. */
  24751. abstract camera: Camera;
  24752. /**
  24753. * How fast is the camera moves in relation to X axis mouseWheel events.
  24754. * Use negative value to reverse direction.
  24755. */
  24756. wheelPrecisionX: number;
  24757. /**
  24758. * How fast is the camera moves in relation to Y axis mouseWheel events.
  24759. * Use negative value to reverse direction.
  24760. */
  24761. wheelPrecisionY: number;
  24762. /**
  24763. * How fast is the camera moves in relation to Z axis mouseWheel events.
  24764. * Use negative value to reverse direction.
  24765. */
  24766. wheelPrecisionZ: number;
  24767. /**
  24768. * Observable for when a mouse wheel move event occurs.
  24769. */
  24770. onChangedObservable: Observable<{
  24771. wheelDeltaX: number;
  24772. wheelDeltaY: number;
  24773. wheelDeltaZ: number;
  24774. }>;
  24775. private _wheel;
  24776. private _observer;
  24777. /**
  24778. * Attach the input controls to a specific dom element to get the input from.
  24779. * @param noPreventDefault Defines whether event caught by the controls
  24780. * should call preventdefault().
  24781. * (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  24782. */
  24783. attachControl(noPreventDefault?: boolean): void;
  24784. /**
  24785. * Detach the current controls from the specified dom element.
  24786. */
  24787. detachControl(): void;
  24788. /**
  24789. * Called for each rendered frame.
  24790. */
  24791. checkInputs(): void;
  24792. /**
  24793. * Gets the class name of the current intput.
  24794. * @returns the class name
  24795. */
  24796. getClassName(): string;
  24797. /**
  24798. * Get the friendly name associated with the input class.
  24799. * @returns the input friendly name
  24800. */
  24801. getSimpleName(): string;
  24802. /**
  24803. * Incremental value of multiple mouse wheel movements of the X axis.
  24804. * Should be zero-ed when read.
  24805. */
  24806. protected _wheelDeltaX: number;
  24807. /**
  24808. * Incremental value of multiple mouse wheel movements of the Y axis.
  24809. * Should be zero-ed when read.
  24810. */
  24811. protected _wheelDeltaY: number;
  24812. /**
  24813. * Incremental value of multiple mouse wheel movements of the Z axis.
  24814. * Should be zero-ed when read.
  24815. */
  24816. protected _wheelDeltaZ: number;
  24817. /**
  24818. * Firefox uses a different scheme to report scroll distances to other
  24819. * browsers. Rather than use complicated methods to calculate the exact
  24820. * multiple we need to apply, let's just cheat and use a constant.
  24821. * https://developer.mozilla.org/en-US/docs/Web/API/WheelEvent/deltaMode
  24822. * https://stackoverflow.com/questions/20110224/what-is-the-height-of-a-line-in-a-wheel-event-deltamode-dom-delta-line
  24823. */
  24824. private readonly _ffMultiplier;
  24825. /**
  24826. * Different event attributes for wheel data fall into a few set ranges.
  24827. * Some relevant but dated date here:
  24828. * https://stackoverflow.com/questions/5527601/normalizing-mousewheel-speed-across-browsers
  24829. */
  24830. private readonly _normalize;
  24831. }
  24832. }
  24833. declare module BABYLON {
  24834. /**
  24835. * Manage the mouse wheel inputs to control a free camera.
  24836. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  24837. */
  24838. export class FreeCameraMouseWheelInput extends BaseCameraMouseWheelInput {
  24839. /**
  24840. * Defines the camera the input is attached to.
  24841. */
  24842. camera: FreeCamera;
  24843. /**
  24844. * Gets the class name of the current input.
  24845. * @returns the class name
  24846. */
  24847. getClassName(): string;
  24848. /**
  24849. * Set which movement axis (relative to camera's orientation) the mouse
  24850. * wheel's X axis controls.
  24851. * @param axis The axis to be moved. Set null to clear.
  24852. */
  24853. set wheelXMoveRelative(axis: Nullable<Coordinate>);
  24854. /**
  24855. * Get the configured movement axis (relative to camera's orientation) the
  24856. * mouse wheel's X axis controls.
  24857. * @returns The configured axis or null if none.
  24858. */
  24859. get wheelXMoveRelative(): Nullable<Coordinate>;
  24860. /**
  24861. * Set which movement axis (relative to camera's orientation) the mouse
  24862. * wheel's Y axis controls.
  24863. * @param axis The axis to be moved. Set null to clear.
  24864. */
  24865. set wheelYMoveRelative(axis: Nullable<Coordinate>);
  24866. /**
  24867. * Get the configured movement axis (relative to camera's orientation) the
  24868. * mouse wheel's Y axis controls.
  24869. * @returns The configured axis or null if none.
  24870. */
  24871. get wheelYMoveRelative(): Nullable<Coordinate>;
  24872. /**
  24873. * Set which movement axis (relative to camera's orientation) the mouse
  24874. * wheel's Z axis controls.
  24875. * @param axis The axis to be moved. Set null to clear.
  24876. */
  24877. set wheelZMoveRelative(axis: Nullable<Coordinate>);
  24878. /**
  24879. * Get the configured movement axis (relative to camera's orientation) the
  24880. * mouse wheel's Z axis controls.
  24881. * @returns The configured axis or null if none.
  24882. */
  24883. get wheelZMoveRelative(): Nullable<Coordinate>;
  24884. /**
  24885. * Set which rotation axis (relative to camera's orientation) the mouse
  24886. * wheel's X axis controls.
  24887. * @param axis The axis to be moved. Set null to clear.
  24888. */
  24889. set wheelXRotateRelative(axis: Nullable<Coordinate>);
  24890. /**
  24891. * Get the configured rotation axis (relative to camera's orientation) the
  24892. * mouse wheel's X axis controls.
  24893. * @returns The configured axis or null if none.
  24894. */
  24895. get wheelXRotateRelative(): Nullable<Coordinate>;
  24896. /**
  24897. * Set which rotation axis (relative to camera's orientation) the mouse
  24898. * wheel's Y axis controls.
  24899. * @param axis The axis to be moved. Set null to clear.
  24900. */
  24901. set wheelYRotateRelative(axis: Nullable<Coordinate>);
  24902. /**
  24903. * Get the configured rotation axis (relative to camera's orientation) the
  24904. * mouse wheel's Y axis controls.
  24905. * @returns The configured axis or null if none.
  24906. */
  24907. get wheelYRotateRelative(): Nullable<Coordinate>;
  24908. /**
  24909. * Set which rotation axis (relative to camera's orientation) the mouse
  24910. * wheel's Z axis controls.
  24911. * @param axis The axis to be moved. Set null to clear.
  24912. */
  24913. set wheelZRotateRelative(axis: Nullable<Coordinate>);
  24914. /**
  24915. * Get the configured rotation axis (relative to camera's orientation) the
  24916. * mouse wheel's Z axis controls.
  24917. * @returns The configured axis or null if none.
  24918. */
  24919. get wheelZRotateRelative(): Nullable<Coordinate>;
  24920. /**
  24921. * Set which movement axis (relative to the scene) the mouse wheel's X axis
  24922. * controls.
  24923. * @param axis The axis to be moved. Set null to clear.
  24924. */
  24925. set wheelXMoveScene(axis: Nullable<Coordinate>);
  24926. /**
  24927. * Get the configured movement axis (relative to the scene) the mouse wheel's
  24928. * X axis controls.
  24929. * @returns The configured axis or null if none.
  24930. */
  24931. get wheelXMoveScene(): Nullable<Coordinate>;
  24932. /**
  24933. * Set which movement axis (relative to the scene) the mouse wheel's Y axis
  24934. * controls.
  24935. * @param axis The axis to be moved. Set null to clear.
  24936. */
  24937. set wheelYMoveScene(axis: Nullable<Coordinate>);
  24938. /**
  24939. * Get the configured movement axis (relative to the scene) the mouse wheel's
  24940. * Y axis controls.
  24941. * @returns The configured axis or null if none.
  24942. */
  24943. get wheelYMoveScene(): Nullable<Coordinate>;
  24944. /**
  24945. * Set which movement axis (relative to the scene) the mouse wheel's Z axis
  24946. * controls.
  24947. * @param axis The axis to be moved. Set null to clear.
  24948. */
  24949. set wheelZMoveScene(axis: Nullable<Coordinate>);
  24950. /**
  24951. * Get the configured movement axis (relative to the scene) the mouse wheel's
  24952. * Z axis controls.
  24953. * @returns The configured axis or null if none.
  24954. */
  24955. get wheelZMoveScene(): Nullable<Coordinate>;
  24956. /**
  24957. * Called for each rendered frame.
  24958. */
  24959. checkInputs(): void;
  24960. private _moveRelative;
  24961. private _rotateRelative;
  24962. private _moveScene;
  24963. /**
  24964. * These are set to the desired default behaviour.
  24965. */
  24966. private _wheelXAction;
  24967. private _wheelXActionCoordinate;
  24968. private _wheelYAction;
  24969. private _wheelYActionCoordinate;
  24970. private _wheelZAction;
  24971. private _wheelZActionCoordinate;
  24972. /**
  24973. * Update the camera according to any configured properties for the 3
  24974. * mouse-wheel axis.
  24975. */
  24976. private _updateCamera;
  24977. /**
  24978. * Update one property of the camera.
  24979. */
  24980. private _updateCameraProperty;
  24981. }
  24982. }
  24983. declare module BABYLON {
  24984. /**
  24985. * Manage the touch inputs to control the movement of a free camera.
  24986. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  24987. */
  24988. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  24989. /**
  24990. * Define if mouse events can be treated as touch events
  24991. */
  24992. allowMouse: boolean;
  24993. /**
  24994. * Defines the camera the input is attached to.
  24995. */
  24996. camera: FreeCamera;
  24997. /**
  24998. * Defines the touch sensibility for rotation.
  24999. * The higher the faster.
  25000. */
  25001. touchAngularSensibility: number;
  25002. /**
  25003. * Defines the touch sensibility for move.
  25004. * The higher the faster.
  25005. */
  25006. touchMoveSensibility: number;
  25007. private _offsetX;
  25008. private _offsetY;
  25009. private _pointerPressed;
  25010. private _pointerInput?;
  25011. private _observer;
  25012. private _onLostFocus;
  25013. /**
  25014. * Manage the touch inputs to control the movement of a free camera.
  25015. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  25016. * @param allowMouse Defines if mouse events can be treated as touch events
  25017. */
  25018. constructor(
  25019. /**
  25020. * Define if mouse events can be treated as touch events
  25021. */
  25022. allowMouse?: boolean);
  25023. /**
  25024. * Attach the input controls to a specific dom element to get the input from.
  25025. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  25026. */
  25027. attachControl(noPreventDefault?: boolean): void;
  25028. /**
  25029. * Detach the current controls from the specified dom element.
  25030. */
  25031. detachControl(): void;
  25032. /**
  25033. * Update the current camera state depending on the inputs that have been used this frame.
  25034. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  25035. */
  25036. checkInputs(): void;
  25037. /**
  25038. * Gets the class name of the current intput.
  25039. * @returns the class name
  25040. */
  25041. getClassName(): string;
  25042. /**
  25043. * Get the friendly name associated with the input class.
  25044. * @returns the input friendly name
  25045. */
  25046. getSimpleName(): string;
  25047. }
  25048. }
  25049. declare module BABYLON {
  25050. /**
  25051. * Default Inputs manager for the FreeCamera.
  25052. * It groups all the default supported inputs for ease of use.
  25053. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  25054. */
  25055. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  25056. /**
  25057. * @hidden
  25058. */
  25059. _mouseInput: Nullable<FreeCameraMouseInput>;
  25060. /**
  25061. * @hidden
  25062. */
  25063. _mouseWheelInput: Nullable<FreeCameraMouseWheelInput>;
  25064. /**
  25065. * Instantiates a new FreeCameraInputsManager.
  25066. * @param camera Defines the camera the inputs belong to
  25067. */
  25068. constructor(camera: FreeCamera);
  25069. /**
  25070. * Add keyboard input support to the input manager.
  25071. * @returns the current input manager
  25072. */
  25073. addKeyboard(): FreeCameraInputsManager;
  25074. /**
  25075. * Add mouse input support to the input manager.
  25076. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  25077. * @returns the current input manager
  25078. */
  25079. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  25080. /**
  25081. * Removes the mouse input support from the manager
  25082. * @returns the current input manager
  25083. */
  25084. removeMouse(): FreeCameraInputsManager;
  25085. /**
  25086. * Add mouse wheel input support to the input manager.
  25087. * @returns the current input manager
  25088. */
  25089. addMouseWheel(): FreeCameraInputsManager;
  25090. /**
  25091. * Removes the mouse wheel input support from the manager
  25092. * @returns the current input manager
  25093. */
  25094. removeMouseWheel(): FreeCameraInputsManager;
  25095. /**
  25096. * Add touch input support to the input manager.
  25097. * @returns the current input manager
  25098. */
  25099. addTouch(): FreeCameraInputsManager;
  25100. /**
  25101. * Remove all attached input methods from a camera
  25102. */
  25103. clear(): void;
  25104. }
  25105. }
  25106. declare module BABYLON {
  25107. /**
  25108. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  25109. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  25110. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  25111. */
  25112. export class FreeCamera extends TargetCamera {
  25113. /**
  25114. * Define the collision ellipsoid of the camera.
  25115. * This is helpful to simulate a camera body like the player body around the camera
  25116. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  25117. */
  25118. ellipsoid: Vector3;
  25119. /**
  25120. * Define an offset for the position of the ellipsoid around the camera.
  25121. * This can be helpful to determine the center of the body near the gravity center of the body
  25122. * instead of its head.
  25123. */
  25124. ellipsoidOffset: Vector3;
  25125. /**
  25126. * Enable or disable collisions of the camera with the rest of the scene objects.
  25127. */
  25128. checkCollisions: boolean;
  25129. /**
  25130. * Enable or disable gravity on the camera.
  25131. */
  25132. applyGravity: boolean;
  25133. /**
  25134. * Define the input manager associated to the camera.
  25135. */
  25136. inputs: FreeCameraInputsManager;
  25137. /**
  25138. * Gets the input sensibility for a mouse input. (default is 2000.0)
  25139. * Higher values reduce sensitivity.
  25140. */
  25141. get angularSensibility(): number;
  25142. /**
  25143. * Sets the input sensibility for a mouse input. (default is 2000.0)
  25144. * Higher values reduce sensitivity.
  25145. */
  25146. set angularSensibility(value: number);
  25147. /**
  25148. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  25149. */
  25150. get keysUp(): number[];
  25151. set keysUp(value: number[]);
  25152. /**
  25153. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  25154. */
  25155. get keysUpward(): number[];
  25156. set keysUpward(value: number[]);
  25157. /**
  25158. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  25159. */
  25160. get keysDown(): number[];
  25161. set keysDown(value: number[]);
  25162. /**
  25163. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  25164. */
  25165. get keysDownward(): number[];
  25166. set keysDownward(value: number[]);
  25167. /**
  25168. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  25169. */
  25170. get keysLeft(): number[];
  25171. set keysLeft(value: number[]);
  25172. /**
  25173. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  25174. */
  25175. get keysRight(): number[];
  25176. set keysRight(value: number[]);
  25177. /**
  25178. * Event raised when the camera collide with a mesh in the scene.
  25179. */
  25180. onCollide: (collidedMesh: AbstractMesh) => void;
  25181. private _collider;
  25182. private _needMoveForGravity;
  25183. private _oldPosition;
  25184. private _diffPosition;
  25185. private _newPosition;
  25186. /** @hidden */
  25187. _localDirection: Vector3;
  25188. /** @hidden */
  25189. _transformedDirection: Vector3;
  25190. /**
  25191. * Instantiates a Free Camera.
  25192. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  25193. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  25194. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  25195. * @param name Define the name of the camera in the scene
  25196. * @param position Define the start position of the camera in the scene
  25197. * @param scene Define the scene the camera belongs to
  25198. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  25199. */
  25200. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  25201. /**
  25202. * Attach the input controls to a specific dom element to get the input from.
  25203. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  25204. */
  25205. attachControl(noPreventDefault?: boolean): void;
  25206. /**
  25207. * Attach the input controls to a specific dom element to get the input from.
  25208. * @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
  25209. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  25210. * BACK COMPAT SIGNATURE ONLY.
  25211. */
  25212. attachControl(ignored: any, noPreventDefault?: boolean): void;
  25213. /**
  25214. * Detach the current controls from the specified dom element.
  25215. */
  25216. detachControl(): void;
  25217. /**
  25218. * Detach the current controls from the specified dom element.
  25219. * @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
  25220. */
  25221. detachControl(ignored: any): void;
  25222. private _collisionMask;
  25223. /**
  25224. * Define a collision mask to limit the list of object the camera can collide with
  25225. */
  25226. get collisionMask(): number;
  25227. set collisionMask(mask: number);
  25228. /** @hidden */
  25229. _collideWithWorld(displacement: Vector3): void;
  25230. private _onCollisionPositionChange;
  25231. /** @hidden */
  25232. _checkInputs(): void;
  25233. /** @hidden */
  25234. _decideIfNeedsToMove(): boolean;
  25235. /** @hidden */
  25236. _updatePosition(): void;
  25237. /**
  25238. * Destroy the camera and release the current resources hold by it.
  25239. */
  25240. dispose(): void;
  25241. /**
  25242. * Gets the current object class name.
  25243. * @return the class name
  25244. */
  25245. getClassName(): string;
  25246. }
  25247. }
  25248. declare module BABYLON {
  25249. /**
  25250. * Represents a gamepad control stick position
  25251. */
  25252. export class StickValues {
  25253. /**
  25254. * The x component of the control stick
  25255. */
  25256. x: number;
  25257. /**
  25258. * The y component of the control stick
  25259. */
  25260. y: number;
  25261. /**
  25262. * Initializes the gamepad x and y control stick values
  25263. * @param x The x component of the gamepad control stick value
  25264. * @param y The y component of the gamepad control stick value
  25265. */
  25266. constructor(
  25267. /**
  25268. * The x component of the control stick
  25269. */
  25270. x: number,
  25271. /**
  25272. * The y component of the control stick
  25273. */
  25274. y: number);
  25275. }
  25276. /**
  25277. * An interface which manages callbacks for gamepad button changes
  25278. */
  25279. export interface GamepadButtonChanges {
  25280. /**
  25281. * Called when a gamepad has been changed
  25282. */
  25283. changed: boolean;
  25284. /**
  25285. * Called when a gamepad press event has been triggered
  25286. */
  25287. pressChanged: boolean;
  25288. /**
  25289. * Called when a touch event has been triggered
  25290. */
  25291. touchChanged: boolean;
  25292. /**
  25293. * Called when a value has changed
  25294. */
  25295. valueChanged: boolean;
  25296. }
  25297. /**
  25298. * Represents a gamepad
  25299. */
  25300. export class Gamepad {
  25301. /**
  25302. * The id of the gamepad
  25303. */
  25304. id: string;
  25305. /**
  25306. * The index of the gamepad
  25307. */
  25308. index: number;
  25309. /**
  25310. * The browser gamepad
  25311. */
  25312. browserGamepad: any;
  25313. /**
  25314. * Specifies what type of gamepad this represents
  25315. */
  25316. type: number;
  25317. private _leftStick;
  25318. private _rightStick;
  25319. /** @hidden */
  25320. _isConnected: boolean;
  25321. private _leftStickAxisX;
  25322. private _leftStickAxisY;
  25323. private _rightStickAxisX;
  25324. private _rightStickAxisY;
  25325. /**
  25326. * Triggered when the left control stick has been changed
  25327. */
  25328. private _onleftstickchanged;
  25329. /**
  25330. * Triggered when the right control stick has been changed
  25331. */
  25332. private _onrightstickchanged;
  25333. /**
  25334. * Represents a gamepad controller
  25335. */
  25336. static GAMEPAD: number;
  25337. /**
  25338. * Represents a generic controller
  25339. */
  25340. static GENERIC: number;
  25341. /**
  25342. * Represents an XBox controller
  25343. */
  25344. static XBOX: number;
  25345. /**
  25346. * Represents a pose-enabled controller
  25347. */
  25348. static POSE_ENABLED: number;
  25349. /**
  25350. * Represents an Dual Shock controller
  25351. */
  25352. static DUALSHOCK: number;
  25353. /**
  25354. * Specifies whether the left control stick should be Y-inverted
  25355. */
  25356. protected _invertLeftStickY: boolean;
  25357. /**
  25358. * Specifies if the gamepad has been connected
  25359. */
  25360. get isConnected(): boolean;
  25361. /**
  25362. * Initializes the gamepad
  25363. * @param id The id of the gamepad
  25364. * @param index The index of the gamepad
  25365. * @param browserGamepad The browser gamepad
  25366. * @param leftStickX The x component of the left joystick
  25367. * @param leftStickY The y component of the left joystick
  25368. * @param rightStickX The x component of the right joystick
  25369. * @param rightStickY The y component of the right joystick
  25370. */
  25371. constructor(
  25372. /**
  25373. * The id of the gamepad
  25374. */
  25375. id: string,
  25376. /**
  25377. * The index of the gamepad
  25378. */
  25379. index: number,
  25380. /**
  25381. * The browser gamepad
  25382. */
  25383. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  25384. /**
  25385. * Callback triggered when the left joystick has changed
  25386. * @param callback
  25387. */
  25388. onleftstickchanged(callback: (values: StickValues) => void): void;
  25389. /**
  25390. * Callback triggered when the right joystick has changed
  25391. * @param callback
  25392. */
  25393. onrightstickchanged(callback: (values: StickValues) => void): void;
  25394. /**
  25395. * Gets the left joystick
  25396. */
  25397. get leftStick(): StickValues;
  25398. /**
  25399. * Sets the left joystick values
  25400. */
  25401. set leftStick(newValues: StickValues);
  25402. /**
  25403. * Gets the right joystick
  25404. */
  25405. get rightStick(): StickValues;
  25406. /**
  25407. * Sets the right joystick value
  25408. */
  25409. set rightStick(newValues: StickValues);
  25410. /**
  25411. * Updates the gamepad joystick positions
  25412. */
  25413. update(): void;
  25414. /**
  25415. * Disposes the gamepad
  25416. */
  25417. dispose(): void;
  25418. }
  25419. /**
  25420. * Represents a generic gamepad
  25421. */
  25422. export class GenericPad extends Gamepad {
  25423. private _buttons;
  25424. private _onbuttondown;
  25425. private _onbuttonup;
  25426. /**
  25427. * Observable triggered when a button has been pressed
  25428. */
  25429. onButtonDownObservable: Observable<number>;
  25430. /**
  25431. * Observable triggered when a button has been released
  25432. */
  25433. onButtonUpObservable: Observable<number>;
  25434. /**
  25435. * Callback triggered when a button has been pressed
  25436. * @param callback Called when a button has been pressed
  25437. */
  25438. onbuttondown(callback: (buttonPressed: number) => void): void;
  25439. /**
  25440. * Callback triggered when a button has been released
  25441. * @param callback Called when a button has been released
  25442. */
  25443. onbuttonup(callback: (buttonReleased: number) => void): void;
  25444. /**
  25445. * Initializes the generic gamepad
  25446. * @param id The id of the generic gamepad
  25447. * @param index The index of the generic gamepad
  25448. * @param browserGamepad The browser gamepad
  25449. */
  25450. constructor(id: string, index: number, browserGamepad: any);
  25451. private _setButtonValue;
  25452. /**
  25453. * Updates the generic gamepad
  25454. */
  25455. update(): void;
  25456. /**
  25457. * Disposes the generic gamepad
  25458. */
  25459. dispose(): void;
  25460. }
  25461. }
  25462. declare module BABYLON {
  25463. /**
  25464. * Defines a runtime animation
  25465. */
  25466. export class RuntimeAnimation {
  25467. private _events;
  25468. /**
  25469. * The current frame of the runtime animation
  25470. */
  25471. private _currentFrame;
  25472. /**
  25473. * The animation used by the runtime animation
  25474. */
  25475. private _animation;
  25476. /**
  25477. * The target of the runtime animation
  25478. */
  25479. private _target;
  25480. /**
  25481. * The initiating animatable
  25482. */
  25483. private _host;
  25484. /**
  25485. * The original value of the runtime animation
  25486. */
  25487. private _originalValue;
  25488. /**
  25489. * The original blend value of the runtime animation
  25490. */
  25491. private _originalBlendValue;
  25492. /**
  25493. * The offsets cache of the runtime animation
  25494. */
  25495. private _offsetsCache;
  25496. /**
  25497. * The high limits cache of the runtime animation
  25498. */
  25499. private _highLimitsCache;
  25500. /**
  25501. * Specifies if the runtime animation has been stopped
  25502. */
  25503. private _stopped;
  25504. /**
  25505. * The blending factor of the runtime animation
  25506. */
  25507. private _blendingFactor;
  25508. /**
  25509. * The BabylonJS scene
  25510. */
  25511. private _scene;
  25512. /**
  25513. * The current value of the runtime animation
  25514. */
  25515. private _currentValue;
  25516. /** @hidden */
  25517. _animationState: _IAnimationState;
  25518. /**
  25519. * The active target of the runtime animation
  25520. */
  25521. private _activeTargets;
  25522. private _currentActiveTarget;
  25523. private _directTarget;
  25524. /**
  25525. * The target path of the runtime animation
  25526. */
  25527. private _targetPath;
  25528. /**
  25529. * The weight of the runtime animation
  25530. */
  25531. private _weight;
  25532. /**
  25533. * The ratio offset of the runtime animation
  25534. */
  25535. private _ratioOffset;
  25536. /**
  25537. * The previous delay of the runtime animation
  25538. */
  25539. private _previousDelay;
  25540. /**
  25541. * The previous ratio of the runtime animation
  25542. */
  25543. private _previousRatio;
  25544. private _enableBlending;
  25545. private _keys;
  25546. private _minFrame;
  25547. private _maxFrame;
  25548. private _minValue;
  25549. private _maxValue;
  25550. private _targetIsArray;
  25551. /**
  25552. * Gets the current frame of the runtime animation
  25553. */
  25554. get currentFrame(): number;
  25555. /**
  25556. * Gets the weight of the runtime animation
  25557. */
  25558. get weight(): number;
  25559. /**
  25560. * Gets the current value of the runtime animation
  25561. */
  25562. get currentValue(): any;
  25563. /**
  25564. * Gets the target path of the runtime animation
  25565. */
  25566. get targetPath(): string;
  25567. /**
  25568. * Gets the actual target of the runtime animation
  25569. */
  25570. get target(): any;
  25571. /**
  25572. * Gets the additive state of the runtime animation
  25573. */
  25574. get isAdditive(): boolean;
  25575. /** @hidden */
  25576. _onLoop: () => void;
  25577. /**
  25578. * Create a new RuntimeAnimation object
  25579. * @param target defines the target of the animation
  25580. * @param animation defines the source animation object
  25581. * @param scene defines the hosting scene
  25582. * @param host defines the initiating Animatable
  25583. */
  25584. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  25585. private _preparePath;
  25586. /**
  25587. * Gets the animation from the runtime animation
  25588. */
  25589. get animation(): Animation;
  25590. /**
  25591. * Resets the runtime animation to the beginning
  25592. * @param restoreOriginal defines whether to restore the target property to the original value
  25593. */
  25594. reset(restoreOriginal?: boolean): void;
  25595. /**
  25596. * Specifies if the runtime animation is stopped
  25597. * @returns Boolean specifying if the runtime animation is stopped
  25598. */
  25599. isStopped(): boolean;
  25600. /**
  25601. * Disposes of the runtime animation
  25602. */
  25603. dispose(): void;
  25604. /**
  25605. * Apply the interpolated value to the target
  25606. * @param currentValue defines the value computed by the animation
  25607. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  25608. */
  25609. setValue(currentValue: any, weight: number): void;
  25610. private _getOriginalValues;
  25611. private _setValue;
  25612. /**
  25613. * Gets the loop pmode of the runtime animation
  25614. * @returns Loop Mode
  25615. */
  25616. private _getCorrectLoopMode;
  25617. /**
  25618. * Move the current animation to a given frame
  25619. * @param frame defines the frame to move to
  25620. */
  25621. goToFrame(frame: number): void;
  25622. /**
  25623. * @hidden Internal use only
  25624. */
  25625. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  25626. /**
  25627. * Execute the current animation
  25628. * @param delay defines the delay to add to the current frame
  25629. * @param from defines the lower bound of the animation range
  25630. * @param to defines the upper bound of the animation range
  25631. * @param loop defines if the current animation must loop
  25632. * @param speedRatio defines the current speed ratio
  25633. * @param weight defines the weight of the animation (default is -1 so no weight)
  25634. * @param onLoop optional callback called when animation loops
  25635. * @returns a boolean indicating if the animation is running
  25636. */
  25637. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  25638. }
  25639. }
  25640. declare module BABYLON {
  25641. /**
  25642. * Class used to store an actual running animation
  25643. */
  25644. export class Animatable {
  25645. /** defines the target object */
  25646. target: any;
  25647. /** defines the starting frame number (default is 0) */
  25648. fromFrame: number;
  25649. /** defines the ending frame number (default is 100) */
  25650. toFrame: number;
  25651. /** defines if the animation must loop (default is false) */
  25652. loopAnimation: boolean;
  25653. /** defines a callback to call when animation ends if it is not looping */
  25654. onAnimationEnd?: (() => void) | null | undefined;
  25655. /** defines a callback to call when animation loops */
  25656. onAnimationLoop?: (() => void) | null | undefined;
  25657. /** defines whether the animation should be evaluated additively */
  25658. isAdditive: boolean;
  25659. private _localDelayOffset;
  25660. private _pausedDelay;
  25661. private _runtimeAnimations;
  25662. private _paused;
  25663. private _scene;
  25664. private _speedRatio;
  25665. private _weight;
  25666. private _syncRoot;
  25667. /**
  25668. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  25669. * This will only apply for non looping animation (default is true)
  25670. */
  25671. disposeOnEnd: boolean;
  25672. /**
  25673. * Gets a boolean indicating if the animation has started
  25674. */
  25675. animationStarted: boolean;
  25676. /**
  25677. * Observer raised when the animation ends
  25678. */
  25679. onAnimationEndObservable: Observable<Animatable>;
  25680. /**
  25681. * Observer raised when the animation loops
  25682. */
  25683. onAnimationLoopObservable: Observable<Animatable>;
  25684. /**
  25685. * Gets the root Animatable used to synchronize and normalize animations
  25686. */
  25687. get syncRoot(): Nullable<Animatable>;
  25688. /**
  25689. * Gets the current frame of the first RuntimeAnimation
  25690. * Used to synchronize Animatables
  25691. */
  25692. get masterFrame(): number;
  25693. /**
  25694. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  25695. */
  25696. get weight(): number;
  25697. set weight(value: number);
  25698. /**
  25699. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  25700. */
  25701. get speedRatio(): number;
  25702. set speedRatio(value: number);
  25703. /**
  25704. * Creates a new Animatable
  25705. * @param scene defines the hosting scene
  25706. * @param target defines the target object
  25707. * @param fromFrame defines the starting frame number (default is 0)
  25708. * @param toFrame defines the ending frame number (default is 100)
  25709. * @param loopAnimation defines if the animation must loop (default is false)
  25710. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  25711. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  25712. * @param animations defines a group of animation to add to the new Animatable
  25713. * @param onAnimationLoop defines a callback to call when animation loops
  25714. * @param isAdditive defines whether the animation should be evaluated additively
  25715. */
  25716. constructor(scene: Scene,
  25717. /** defines the target object */
  25718. target: any,
  25719. /** defines the starting frame number (default is 0) */
  25720. fromFrame?: number,
  25721. /** defines the ending frame number (default is 100) */
  25722. toFrame?: number,
  25723. /** defines if the animation must loop (default is false) */
  25724. loopAnimation?: boolean, speedRatio?: number,
  25725. /** defines a callback to call when animation ends if it is not looping */
  25726. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  25727. /** defines a callback to call when animation loops */
  25728. onAnimationLoop?: (() => void) | null | undefined,
  25729. /** defines whether the animation should be evaluated additively */
  25730. isAdditive?: boolean);
  25731. /**
  25732. * Synchronize and normalize current Animatable with a source Animatable
  25733. * This is useful when using animation weights and when animations are not of the same length
  25734. * @param root defines the root Animatable to synchronize with
  25735. * @returns the current Animatable
  25736. */
  25737. syncWith(root: Animatable): Animatable;
  25738. /**
  25739. * Gets the list of runtime animations
  25740. * @returns an array of RuntimeAnimation
  25741. */
  25742. getAnimations(): RuntimeAnimation[];
  25743. /**
  25744. * Adds more animations to the current animatable
  25745. * @param target defines the target of the animations
  25746. * @param animations defines the new animations to add
  25747. */
  25748. appendAnimations(target: any, animations: Animation[]): void;
  25749. /**
  25750. * Gets the source animation for a specific property
  25751. * @param property defines the propertyu to look for
  25752. * @returns null or the source animation for the given property
  25753. */
  25754. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  25755. /**
  25756. * Gets the runtime animation for a specific property
  25757. * @param property defines the propertyu to look for
  25758. * @returns null or the runtime animation for the given property
  25759. */
  25760. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  25761. /**
  25762. * Resets the animatable to its original state
  25763. */
  25764. reset(): void;
  25765. /**
  25766. * Allows the animatable to blend with current running animations
  25767. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  25768. * @param blendingSpeed defines the blending speed to use
  25769. */
  25770. enableBlending(blendingSpeed: number): void;
  25771. /**
  25772. * Disable animation blending
  25773. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  25774. */
  25775. disableBlending(): void;
  25776. /**
  25777. * Jump directly to a given frame
  25778. * @param frame defines the frame to jump to
  25779. */
  25780. goToFrame(frame: number): void;
  25781. /**
  25782. * Pause the animation
  25783. */
  25784. pause(): void;
  25785. /**
  25786. * Restart the animation
  25787. */
  25788. restart(): void;
  25789. private _raiseOnAnimationEnd;
  25790. /**
  25791. * Stop and delete the current animation
  25792. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  25793. * @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)
  25794. */
  25795. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  25796. /**
  25797. * Wait asynchronously for the animation to end
  25798. * @returns a promise which will be fullfilled when the animation ends
  25799. */
  25800. waitAsync(): Promise<Animatable>;
  25801. /** @hidden */
  25802. _animate(delay: number): boolean;
  25803. }
  25804. interface Scene {
  25805. /** @hidden */
  25806. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  25807. /** @hidden */
  25808. _processLateAnimationBindingsForMatrices(holder: {
  25809. totalWeight: number;
  25810. totalAdditiveWeight: number;
  25811. animations: RuntimeAnimation[];
  25812. additiveAnimations: RuntimeAnimation[];
  25813. originalValue: Matrix;
  25814. }): any;
  25815. /** @hidden */
  25816. _processLateAnimationBindingsForQuaternions(holder: {
  25817. totalWeight: number;
  25818. totalAdditiveWeight: number;
  25819. animations: RuntimeAnimation[];
  25820. additiveAnimations: RuntimeAnimation[];
  25821. originalValue: Quaternion;
  25822. }, refQuaternion: Quaternion): Quaternion;
  25823. /** @hidden */
  25824. _processLateAnimationBindings(): void;
  25825. /**
  25826. * Will start the animation sequence of a given target
  25827. * @param target defines the target
  25828. * @param from defines from which frame should animation start
  25829. * @param to defines until which frame should animation run.
  25830. * @param weight defines the weight to apply to the animation (1.0 by default)
  25831. * @param loop defines if the animation loops
  25832. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  25833. * @param onAnimationEnd defines the function to be executed when the animation ends
  25834. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  25835. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  25836. * @param onAnimationLoop defines the callback to call when an animation loops
  25837. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  25838. * @returns the animatable object created for this animation
  25839. */
  25840. 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;
  25841. /**
  25842. * Will start the animation sequence of a given target
  25843. * @param target defines the target
  25844. * @param from defines from which frame should animation start
  25845. * @param to defines until which frame should animation run.
  25846. * @param loop defines if the animation loops
  25847. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  25848. * @param onAnimationEnd defines the function to be executed when the animation ends
  25849. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  25850. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  25851. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  25852. * @param onAnimationLoop defines the callback to call when an animation loops
  25853. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  25854. * @returns the animatable object created for this animation
  25855. */
  25856. 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;
  25857. /**
  25858. * Will start the animation sequence of a given target and its hierarchy
  25859. * @param target defines the target
  25860. * @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.
  25861. * @param from defines from which frame should animation start
  25862. * @param to defines until which frame should animation run.
  25863. * @param loop defines if the animation loops
  25864. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  25865. * @param onAnimationEnd defines the function to be executed when the animation ends
  25866. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  25867. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  25868. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  25869. * @param onAnimationLoop defines the callback to call when an animation loops
  25870. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  25871. * @returns the list of created animatables
  25872. */
  25873. 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[];
  25874. /**
  25875. * Begin a new animation on a given node
  25876. * @param target defines the target where the animation will take place
  25877. * @param animations defines the list of animations to start
  25878. * @param from defines the initial value
  25879. * @param to defines the final value
  25880. * @param loop defines if you want animation to loop (off by default)
  25881. * @param speedRatio defines the speed ratio to apply to all animations
  25882. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  25883. * @param onAnimationLoop defines the callback to call when an animation loops
  25884. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  25885. * @returns the list of created animatables
  25886. */
  25887. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  25888. /**
  25889. * Begin a new animation on a given node and its hierarchy
  25890. * @param target defines the root node where the animation will take place
  25891. * @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.
  25892. * @param animations defines the list of animations to start
  25893. * @param from defines the initial value
  25894. * @param to defines the final value
  25895. * @param loop defines if you want animation to loop (off by default)
  25896. * @param speedRatio defines the speed ratio to apply to all animations
  25897. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  25898. * @param onAnimationLoop defines the callback to call when an animation loops
  25899. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  25900. * @returns the list of animatables created for all nodes
  25901. */
  25902. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  25903. /**
  25904. * Gets the animatable associated with a specific target
  25905. * @param target defines the target of the animatable
  25906. * @returns the required animatable if found
  25907. */
  25908. getAnimatableByTarget(target: any): Nullable<Animatable>;
  25909. /**
  25910. * Gets all animatables associated with a given target
  25911. * @param target defines the target to look animatables for
  25912. * @returns an array of Animatables
  25913. */
  25914. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  25915. /**
  25916. * Stops and removes all animations that have been applied to the scene
  25917. */
  25918. stopAllAnimations(): void;
  25919. /**
  25920. * Gets the current delta time used by animation engine
  25921. */
  25922. deltaTime: number;
  25923. }
  25924. interface Bone {
  25925. /**
  25926. * Copy an animation range from another bone
  25927. * @param source defines the source bone
  25928. * @param rangeName defines the range name to copy
  25929. * @param frameOffset defines the frame offset
  25930. * @param rescaleAsRequired defines if rescaling must be applied if required
  25931. * @param skelDimensionsRatio defines the scaling ratio
  25932. * @returns true if operation was successful
  25933. */
  25934. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  25935. }
  25936. }
  25937. declare module BABYLON {
  25938. /**
  25939. * Class used to override all child animations of a given target
  25940. */
  25941. export class AnimationPropertiesOverride {
  25942. /**
  25943. * Gets or sets a value indicating if animation blending must be used
  25944. */
  25945. enableBlending: boolean;
  25946. /**
  25947. * Gets or sets the blending speed to use when enableBlending is true
  25948. */
  25949. blendingSpeed: number;
  25950. /**
  25951. * Gets or sets the default loop mode to use
  25952. */
  25953. loopMode: number;
  25954. }
  25955. }
  25956. declare module BABYLON {
  25957. /**
  25958. * Class used to handle skinning animations
  25959. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  25960. */
  25961. export class Skeleton implements IAnimatable {
  25962. /** defines the skeleton name */
  25963. name: string;
  25964. /** defines the skeleton Id */
  25965. id: string;
  25966. /**
  25967. * Defines the list of child bones
  25968. */
  25969. bones: Bone[];
  25970. /**
  25971. * Defines an estimate of the dimension of the skeleton at rest
  25972. */
  25973. dimensionsAtRest: Vector3;
  25974. /**
  25975. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  25976. */
  25977. needInitialSkinMatrix: boolean;
  25978. /**
  25979. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  25980. */
  25981. overrideMesh: Nullable<AbstractMesh>;
  25982. /**
  25983. * Gets the list of animations attached to this skeleton
  25984. */
  25985. animations: Array<Animation>;
  25986. private _scene;
  25987. private _isDirty;
  25988. private _transformMatrices;
  25989. private _transformMatrixTexture;
  25990. private _meshesWithPoseMatrix;
  25991. private _animatables;
  25992. private _identity;
  25993. private _synchronizedWithMesh;
  25994. private _ranges;
  25995. private _lastAbsoluteTransformsUpdateId;
  25996. private _canUseTextureForBones;
  25997. private _uniqueId;
  25998. /** @hidden */
  25999. _numBonesWithLinkedTransformNode: number;
  26000. /** @hidden */
  26001. _hasWaitingData: Nullable<boolean>;
  26002. /** @hidden */
  26003. _waitingOverrideMeshId: Nullable<string>;
  26004. /**
  26005. * Specifies if the skeleton should be serialized
  26006. */
  26007. doNotSerialize: boolean;
  26008. private _useTextureToStoreBoneMatrices;
  26009. /**
  26010. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  26011. * Please note that this option is not available if the hardware does not support it
  26012. */
  26013. get useTextureToStoreBoneMatrices(): boolean;
  26014. set useTextureToStoreBoneMatrices(value: boolean);
  26015. private _animationPropertiesOverride;
  26016. /**
  26017. * Gets or sets the animation properties override
  26018. */
  26019. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  26020. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  26021. /**
  26022. * List of inspectable custom properties (used by the Inspector)
  26023. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  26024. */
  26025. inspectableCustomProperties: IInspectable[];
  26026. /**
  26027. * An observable triggered before computing the skeleton's matrices
  26028. */
  26029. onBeforeComputeObservable: Observable<Skeleton>;
  26030. /**
  26031. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  26032. */
  26033. get isUsingTextureForMatrices(): boolean;
  26034. /**
  26035. * Gets the unique ID of this skeleton
  26036. */
  26037. get uniqueId(): number;
  26038. /**
  26039. * Creates a new skeleton
  26040. * @param name defines the skeleton name
  26041. * @param id defines the skeleton Id
  26042. * @param scene defines the hosting scene
  26043. */
  26044. constructor(
  26045. /** defines the skeleton name */
  26046. name: string,
  26047. /** defines the skeleton Id */
  26048. id: string, scene: Scene);
  26049. /**
  26050. * Gets the current object class name.
  26051. * @return the class name
  26052. */
  26053. getClassName(): string;
  26054. /**
  26055. * Returns an array containing the root bones
  26056. * @returns an array containing the root bones
  26057. */
  26058. getChildren(): Array<Bone>;
  26059. /**
  26060. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  26061. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  26062. * @returns a Float32Array containing matrices data
  26063. */
  26064. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  26065. /**
  26066. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  26067. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  26068. * @returns a raw texture containing the data
  26069. */
  26070. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  26071. /**
  26072. * Gets the current hosting scene
  26073. * @returns a scene object
  26074. */
  26075. getScene(): Scene;
  26076. /**
  26077. * Gets a string representing the current skeleton data
  26078. * @param fullDetails defines a boolean indicating if we want a verbose version
  26079. * @returns a string representing the current skeleton data
  26080. */
  26081. toString(fullDetails?: boolean): string;
  26082. /**
  26083. * Get bone's index searching by name
  26084. * @param name defines bone's name to search for
  26085. * @return the indice of the bone. Returns -1 if not found
  26086. */
  26087. getBoneIndexByName(name: string): number;
  26088. /**
  26089. * Creater a new animation range
  26090. * @param name defines the name of the range
  26091. * @param from defines the start key
  26092. * @param to defines the end key
  26093. */
  26094. createAnimationRange(name: string, from: number, to: number): void;
  26095. /**
  26096. * Delete a specific animation range
  26097. * @param name defines the name of the range
  26098. * @param deleteFrames defines if frames must be removed as well
  26099. */
  26100. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  26101. /**
  26102. * Gets a specific animation range
  26103. * @param name defines the name of the range to look for
  26104. * @returns the requested animation range or null if not found
  26105. */
  26106. getAnimationRange(name: string): Nullable<AnimationRange>;
  26107. /**
  26108. * Gets the list of all animation ranges defined on this skeleton
  26109. * @returns an array
  26110. */
  26111. getAnimationRanges(): Nullable<AnimationRange>[];
  26112. /**
  26113. * Copy animation range from a source skeleton.
  26114. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  26115. * @param source defines the source skeleton
  26116. * @param name defines the name of the range to copy
  26117. * @param rescaleAsRequired defines if rescaling must be applied if required
  26118. * @returns true if operation was successful
  26119. */
  26120. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  26121. /**
  26122. * Forces the skeleton to go to rest pose
  26123. */
  26124. returnToRest(): void;
  26125. private _getHighestAnimationFrame;
  26126. /**
  26127. * Begin a specific animation range
  26128. * @param name defines the name of the range to start
  26129. * @param loop defines if looping must be turned on (false by default)
  26130. * @param speedRatio defines the speed ratio to apply (1 by default)
  26131. * @param onAnimationEnd defines a callback which will be called when animation will end
  26132. * @returns a new animatable
  26133. */
  26134. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  26135. /**
  26136. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  26137. * @param skeleton defines the Skeleton containing the animation range to convert
  26138. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  26139. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  26140. * @returns the original skeleton
  26141. */
  26142. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  26143. /** @hidden */
  26144. _markAsDirty(): void;
  26145. /** @hidden */
  26146. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  26147. /** @hidden */
  26148. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  26149. private _computeTransformMatrices;
  26150. /**
  26151. * Build all resources required to render a skeleton
  26152. */
  26153. prepare(): void;
  26154. /**
  26155. * Gets the list of animatables currently running for this skeleton
  26156. * @returns an array of animatables
  26157. */
  26158. getAnimatables(): IAnimatable[];
  26159. /**
  26160. * Clone the current skeleton
  26161. * @param name defines the name of the new skeleton
  26162. * @param id defines the id of the new skeleton
  26163. * @returns the new skeleton
  26164. */
  26165. clone(name: string, id?: string): Skeleton;
  26166. /**
  26167. * Enable animation blending for this skeleton
  26168. * @param blendingSpeed defines the blending speed to apply
  26169. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  26170. */
  26171. enableBlending(blendingSpeed?: number): void;
  26172. /**
  26173. * Releases all resources associated with the current skeleton
  26174. */
  26175. dispose(): void;
  26176. /**
  26177. * Serialize the skeleton in a JSON object
  26178. * @returns a JSON object
  26179. */
  26180. serialize(): any;
  26181. /**
  26182. * Creates a new skeleton from serialized data
  26183. * @param parsedSkeleton defines the serialized data
  26184. * @param scene defines the hosting scene
  26185. * @returns a new skeleton
  26186. */
  26187. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  26188. /**
  26189. * Compute all node absolute transforms
  26190. * @param forceUpdate defines if computation must be done even if cache is up to date
  26191. */
  26192. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  26193. /**
  26194. * Gets the root pose matrix
  26195. * @returns a matrix
  26196. */
  26197. getPoseMatrix(): Nullable<Matrix>;
  26198. /**
  26199. * Sorts bones per internal index
  26200. */
  26201. sortBones(): void;
  26202. private _sortBones;
  26203. /**
  26204. * Set the current local matrix as the restPose for all bones in the skeleton.
  26205. */
  26206. setCurrentPoseAsRest(): void;
  26207. }
  26208. }
  26209. declare module BABYLON {
  26210. /**
  26211. * Class used to store bone information
  26212. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  26213. */
  26214. export class Bone extends Node {
  26215. /**
  26216. * defines the bone name
  26217. */
  26218. name: string;
  26219. private static _tmpVecs;
  26220. private static _tmpQuat;
  26221. private static _tmpMats;
  26222. /**
  26223. * Gets the list of child bones
  26224. */
  26225. children: Bone[];
  26226. /** Gets the animations associated with this bone */
  26227. animations: Animation[];
  26228. /**
  26229. * Gets or sets bone length
  26230. */
  26231. length: number;
  26232. /**
  26233. * @hidden Internal only
  26234. * Set this value to map this bone to a different index in the transform matrices
  26235. * Set this value to -1 to exclude the bone from the transform matrices
  26236. */
  26237. _index: Nullable<number>;
  26238. private _skeleton;
  26239. private _localMatrix;
  26240. private _restPose;
  26241. private _bindPose;
  26242. private _baseMatrix;
  26243. private _absoluteTransform;
  26244. private _invertedAbsoluteTransform;
  26245. private _parent;
  26246. private _scalingDeterminant;
  26247. private _worldTransform;
  26248. private _localScaling;
  26249. private _localRotation;
  26250. private _localPosition;
  26251. private _needToDecompose;
  26252. private _needToCompose;
  26253. /** @hidden */
  26254. _linkedTransformNode: Nullable<TransformNode>;
  26255. /** @hidden */
  26256. _waitingTransformNodeId: Nullable<string>;
  26257. /** @hidden */
  26258. get _matrix(): Matrix;
  26259. /** @hidden */
  26260. set _matrix(value: Matrix);
  26261. /**
  26262. * Create a new bone
  26263. * @param name defines the bone name
  26264. * @param skeleton defines the parent skeleton
  26265. * @param parentBone defines the parent (can be null if the bone is the root)
  26266. * @param localMatrix defines the local matrix
  26267. * @param restPose defines the rest pose matrix
  26268. * @param baseMatrix defines the base matrix
  26269. * @param index defines index of the bone in the hiearchy
  26270. */
  26271. constructor(
  26272. /**
  26273. * defines the bone name
  26274. */
  26275. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  26276. /**
  26277. * Gets the current object class name.
  26278. * @return the class name
  26279. */
  26280. getClassName(): string;
  26281. /**
  26282. * Gets the parent skeleton
  26283. * @returns a skeleton
  26284. */
  26285. getSkeleton(): Skeleton;
  26286. /**
  26287. * Gets parent bone
  26288. * @returns a bone or null if the bone is the root of the bone hierarchy
  26289. */
  26290. getParent(): Nullable<Bone>;
  26291. /**
  26292. * Returns an array containing the root bones
  26293. * @returns an array containing the root bones
  26294. */
  26295. getChildren(): Array<Bone>;
  26296. /**
  26297. * Gets the node index in matrix array generated for rendering
  26298. * @returns the node index
  26299. */
  26300. getIndex(): number;
  26301. /**
  26302. * Sets the parent bone
  26303. * @param parent defines the parent (can be null if the bone is the root)
  26304. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  26305. */
  26306. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  26307. /**
  26308. * Gets the local matrix
  26309. * @returns a matrix
  26310. */
  26311. getLocalMatrix(): Matrix;
  26312. /**
  26313. * Gets the base matrix (initial matrix which remains unchanged)
  26314. * @returns a matrix
  26315. */
  26316. getBaseMatrix(): Matrix;
  26317. /**
  26318. * Gets the rest pose matrix
  26319. * @returns a matrix
  26320. */
  26321. getRestPose(): Matrix;
  26322. /**
  26323. * Sets the rest pose matrix
  26324. * @param matrix the local-space rest pose to set for this bone
  26325. */
  26326. setRestPose(matrix: Matrix): void;
  26327. /**
  26328. * Gets the bind pose matrix
  26329. * @returns the bind pose matrix
  26330. */
  26331. getBindPose(): Matrix;
  26332. /**
  26333. * Sets the bind pose matrix
  26334. * @param matrix the local-space bind pose to set for this bone
  26335. */
  26336. setBindPose(matrix: Matrix): void;
  26337. /**
  26338. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  26339. */
  26340. getWorldMatrix(): Matrix;
  26341. /**
  26342. * Sets the local matrix to rest pose matrix
  26343. */
  26344. returnToRest(): void;
  26345. /**
  26346. * Gets the inverse of the absolute transform matrix.
  26347. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  26348. * @returns a matrix
  26349. */
  26350. getInvertedAbsoluteTransform(): Matrix;
  26351. /**
  26352. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  26353. * @returns a matrix
  26354. */
  26355. getAbsoluteTransform(): Matrix;
  26356. /**
  26357. * Links with the given transform node.
  26358. * The local matrix of this bone is copied from the transform node every frame.
  26359. * @param transformNode defines the transform node to link to
  26360. */
  26361. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  26362. /**
  26363. * Gets the node used to drive the bone's transformation
  26364. * @returns a transform node or null
  26365. */
  26366. getTransformNode(): Nullable<TransformNode>;
  26367. /** Gets or sets current position (in local space) */
  26368. get position(): Vector3;
  26369. set position(newPosition: Vector3);
  26370. /** Gets or sets current rotation (in local space) */
  26371. get rotation(): Vector3;
  26372. set rotation(newRotation: Vector3);
  26373. /** Gets or sets current rotation quaternion (in local space) */
  26374. get rotationQuaternion(): Quaternion;
  26375. set rotationQuaternion(newRotation: Quaternion);
  26376. /** Gets or sets current scaling (in local space) */
  26377. get scaling(): Vector3;
  26378. set scaling(newScaling: Vector3);
  26379. /**
  26380. * Gets the animation properties override
  26381. */
  26382. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  26383. private _decompose;
  26384. private _compose;
  26385. /**
  26386. * Update the base and local matrices
  26387. * @param matrix defines the new base or local matrix
  26388. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  26389. * @param updateLocalMatrix defines if the local matrix should be updated
  26390. */
  26391. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  26392. /** @hidden */
  26393. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  26394. /**
  26395. * Flag the bone as dirty (Forcing it to update everything)
  26396. */
  26397. markAsDirty(): void;
  26398. /** @hidden */
  26399. _markAsDirtyAndCompose(): void;
  26400. private _markAsDirtyAndDecompose;
  26401. /**
  26402. * Translate the bone in local or world space
  26403. * @param vec The amount to translate the bone
  26404. * @param space The space that the translation is in
  26405. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26406. */
  26407. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  26408. /**
  26409. * Set the postion of the bone in local or world space
  26410. * @param position The position to set the bone
  26411. * @param space The space that the position is in
  26412. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26413. */
  26414. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  26415. /**
  26416. * Set the absolute position of the bone (world space)
  26417. * @param position The position to set the bone
  26418. * @param mesh The mesh that this bone is attached to
  26419. */
  26420. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  26421. /**
  26422. * Scale the bone on the x, y and z axes (in local space)
  26423. * @param x The amount to scale the bone on the x axis
  26424. * @param y The amount to scale the bone on the y axis
  26425. * @param z The amount to scale the bone on the z axis
  26426. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  26427. */
  26428. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  26429. /**
  26430. * Set the bone scaling in local space
  26431. * @param scale defines the scaling vector
  26432. */
  26433. setScale(scale: Vector3): void;
  26434. /**
  26435. * Gets the current scaling in local space
  26436. * @returns the current scaling vector
  26437. */
  26438. getScale(): Vector3;
  26439. /**
  26440. * Gets the current scaling in local space and stores it in a target vector
  26441. * @param result defines the target vector
  26442. */
  26443. getScaleToRef(result: Vector3): void;
  26444. /**
  26445. * Set the yaw, pitch, and roll of the bone in local or world space
  26446. * @param yaw The rotation of the bone on the y axis
  26447. * @param pitch The rotation of the bone on the x axis
  26448. * @param roll The rotation of the bone on the z axis
  26449. * @param space The space that the axes of rotation are in
  26450. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26451. */
  26452. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  26453. /**
  26454. * Add a rotation to the bone on an axis in local or world space
  26455. * @param axis The axis to rotate the bone on
  26456. * @param amount The amount to rotate the bone
  26457. * @param space The space that the axis is in
  26458. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26459. */
  26460. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  26461. /**
  26462. * Set the rotation of the bone to a particular axis angle in local or world space
  26463. * @param axis The axis to rotate the bone on
  26464. * @param angle The angle that the bone should be rotated to
  26465. * @param space The space that the axis is in
  26466. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26467. */
  26468. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  26469. /**
  26470. * Set the euler rotation of the bone in local or world space
  26471. * @param rotation The euler rotation that the bone should be set to
  26472. * @param space The space that the rotation is in
  26473. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26474. */
  26475. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  26476. /**
  26477. * Set the quaternion rotation of the bone in local or world space
  26478. * @param quat The quaternion rotation that the bone should be set to
  26479. * @param space The space that the rotation is in
  26480. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26481. */
  26482. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  26483. /**
  26484. * Set the rotation matrix of the bone in local or world space
  26485. * @param rotMat The rotation matrix that the bone should be set to
  26486. * @param space The space that the rotation is in
  26487. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26488. */
  26489. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  26490. private _rotateWithMatrix;
  26491. private _getNegativeRotationToRef;
  26492. /**
  26493. * Get the position of the bone in local or world space
  26494. * @param space The space that the returned position is in
  26495. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26496. * @returns The position of the bone
  26497. */
  26498. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  26499. /**
  26500. * Copy the position of the bone to a vector3 in local or world space
  26501. * @param space The space that the returned position is in
  26502. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26503. * @param result The vector3 to copy the position to
  26504. */
  26505. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  26506. /**
  26507. * Get the absolute position of the bone (world space)
  26508. * @param mesh The mesh that this bone is attached to
  26509. * @returns The absolute position of the bone
  26510. */
  26511. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  26512. /**
  26513. * Copy the absolute position of the bone (world space) to the result param
  26514. * @param mesh The mesh that this bone is attached to
  26515. * @param result The vector3 to copy the absolute position to
  26516. */
  26517. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  26518. /**
  26519. * Compute the absolute transforms of this bone and its children
  26520. */
  26521. computeAbsoluteTransforms(): void;
  26522. /**
  26523. * Get the world direction from an axis that is in the local space of the bone
  26524. * @param localAxis The local direction that is used to compute the world direction
  26525. * @param mesh The mesh that this bone is attached to
  26526. * @returns The world direction
  26527. */
  26528. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  26529. /**
  26530. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  26531. * @param localAxis The local direction that is used to compute the world direction
  26532. * @param mesh The mesh that this bone is attached to
  26533. * @param result The vector3 that the world direction will be copied to
  26534. */
  26535. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  26536. /**
  26537. * Get the euler rotation of the bone in local or world space
  26538. * @param space The space that the rotation should be in
  26539. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26540. * @returns The euler rotation
  26541. */
  26542. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  26543. /**
  26544. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  26545. * @param space The space that the rotation should be in
  26546. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26547. * @param result The vector3 that the rotation should be copied to
  26548. */
  26549. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  26550. /**
  26551. * Get the quaternion rotation of the bone in either local or world space
  26552. * @param space The space that the rotation should be in
  26553. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26554. * @returns The quaternion rotation
  26555. */
  26556. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  26557. /**
  26558. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  26559. * @param space The space that the rotation should be in
  26560. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26561. * @param result The quaternion that the rotation should be copied to
  26562. */
  26563. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  26564. /**
  26565. * Get the rotation matrix of the bone in local or world space
  26566. * @param space The space that the rotation should be in
  26567. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26568. * @returns The rotation matrix
  26569. */
  26570. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  26571. /**
  26572. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  26573. * @param space The space that the rotation should be in
  26574. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26575. * @param result The quaternion that the rotation should be copied to
  26576. */
  26577. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  26578. /**
  26579. * Get the world position of a point that is in the local space of the bone
  26580. * @param position The local position
  26581. * @param mesh The mesh that this bone is attached to
  26582. * @returns The world position
  26583. */
  26584. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  26585. /**
  26586. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  26587. * @param position The local position
  26588. * @param mesh The mesh that this bone is attached to
  26589. * @param result The vector3 that the world position should be copied to
  26590. */
  26591. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  26592. /**
  26593. * Get the local position of a point that is in world space
  26594. * @param position The world position
  26595. * @param mesh The mesh that this bone is attached to
  26596. * @returns The local position
  26597. */
  26598. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  26599. /**
  26600. * Get the local position of a point that is in world space and copy it to the result param
  26601. * @param position The world position
  26602. * @param mesh The mesh that this bone is attached to
  26603. * @param result The vector3 that the local position should be copied to
  26604. */
  26605. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  26606. /**
  26607. * Set the current local matrix as the restPose for this bone.
  26608. */
  26609. setCurrentPoseAsRest(): void;
  26610. }
  26611. }
  26612. declare module BABYLON {
  26613. /**
  26614. * 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.
  26615. * @see https://doc.babylonjs.com/how_to/transformnode
  26616. */
  26617. export class TransformNode extends Node {
  26618. /**
  26619. * Object will not rotate to face the camera
  26620. */
  26621. static BILLBOARDMODE_NONE: number;
  26622. /**
  26623. * Object will rotate to face the camera but only on the x axis
  26624. */
  26625. static BILLBOARDMODE_X: number;
  26626. /**
  26627. * Object will rotate to face the camera but only on the y axis
  26628. */
  26629. static BILLBOARDMODE_Y: number;
  26630. /**
  26631. * Object will rotate to face the camera but only on the z axis
  26632. */
  26633. static BILLBOARDMODE_Z: number;
  26634. /**
  26635. * Object will rotate to face the camera
  26636. */
  26637. static BILLBOARDMODE_ALL: number;
  26638. /**
  26639. * Object will rotate to face the camera's position instead of orientation
  26640. */
  26641. static BILLBOARDMODE_USE_POSITION: number;
  26642. private static _TmpRotation;
  26643. private static _TmpScaling;
  26644. private static _TmpTranslation;
  26645. private _forward;
  26646. private _forwardInverted;
  26647. private _up;
  26648. private _right;
  26649. private _rightInverted;
  26650. private _position;
  26651. private _rotation;
  26652. private _rotationQuaternion;
  26653. protected _scaling: Vector3;
  26654. protected _isDirty: boolean;
  26655. private _transformToBoneReferal;
  26656. private _isAbsoluteSynced;
  26657. private _billboardMode;
  26658. /**
  26659. * Gets or sets the billboard mode. Default is 0.
  26660. *
  26661. * | Value | Type | Description |
  26662. * | --- | --- | --- |
  26663. * | 0 | BILLBOARDMODE_NONE | |
  26664. * | 1 | BILLBOARDMODE_X | |
  26665. * | 2 | BILLBOARDMODE_Y | |
  26666. * | 4 | BILLBOARDMODE_Z | |
  26667. * | 7 | BILLBOARDMODE_ALL | |
  26668. *
  26669. */
  26670. get billboardMode(): number;
  26671. set billboardMode(value: number);
  26672. private _preserveParentRotationForBillboard;
  26673. /**
  26674. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  26675. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  26676. */
  26677. get preserveParentRotationForBillboard(): boolean;
  26678. set preserveParentRotationForBillboard(value: boolean);
  26679. /**
  26680. * 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
  26681. */
  26682. scalingDeterminant: number;
  26683. private _infiniteDistance;
  26684. /**
  26685. * Gets or sets the distance of the object to max, often used by skybox
  26686. */
  26687. get infiniteDistance(): boolean;
  26688. set infiniteDistance(value: boolean);
  26689. /**
  26690. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  26691. * By default the system will update normals to compensate
  26692. */
  26693. ignoreNonUniformScaling: boolean;
  26694. /**
  26695. * 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
  26696. */
  26697. reIntegrateRotationIntoRotationQuaternion: boolean;
  26698. /** @hidden */
  26699. _poseMatrix: Nullable<Matrix>;
  26700. /** @hidden */
  26701. _localMatrix: Matrix;
  26702. private _usePivotMatrix;
  26703. private _absolutePosition;
  26704. private _absoluteScaling;
  26705. private _absoluteRotationQuaternion;
  26706. private _pivotMatrix;
  26707. private _pivotMatrixInverse;
  26708. /** @hidden */
  26709. _postMultiplyPivotMatrix: boolean;
  26710. protected _isWorldMatrixFrozen: boolean;
  26711. /** @hidden */
  26712. _indexInSceneTransformNodesArray: number;
  26713. /**
  26714. * An event triggered after the world matrix is updated
  26715. */
  26716. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  26717. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  26718. /**
  26719. * Gets a string identifying the name of the class
  26720. * @returns "TransformNode" string
  26721. */
  26722. getClassName(): string;
  26723. /**
  26724. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  26725. */
  26726. get position(): Vector3;
  26727. set position(newPosition: Vector3);
  26728. /**
  26729. * 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)).
  26730. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  26731. */
  26732. get rotation(): Vector3;
  26733. set rotation(newRotation: Vector3);
  26734. /**
  26735. * 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)).
  26736. */
  26737. get scaling(): Vector3;
  26738. set scaling(newScaling: Vector3);
  26739. /**
  26740. * 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).
  26741. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  26742. */
  26743. get rotationQuaternion(): Nullable<Quaternion>;
  26744. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  26745. /**
  26746. * The forward direction of that transform in world space.
  26747. */
  26748. get forward(): Vector3;
  26749. /**
  26750. * The up direction of that transform in world space.
  26751. */
  26752. get up(): Vector3;
  26753. /**
  26754. * The right direction of that transform in world space.
  26755. */
  26756. get right(): Vector3;
  26757. /**
  26758. * Copies the parameter passed Matrix into the mesh Pose matrix.
  26759. * @param matrix the matrix to copy the pose from
  26760. * @returns this TransformNode.
  26761. */
  26762. updatePoseMatrix(matrix: Matrix): TransformNode;
  26763. /**
  26764. * Returns the mesh Pose matrix.
  26765. * @returns the pose matrix
  26766. */
  26767. getPoseMatrix(): Matrix;
  26768. /** @hidden */
  26769. _isSynchronized(): boolean;
  26770. /** @hidden */
  26771. _initCache(): void;
  26772. /**
  26773. * Flag the transform node as dirty (Forcing it to update everything)
  26774. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  26775. * @returns this transform node
  26776. */
  26777. markAsDirty(property: string): TransformNode;
  26778. /**
  26779. * Returns the current mesh absolute position.
  26780. * Returns a Vector3.
  26781. */
  26782. get absolutePosition(): Vector3;
  26783. /**
  26784. * Returns the current mesh absolute scaling.
  26785. * Returns a Vector3.
  26786. */
  26787. get absoluteScaling(): Vector3;
  26788. /**
  26789. * Returns the current mesh absolute rotation.
  26790. * Returns a Quaternion.
  26791. */
  26792. get absoluteRotationQuaternion(): Quaternion;
  26793. /**
  26794. * Sets a new matrix to apply before all other transformation
  26795. * @param matrix defines the transform matrix
  26796. * @returns the current TransformNode
  26797. */
  26798. setPreTransformMatrix(matrix: Matrix): TransformNode;
  26799. /**
  26800. * Sets a new pivot matrix to the current node
  26801. * @param matrix defines the new pivot matrix to use
  26802. * @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
  26803. * @returns the current TransformNode
  26804. */
  26805. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  26806. /**
  26807. * Returns the mesh pivot matrix.
  26808. * Default : Identity.
  26809. * @returns the matrix
  26810. */
  26811. getPivotMatrix(): Matrix;
  26812. /**
  26813. * Instantiate (when possible) or clone that node with its hierarchy
  26814. * @param newParent defines the new parent to use for the instance (or clone)
  26815. * @param options defines options to configure how copy is done
  26816. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  26817. * @returns an instance (or a clone) of the current node with its hiearchy
  26818. */
  26819. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  26820. doNotInstantiate: boolean;
  26821. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  26822. /**
  26823. * Prevents the World matrix to be computed any longer
  26824. * @param newWorldMatrix defines an optional matrix to use as world matrix
  26825. * @returns the TransformNode.
  26826. */
  26827. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  26828. /**
  26829. * Allows back the World matrix computation.
  26830. * @returns the TransformNode.
  26831. */
  26832. unfreezeWorldMatrix(): this;
  26833. /**
  26834. * True if the World matrix has been frozen.
  26835. */
  26836. get isWorldMatrixFrozen(): boolean;
  26837. /**
  26838. * Retuns the mesh absolute position in the World.
  26839. * @returns a Vector3.
  26840. */
  26841. getAbsolutePosition(): Vector3;
  26842. /**
  26843. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  26844. * @param absolutePosition the absolute position to set
  26845. * @returns the TransformNode.
  26846. */
  26847. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  26848. /**
  26849. * Sets the mesh position in its local space.
  26850. * @param vector3 the position to set in localspace
  26851. * @returns the TransformNode.
  26852. */
  26853. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  26854. /**
  26855. * Returns the mesh position in the local space from the current World matrix values.
  26856. * @returns a new Vector3.
  26857. */
  26858. getPositionExpressedInLocalSpace(): Vector3;
  26859. /**
  26860. * Translates the mesh along the passed Vector3 in its local space.
  26861. * @param vector3 the distance to translate in localspace
  26862. * @returns the TransformNode.
  26863. */
  26864. locallyTranslate(vector3: Vector3): TransformNode;
  26865. private static _lookAtVectorCache;
  26866. /**
  26867. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  26868. * @param targetPoint the position (must be in same space as current mesh) to look at
  26869. * @param yawCor optional yaw (y-axis) correction in radians
  26870. * @param pitchCor optional pitch (x-axis) correction in radians
  26871. * @param rollCor optional roll (z-axis) correction in radians
  26872. * @param space the choosen space of the target
  26873. * @returns the TransformNode.
  26874. */
  26875. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  26876. /**
  26877. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  26878. * This Vector3 is expressed in the World space.
  26879. * @param localAxis axis to rotate
  26880. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  26881. */
  26882. getDirection(localAxis: Vector3): Vector3;
  26883. /**
  26884. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  26885. * localAxis is expressed in the mesh local space.
  26886. * result is computed in the Wordl space from the mesh World matrix.
  26887. * @param localAxis axis to rotate
  26888. * @param result the resulting transformnode
  26889. * @returns this TransformNode.
  26890. */
  26891. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  26892. /**
  26893. * Sets this transform node rotation to the given local axis.
  26894. * @param localAxis the axis in local space
  26895. * @param yawCor optional yaw (y-axis) correction in radians
  26896. * @param pitchCor optional pitch (x-axis) correction in radians
  26897. * @param rollCor optional roll (z-axis) correction in radians
  26898. * @returns this TransformNode
  26899. */
  26900. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  26901. /**
  26902. * Sets a new pivot point to the current node
  26903. * @param point defines the new pivot point to use
  26904. * @param space defines if the point is in world or local space (local by default)
  26905. * @returns the current TransformNode
  26906. */
  26907. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  26908. /**
  26909. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  26910. * @returns the pivot point
  26911. */
  26912. getPivotPoint(): Vector3;
  26913. /**
  26914. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  26915. * @param result the vector3 to store the result
  26916. * @returns this TransformNode.
  26917. */
  26918. getPivotPointToRef(result: Vector3): TransformNode;
  26919. /**
  26920. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  26921. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  26922. */
  26923. getAbsolutePivotPoint(): Vector3;
  26924. /**
  26925. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  26926. * @param result vector3 to store the result
  26927. * @returns this TransformNode.
  26928. */
  26929. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  26930. /**
  26931. * Defines the passed node as the parent of the current node.
  26932. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  26933. * @see https://doc.babylonjs.com/how_to/parenting
  26934. * @param node the node ot set as the parent
  26935. * @returns this TransformNode.
  26936. */
  26937. setParent(node: Nullable<Node>): TransformNode;
  26938. private _nonUniformScaling;
  26939. /**
  26940. * True if the scaling property of this object is non uniform eg. (1,2,1)
  26941. */
  26942. get nonUniformScaling(): boolean;
  26943. /** @hidden */
  26944. _updateNonUniformScalingState(value: boolean): boolean;
  26945. /**
  26946. * Attach the current TransformNode to another TransformNode associated with a bone
  26947. * @param bone Bone affecting the TransformNode
  26948. * @param affectedTransformNode TransformNode associated with the bone
  26949. * @returns this object
  26950. */
  26951. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  26952. /**
  26953. * Detach the transform node if its associated with a bone
  26954. * @returns this object
  26955. */
  26956. detachFromBone(): TransformNode;
  26957. private static _rotationAxisCache;
  26958. /**
  26959. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  26960. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  26961. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  26962. * The passed axis is also normalized.
  26963. * @param axis the axis to rotate around
  26964. * @param amount the amount to rotate in radians
  26965. * @param space Space to rotate in (Default: local)
  26966. * @returns the TransformNode.
  26967. */
  26968. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  26969. /**
  26970. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  26971. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  26972. * The passed axis is also normalized. .
  26973. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  26974. * @param point the point to rotate around
  26975. * @param axis the axis to rotate around
  26976. * @param amount the amount to rotate in radians
  26977. * @returns the TransformNode
  26978. */
  26979. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  26980. /**
  26981. * Translates the mesh along the axis vector for the passed distance in the given space.
  26982. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  26983. * @param axis the axis to translate in
  26984. * @param distance the distance to translate
  26985. * @param space Space to rotate in (Default: local)
  26986. * @returns the TransformNode.
  26987. */
  26988. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  26989. /**
  26990. * Adds a rotation step to the mesh current rotation.
  26991. * x, y, z are Euler angles expressed in radians.
  26992. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  26993. * This means this rotation is made in the mesh local space only.
  26994. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  26995. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  26996. * ```javascript
  26997. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  26998. * ```
  26999. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  27000. * 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.
  27001. * @param x Rotation to add
  27002. * @param y Rotation to add
  27003. * @param z Rotation to add
  27004. * @returns the TransformNode.
  27005. */
  27006. addRotation(x: number, y: number, z: number): TransformNode;
  27007. /**
  27008. * @hidden
  27009. */
  27010. protected _getEffectiveParent(): Nullable<Node>;
  27011. /**
  27012. * Computes the world matrix of the node
  27013. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  27014. * @returns the world matrix
  27015. */
  27016. computeWorldMatrix(force?: boolean): Matrix;
  27017. /**
  27018. * Resets this nodeTransform's local matrix to Matrix.Identity().
  27019. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  27020. */
  27021. resetLocalMatrix(independentOfChildren?: boolean): void;
  27022. protected _afterComputeWorldMatrix(): void;
  27023. /**
  27024. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  27025. * @param func callback function to add
  27026. *
  27027. * @returns the TransformNode.
  27028. */
  27029. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  27030. /**
  27031. * Removes a registered callback function.
  27032. * @param func callback function to remove
  27033. * @returns the TransformNode.
  27034. */
  27035. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  27036. /**
  27037. * Gets the position of the current mesh in camera space
  27038. * @param camera defines the camera to use
  27039. * @returns a position
  27040. */
  27041. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  27042. /**
  27043. * Returns the distance from the mesh to the active camera
  27044. * @param camera defines the camera to use
  27045. * @returns the distance
  27046. */
  27047. getDistanceToCamera(camera?: Nullable<Camera>): number;
  27048. /**
  27049. * Clone the current transform node
  27050. * @param name Name of the new clone
  27051. * @param newParent New parent for the clone
  27052. * @param doNotCloneChildren Do not clone children hierarchy
  27053. * @returns the new transform node
  27054. */
  27055. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  27056. /**
  27057. * Serializes the objects information.
  27058. * @param currentSerializationObject defines the object to serialize in
  27059. * @returns the serialized object
  27060. */
  27061. serialize(currentSerializationObject?: any): any;
  27062. /**
  27063. * Returns a new TransformNode object parsed from the source provided.
  27064. * @param parsedTransformNode is the source.
  27065. * @param scene the scne the object belongs to
  27066. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  27067. * @returns a new TransformNode object parsed from the source provided.
  27068. */
  27069. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  27070. /**
  27071. * Get all child-transformNodes of this node
  27072. * @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
  27073. * @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
  27074. * @returns an array of TransformNode
  27075. */
  27076. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  27077. /**
  27078. * Releases resources associated with this transform node.
  27079. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  27080. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  27081. */
  27082. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  27083. /**
  27084. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  27085. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  27086. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  27087. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  27088. * @returns the current mesh
  27089. */
  27090. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  27091. private _syncAbsoluteScalingAndRotation;
  27092. }
  27093. }
  27094. declare module BABYLON {
  27095. /**
  27096. * Defines the types of pose enabled controllers that are supported
  27097. */
  27098. export enum PoseEnabledControllerType {
  27099. /**
  27100. * HTC Vive
  27101. */
  27102. VIVE = 0,
  27103. /**
  27104. * Oculus Rift
  27105. */
  27106. OCULUS = 1,
  27107. /**
  27108. * Windows mixed reality
  27109. */
  27110. WINDOWS = 2,
  27111. /**
  27112. * Samsung gear VR
  27113. */
  27114. GEAR_VR = 3,
  27115. /**
  27116. * Google Daydream
  27117. */
  27118. DAYDREAM = 4,
  27119. /**
  27120. * Generic
  27121. */
  27122. GENERIC = 5
  27123. }
  27124. /**
  27125. * Defines the MutableGamepadButton interface for the state of a gamepad button
  27126. */
  27127. export interface MutableGamepadButton {
  27128. /**
  27129. * Value of the button/trigger
  27130. */
  27131. value: number;
  27132. /**
  27133. * If the button/trigger is currently touched
  27134. */
  27135. touched: boolean;
  27136. /**
  27137. * If the button/trigger is currently pressed
  27138. */
  27139. pressed: boolean;
  27140. }
  27141. /**
  27142. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  27143. * @hidden
  27144. */
  27145. export interface ExtendedGamepadButton extends GamepadButton {
  27146. /**
  27147. * If the button/trigger is currently pressed
  27148. */
  27149. readonly pressed: boolean;
  27150. /**
  27151. * If the button/trigger is currently touched
  27152. */
  27153. readonly touched: boolean;
  27154. /**
  27155. * Value of the button/trigger
  27156. */
  27157. readonly value: number;
  27158. }
  27159. /** @hidden */
  27160. export interface _GamePadFactory {
  27161. /**
  27162. * Returns whether or not the current gamepad can be created for this type of controller.
  27163. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  27164. * @returns true if it can be created, otherwise false
  27165. */
  27166. canCreate(gamepadInfo: any): boolean;
  27167. /**
  27168. * Creates a new instance of the Gamepad.
  27169. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  27170. * @returns the new gamepad instance
  27171. */
  27172. create(gamepadInfo: any): Gamepad;
  27173. }
  27174. /**
  27175. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  27176. */
  27177. export class PoseEnabledControllerHelper {
  27178. /** @hidden */
  27179. static _ControllerFactories: _GamePadFactory[];
  27180. /** @hidden */
  27181. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  27182. /**
  27183. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  27184. * @param vrGamepad the gamepad to initialized
  27185. * @returns a vr controller of the type the gamepad identified as
  27186. */
  27187. static InitiateController(vrGamepad: any): Gamepad;
  27188. }
  27189. /**
  27190. * Defines the PoseEnabledController object that contains state of a vr capable controller
  27191. */
  27192. export class PoseEnabledController extends Gamepad implements PoseControlled {
  27193. /**
  27194. * If the controller is used in a webXR session
  27195. */
  27196. isXR: boolean;
  27197. private _deviceRoomPosition;
  27198. private _deviceRoomRotationQuaternion;
  27199. /**
  27200. * The device position in babylon space
  27201. */
  27202. devicePosition: Vector3;
  27203. /**
  27204. * The device rotation in babylon space
  27205. */
  27206. deviceRotationQuaternion: Quaternion;
  27207. /**
  27208. * The scale factor of the device in babylon space
  27209. */
  27210. deviceScaleFactor: number;
  27211. /**
  27212. * (Likely devicePosition should be used instead) The device position in its room space
  27213. */
  27214. position: Vector3;
  27215. /**
  27216. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  27217. */
  27218. rotationQuaternion: Quaternion;
  27219. /**
  27220. * The type of controller (Eg. Windows mixed reality)
  27221. */
  27222. controllerType: PoseEnabledControllerType;
  27223. protected _calculatedPosition: Vector3;
  27224. private _calculatedRotation;
  27225. /**
  27226. * The raw pose from the device
  27227. */
  27228. rawPose: DevicePose;
  27229. private _trackPosition;
  27230. private _maxRotationDistFromHeadset;
  27231. private _draggedRoomRotation;
  27232. /**
  27233. * @hidden
  27234. */
  27235. _disableTrackPosition(fixedPosition: Vector3): void;
  27236. /**
  27237. * Internal, the mesh attached to the controller
  27238. * @hidden
  27239. */
  27240. _mesh: Nullable<AbstractMesh>;
  27241. private _poseControlledCamera;
  27242. private _leftHandSystemQuaternion;
  27243. /**
  27244. * Internal, matrix used to convert room space to babylon space
  27245. * @hidden
  27246. */
  27247. _deviceToWorld: Matrix;
  27248. /**
  27249. * Node to be used when casting a ray from the controller
  27250. * @hidden
  27251. */
  27252. _pointingPoseNode: Nullable<TransformNode>;
  27253. /**
  27254. * Name of the child mesh that can be used to cast a ray from the controller
  27255. */
  27256. static readonly POINTING_POSE: string;
  27257. /**
  27258. * Creates a new PoseEnabledController from a gamepad
  27259. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  27260. */
  27261. constructor(browserGamepad: any);
  27262. private _workingMatrix;
  27263. /**
  27264. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  27265. */
  27266. update(): void;
  27267. /**
  27268. * Updates only the pose device and mesh without doing any button event checking
  27269. */
  27270. protected _updatePoseAndMesh(): void;
  27271. /**
  27272. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  27273. * @param poseData raw pose fromthe device
  27274. */
  27275. updateFromDevice(poseData: DevicePose): void;
  27276. /**
  27277. * @hidden
  27278. */
  27279. _meshAttachedObservable: Observable<AbstractMesh>;
  27280. /**
  27281. * Attaches a mesh to the controller
  27282. * @param mesh the mesh to be attached
  27283. */
  27284. attachToMesh(mesh: AbstractMesh): void;
  27285. /**
  27286. * Attaches the controllers mesh to a camera
  27287. * @param camera the camera the mesh should be attached to
  27288. */
  27289. attachToPoseControlledCamera(camera: TargetCamera): void;
  27290. /**
  27291. * Disposes of the controller
  27292. */
  27293. dispose(): void;
  27294. /**
  27295. * The mesh that is attached to the controller
  27296. */
  27297. get mesh(): Nullable<AbstractMesh>;
  27298. /**
  27299. * Gets the ray of the controller in the direction the controller is pointing
  27300. * @param length the length the resulting ray should be
  27301. * @returns a ray in the direction the controller is pointing
  27302. */
  27303. getForwardRay(length?: number): Ray;
  27304. }
  27305. }
  27306. declare module BABYLON {
  27307. /**
  27308. * Defines the WebVRController object that represents controllers tracked in 3D space
  27309. */
  27310. export abstract class WebVRController extends PoseEnabledController {
  27311. /**
  27312. * Internal, the default controller model for the controller
  27313. */
  27314. protected _defaultModel: Nullable<AbstractMesh>;
  27315. /**
  27316. * Fired when the trigger state has changed
  27317. */
  27318. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  27319. /**
  27320. * Fired when the main button state has changed
  27321. */
  27322. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  27323. /**
  27324. * Fired when the secondary button state has changed
  27325. */
  27326. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  27327. /**
  27328. * Fired when the pad state has changed
  27329. */
  27330. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  27331. /**
  27332. * Fired when controllers stick values have changed
  27333. */
  27334. onPadValuesChangedObservable: Observable<StickValues>;
  27335. /**
  27336. * Array of button availible on the controller
  27337. */
  27338. protected _buttons: Array<MutableGamepadButton>;
  27339. private _onButtonStateChange;
  27340. /**
  27341. * Fired when a controller button's state has changed
  27342. * @param callback the callback containing the button that was modified
  27343. */
  27344. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  27345. /**
  27346. * X and Y axis corresponding to the controllers joystick
  27347. */
  27348. pad: StickValues;
  27349. /**
  27350. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  27351. */
  27352. hand: string;
  27353. /**
  27354. * The default controller model for the controller
  27355. */
  27356. get defaultModel(): Nullable<AbstractMesh>;
  27357. /**
  27358. * Creates a new WebVRController from a gamepad
  27359. * @param vrGamepad the gamepad that the WebVRController should be created from
  27360. */
  27361. constructor(vrGamepad: any);
  27362. /**
  27363. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  27364. */
  27365. update(): void;
  27366. /**
  27367. * Function to be called when a button is modified
  27368. */
  27369. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  27370. /**
  27371. * Loads a mesh and attaches it to the controller
  27372. * @param scene the scene the mesh should be added to
  27373. * @param meshLoaded callback for when the mesh has been loaded
  27374. */
  27375. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  27376. private _setButtonValue;
  27377. private _changes;
  27378. private _checkChanges;
  27379. /**
  27380. * Disposes of th webVRCOntroller
  27381. */
  27382. dispose(): void;
  27383. }
  27384. }
  27385. declare module BABYLON {
  27386. /**
  27387. * The HemisphericLight simulates the ambient environment light,
  27388. * so the passed direction is the light reflection direction, not the incoming direction.
  27389. */
  27390. export class HemisphericLight extends Light {
  27391. /**
  27392. * The groundColor is the light in the opposite direction to the one specified during creation.
  27393. * 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.
  27394. */
  27395. groundColor: Color3;
  27396. /**
  27397. * The light reflection direction, not the incoming direction.
  27398. */
  27399. direction: Vector3;
  27400. /**
  27401. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  27402. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  27403. * The HemisphericLight can't cast shadows.
  27404. * Documentation : https://doc.babylonjs.com/babylon101/lights
  27405. * @param name The friendly name of the light
  27406. * @param direction The direction of the light reflection
  27407. * @param scene The scene the light belongs to
  27408. */
  27409. constructor(name: string, direction: Vector3, scene: Scene);
  27410. protected _buildUniformLayout(): void;
  27411. /**
  27412. * Returns the string "HemisphericLight".
  27413. * @return The class name
  27414. */
  27415. getClassName(): string;
  27416. /**
  27417. * Sets the HemisphericLight direction towards the passed target (Vector3).
  27418. * Returns the updated direction.
  27419. * @param target The target the direction should point to
  27420. * @return The computed direction
  27421. */
  27422. setDirectionToTarget(target: Vector3): Vector3;
  27423. /**
  27424. * Returns the shadow generator associated to the light.
  27425. * @returns Always null for hemispheric lights because it does not support shadows.
  27426. */
  27427. getShadowGenerator(): Nullable<IShadowGenerator>;
  27428. /**
  27429. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  27430. * @param effect The effect to update
  27431. * @param lightIndex The index of the light in the effect to update
  27432. * @returns The hemispheric light
  27433. */
  27434. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  27435. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  27436. /**
  27437. * Computes the world matrix of the node
  27438. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  27439. * @param useWasUpdatedFlag defines a reserved property
  27440. * @returns the world matrix
  27441. */
  27442. computeWorldMatrix(): Matrix;
  27443. /**
  27444. * Returns the integer 3.
  27445. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  27446. */
  27447. getTypeID(): number;
  27448. /**
  27449. * Prepares the list of defines specific to the light type.
  27450. * @param defines the list of defines
  27451. * @param lightIndex defines the index of the light for the effect
  27452. */
  27453. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  27454. }
  27455. }
  27456. declare module BABYLON {
  27457. /** @hidden */
  27458. export var vrMultiviewToSingleviewPixelShader: {
  27459. name: string;
  27460. shader: string;
  27461. };
  27462. }
  27463. declare module BABYLON {
  27464. /**
  27465. * Renders to multiple views with a single draw call
  27466. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  27467. */
  27468. export class MultiviewRenderTarget extends RenderTargetTexture {
  27469. /**
  27470. * Creates a multiview render target
  27471. * @param scene scene used with the render target
  27472. * @param size the size of the render target (used for each view)
  27473. */
  27474. constructor(scene: Scene, size?: number | {
  27475. width: number;
  27476. height: number;
  27477. } | {
  27478. ratio: number;
  27479. });
  27480. /**
  27481. * @hidden
  27482. * @param faceIndex the face index, if its a cube texture
  27483. */
  27484. _bindFrameBuffer(faceIndex?: number): void;
  27485. /**
  27486. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  27487. * @returns the view count
  27488. */
  27489. getViewCount(): number;
  27490. }
  27491. }
  27492. declare module BABYLON {
  27493. interface Engine {
  27494. /**
  27495. * Creates a new multiview render target
  27496. * @param width defines the width of the texture
  27497. * @param height defines the height of the texture
  27498. * @returns the created multiview texture
  27499. */
  27500. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  27501. /**
  27502. * Binds a multiview framebuffer to be drawn to
  27503. * @param multiviewTexture texture to bind
  27504. */
  27505. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  27506. }
  27507. interface Camera {
  27508. /**
  27509. * @hidden
  27510. * 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)
  27511. */
  27512. _useMultiviewToSingleView: boolean;
  27513. /**
  27514. * @hidden
  27515. * 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)
  27516. */
  27517. _multiviewTexture: Nullable<RenderTargetTexture>;
  27518. /**
  27519. * @hidden
  27520. * ensures the multiview texture of the camera exists and has the specified width/height
  27521. * @param width height to set on the multiview texture
  27522. * @param height width to set on the multiview texture
  27523. */
  27524. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  27525. }
  27526. interface Scene {
  27527. /** @hidden */
  27528. _transformMatrixR: Matrix;
  27529. /** @hidden */
  27530. _multiviewSceneUbo: Nullable<UniformBuffer>;
  27531. /** @hidden */
  27532. _createMultiviewUbo(): void;
  27533. /** @hidden */
  27534. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  27535. /** @hidden */
  27536. _renderMultiviewToSingleView(camera: Camera): void;
  27537. }
  27538. }
  27539. declare module BABYLON {
  27540. /**
  27541. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  27542. * This will not be used for webXR as it supports displaying texture arrays directly
  27543. */
  27544. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  27545. /**
  27546. * Gets a string identifying the name of the class
  27547. * @returns "VRMultiviewToSingleviewPostProcess" string
  27548. */
  27549. getClassName(): string;
  27550. /**
  27551. * Initializes a VRMultiviewToSingleview
  27552. * @param name name of the post process
  27553. * @param camera camera to be applied to
  27554. * @param scaleFactor scaling factor to the size of the output texture
  27555. */
  27556. constructor(name: string, camera: Camera, scaleFactor: number);
  27557. }
  27558. }
  27559. declare module BABYLON {
  27560. /**
  27561. * Interface used to define additional presentation attributes
  27562. */
  27563. export interface IVRPresentationAttributes {
  27564. /**
  27565. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  27566. */
  27567. highRefreshRate: boolean;
  27568. /**
  27569. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  27570. */
  27571. foveationLevel: number;
  27572. }
  27573. interface Engine {
  27574. /** @hidden */
  27575. _vrDisplay: any;
  27576. /** @hidden */
  27577. _vrSupported: boolean;
  27578. /** @hidden */
  27579. _oldSize: Size;
  27580. /** @hidden */
  27581. _oldHardwareScaleFactor: number;
  27582. /** @hidden */
  27583. _vrExclusivePointerMode: boolean;
  27584. /** @hidden */
  27585. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  27586. /** @hidden */
  27587. _onVRDisplayPointerRestricted: () => void;
  27588. /** @hidden */
  27589. _onVRDisplayPointerUnrestricted: () => void;
  27590. /** @hidden */
  27591. _onVrDisplayConnect: Nullable<(display: any) => void>;
  27592. /** @hidden */
  27593. _onVrDisplayDisconnect: Nullable<() => void>;
  27594. /** @hidden */
  27595. _onVrDisplayPresentChange: Nullable<() => void>;
  27596. /**
  27597. * Observable signaled when VR display mode changes
  27598. */
  27599. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  27600. /**
  27601. * Observable signaled when VR request present is complete
  27602. */
  27603. onVRRequestPresentComplete: Observable<boolean>;
  27604. /**
  27605. * Observable signaled when VR request present starts
  27606. */
  27607. onVRRequestPresentStart: Observable<Engine>;
  27608. /**
  27609. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  27610. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  27611. */
  27612. isInVRExclusivePointerMode: boolean;
  27613. /**
  27614. * Gets a boolean indicating if a webVR device was detected
  27615. * @returns true if a webVR device was detected
  27616. */
  27617. isVRDevicePresent(): boolean;
  27618. /**
  27619. * Gets the current webVR device
  27620. * @returns the current webVR device (or null)
  27621. */
  27622. getVRDevice(): any;
  27623. /**
  27624. * Initializes a webVR display and starts listening to display change events
  27625. * The onVRDisplayChangedObservable will be notified upon these changes
  27626. * @returns A promise containing a VRDisplay and if vr is supported
  27627. */
  27628. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  27629. /** @hidden */
  27630. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  27631. /**
  27632. * Gets or sets the presentation attributes used to configure VR rendering
  27633. */
  27634. vrPresentationAttributes?: IVRPresentationAttributes;
  27635. /**
  27636. * Call this function to switch to webVR mode
  27637. * Will do nothing if webVR is not supported or if there is no webVR device
  27638. * @param options the webvr options provided to the camera. mainly used for multiview
  27639. * @see https://doc.babylonjs.com/how_to/webvr_camera
  27640. */
  27641. enableVR(options: WebVROptions): void;
  27642. /** @hidden */
  27643. _onVRFullScreenTriggered(): void;
  27644. }
  27645. }
  27646. declare module BABYLON {
  27647. /**
  27648. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  27649. * IMPORTANT!! The data is right-hand data.
  27650. * @export
  27651. * @interface DevicePose
  27652. */
  27653. export interface DevicePose {
  27654. /**
  27655. * The position of the device, values in array are [x,y,z].
  27656. */
  27657. readonly position: Nullable<Float32Array>;
  27658. /**
  27659. * The linearVelocity of the device, values in array are [x,y,z].
  27660. */
  27661. readonly linearVelocity: Nullable<Float32Array>;
  27662. /**
  27663. * The linearAcceleration of the device, values in array are [x,y,z].
  27664. */
  27665. readonly linearAcceleration: Nullable<Float32Array>;
  27666. /**
  27667. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  27668. */
  27669. readonly orientation: Nullable<Float32Array>;
  27670. /**
  27671. * The angularVelocity of the device, values in array are [x,y,z].
  27672. */
  27673. readonly angularVelocity: Nullable<Float32Array>;
  27674. /**
  27675. * The angularAcceleration of the device, values in array are [x,y,z].
  27676. */
  27677. readonly angularAcceleration: Nullable<Float32Array>;
  27678. }
  27679. /**
  27680. * Interface representing a pose controlled object in Babylon.
  27681. * A pose controlled object has both regular pose values as well as pose values
  27682. * from an external device such as a VR head mounted display
  27683. */
  27684. export interface PoseControlled {
  27685. /**
  27686. * The position of the object in babylon space.
  27687. */
  27688. position: Vector3;
  27689. /**
  27690. * The rotation quaternion of the object in babylon space.
  27691. */
  27692. rotationQuaternion: Quaternion;
  27693. /**
  27694. * The position of the device in babylon space.
  27695. */
  27696. devicePosition?: Vector3;
  27697. /**
  27698. * The rotation quaternion of the device in babylon space.
  27699. */
  27700. deviceRotationQuaternion: Quaternion;
  27701. /**
  27702. * The raw pose coming from the device.
  27703. */
  27704. rawPose: Nullable<DevicePose>;
  27705. /**
  27706. * The scale of the device to be used when translating from device space to babylon space.
  27707. */
  27708. deviceScaleFactor: number;
  27709. /**
  27710. * Updates the poseControlled values based on the input device pose.
  27711. * @param poseData the pose data to update the object with
  27712. */
  27713. updateFromDevice(poseData: DevicePose): void;
  27714. }
  27715. /**
  27716. * Set of options to customize the webVRCamera
  27717. */
  27718. export interface WebVROptions {
  27719. /**
  27720. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  27721. */
  27722. trackPosition?: boolean;
  27723. /**
  27724. * Sets the scale of the vrDevice in babylon space. (default: 1)
  27725. */
  27726. positionScale?: number;
  27727. /**
  27728. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  27729. */
  27730. displayName?: string;
  27731. /**
  27732. * Should the native controller meshes be initialized. (default: true)
  27733. */
  27734. controllerMeshes?: boolean;
  27735. /**
  27736. * Creating a default HemiLight only on controllers. (default: true)
  27737. */
  27738. defaultLightingOnControllers?: boolean;
  27739. /**
  27740. * If you don't want to use the default VR button of the helper. (default: false)
  27741. */
  27742. useCustomVRButton?: boolean;
  27743. /**
  27744. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  27745. */
  27746. customVRButton?: HTMLButtonElement;
  27747. /**
  27748. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  27749. */
  27750. rayLength?: number;
  27751. /**
  27752. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  27753. */
  27754. defaultHeight?: number;
  27755. /**
  27756. * If multiview should be used if availible (default: false)
  27757. */
  27758. useMultiview?: boolean;
  27759. }
  27760. /**
  27761. * This represents a WebVR camera.
  27762. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  27763. * @example https://doc.babylonjs.com/how_to/webvr_camera
  27764. */
  27765. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  27766. private webVROptions;
  27767. /**
  27768. * @hidden
  27769. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  27770. */
  27771. _vrDevice: any;
  27772. /**
  27773. * The rawPose of the vrDevice.
  27774. */
  27775. rawPose: Nullable<DevicePose>;
  27776. private _onVREnabled;
  27777. private _specsVersion;
  27778. private _attached;
  27779. private _frameData;
  27780. protected _descendants: Array<Node>;
  27781. private _deviceRoomPosition;
  27782. /** @hidden */
  27783. _deviceRoomRotationQuaternion: Quaternion;
  27784. private _standingMatrix;
  27785. /**
  27786. * Represents device position in babylon space.
  27787. */
  27788. devicePosition: Vector3;
  27789. /**
  27790. * Represents device rotation in babylon space.
  27791. */
  27792. deviceRotationQuaternion: Quaternion;
  27793. /**
  27794. * The scale of the device to be used when translating from device space to babylon space.
  27795. */
  27796. deviceScaleFactor: number;
  27797. private _deviceToWorld;
  27798. private _worldToDevice;
  27799. /**
  27800. * References to the webVR controllers for the vrDevice.
  27801. */
  27802. controllers: Array<WebVRController>;
  27803. /**
  27804. * Emits an event when a controller is attached.
  27805. */
  27806. onControllersAttachedObservable: Observable<WebVRController[]>;
  27807. /**
  27808. * Emits an event when a controller's mesh has been loaded;
  27809. */
  27810. onControllerMeshLoadedObservable: Observable<WebVRController>;
  27811. /**
  27812. * Emits an event when the HMD's pose has been updated.
  27813. */
  27814. onPoseUpdatedFromDeviceObservable: Observable<any>;
  27815. private _poseSet;
  27816. /**
  27817. * If the rig cameras be used as parent instead of this camera.
  27818. */
  27819. rigParenting: boolean;
  27820. private _lightOnControllers;
  27821. private _defaultHeight?;
  27822. /**
  27823. * Instantiates a WebVRFreeCamera.
  27824. * @param name The name of the WebVRFreeCamera
  27825. * @param position The starting anchor position for the camera
  27826. * @param scene The scene the camera belongs to
  27827. * @param webVROptions a set of customizable options for the webVRCamera
  27828. */
  27829. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  27830. /**
  27831. * Gets the device distance from the ground in meters.
  27832. * @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.
  27833. */
  27834. deviceDistanceToRoomGround(): number;
  27835. /**
  27836. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  27837. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  27838. */
  27839. useStandingMatrix(callback?: (bool: boolean) => void): void;
  27840. /**
  27841. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  27842. * @returns A promise with a boolean set to if the standing matrix is supported.
  27843. */
  27844. useStandingMatrixAsync(): Promise<boolean>;
  27845. /**
  27846. * Disposes the camera
  27847. */
  27848. dispose(): void;
  27849. /**
  27850. * Gets a vrController by name.
  27851. * @param name The name of the controller to retreive
  27852. * @returns the controller matching the name specified or null if not found
  27853. */
  27854. getControllerByName(name: string): Nullable<WebVRController>;
  27855. private _leftController;
  27856. /**
  27857. * The controller corresponding to the users left hand.
  27858. */
  27859. get leftController(): Nullable<WebVRController>;
  27860. private _rightController;
  27861. /**
  27862. * The controller corresponding to the users right hand.
  27863. */
  27864. get rightController(): Nullable<WebVRController>;
  27865. /**
  27866. * Casts a ray forward from the vrCamera's gaze.
  27867. * @param length Length of the ray (default: 100)
  27868. * @returns the ray corresponding to the gaze
  27869. */
  27870. getForwardRay(length?: number): Ray;
  27871. /**
  27872. * @hidden
  27873. * Updates the camera based on device's frame data
  27874. */
  27875. _checkInputs(): void;
  27876. /**
  27877. * Updates the poseControlled values based on the input device pose.
  27878. * @param poseData Pose coming from the device
  27879. */
  27880. updateFromDevice(poseData: DevicePose): void;
  27881. private _detachIfAttached;
  27882. /**
  27883. * WebVR's attach control will start broadcasting frames to the device.
  27884. * Note that in certain browsers (chrome for example) this function must be called
  27885. * within a user-interaction callback. Example:
  27886. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  27887. *
  27888. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  27889. */
  27890. attachControl(noPreventDefault?: boolean): void;
  27891. /**
  27892. * Detach the current controls from the specified dom element.
  27893. */
  27894. detachControl(): void;
  27895. /**
  27896. * @returns the name of this class
  27897. */
  27898. getClassName(): string;
  27899. /**
  27900. * Calls resetPose on the vrDisplay
  27901. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  27902. */
  27903. resetToCurrentRotation(): void;
  27904. /**
  27905. * @hidden
  27906. * Updates the rig cameras (left and right eye)
  27907. */
  27908. _updateRigCameras(): void;
  27909. private _workingVector;
  27910. private _oneVector;
  27911. private _workingMatrix;
  27912. private updateCacheCalled;
  27913. private _correctPositionIfNotTrackPosition;
  27914. /**
  27915. * @hidden
  27916. * Updates the cached values of the camera
  27917. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  27918. */
  27919. _updateCache(ignoreParentClass?: boolean): void;
  27920. /**
  27921. * @hidden
  27922. * Get current device position in babylon world
  27923. */
  27924. _computeDevicePosition(): void;
  27925. /**
  27926. * Updates the current device position and rotation in the babylon world
  27927. */
  27928. update(): void;
  27929. /**
  27930. * @hidden
  27931. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  27932. * @returns an identity matrix
  27933. */
  27934. _getViewMatrix(): Matrix;
  27935. private _tmpMatrix;
  27936. /**
  27937. * This function is called by the two RIG cameras.
  27938. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  27939. * @hidden
  27940. */
  27941. _getWebVRViewMatrix(): Matrix;
  27942. /** @hidden */
  27943. _getWebVRProjectionMatrix(): Matrix;
  27944. private _onGamepadConnectedObserver;
  27945. private _onGamepadDisconnectedObserver;
  27946. private _updateCacheWhenTrackingDisabledObserver;
  27947. /**
  27948. * Initializes the controllers and their meshes
  27949. */
  27950. initControllers(): void;
  27951. }
  27952. }
  27953. declare module BABYLON {
  27954. /**
  27955. * "Static Class" containing the most commonly used helper while dealing with material for rendering purpose.
  27956. *
  27957. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  27958. *
  27959. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  27960. */
  27961. export class MaterialHelper {
  27962. /**
  27963. * Bind the current view position to an effect.
  27964. * @param effect The effect to be bound
  27965. * @param scene The scene the eyes position is used from
  27966. * @param variableName name of the shader variable that will hold the eye position
  27967. * @param isVector3 true to indicates that variableName is a Vector3 and not a Vector4
  27968. * @return the computed eye position
  27969. */
  27970. static BindEyePosition(effect: Nullable<Effect>, scene: Scene, variableName?: string, isVector3?: boolean): Vector4;
  27971. /**
  27972. * Helps preparing the defines values about the UVs in used in the effect.
  27973. * UVs are shared as much as we can accross channels in the shaders.
  27974. * @param texture The texture we are preparing the UVs for
  27975. * @param defines The defines to update
  27976. * @param key The channel key "diffuse", "specular"... used in the shader
  27977. */
  27978. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  27979. /**
  27980. * Binds a texture matrix value to its corrsponding uniform
  27981. * @param texture The texture to bind the matrix for
  27982. * @param uniformBuffer The uniform buffer receivin the data
  27983. * @param key The channel key "diffuse", "specular"... used in the shader
  27984. */
  27985. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  27986. /**
  27987. * Gets the current status of the fog (should it be enabled?)
  27988. * @param mesh defines the mesh to evaluate for fog support
  27989. * @param scene defines the hosting scene
  27990. * @returns true if fog must be enabled
  27991. */
  27992. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  27993. /**
  27994. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  27995. * @param mesh defines the current mesh
  27996. * @param scene defines the current scene
  27997. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  27998. * @param pointsCloud defines if point cloud rendering has to be turned on
  27999. * @param fogEnabled defines if fog has to be turned on
  28000. * @param alphaTest defines if alpha testing has to be turned on
  28001. * @param defines defines the current list of defines
  28002. */
  28003. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  28004. /**
  28005. * Helper used to prepare the list of defines associated with frame values for shader compilation
  28006. * @param scene defines the current scene
  28007. * @param engine defines the current engine
  28008. * @param defines specifies the list of active defines
  28009. * @param useInstances defines if instances have to be turned on
  28010. * @param useClipPlane defines if clip plane have to be turned on
  28011. * @param useInstances defines if instances have to be turned on
  28012. * @param useThinInstances defines if thin instances have to be turned on
  28013. */
  28014. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  28015. /**
  28016. * Prepares the defines for bones
  28017. * @param mesh The mesh containing the geometry data we will draw
  28018. * @param defines The defines to update
  28019. */
  28020. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  28021. /**
  28022. * Prepares the defines for morph targets
  28023. * @param mesh The mesh containing the geometry data we will draw
  28024. * @param defines The defines to update
  28025. */
  28026. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  28027. /**
  28028. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  28029. * @param mesh The mesh containing the geometry data we will draw
  28030. * @param defines The defines to update
  28031. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  28032. * @param useBones Precise whether bones should be used or not (override mesh info)
  28033. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  28034. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  28035. * @returns false if defines are considered not dirty and have not been checked
  28036. */
  28037. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  28038. /**
  28039. * Prepares the defines related to multiview
  28040. * @param scene The scene we are intending to draw
  28041. * @param defines The defines to update
  28042. */
  28043. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  28044. /**
  28045. * Prepares the defines related to the prepass
  28046. * @param scene The scene we are intending to draw
  28047. * @param defines The defines to update
  28048. * @param canRenderToMRT Indicates if this material renders to several textures in the prepass
  28049. */
  28050. static PrepareDefinesForPrePass(scene: Scene, defines: any, canRenderToMRT: boolean): void;
  28051. /**
  28052. * Prepares the defines related to the light information passed in parameter
  28053. * @param scene The scene we are intending to draw
  28054. * @param mesh The mesh the effect is compiling for
  28055. * @param light The light the effect is compiling for
  28056. * @param lightIndex The index of the light
  28057. * @param defines The defines to update
  28058. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  28059. * @param state Defines the current state regarding what is needed (normals, etc...)
  28060. */
  28061. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  28062. needNormals: boolean;
  28063. needRebuild: boolean;
  28064. shadowEnabled: boolean;
  28065. specularEnabled: boolean;
  28066. lightmapMode: boolean;
  28067. }): void;
  28068. /**
  28069. * Prepares the defines related to the light information passed in parameter
  28070. * @param scene The scene we are intending to draw
  28071. * @param mesh The mesh the effect is compiling for
  28072. * @param defines The defines to update
  28073. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  28074. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  28075. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  28076. * @returns true if normals will be required for the rest of the effect
  28077. */
  28078. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  28079. /**
  28080. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  28081. * @param lightIndex defines the light index
  28082. * @param uniformsList The uniform list
  28083. * @param samplersList The sampler list
  28084. * @param projectedLightTexture defines if projected texture must be used
  28085. * @param uniformBuffersList defines an optional list of uniform buffers
  28086. * @param updateOnlyBuffersList True to only update the uniformBuffersList array
  28087. */
  28088. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>, updateOnlyBuffersList?: boolean): void;
  28089. /**
  28090. * Prepares the uniforms and samplers list to be used in the effect
  28091. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  28092. * @param samplersList The sampler list
  28093. * @param defines The defines helping in the list generation
  28094. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  28095. */
  28096. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  28097. /**
  28098. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  28099. * @param defines The defines to update while falling back
  28100. * @param fallbacks The authorized effect fallbacks
  28101. * @param maxSimultaneousLights The maximum number of lights allowed
  28102. * @param rank the current rank of the Effect
  28103. * @returns The newly affected rank
  28104. */
  28105. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  28106. private static _TmpMorphInfluencers;
  28107. /**
  28108. * Prepares the list of attributes required for morph targets according to the effect defines.
  28109. * @param attribs The current list of supported attribs
  28110. * @param mesh The mesh to prepare the morph targets attributes for
  28111. * @param influencers The number of influencers
  28112. */
  28113. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  28114. /**
  28115. * Prepares the list of attributes required for morph targets according to the effect defines.
  28116. * @param attribs The current list of supported attribs
  28117. * @param mesh The mesh to prepare the morph targets attributes for
  28118. * @param defines The current Defines of the effect
  28119. */
  28120. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  28121. /**
  28122. * Prepares the list of attributes required for bones according to the effect defines.
  28123. * @param attribs The current list of supported attribs
  28124. * @param mesh The mesh to prepare the bones attributes for
  28125. * @param defines The current Defines of the effect
  28126. * @param fallbacks The current efffect fallback strategy
  28127. */
  28128. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  28129. /**
  28130. * Check and prepare the list of attributes required for instances according to the effect defines.
  28131. * @param attribs The current list of supported attribs
  28132. * @param defines The current MaterialDefines of the effect
  28133. */
  28134. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  28135. /**
  28136. * Add the list of attributes required for instances to the attribs array.
  28137. * @param attribs The current list of supported attribs
  28138. */
  28139. static PushAttributesForInstances(attribs: string[]): void;
  28140. /**
  28141. * Binds the light information to the effect.
  28142. * @param light The light containing the generator
  28143. * @param effect The effect we are binding the data to
  28144. * @param lightIndex The light index in the effect used to render
  28145. */
  28146. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  28147. /**
  28148. * Binds the lights information from the scene to the effect for the given mesh.
  28149. * @param light Light to bind
  28150. * @param lightIndex Light index
  28151. * @param scene The scene where the light belongs to
  28152. * @param effect The effect we are binding the data to
  28153. * @param useSpecular Defines if specular is supported
  28154. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  28155. */
  28156. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  28157. /**
  28158. * Binds the lights information from the scene to the effect for the given mesh.
  28159. * @param scene The scene the lights belongs to
  28160. * @param mesh The mesh we are binding the information to render
  28161. * @param effect The effect we are binding the data to
  28162. * @param defines The generated defines for the effect
  28163. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  28164. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  28165. */
  28166. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  28167. private static _tempFogColor;
  28168. /**
  28169. * Binds the fog information from the scene to the effect for the given mesh.
  28170. * @param scene The scene the lights belongs to
  28171. * @param mesh The mesh we are binding the information to render
  28172. * @param effect The effect we are binding the data to
  28173. * @param linearSpace Defines if the fog effect is applied in linear space
  28174. */
  28175. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  28176. /**
  28177. * Binds the bones information from the mesh to the effect.
  28178. * @param mesh The mesh we are binding the information to render
  28179. * @param effect The effect we are binding the data to
  28180. * @param prePassConfiguration Configuration for the prepass, in case prepass is activated
  28181. */
  28182. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect, prePassConfiguration?: PrePassConfiguration): void;
  28183. private static _CopyBonesTransformationMatrices;
  28184. /**
  28185. * Binds the morph targets information from the mesh to the effect.
  28186. * @param abstractMesh The mesh we are binding the information to render
  28187. * @param effect The effect we are binding the data to
  28188. */
  28189. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  28190. /**
  28191. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  28192. * @param defines The generated defines used in the effect
  28193. * @param effect The effect we are binding the data to
  28194. * @param scene The scene we are willing to render with logarithmic scale for
  28195. */
  28196. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  28197. /**
  28198. * Binds the clip plane information from the scene to the effect.
  28199. * @param scene The scene the clip plane information are extracted from
  28200. * @param effect The effect we are binding the data to
  28201. */
  28202. static BindClipPlane(effect: Effect, scene: Scene): void;
  28203. }
  28204. }
  28205. declare module BABYLON {
  28206. /** @hidden */
  28207. export var bayerDitherFunctions: {
  28208. name: string;
  28209. shader: string;
  28210. };
  28211. }
  28212. declare module BABYLON {
  28213. /** @hidden */
  28214. export var shadowMapFragmentDeclaration: {
  28215. name: string;
  28216. shader: string;
  28217. };
  28218. }
  28219. declare module BABYLON {
  28220. /** @hidden */
  28221. export var shadowMapFragment: {
  28222. name: string;
  28223. shader: string;
  28224. };
  28225. }
  28226. declare module BABYLON {
  28227. /** @hidden */
  28228. export var shadowMapPixelShader: {
  28229. name: string;
  28230. shader: string;
  28231. };
  28232. }
  28233. declare module BABYLON {
  28234. /** @hidden */
  28235. export var shadowMapVertexDeclaration: {
  28236. name: string;
  28237. shader: string;
  28238. };
  28239. }
  28240. declare module BABYLON {
  28241. /** @hidden */
  28242. export var shadowMapVertexNormalBias: {
  28243. name: string;
  28244. shader: string;
  28245. };
  28246. }
  28247. declare module BABYLON {
  28248. /** @hidden */
  28249. export var shadowMapVertexMetric: {
  28250. name: string;
  28251. shader: string;
  28252. };
  28253. }
  28254. declare module BABYLON {
  28255. /** @hidden */
  28256. export var shadowMapVertexShader: {
  28257. name: string;
  28258. shader: string;
  28259. };
  28260. }
  28261. declare module BABYLON {
  28262. /** @hidden */
  28263. export var depthBoxBlurPixelShader: {
  28264. name: string;
  28265. shader: string;
  28266. };
  28267. }
  28268. declare module BABYLON {
  28269. /** @hidden */
  28270. export var shadowMapFragmentSoftTransparentShadow: {
  28271. name: string;
  28272. shader: string;
  28273. };
  28274. }
  28275. declare module BABYLON {
  28276. /**
  28277. * Creates an instance based on a source mesh.
  28278. */
  28279. export class InstancedMesh extends AbstractMesh {
  28280. private _sourceMesh;
  28281. private _currentLOD;
  28282. /** @hidden */
  28283. _indexInSourceMeshInstanceArray: number;
  28284. constructor(name: string, source: Mesh);
  28285. /**
  28286. * Returns the string "InstancedMesh".
  28287. */
  28288. getClassName(): string;
  28289. /** Gets the list of lights affecting that mesh */
  28290. get lightSources(): Light[];
  28291. _resyncLightSources(): void;
  28292. _resyncLightSource(light: Light): void;
  28293. _removeLightSource(light: Light, dispose: boolean): void;
  28294. /**
  28295. * If the source mesh receives shadows
  28296. */
  28297. get receiveShadows(): boolean;
  28298. /**
  28299. * The material of the source mesh
  28300. */
  28301. get material(): Nullable<Material>;
  28302. /**
  28303. * Visibility of the source mesh
  28304. */
  28305. get visibility(): number;
  28306. /**
  28307. * Skeleton of the source mesh
  28308. */
  28309. get skeleton(): Nullable<Skeleton>;
  28310. /**
  28311. * Rendering ground id of the source mesh
  28312. */
  28313. get renderingGroupId(): number;
  28314. set renderingGroupId(value: number);
  28315. /**
  28316. * Returns the total number of vertices (integer).
  28317. */
  28318. getTotalVertices(): number;
  28319. /**
  28320. * Returns a positive integer : the total number of indices in this mesh geometry.
  28321. * @returns the numner of indices or zero if the mesh has no geometry.
  28322. */
  28323. getTotalIndices(): number;
  28324. /**
  28325. * The source mesh of the instance
  28326. */
  28327. get sourceMesh(): Mesh;
  28328. /**
  28329. * Creates a new InstancedMesh object from the mesh model.
  28330. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  28331. * @param name defines the name of the new instance
  28332. * @returns a new InstancedMesh
  28333. */
  28334. createInstance(name: string): InstancedMesh;
  28335. /**
  28336. * Is this node ready to be used/rendered
  28337. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  28338. * @return {boolean} is it ready
  28339. */
  28340. isReady(completeCheck?: boolean): boolean;
  28341. /**
  28342. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  28343. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  28344. * @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.
  28345. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  28346. */
  28347. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  28348. /**
  28349. * Sets the vertex data of the mesh geometry for the requested `kind`.
  28350. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  28351. * The `data` are either a numeric array either a Float32Array.
  28352. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  28353. * 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).
  28354. * Note that a new underlying VertexBuffer object is created each call.
  28355. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  28356. *
  28357. * Possible `kind` values :
  28358. * - VertexBuffer.PositionKind
  28359. * - VertexBuffer.UVKind
  28360. * - VertexBuffer.UV2Kind
  28361. * - VertexBuffer.UV3Kind
  28362. * - VertexBuffer.UV4Kind
  28363. * - VertexBuffer.UV5Kind
  28364. * - VertexBuffer.UV6Kind
  28365. * - VertexBuffer.ColorKind
  28366. * - VertexBuffer.MatricesIndicesKind
  28367. * - VertexBuffer.MatricesIndicesExtraKind
  28368. * - VertexBuffer.MatricesWeightsKind
  28369. * - VertexBuffer.MatricesWeightsExtraKind
  28370. *
  28371. * Returns the Mesh.
  28372. */
  28373. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  28374. /**
  28375. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  28376. * If the mesh has no geometry, it is simply returned as it is.
  28377. * The `data` are either a numeric array either a Float32Array.
  28378. * No new underlying VertexBuffer object is created.
  28379. * 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.
  28380. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  28381. *
  28382. * Possible `kind` values :
  28383. * - VertexBuffer.PositionKind
  28384. * - VertexBuffer.UVKind
  28385. * - VertexBuffer.UV2Kind
  28386. * - VertexBuffer.UV3Kind
  28387. * - VertexBuffer.UV4Kind
  28388. * - VertexBuffer.UV5Kind
  28389. * - VertexBuffer.UV6Kind
  28390. * - VertexBuffer.ColorKind
  28391. * - VertexBuffer.MatricesIndicesKind
  28392. * - VertexBuffer.MatricesIndicesExtraKind
  28393. * - VertexBuffer.MatricesWeightsKind
  28394. * - VertexBuffer.MatricesWeightsExtraKind
  28395. *
  28396. * Returns the Mesh.
  28397. */
  28398. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  28399. /**
  28400. * Sets the mesh indices.
  28401. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  28402. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  28403. * This method creates a new index buffer each call.
  28404. * Returns the Mesh.
  28405. */
  28406. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  28407. /**
  28408. * Boolean : True if the mesh owns the requested kind of data.
  28409. */
  28410. isVerticesDataPresent(kind: string): boolean;
  28411. /**
  28412. * Returns an array of indices (IndicesArray).
  28413. */
  28414. getIndices(): Nullable<IndicesArray>;
  28415. get _positions(): Nullable<Vector3[]>;
  28416. /**
  28417. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  28418. * This means the mesh underlying bounding box and sphere are recomputed.
  28419. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  28420. * @returns the current mesh
  28421. */
  28422. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  28423. /** @hidden */
  28424. _preActivate(): InstancedMesh;
  28425. /** @hidden */
  28426. _activate(renderId: number, intermediateRendering: boolean): boolean;
  28427. /** @hidden */
  28428. _postActivate(): void;
  28429. getWorldMatrix(): Matrix;
  28430. get isAnInstance(): boolean;
  28431. /**
  28432. * Returns the current associated LOD AbstractMesh.
  28433. */
  28434. getLOD(camera: Camera): AbstractMesh;
  28435. /** @hidden */
  28436. _preActivateForIntermediateRendering(renderId: number): Mesh;
  28437. /** @hidden */
  28438. _syncSubMeshes(): InstancedMesh;
  28439. /** @hidden */
  28440. _generatePointsArray(): boolean;
  28441. /** @hidden */
  28442. _updateBoundingInfo(): AbstractMesh;
  28443. /**
  28444. * Creates a new InstancedMesh from the current mesh.
  28445. * - name (string) : the cloned mesh name
  28446. * - newParent (optional Node) : the optional Node to parent the clone to.
  28447. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  28448. *
  28449. * Returns the clone.
  28450. */
  28451. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  28452. /**
  28453. * Disposes the InstancedMesh.
  28454. * Returns nothing.
  28455. */
  28456. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  28457. }
  28458. interface Mesh {
  28459. /**
  28460. * Register a custom buffer that will be instanced
  28461. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  28462. * @param kind defines the buffer kind
  28463. * @param stride defines the stride in floats
  28464. */
  28465. registerInstancedBuffer(kind: string, stride: number): void;
  28466. /**
  28467. * Invalidate VertexArrayObjects belonging to the mesh (but not to the Geometry of the mesh).
  28468. */
  28469. _invalidateInstanceVertexArrayObject(): void;
  28470. /**
  28471. * true to use the edge renderer for all instances of this mesh
  28472. */
  28473. edgesShareWithInstances: boolean;
  28474. /** @hidden */
  28475. _userInstancedBuffersStorage: {
  28476. data: {
  28477. [key: string]: Float32Array;
  28478. };
  28479. sizes: {
  28480. [key: string]: number;
  28481. };
  28482. vertexBuffers: {
  28483. [key: string]: Nullable<VertexBuffer>;
  28484. };
  28485. strides: {
  28486. [key: string]: number;
  28487. };
  28488. vertexArrayObjects?: {
  28489. [key: string]: WebGLVertexArrayObject;
  28490. };
  28491. };
  28492. }
  28493. interface AbstractMesh {
  28494. /**
  28495. * Object used to store instanced buffers defined by user
  28496. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  28497. */
  28498. instancedBuffers: {
  28499. [key: string]: any;
  28500. };
  28501. }
  28502. }
  28503. declare module BABYLON {
  28504. /**
  28505. * Defines the options associated with the creation of a shader material.
  28506. */
  28507. export interface IShaderMaterialOptions {
  28508. /**
  28509. * Does the material work in alpha blend mode
  28510. */
  28511. needAlphaBlending: boolean;
  28512. /**
  28513. * Does the material work in alpha test mode
  28514. */
  28515. needAlphaTesting: boolean;
  28516. /**
  28517. * The list of attribute names used in the shader
  28518. */
  28519. attributes: string[];
  28520. /**
  28521. * The list of unifrom names used in the shader
  28522. */
  28523. uniforms: string[];
  28524. /**
  28525. * The list of UBO names used in the shader
  28526. */
  28527. uniformBuffers: string[];
  28528. /**
  28529. * The list of sampler names used in the shader
  28530. */
  28531. samplers: string[];
  28532. /**
  28533. * The list of defines used in the shader
  28534. */
  28535. defines: string[];
  28536. }
  28537. /**
  28538. * 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.
  28539. *
  28540. * This returned material effects how the mesh will look based on the code in the shaders.
  28541. *
  28542. * @see https://doc.babylonjs.com/how_to/shader_material
  28543. */
  28544. export class ShaderMaterial extends Material {
  28545. private _shaderPath;
  28546. private _options;
  28547. private _textures;
  28548. private _textureArrays;
  28549. private _floats;
  28550. private _ints;
  28551. private _floatsArrays;
  28552. private _colors3;
  28553. private _colors3Arrays;
  28554. private _colors4;
  28555. private _colors4Arrays;
  28556. private _vectors2;
  28557. private _vectors3;
  28558. private _vectors4;
  28559. private _matrices;
  28560. private _matrixArrays;
  28561. private _matrices3x3;
  28562. private _matrices2x2;
  28563. private _vectors2Arrays;
  28564. private _vectors3Arrays;
  28565. private _vectors4Arrays;
  28566. private _cachedWorldViewMatrix;
  28567. private _cachedWorldViewProjectionMatrix;
  28568. private _renderId;
  28569. private _multiview;
  28570. private _cachedDefines;
  28571. /** Define the Url to load snippets */
  28572. static SnippetUrl: string;
  28573. /** Snippet ID if the material was created from the snippet server */
  28574. snippetId: string;
  28575. /**
  28576. * Instantiate a new shader material.
  28577. * 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.
  28578. * This returned material effects how the mesh will look based on the code in the shaders.
  28579. * @see https://doc.babylonjs.com/how_to/shader_material
  28580. * @param name Define the name of the material in the scene
  28581. * @param scene Define the scene the material belongs to
  28582. * @param shaderPath Defines the route to the shader code in one of three ways:
  28583. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  28584. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  28585. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  28586. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  28587. * @param options Define the options used to create the shader
  28588. */
  28589. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  28590. /**
  28591. * Gets the shader path used to define the shader code
  28592. * It can be modified to trigger a new compilation
  28593. */
  28594. get shaderPath(): any;
  28595. /**
  28596. * Sets the shader path used to define the shader code
  28597. * It can be modified to trigger a new compilation
  28598. */
  28599. set shaderPath(shaderPath: any);
  28600. /**
  28601. * Gets the options used to compile the shader.
  28602. * They can be modified to trigger a new compilation
  28603. */
  28604. get options(): IShaderMaterialOptions;
  28605. /**
  28606. * Gets the current class name of the material e.g. "ShaderMaterial"
  28607. * Mainly use in serialization.
  28608. * @returns the class name
  28609. */
  28610. getClassName(): string;
  28611. /**
  28612. * Specifies if the material will require alpha blending
  28613. * @returns a boolean specifying if alpha blending is needed
  28614. */
  28615. needAlphaBlending(): boolean;
  28616. /**
  28617. * Specifies if this material should be rendered in alpha test mode
  28618. * @returns a boolean specifying if an alpha test is needed.
  28619. */
  28620. needAlphaTesting(): boolean;
  28621. private _checkUniform;
  28622. /**
  28623. * Set a texture in the shader.
  28624. * @param name Define the name of the uniform samplers as defined in the shader
  28625. * @param texture Define the texture to bind to this sampler
  28626. * @return the material itself allowing "fluent" like uniform updates
  28627. */
  28628. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  28629. /**
  28630. * Set a texture array in the shader.
  28631. * @param name Define the name of the uniform sampler array as defined in the shader
  28632. * @param textures Define the list of textures to bind to this sampler
  28633. * @return the material itself allowing "fluent" like uniform updates
  28634. */
  28635. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  28636. /**
  28637. * Set a float in the shader.
  28638. * @param name Define the name of the uniform as defined in the shader
  28639. * @param value Define the value to give to the uniform
  28640. * @return the material itself allowing "fluent" like uniform updates
  28641. */
  28642. setFloat(name: string, value: number): ShaderMaterial;
  28643. /**
  28644. * Set a int in the shader.
  28645. * @param name Define the name of the uniform as defined in the shader
  28646. * @param value Define the value to give to the uniform
  28647. * @return the material itself allowing "fluent" like uniform updates
  28648. */
  28649. setInt(name: string, value: number): ShaderMaterial;
  28650. /**
  28651. * Set an array of floats in the shader.
  28652. * @param name Define the name of the uniform as defined in the shader
  28653. * @param value Define the value to give to the uniform
  28654. * @return the material itself allowing "fluent" like uniform updates
  28655. */
  28656. setFloats(name: string, value: number[]): ShaderMaterial;
  28657. /**
  28658. * Set a vec3 in the shader from a Color3.
  28659. * @param name Define the name of the uniform as defined in the shader
  28660. * @param value Define the value to give to the uniform
  28661. * @return the material itself allowing "fluent" like uniform updates
  28662. */
  28663. setColor3(name: string, value: Color3): ShaderMaterial;
  28664. /**
  28665. * Set a vec3 array in the shader from a Color3 array.
  28666. * @param name Define the name of the uniform as defined in the shader
  28667. * @param value Define the value to give to the uniform
  28668. * @return the material itself allowing "fluent" like uniform updates
  28669. */
  28670. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  28671. /**
  28672. * Set a vec4 in the shader from a Color4.
  28673. * @param name Define the name of the uniform as defined in the shader
  28674. * @param value Define the value to give to the uniform
  28675. * @return the material itself allowing "fluent" like uniform updates
  28676. */
  28677. setColor4(name: string, value: Color4): ShaderMaterial;
  28678. /**
  28679. * Set a vec4 array in the shader from a Color4 array.
  28680. * @param name Define the name of the uniform as defined in the shader
  28681. * @param value Define the value to give to the uniform
  28682. * @return the material itself allowing "fluent" like uniform updates
  28683. */
  28684. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  28685. /**
  28686. * Set a vec2 in the shader from a Vector2.
  28687. * @param name Define the name of the uniform as defined in the shader
  28688. * @param value Define the value to give to the uniform
  28689. * @return the material itself allowing "fluent" like uniform updates
  28690. */
  28691. setVector2(name: string, value: Vector2): ShaderMaterial;
  28692. /**
  28693. * Set a vec3 in the shader from a Vector3.
  28694. * @param name Define the name of the uniform as defined in the shader
  28695. * @param value Define the value to give to the uniform
  28696. * @return the material itself allowing "fluent" like uniform updates
  28697. */
  28698. setVector3(name: string, value: Vector3): ShaderMaterial;
  28699. /**
  28700. * Set a vec4 in the shader from a Vector4.
  28701. * @param name Define the name of the uniform as defined in the shader
  28702. * @param value Define the value to give to the uniform
  28703. * @return the material itself allowing "fluent" like uniform updates
  28704. */
  28705. setVector4(name: string, value: Vector4): ShaderMaterial;
  28706. /**
  28707. * Set a mat4 in the shader from a Matrix.
  28708. * @param name Define the name of the uniform as defined in the shader
  28709. * @param value Define the value to give to the uniform
  28710. * @return the material itself allowing "fluent" like uniform updates
  28711. */
  28712. setMatrix(name: string, value: Matrix): ShaderMaterial;
  28713. /**
  28714. * Set a float32Array in the shader from a matrix array.
  28715. * @param name Define the name of the uniform as defined in the shader
  28716. * @param value Define the value to give to the uniform
  28717. * @return the material itself allowing "fluent" like uniform updates
  28718. */
  28719. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  28720. /**
  28721. * Set a mat3 in the shader from a Float32Array.
  28722. * @param name Define the name of the uniform as defined in the shader
  28723. * @param value Define the value to give to the uniform
  28724. * @return the material itself allowing "fluent" like uniform updates
  28725. */
  28726. setMatrix3x3(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  28727. /**
  28728. * Set a mat2 in the shader from a Float32Array.
  28729. * @param name Define the name of the uniform as defined in the shader
  28730. * @param value Define the value to give to the uniform
  28731. * @return the material itself allowing "fluent" like uniform updates
  28732. */
  28733. setMatrix2x2(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  28734. /**
  28735. * Set a vec2 array in the shader from a number array.
  28736. * @param name Define the name of the uniform as defined in the shader
  28737. * @param value Define the value to give to the uniform
  28738. * @return the material itself allowing "fluent" like uniform updates
  28739. */
  28740. setArray2(name: string, value: number[]): ShaderMaterial;
  28741. /**
  28742. * Set a vec3 array in the shader from a number array.
  28743. * @param name Define the name of the uniform as defined in the shader
  28744. * @param value Define the value to give to the uniform
  28745. * @return the material itself allowing "fluent" like uniform updates
  28746. */
  28747. setArray3(name: string, value: number[]): ShaderMaterial;
  28748. /**
  28749. * Set a vec4 array in the shader from a number array.
  28750. * @param name Define the name of the uniform as defined in the shader
  28751. * @param value Define the value to give to the uniform
  28752. * @return the material itself allowing "fluent" like uniform updates
  28753. */
  28754. setArray4(name: string, value: number[]): ShaderMaterial;
  28755. private _checkCache;
  28756. /**
  28757. * Specifies that the submesh is ready to be used
  28758. * @param mesh defines the mesh to check
  28759. * @param subMesh defines which submesh to check
  28760. * @param useInstances specifies that instances should be used
  28761. * @returns a boolean indicating that the submesh is ready or not
  28762. */
  28763. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  28764. /**
  28765. * Checks if the material is ready to render the requested mesh
  28766. * @param mesh Define the mesh to render
  28767. * @param useInstances Define whether or not the material is used with instances
  28768. * @returns true if ready, otherwise false
  28769. */
  28770. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  28771. /**
  28772. * Binds the world matrix to the material
  28773. * @param world defines the world transformation matrix
  28774. * @param effectOverride - If provided, use this effect instead of internal effect
  28775. */
  28776. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  28777. /**
  28778. * Binds the submesh to this material by preparing the effect and shader to draw
  28779. * @param world defines the world transformation matrix
  28780. * @param mesh defines the mesh containing the submesh
  28781. * @param subMesh defines the submesh to bind the material to
  28782. */
  28783. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  28784. /**
  28785. * Binds the material to the mesh
  28786. * @param world defines the world transformation matrix
  28787. * @param mesh defines the mesh to bind the material to
  28788. * @param effectOverride - If provided, use this effect instead of internal effect
  28789. */
  28790. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  28791. protected _afterBind(mesh?: Mesh, effect?: Nullable<Effect>): void;
  28792. /**
  28793. * Gets the active textures from the material
  28794. * @returns an array of textures
  28795. */
  28796. getActiveTextures(): BaseTexture[];
  28797. /**
  28798. * Specifies if the material uses a texture
  28799. * @param texture defines the texture to check against the material
  28800. * @returns a boolean specifying if the material uses the texture
  28801. */
  28802. hasTexture(texture: BaseTexture): boolean;
  28803. /**
  28804. * Makes a duplicate of the material, and gives it a new name
  28805. * @param name defines the new name for the duplicated material
  28806. * @returns the cloned material
  28807. */
  28808. clone(name: string): ShaderMaterial;
  28809. /**
  28810. * Disposes the material
  28811. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  28812. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  28813. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  28814. */
  28815. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  28816. /**
  28817. * Serializes this material in a JSON representation
  28818. * @returns the serialized material object
  28819. */
  28820. serialize(): any;
  28821. /**
  28822. * Creates a shader material from parsed shader material data
  28823. * @param source defines the JSON represnetation of the material
  28824. * @param scene defines the hosting scene
  28825. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  28826. * @returns a new material
  28827. */
  28828. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  28829. /**
  28830. * Creates a new ShaderMaterial from a snippet saved in a remote file
  28831. * @param name defines the name of the ShaderMaterial to create (can be null or empty to use the one from the json data)
  28832. * @param url defines the url to load from
  28833. * @param scene defines the hosting scene
  28834. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  28835. * @returns a promise that will resolve to the new ShaderMaterial
  28836. */
  28837. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  28838. /**
  28839. * Creates a ShaderMaterial from a snippet saved by the Inspector
  28840. * @param snippetId defines the snippet to load
  28841. * @param scene defines the hosting scene
  28842. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  28843. * @returns a promise that will resolve to the new ShaderMaterial
  28844. */
  28845. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  28846. }
  28847. }
  28848. declare module BABYLON {
  28849. /** @hidden */
  28850. export var colorPixelShader: {
  28851. name: string;
  28852. shader: string;
  28853. };
  28854. }
  28855. declare module BABYLON {
  28856. /** @hidden */
  28857. export var colorVertexShader: {
  28858. name: string;
  28859. shader: string;
  28860. };
  28861. }
  28862. declare module BABYLON {
  28863. /**
  28864. * Line mesh
  28865. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  28866. */
  28867. export class LinesMesh extends Mesh {
  28868. /**
  28869. * If vertex color should be applied to the mesh
  28870. */
  28871. readonly useVertexColor?: boolean | undefined;
  28872. /**
  28873. * If vertex alpha should be applied to the mesh
  28874. */
  28875. readonly useVertexAlpha?: boolean | undefined;
  28876. /**
  28877. * Color of the line (Default: White)
  28878. */
  28879. color: Color3;
  28880. /**
  28881. * Alpha of the line (Default: 1)
  28882. */
  28883. alpha: number;
  28884. /**
  28885. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  28886. * This margin is expressed in world space coordinates, so its value may vary.
  28887. * Default value is 0.1
  28888. */
  28889. intersectionThreshold: number;
  28890. private _colorShader;
  28891. private color4;
  28892. /**
  28893. * Creates a new LinesMesh
  28894. * @param name defines the name
  28895. * @param scene defines the hosting scene
  28896. * @param parent defines the parent mesh if any
  28897. * @param source defines the optional source LinesMesh used to clone data from
  28898. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  28899. * When false, achieved by calling a clone(), also passing False.
  28900. * This will make creation of children, recursive.
  28901. * @param useVertexColor defines if this LinesMesh supports vertex color
  28902. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  28903. */
  28904. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  28905. /**
  28906. * If vertex color should be applied to the mesh
  28907. */
  28908. useVertexColor?: boolean | undefined,
  28909. /**
  28910. * If vertex alpha should be applied to the mesh
  28911. */
  28912. useVertexAlpha?: boolean | undefined);
  28913. private _addClipPlaneDefine;
  28914. private _removeClipPlaneDefine;
  28915. isReady(): boolean;
  28916. /**
  28917. * Returns the string "LineMesh"
  28918. */
  28919. getClassName(): string;
  28920. /**
  28921. * @hidden
  28922. */
  28923. get material(): Material;
  28924. /**
  28925. * @hidden
  28926. */
  28927. set material(value: Material);
  28928. /**
  28929. * @hidden
  28930. */
  28931. get checkCollisions(): boolean;
  28932. set checkCollisions(value: boolean);
  28933. /** @hidden */
  28934. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  28935. /** @hidden */
  28936. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  28937. /**
  28938. * Disposes of the line mesh
  28939. * @param doNotRecurse If children should be disposed
  28940. */
  28941. dispose(doNotRecurse?: boolean): void;
  28942. /**
  28943. * Returns a new LineMesh object cloned from the current one.
  28944. */
  28945. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  28946. /**
  28947. * Creates a new InstancedLinesMesh object from the mesh model.
  28948. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  28949. * @param name defines the name of the new instance
  28950. * @returns a new InstancedLinesMesh
  28951. */
  28952. createInstance(name: string): InstancedLinesMesh;
  28953. }
  28954. /**
  28955. * Creates an instance based on a source LinesMesh
  28956. */
  28957. export class InstancedLinesMesh extends InstancedMesh {
  28958. /**
  28959. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  28960. * This margin is expressed in world space coordinates, so its value may vary.
  28961. * Initilized with the intersectionThreshold value of the source LinesMesh
  28962. */
  28963. intersectionThreshold: number;
  28964. constructor(name: string, source: LinesMesh);
  28965. /**
  28966. * Returns the string "InstancedLinesMesh".
  28967. */
  28968. getClassName(): string;
  28969. }
  28970. }
  28971. declare module BABYLON {
  28972. /** @hidden */
  28973. export var linePixelShader: {
  28974. name: string;
  28975. shader: string;
  28976. };
  28977. }
  28978. declare module BABYLON {
  28979. /** @hidden */
  28980. export var lineVertexShader: {
  28981. name: string;
  28982. shader: string;
  28983. };
  28984. }
  28985. declare module BABYLON {
  28986. interface Scene {
  28987. /** @hidden */
  28988. _edgeRenderLineShader: Nullable<ShaderMaterial>;
  28989. }
  28990. interface AbstractMesh {
  28991. /**
  28992. * Gets the edgesRenderer associated with the mesh
  28993. */
  28994. edgesRenderer: Nullable<EdgesRenderer>;
  28995. }
  28996. interface LinesMesh {
  28997. /**
  28998. * Enables the edge rendering mode on the mesh.
  28999. * This mode makes the mesh edges visible
  29000. * @param epsilon defines the maximal distance between two angles to detect a face
  29001. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  29002. * @returns the currentAbstractMesh
  29003. * @see https://www.babylonjs-playground.com/#19O9TU#0
  29004. */
  29005. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  29006. }
  29007. interface InstancedLinesMesh {
  29008. /**
  29009. * Enables the edge rendering mode on the mesh.
  29010. * This mode makes the mesh edges visible
  29011. * @param epsilon defines the maximal distance between two angles to detect a face
  29012. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  29013. * @returns the current InstancedLinesMesh
  29014. * @see https://www.babylonjs-playground.com/#19O9TU#0
  29015. */
  29016. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  29017. }
  29018. /**
  29019. * Defines the minimum contract an Edges renderer should follow.
  29020. */
  29021. export interface IEdgesRenderer extends IDisposable {
  29022. /**
  29023. * Gets or sets a boolean indicating if the edgesRenderer is active
  29024. */
  29025. isEnabled: boolean;
  29026. /**
  29027. * Renders the edges of the attached mesh,
  29028. */
  29029. render(): void;
  29030. /**
  29031. * Checks wether or not the edges renderer is ready to render.
  29032. * @return true if ready, otherwise false.
  29033. */
  29034. isReady(): boolean;
  29035. /**
  29036. * List of instances to render in case the source mesh has instances
  29037. */
  29038. customInstances: SmartArray<Matrix>;
  29039. }
  29040. /**
  29041. * Defines the additional options of the edges renderer
  29042. */
  29043. export interface IEdgesRendererOptions {
  29044. /**
  29045. * Gets or sets a boolean indicating that the alternate edge finder algorithm must be used
  29046. * If not defined, the default value is true
  29047. */
  29048. useAlternateEdgeFinder?: boolean;
  29049. /**
  29050. * Gets or sets a boolean indicating that the vertex merger fast processing must be used.
  29051. * If not defined, the default value is true.
  29052. * 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)
  29053. * This option is used only if useAlternateEdgeFinder = true
  29054. */
  29055. useFastVertexMerger?: boolean;
  29056. /**
  29057. * During edges processing, the vertices are merged if they are close enough: epsilonVertexMerge is the limit whithin which vertices are considered to be equal.
  29058. * The default value is 1e-6
  29059. * This option is used only if useAlternateEdgeFinder = true
  29060. */
  29061. epsilonVertexMerge?: number;
  29062. /**
  29063. * 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
  29064. * 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.
  29065. * This option is used only if useAlternateEdgeFinder = true
  29066. */
  29067. applyTessellation?: boolean;
  29068. /**
  29069. * 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
  29070. * The default value is 1e-6
  29071. * This option is used only if useAlternateEdgeFinder = true
  29072. */
  29073. epsilonVertexAligned?: number;
  29074. }
  29075. /**
  29076. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  29077. */
  29078. export class EdgesRenderer implements IEdgesRenderer {
  29079. /**
  29080. * Define the size of the edges with an orthographic camera
  29081. */
  29082. edgesWidthScalerForOrthographic: number;
  29083. /**
  29084. * Define the size of the edges with a perspective camera
  29085. */
  29086. edgesWidthScalerForPerspective: number;
  29087. protected _source: AbstractMesh;
  29088. protected _linesPositions: number[];
  29089. protected _linesNormals: number[];
  29090. protected _linesIndices: number[];
  29091. protected _epsilon: number;
  29092. protected _indicesCount: number;
  29093. protected _lineShader: ShaderMaterial;
  29094. protected _ib: DataBuffer;
  29095. protected _buffers: {
  29096. [key: string]: Nullable<VertexBuffer>;
  29097. };
  29098. protected _buffersForInstances: {
  29099. [key: string]: Nullable<VertexBuffer>;
  29100. };
  29101. protected _checkVerticesInsteadOfIndices: boolean;
  29102. protected _options: Nullable<IEdgesRendererOptions>;
  29103. private _meshRebuildObserver;
  29104. private _meshDisposeObserver;
  29105. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  29106. isEnabled: boolean;
  29107. /** Gets the vertices generated by the edge renderer */
  29108. get linesPositions(): Immutable<Array<number>>;
  29109. /** Gets the normals generated by the edge renderer */
  29110. get linesNormals(): Immutable<Array<number>>;
  29111. /** Gets the indices generated by the edge renderer */
  29112. get linesIndices(): Immutable<Array<number>>;
  29113. /**
  29114. * List of instances to render in case the source mesh has instances
  29115. */
  29116. customInstances: SmartArray<Matrix>;
  29117. private static GetShader;
  29118. /**
  29119. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  29120. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  29121. * @param source Mesh used to create edges
  29122. * @param epsilon sum of angles in adjacency to check for edge
  29123. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices. Note that this parameter is not used if options.useAlternateEdgeFinder = true
  29124. * @param generateEdgesLines - should generate Lines or only prepare resources.
  29125. * @param options The options to apply when generating the edges
  29126. */
  29127. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean, options?: IEdgesRendererOptions);
  29128. protected _prepareRessources(): void;
  29129. /** @hidden */
  29130. _rebuild(): void;
  29131. /**
  29132. * Releases the required resources for the edges renderer
  29133. */
  29134. dispose(): void;
  29135. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  29136. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  29137. /**
  29138. * Checks if the pair of p0 and p1 is en edge
  29139. * @param faceIndex
  29140. * @param edge
  29141. * @param faceNormals
  29142. * @param p0
  29143. * @param p1
  29144. * @private
  29145. */
  29146. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  29147. /**
  29148. * push line into the position, normal and index buffer
  29149. * @protected
  29150. */
  29151. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  29152. /**
  29153. * See https://playground.babylonjs.com/#R3JR6V#1 for a visual display of the algorithm
  29154. */
  29155. private _tessellateTriangle;
  29156. private _generateEdgesLinesAlternate;
  29157. /**
  29158. * Generates lines edges from adjacencjes
  29159. * @private
  29160. */
  29161. _generateEdgesLines(): void;
  29162. /**
  29163. * Checks wether or not the edges renderer is ready to render.
  29164. * @return true if ready, otherwise false.
  29165. */
  29166. isReady(): boolean;
  29167. /**
  29168. * Renders the edges of the attached mesh,
  29169. */
  29170. render(): void;
  29171. }
  29172. /**
  29173. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  29174. */
  29175. export class LineEdgesRenderer extends EdgesRenderer {
  29176. /**
  29177. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  29178. * @param source LineMesh used to generate edges
  29179. * @param epsilon not important (specified angle for edge detection)
  29180. * @param checkVerticesInsteadOfIndices not important for LineMesh
  29181. */
  29182. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  29183. /**
  29184. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  29185. */
  29186. _generateEdgesLines(): void;
  29187. }
  29188. }
  29189. declare module BABYLON {
  29190. /**
  29191. * This represents the object necessary to create a rendering group.
  29192. * This is exclusively used and created by the rendering manager.
  29193. * To modify the behavior, you use the available helpers in your scene or meshes.
  29194. * @hidden
  29195. */
  29196. export class RenderingGroup {
  29197. index: number;
  29198. private static _zeroVector;
  29199. private _scene;
  29200. private _opaqueSubMeshes;
  29201. private _transparentSubMeshes;
  29202. private _alphaTestSubMeshes;
  29203. private _depthOnlySubMeshes;
  29204. private _particleSystems;
  29205. private _spriteManagers;
  29206. private _opaqueSortCompareFn;
  29207. private _alphaTestSortCompareFn;
  29208. private _transparentSortCompareFn;
  29209. private _renderOpaque;
  29210. private _renderAlphaTest;
  29211. private _renderTransparent;
  29212. /** @hidden */
  29213. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  29214. onBeforeTransparentRendering: () => void;
  29215. /**
  29216. * Set the opaque sort comparison function.
  29217. * If null the sub meshes will be render in the order they were created
  29218. */
  29219. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  29220. /**
  29221. * Set the alpha test sort comparison function.
  29222. * If null the sub meshes will be render in the order they were created
  29223. */
  29224. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  29225. /**
  29226. * Set the transparent sort comparison function.
  29227. * If null the sub meshes will be render in the order they were created
  29228. */
  29229. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  29230. /**
  29231. * Creates a new rendering group.
  29232. * @param index The rendering group index
  29233. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  29234. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  29235. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  29236. */
  29237. 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>);
  29238. /**
  29239. * Render all the sub meshes contained in the group.
  29240. * @param customRenderFunction Used to override the default render behaviour of the group.
  29241. * @returns true if rendered some submeshes.
  29242. */
  29243. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  29244. /**
  29245. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  29246. * @param subMeshes The submeshes to render
  29247. */
  29248. private renderOpaqueSorted;
  29249. /**
  29250. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  29251. * @param subMeshes The submeshes to render
  29252. */
  29253. private renderAlphaTestSorted;
  29254. /**
  29255. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  29256. * @param subMeshes The submeshes to render
  29257. */
  29258. private renderTransparentSorted;
  29259. /**
  29260. * Renders the submeshes in a specified order.
  29261. * @param subMeshes The submeshes to sort before render
  29262. * @param sortCompareFn The comparison function use to sort
  29263. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  29264. * @param transparent Specifies to activate blending if true
  29265. */
  29266. private static renderSorted;
  29267. /**
  29268. * Renders the submeshes in the order they were dispatched (no sort applied).
  29269. * @param subMeshes The submeshes to render
  29270. */
  29271. private static renderUnsorted;
  29272. /**
  29273. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  29274. * are rendered back to front if in the same alpha index.
  29275. *
  29276. * @param a The first submesh
  29277. * @param b The second submesh
  29278. * @returns The result of the comparison
  29279. */
  29280. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  29281. /**
  29282. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  29283. * are rendered back to front.
  29284. *
  29285. * @param a The first submesh
  29286. * @param b The second submesh
  29287. * @returns The result of the comparison
  29288. */
  29289. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  29290. /**
  29291. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  29292. * are rendered front to back (prevent overdraw).
  29293. *
  29294. * @param a The first submesh
  29295. * @param b The second submesh
  29296. * @returns The result of the comparison
  29297. */
  29298. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  29299. /**
  29300. * Resets the different lists of submeshes to prepare a new frame.
  29301. */
  29302. prepare(): void;
  29303. dispose(): void;
  29304. /**
  29305. * Inserts the submesh in its correct queue depending on its material.
  29306. * @param subMesh The submesh to dispatch
  29307. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  29308. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  29309. */
  29310. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  29311. dispatchSprites(spriteManager: ISpriteManager): void;
  29312. dispatchParticles(particleSystem: IParticleSystem): void;
  29313. private _renderParticles;
  29314. private _renderSprites;
  29315. }
  29316. }
  29317. declare module BABYLON {
  29318. /**
  29319. * Interface describing the different options available in the rendering manager
  29320. * regarding Auto Clear between groups.
  29321. */
  29322. export interface IRenderingManagerAutoClearSetup {
  29323. /**
  29324. * Defines whether or not autoclear is enable.
  29325. */
  29326. autoClear: boolean;
  29327. /**
  29328. * Defines whether or not to autoclear the depth buffer.
  29329. */
  29330. depth: boolean;
  29331. /**
  29332. * Defines whether or not to autoclear the stencil buffer.
  29333. */
  29334. stencil: boolean;
  29335. }
  29336. /**
  29337. * This class is used by the onRenderingGroupObservable
  29338. */
  29339. export class RenderingGroupInfo {
  29340. /**
  29341. * The Scene that being rendered
  29342. */
  29343. scene: Scene;
  29344. /**
  29345. * The camera currently used for the rendering pass
  29346. */
  29347. camera: Nullable<Camera>;
  29348. /**
  29349. * The ID of the renderingGroup being processed
  29350. */
  29351. renderingGroupId: number;
  29352. }
  29353. /**
  29354. * This is the manager responsible of all the rendering for meshes sprites and particles.
  29355. * It is enable to manage the different groups as well as the different necessary sort functions.
  29356. * This should not be used directly aside of the few static configurations
  29357. */
  29358. export class RenderingManager {
  29359. /**
  29360. * The max id used for rendering groups (not included)
  29361. */
  29362. static MAX_RENDERINGGROUPS: number;
  29363. /**
  29364. * The min id used for rendering groups (included)
  29365. */
  29366. static MIN_RENDERINGGROUPS: number;
  29367. /**
  29368. * Used to globally prevent autoclearing scenes.
  29369. */
  29370. static AUTOCLEAR: boolean;
  29371. /**
  29372. * @hidden
  29373. */
  29374. _useSceneAutoClearSetup: boolean;
  29375. private _scene;
  29376. private _renderingGroups;
  29377. private _depthStencilBufferAlreadyCleaned;
  29378. private _autoClearDepthStencil;
  29379. private _customOpaqueSortCompareFn;
  29380. private _customAlphaTestSortCompareFn;
  29381. private _customTransparentSortCompareFn;
  29382. private _renderingGroupInfo;
  29383. /**
  29384. * Instantiates a new rendering group for a particular scene
  29385. * @param scene Defines the scene the groups belongs to
  29386. */
  29387. constructor(scene: Scene);
  29388. private _clearDepthStencilBuffer;
  29389. /**
  29390. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  29391. * @hidden
  29392. */
  29393. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  29394. /**
  29395. * Resets the different information of the group to prepare a new frame
  29396. * @hidden
  29397. */
  29398. reset(): void;
  29399. /**
  29400. * Dispose and release the group and its associated resources.
  29401. * @hidden
  29402. */
  29403. dispose(): void;
  29404. /**
  29405. * Clear the info related to rendering groups preventing retention points during dispose.
  29406. */
  29407. freeRenderingGroups(): void;
  29408. private _prepareRenderingGroup;
  29409. /**
  29410. * Add a sprite manager to the rendering manager in order to render it this frame.
  29411. * @param spriteManager Define the sprite manager to render
  29412. */
  29413. dispatchSprites(spriteManager: ISpriteManager): void;
  29414. /**
  29415. * Add a particle system to the rendering manager in order to render it this frame.
  29416. * @param particleSystem Define the particle system to render
  29417. */
  29418. dispatchParticles(particleSystem: IParticleSystem): void;
  29419. /**
  29420. * Add a submesh to the manager in order to render it this frame
  29421. * @param subMesh The submesh to dispatch
  29422. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  29423. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  29424. */
  29425. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  29426. /**
  29427. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  29428. * This allowed control for front to back rendering or reversly depending of the special needs.
  29429. *
  29430. * @param renderingGroupId The rendering group id corresponding to its index
  29431. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  29432. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  29433. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  29434. */
  29435. 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;
  29436. /**
  29437. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  29438. *
  29439. * @param renderingGroupId The rendering group id corresponding to its index
  29440. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  29441. * @param depth Automatically clears depth between groups if true and autoClear is true.
  29442. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  29443. */
  29444. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  29445. /**
  29446. * Gets the current auto clear configuration for one rendering group of the rendering
  29447. * manager.
  29448. * @param index the rendering group index to get the information for
  29449. * @returns The auto clear setup for the requested rendering group
  29450. */
  29451. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  29452. }
  29453. }
  29454. declare module BABYLON {
  29455. /**
  29456. * Defines the options associated with the creation of a custom shader for a shadow generator.
  29457. */
  29458. export interface ICustomShaderOptions {
  29459. /**
  29460. * Gets or sets the custom shader name to use
  29461. */
  29462. shaderName: string;
  29463. /**
  29464. * The list of attribute names used in the shader
  29465. */
  29466. attributes?: string[];
  29467. /**
  29468. * The list of unifrom names used in the shader
  29469. */
  29470. uniforms?: string[];
  29471. /**
  29472. * The list of sampler names used in the shader
  29473. */
  29474. samplers?: string[];
  29475. /**
  29476. * The list of defines used in the shader
  29477. */
  29478. defines?: string[];
  29479. }
  29480. /**
  29481. * Interface to implement to create a shadow generator compatible with BJS.
  29482. */
  29483. export interface IShadowGenerator {
  29484. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  29485. id: string;
  29486. /**
  29487. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  29488. * @returns The render target texture if present otherwise, null
  29489. */
  29490. getShadowMap(): Nullable<RenderTargetTexture>;
  29491. /**
  29492. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  29493. * @param subMesh The submesh we want to render in the shadow map
  29494. * @param useInstances Defines wether will draw in the map using instances
  29495. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  29496. * @returns true if ready otherwise, false
  29497. */
  29498. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  29499. /**
  29500. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  29501. * @param defines Defines of the material we want to update
  29502. * @param lightIndex Index of the light in the enabled light list of the material
  29503. */
  29504. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  29505. /**
  29506. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  29507. * defined in the generator but impacting the effect).
  29508. * It implies the unifroms available on the materials are the standard BJS ones.
  29509. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  29510. * @param effect The effect we are binfing the information for
  29511. */
  29512. bindShadowLight(lightIndex: string, effect: Effect): void;
  29513. /**
  29514. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  29515. * (eq to shadow prjection matrix * light transform matrix)
  29516. * @returns The transform matrix used to create the shadow map
  29517. */
  29518. getTransformMatrix(): Matrix;
  29519. /**
  29520. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  29521. * Cube and 2D textures for instance.
  29522. */
  29523. recreateShadowMap(): void;
  29524. /**
  29525. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  29526. * @param onCompiled Callback triggered at the and of the effects compilation
  29527. * @param options Sets of optional options forcing the compilation with different modes
  29528. */
  29529. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  29530. useInstances: boolean;
  29531. }>): void;
  29532. /**
  29533. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  29534. * @param options Sets of optional options forcing the compilation with different modes
  29535. * @returns A promise that resolves when the compilation completes
  29536. */
  29537. forceCompilationAsync(options?: Partial<{
  29538. useInstances: boolean;
  29539. }>): Promise<void>;
  29540. /**
  29541. * Serializes the shadow generator setup to a json object.
  29542. * @returns The serialized JSON object
  29543. */
  29544. serialize(): any;
  29545. /**
  29546. * Disposes the Shadow map and related Textures and effects.
  29547. */
  29548. dispose(): void;
  29549. }
  29550. /**
  29551. * Default implementation IShadowGenerator.
  29552. * This is the main object responsible of generating shadows in the framework.
  29553. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  29554. */
  29555. export class ShadowGenerator implements IShadowGenerator {
  29556. private static _Counter;
  29557. /**
  29558. * Name of the shadow generator class
  29559. */
  29560. static CLASSNAME: string;
  29561. /**
  29562. * Shadow generator mode None: no filtering applied.
  29563. */
  29564. static readonly FILTER_NONE: number;
  29565. /**
  29566. * Shadow generator mode ESM: Exponential Shadow Mapping.
  29567. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  29568. */
  29569. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  29570. /**
  29571. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  29572. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  29573. */
  29574. static readonly FILTER_POISSONSAMPLING: number;
  29575. /**
  29576. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  29577. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  29578. */
  29579. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  29580. /**
  29581. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  29582. * edge artifacts on steep falloff.
  29583. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  29584. */
  29585. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  29586. /**
  29587. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  29588. * edge artifacts on steep falloff.
  29589. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  29590. */
  29591. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  29592. /**
  29593. * Shadow generator mode PCF: Percentage Closer Filtering
  29594. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  29595. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  29596. */
  29597. static readonly FILTER_PCF: number;
  29598. /**
  29599. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  29600. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  29601. * Contact Hardening
  29602. */
  29603. static readonly FILTER_PCSS: number;
  29604. /**
  29605. * Reserved for PCF and PCSS
  29606. * Highest Quality.
  29607. *
  29608. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  29609. *
  29610. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  29611. */
  29612. static readonly QUALITY_HIGH: number;
  29613. /**
  29614. * Reserved for PCF and PCSS
  29615. * Good tradeoff for quality/perf cross devices
  29616. *
  29617. * Execute PCF on a 3*3 kernel.
  29618. *
  29619. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  29620. */
  29621. static readonly QUALITY_MEDIUM: number;
  29622. /**
  29623. * Reserved for PCF and PCSS
  29624. * The lowest quality but the fastest.
  29625. *
  29626. * Execute PCF on a 1*1 kernel.
  29627. *
  29628. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  29629. */
  29630. static readonly QUALITY_LOW: number;
  29631. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  29632. id: string;
  29633. /** Gets or sets the custom shader name to use */
  29634. customShaderOptions: ICustomShaderOptions;
  29635. /** Gets or sets a custom function to allow/disallow rendering a sub mesh in the shadow map */
  29636. customAllowRendering: (subMesh: SubMesh) => boolean;
  29637. /**
  29638. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  29639. */
  29640. onBeforeShadowMapRenderObservable: Observable<Effect>;
  29641. /**
  29642. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  29643. */
  29644. onAfterShadowMapRenderObservable: Observable<Effect>;
  29645. /**
  29646. * Observable triggered before a mesh is rendered in the shadow map.
  29647. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  29648. */
  29649. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  29650. /**
  29651. * Observable triggered after a mesh is rendered in the shadow map.
  29652. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  29653. */
  29654. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  29655. protected _bias: number;
  29656. /**
  29657. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  29658. */
  29659. get bias(): number;
  29660. /**
  29661. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  29662. */
  29663. set bias(bias: number);
  29664. protected _normalBias: number;
  29665. /**
  29666. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  29667. */
  29668. get normalBias(): number;
  29669. /**
  29670. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  29671. */
  29672. set normalBias(normalBias: number);
  29673. protected _blurBoxOffset: number;
  29674. /**
  29675. * Gets the blur box offset: offset applied during the blur pass.
  29676. * Only useful if useKernelBlur = false
  29677. */
  29678. get blurBoxOffset(): number;
  29679. /**
  29680. * Sets the blur box offset: offset applied during the blur pass.
  29681. * Only useful if useKernelBlur = false
  29682. */
  29683. set blurBoxOffset(value: number);
  29684. protected _blurScale: number;
  29685. /**
  29686. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  29687. * 2 means half of the size.
  29688. */
  29689. get blurScale(): number;
  29690. /**
  29691. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  29692. * 2 means half of the size.
  29693. */
  29694. set blurScale(value: number);
  29695. protected _blurKernel: number;
  29696. /**
  29697. * Gets the blur kernel: kernel size of the blur pass.
  29698. * Only useful if useKernelBlur = true
  29699. */
  29700. get blurKernel(): number;
  29701. /**
  29702. * Sets the blur kernel: kernel size of the blur pass.
  29703. * Only useful if useKernelBlur = true
  29704. */
  29705. set blurKernel(value: number);
  29706. protected _useKernelBlur: boolean;
  29707. /**
  29708. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  29709. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  29710. */
  29711. get useKernelBlur(): boolean;
  29712. /**
  29713. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  29714. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  29715. */
  29716. set useKernelBlur(value: boolean);
  29717. protected _depthScale: number;
  29718. /**
  29719. * Gets the depth scale used in ESM mode.
  29720. */
  29721. get depthScale(): number;
  29722. /**
  29723. * Sets the depth scale used in ESM mode.
  29724. * This can override the scale stored on the light.
  29725. */
  29726. set depthScale(value: number);
  29727. protected _validateFilter(filter: number): number;
  29728. protected _filter: number;
  29729. /**
  29730. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  29731. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  29732. */
  29733. get filter(): number;
  29734. /**
  29735. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  29736. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  29737. */
  29738. set filter(value: number);
  29739. /**
  29740. * Gets if the current filter is set to Poisson Sampling.
  29741. */
  29742. get usePoissonSampling(): boolean;
  29743. /**
  29744. * Sets the current filter to Poisson Sampling.
  29745. */
  29746. set usePoissonSampling(value: boolean);
  29747. /**
  29748. * Gets if the current filter is set to ESM.
  29749. */
  29750. get useExponentialShadowMap(): boolean;
  29751. /**
  29752. * Sets the current filter is to ESM.
  29753. */
  29754. set useExponentialShadowMap(value: boolean);
  29755. /**
  29756. * Gets if the current filter is set to filtered ESM.
  29757. */
  29758. get useBlurExponentialShadowMap(): boolean;
  29759. /**
  29760. * Gets if the current filter is set to filtered ESM.
  29761. */
  29762. set useBlurExponentialShadowMap(value: boolean);
  29763. /**
  29764. * Gets if the current filter is set to "close ESM" (using the inverse of the
  29765. * exponential to prevent steep falloff artifacts).
  29766. */
  29767. get useCloseExponentialShadowMap(): boolean;
  29768. /**
  29769. * Sets the current filter to "close ESM" (using the inverse of the
  29770. * exponential to prevent steep falloff artifacts).
  29771. */
  29772. set useCloseExponentialShadowMap(value: boolean);
  29773. /**
  29774. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  29775. * exponential to prevent steep falloff artifacts).
  29776. */
  29777. get useBlurCloseExponentialShadowMap(): boolean;
  29778. /**
  29779. * Sets the current filter to filtered "close ESM" (using the inverse of the
  29780. * exponential to prevent steep falloff artifacts).
  29781. */
  29782. set useBlurCloseExponentialShadowMap(value: boolean);
  29783. /**
  29784. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  29785. */
  29786. get usePercentageCloserFiltering(): boolean;
  29787. /**
  29788. * Sets the current filter to "PCF" (percentage closer filtering).
  29789. */
  29790. set usePercentageCloserFiltering(value: boolean);
  29791. protected _filteringQuality: number;
  29792. /**
  29793. * Gets the PCF or PCSS Quality.
  29794. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  29795. */
  29796. get filteringQuality(): number;
  29797. /**
  29798. * Sets the PCF or PCSS Quality.
  29799. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  29800. */
  29801. set filteringQuality(filteringQuality: number);
  29802. /**
  29803. * Gets if the current filter is set to "PCSS" (contact hardening).
  29804. */
  29805. get useContactHardeningShadow(): boolean;
  29806. /**
  29807. * Sets the current filter to "PCSS" (contact hardening).
  29808. */
  29809. set useContactHardeningShadow(value: boolean);
  29810. protected _contactHardeningLightSizeUVRatio: number;
  29811. /**
  29812. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  29813. * Using a ratio helps keeping shape stability independently of the map size.
  29814. *
  29815. * It does not account for the light projection as it was having too much
  29816. * instability during the light setup or during light position changes.
  29817. *
  29818. * Only valid if useContactHardeningShadow is true.
  29819. */
  29820. get contactHardeningLightSizeUVRatio(): number;
  29821. /**
  29822. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  29823. * Using a ratio helps keeping shape stability independently of the map size.
  29824. *
  29825. * It does not account for the light projection as it was having too much
  29826. * instability during the light setup or during light position changes.
  29827. *
  29828. * Only valid if useContactHardeningShadow is true.
  29829. */
  29830. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  29831. protected _darkness: number;
  29832. /** Gets or sets the actual darkness of a shadow */
  29833. get darkness(): number;
  29834. set darkness(value: number);
  29835. /**
  29836. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  29837. * 0 means strongest and 1 would means no shadow.
  29838. * @returns the darkness.
  29839. */
  29840. getDarkness(): number;
  29841. /**
  29842. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  29843. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  29844. * @returns the shadow generator allowing fluent coding.
  29845. */
  29846. setDarkness(darkness: number): ShadowGenerator;
  29847. protected _transparencyShadow: boolean;
  29848. /** Gets or sets the ability to have transparent shadow */
  29849. get transparencyShadow(): boolean;
  29850. set transparencyShadow(value: boolean);
  29851. /**
  29852. * Sets the ability to have transparent shadow (boolean).
  29853. * @param transparent True if transparent else False
  29854. * @returns the shadow generator allowing fluent coding
  29855. */
  29856. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  29857. /**
  29858. * Enables or disables shadows with varying strength based on the transparency
  29859. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  29860. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  29861. * mesh.visibility * alphaTexture.a
  29862. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  29863. */
  29864. enableSoftTransparentShadow: boolean;
  29865. protected _shadowMap: Nullable<RenderTargetTexture>;
  29866. protected _shadowMap2: Nullable<RenderTargetTexture>;
  29867. /**
  29868. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  29869. * @returns The render target texture if present otherwise, null
  29870. */
  29871. getShadowMap(): Nullable<RenderTargetTexture>;
  29872. /**
  29873. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  29874. * @returns The render target texture if the shadow map is present otherwise, null
  29875. */
  29876. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  29877. /**
  29878. * Gets the class name of that object
  29879. * @returns "ShadowGenerator"
  29880. */
  29881. getClassName(): string;
  29882. /**
  29883. * Helper function to add a mesh and its descendants to the list of shadow casters.
  29884. * @param mesh Mesh to add
  29885. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  29886. * @returns the Shadow Generator itself
  29887. */
  29888. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  29889. /**
  29890. * Helper function to remove a mesh and its descendants from the list of shadow casters
  29891. * @param mesh Mesh to remove
  29892. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  29893. * @returns the Shadow Generator itself
  29894. */
  29895. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  29896. /**
  29897. * Controls the extent to which the shadows fade out at the edge of the frustum
  29898. */
  29899. frustumEdgeFalloff: number;
  29900. protected _light: IShadowLight;
  29901. /**
  29902. * Returns the associated light object.
  29903. * @returns the light generating the shadow
  29904. */
  29905. getLight(): IShadowLight;
  29906. /**
  29907. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  29908. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  29909. * It might on the other hand introduce peter panning.
  29910. */
  29911. forceBackFacesOnly: boolean;
  29912. protected _scene: Scene;
  29913. protected _lightDirection: Vector3;
  29914. protected _viewMatrix: Matrix;
  29915. protected _projectionMatrix: Matrix;
  29916. protected _transformMatrix: Matrix;
  29917. protected _cachedPosition: Vector3;
  29918. protected _cachedDirection: Vector3;
  29919. protected _cachedDefines: string;
  29920. protected _currentRenderID: number;
  29921. protected _boxBlurPostprocess: Nullable<PostProcess>;
  29922. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  29923. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  29924. protected _blurPostProcesses: PostProcess[];
  29925. protected _mapSize: number;
  29926. protected _currentFaceIndex: number;
  29927. protected _currentFaceIndexCache: number;
  29928. protected _textureType: number;
  29929. protected _defaultTextureMatrix: Matrix;
  29930. protected _storedUniqueId: Nullable<number>;
  29931. protected _nameForCustomEffect: string;
  29932. /** @hidden */
  29933. static _SceneComponentInitialization: (scene: Scene) => void;
  29934. /**
  29935. * Gets or sets the size of the texture what stores the shadows
  29936. */
  29937. get mapSize(): number;
  29938. set mapSize(size: number);
  29939. /**
  29940. * Creates a ShadowGenerator object.
  29941. * A ShadowGenerator is the required tool to use the shadows.
  29942. * Each light casting shadows needs to use its own ShadowGenerator.
  29943. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  29944. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  29945. * @param light The light object generating the shadows.
  29946. * @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.
  29947. */
  29948. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  29949. protected _initializeGenerator(): void;
  29950. protected _createTargetRenderTexture(): void;
  29951. protected _initializeShadowMap(): void;
  29952. protected _initializeBlurRTTAndPostProcesses(): void;
  29953. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  29954. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  29955. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  29956. protected _applyFilterValues(): void;
  29957. /**
  29958. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  29959. * @param onCompiled Callback triggered at the and of the effects compilation
  29960. * @param options Sets of optional options forcing the compilation with different modes
  29961. */
  29962. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  29963. useInstances: boolean;
  29964. }>): void;
  29965. /**
  29966. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  29967. * @param options Sets of optional options forcing the compilation with different modes
  29968. * @returns A promise that resolves when the compilation completes
  29969. */
  29970. forceCompilationAsync(options?: Partial<{
  29971. useInstances: boolean;
  29972. }>): Promise<void>;
  29973. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  29974. private _prepareShadowDefines;
  29975. /**
  29976. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  29977. * @param subMesh The submesh we want to render in the shadow map
  29978. * @param useInstances Defines wether will draw in the map using instances
  29979. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  29980. * @returns true if ready otherwise, false
  29981. */
  29982. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  29983. /**
  29984. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  29985. * @param defines Defines of the material we want to update
  29986. * @param lightIndex Index of the light in the enabled light list of the material
  29987. */
  29988. prepareDefines(defines: any, lightIndex: number): void;
  29989. /**
  29990. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  29991. * defined in the generator but impacting the effect).
  29992. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  29993. * @param effect The effect we are binfing the information for
  29994. */
  29995. bindShadowLight(lightIndex: string, effect: Effect): void;
  29996. /**
  29997. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  29998. * (eq to shadow prjection matrix * light transform matrix)
  29999. * @returns The transform matrix used to create the shadow map
  30000. */
  30001. getTransformMatrix(): Matrix;
  30002. /**
  30003. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  30004. * Cube and 2D textures for instance.
  30005. */
  30006. recreateShadowMap(): void;
  30007. protected _disposeBlurPostProcesses(): void;
  30008. protected _disposeRTTandPostProcesses(): void;
  30009. /**
  30010. * Disposes the ShadowGenerator.
  30011. * Returns nothing.
  30012. */
  30013. dispose(): void;
  30014. /**
  30015. * Serializes the shadow generator setup to a json object.
  30016. * @returns The serialized JSON object
  30017. */
  30018. serialize(): any;
  30019. /**
  30020. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  30021. * @param parsedShadowGenerator The JSON object to parse
  30022. * @param scene The scene to create the shadow map for
  30023. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  30024. * @returns The parsed shadow generator
  30025. */
  30026. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  30027. }
  30028. }
  30029. declare module BABYLON {
  30030. /**
  30031. * Options to be used when creating a shadow depth material
  30032. */
  30033. export interface IIOptionShadowDepthMaterial {
  30034. /** Variables in the vertex shader code that need to have their names remapped.
  30035. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  30036. * "var_name" should be either: worldPos or vNormalW
  30037. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  30038. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  30039. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  30040. */
  30041. remappedVariables?: string[];
  30042. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  30043. standalone?: boolean;
  30044. }
  30045. /**
  30046. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  30047. */
  30048. export class ShadowDepthWrapper {
  30049. private _scene;
  30050. private _options?;
  30051. private _baseMaterial;
  30052. private _onEffectCreatedObserver;
  30053. private _subMeshToEffect;
  30054. private _subMeshToDepthEffect;
  30055. private _meshes;
  30056. /** @hidden */
  30057. _matriceNames: any;
  30058. /** Gets the standalone status of the wrapper */
  30059. get standalone(): boolean;
  30060. /** Gets the base material the wrapper is built upon */
  30061. get baseMaterial(): Material;
  30062. /**
  30063. * Instantiate a new shadow depth wrapper.
  30064. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  30065. * generate the shadow depth map. For more information, please refer to the documentation:
  30066. * https://doc.babylonjs.com/babylon101/shadows
  30067. * @param baseMaterial Material to wrap
  30068. * @param scene Define the scene the material belongs to
  30069. * @param options Options used to create the wrapper
  30070. */
  30071. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  30072. /**
  30073. * Gets the effect to use to generate the depth map
  30074. * @param subMesh subMesh to get the effect for
  30075. * @param shadowGenerator shadow generator to get the effect for
  30076. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  30077. */
  30078. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  30079. /**
  30080. * Specifies that the submesh is ready to be used for depth rendering
  30081. * @param subMesh submesh to check
  30082. * @param defines the list of defines to take into account when checking the effect
  30083. * @param shadowGenerator combined with subMesh, it defines the effect to check
  30084. * @param useInstances specifies that instances should be used
  30085. * @returns a boolean indicating that the submesh is ready or not
  30086. */
  30087. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  30088. /**
  30089. * Disposes the resources
  30090. */
  30091. dispose(): void;
  30092. private _makeEffect;
  30093. }
  30094. }
  30095. declare module BABYLON {
  30096. /**
  30097. * Options for compiling materials.
  30098. */
  30099. export interface IMaterialCompilationOptions {
  30100. /**
  30101. * Defines whether clip planes are enabled.
  30102. */
  30103. clipPlane: boolean;
  30104. /**
  30105. * Defines whether instances are enabled.
  30106. */
  30107. useInstances: boolean;
  30108. }
  30109. /**
  30110. * Options passed when calling customShaderNameResolve
  30111. */
  30112. export interface ICustomShaderNameResolveOptions {
  30113. /**
  30114. * 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
  30115. */
  30116. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  30117. }
  30118. /**
  30119. * Base class for the main features of a material in Babylon.js
  30120. */
  30121. export class Material implements IAnimatable {
  30122. /**
  30123. * Returns the triangle fill mode
  30124. */
  30125. static readonly TriangleFillMode: number;
  30126. /**
  30127. * Returns the wireframe mode
  30128. */
  30129. static readonly WireFrameFillMode: number;
  30130. /**
  30131. * Returns the point fill mode
  30132. */
  30133. static readonly PointFillMode: number;
  30134. /**
  30135. * Returns the point list draw mode
  30136. */
  30137. static readonly PointListDrawMode: number;
  30138. /**
  30139. * Returns the line list draw mode
  30140. */
  30141. static readonly LineListDrawMode: number;
  30142. /**
  30143. * Returns the line loop draw mode
  30144. */
  30145. static readonly LineLoopDrawMode: number;
  30146. /**
  30147. * Returns the line strip draw mode
  30148. */
  30149. static readonly LineStripDrawMode: number;
  30150. /**
  30151. * Returns the triangle strip draw mode
  30152. */
  30153. static readonly TriangleStripDrawMode: number;
  30154. /**
  30155. * Returns the triangle fan draw mode
  30156. */
  30157. static readonly TriangleFanDrawMode: number;
  30158. /**
  30159. * Stores the clock-wise side orientation
  30160. */
  30161. static readonly ClockWiseSideOrientation: number;
  30162. /**
  30163. * Stores the counter clock-wise side orientation
  30164. */
  30165. static readonly CounterClockWiseSideOrientation: number;
  30166. /**
  30167. * The dirty texture flag value
  30168. */
  30169. static readonly TextureDirtyFlag: number;
  30170. /**
  30171. * The dirty light flag value
  30172. */
  30173. static readonly LightDirtyFlag: number;
  30174. /**
  30175. * The dirty fresnel flag value
  30176. */
  30177. static readonly FresnelDirtyFlag: number;
  30178. /**
  30179. * The dirty attribute flag value
  30180. */
  30181. static readonly AttributesDirtyFlag: number;
  30182. /**
  30183. * The dirty misc flag value
  30184. */
  30185. static readonly MiscDirtyFlag: number;
  30186. /**
  30187. * The dirty prepass flag value
  30188. */
  30189. static readonly PrePassDirtyFlag: number;
  30190. /**
  30191. * The all dirty flag value
  30192. */
  30193. static readonly AllDirtyFlag: number;
  30194. /**
  30195. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  30196. */
  30197. static readonly MATERIAL_OPAQUE: number;
  30198. /**
  30199. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  30200. */
  30201. static readonly MATERIAL_ALPHATEST: number;
  30202. /**
  30203. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  30204. */
  30205. static readonly MATERIAL_ALPHABLEND: number;
  30206. /**
  30207. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  30208. * They are also discarded below the alpha cutoff threshold to improve performances.
  30209. */
  30210. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  30211. /**
  30212. * The Whiteout method is used to blend normals.
  30213. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  30214. */
  30215. static readonly MATERIAL_NORMALBLENDMETHOD_WHITEOUT: number;
  30216. /**
  30217. * The Reoriented Normal Mapping method is used to blend normals.
  30218. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  30219. */
  30220. static readonly MATERIAL_NORMALBLENDMETHOD_RNM: number;
  30221. /**
  30222. * Custom callback helping to override the default shader used in the material.
  30223. */
  30224. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  30225. /**
  30226. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  30227. */
  30228. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  30229. /**
  30230. * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
  30231. * This means that the material can keep using a previous shader while a new one is being compiled.
  30232. * This is mostly used when shader parallel compilation is supported (true by default)
  30233. */
  30234. allowShaderHotSwapping: boolean;
  30235. /**
  30236. * The ID of the material
  30237. */
  30238. id: string;
  30239. /**
  30240. * Gets or sets the unique id of the material
  30241. */
  30242. uniqueId: number;
  30243. /**
  30244. * The name of the material
  30245. */
  30246. name: string;
  30247. /**
  30248. * Gets or sets user defined metadata
  30249. */
  30250. metadata: any;
  30251. /**
  30252. * For internal use only. Please do not use.
  30253. */
  30254. reservedDataStore: any;
  30255. /**
  30256. * Specifies if the ready state should be checked on each call
  30257. */
  30258. checkReadyOnEveryCall: boolean;
  30259. /**
  30260. * Specifies if the ready state should be checked once
  30261. */
  30262. checkReadyOnlyOnce: boolean;
  30263. /**
  30264. * The state of the material
  30265. */
  30266. state: string;
  30267. /**
  30268. * If the material can be rendered to several textures with MRT extension
  30269. */
  30270. get canRenderToMRT(): boolean;
  30271. /**
  30272. * The alpha value of the material
  30273. */
  30274. protected _alpha: number;
  30275. /**
  30276. * List of inspectable custom properties (used by the Inspector)
  30277. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  30278. */
  30279. inspectableCustomProperties: IInspectable[];
  30280. /**
  30281. * Sets the alpha value of the material
  30282. */
  30283. set alpha(value: number);
  30284. /**
  30285. * Gets the alpha value of the material
  30286. */
  30287. get alpha(): number;
  30288. /**
  30289. * Specifies if back face culling is enabled
  30290. */
  30291. protected _backFaceCulling: boolean;
  30292. /**
  30293. * Sets the back-face culling state
  30294. */
  30295. set backFaceCulling(value: boolean);
  30296. /**
  30297. * Gets the back-face culling state
  30298. */
  30299. get backFaceCulling(): boolean;
  30300. /**
  30301. * Stores the value for side orientation
  30302. */
  30303. sideOrientation: number;
  30304. /**
  30305. * Callback triggered when the material is compiled
  30306. */
  30307. onCompiled: Nullable<(effect: Effect) => void>;
  30308. /**
  30309. * Callback triggered when an error occurs
  30310. */
  30311. onError: Nullable<(effect: Effect, errors: string) => void>;
  30312. /**
  30313. * Callback triggered to get the render target textures
  30314. */
  30315. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  30316. /**
  30317. * Gets a boolean indicating that current material needs to register RTT
  30318. */
  30319. get hasRenderTargetTextures(): boolean;
  30320. /**
  30321. * Specifies if the material should be serialized
  30322. */
  30323. doNotSerialize: boolean;
  30324. /**
  30325. * @hidden
  30326. */
  30327. _storeEffectOnSubMeshes: boolean;
  30328. /**
  30329. * Stores the animations for the material
  30330. */
  30331. animations: Nullable<Array<Animation>>;
  30332. /**
  30333. * An event triggered when the material is disposed
  30334. */
  30335. onDisposeObservable: Observable<Material>;
  30336. /**
  30337. * An observer which watches for dispose events
  30338. */
  30339. private _onDisposeObserver;
  30340. private _onUnBindObservable;
  30341. /**
  30342. * Called during a dispose event
  30343. */
  30344. set onDispose(callback: () => void);
  30345. private _onBindObservable;
  30346. /**
  30347. * An event triggered when the material is bound
  30348. */
  30349. get onBindObservable(): Observable<AbstractMesh>;
  30350. /**
  30351. * An observer which watches for bind events
  30352. */
  30353. private _onBindObserver;
  30354. /**
  30355. * Called during a bind event
  30356. */
  30357. set onBind(callback: (Mesh: AbstractMesh) => void);
  30358. /**
  30359. * An event triggered when the material is unbound
  30360. */
  30361. get onUnBindObservable(): Observable<Material>;
  30362. protected _onEffectCreatedObservable: Nullable<Observable<{
  30363. effect: Effect;
  30364. subMesh: Nullable<SubMesh>;
  30365. }>>;
  30366. /**
  30367. * An event triggered when the effect is (re)created
  30368. */
  30369. get onEffectCreatedObservable(): Observable<{
  30370. effect: Effect;
  30371. subMesh: Nullable<SubMesh>;
  30372. }>;
  30373. /**
  30374. * Stores the value of the alpha mode
  30375. */
  30376. private _alphaMode;
  30377. /**
  30378. * Sets the value of the alpha mode.
  30379. *
  30380. * | Value | Type | Description |
  30381. * | --- | --- | --- |
  30382. * | 0 | ALPHA_DISABLE | |
  30383. * | 1 | ALPHA_ADD | |
  30384. * | 2 | ALPHA_COMBINE | |
  30385. * | 3 | ALPHA_SUBTRACT | |
  30386. * | 4 | ALPHA_MULTIPLY | |
  30387. * | 5 | ALPHA_MAXIMIZED | |
  30388. * | 6 | ALPHA_ONEONE | |
  30389. * | 7 | ALPHA_PREMULTIPLIED | |
  30390. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  30391. * | 9 | ALPHA_INTERPOLATE | |
  30392. * | 10 | ALPHA_SCREENMODE | |
  30393. *
  30394. */
  30395. set alphaMode(value: number);
  30396. /**
  30397. * Gets the value of the alpha mode
  30398. */
  30399. get alphaMode(): number;
  30400. /**
  30401. * Stores the state of the need depth pre-pass value
  30402. */
  30403. private _needDepthPrePass;
  30404. /**
  30405. * Sets the need depth pre-pass value
  30406. */
  30407. set needDepthPrePass(value: boolean);
  30408. /**
  30409. * Gets the depth pre-pass value
  30410. */
  30411. get needDepthPrePass(): boolean;
  30412. /**
  30413. * Specifies if depth writing should be disabled
  30414. */
  30415. disableDepthWrite: boolean;
  30416. /**
  30417. * Specifies if color writing should be disabled
  30418. */
  30419. disableColorWrite: boolean;
  30420. /**
  30421. * Specifies if depth writing should be forced
  30422. */
  30423. forceDepthWrite: boolean;
  30424. /**
  30425. * Specifies the depth function that should be used. 0 means the default engine function
  30426. */
  30427. depthFunction: number;
  30428. /**
  30429. * Specifies if there should be a separate pass for culling
  30430. */
  30431. separateCullingPass: boolean;
  30432. /**
  30433. * Stores the state specifing if fog should be enabled
  30434. */
  30435. private _fogEnabled;
  30436. /**
  30437. * Sets the state for enabling fog
  30438. */
  30439. set fogEnabled(value: boolean);
  30440. /**
  30441. * Gets the value of the fog enabled state
  30442. */
  30443. get fogEnabled(): boolean;
  30444. /**
  30445. * Stores the size of points
  30446. */
  30447. pointSize: number;
  30448. /**
  30449. * Stores the z offset value
  30450. */
  30451. zOffset: number;
  30452. get wireframe(): boolean;
  30453. /**
  30454. * Sets the state of wireframe mode
  30455. */
  30456. set wireframe(value: boolean);
  30457. /**
  30458. * Gets the value specifying if point clouds are enabled
  30459. */
  30460. get pointsCloud(): boolean;
  30461. /**
  30462. * Sets the state of point cloud mode
  30463. */
  30464. set pointsCloud(value: boolean);
  30465. /**
  30466. * Gets the material fill mode
  30467. */
  30468. get fillMode(): number;
  30469. /**
  30470. * Sets the material fill mode
  30471. */
  30472. set fillMode(value: number);
  30473. /**
  30474. * @hidden
  30475. * Stores the effects for the material
  30476. */
  30477. _effect: Nullable<Effect>;
  30478. /**
  30479. * Specifies if uniform buffers should be used
  30480. */
  30481. private _useUBO;
  30482. /**
  30483. * Stores a reference to the scene
  30484. */
  30485. private _scene;
  30486. private _needToBindSceneUbo;
  30487. /**
  30488. * Stores the fill mode state
  30489. */
  30490. private _fillMode;
  30491. /**
  30492. * Specifies if the depth write state should be cached
  30493. */
  30494. private _cachedDepthWriteState;
  30495. /**
  30496. * Specifies if the color write state should be cached
  30497. */
  30498. private _cachedColorWriteState;
  30499. /**
  30500. * Specifies if the depth function state should be cached
  30501. */
  30502. private _cachedDepthFunctionState;
  30503. /**
  30504. * Stores the uniform buffer
  30505. */
  30506. protected _uniformBuffer: UniformBuffer;
  30507. /** @hidden */
  30508. _indexInSceneMaterialArray: number;
  30509. /** @hidden */
  30510. meshMap: Nullable<{
  30511. [id: string]: AbstractMesh | undefined;
  30512. }>;
  30513. /**
  30514. * Creates a material instance
  30515. * @param name defines the name of the material
  30516. * @param scene defines the scene to reference
  30517. * @param doNotAdd specifies if the material should be added to the scene
  30518. */
  30519. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  30520. /**
  30521. * Returns a string representation of the current material
  30522. * @param fullDetails defines a boolean indicating which levels of logging is desired
  30523. * @returns a string with material information
  30524. */
  30525. toString(fullDetails?: boolean): string;
  30526. /**
  30527. * Gets the class name of the material
  30528. * @returns a string with the class name of the material
  30529. */
  30530. getClassName(): string;
  30531. /**
  30532. * Specifies if updates for the material been locked
  30533. */
  30534. get isFrozen(): boolean;
  30535. /**
  30536. * Locks updates for the material
  30537. */
  30538. freeze(): void;
  30539. /**
  30540. * Unlocks updates for the material
  30541. */
  30542. unfreeze(): void;
  30543. /**
  30544. * Specifies if the material is ready to be used
  30545. * @param mesh defines the mesh to check
  30546. * @param useInstances specifies if instances should be used
  30547. * @returns a boolean indicating if the material is ready to be used
  30548. */
  30549. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  30550. /**
  30551. * Specifies that the submesh is ready to be used
  30552. * @param mesh defines the mesh to check
  30553. * @param subMesh defines which submesh to check
  30554. * @param useInstances specifies that instances should be used
  30555. * @returns a boolean indicating that the submesh is ready or not
  30556. */
  30557. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  30558. /**
  30559. * Returns the material effect
  30560. * @returns the effect associated with the material
  30561. */
  30562. getEffect(): Nullable<Effect>;
  30563. /**
  30564. * Returns the current scene
  30565. * @returns a Scene
  30566. */
  30567. getScene(): Scene;
  30568. /**
  30569. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  30570. */
  30571. protected _forceAlphaTest: boolean;
  30572. /**
  30573. * The transparency mode of the material.
  30574. */
  30575. protected _transparencyMode: Nullable<number>;
  30576. /**
  30577. * Gets the current transparency mode.
  30578. */
  30579. get transparencyMode(): Nullable<number>;
  30580. /**
  30581. * Sets the transparency mode of the material.
  30582. *
  30583. * | Value | Type | Description |
  30584. * | ----- | ----------------------------------- | ----------- |
  30585. * | 0 | OPAQUE | |
  30586. * | 1 | ALPHATEST | |
  30587. * | 2 | ALPHABLEND | |
  30588. * | 3 | ALPHATESTANDBLEND | |
  30589. *
  30590. */
  30591. set transparencyMode(value: Nullable<number>);
  30592. /**
  30593. * Returns true if alpha blending should be disabled.
  30594. */
  30595. protected get _disableAlphaBlending(): boolean;
  30596. /**
  30597. * Specifies whether or not this material should be rendered in alpha blend mode.
  30598. * @returns a boolean specifying if alpha blending is needed
  30599. */
  30600. needAlphaBlending(): boolean;
  30601. /**
  30602. * Specifies if the mesh will require alpha blending
  30603. * @param mesh defines the mesh to check
  30604. * @returns a boolean specifying if alpha blending is needed for the mesh
  30605. */
  30606. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  30607. /**
  30608. * Specifies whether or not this material should be rendered in alpha test mode.
  30609. * @returns a boolean specifying if an alpha test is needed.
  30610. */
  30611. needAlphaTesting(): boolean;
  30612. /**
  30613. * Specifies if material alpha testing should be turned on for the mesh
  30614. * @param mesh defines the mesh to check
  30615. */
  30616. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  30617. /**
  30618. * Gets the texture used for the alpha test
  30619. * @returns the texture to use for alpha testing
  30620. */
  30621. getAlphaTestTexture(): Nullable<BaseTexture>;
  30622. /**
  30623. * Marks the material to indicate that it needs to be re-calculated
  30624. */
  30625. markDirty(): void;
  30626. /** @hidden */
  30627. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  30628. /**
  30629. * Binds the material to the mesh
  30630. * @param world defines the world transformation matrix
  30631. * @param mesh defines the mesh to bind the material to
  30632. */
  30633. bind(world: Matrix, mesh?: Mesh): void;
  30634. /**
  30635. * Binds the submesh to the material
  30636. * @param world defines the world transformation matrix
  30637. * @param mesh defines the mesh containing the submesh
  30638. * @param subMesh defines the submesh to bind the material to
  30639. */
  30640. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  30641. /**
  30642. * Binds the world matrix to the material
  30643. * @param world defines the world transformation matrix
  30644. */
  30645. bindOnlyWorldMatrix(world: Matrix): void;
  30646. /**
  30647. * Update the scene ubo before it can be used in rendering processing
  30648. * @param scene the scene to retrieve the ubo from
  30649. * @returns the scene UniformBuffer
  30650. */
  30651. finalizeSceneUbo(scene: Scene): UniformBuffer;
  30652. /**
  30653. * Binds the scene's uniform buffer to the effect.
  30654. * @param effect defines the effect to bind to the scene uniform buffer
  30655. * @param sceneUbo defines the uniform buffer storing scene data
  30656. */
  30657. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  30658. /**
  30659. * Binds the view matrix to the effect
  30660. * @param effect defines the effect to bind the view matrix to
  30661. */
  30662. bindView(effect: Effect): void;
  30663. /**
  30664. * Binds the view projection and projection matrices to the effect
  30665. * @param effect defines the effect to bind the view projection and projection matrices to
  30666. */
  30667. bindViewProjection(effect: Effect): void;
  30668. /**
  30669. * Binds the view matrix to the effect
  30670. * @param effect defines the effect to bind the view matrix to
  30671. * @param variableName name of the shader variable that will hold the eye position
  30672. */
  30673. bindEyePosition(effect: Effect, variableName?: string): void;
  30674. /**
  30675. * Processes to execute after binding the material to a mesh
  30676. * @param mesh defines the rendered mesh
  30677. */
  30678. protected _afterBind(mesh?: Mesh, effect?: Nullable<Effect>): void;
  30679. /**
  30680. * Unbinds the material from the mesh
  30681. */
  30682. unbind(): void;
  30683. /**
  30684. * Gets the active textures from the material
  30685. * @returns an array of textures
  30686. */
  30687. getActiveTextures(): BaseTexture[];
  30688. /**
  30689. * Specifies if the material uses a texture
  30690. * @param texture defines the texture to check against the material
  30691. * @returns a boolean specifying if the material uses the texture
  30692. */
  30693. hasTexture(texture: BaseTexture): boolean;
  30694. /**
  30695. * Makes a duplicate of the material, and gives it a new name
  30696. * @param name defines the new name for the duplicated material
  30697. * @returns the cloned material
  30698. */
  30699. clone(name: string): Nullable<Material>;
  30700. /**
  30701. * Gets the meshes bound to the material
  30702. * @returns an array of meshes bound to the material
  30703. */
  30704. getBindedMeshes(): AbstractMesh[];
  30705. /**
  30706. * Force shader compilation
  30707. * @param mesh defines the mesh associated with this material
  30708. * @param onCompiled defines a function to execute once the material is compiled
  30709. * @param options defines the options to configure the compilation
  30710. * @param onError defines a function to execute if the material fails compiling
  30711. */
  30712. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  30713. /**
  30714. * Force shader compilation
  30715. * @param mesh defines the mesh that will use this material
  30716. * @param options defines additional options for compiling the shaders
  30717. * @returns a promise that resolves when the compilation completes
  30718. */
  30719. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  30720. private static readonly _AllDirtyCallBack;
  30721. private static readonly _ImageProcessingDirtyCallBack;
  30722. private static readonly _TextureDirtyCallBack;
  30723. private static readonly _FresnelDirtyCallBack;
  30724. private static readonly _MiscDirtyCallBack;
  30725. private static readonly _PrePassDirtyCallBack;
  30726. private static readonly _LightsDirtyCallBack;
  30727. private static readonly _AttributeDirtyCallBack;
  30728. private static _FresnelAndMiscDirtyCallBack;
  30729. private static _TextureAndMiscDirtyCallBack;
  30730. private static readonly _DirtyCallbackArray;
  30731. private static readonly _RunDirtyCallBacks;
  30732. /**
  30733. * Marks a define in the material to indicate that it needs to be re-computed
  30734. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  30735. */
  30736. markAsDirty(flag: number): void;
  30737. /**
  30738. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  30739. * @param func defines a function which checks material defines against the submeshes
  30740. */
  30741. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  30742. /**
  30743. * Indicates that the scene should check if the rendering now needs a prepass
  30744. */
  30745. protected _markScenePrePassDirty(): void;
  30746. /**
  30747. * Indicates that we need to re-calculated for all submeshes
  30748. */
  30749. protected _markAllSubMeshesAsAllDirty(): void;
  30750. /**
  30751. * Indicates that image processing needs to be re-calculated for all submeshes
  30752. */
  30753. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  30754. /**
  30755. * Indicates that textures need to be re-calculated for all submeshes
  30756. */
  30757. protected _markAllSubMeshesAsTexturesDirty(): void;
  30758. /**
  30759. * Indicates that fresnel needs to be re-calculated for all submeshes
  30760. */
  30761. protected _markAllSubMeshesAsFresnelDirty(): void;
  30762. /**
  30763. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  30764. */
  30765. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  30766. /**
  30767. * Indicates that lights need to be re-calculated for all submeshes
  30768. */
  30769. protected _markAllSubMeshesAsLightsDirty(): void;
  30770. /**
  30771. * Indicates that attributes need to be re-calculated for all submeshes
  30772. */
  30773. protected _markAllSubMeshesAsAttributesDirty(): void;
  30774. /**
  30775. * Indicates that misc needs to be re-calculated for all submeshes
  30776. */
  30777. protected _markAllSubMeshesAsMiscDirty(): void;
  30778. /**
  30779. * Indicates that prepass needs to be re-calculated for all submeshes
  30780. */
  30781. protected _markAllSubMeshesAsPrePassDirty(): void;
  30782. /**
  30783. * Indicates that textures and misc need to be re-calculated for all submeshes
  30784. */
  30785. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  30786. /**
  30787. * Sets the required values to the prepass renderer.
  30788. * @param prePassRenderer defines the prepass renderer to setup.
  30789. * @returns true if the pre pass is needed.
  30790. */
  30791. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  30792. /**
  30793. * Disposes the material
  30794. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  30795. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  30796. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  30797. */
  30798. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  30799. /** @hidden */
  30800. private releaseVertexArrayObject;
  30801. /**
  30802. * Serializes this material
  30803. * @returns the serialized material object
  30804. */
  30805. serialize(): any;
  30806. /**
  30807. * Creates a material from parsed material data
  30808. * @param parsedMaterial defines parsed material data
  30809. * @param scene defines the hosting scene
  30810. * @param rootUrl defines the root URL to use to load textures
  30811. * @returns a new material
  30812. */
  30813. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  30814. }
  30815. }
  30816. declare module BABYLON {
  30817. /**
  30818. * A multi-material is used to apply different materials to different parts of the same object without the need of
  30819. * separate meshes. This can be use to improve performances.
  30820. * @see https://doc.babylonjs.com/how_to/multi_materials
  30821. */
  30822. export class MultiMaterial extends Material {
  30823. private _subMaterials;
  30824. /**
  30825. * Gets or Sets the list of Materials used within the multi material.
  30826. * They need to be ordered according to the submeshes order in the associated mesh
  30827. */
  30828. get subMaterials(): Nullable<Material>[];
  30829. set subMaterials(value: Nullable<Material>[]);
  30830. /**
  30831. * Function used to align with Node.getChildren()
  30832. * @returns the list of Materials used within the multi material
  30833. */
  30834. getChildren(): Nullable<Material>[];
  30835. /**
  30836. * Instantiates a new Multi Material
  30837. * A multi-material is used to apply different materials to different parts of the same object without the need of
  30838. * separate meshes. This can be use to improve performances.
  30839. * @see https://doc.babylonjs.com/how_to/multi_materials
  30840. * @param name Define the name in the scene
  30841. * @param scene Define the scene the material belongs to
  30842. */
  30843. constructor(name: string, scene: Scene);
  30844. private _hookArray;
  30845. /**
  30846. * Get one of the submaterial by its index in the submaterials array
  30847. * @param index The index to look the sub material at
  30848. * @returns The Material if the index has been defined
  30849. */
  30850. getSubMaterial(index: number): Nullable<Material>;
  30851. /**
  30852. * Get the list of active textures for the whole sub materials list.
  30853. * @returns All the textures that will be used during the rendering
  30854. */
  30855. getActiveTextures(): BaseTexture[];
  30856. /**
  30857. * Specifies if any sub-materials of this multi-material use a given texture.
  30858. * @param texture Defines the texture to check against this multi-material's sub-materials.
  30859. * @returns A boolean specifying if any sub-material of this multi-material uses the texture.
  30860. */
  30861. hasTexture(texture: BaseTexture): boolean;
  30862. /**
  30863. * Gets the current class name of the material e.g. "MultiMaterial"
  30864. * Mainly use in serialization.
  30865. * @returns the class name
  30866. */
  30867. getClassName(): string;
  30868. /**
  30869. * Checks if the material is ready to render the requested sub mesh
  30870. * @param mesh Define the mesh the submesh belongs to
  30871. * @param subMesh Define the sub mesh to look readyness for
  30872. * @param useInstances Define whether or not the material is used with instances
  30873. * @returns true if ready, otherwise false
  30874. */
  30875. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  30876. /**
  30877. * Clones the current material and its related sub materials
  30878. * @param name Define the name of the newly cloned material
  30879. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  30880. * @returns the cloned material
  30881. */
  30882. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  30883. /**
  30884. * Serializes the materials into a JSON representation.
  30885. * @returns the JSON representation
  30886. */
  30887. serialize(): any;
  30888. /**
  30889. * Dispose the material and release its associated resources
  30890. * @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)
  30891. * @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)
  30892. * @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)
  30893. */
  30894. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  30895. /**
  30896. * Creates a MultiMaterial from parsed MultiMaterial data.
  30897. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  30898. * @param scene defines the hosting scene
  30899. * @returns a new MultiMaterial
  30900. */
  30901. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  30902. }
  30903. }
  30904. declare module BABYLON {
  30905. /** @hidden */
  30906. export interface ICustomEffect {
  30907. effect: Effect;
  30908. defines: string;
  30909. }
  30910. /**
  30911. * Defines a subdivision inside a mesh
  30912. */
  30913. export class SubMesh implements ICullable {
  30914. /** the material index to use */
  30915. materialIndex: number;
  30916. /** vertex index start */
  30917. verticesStart: number;
  30918. /** vertices count */
  30919. verticesCount: number;
  30920. /** index start */
  30921. indexStart: number;
  30922. /** indices count */
  30923. indexCount: number;
  30924. /** @hidden */
  30925. _materialDefines: Nullable<MaterialDefines>;
  30926. /** @hidden */
  30927. _materialEffect: Nullable<Effect>;
  30928. /** @hidden */
  30929. _effectOverride: Nullable<Effect>;
  30930. private _customEffects;
  30931. /**
  30932. * Gets material defines used by the effect associated to the sub mesh
  30933. */
  30934. get materialDefines(): Nullable<MaterialDefines>;
  30935. /**
  30936. * Sets material defines used by the effect associated to the sub mesh
  30937. */
  30938. set materialDefines(defines: Nullable<MaterialDefines>);
  30939. /** @hidden */
  30940. _getCustomEffect(name: string, createIfNotExisting?: boolean): Nullable<ICustomEffect>;
  30941. /** @hidden */
  30942. _removeCustomEffect(name: string): void;
  30943. /**
  30944. * Gets associated effect
  30945. */
  30946. get effect(): Nullable<Effect>;
  30947. /**
  30948. * Sets associated effect (effect used to render this submesh)
  30949. * @param effect defines the effect to associate with
  30950. * @param defines defines the set of defines used to compile this effect
  30951. */
  30952. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  30953. /** @hidden */
  30954. _linesIndexCount: number;
  30955. private _mesh;
  30956. private _renderingMesh;
  30957. private _boundingInfo;
  30958. private _linesIndexBuffer;
  30959. /** @hidden */
  30960. _lastColliderWorldVertices: Nullable<Vector3[]>;
  30961. /** @hidden */
  30962. _trianglePlanes: Plane[];
  30963. /** @hidden */
  30964. _lastColliderTransformMatrix: Nullable<Matrix>;
  30965. /** @hidden */
  30966. _renderId: number;
  30967. /** @hidden */
  30968. _alphaIndex: number;
  30969. /** @hidden */
  30970. _distanceToCamera: number;
  30971. /** @hidden */
  30972. _id: number;
  30973. private _currentMaterial;
  30974. /**
  30975. * Add a new submesh to a mesh
  30976. * @param materialIndex defines the material index to use
  30977. * @param verticesStart defines vertex index start
  30978. * @param verticesCount defines vertices count
  30979. * @param indexStart defines index start
  30980. * @param indexCount defines indices count
  30981. * @param mesh defines the parent mesh
  30982. * @param renderingMesh defines an optional rendering mesh
  30983. * @param createBoundingBox defines if bounding box should be created for this submesh
  30984. * @returns the new submesh
  30985. */
  30986. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  30987. /**
  30988. * Creates a new submesh
  30989. * @param materialIndex defines the material index to use
  30990. * @param verticesStart defines vertex index start
  30991. * @param verticesCount defines vertices count
  30992. * @param indexStart defines index start
  30993. * @param indexCount defines indices count
  30994. * @param mesh defines the parent mesh
  30995. * @param renderingMesh defines an optional rendering mesh
  30996. * @param createBoundingBox defines if bounding box should be created for this submesh
  30997. * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)
  30998. */
  30999. constructor(
  31000. /** the material index to use */
  31001. materialIndex: number,
  31002. /** vertex index start */
  31003. verticesStart: number,
  31004. /** vertices count */
  31005. verticesCount: number,
  31006. /** index start */
  31007. indexStart: number,
  31008. /** indices count */
  31009. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean, addToMesh?: boolean);
  31010. /**
  31011. * Returns true if this submesh covers the entire parent mesh
  31012. * @ignorenaming
  31013. */
  31014. get IsGlobal(): boolean;
  31015. /**
  31016. * Returns the submesh BoudingInfo object
  31017. * @returns current bounding info (or mesh's one if the submesh is global)
  31018. */
  31019. getBoundingInfo(): BoundingInfo;
  31020. /**
  31021. * Sets the submesh BoundingInfo
  31022. * @param boundingInfo defines the new bounding info to use
  31023. * @returns the SubMesh
  31024. */
  31025. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  31026. /**
  31027. * Returns the mesh of the current submesh
  31028. * @return the parent mesh
  31029. */
  31030. getMesh(): AbstractMesh;
  31031. /**
  31032. * Returns the rendering mesh of the submesh
  31033. * @returns the rendering mesh (could be different from parent mesh)
  31034. */
  31035. getRenderingMesh(): Mesh;
  31036. /**
  31037. * Returns the replacement mesh of the submesh
  31038. * @returns the replacement mesh (could be different from parent mesh)
  31039. */
  31040. getReplacementMesh(): Nullable<AbstractMesh>;
  31041. /**
  31042. * Returns the effective mesh of the submesh
  31043. * @returns the effective mesh (could be different from parent mesh)
  31044. */
  31045. getEffectiveMesh(): AbstractMesh;
  31046. /**
  31047. * Returns the submesh material
  31048. * @returns null or the current material
  31049. */
  31050. getMaterial(): Nullable<Material>;
  31051. private _IsMultiMaterial;
  31052. /**
  31053. * Sets a new updated BoundingInfo object to the submesh
  31054. * @param data defines an optional position array to use to determine the bounding info
  31055. * @returns the SubMesh
  31056. */
  31057. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  31058. /** @hidden */
  31059. _checkCollision(collider: Collider): boolean;
  31060. /**
  31061. * Updates the submesh BoundingInfo
  31062. * @param world defines the world matrix to use to update the bounding info
  31063. * @returns the submesh
  31064. */
  31065. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  31066. /**
  31067. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  31068. * @param frustumPlanes defines the frustum planes
  31069. * @returns true if the submesh is intersecting with the frustum
  31070. */
  31071. isInFrustum(frustumPlanes: Plane[]): boolean;
  31072. /**
  31073. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  31074. * @param frustumPlanes defines the frustum planes
  31075. * @returns true if the submesh is inside the frustum
  31076. */
  31077. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  31078. /**
  31079. * Renders the submesh
  31080. * @param enableAlphaMode defines if alpha needs to be used
  31081. * @returns the submesh
  31082. */
  31083. render(enableAlphaMode: boolean): SubMesh;
  31084. /**
  31085. * @hidden
  31086. */
  31087. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  31088. /**
  31089. * Checks if the submesh intersects with a ray
  31090. * @param ray defines the ray to test
  31091. * @returns true is the passed ray intersects the submesh bounding box
  31092. */
  31093. canIntersects(ray: Ray): boolean;
  31094. /**
  31095. * Intersects current submesh with a ray
  31096. * @param ray defines the ray to test
  31097. * @param positions defines mesh's positions array
  31098. * @param indices defines mesh's indices array
  31099. * @param fastCheck defines if the first intersection will be used (and not the closest)
  31100. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  31101. * @returns intersection info or null if no intersection
  31102. */
  31103. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  31104. /** @hidden */
  31105. private _intersectLines;
  31106. /** @hidden */
  31107. private _intersectUnIndexedLines;
  31108. /** @hidden */
  31109. private _intersectTriangles;
  31110. /** @hidden */
  31111. private _intersectUnIndexedTriangles;
  31112. /** @hidden */
  31113. _rebuild(): void;
  31114. /**
  31115. * Creates a new submesh from the passed mesh
  31116. * @param newMesh defines the new hosting mesh
  31117. * @param newRenderingMesh defines an optional rendering mesh
  31118. * @returns the new submesh
  31119. */
  31120. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  31121. /**
  31122. * Release associated resources
  31123. */
  31124. dispose(): void;
  31125. /**
  31126. * Gets the class name
  31127. * @returns the string "SubMesh".
  31128. */
  31129. getClassName(): string;
  31130. /**
  31131. * Creates a new submesh from indices data
  31132. * @param materialIndex the index of the main mesh material
  31133. * @param startIndex the index where to start the copy in the mesh indices array
  31134. * @param indexCount the number of indices to copy then from the startIndex
  31135. * @param mesh the main mesh to create the submesh from
  31136. * @param renderingMesh the optional rendering mesh
  31137. * @returns a new submesh
  31138. */
  31139. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  31140. }
  31141. }
  31142. declare module BABYLON {
  31143. /**
  31144. * Class used to represent data loading progression
  31145. */
  31146. export class SceneLoaderFlags {
  31147. private static _ForceFullSceneLoadingForIncremental;
  31148. private static _ShowLoadingScreen;
  31149. private static _CleanBoneMatrixWeights;
  31150. private static _loggingLevel;
  31151. /**
  31152. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  31153. */
  31154. static get ForceFullSceneLoadingForIncremental(): boolean;
  31155. static set ForceFullSceneLoadingForIncremental(value: boolean);
  31156. /**
  31157. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  31158. */
  31159. static get ShowLoadingScreen(): boolean;
  31160. static set ShowLoadingScreen(value: boolean);
  31161. /**
  31162. * Defines the current logging level (while loading the scene)
  31163. * @ignorenaming
  31164. */
  31165. static get loggingLevel(): number;
  31166. static set loggingLevel(value: number);
  31167. /**
  31168. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  31169. */
  31170. static get CleanBoneMatrixWeights(): boolean;
  31171. static set CleanBoneMatrixWeights(value: boolean);
  31172. }
  31173. }
  31174. declare module BABYLON {
  31175. /**
  31176. * Class used to store geometry data (vertex buffers + index buffer)
  31177. */
  31178. export class Geometry implements IGetSetVerticesData {
  31179. /**
  31180. * Gets or sets the ID of the geometry
  31181. */
  31182. id: string;
  31183. /**
  31184. * Gets or sets the unique ID of the geometry
  31185. */
  31186. uniqueId: number;
  31187. /**
  31188. * Gets the delay loading state of the geometry (none by default which means not delayed)
  31189. */
  31190. delayLoadState: number;
  31191. /**
  31192. * Gets the file containing the data to load when running in delay load state
  31193. */
  31194. delayLoadingFile: Nullable<string>;
  31195. /**
  31196. * Callback called when the geometry is updated
  31197. */
  31198. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  31199. private _scene;
  31200. private _engine;
  31201. private _meshes;
  31202. private _totalVertices;
  31203. /** @hidden */
  31204. _indices: IndicesArray;
  31205. /** @hidden */
  31206. _vertexBuffers: {
  31207. [key: string]: VertexBuffer;
  31208. };
  31209. private _isDisposed;
  31210. private _extend;
  31211. private _boundingBias;
  31212. /** @hidden */
  31213. _delayInfo: Array<string>;
  31214. private _indexBuffer;
  31215. private _indexBufferIsUpdatable;
  31216. /** @hidden */
  31217. _boundingInfo: Nullable<BoundingInfo>;
  31218. /** @hidden */
  31219. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  31220. /** @hidden */
  31221. _softwareSkinningFrameId: number;
  31222. private _vertexArrayObjects;
  31223. private _updatable;
  31224. /** @hidden */
  31225. _positions: Nullable<Vector3[]>;
  31226. private _positionsCache;
  31227. /**
  31228. * 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
  31229. */
  31230. get boundingBias(): Vector2;
  31231. /**
  31232. * 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
  31233. */
  31234. set boundingBias(value: Vector2);
  31235. /**
  31236. * Static function used to attach a new empty geometry to a mesh
  31237. * @param mesh defines the mesh to attach the geometry to
  31238. * @returns the new Geometry
  31239. */
  31240. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  31241. /** Get the list of meshes using this geometry */
  31242. get meshes(): Mesh[];
  31243. /**
  31244. * 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
  31245. * and won't be computed based on the vertex positions (which is what we get when useBoundingInfoFromGeometry = false)
  31246. */
  31247. useBoundingInfoFromGeometry: boolean;
  31248. /**
  31249. * Creates a new geometry
  31250. * @param id defines the unique ID
  31251. * @param scene defines the hosting scene
  31252. * @param vertexData defines the VertexData used to get geometry data
  31253. * @param updatable defines if geometry must be updatable (false by default)
  31254. * @param mesh defines the mesh that will be associated with the geometry
  31255. */
  31256. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  31257. /**
  31258. * Gets the current extend of the geometry
  31259. */
  31260. get extend(): {
  31261. minimum: Vector3;
  31262. maximum: Vector3;
  31263. };
  31264. /**
  31265. * Gets the hosting scene
  31266. * @returns the hosting Scene
  31267. */
  31268. getScene(): Scene;
  31269. /**
  31270. * Gets the hosting engine
  31271. * @returns the hosting Engine
  31272. */
  31273. getEngine(): Engine;
  31274. /**
  31275. * Defines if the geometry is ready to use
  31276. * @returns true if the geometry is ready to be used
  31277. */
  31278. isReady(): boolean;
  31279. /**
  31280. * Gets a value indicating that the geometry should not be serialized
  31281. */
  31282. get doNotSerialize(): boolean;
  31283. /** @hidden */
  31284. _rebuild(): void;
  31285. /**
  31286. * Affects all geometry data in one call
  31287. * @param vertexData defines the geometry data
  31288. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  31289. */
  31290. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  31291. /**
  31292. * Set specific vertex data
  31293. * @param kind defines the data kind (Position, normal, etc...)
  31294. * @param data defines the vertex data to use
  31295. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  31296. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  31297. */
  31298. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  31299. /**
  31300. * Removes a specific vertex data
  31301. * @param kind defines the data kind (Position, normal, etc...)
  31302. */
  31303. removeVerticesData(kind: string): void;
  31304. /**
  31305. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  31306. * @param buffer defines the vertex buffer to use
  31307. * @param totalVertices defines the total number of vertices for position kind (could be null)
  31308. */
  31309. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  31310. /**
  31311. * Update a specific vertex buffer
  31312. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  31313. * It will do nothing if the buffer is not updatable
  31314. * @param kind defines the data kind (Position, normal, etc...)
  31315. * @param data defines the data to use
  31316. * @param offset defines the offset in the target buffer where to store the data
  31317. * @param useBytes set to true if the offset is in bytes
  31318. */
  31319. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  31320. /**
  31321. * Update a specific vertex buffer
  31322. * This function will create a new buffer if the current one is not updatable
  31323. * @param kind defines the data kind (Position, normal, etc...)
  31324. * @param data defines the data to use
  31325. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  31326. */
  31327. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  31328. private _updateBoundingInfo;
  31329. /** @hidden */
  31330. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>, overrideVertexBuffers?: {
  31331. [kind: string]: Nullable<VertexBuffer>;
  31332. }, overrideVertexArrayObjects?: {
  31333. [key: string]: WebGLVertexArrayObject;
  31334. }): void;
  31335. /**
  31336. * Gets total number of vertices
  31337. * @returns the total number of vertices
  31338. */
  31339. getTotalVertices(): number;
  31340. /**
  31341. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  31342. * @param kind defines the data kind (Position, normal, etc...)
  31343. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  31344. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  31345. * @returns a float array containing vertex data
  31346. */
  31347. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  31348. /**
  31349. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  31350. * @param kind defines the data kind (Position, normal, etc...)
  31351. * @returns true if the vertex buffer with the specified kind is updatable
  31352. */
  31353. isVertexBufferUpdatable(kind: string): boolean;
  31354. /**
  31355. * Gets a specific vertex buffer
  31356. * @param kind defines the data kind (Position, normal, etc...)
  31357. * @returns a VertexBuffer
  31358. */
  31359. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  31360. /**
  31361. * Returns all vertex buffers
  31362. * @return an object holding all vertex buffers indexed by kind
  31363. */
  31364. getVertexBuffers(): Nullable<{
  31365. [key: string]: VertexBuffer;
  31366. }>;
  31367. /**
  31368. * Gets a boolean indicating if specific vertex buffer is present
  31369. * @param kind defines the data kind (Position, normal, etc...)
  31370. * @returns true if data is present
  31371. */
  31372. isVerticesDataPresent(kind: string): boolean;
  31373. /**
  31374. * Gets a list of all attached data kinds (Position, normal, etc...)
  31375. * @returns a list of string containing all kinds
  31376. */
  31377. getVerticesDataKinds(): string[];
  31378. /**
  31379. * Update index buffer
  31380. * @param indices defines the indices to store in the index buffer
  31381. * @param offset defines the offset in the target buffer where to store the data
  31382. * @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)
  31383. */
  31384. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  31385. /**
  31386. * Creates a new index buffer
  31387. * @param indices defines the indices to store in the index buffer
  31388. * @param totalVertices defines the total number of vertices (could be null)
  31389. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  31390. */
  31391. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  31392. /**
  31393. * Return the total number of indices
  31394. * @returns the total number of indices
  31395. */
  31396. getTotalIndices(): number;
  31397. /**
  31398. * Gets the index buffer array
  31399. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  31400. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  31401. * @returns the index buffer array
  31402. */
  31403. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  31404. /**
  31405. * Gets the index buffer
  31406. * @return the index buffer
  31407. */
  31408. getIndexBuffer(): Nullable<DataBuffer>;
  31409. /** @hidden */
  31410. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  31411. /**
  31412. * Release the associated resources for a specific mesh
  31413. * @param mesh defines the source mesh
  31414. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  31415. */
  31416. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  31417. /**
  31418. * Apply current geometry to a given mesh
  31419. * @param mesh defines the mesh to apply geometry to
  31420. */
  31421. applyToMesh(mesh: Mesh): void;
  31422. private _updateExtend;
  31423. private _applyToMesh;
  31424. private notifyUpdate;
  31425. /**
  31426. * Load the geometry if it was flagged as delay loaded
  31427. * @param scene defines the hosting scene
  31428. * @param onLoaded defines a callback called when the geometry is loaded
  31429. */
  31430. load(scene: Scene, onLoaded?: () => void): void;
  31431. private _queueLoad;
  31432. /**
  31433. * Invert the geometry to move from a right handed system to a left handed one.
  31434. */
  31435. toLeftHanded(): void;
  31436. /** @hidden */
  31437. _resetPointsArrayCache(): void;
  31438. /** @hidden */
  31439. _generatePointsArray(): boolean;
  31440. /**
  31441. * Gets a value indicating if the geometry is disposed
  31442. * @returns true if the geometry was disposed
  31443. */
  31444. isDisposed(): boolean;
  31445. private _disposeVertexArrayObjects;
  31446. /**
  31447. * Free all associated resources
  31448. */
  31449. dispose(): void;
  31450. /**
  31451. * Clone the current geometry into a new geometry
  31452. * @param id defines the unique ID of the new geometry
  31453. * @returns a new geometry object
  31454. */
  31455. copy(id: string): Geometry;
  31456. /**
  31457. * Serialize the current geometry info (and not the vertices data) into a JSON object
  31458. * @return a JSON representation of the current geometry data (without the vertices data)
  31459. */
  31460. serialize(): any;
  31461. private toNumberArray;
  31462. /**
  31463. * Serialize all vertices data into a JSON oject
  31464. * @returns a JSON representation of the current geometry data
  31465. */
  31466. serializeVerticeData(): any;
  31467. /**
  31468. * Extracts a clone of a mesh geometry
  31469. * @param mesh defines the source mesh
  31470. * @param id defines the unique ID of the new geometry object
  31471. * @returns the new geometry object
  31472. */
  31473. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  31474. /**
  31475. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  31476. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  31477. * Be aware Math.random() could cause collisions, but:
  31478. * "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"
  31479. * @returns a string containing a new GUID
  31480. */
  31481. static RandomId(): string;
  31482. /** @hidden */
  31483. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  31484. private static _CleanMatricesWeights;
  31485. /**
  31486. * Create a new geometry from persisted data (Using .babylon file format)
  31487. * @param parsedVertexData defines the persisted data
  31488. * @param scene defines the hosting scene
  31489. * @param rootUrl defines the root url to use to load assets (like delayed data)
  31490. * @returns the new geometry object
  31491. */
  31492. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  31493. }
  31494. }
  31495. declare module BABYLON {
  31496. /**
  31497. * Defines a target to use with MorphTargetManager
  31498. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  31499. */
  31500. export class MorphTarget implements IAnimatable {
  31501. /** defines the name of the target */
  31502. name: string;
  31503. /**
  31504. * Gets or sets the list of animations
  31505. */
  31506. animations: Animation[];
  31507. private _scene;
  31508. private _positions;
  31509. private _normals;
  31510. private _tangents;
  31511. private _uvs;
  31512. private _influence;
  31513. private _uniqueId;
  31514. /**
  31515. * Observable raised when the influence changes
  31516. */
  31517. onInfluenceChanged: Observable<boolean>;
  31518. /** @hidden */
  31519. _onDataLayoutChanged: Observable<void>;
  31520. /**
  31521. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  31522. */
  31523. get influence(): number;
  31524. set influence(influence: number);
  31525. /**
  31526. * Gets or sets the id of the morph Target
  31527. */
  31528. id: string;
  31529. private _animationPropertiesOverride;
  31530. /**
  31531. * Gets or sets the animation properties override
  31532. */
  31533. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  31534. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  31535. /**
  31536. * Creates a new MorphTarget
  31537. * @param name defines the name of the target
  31538. * @param influence defines the influence to use
  31539. * @param scene defines the scene the morphtarget belongs to
  31540. */
  31541. constructor(
  31542. /** defines the name of the target */
  31543. name: string, influence?: number, scene?: Nullable<Scene>);
  31544. /**
  31545. * Gets the unique ID of this manager
  31546. */
  31547. get uniqueId(): number;
  31548. /**
  31549. * Gets a boolean defining if the target contains position data
  31550. */
  31551. get hasPositions(): boolean;
  31552. /**
  31553. * Gets a boolean defining if the target contains normal data
  31554. */
  31555. get hasNormals(): boolean;
  31556. /**
  31557. * Gets a boolean defining if the target contains tangent data
  31558. */
  31559. get hasTangents(): boolean;
  31560. /**
  31561. * Gets a boolean defining if the target contains texture coordinates data
  31562. */
  31563. get hasUVs(): boolean;
  31564. /**
  31565. * Affects position data to this target
  31566. * @param data defines the position data to use
  31567. */
  31568. setPositions(data: Nullable<FloatArray>): void;
  31569. /**
  31570. * Gets the position data stored in this target
  31571. * @returns a FloatArray containing the position data (or null if not present)
  31572. */
  31573. getPositions(): Nullable<FloatArray>;
  31574. /**
  31575. * Affects normal data to this target
  31576. * @param data defines the normal data to use
  31577. */
  31578. setNormals(data: Nullable<FloatArray>): void;
  31579. /**
  31580. * Gets the normal data stored in this target
  31581. * @returns a FloatArray containing the normal data (or null if not present)
  31582. */
  31583. getNormals(): Nullable<FloatArray>;
  31584. /**
  31585. * Affects tangent data to this target
  31586. * @param data defines the tangent data to use
  31587. */
  31588. setTangents(data: Nullable<FloatArray>): void;
  31589. /**
  31590. * Gets the tangent data stored in this target
  31591. * @returns a FloatArray containing the tangent data (or null if not present)
  31592. */
  31593. getTangents(): Nullable<FloatArray>;
  31594. /**
  31595. * Affects texture coordinates data to this target
  31596. * @param data defines the texture coordinates data to use
  31597. */
  31598. setUVs(data: Nullable<FloatArray>): void;
  31599. /**
  31600. * Gets the texture coordinates data stored in this target
  31601. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  31602. */
  31603. getUVs(): Nullable<FloatArray>;
  31604. /**
  31605. * Clone the current target
  31606. * @returns a new MorphTarget
  31607. */
  31608. clone(): MorphTarget;
  31609. /**
  31610. * Serializes the current target into a Serialization object
  31611. * @returns the serialized object
  31612. */
  31613. serialize(): any;
  31614. /**
  31615. * Returns the string "MorphTarget"
  31616. * @returns "MorphTarget"
  31617. */
  31618. getClassName(): string;
  31619. /**
  31620. * Creates a new target from serialized data
  31621. * @param serializationObject defines the serialized data to use
  31622. * @returns a new MorphTarget
  31623. */
  31624. static Parse(serializationObject: any): MorphTarget;
  31625. /**
  31626. * Creates a MorphTarget from mesh data
  31627. * @param mesh defines the source mesh
  31628. * @param name defines the name to use for the new target
  31629. * @param influence defines the influence to attach to the target
  31630. * @returns a new MorphTarget
  31631. */
  31632. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  31633. }
  31634. }
  31635. declare module BABYLON {
  31636. /**
  31637. * This class is used to deform meshes using morphing between different targets
  31638. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  31639. */
  31640. export class MorphTargetManager {
  31641. private _targets;
  31642. private _targetInfluenceChangedObservers;
  31643. private _targetDataLayoutChangedObservers;
  31644. private _activeTargets;
  31645. private _scene;
  31646. private _influences;
  31647. private _supportsNormals;
  31648. private _supportsTangents;
  31649. private _supportsUVs;
  31650. private _vertexCount;
  31651. private _uniqueId;
  31652. private _tempInfluences;
  31653. /**
  31654. * Gets or sets a boolean indicating if normals must be morphed
  31655. */
  31656. enableNormalMorphing: boolean;
  31657. /**
  31658. * Gets or sets a boolean indicating if tangents must be morphed
  31659. */
  31660. enableTangentMorphing: boolean;
  31661. /**
  31662. * Gets or sets a boolean indicating if UV must be morphed
  31663. */
  31664. enableUVMorphing: boolean;
  31665. /**
  31666. * Creates a new MorphTargetManager
  31667. * @param scene defines the current scene
  31668. */
  31669. constructor(scene?: Nullable<Scene>);
  31670. /**
  31671. * Gets the unique ID of this manager
  31672. */
  31673. get uniqueId(): number;
  31674. /**
  31675. * Gets the number of vertices handled by this manager
  31676. */
  31677. get vertexCount(): number;
  31678. /**
  31679. * Gets a boolean indicating if this manager supports morphing of normals
  31680. */
  31681. get supportsNormals(): boolean;
  31682. /**
  31683. * Gets a boolean indicating if this manager supports morphing of tangents
  31684. */
  31685. get supportsTangents(): boolean;
  31686. /**
  31687. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  31688. */
  31689. get supportsUVs(): boolean;
  31690. /**
  31691. * Gets the number of targets stored in this manager
  31692. */
  31693. get numTargets(): number;
  31694. /**
  31695. * Gets the number of influencers (ie. the number of targets with influences > 0)
  31696. */
  31697. get numInfluencers(): number;
  31698. /**
  31699. * Gets the list of influences (one per target)
  31700. */
  31701. get influences(): Float32Array;
  31702. /**
  31703. * Gets the active target at specified index. An active target is a target with an influence > 0
  31704. * @param index defines the index to check
  31705. * @returns the requested target
  31706. */
  31707. getActiveTarget(index: number): MorphTarget;
  31708. /**
  31709. * Gets the target at specified index
  31710. * @param index defines the index to check
  31711. * @returns the requested target
  31712. */
  31713. getTarget(index: number): MorphTarget;
  31714. /**
  31715. * Add a new target to this manager
  31716. * @param target defines the target to add
  31717. */
  31718. addTarget(target: MorphTarget): void;
  31719. /**
  31720. * Removes a target from the manager
  31721. * @param target defines the target to remove
  31722. */
  31723. removeTarget(target: MorphTarget): void;
  31724. /**
  31725. * Clone the current manager
  31726. * @returns a new MorphTargetManager
  31727. */
  31728. clone(): MorphTargetManager;
  31729. /**
  31730. * Serializes the current manager into a Serialization object
  31731. * @returns the serialized object
  31732. */
  31733. serialize(): any;
  31734. private _syncActiveTargets;
  31735. /**
  31736. * Syncrhonize the targets with all the meshes using this morph target manager
  31737. */
  31738. synchronize(): void;
  31739. /**
  31740. * Creates a new MorphTargetManager from serialized data
  31741. * @param serializationObject defines the serialized data
  31742. * @param scene defines the hosting scene
  31743. * @returns the new MorphTargetManager
  31744. */
  31745. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  31746. }
  31747. }
  31748. declare module BABYLON {
  31749. /**
  31750. * Class used to represent a specific level of detail of a mesh
  31751. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  31752. */
  31753. export class MeshLODLevel {
  31754. /** Defines the distance where this level should start being displayed */
  31755. distance: number;
  31756. /** Defines the mesh to use to render this level */
  31757. mesh: Nullable<Mesh>;
  31758. /**
  31759. * Creates a new LOD level
  31760. * @param distance defines the distance where this level should star being displayed
  31761. * @param mesh defines the mesh to use to render this level
  31762. */
  31763. constructor(
  31764. /** Defines the distance where this level should start being displayed */
  31765. distance: number,
  31766. /** Defines the mesh to use to render this level */
  31767. mesh: Nullable<Mesh>);
  31768. }
  31769. }
  31770. declare module BABYLON {
  31771. /**
  31772. * Helper class used to generate a canvas to manipulate images
  31773. */
  31774. export class CanvasGenerator {
  31775. /**
  31776. * Create a new canvas (or offscreen canvas depending on the context)
  31777. * @param width defines the expected width
  31778. * @param height defines the expected height
  31779. * @return a new canvas or offscreen canvas
  31780. */
  31781. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  31782. }
  31783. }
  31784. declare module BABYLON {
  31785. /**
  31786. * Mesh representing the gorund
  31787. */
  31788. export class GroundMesh extends Mesh {
  31789. /** If octree should be generated */
  31790. generateOctree: boolean;
  31791. private _heightQuads;
  31792. /** @hidden */
  31793. _subdivisionsX: number;
  31794. /** @hidden */
  31795. _subdivisionsY: number;
  31796. /** @hidden */
  31797. _width: number;
  31798. /** @hidden */
  31799. _height: number;
  31800. /** @hidden */
  31801. _minX: number;
  31802. /** @hidden */
  31803. _maxX: number;
  31804. /** @hidden */
  31805. _minZ: number;
  31806. /** @hidden */
  31807. _maxZ: number;
  31808. constructor(name: string, scene: Scene);
  31809. /**
  31810. * "GroundMesh"
  31811. * @returns "GroundMesh"
  31812. */
  31813. getClassName(): string;
  31814. /**
  31815. * The minimum of x and y subdivisions
  31816. */
  31817. get subdivisions(): number;
  31818. /**
  31819. * X subdivisions
  31820. */
  31821. get subdivisionsX(): number;
  31822. /**
  31823. * Y subdivisions
  31824. */
  31825. get subdivisionsY(): number;
  31826. /**
  31827. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  31828. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  31829. * @param chunksCount the number of subdivisions for x and y
  31830. * @param octreeBlocksSize (Default: 32)
  31831. */
  31832. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  31833. /**
  31834. * Returns a height (y) value in the Worl system :
  31835. * the ground altitude at the coordinates (x, z) expressed in the World system.
  31836. * @param x x coordinate
  31837. * @param z z coordinate
  31838. * @returns the ground y position if (x, z) are outside the ground surface.
  31839. */
  31840. getHeightAtCoordinates(x: number, z: number): number;
  31841. /**
  31842. * Returns a normalized vector (Vector3) orthogonal to the ground
  31843. * at the ground coordinates (x, z) expressed in the World system.
  31844. * @param x x coordinate
  31845. * @param z z coordinate
  31846. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  31847. */
  31848. getNormalAtCoordinates(x: number, z: number): Vector3;
  31849. /**
  31850. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  31851. * at the ground coordinates (x, z) expressed in the World system.
  31852. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  31853. * @param x x coordinate
  31854. * @param z z coordinate
  31855. * @param ref vector to store the result
  31856. * @returns the GroundMesh.
  31857. */
  31858. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  31859. /**
  31860. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  31861. * if the ground has been updated.
  31862. * This can be used in the render loop.
  31863. * @returns the GroundMesh.
  31864. */
  31865. updateCoordinateHeights(): GroundMesh;
  31866. private _getFacetAt;
  31867. private _initHeightQuads;
  31868. private _computeHeightQuads;
  31869. /**
  31870. * Serializes this ground mesh
  31871. * @param serializationObject object to write serialization to
  31872. */
  31873. serialize(serializationObject: any): void;
  31874. /**
  31875. * Parses a serialized ground mesh
  31876. * @param parsedMesh the serialized mesh
  31877. * @param scene the scene to create the ground mesh in
  31878. * @returns the created ground mesh
  31879. */
  31880. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  31881. }
  31882. }
  31883. declare module BABYLON {
  31884. /**
  31885. * Interface for Physics-Joint data
  31886. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31887. */
  31888. export interface PhysicsJointData {
  31889. /**
  31890. * The main pivot of the joint
  31891. */
  31892. mainPivot?: Vector3;
  31893. /**
  31894. * The connected pivot of the joint
  31895. */
  31896. connectedPivot?: Vector3;
  31897. /**
  31898. * The main axis of the joint
  31899. */
  31900. mainAxis?: Vector3;
  31901. /**
  31902. * The connected axis of the joint
  31903. */
  31904. connectedAxis?: Vector3;
  31905. /**
  31906. * The collision of the joint
  31907. */
  31908. collision?: boolean;
  31909. /**
  31910. * Native Oimo/Cannon/Energy data
  31911. */
  31912. nativeParams?: any;
  31913. }
  31914. /**
  31915. * This is a holder class for the physics joint created by the physics plugin
  31916. * It holds a set of functions to control the underlying joint
  31917. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31918. */
  31919. export class PhysicsJoint {
  31920. /**
  31921. * The type of the physics joint
  31922. */
  31923. type: number;
  31924. /**
  31925. * The data for the physics joint
  31926. */
  31927. jointData: PhysicsJointData;
  31928. private _physicsJoint;
  31929. protected _physicsPlugin: IPhysicsEnginePlugin;
  31930. /**
  31931. * Initializes the physics joint
  31932. * @param type The type of the physics joint
  31933. * @param jointData The data for the physics joint
  31934. */
  31935. constructor(
  31936. /**
  31937. * The type of the physics joint
  31938. */
  31939. type: number,
  31940. /**
  31941. * The data for the physics joint
  31942. */
  31943. jointData: PhysicsJointData);
  31944. /**
  31945. * Gets the physics joint
  31946. */
  31947. get physicsJoint(): any;
  31948. /**
  31949. * Sets the physics joint
  31950. */
  31951. set physicsJoint(newJoint: any);
  31952. /**
  31953. * Sets the physics plugin
  31954. */
  31955. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  31956. /**
  31957. * Execute a function that is physics-plugin specific.
  31958. * @param {Function} func the function that will be executed.
  31959. * It accepts two parameters: the physics world and the physics joint
  31960. */
  31961. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  31962. /**
  31963. * Distance-Joint type
  31964. */
  31965. static DistanceJoint: number;
  31966. /**
  31967. * Hinge-Joint type
  31968. */
  31969. static HingeJoint: number;
  31970. /**
  31971. * Ball-and-Socket joint type
  31972. */
  31973. static BallAndSocketJoint: number;
  31974. /**
  31975. * Wheel-Joint type
  31976. */
  31977. static WheelJoint: number;
  31978. /**
  31979. * Slider-Joint type
  31980. */
  31981. static SliderJoint: number;
  31982. /**
  31983. * Prismatic-Joint type
  31984. */
  31985. static PrismaticJoint: number;
  31986. /**
  31987. * Universal-Joint type
  31988. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  31989. */
  31990. static UniversalJoint: number;
  31991. /**
  31992. * Hinge-Joint 2 type
  31993. */
  31994. static Hinge2Joint: number;
  31995. /**
  31996. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  31997. */
  31998. static PointToPointJoint: number;
  31999. /**
  32000. * Spring-Joint type
  32001. */
  32002. static SpringJoint: number;
  32003. /**
  32004. * Lock-Joint type
  32005. */
  32006. static LockJoint: number;
  32007. }
  32008. /**
  32009. * A class representing a physics distance joint
  32010. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32011. */
  32012. export class DistanceJoint extends PhysicsJoint {
  32013. /**
  32014. *
  32015. * @param jointData The data for the Distance-Joint
  32016. */
  32017. constructor(jointData: DistanceJointData);
  32018. /**
  32019. * Update the predefined distance.
  32020. * @param maxDistance The maximum preferred distance
  32021. * @param minDistance The minimum preferred distance
  32022. */
  32023. updateDistance(maxDistance: number, minDistance?: number): void;
  32024. }
  32025. /**
  32026. * Represents a Motor-Enabled Joint
  32027. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32028. */
  32029. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  32030. /**
  32031. * Initializes the Motor-Enabled Joint
  32032. * @param type The type of the joint
  32033. * @param jointData The physica joint data for the joint
  32034. */
  32035. constructor(type: number, jointData: PhysicsJointData);
  32036. /**
  32037. * Set the motor values.
  32038. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32039. * @param force the force to apply
  32040. * @param maxForce max force for this motor.
  32041. */
  32042. setMotor(force?: number, maxForce?: number): void;
  32043. /**
  32044. * Set the motor's limits.
  32045. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32046. * @param upperLimit The upper limit of the motor
  32047. * @param lowerLimit The lower limit of the motor
  32048. */
  32049. setLimit(upperLimit: number, lowerLimit?: number): void;
  32050. }
  32051. /**
  32052. * This class represents a single physics Hinge-Joint
  32053. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32054. */
  32055. export class HingeJoint extends MotorEnabledJoint {
  32056. /**
  32057. * Initializes the Hinge-Joint
  32058. * @param jointData The joint data for the Hinge-Joint
  32059. */
  32060. constructor(jointData: PhysicsJointData);
  32061. /**
  32062. * Set the motor values.
  32063. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32064. * @param {number} force the force to apply
  32065. * @param {number} maxForce max force for this motor.
  32066. */
  32067. setMotor(force?: number, maxForce?: number): void;
  32068. /**
  32069. * Set the motor's limits.
  32070. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32071. * @param upperLimit The upper limit of the motor
  32072. * @param lowerLimit The lower limit of the motor
  32073. */
  32074. setLimit(upperLimit: number, lowerLimit?: number): void;
  32075. }
  32076. /**
  32077. * This class represents a dual hinge physics joint (same as wheel joint)
  32078. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32079. */
  32080. export class Hinge2Joint extends MotorEnabledJoint {
  32081. /**
  32082. * Initializes the Hinge2-Joint
  32083. * @param jointData The joint data for the Hinge2-Joint
  32084. */
  32085. constructor(jointData: PhysicsJointData);
  32086. /**
  32087. * Set the motor values.
  32088. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32089. * @param {number} targetSpeed the speed the motor is to reach
  32090. * @param {number} maxForce max force for this motor.
  32091. * @param {motorIndex} the motor's index, 0 or 1.
  32092. */
  32093. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  32094. /**
  32095. * Set the motor limits.
  32096. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32097. * @param {number} upperLimit the upper limit
  32098. * @param {number} lowerLimit lower limit
  32099. * @param {motorIndex} the motor's index, 0 or 1.
  32100. */
  32101. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  32102. }
  32103. /**
  32104. * Interface for a motor enabled joint
  32105. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32106. */
  32107. export interface IMotorEnabledJoint {
  32108. /**
  32109. * Physics joint
  32110. */
  32111. physicsJoint: any;
  32112. /**
  32113. * Sets the motor of the motor-enabled joint
  32114. * @param force The force of the motor
  32115. * @param maxForce The maximum force of the motor
  32116. * @param motorIndex The index of the motor
  32117. */
  32118. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  32119. /**
  32120. * Sets the limit of the motor
  32121. * @param upperLimit The upper limit of the motor
  32122. * @param lowerLimit The lower limit of the motor
  32123. * @param motorIndex The index of the motor
  32124. */
  32125. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  32126. }
  32127. /**
  32128. * Joint data for a Distance-Joint
  32129. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32130. */
  32131. export interface DistanceJointData extends PhysicsJointData {
  32132. /**
  32133. * Max distance the 2 joint objects can be apart
  32134. */
  32135. maxDistance: number;
  32136. }
  32137. /**
  32138. * Joint data from a spring joint
  32139. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32140. */
  32141. export interface SpringJointData extends PhysicsJointData {
  32142. /**
  32143. * Length of the spring
  32144. */
  32145. length: number;
  32146. /**
  32147. * Stiffness of the spring
  32148. */
  32149. stiffness: number;
  32150. /**
  32151. * Damping of the spring
  32152. */
  32153. damping: number;
  32154. /** this callback will be called when applying the force to the impostors. */
  32155. forceApplicationCallback: () => void;
  32156. }
  32157. }
  32158. declare module BABYLON {
  32159. /**
  32160. * Holds the data for the raycast result
  32161. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32162. */
  32163. export class PhysicsRaycastResult {
  32164. private _hasHit;
  32165. private _hitDistance;
  32166. private _hitNormalWorld;
  32167. private _hitPointWorld;
  32168. private _rayFromWorld;
  32169. private _rayToWorld;
  32170. /**
  32171. * Gets if there was a hit
  32172. */
  32173. get hasHit(): boolean;
  32174. /**
  32175. * Gets the distance from the hit
  32176. */
  32177. get hitDistance(): number;
  32178. /**
  32179. * Gets the hit normal/direction in the world
  32180. */
  32181. get hitNormalWorld(): Vector3;
  32182. /**
  32183. * Gets the hit point in the world
  32184. */
  32185. get hitPointWorld(): Vector3;
  32186. /**
  32187. * Gets the ray "start point" of the ray in the world
  32188. */
  32189. get rayFromWorld(): Vector3;
  32190. /**
  32191. * Gets the ray "end point" of the ray in the world
  32192. */
  32193. get rayToWorld(): Vector3;
  32194. /**
  32195. * Sets the hit data (normal & point in world space)
  32196. * @param hitNormalWorld defines the normal in world space
  32197. * @param hitPointWorld defines the point in world space
  32198. */
  32199. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  32200. /**
  32201. * Sets the distance from the start point to the hit point
  32202. * @param distance
  32203. */
  32204. setHitDistance(distance: number): void;
  32205. /**
  32206. * Calculates the distance manually
  32207. */
  32208. calculateHitDistance(): void;
  32209. /**
  32210. * Resets all the values to default
  32211. * @param from The from point on world space
  32212. * @param to The to point on world space
  32213. */
  32214. reset(from?: Vector3, to?: Vector3): void;
  32215. }
  32216. /**
  32217. * Interface for the size containing width and height
  32218. */
  32219. interface IXYZ {
  32220. /**
  32221. * X
  32222. */
  32223. x: number;
  32224. /**
  32225. * Y
  32226. */
  32227. y: number;
  32228. /**
  32229. * Z
  32230. */
  32231. z: number;
  32232. }
  32233. }
  32234. declare module BABYLON {
  32235. /**
  32236. * Interface used to describe a physics joint
  32237. */
  32238. export interface PhysicsImpostorJoint {
  32239. /** Defines the main impostor to which the joint is linked */
  32240. mainImpostor: PhysicsImpostor;
  32241. /** Defines the impostor that is connected to the main impostor using this joint */
  32242. connectedImpostor: PhysicsImpostor;
  32243. /** Defines the joint itself */
  32244. joint: PhysicsJoint;
  32245. }
  32246. /** @hidden */
  32247. export interface IPhysicsEnginePlugin {
  32248. world: any;
  32249. name: string;
  32250. setGravity(gravity: Vector3): void;
  32251. setTimeStep(timeStep: number): void;
  32252. getTimeStep(): number;
  32253. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  32254. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  32255. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  32256. generatePhysicsBody(impostor: PhysicsImpostor): void;
  32257. removePhysicsBody(impostor: PhysicsImpostor): void;
  32258. generateJoint(joint: PhysicsImpostorJoint): void;
  32259. removeJoint(joint: PhysicsImpostorJoint): void;
  32260. isSupported(): boolean;
  32261. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  32262. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  32263. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  32264. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  32265. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  32266. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  32267. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  32268. getBodyMass(impostor: PhysicsImpostor): number;
  32269. getBodyFriction(impostor: PhysicsImpostor): number;
  32270. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  32271. getBodyRestitution(impostor: PhysicsImpostor): number;
  32272. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  32273. getBodyPressure?(impostor: PhysicsImpostor): number;
  32274. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  32275. getBodyStiffness?(impostor: PhysicsImpostor): number;
  32276. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  32277. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  32278. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  32279. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  32280. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  32281. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  32282. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  32283. sleepBody(impostor: PhysicsImpostor): void;
  32284. wakeUpBody(impostor: PhysicsImpostor): void;
  32285. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  32286. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  32287. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  32288. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  32289. getRadius(impostor: PhysicsImpostor): number;
  32290. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  32291. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  32292. dispose(): void;
  32293. }
  32294. /**
  32295. * Interface used to define a physics engine
  32296. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32297. */
  32298. export interface IPhysicsEngine {
  32299. /**
  32300. * Gets the gravity vector used by the simulation
  32301. */
  32302. gravity: Vector3;
  32303. /**
  32304. * Sets the gravity vector used by the simulation
  32305. * @param gravity defines the gravity vector to use
  32306. */
  32307. setGravity(gravity: Vector3): void;
  32308. /**
  32309. * Set the time step of the physics engine.
  32310. * Default is 1/60.
  32311. * To slow it down, enter 1/600 for example.
  32312. * To speed it up, 1/30
  32313. * @param newTimeStep the new timestep to apply to this world.
  32314. */
  32315. setTimeStep(newTimeStep: number): void;
  32316. /**
  32317. * Get the time step of the physics engine.
  32318. * @returns the current time step
  32319. */
  32320. getTimeStep(): number;
  32321. /**
  32322. * Set the sub time step of the physics engine.
  32323. * Default is 0 meaning there is no sub steps
  32324. * To increase physics resolution precision, set a small value (like 1 ms)
  32325. * @param subTimeStep defines the new sub timestep used for physics resolution.
  32326. */
  32327. setSubTimeStep(subTimeStep: number): void;
  32328. /**
  32329. * Get the sub time step of the physics engine.
  32330. * @returns the current sub time step
  32331. */
  32332. getSubTimeStep(): number;
  32333. /**
  32334. * Release all resources
  32335. */
  32336. dispose(): void;
  32337. /**
  32338. * Gets the name of the current physics plugin
  32339. * @returns the name of the plugin
  32340. */
  32341. getPhysicsPluginName(): string;
  32342. /**
  32343. * Adding a new impostor for the impostor tracking.
  32344. * This will be done by the impostor itself.
  32345. * @param impostor the impostor to add
  32346. */
  32347. addImpostor(impostor: PhysicsImpostor): void;
  32348. /**
  32349. * Remove an impostor from the engine.
  32350. * This impostor and its mesh will not longer be updated by the physics engine.
  32351. * @param impostor the impostor to remove
  32352. */
  32353. removeImpostor(impostor: PhysicsImpostor): void;
  32354. /**
  32355. * Add a joint to the physics engine
  32356. * @param mainImpostor defines the main impostor to which the joint is added.
  32357. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  32358. * @param joint defines the joint that will connect both impostors.
  32359. */
  32360. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  32361. /**
  32362. * Removes a joint from the simulation
  32363. * @param mainImpostor defines the impostor used with the joint
  32364. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  32365. * @param joint defines the joint to remove
  32366. */
  32367. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  32368. /**
  32369. * Gets the current plugin used to run the simulation
  32370. * @returns current plugin
  32371. */
  32372. getPhysicsPlugin(): IPhysicsEnginePlugin;
  32373. /**
  32374. * Gets the list of physic impostors
  32375. * @returns an array of PhysicsImpostor
  32376. */
  32377. getImpostors(): Array<PhysicsImpostor>;
  32378. /**
  32379. * Gets the impostor for a physics enabled object
  32380. * @param object defines the object impersonated by the impostor
  32381. * @returns the PhysicsImpostor or null if not found
  32382. */
  32383. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  32384. /**
  32385. * Gets the impostor for a physics body object
  32386. * @param body defines physics body used by the impostor
  32387. * @returns the PhysicsImpostor or null if not found
  32388. */
  32389. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  32390. /**
  32391. * Does a raycast in the physics world
  32392. * @param from when should the ray start?
  32393. * @param to when should the ray end?
  32394. * @returns PhysicsRaycastResult
  32395. */
  32396. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  32397. /**
  32398. * Called by the scene. No need to call it.
  32399. * @param delta defines the timespam between frames
  32400. */
  32401. _step(delta: number): void;
  32402. }
  32403. }
  32404. declare module BABYLON {
  32405. /**
  32406. * The interface for the physics imposter parameters
  32407. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32408. */
  32409. export interface PhysicsImpostorParameters {
  32410. /**
  32411. * The mass of the physics imposter
  32412. */
  32413. mass: number;
  32414. /**
  32415. * The friction of the physics imposter
  32416. */
  32417. friction?: number;
  32418. /**
  32419. * The coefficient of restitution of the physics imposter
  32420. */
  32421. restitution?: number;
  32422. /**
  32423. * The native options of the physics imposter
  32424. */
  32425. nativeOptions?: any;
  32426. /**
  32427. * Specifies if the parent should be ignored
  32428. */
  32429. ignoreParent?: boolean;
  32430. /**
  32431. * Specifies if bi-directional transformations should be disabled
  32432. */
  32433. disableBidirectionalTransformation?: boolean;
  32434. /**
  32435. * The pressure inside the physics imposter, soft object only
  32436. */
  32437. pressure?: number;
  32438. /**
  32439. * The stiffness the physics imposter, soft object only
  32440. */
  32441. stiffness?: number;
  32442. /**
  32443. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  32444. */
  32445. velocityIterations?: number;
  32446. /**
  32447. * The number of iterations used in maintaining consistent vertex positions, soft object only
  32448. */
  32449. positionIterations?: number;
  32450. /**
  32451. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  32452. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  32453. * Add to fix multiple points
  32454. */
  32455. fixedPoints?: number;
  32456. /**
  32457. * The collision margin around a soft object
  32458. */
  32459. margin?: number;
  32460. /**
  32461. * The collision margin around a soft object
  32462. */
  32463. damping?: number;
  32464. /**
  32465. * The path for a rope based on an extrusion
  32466. */
  32467. path?: any;
  32468. /**
  32469. * The shape of an extrusion used for a rope based on an extrusion
  32470. */
  32471. shape?: any;
  32472. }
  32473. /**
  32474. * Interface for a physics-enabled object
  32475. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32476. */
  32477. export interface IPhysicsEnabledObject {
  32478. /**
  32479. * The position of the physics-enabled object
  32480. */
  32481. position: Vector3;
  32482. /**
  32483. * The rotation of the physics-enabled object
  32484. */
  32485. rotationQuaternion: Nullable<Quaternion>;
  32486. /**
  32487. * The scale of the physics-enabled object
  32488. */
  32489. scaling: Vector3;
  32490. /**
  32491. * The rotation of the physics-enabled object
  32492. */
  32493. rotation?: Vector3;
  32494. /**
  32495. * The parent of the physics-enabled object
  32496. */
  32497. parent?: any;
  32498. /**
  32499. * The bounding info of the physics-enabled object
  32500. * @returns The bounding info of the physics-enabled object
  32501. */
  32502. getBoundingInfo(): BoundingInfo;
  32503. /**
  32504. * Computes the world matrix
  32505. * @param force Specifies if the world matrix should be computed by force
  32506. * @returns A world matrix
  32507. */
  32508. computeWorldMatrix(force: boolean): Matrix;
  32509. /**
  32510. * Gets the world matrix
  32511. * @returns A world matrix
  32512. */
  32513. getWorldMatrix?(): Matrix;
  32514. /**
  32515. * Gets the child meshes
  32516. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  32517. * @returns An array of abstract meshes
  32518. */
  32519. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  32520. /**
  32521. * Gets the vertex data
  32522. * @param kind The type of vertex data
  32523. * @returns A nullable array of numbers, or a float32 array
  32524. */
  32525. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  32526. /**
  32527. * Gets the indices from the mesh
  32528. * @returns A nullable array of index arrays
  32529. */
  32530. getIndices?(): Nullable<IndicesArray>;
  32531. /**
  32532. * Gets the scene from the mesh
  32533. * @returns the indices array or null
  32534. */
  32535. getScene?(): Scene;
  32536. /**
  32537. * Gets the absolute position from the mesh
  32538. * @returns the absolute position
  32539. */
  32540. getAbsolutePosition(): Vector3;
  32541. /**
  32542. * Gets the absolute pivot point from the mesh
  32543. * @returns the absolute pivot point
  32544. */
  32545. getAbsolutePivotPoint(): Vector3;
  32546. /**
  32547. * Rotates the mesh
  32548. * @param axis The axis of rotation
  32549. * @param amount The amount of rotation
  32550. * @param space The space of the rotation
  32551. * @returns The rotation transform node
  32552. */
  32553. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  32554. /**
  32555. * Translates the mesh
  32556. * @param axis The axis of translation
  32557. * @param distance The distance of translation
  32558. * @param space The space of the translation
  32559. * @returns The transform node
  32560. */
  32561. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  32562. /**
  32563. * Sets the absolute position of the mesh
  32564. * @param absolutePosition The absolute position of the mesh
  32565. * @returns The transform node
  32566. */
  32567. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  32568. /**
  32569. * Gets the class name of the mesh
  32570. * @returns The class name
  32571. */
  32572. getClassName(): string;
  32573. }
  32574. /**
  32575. * Represents a physics imposter
  32576. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32577. */
  32578. export class PhysicsImpostor {
  32579. /**
  32580. * The physics-enabled object used as the physics imposter
  32581. */
  32582. object: IPhysicsEnabledObject;
  32583. /**
  32584. * The type of the physics imposter
  32585. */
  32586. type: number;
  32587. private _options;
  32588. private _scene?;
  32589. /**
  32590. * The default object size of the imposter
  32591. */
  32592. static DEFAULT_OBJECT_SIZE: Vector3;
  32593. /**
  32594. * The identity quaternion of the imposter
  32595. */
  32596. static IDENTITY_QUATERNION: Quaternion;
  32597. /** @hidden */
  32598. _pluginData: any;
  32599. private _physicsEngine;
  32600. private _physicsBody;
  32601. private _bodyUpdateRequired;
  32602. private _onBeforePhysicsStepCallbacks;
  32603. private _onAfterPhysicsStepCallbacks;
  32604. /** @hidden */
  32605. _onPhysicsCollideCallbacks: Array<{
  32606. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor, point: Nullable<Vector3>) => void;
  32607. otherImpostors: Array<PhysicsImpostor>;
  32608. }>;
  32609. private _deltaPosition;
  32610. private _deltaRotation;
  32611. private _deltaRotationConjugated;
  32612. /** @hidden */
  32613. _isFromLine: boolean;
  32614. private _parent;
  32615. private _isDisposed;
  32616. private static _tmpVecs;
  32617. private static _tmpQuat;
  32618. /**
  32619. * Specifies if the physics imposter is disposed
  32620. */
  32621. get isDisposed(): boolean;
  32622. /**
  32623. * Gets the mass of the physics imposter
  32624. */
  32625. get mass(): number;
  32626. set mass(value: number);
  32627. /**
  32628. * Gets the coefficient of friction
  32629. */
  32630. get friction(): number;
  32631. /**
  32632. * Sets the coefficient of friction
  32633. */
  32634. set friction(value: number);
  32635. /**
  32636. * Gets the coefficient of restitution
  32637. */
  32638. get restitution(): number;
  32639. /**
  32640. * Sets the coefficient of restitution
  32641. */
  32642. set restitution(value: number);
  32643. /**
  32644. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  32645. */
  32646. get pressure(): number;
  32647. /**
  32648. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  32649. */
  32650. set pressure(value: number);
  32651. /**
  32652. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  32653. */
  32654. get stiffness(): number;
  32655. /**
  32656. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  32657. */
  32658. set stiffness(value: number);
  32659. /**
  32660. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  32661. */
  32662. get velocityIterations(): number;
  32663. /**
  32664. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  32665. */
  32666. set velocityIterations(value: number);
  32667. /**
  32668. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  32669. */
  32670. get positionIterations(): number;
  32671. /**
  32672. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  32673. */
  32674. set positionIterations(value: number);
  32675. /**
  32676. * The unique id of the physics imposter
  32677. * set by the physics engine when adding this impostor to the array
  32678. */
  32679. uniqueId: number;
  32680. /**
  32681. * @hidden
  32682. */
  32683. soft: boolean;
  32684. /**
  32685. * @hidden
  32686. */
  32687. segments: number;
  32688. private _joints;
  32689. /**
  32690. * Initializes the physics imposter
  32691. * @param object The physics-enabled object used as the physics imposter
  32692. * @param type The type of the physics imposter
  32693. * @param _options The options for the physics imposter
  32694. * @param _scene The Babylon scene
  32695. */
  32696. constructor(
  32697. /**
  32698. * The physics-enabled object used as the physics imposter
  32699. */
  32700. object: IPhysicsEnabledObject,
  32701. /**
  32702. * The type of the physics imposter
  32703. */
  32704. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  32705. /**
  32706. * This function will completly initialize this impostor.
  32707. * It will create a new body - but only if this mesh has no parent.
  32708. * If it has, this impostor will not be used other than to define the impostor
  32709. * of the child mesh.
  32710. * @hidden
  32711. */
  32712. _init(): void;
  32713. private _getPhysicsParent;
  32714. /**
  32715. * Should a new body be generated.
  32716. * @returns boolean specifying if body initialization is required
  32717. */
  32718. isBodyInitRequired(): boolean;
  32719. /**
  32720. * Sets the updated scaling
  32721. * @param updated Specifies if the scaling is updated
  32722. */
  32723. setScalingUpdated(): void;
  32724. /**
  32725. * Force a regeneration of this or the parent's impostor's body.
  32726. * Use under cautious - This will remove all joints already implemented.
  32727. */
  32728. forceUpdate(): void;
  32729. /**
  32730. * Gets the body that holds this impostor. Either its own, or its parent.
  32731. */
  32732. get physicsBody(): any;
  32733. /**
  32734. * Get the parent of the physics imposter
  32735. * @returns Physics imposter or null
  32736. */
  32737. get parent(): Nullable<PhysicsImpostor>;
  32738. /**
  32739. * Sets the parent of the physics imposter
  32740. */
  32741. set parent(value: Nullable<PhysicsImpostor>);
  32742. /**
  32743. * Set the physics body. Used mainly by the physics engine/plugin
  32744. */
  32745. set physicsBody(physicsBody: any);
  32746. /**
  32747. * Resets the update flags
  32748. */
  32749. resetUpdateFlags(): void;
  32750. /**
  32751. * Gets the object extend size
  32752. * @returns the object extend size
  32753. */
  32754. getObjectExtendSize(): Vector3;
  32755. /**
  32756. * Gets the object center
  32757. * @returns The object center
  32758. */
  32759. getObjectCenter(): Vector3;
  32760. /**
  32761. * Get a specific parameter from the options parameters
  32762. * @param paramName The object parameter name
  32763. * @returns The object parameter
  32764. */
  32765. getParam(paramName: string): any;
  32766. /**
  32767. * Sets a specific parameter in the options given to the physics plugin
  32768. * @param paramName The parameter name
  32769. * @param value The value of the parameter
  32770. */
  32771. setParam(paramName: string, value: number): void;
  32772. /**
  32773. * Specifically change the body's mass option. Won't recreate the physics body object
  32774. * @param mass The mass of the physics imposter
  32775. */
  32776. setMass(mass: number): void;
  32777. /**
  32778. * Gets the linear velocity
  32779. * @returns linear velocity or null
  32780. */
  32781. getLinearVelocity(): Nullable<Vector3>;
  32782. /**
  32783. * Sets the linear velocity
  32784. * @param velocity linear velocity or null
  32785. */
  32786. setLinearVelocity(velocity: Nullable<Vector3>): void;
  32787. /**
  32788. * Gets the angular velocity
  32789. * @returns angular velocity or null
  32790. */
  32791. getAngularVelocity(): Nullable<Vector3>;
  32792. /**
  32793. * Sets the angular velocity
  32794. * @param velocity The velocity or null
  32795. */
  32796. setAngularVelocity(velocity: Nullable<Vector3>): void;
  32797. /**
  32798. * Execute a function with the physics plugin native code
  32799. * Provide a function the will have two variables - the world object and the physics body object
  32800. * @param func The function to execute with the physics plugin native code
  32801. */
  32802. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  32803. /**
  32804. * Register a function that will be executed before the physics world is stepping forward
  32805. * @param func The function to execute before the physics world is stepped forward
  32806. */
  32807. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  32808. /**
  32809. * Unregister a function that will be executed before the physics world is stepping forward
  32810. * @param func The function to execute before the physics world is stepped forward
  32811. */
  32812. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  32813. /**
  32814. * Register a function that will be executed after the physics step
  32815. * @param func The function to execute after physics step
  32816. */
  32817. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  32818. /**
  32819. * Unregisters a function that will be executed after the physics step
  32820. * @param func The function to execute after physics step
  32821. */
  32822. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  32823. /**
  32824. * register a function that will be executed when this impostor collides against a different body
  32825. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  32826. * @param func Callback that is executed on collision
  32827. */
  32828. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  32829. /**
  32830. * Unregisters the physics imposter on contact
  32831. * @param collideAgainst The physics object to collide against
  32832. * @param func Callback to execute on collision
  32833. */
  32834. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  32835. private _tmpQuat;
  32836. private _tmpQuat2;
  32837. /**
  32838. * Get the parent rotation
  32839. * @returns The parent rotation
  32840. */
  32841. getParentsRotation(): Quaternion;
  32842. /**
  32843. * this function is executed by the physics engine.
  32844. */
  32845. beforeStep: () => void;
  32846. /**
  32847. * this function is executed by the physics engine
  32848. */
  32849. afterStep: () => void;
  32850. /**
  32851. * Legacy collision detection event support
  32852. */
  32853. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  32854. /**
  32855. * event and body object due to cannon's event-based architecture.
  32856. */
  32857. onCollide: (e: {
  32858. body: any;
  32859. point: Nullable<Vector3>;
  32860. }) => void;
  32861. /**
  32862. * Apply a force
  32863. * @param force The force to apply
  32864. * @param contactPoint The contact point for the force
  32865. * @returns The physics imposter
  32866. */
  32867. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  32868. /**
  32869. * Apply an impulse
  32870. * @param force The impulse force
  32871. * @param contactPoint The contact point for the impulse force
  32872. * @returns The physics imposter
  32873. */
  32874. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  32875. /**
  32876. * A help function to create a joint
  32877. * @param otherImpostor A physics imposter used to create a joint
  32878. * @param jointType The type of joint
  32879. * @param jointData The data for the joint
  32880. * @returns The physics imposter
  32881. */
  32882. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  32883. /**
  32884. * Add a joint to this impostor with a different impostor
  32885. * @param otherImpostor A physics imposter used to add a joint
  32886. * @param joint The joint to add
  32887. * @returns The physics imposter
  32888. */
  32889. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  32890. /**
  32891. * Add an anchor to a cloth impostor
  32892. * @param otherImpostor rigid impostor to anchor to
  32893. * @param width ratio across width from 0 to 1
  32894. * @param height ratio up height from 0 to 1
  32895. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  32896. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  32897. * @returns impostor the soft imposter
  32898. */
  32899. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  32900. /**
  32901. * Add a hook to a rope impostor
  32902. * @param otherImpostor rigid impostor to anchor to
  32903. * @param length ratio across rope from 0 to 1
  32904. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  32905. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  32906. * @returns impostor the rope imposter
  32907. */
  32908. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  32909. /**
  32910. * Will keep this body still, in a sleep mode.
  32911. * @returns the physics imposter
  32912. */
  32913. sleep(): PhysicsImpostor;
  32914. /**
  32915. * Wake the body up.
  32916. * @returns The physics imposter
  32917. */
  32918. wakeUp(): PhysicsImpostor;
  32919. /**
  32920. * Clones the physics imposter
  32921. * @param newObject The physics imposter clones to this physics-enabled object
  32922. * @returns A nullable physics imposter
  32923. */
  32924. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  32925. /**
  32926. * Disposes the physics imposter
  32927. */
  32928. dispose(): void;
  32929. /**
  32930. * Sets the delta position
  32931. * @param position The delta position amount
  32932. */
  32933. setDeltaPosition(position: Vector3): void;
  32934. /**
  32935. * Sets the delta rotation
  32936. * @param rotation The delta rotation amount
  32937. */
  32938. setDeltaRotation(rotation: Quaternion): void;
  32939. /**
  32940. * Gets the box size of the physics imposter and stores the result in the input parameter
  32941. * @param result Stores the box size
  32942. * @returns The physics imposter
  32943. */
  32944. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  32945. /**
  32946. * Gets the radius of the physics imposter
  32947. * @returns Radius of the physics imposter
  32948. */
  32949. getRadius(): number;
  32950. /**
  32951. * Sync a bone with this impostor
  32952. * @param bone The bone to sync to the impostor.
  32953. * @param boneMesh The mesh that the bone is influencing.
  32954. * @param jointPivot The pivot of the joint / bone in local space.
  32955. * @param distToJoint Optional distance from the impostor to the joint.
  32956. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  32957. */
  32958. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  32959. /**
  32960. * Sync impostor to a bone
  32961. * @param bone The bone that the impostor will be synced to.
  32962. * @param boneMesh The mesh that the bone is influencing.
  32963. * @param jointPivot The pivot of the joint / bone in local space.
  32964. * @param distToJoint Optional distance from the impostor to the joint.
  32965. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  32966. * @param boneAxis Optional vector3 axis the bone is aligned with
  32967. */
  32968. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  32969. /**
  32970. * No-Imposter type
  32971. */
  32972. static NoImpostor: number;
  32973. /**
  32974. * Sphere-Imposter type
  32975. */
  32976. static SphereImpostor: number;
  32977. /**
  32978. * Box-Imposter type
  32979. */
  32980. static BoxImpostor: number;
  32981. /**
  32982. * Plane-Imposter type
  32983. */
  32984. static PlaneImpostor: number;
  32985. /**
  32986. * Mesh-imposter type
  32987. */
  32988. static MeshImpostor: number;
  32989. /**
  32990. * Capsule-Impostor type (Ammo.js plugin only)
  32991. */
  32992. static CapsuleImpostor: number;
  32993. /**
  32994. * Cylinder-Imposter type
  32995. */
  32996. static CylinderImpostor: number;
  32997. /**
  32998. * Particle-Imposter type
  32999. */
  33000. static ParticleImpostor: number;
  33001. /**
  33002. * Heightmap-Imposter type
  33003. */
  33004. static HeightmapImpostor: number;
  33005. /**
  33006. * ConvexHull-Impostor type (Ammo.js plugin only)
  33007. */
  33008. static ConvexHullImpostor: number;
  33009. /**
  33010. * Custom-Imposter type (Ammo.js plugin only)
  33011. */
  33012. static CustomImpostor: number;
  33013. /**
  33014. * Rope-Imposter type
  33015. */
  33016. static RopeImpostor: number;
  33017. /**
  33018. * Cloth-Imposter type
  33019. */
  33020. static ClothImpostor: number;
  33021. /**
  33022. * Softbody-Imposter type
  33023. */
  33024. static SoftbodyImpostor: number;
  33025. }
  33026. }
  33027. declare module BABYLON {
  33028. /**
  33029. * @hidden
  33030. **/
  33031. export class _CreationDataStorage {
  33032. closePath?: boolean;
  33033. closeArray?: boolean;
  33034. idx: number[];
  33035. dashSize: number;
  33036. gapSize: number;
  33037. path3D: Path3D;
  33038. pathArray: Vector3[][];
  33039. arc: number;
  33040. radius: number;
  33041. cap: number;
  33042. tessellation: number;
  33043. }
  33044. /**
  33045. * @hidden
  33046. **/
  33047. class _InstanceDataStorage {
  33048. visibleInstances: any;
  33049. batchCache: _InstancesBatch;
  33050. instancesBufferSize: number;
  33051. instancesBuffer: Nullable<Buffer>;
  33052. instancesData: Float32Array;
  33053. overridenInstanceCount: number;
  33054. isFrozen: boolean;
  33055. previousBatch: Nullable<_InstancesBatch>;
  33056. hardwareInstancedRendering: boolean;
  33057. sideOrientation: number;
  33058. manualUpdate: boolean;
  33059. previousRenderId: number;
  33060. }
  33061. /**
  33062. * @hidden
  33063. **/
  33064. export class _InstancesBatch {
  33065. mustReturn: boolean;
  33066. visibleInstances: Nullable<InstancedMesh[]>[];
  33067. renderSelf: boolean[];
  33068. hardwareInstancedRendering: boolean[];
  33069. }
  33070. /**
  33071. * @hidden
  33072. **/
  33073. class _ThinInstanceDataStorage {
  33074. instancesCount: number;
  33075. matrixBuffer: Nullable<Buffer>;
  33076. matrixBufferSize: number;
  33077. matrixData: Nullable<Float32Array>;
  33078. boundingVectors: Array<Vector3>;
  33079. worldMatrices: Nullable<Matrix[]>;
  33080. }
  33081. /**
  33082. * Class used to represent renderable models
  33083. */
  33084. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  33085. /**
  33086. * Mesh side orientation : usually the external or front surface
  33087. */
  33088. static readonly FRONTSIDE: number;
  33089. /**
  33090. * Mesh side orientation : usually the internal or back surface
  33091. */
  33092. static readonly BACKSIDE: number;
  33093. /**
  33094. * Mesh side orientation : both internal and external or front and back surfaces
  33095. */
  33096. static readonly DOUBLESIDE: number;
  33097. /**
  33098. * Mesh side orientation : by default, `FRONTSIDE`
  33099. */
  33100. static readonly DEFAULTSIDE: number;
  33101. /**
  33102. * Mesh cap setting : no cap
  33103. */
  33104. static readonly NO_CAP: number;
  33105. /**
  33106. * Mesh cap setting : one cap at the beginning of the mesh
  33107. */
  33108. static readonly CAP_START: number;
  33109. /**
  33110. * Mesh cap setting : one cap at the end of the mesh
  33111. */
  33112. static readonly CAP_END: number;
  33113. /**
  33114. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  33115. */
  33116. static readonly CAP_ALL: number;
  33117. /**
  33118. * Mesh pattern setting : no flip or rotate
  33119. */
  33120. static readonly NO_FLIP: number;
  33121. /**
  33122. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  33123. */
  33124. static readonly FLIP_TILE: number;
  33125. /**
  33126. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  33127. */
  33128. static readonly ROTATE_TILE: number;
  33129. /**
  33130. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  33131. */
  33132. static readonly FLIP_ROW: number;
  33133. /**
  33134. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  33135. */
  33136. static readonly ROTATE_ROW: number;
  33137. /**
  33138. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  33139. */
  33140. static readonly FLIP_N_ROTATE_TILE: number;
  33141. /**
  33142. * Mesh pattern setting : rotate pattern and rotate
  33143. */
  33144. static readonly FLIP_N_ROTATE_ROW: number;
  33145. /**
  33146. * Mesh tile positioning : part tiles same on left/right or top/bottom
  33147. */
  33148. static readonly CENTER: number;
  33149. /**
  33150. * Mesh tile positioning : part tiles on left
  33151. */
  33152. static readonly LEFT: number;
  33153. /**
  33154. * Mesh tile positioning : part tiles on right
  33155. */
  33156. static readonly RIGHT: number;
  33157. /**
  33158. * Mesh tile positioning : part tiles on top
  33159. */
  33160. static readonly TOP: number;
  33161. /**
  33162. * Mesh tile positioning : part tiles on bottom
  33163. */
  33164. static readonly BOTTOM: number;
  33165. /**
  33166. * Gets the default side orientation.
  33167. * @param orientation the orientation to value to attempt to get
  33168. * @returns the default orientation
  33169. * @hidden
  33170. */
  33171. static _GetDefaultSideOrientation(orientation?: number): number;
  33172. private _internalMeshDataInfo;
  33173. get computeBonesUsingShaders(): boolean;
  33174. set computeBonesUsingShaders(value: boolean);
  33175. /**
  33176. * An event triggered before rendering the mesh
  33177. */
  33178. get onBeforeRenderObservable(): Observable<Mesh>;
  33179. /**
  33180. * An event triggered before binding the mesh
  33181. */
  33182. get onBeforeBindObservable(): Observable<Mesh>;
  33183. /**
  33184. * An event triggered after rendering the mesh
  33185. */
  33186. get onAfterRenderObservable(): Observable<Mesh>;
  33187. /**
  33188. * An event triggered before drawing the mesh
  33189. */
  33190. get onBeforeDrawObservable(): Observable<Mesh>;
  33191. private _onBeforeDrawObserver;
  33192. /**
  33193. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  33194. */
  33195. set onBeforeDraw(callback: () => void);
  33196. get hasInstances(): boolean;
  33197. get hasThinInstances(): boolean;
  33198. /**
  33199. * Gets the delay loading state of the mesh (when delay loading is turned on)
  33200. * @see https://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  33201. */
  33202. delayLoadState: number;
  33203. /**
  33204. * Gets the list of instances created from this mesh
  33205. * it is not supposed to be modified manually.
  33206. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  33207. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  33208. */
  33209. instances: InstancedMesh[];
  33210. /**
  33211. * Gets the file containing delay loading data for this mesh
  33212. */
  33213. delayLoadingFile: string;
  33214. /** @hidden */
  33215. _binaryInfo: any;
  33216. /**
  33217. * User defined function used to change how LOD level selection is done
  33218. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  33219. */
  33220. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  33221. /**
  33222. * Gets or sets the morph target manager
  33223. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  33224. */
  33225. get morphTargetManager(): Nullable<MorphTargetManager>;
  33226. set morphTargetManager(value: Nullable<MorphTargetManager>);
  33227. /** @hidden */
  33228. _creationDataStorage: Nullable<_CreationDataStorage>;
  33229. /** @hidden */
  33230. _geometry: Nullable<Geometry>;
  33231. /** @hidden */
  33232. _delayInfo: Array<string>;
  33233. /** @hidden */
  33234. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  33235. /** @hidden */
  33236. _instanceDataStorage: _InstanceDataStorage;
  33237. /** @hidden */
  33238. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  33239. private _effectiveMaterial;
  33240. /** @hidden */
  33241. _shouldGenerateFlatShading: boolean;
  33242. /** @hidden */
  33243. _originalBuilderSideOrientation: number;
  33244. /**
  33245. * Use this property to change the original side orientation defined at construction time
  33246. */
  33247. overrideMaterialSideOrientation: Nullable<number>;
  33248. /**
  33249. * Gets or sets a boolean indicating whether to render ignoring the active camera's max z setting. (false by default)
  33250. * Note this will reduce performance when set to true.
  33251. */
  33252. ignoreCameraMaxZ: boolean;
  33253. /**
  33254. * Gets the source mesh (the one used to clone this one from)
  33255. */
  33256. get source(): Nullable<Mesh>;
  33257. /**
  33258. * Gets the list of clones of this mesh
  33259. * The scene must have been constructed with useClonedMeshMap=true for this to work!
  33260. * Note that useClonedMeshMap=true is the default setting
  33261. */
  33262. get cloneMeshMap(): Nullable<{
  33263. [id: string]: Mesh | undefined;
  33264. }>;
  33265. /**
  33266. * Gets or sets a boolean indicating that this mesh does not use index buffer
  33267. */
  33268. get isUnIndexed(): boolean;
  33269. set isUnIndexed(value: boolean);
  33270. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  33271. get worldMatrixInstancedBuffer(): Float32Array;
  33272. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  33273. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  33274. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  33275. /**
  33276. * @constructor
  33277. * @param name The value used by scene.getMeshByName() to do a lookup.
  33278. * @param scene The scene to add this mesh to.
  33279. * @param parent The parent of this mesh, if it has one
  33280. * @param source An optional Mesh from which geometry is shared, cloned.
  33281. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  33282. * When false, achieved by calling a clone(), also passing False.
  33283. * This will make creation of children, recursive.
  33284. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  33285. */
  33286. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  33287. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  33288. doNotInstantiate: boolean;
  33289. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  33290. /**
  33291. * Gets the class name
  33292. * @returns the string "Mesh".
  33293. */
  33294. getClassName(): string;
  33295. /** @hidden */
  33296. get _isMesh(): boolean;
  33297. /**
  33298. * Returns a description of this mesh
  33299. * @param fullDetails define if full details about this mesh must be used
  33300. * @returns a descriptive string representing this mesh
  33301. */
  33302. toString(fullDetails?: boolean): string;
  33303. /** @hidden */
  33304. _unBindEffect(): void;
  33305. /**
  33306. * Gets a boolean indicating if this mesh has LOD
  33307. */
  33308. get hasLODLevels(): boolean;
  33309. /**
  33310. * Gets the list of MeshLODLevel associated with the current mesh
  33311. * @returns an array of MeshLODLevel
  33312. */
  33313. getLODLevels(): MeshLODLevel[];
  33314. private _sortLODLevels;
  33315. /**
  33316. * Add a mesh as LOD level triggered at the given distance.
  33317. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  33318. * @param distance The distance from the center of the object to show this level
  33319. * @param mesh The mesh to be added as LOD level (can be null)
  33320. * @return This mesh (for chaining)
  33321. */
  33322. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  33323. /**
  33324. * Returns the LOD level mesh at the passed distance or null if not found.
  33325. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  33326. * @param distance The distance from the center of the object to show this level
  33327. * @returns a Mesh or `null`
  33328. */
  33329. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  33330. /**
  33331. * Remove a mesh from the LOD array
  33332. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  33333. * @param mesh defines the mesh to be removed
  33334. * @return This mesh (for chaining)
  33335. */
  33336. removeLODLevel(mesh: Mesh): Mesh;
  33337. /**
  33338. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  33339. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  33340. * @param camera defines the camera to use to compute distance
  33341. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  33342. * @return This mesh (for chaining)
  33343. */
  33344. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  33345. /**
  33346. * Gets the mesh internal Geometry object
  33347. */
  33348. get geometry(): Nullable<Geometry>;
  33349. /**
  33350. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  33351. * @returns the total number of vertices
  33352. */
  33353. getTotalVertices(): number;
  33354. /**
  33355. * Returns the content of an associated vertex buffer
  33356. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  33357. * - VertexBuffer.PositionKind
  33358. * - VertexBuffer.UVKind
  33359. * - VertexBuffer.UV2Kind
  33360. * - VertexBuffer.UV3Kind
  33361. * - VertexBuffer.UV4Kind
  33362. * - VertexBuffer.UV5Kind
  33363. * - VertexBuffer.UV6Kind
  33364. * - VertexBuffer.ColorKind
  33365. * - VertexBuffer.MatricesIndicesKind
  33366. * - VertexBuffer.MatricesIndicesExtraKind
  33367. * - VertexBuffer.MatricesWeightsKind
  33368. * - VertexBuffer.MatricesWeightsExtraKind
  33369. * @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
  33370. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  33371. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  33372. */
  33373. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  33374. /**
  33375. * Returns the mesh VertexBuffer object from the requested `kind`
  33376. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  33377. * - VertexBuffer.PositionKind
  33378. * - VertexBuffer.NormalKind
  33379. * - VertexBuffer.UVKind
  33380. * - VertexBuffer.UV2Kind
  33381. * - VertexBuffer.UV3Kind
  33382. * - VertexBuffer.UV4Kind
  33383. * - VertexBuffer.UV5Kind
  33384. * - VertexBuffer.UV6Kind
  33385. * - VertexBuffer.ColorKind
  33386. * - VertexBuffer.MatricesIndicesKind
  33387. * - VertexBuffer.MatricesIndicesExtraKind
  33388. * - VertexBuffer.MatricesWeightsKind
  33389. * - VertexBuffer.MatricesWeightsExtraKind
  33390. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  33391. */
  33392. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  33393. /**
  33394. * Tests if a specific vertex buffer is associated with this mesh
  33395. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  33396. * - VertexBuffer.PositionKind
  33397. * - VertexBuffer.NormalKind
  33398. * - VertexBuffer.UVKind
  33399. * - VertexBuffer.UV2Kind
  33400. * - VertexBuffer.UV3Kind
  33401. * - VertexBuffer.UV4Kind
  33402. * - VertexBuffer.UV5Kind
  33403. * - VertexBuffer.UV6Kind
  33404. * - VertexBuffer.ColorKind
  33405. * - VertexBuffer.MatricesIndicesKind
  33406. * - VertexBuffer.MatricesIndicesExtraKind
  33407. * - VertexBuffer.MatricesWeightsKind
  33408. * - VertexBuffer.MatricesWeightsExtraKind
  33409. * @returns a boolean
  33410. */
  33411. isVerticesDataPresent(kind: string): boolean;
  33412. /**
  33413. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  33414. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  33415. * - VertexBuffer.PositionKind
  33416. * - VertexBuffer.UVKind
  33417. * - VertexBuffer.UV2Kind
  33418. * - VertexBuffer.UV3Kind
  33419. * - VertexBuffer.UV4Kind
  33420. * - VertexBuffer.UV5Kind
  33421. * - VertexBuffer.UV6Kind
  33422. * - VertexBuffer.ColorKind
  33423. * - VertexBuffer.MatricesIndicesKind
  33424. * - VertexBuffer.MatricesIndicesExtraKind
  33425. * - VertexBuffer.MatricesWeightsKind
  33426. * - VertexBuffer.MatricesWeightsExtraKind
  33427. * @returns a boolean
  33428. */
  33429. isVertexBufferUpdatable(kind: string): boolean;
  33430. /**
  33431. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  33432. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  33433. * - VertexBuffer.PositionKind
  33434. * - VertexBuffer.NormalKind
  33435. * - VertexBuffer.UVKind
  33436. * - VertexBuffer.UV2Kind
  33437. * - VertexBuffer.UV3Kind
  33438. * - VertexBuffer.UV4Kind
  33439. * - VertexBuffer.UV5Kind
  33440. * - VertexBuffer.UV6Kind
  33441. * - VertexBuffer.ColorKind
  33442. * - VertexBuffer.MatricesIndicesKind
  33443. * - VertexBuffer.MatricesIndicesExtraKind
  33444. * - VertexBuffer.MatricesWeightsKind
  33445. * - VertexBuffer.MatricesWeightsExtraKind
  33446. * @returns an array of strings
  33447. */
  33448. getVerticesDataKinds(): string[];
  33449. /**
  33450. * Returns a positive integer : the total number of indices in this mesh geometry.
  33451. * @returns the numner of indices or zero if the mesh has no geometry.
  33452. */
  33453. getTotalIndices(): number;
  33454. /**
  33455. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  33456. * @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.
  33457. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  33458. * @returns the indices array or an empty array if the mesh has no geometry
  33459. */
  33460. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  33461. get isBlocked(): boolean;
  33462. /**
  33463. * Determine if the current mesh is ready to be rendered
  33464. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  33465. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  33466. * @returns true if all associated assets are ready (material, textures, shaders)
  33467. */
  33468. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  33469. /**
  33470. * 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.
  33471. */
  33472. get areNormalsFrozen(): boolean;
  33473. /**
  33474. * 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.
  33475. * @returns the current mesh
  33476. */
  33477. freezeNormals(): Mesh;
  33478. /**
  33479. * 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
  33480. * @returns the current mesh
  33481. */
  33482. unfreezeNormals(): Mesh;
  33483. /**
  33484. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  33485. */
  33486. set overridenInstanceCount(count: number);
  33487. /** @hidden */
  33488. _preActivate(): Mesh;
  33489. /** @hidden */
  33490. _preActivateForIntermediateRendering(renderId: number): Mesh;
  33491. /** @hidden */
  33492. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  33493. protected _afterComputeWorldMatrix(): void;
  33494. /** @hidden */
  33495. _postActivate(): void;
  33496. /**
  33497. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  33498. * This means the mesh underlying bounding box and sphere are recomputed.
  33499. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  33500. * @returns the current mesh
  33501. */
  33502. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  33503. /** @hidden */
  33504. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  33505. /**
  33506. * This function will subdivide the mesh into multiple submeshes
  33507. * @param count defines the expected number of submeshes
  33508. */
  33509. subdivide(count: number): void;
  33510. /**
  33511. * Copy a FloatArray into a specific associated vertex buffer
  33512. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  33513. * - VertexBuffer.PositionKind
  33514. * - VertexBuffer.UVKind
  33515. * - VertexBuffer.UV2Kind
  33516. * - VertexBuffer.UV3Kind
  33517. * - VertexBuffer.UV4Kind
  33518. * - VertexBuffer.UV5Kind
  33519. * - VertexBuffer.UV6Kind
  33520. * - VertexBuffer.ColorKind
  33521. * - VertexBuffer.MatricesIndicesKind
  33522. * - VertexBuffer.MatricesIndicesExtraKind
  33523. * - VertexBuffer.MatricesWeightsKind
  33524. * - VertexBuffer.MatricesWeightsExtraKind
  33525. * @param data defines the data source
  33526. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  33527. * @param stride defines the data stride size (can be null)
  33528. * @returns the current mesh
  33529. */
  33530. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  33531. /**
  33532. * Delete a vertex buffer associated with this mesh
  33533. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  33534. * - VertexBuffer.PositionKind
  33535. * - VertexBuffer.UVKind
  33536. * - VertexBuffer.UV2Kind
  33537. * - VertexBuffer.UV3Kind
  33538. * - VertexBuffer.UV4Kind
  33539. * - VertexBuffer.UV5Kind
  33540. * - VertexBuffer.UV6Kind
  33541. * - VertexBuffer.ColorKind
  33542. * - VertexBuffer.MatricesIndicesKind
  33543. * - VertexBuffer.MatricesIndicesExtraKind
  33544. * - VertexBuffer.MatricesWeightsKind
  33545. * - VertexBuffer.MatricesWeightsExtraKind
  33546. */
  33547. removeVerticesData(kind: string): void;
  33548. /**
  33549. * Flags an associated vertex buffer as updatable
  33550. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  33551. * - VertexBuffer.PositionKind
  33552. * - VertexBuffer.UVKind
  33553. * - VertexBuffer.UV2Kind
  33554. * - VertexBuffer.UV3Kind
  33555. * - VertexBuffer.UV4Kind
  33556. * - VertexBuffer.UV5Kind
  33557. * - VertexBuffer.UV6Kind
  33558. * - VertexBuffer.ColorKind
  33559. * - VertexBuffer.MatricesIndicesKind
  33560. * - VertexBuffer.MatricesIndicesExtraKind
  33561. * - VertexBuffer.MatricesWeightsKind
  33562. * - VertexBuffer.MatricesWeightsExtraKind
  33563. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  33564. */
  33565. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  33566. /**
  33567. * Sets the mesh global Vertex Buffer
  33568. * @param buffer defines the buffer to use
  33569. * @returns the current mesh
  33570. */
  33571. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  33572. /**
  33573. * Update a specific associated vertex buffer
  33574. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  33575. * - VertexBuffer.PositionKind
  33576. * - VertexBuffer.UVKind
  33577. * - VertexBuffer.UV2Kind
  33578. * - VertexBuffer.UV3Kind
  33579. * - VertexBuffer.UV4Kind
  33580. * - VertexBuffer.UV5Kind
  33581. * - VertexBuffer.UV6Kind
  33582. * - VertexBuffer.ColorKind
  33583. * - VertexBuffer.MatricesIndicesKind
  33584. * - VertexBuffer.MatricesIndicesExtraKind
  33585. * - VertexBuffer.MatricesWeightsKind
  33586. * - VertexBuffer.MatricesWeightsExtraKind
  33587. * @param data defines the data source
  33588. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  33589. * @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)
  33590. * @returns the current mesh
  33591. */
  33592. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  33593. /**
  33594. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  33595. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  33596. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  33597. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  33598. * @returns the current mesh
  33599. */
  33600. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  33601. /**
  33602. * Creates a un-shared specific occurence of the geometry for the mesh.
  33603. * @returns the current mesh
  33604. */
  33605. makeGeometryUnique(): Mesh;
  33606. /**
  33607. * Set the index buffer of this mesh
  33608. * @param indices defines the source data
  33609. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  33610. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  33611. * @returns the current mesh
  33612. */
  33613. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  33614. /**
  33615. * Update the current index buffer
  33616. * @param indices defines the source data
  33617. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  33618. * @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)
  33619. * @returns the current mesh
  33620. */
  33621. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  33622. /**
  33623. * Invert the geometry to move from a right handed system to a left handed one.
  33624. * @returns the current mesh
  33625. */
  33626. toLeftHanded(): Mesh;
  33627. /** @hidden */
  33628. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  33629. /** @hidden */
  33630. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  33631. /**
  33632. * Registers for this mesh a javascript function called just before the rendering process
  33633. * @param func defines the function to call before rendering this mesh
  33634. * @returns the current mesh
  33635. */
  33636. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  33637. /**
  33638. * Disposes a previously registered javascript function called before the rendering
  33639. * @param func defines the function to remove
  33640. * @returns the current mesh
  33641. */
  33642. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  33643. /**
  33644. * Registers for this mesh a javascript function called just after the rendering is complete
  33645. * @param func defines the function to call after rendering this mesh
  33646. * @returns the current mesh
  33647. */
  33648. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  33649. /**
  33650. * Disposes a previously registered javascript function called after the rendering.
  33651. * @param func defines the function to remove
  33652. * @returns the current mesh
  33653. */
  33654. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  33655. /** @hidden */
  33656. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  33657. /** @hidden */
  33658. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  33659. /** @hidden */
  33660. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  33661. /** @hidden */
  33662. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  33663. /** @hidden */
  33664. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  33665. /** @hidden */
  33666. _rebuild(): void;
  33667. /** @hidden */
  33668. _freeze(): void;
  33669. /** @hidden */
  33670. _unFreeze(): void;
  33671. /**
  33672. * 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
  33673. * @param subMesh defines the subMesh to render
  33674. * @param enableAlphaMode defines if alpha mode can be changed
  33675. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  33676. * @returns the current mesh
  33677. */
  33678. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  33679. private _onBeforeDraw;
  33680. /**
  33681. * Renormalize the mesh and patch it up if there are no weights
  33682. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  33683. * However in the case of zero weights then we set just a single influence to 1.
  33684. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  33685. */
  33686. cleanMatrixWeights(): void;
  33687. private normalizeSkinFourWeights;
  33688. private normalizeSkinWeightsAndExtra;
  33689. /**
  33690. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  33691. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  33692. * the user know there was an issue with importing the mesh
  33693. * @returns a validation object with skinned, valid and report string
  33694. */
  33695. validateSkinning(): {
  33696. skinned: boolean;
  33697. valid: boolean;
  33698. report: string;
  33699. };
  33700. /** @hidden */
  33701. _checkDelayState(): Mesh;
  33702. private _queueLoad;
  33703. /**
  33704. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  33705. * A mesh is in the frustum if its bounding box intersects the frustum
  33706. * @param frustumPlanes defines the frustum to test
  33707. * @returns true if the mesh is in the frustum planes
  33708. */
  33709. isInFrustum(frustumPlanes: Plane[]): boolean;
  33710. /**
  33711. * Sets the mesh material by the material or multiMaterial `id` property
  33712. * @param id is a string identifying the material or the multiMaterial
  33713. * @returns the current mesh
  33714. */
  33715. setMaterialByID(id: string): Mesh;
  33716. /**
  33717. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  33718. * @returns an array of IAnimatable
  33719. */
  33720. getAnimatables(): IAnimatable[];
  33721. /**
  33722. * Modifies the mesh geometry according to the passed transformation matrix.
  33723. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  33724. * The mesh normals are modified using the same transformation.
  33725. * Note that, under the hood, this method sets a new VertexBuffer each call.
  33726. * @param transform defines the transform matrix to use
  33727. * @see https://doc.babylonjs.com/resources/baking_transformations
  33728. * @returns the current mesh
  33729. */
  33730. bakeTransformIntoVertices(transform: Matrix): Mesh;
  33731. /**
  33732. * Modifies the mesh geometry according to its own current World Matrix.
  33733. * The mesh World Matrix is then reset.
  33734. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  33735. * Note that, under the hood, this method sets a new VertexBuffer each call.
  33736. * @see https://doc.babylonjs.com/resources/baking_transformations
  33737. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  33738. * @returns the current mesh
  33739. */
  33740. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  33741. /** @hidden */
  33742. get _positions(): Nullable<Vector3[]>;
  33743. /** @hidden */
  33744. _resetPointsArrayCache(): Mesh;
  33745. /** @hidden */
  33746. _generatePointsArray(): boolean;
  33747. /**
  33748. * Returns a new Mesh object generated from the current mesh properties.
  33749. * This method must not get confused with createInstance()
  33750. * @param name is a string, the name given to the new mesh
  33751. * @param newParent can be any Node object (default `null`)
  33752. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  33753. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  33754. * @returns a new mesh
  33755. */
  33756. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  33757. /**
  33758. * Releases resources associated with this mesh.
  33759. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  33760. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  33761. */
  33762. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  33763. /** @hidden */
  33764. _disposeInstanceSpecificData(): void;
  33765. /** @hidden */
  33766. _disposeThinInstanceSpecificData(): void;
  33767. /**
  33768. * Modifies the mesh geometry according to a displacement map.
  33769. * 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.
  33770. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  33771. * @param url is a string, the URL from the image file is to be downloaded.
  33772. * @param minHeight is the lower limit of the displacement.
  33773. * @param maxHeight is the upper limit of the displacement.
  33774. * @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.
  33775. * @param uvOffset is an optional vector2 used to offset UV.
  33776. * @param uvScale is an optional vector2 used to scale UV.
  33777. * @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.
  33778. * @returns the Mesh.
  33779. */
  33780. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  33781. /**
  33782. * Modifies the mesh geometry according to a displacementMap buffer.
  33783. * 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.
  33784. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  33785. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  33786. * @param heightMapWidth is the width of the buffer image.
  33787. * @param heightMapHeight is the height of the buffer image.
  33788. * @param minHeight is the lower limit of the displacement.
  33789. * @param maxHeight is the upper limit of the displacement.
  33790. * @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.
  33791. * @param uvOffset is an optional vector2 used to offset UV.
  33792. * @param uvScale is an optional vector2 used to scale UV.
  33793. * @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.
  33794. * @returns the Mesh.
  33795. */
  33796. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  33797. /**
  33798. * Modify the mesh to get a flat shading rendering.
  33799. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  33800. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  33801. * @returns current mesh
  33802. */
  33803. convertToFlatShadedMesh(): Mesh;
  33804. /**
  33805. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  33806. * In other words, more vertices, no more indices and a single bigger VBO.
  33807. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  33808. * @returns current mesh
  33809. */
  33810. convertToUnIndexedMesh(): Mesh;
  33811. /**
  33812. * Inverses facet orientations.
  33813. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  33814. * @param flipNormals will also inverts the normals
  33815. * @returns current mesh
  33816. */
  33817. flipFaces(flipNormals?: boolean): Mesh;
  33818. /**
  33819. * Increase the number of facets and hence vertices in a mesh
  33820. * Vertex normals are interpolated from existing vertex normals
  33821. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  33822. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  33823. */
  33824. increaseVertices(numberPerEdge: number): void;
  33825. /**
  33826. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  33827. * This will undo any application of covertToFlatShadedMesh
  33828. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  33829. */
  33830. forceSharedVertices(): void;
  33831. /** @hidden */
  33832. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  33833. /** @hidden */
  33834. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  33835. /**
  33836. * Creates a new InstancedMesh object from the mesh model.
  33837. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  33838. * @param name defines the name of the new instance
  33839. * @returns a new InstancedMesh
  33840. */
  33841. createInstance(name: string): InstancedMesh;
  33842. /**
  33843. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  33844. * After this call, all the mesh instances have the same submeshes than the current mesh.
  33845. * @returns the current mesh
  33846. */
  33847. synchronizeInstances(): Mesh;
  33848. /**
  33849. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  33850. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  33851. * This should be used together with the simplification to avoid disappearing triangles.
  33852. * @param successCallback an optional success callback to be called after the optimization finished.
  33853. * @returns the current mesh
  33854. */
  33855. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  33856. /**
  33857. * Serialize current mesh
  33858. * @param serializationObject defines the object which will receive the serialization data
  33859. */
  33860. serialize(serializationObject: any): void;
  33861. /** @hidden */
  33862. _syncGeometryWithMorphTargetManager(): void;
  33863. /** @hidden */
  33864. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  33865. /**
  33866. * Returns a new Mesh object parsed from the source provided.
  33867. * @param parsedMesh is the source
  33868. * @param scene defines the hosting scene
  33869. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  33870. * @returns a new Mesh
  33871. */
  33872. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  33873. /**
  33874. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  33875. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  33876. * @param name defines the name of the mesh to create
  33877. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  33878. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  33879. * @param closePath creates a seam between the first and the last points of each path of the path array
  33880. * @param offset is taken in account only if the `pathArray` is containing a single path
  33881. * @param scene defines the hosting scene
  33882. * @param updatable defines if the mesh must be flagged as updatable
  33883. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33884. * @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)
  33885. * @returns a new Mesh
  33886. */
  33887. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  33888. /**
  33889. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  33890. * @param name defines the name of the mesh to create
  33891. * @param radius sets the radius size (float) of the polygon (default 0.5)
  33892. * @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
  33893. * @param scene defines the hosting scene
  33894. * @param updatable defines if the mesh must be flagged as updatable
  33895. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33896. * @returns a new Mesh
  33897. */
  33898. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  33899. /**
  33900. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  33901. * @param name defines the name of the mesh to create
  33902. * @param size sets the size (float) of each box side (default 1)
  33903. * @param scene defines the hosting scene
  33904. * @param updatable defines if the mesh must be flagged as updatable
  33905. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33906. * @returns a new Mesh
  33907. */
  33908. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  33909. /**
  33910. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  33911. * @param name defines the name of the mesh to create
  33912. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  33913. * @param diameter sets the diameter size (float) of the sphere (default 1)
  33914. * @param scene defines the hosting scene
  33915. * @param updatable defines if the mesh must be flagged as updatable
  33916. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33917. * @returns a new Mesh
  33918. */
  33919. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  33920. /**
  33921. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  33922. * @param name defines the name of the mesh to create
  33923. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  33924. * @param diameter sets the diameter size (float) of the sphere (default 1)
  33925. * @param scene defines the hosting scene
  33926. * @returns a new Mesh
  33927. */
  33928. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  33929. /**
  33930. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  33931. * @param name defines the name of the mesh to create
  33932. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  33933. * @param diameterTop set the top cap diameter (floats, default 1)
  33934. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  33935. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  33936. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  33937. * @param scene defines the hosting scene
  33938. * @param updatable defines if the mesh must be flagged as updatable
  33939. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33940. * @returns a new Mesh
  33941. */
  33942. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  33943. /**
  33944. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  33945. * @param name defines the name of the mesh to create
  33946. * @param diameter sets the diameter size (float) of the torus (default 1)
  33947. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  33948. * @param tessellation sets the number of torus sides (postive integer, default 16)
  33949. * @param scene defines the hosting scene
  33950. * @param updatable defines if the mesh must be flagged as updatable
  33951. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33952. * @returns a new Mesh
  33953. */
  33954. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  33955. /**
  33956. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  33957. * @param name defines the name of the mesh to create
  33958. * @param radius sets the global radius size (float) of the torus knot (default 2)
  33959. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  33960. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  33961. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  33962. * @param p the number of windings on X axis (positive integers, default 2)
  33963. * @param q the number of windings on Y axis (positive integers, default 3)
  33964. * @param scene defines the hosting scene
  33965. * @param updatable defines if the mesh must be flagged as updatable
  33966. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33967. * @returns a new Mesh
  33968. */
  33969. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  33970. /**
  33971. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  33972. * @param name defines the name of the mesh to create
  33973. * @param points is an array successive Vector3
  33974. * @param scene defines the hosting scene
  33975. * @param updatable defines if the mesh must be flagged as updatable
  33976. * @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).
  33977. * @returns a new Mesh
  33978. */
  33979. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  33980. /**
  33981. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  33982. * @param name defines the name of the mesh to create
  33983. * @param points is an array successive Vector3
  33984. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  33985. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  33986. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  33987. * @param scene defines the hosting scene
  33988. * @param updatable defines if the mesh must be flagged as updatable
  33989. * @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)
  33990. * @returns a new Mesh
  33991. */
  33992. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  33993. /**
  33994. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  33995. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  33996. * 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.
  33997. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  33998. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  33999. * Remember you can only change the shape positions, not their number when updating a polygon.
  34000. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  34001. * @param name defines the name of the mesh to create
  34002. * @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
  34003. * @param scene defines the hosting scene
  34004. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  34005. * @param updatable defines if the mesh must be flagged as updatable
  34006. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34007. * @param earcutInjection can be used to inject your own earcut reference
  34008. * @returns a new Mesh
  34009. */
  34010. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  34011. /**
  34012. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  34013. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  34014. * @param name defines the name of the mesh to create
  34015. * @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
  34016. * @param depth defines the height of extrusion
  34017. * @param scene defines the hosting scene
  34018. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  34019. * @param updatable defines if the mesh must be flagged as updatable
  34020. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34021. * @param earcutInjection can be used to inject your own earcut reference
  34022. * @returns a new Mesh
  34023. */
  34024. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  34025. /**
  34026. * Creates an extruded shape mesh.
  34027. * 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
  34028. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  34029. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  34030. * @param name defines the name of the mesh to create
  34031. * @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
  34032. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  34033. * @param scale is the value to scale the shape
  34034. * @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
  34035. * @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
  34036. * @param scene defines the hosting scene
  34037. * @param updatable defines if the mesh must be flagged as updatable
  34038. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34039. * @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)
  34040. * @returns a new Mesh
  34041. */
  34042. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  34043. /**
  34044. * Creates an custom extruded shape mesh.
  34045. * The custom extrusion is a parametric shape.
  34046. * It has no predefined shape. Its final shape will depend on the input parameters.
  34047. * Please consider using the same method from the MeshBuilder class instead
  34048. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  34049. * @param name defines the name of the mesh to create
  34050. * @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
  34051. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  34052. * @param scaleFunction is a custom Javascript function called on each path point
  34053. * @param rotationFunction is a custom Javascript function called on each path point
  34054. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  34055. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  34056. * @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
  34057. * @param scene defines the hosting scene
  34058. * @param updatable defines if the mesh must be flagged as updatable
  34059. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34060. * @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)
  34061. * @returns a new Mesh
  34062. */
  34063. 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;
  34064. /**
  34065. * Creates lathe mesh.
  34066. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  34067. * Please consider using the same method from the MeshBuilder class instead
  34068. * @param name defines the name of the mesh to create
  34069. * @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
  34070. * @param radius is the radius value of the lathe
  34071. * @param tessellation is the side number of the lathe.
  34072. * @param scene defines the hosting scene
  34073. * @param updatable defines if the mesh must be flagged as updatable
  34074. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34075. * @returns a new Mesh
  34076. */
  34077. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  34078. /**
  34079. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  34080. * @param name defines the name of the mesh to create
  34081. * @param size sets the size (float) of both sides of the plane at once (default 1)
  34082. * @param scene defines the hosting scene
  34083. * @param updatable defines if the mesh must be flagged as updatable
  34084. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34085. * @returns a new Mesh
  34086. */
  34087. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  34088. /**
  34089. * Creates a ground mesh.
  34090. * Please consider using the same method from the MeshBuilder class instead
  34091. * @param name defines the name of the mesh to create
  34092. * @param width set the width of the ground
  34093. * @param height set the height of the ground
  34094. * @param subdivisions sets the number of subdivisions per side
  34095. * @param scene defines the hosting scene
  34096. * @param updatable defines if the mesh must be flagged as updatable
  34097. * @returns a new Mesh
  34098. */
  34099. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  34100. /**
  34101. * Creates a tiled ground mesh.
  34102. * Please consider using the same method from the MeshBuilder class instead
  34103. * @param name defines the name of the mesh to create
  34104. * @param xmin set the ground minimum X coordinate
  34105. * @param zmin set the ground minimum Y coordinate
  34106. * @param xmax set the ground maximum X coordinate
  34107. * @param zmax set the ground maximum Z coordinate
  34108. * @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
  34109. * @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
  34110. * @param scene defines the hosting scene
  34111. * @param updatable defines if the mesh must be flagged as updatable
  34112. * @returns a new Mesh
  34113. */
  34114. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  34115. w: number;
  34116. h: number;
  34117. }, precision: {
  34118. w: number;
  34119. h: number;
  34120. }, scene: Scene, updatable?: boolean): Mesh;
  34121. /**
  34122. * Creates a ground mesh from a height map.
  34123. * Please consider using the same method from the MeshBuilder class instead
  34124. * @see https://doc.babylonjs.com/babylon101/height_map
  34125. * @param name defines the name of the mesh to create
  34126. * @param url sets the URL of the height map image resource
  34127. * @param width set the ground width size
  34128. * @param height set the ground height size
  34129. * @param subdivisions sets the number of subdivision per side
  34130. * @param minHeight is the minimum altitude on the ground
  34131. * @param maxHeight is the maximum altitude on the ground
  34132. * @param scene defines the hosting scene
  34133. * @param updatable defines if the mesh must be flagged as updatable
  34134. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  34135. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  34136. * @returns a new Mesh
  34137. */
  34138. 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;
  34139. /**
  34140. * Creates a tube mesh.
  34141. * The tube is a parametric shape.
  34142. * It has no predefined shape. Its final shape will depend on the input parameters.
  34143. * Please consider using the same method from the MeshBuilder class instead
  34144. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  34145. * @param name defines the name of the mesh to create
  34146. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  34147. * @param radius sets the tube radius size
  34148. * @param tessellation is the number of sides on the tubular surface
  34149. * @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
  34150. * @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
  34151. * @param scene defines the hosting scene
  34152. * @param updatable defines if the mesh must be flagged as updatable
  34153. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34154. * @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)
  34155. * @returns a new Mesh
  34156. */
  34157. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  34158. (i: number, distance: number): number;
  34159. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  34160. /**
  34161. * Creates a polyhedron mesh.
  34162. * Please consider using the same method from the MeshBuilder class instead.
  34163. * * 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
  34164. * * The parameter `size` (positive float, default 1) sets the polygon size
  34165. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  34166. * * 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`
  34167. * * 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
  34168. * * 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)`)
  34169. * * 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
  34170. * * 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
  34171. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34172. * * 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
  34173. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  34174. * @param name defines the name of the mesh to create
  34175. * @param options defines the options used to create the mesh
  34176. * @param scene defines the hosting scene
  34177. * @returns a new Mesh
  34178. */
  34179. static CreatePolyhedron(name: string, options: {
  34180. type?: number;
  34181. size?: number;
  34182. sizeX?: number;
  34183. sizeY?: number;
  34184. sizeZ?: number;
  34185. custom?: any;
  34186. faceUV?: Vector4[];
  34187. faceColors?: Color4[];
  34188. updatable?: boolean;
  34189. sideOrientation?: number;
  34190. }, scene: Scene): Mesh;
  34191. /**
  34192. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  34193. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  34194. * * 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`)
  34195. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  34196. * * 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
  34197. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34198. * * 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
  34199. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  34200. * @param name defines the name of the mesh
  34201. * @param options defines the options used to create the mesh
  34202. * @param scene defines the hosting scene
  34203. * @returns a new Mesh
  34204. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  34205. */
  34206. static CreateIcoSphere(name: string, options: {
  34207. radius?: number;
  34208. flat?: boolean;
  34209. subdivisions?: number;
  34210. sideOrientation?: number;
  34211. updatable?: boolean;
  34212. }, scene: Scene): Mesh;
  34213. /**
  34214. * Creates a decal mesh.
  34215. * Please consider using the same method from the MeshBuilder class instead.
  34216. * A decal is a mesh usually applied as a model onto the surface of another mesh
  34217. * @param name defines the name of the mesh
  34218. * @param sourceMesh defines the mesh receiving the decal
  34219. * @param position sets the position of the decal in world coordinates
  34220. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  34221. * @param size sets the decal scaling
  34222. * @param angle sets the angle to rotate the decal
  34223. * @returns a new Mesh
  34224. */
  34225. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  34226. /** Creates a Capsule Mesh
  34227. * @param name defines the name of the mesh.
  34228. * @param options the constructors options used to shape the mesh.
  34229. * @param scene defines the scene the mesh is scoped to.
  34230. * @returns the capsule mesh
  34231. * @see https://doc.babylonjs.com/how_to/capsule_shape
  34232. */
  34233. static CreateCapsule(name: string, options: ICreateCapsuleOptions, scene: Scene): Mesh;
  34234. /**
  34235. * Prepare internal position array for software CPU skinning
  34236. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  34237. */
  34238. setPositionsForCPUSkinning(): Float32Array;
  34239. /**
  34240. * Prepare internal normal array for software CPU skinning
  34241. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  34242. */
  34243. setNormalsForCPUSkinning(): Float32Array;
  34244. /**
  34245. * Updates the vertex buffer by applying transformation from the bones
  34246. * @param skeleton defines the skeleton to apply to current mesh
  34247. * @returns the current mesh
  34248. */
  34249. applySkeleton(skeleton: Skeleton): Mesh;
  34250. /**
  34251. * 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
  34252. * @param meshes defines the list of meshes to scan
  34253. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  34254. */
  34255. static MinMax(meshes: AbstractMesh[]): {
  34256. min: Vector3;
  34257. max: Vector3;
  34258. };
  34259. /**
  34260. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  34261. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  34262. * @returns a vector3
  34263. */
  34264. static Center(meshesOrMinMaxVector: {
  34265. min: Vector3;
  34266. max: Vector3;
  34267. } | AbstractMesh[]): Vector3;
  34268. /**
  34269. * Merge the array of meshes into a single mesh for performance reasons.
  34270. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  34271. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  34272. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  34273. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  34274. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  34275. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  34276. * @returns a new mesh
  34277. */
  34278. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  34279. /** @hidden */
  34280. addInstance(instance: InstancedMesh): void;
  34281. /** @hidden */
  34282. removeInstance(instance: InstancedMesh): void;
  34283. }
  34284. }
  34285. declare module BABYLON {
  34286. /**
  34287. * The options Interface for creating a Capsule Mesh
  34288. */
  34289. export interface ICreateCapsuleOptions {
  34290. /** The Orientation of the capsule. Default : Vector3.Up() */
  34291. orientation?: Vector3;
  34292. /** Number of sub segments on the tube section of the capsule running parallel to orientation. */
  34293. subdivisions: number;
  34294. /** Number of cylindrical segments on the capsule. */
  34295. tessellation: number;
  34296. /** Height or Length of the capsule. */
  34297. height: number;
  34298. /** Radius of the capsule. */
  34299. radius: number;
  34300. /** Number of sub segments on the cap sections of the capsule running parallel to orientation. */
  34301. capSubdivisions: number;
  34302. /** Overwrite for the top radius. */
  34303. radiusTop?: number;
  34304. /** Overwrite for the bottom radius. */
  34305. radiusBottom?: number;
  34306. /** Overwrite for the top capSubdivisions. */
  34307. topCapSubdivisions?: number;
  34308. /** Overwrite for the bottom capSubdivisions. */
  34309. bottomCapSubdivisions?: number;
  34310. }
  34311. /**
  34312. * Class containing static functions to help procedurally build meshes
  34313. */
  34314. export class CapsuleBuilder {
  34315. /**
  34316. * Creates a capsule or a pill mesh
  34317. * @param name defines the name of the mesh
  34318. * @param options The constructors options.
  34319. * @param scene The scene the mesh is scoped to.
  34320. * @returns Capsule Mesh
  34321. */
  34322. static CreateCapsule(name: string, options: ICreateCapsuleOptions | undefined, scene: any): Mesh;
  34323. }
  34324. }
  34325. declare module BABYLON {
  34326. /**
  34327. * Define an interface for all classes that will get and set the data on vertices
  34328. */
  34329. export interface IGetSetVerticesData {
  34330. /**
  34331. * Gets a boolean indicating if specific vertex data is present
  34332. * @param kind defines the vertex data kind to use
  34333. * @returns true is data kind is present
  34334. */
  34335. isVerticesDataPresent(kind: string): boolean;
  34336. /**
  34337. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  34338. * @param kind defines the data kind (Position, normal, etc...)
  34339. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  34340. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  34341. * @returns a float array containing vertex data
  34342. */
  34343. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  34344. /**
  34345. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  34346. * @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.
  34347. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  34348. * @returns the indices array or an empty array if the mesh has no geometry
  34349. */
  34350. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  34351. /**
  34352. * Set specific vertex data
  34353. * @param kind defines the data kind (Position, normal, etc...)
  34354. * @param data defines the vertex data to use
  34355. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  34356. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  34357. */
  34358. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  34359. /**
  34360. * Update a specific associated vertex buffer
  34361. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  34362. * - VertexBuffer.PositionKind
  34363. * - VertexBuffer.UVKind
  34364. * - VertexBuffer.UV2Kind
  34365. * - VertexBuffer.UV3Kind
  34366. * - VertexBuffer.UV4Kind
  34367. * - VertexBuffer.UV5Kind
  34368. * - VertexBuffer.UV6Kind
  34369. * - VertexBuffer.ColorKind
  34370. * - VertexBuffer.MatricesIndicesKind
  34371. * - VertexBuffer.MatricesIndicesExtraKind
  34372. * - VertexBuffer.MatricesWeightsKind
  34373. * - VertexBuffer.MatricesWeightsExtraKind
  34374. * @param data defines the data source
  34375. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  34376. * @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)
  34377. */
  34378. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  34379. /**
  34380. * Creates a new index buffer
  34381. * @param indices defines the indices to store in the index buffer
  34382. * @param totalVertices defines the total number of vertices (could be null)
  34383. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  34384. */
  34385. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  34386. }
  34387. /**
  34388. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  34389. */
  34390. export class VertexData {
  34391. /**
  34392. * Mesh side orientation : usually the external or front surface
  34393. */
  34394. static readonly FRONTSIDE: number;
  34395. /**
  34396. * Mesh side orientation : usually the internal or back surface
  34397. */
  34398. static readonly BACKSIDE: number;
  34399. /**
  34400. * Mesh side orientation : both internal and external or front and back surfaces
  34401. */
  34402. static readonly DOUBLESIDE: number;
  34403. /**
  34404. * Mesh side orientation : by default, `FRONTSIDE`
  34405. */
  34406. static readonly DEFAULTSIDE: number;
  34407. /**
  34408. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  34409. */
  34410. positions: Nullable<FloatArray>;
  34411. /**
  34412. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  34413. */
  34414. normals: Nullable<FloatArray>;
  34415. /**
  34416. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  34417. */
  34418. tangents: Nullable<FloatArray>;
  34419. /**
  34420. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  34421. */
  34422. uvs: Nullable<FloatArray>;
  34423. /**
  34424. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  34425. */
  34426. uvs2: Nullable<FloatArray>;
  34427. /**
  34428. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  34429. */
  34430. uvs3: Nullable<FloatArray>;
  34431. /**
  34432. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  34433. */
  34434. uvs4: Nullable<FloatArray>;
  34435. /**
  34436. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  34437. */
  34438. uvs5: Nullable<FloatArray>;
  34439. /**
  34440. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  34441. */
  34442. uvs6: Nullable<FloatArray>;
  34443. /**
  34444. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  34445. */
  34446. colors: Nullable<FloatArray>;
  34447. /**
  34448. * 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).
  34449. */
  34450. matricesIndices: Nullable<FloatArray>;
  34451. /**
  34452. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  34453. */
  34454. matricesWeights: Nullable<FloatArray>;
  34455. /**
  34456. * An array extending the number of possible indices
  34457. */
  34458. matricesIndicesExtra: Nullable<FloatArray>;
  34459. /**
  34460. * An array extending the number of possible weights when the number of indices is extended
  34461. */
  34462. matricesWeightsExtra: Nullable<FloatArray>;
  34463. /**
  34464. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  34465. */
  34466. indices: Nullable<IndicesArray>;
  34467. /**
  34468. * Uses the passed data array to set the set the values for the specified kind of data
  34469. * @param data a linear array of floating numbers
  34470. * @param kind the type of data that is being set, eg positions, colors etc
  34471. */
  34472. set(data: FloatArray, kind: string): void;
  34473. /**
  34474. * Associates the vertexData to the passed Mesh.
  34475. * Sets it as updatable or not (default `false`)
  34476. * @param mesh the mesh the vertexData is applied to
  34477. * @param updatable when used and having the value true allows new data to update the vertexData
  34478. * @returns the VertexData
  34479. */
  34480. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  34481. /**
  34482. * Associates the vertexData to the passed Geometry.
  34483. * Sets it as updatable or not (default `false`)
  34484. * @param geometry the geometry the vertexData is applied to
  34485. * @param updatable when used and having the value true allows new data to update the vertexData
  34486. * @returns VertexData
  34487. */
  34488. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  34489. /**
  34490. * Updates the associated mesh
  34491. * @param mesh the mesh to be updated
  34492. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  34493. * @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
  34494. * @returns VertexData
  34495. */
  34496. updateMesh(mesh: Mesh): VertexData;
  34497. /**
  34498. * Updates the associated geometry
  34499. * @param geometry the geometry to be updated
  34500. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  34501. * @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
  34502. * @returns VertexData.
  34503. */
  34504. updateGeometry(geometry: Geometry): VertexData;
  34505. private _applyTo;
  34506. private _update;
  34507. /**
  34508. * Transforms each position and each normal of the vertexData according to the passed Matrix
  34509. * @param matrix the transforming matrix
  34510. * @returns the VertexData
  34511. */
  34512. transform(matrix: Matrix): VertexData;
  34513. /**
  34514. * Merges the passed VertexData into the current one
  34515. * @param other the VertexData to be merged into the current one
  34516. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  34517. * @returns the modified VertexData
  34518. */
  34519. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  34520. private _mergeElement;
  34521. private _validate;
  34522. /**
  34523. * Serializes the VertexData
  34524. * @returns a serialized object
  34525. */
  34526. serialize(): any;
  34527. /**
  34528. * Extracts the vertexData from a mesh
  34529. * @param mesh the mesh from which to extract the VertexData
  34530. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  34531. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  34532. * @returns the object VertexData associated to the passed mesh
  34533. */
  34534. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  34535. /**
  34536. * Extracts the vertexData from the geometry
  34537. * @param geometry the geometry from which to extract the VertexData
  34538. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  34539. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  34540. * @returns the object VertexData associated to the passed mesh
  34541. */
  34542. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  34543. private static _ExtractFrom;
  34544. /**
  34545. * Creates the VertexData for a Ribbon
  34546. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  34547. * * pathArray array of paths, each of which an array of successive Vector3
  34548. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  34549. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  34550. * * 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
  34551. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34552. * * 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)
  34553. * * 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)
  34554. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  34555. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  34556. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  34557. * @returns the VertexData of the ribbon
  34558. */
  34559. static CreateRibbon(options: {
  34560. pathArray: Vector3[][];
  34561. closeArray?: boolean;
  34562. closePath?: boolean;
  34563. offset?: number;
  34564. sideOrientation?: number;
  34565. frontUVs?: Vector4;
  34566. backUVs?: Vector4;
  34567. invertUV?: boolean;
  34568. uvs?: Vector2[];
  34569. colors?: Color4[];
  34570. }): VertexData;
  34571. /**
  34572. * Creates the VertexData for a box
  34573. * @param options an object used to set the following optional parameters for the box, required but can be empty
  34574. * * size sets the width, height and depth of the box to the value of size, optional default 1
  34575. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  34576. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  34577. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  34578. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  34579. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  34580. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34581. * * 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)
  34582. * * 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)
  34583. * @returns the VertexData of the box
  34584. */
  34585. static CreateBox(options: {
  34586. size?: number;
  34587. width?: number;
  34588. height?: number;
  34589. depth?: number;
  34590. faceUV?: Vector4[];
  34591. faceColors?: Color4[];
  34592. sideOrientation?: number;
  34593. frontUVs?: Vector4;
  34594. backUVs?: Vector4;
  34595. }): VertexData;
  34596. /**
  34597. * Creates the VertexData for a tiled box
  34598. * @param options an object used to set the following optional parameters for the box, required but can be empty
  34599. * * faceTiles sets the pattern, tile size and number of tiles for a face
  34600. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  34601. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  34602. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34603. * @returns the VertexData of the box
  34604. */
  34605. static CreateTiledBox(options: {
  34606. pattern?: number;
  34607. width?: number;
  34608. height?: number;
  34609. depth?: number;
  34610. tileSize?: number;
  34611. tileWidth?: number;
  34612. tileHeight?: number;
  34613. alignHorizontal?: number;
  34614. alignVertical?: number;
  34615. faceUV?: Vector4[];
  34616. faceColors?: Color4[];
  34617. sideOrientation?: number;
  34618. }): VertexData;
  34619. /**
  34620. * Creates the VertexData for a tiled plane
  34621. * @param options an object used to set the following optional parameters for the box, required but can be empty
  34622. * * pattern a limited pattern arrangement depending on the number
  34623. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  34624. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  34625. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  34626. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34627. * * 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)
  34628. * * 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)
  34629. * @returns the VertexData of the tiled plane
  34630. */
  34631. static CreateTiledPlane(options: {
  34632. pattern?: number;
  34633. tileSize?: number;
  34634. tileWidth?: number;
  34635. tileHeight?: number;
  34636. size?: number;
  34637. width?: number;
  34638. height?: number;
  34639. alignHorizontal?: number;
  34640. alignVertical?: number;
  34641. sideOrientation?: number;
  34642. frontUVs?: Vector4;
  34643. backUVs?: Vector4;
  34644. }): VertexData;
  34645. /**
  34646. * Creates the VertexData for an ellipsoid, defaults to a sphere
  34647. * @param options an object used to set the following optional parameters for the box, required but can be empty
  34648. * * segments sets the number of horizontal strips optional, default 32
  34649. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  34650. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  34651. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  34652. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  34653. * * 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
  34654. * * 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
  34655. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34656. * * 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)
  34657. * * 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)
  34658. * @returns the VertexData of the ellipsoid
  34659. */
  34660. static CreateSphere(options: {
  34661. segments?: number;
  34662. diameter?: number;
  34663. diameterX?: number;
  34664. diameterY?: number;
  34665. diameterZ?: number;
  34666. arc?: number;
  34667. slice?: number;
  34668. sideOrientation?: number;
  34669. frontUVs?: Vector4;
  34670. backUVs?: Vector4;
  34671. }): VertexData;
  34672. /**
  34673. * Creates the VertexData for a cylinder, cone or prism
  34674. * @param options an object used to set the following optional parameters for the box, required but can be empty
  34675. * * height sets the height (y direction) of the cylinder, optional, default 2
  34676. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  34677. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  34678. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  34679. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  34680. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  34681. * * 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
  34682. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  34683. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  34684. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  34685. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  34686. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34687. * * 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)
  34688. * * 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)
  34689. * @returns the VertexData of the cylinder, cone or prism
  34690. */
  34691. static CreateCylinder(options: {
  34692. height?: number;
  34693. diameterTop?: number;
  34694. diameterBottom?: number;
  34695. diameter?: number;
  34696. tessellation?: number;
  34697. subdivisions?: number;
  34698. arc?: number;
  34699. faceColors?: Color4[];
  34700. faceUV?: Vector4[];
  34701. hasRings?: boolean;
  34702. enclose?: boolean;
  34703. sideOrientation?: number;
  34704. frontUVs?: Vector4;
  34705. backUVs?: Vector4;
  34706. }): VertexData;
  34707. /**
  34708. * Creates the VertexData for a torus
  34709. * @param options an object used to set the following optional parameters for the box, required but can be empty
  34710. * * diameter the diameter of the torus, optional default 1
  34711. * * thickness the diameter of the tube forming the torus, optional default 0.5
  34712. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  34713. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34714. * * 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)
  34715. * * 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)
  34716. * @returns the VertexData of the torus
  34717. */
  34718. static CreateTorus(options: {
  34719. diameter?: number;
  34720. thickness?: number;
  34721. tessellation?: number;
  34722. sideOrientation?: number;
  34723. frontUVs?: Vector4;
  34724. backUVs?: Vector4;
  34725. }): VertexData;
  34726. /**
  34727. * Creates the VertexData of the LineSystem
  34728. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  34729. * - lines an array of lines, each line being an array of successive Vector3
  34730. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  34731. * @returns the VertexData of the LineSystem
  34732. */
  34733. static CreateLineSystem(options: {
  34734. lines: Vector3[][];
  34735. colors?: Nullable<Color4[][]>;
  34736. }): VertexData;
  34737. /**
  34738. * Create the VertexData for a DashedLines
  34739. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  34740. * - points an array successive Vector3
  34741. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  34742. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  34743. * - dashNb the intended total number of dashes, optional, default 200
  34744. * @returns the VertexData for the DashedLines
  34745. */
  34746. static CreateDashedLines(options: {
  34747. points: Vector3[];
  34748. dashSize?: number;
  34749. gapSize?: number;
  34750. dashNb?: number;
  34751. }): VertexData;
  34752. /**
  34753. * Creates the VertexData for a Ground
  34754. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  34755. * - width the width (x direction) of the ground, optional, default 1
  34756. * - height the height (z direction) of the ground, optional, default 1
  34757. * - subdivisions the number of subdivisions per side, optional, default 1
  34758. * @returns the VertexData of the Ground
  34759. */
  34760. static CreateGround(options: {
  34761. width?: number;
  34762. height?: number;
  34763. subdivisions?: number;
  34764. subdivisionsX?: number;
  34765. subdivisionsY?: number;
  34766. }): VertexData;
  34767. /**
  34768. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  34769. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  34770. * * xmin the ground minimum X coordinate, optional, default -1
  34771. * * zmin the ground minimum Z coordinate, optional, default -1
  34772. * * xmax the ground maximum X coordinate, optional, default 1
  34773. * * zmax the ground maximum Z coordinate, optional, default 1
  34774. * * 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}
  34775. * * 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}
  34776. * @returns the VertexData of the TiledGround
  34777. */
  34778. static CreateTiledGround(options: {
  34779. xmin: number;
  34780. zmin: number;
  34781. xmax: number;
  34782. zmax: number;
  34783. subdivisions?: {
  34784. w: number;
  34785. h: number;
  34786. };
  34787. precision?: {
  34788. w: number;
  34789. h: number;
  34790. };
  34791. }): VertexData;
  34792. /**
  34793. * Creates the VertexData of the Ground designed from a heightmap
  34794. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  34795. * * width the width (x direction) of the ground
  34796. * * height the height (z direction) of the ground
  34797. * * subdivisions the number of subdivisions per side
  34798. * * minHeight the minimum altitude on the ground, optional, default 0
  34799. * * maxHeight the maximum altitude on the ground, optional default 1
  34800. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  34801. * * buffer the array holding the image color data
  34802. * * bufferWidth the width of image
  34803. * * bufferHeight the height of image
  34804. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  34805. * @returns the VertexData of the Ground designed from a heightmap
  34806. */
  34807. static CreateGroundFromHeightMap(options: {
  34808. width: number;
  34809. height: number;
  34810. subdivisions: number;
  34811. minHeight: number;
  34812. maxHeight: number;
  34813. colorFilter: Color3;
  34814. buffer: Uint8Array;
  34815. bufferWidth: number;
  34816. bufferHeight: number;
  34817. alphaFilter: number;
  34818. }): VertexData;
  34819. /**
  34820. * Creates the VertexData for a Plane
  34821. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  34822. * * size sets the width and height of the plane to the value of size, optional default 1
  34823. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  34824. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  34825. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34826. * * 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)
  34827. * * 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)
  34828. * @returns the VertexData of the box
  34829. */
  34830. static CreatePlane(options: {
  34831. size?: number;
  34832. width?: number;
  34833. height?: number;
  34834. sideOrientation?: number;
  34835. frontUVs?: Vector4;
  34836. backUVs?: Vector4;
  34837. }): VertexData;
  34838. /**
  34839. * Creates the VertexData of the Disc or regular Polygon
  34840. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  34841. * * radius the radius of the disc, optional default 0.5
  34842. * * tessellation the number of polygon sides, optional, default 64
  34843. * * 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
  34844. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34845. * * 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)
  34846. * * 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)
  34847. * @returns the VertexData of the box
  34848. */
  34849. static CreateDisc(options: {
  34850. radius?: number;
  34851. tessellation?: number;
  34852. arc?: number;
  34853. sideOrientation?: number;
  34854. frontUVs?: Vector4;
  34855. backUVs?: Vector4;
  34856. }): VertexData;
  34857. /**
  34858. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  34859. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  34860. * @param polygon a mesh built from polygonTriangulation.build()
  34861. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34862. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  34863. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  34864. * @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)
  34865. * @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)
  34866. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  34867. * @returns the VertexData of the Polygon
  34868. */
  34869. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  34870. /**
  34871. * Creates the VertexData of the IcoSphere
  34872. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  34873. * * radius the radius of the IcoSphere, optional default 1
  34874. * * radiusX allows stretching in the x direction, optional, default radius
  34875. * * radiusY allows stretching in the y direction, optional, default radius
  34876. * * radiusZ allows stretching in the z direction, optional, default radius
  34877. * * flat when true creates a flat shaded mesh, optional, default true
  34878. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  34879. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34880. * * 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)
  34881. * * 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)
  34882. * @returns the VertexData of the IcoSphere
  34883. */
  34884. static CreateIcoSphere(options: {
  34885. radius?: number;
  34886. radiusX?: number;
  34887. radiusY?: number;
  34888. radiusZ?: number;
  34889. flat?: boolean;
  34890. subdivisions?: number;
  34891. sideOrientation?: number;
  34892. frontUVs?: Vector4;
  34893. backUVs?: Vector4;
  34894. }): VertexData;
  34895. /**
  34896. * Creates the VertexData for a Polyhedron
  34897. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  34898. * * type provided types are:
  34899. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  34900. * * 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)
  34901. * * size the size of the IcoSphere, optional default 1
  34902. * * sizeX allows stretching in the x direction, optional, default size
  34903. * * sizeY allows stretching in the y direction, optional, default size
  34904. * * sizeZ allows stretching in the z direction, optional, default size
  34905. * * 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
  34906. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  34907. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  34908. * * flat when true creates a flat shaded mesh, optional, default true
  34909. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  34910. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34911. * * 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)
  34912. * * 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)
  34913. * @returns the VertexData of the Polyhedron
  34914. */
  34915. static CreatePolyhedron(options: {
  34916. type?: number;
  34917. size?: number;
  34918. sizeX?: number;
  34919. sizeY?: number;
  34920. sizeZ?: number;
  34921. custom?: any;
  34922. faceUV?: Vector4[];
  34923. faceColors?: Color4[];
  34924. flat?: boolean;
  34925. sideOrientation?: number;
  34926. frontUVs?: Vector4;
  34927. backUVs?: Vector4;
  34928. }): VertexData;
  34929. /**
  34930. * Creates the VertexData for a Capsule, inspired from https://github.com/maximeq/three-js-capsule-geometry/blob/master/src/CapsuleBufferGeometry.js
  34931. * @param options an object used to set the following optional parameters for the capsule, required but can be empty
  34932. * @returns the VertexData of the Capsule
  34933. */
  34934. static CreateCapsule(options?: ICreateCapsuleOptions): VertexData;
  34935. /**
  34936. * Creates the VertexData for a TorusKnot
  34937. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  34938. * * radius the radius of the torus knot, optional, default 2
  34939. * * tube the thickness of the tube, optional, default 0.5
  34940. * * radialSegments the number of sides on each tube segments, optional, default 32
  34941. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  34942. * * p the number of windings around the z axis, optional, default 2
  34943. * * q the number of windings around the x axis, optional, default 3
  34944. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34945. * * 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)
  34946. * * 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)
  34947. * @returns the VertexData of the Torus Knot
  34948. */
  34949. static CreateTorusKnot(options: {
  34950. radius?: number;
  34951. tube?: number;
  34952. radialSegments?: number;
  34953. tubularSegments?: number;
  34954. p?: number;
  34955. q?: number;
  34956. sideOrientation?: number;
  34957. frontUVs?: Vector4;
  34958. backUVs?: Vector4;
  34959. }): VertexData;
  34960. /**
  34961. * Compute normals for given positions and indices
  34962. * @param positions an array of vertex positions, [...., x, y, z, ......]
  34963. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  34964. * @param normals an array of vertex normals, [...., x, y, z, ......]
  34965. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  34966. * * facetNormals : optional array of facet normals (vector3)
  34967. * * facetPositions : optional array of facet positions (vector3)
  34968. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  34969. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  34970. * * bInfo : optional bounding info, required for facetPartitioning computation
  34971. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  34972. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  34973. * * useRightHandedSystem: optional boolean to for right handed system computation
  34974. * * depthSort : optional boolean to enable the facet depth sort computation
  34975. * * distanceTo : optional Vector3 to compute the facet depth from this location
  34976. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  34977. */
  34978. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  34979. facetNormals?: any;
  34980. facetPositions?: any;
  34981. facetPartitioning?: any;
  34982. ratio?: number;
  34983. bInfo?: any;
  34984. bbSize?: Vector3;
  34985. subDiv?: any;
  34986. useRightHandedSystem?: boolean;
  34987. depthSort?: boolean;
  34988. distanceTo?: Vector3;
  34989. depthSortedFacets?: any;
  34990. }): void;
  34991. /** @hidden */
  34992. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  34993. /**
  34994. * Applies VertexData created from the imported parameters to the geometry
  34995. * @param parsedVertexData the parsed data from an imported file
  34996. * @param geometry the geometry to apply the VertexData to
  34997. */
  34998. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  34999. }
  35000. }
  35001. declare module BABYLON {
  35002. /**
  35003. * Class containing static functions to help procedurally build meshes
  35004. */
  35005. export class DiscBuilder {
  35006. /**
  35007. * Creates a plane polygonal mesh. By default, this is a disc
  35008. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  35009. * * 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
  35010. * * 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
  35011. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  35012. * * 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
  35013. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  35014. * @param name defines the name of the mesh
  35015. * @param options defines the options used to create the mesh
  35016. * @param scene defines the hosting scene
  35017. * @returns the plane polygonal mesh
  35018. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  35019. */
  35020. static CreateDisc(name: string, options: {
  35021. radius?: number;
  35022. tessellation?: number;
  35023. arc?: number;
  35024. updatable?: boolean;
  35025. sideOrientation?: number;
  35026. frontUVs?: Vector4;
  35027. backUVs?: Vector4;
  35028. }, scene?: Nullable<Scene>): Mesh;
  35029. }
  35030. }
  35031. declare module BABYLON {
  35032. /**
  35033. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  35034. *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.
  35035. * The SPS is also a particle system. It provides some methods to manage the particles.
  35036. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  35037. *
  35038. * Full documentation here : https://doc.babylonjs.com/how_to/Solid_Particle_System
  35039. */
  35040. export class SolidParticleSystem implements IDisposable {
  35041. /**
  35042. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  35043. * Example : var p = SPS.particles[i];
  35044. */
  35045. particles: SolidParticle[];
  35046. /**
  35047. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  35048. */
  35049. nbParticles: number;
  35050. /**
  35051. * If the particles must ever face the camera (default false). Useful for planar particles.
  35052. */
  35053. billboard: boolean;
  35054. /**
  35055. * Recompute normals when adding a shape
  35056. */
  35057. recomputeNormals: boolean;
  35058. /**
  35059. * This a counter ofr your own usage. It's not set by any SPS functions.
  35060. */
  35061. counter: number;
  35062. /**
  35063. * The SPS name. This name is also given to the underlying mesh.
  35064. */
  35065. name: string;
  35066. /**
  35067. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  35068. */
  35069. mesh: Mesh;
  35070. /**
  35071. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  35072. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  35073. */
  35074. vars: any;
  35075. /**
  35076. * This array is populated when the SPS is set as 'pickable'.
  35077. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  35078. * Each element of this array is an object `{idx: int, faceId: int}`.
  35079. * `idx` is the picked particle index in the `SPS.particles` array
  35080. * `faceId` is the picked face index counted within this particle.
  35081. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  35082. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  35083. * Use the method SPS.pickedParticle(pickingInfo) instead.
  35084. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  35085. */
  35086. pickedParticles: {
  35087. idx: number;
  35088. faceId: number;
  35089. }[];
  35090. /**
  35091. * This array is populated when the SPS is set as 'pickable'
  35092. * Each key of this array is a submesh index.
  35093. * Each element of this array is a second array defined like this :
  35094. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  35095. * Each element of this second array is an object `{idx: int, faceId: int}`.
  35096. * `idx` is the picked particle index in the `SPS.particles` array
  35097. * `faceId` is the picked face index counted within this particle.
  35098. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  35099. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  35100. */
  35101. pickedBySubMesh: {
  35102. idx: number;
  35103. faceId: number;
  35104. }[][];
  35105. /**
  35106. * This array is populated when `enableDepthSort` is set to true.
  35107. * Each element of this array is an instance of the class DepthSortedParticle.
  35108. */
  35109. depthSortedParticles: DepthSortedParticle[];
  35110. /**
  35111. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  35112. * @hidden
  35113. */
  35114. _bSphereOnly: boolean;
  35115. /**
  35116. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  35117. * @hidden
  35118. */
  35119. _bSphereRadiusFactor: number;
  35120. private _scene;
  35121. private _positions;
  35122. private _indices;
  35123. private _normals;
  35124. private _colors;
  35125. private _uvs;
  35126. private _indices32;
  35127. private _positions32;
  35128. private _normals32;
  35129. private _fixedNormal32;
  35130. private _colors32;
  35131. private _uvs32;
  35132. private _index;
  35133. private _updatable;
  35134. private _pickable;
  35135. private _isVisibilityBoxLocked;
  35136. private _alwaysVisible;
  35137. private _depthSort;
  35138. private _expandable;
  35139. private _shapeCounter;
  35140. private _copy;
  35141. private _color;
  35142. private _computeParticleColor;
  35143. private _computeParticleTexture;
  35144. private _computeParticleRotation;
  35145. private _computeParticleVertex;
  35146. private _computeBoundingBox;
  35147. private _depthSortParticles;
  35148. private _camera;
  35149. private _mustUnrotateFixedNormals;
  35150. private _particlesIntersect;
  35151. private _needs32Bits;
  35152. private _isNotBuilt;
  35153. private _lastParticleId;
  35154. private _idxOfId;
  35155. private _multimaterialEnabled;
  35156. private _useModelMaterial;
  35157. private _indicesByMaterial;
  35158. private _materialIndexes;
  35159. private _depthSortFunction;
  35160. private _materialSortFunction;
  35161. private _materials;
  35162. private _multimaterial;
  35163. private _materialIndexesById;
  35164. private _defaultMaterial;
  35165. private _autoUpdateSubMeshes;
  35166. private _tmpVertex;
  35167. /**
  35168. * Creates a SPS (Solid Particle System) object.
  35169. * @param name (String) is the SPS name, this will be the underlying mesh name.
  35170. * @param scene (Scene) is the scene in which the SPS is added.
  35171. * @param options defines the options of the sps e.g.
  35172. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  35173. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  35174. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  35175. * * 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.
  35176. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  35177. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  35178. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  35179. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  35180. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  35181. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  35182. */
  35183. constructor(name: string, scene: Scene, options?: {
  35184. updatable?: boolean;
  35185. isPickable?: boolean;
  35186. enableDepthSort?: boolean;
  35187. particleIntersection?: boolean;
  35188. boundingSphereOnly?: boolean;
  35189. bSphereRadiusFactor?: number;
  35190. expandable?: boolean;
  35191. useModelMaterial?: boolean;
  35192. enableMultiMaterial?: boolean;
  35193. });
  35194. /**
  35195. * Builds the SPS underlying mesh. Returns a standard Mesh.
  35196. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  35197. * @returns the created mesh
  35198. */
  35199. buildMesh(): Mesh;
  35200. /**
  35201. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  35202. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  35203. * Thus the particles generated from `digest()` have their property `position` set yet.
  35204. * @param mesh ( Mesh ) is the mesh to be digested
  35205. * @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
  35206. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  35207. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  35208. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  35209. * @returns the current SPS
  35210. */
  35211. digest(mesh: Mesh, options?: {
  35212. facetNb?: number;
  35213. number?: number;
  35214. delta?: number;
  35215. storage?: [];
  35216. }): SolidParticleSystem;
  35217. /**
  35218. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  35219. * @hidden
  35220. */
  35221. private _unrotateFixedNormals;
  35222. /**
  35223. * Resets the temporary working copy particle
  35224. * @hidden
  35225. */
  35226. private _resetCopy;
  35227. /**
  35228. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  35229. * @param p the current index in the positions array to be updated
  35230. * @param ind the current index in the indices array
  35231. * @param shape a Vector3 array, the shape geometry
  35232. * @param positions the positions array to be updated
  35233. * @param meshInd the shape indices array
  35234. * @param indices the indices array to be updated
  35235. * @param meshUV the shape uv array
  35236. * @param uvs the uv array to be updated
  35237. * @param meshCol the shape color array
  35238. * @param colors the color array to be updated
  35239. * @param meshNor the shape normals array
  35240. * @param normals the normals array to be updated
  35241. * @param idx the particle index
  35242. * @param idxInShape the particle index in its shape
  35243. * @param options the addShape() method passed options
  35244. * @model the particle model
  35245. * @hidden
  35246. */
  35247. private _meshBuilder;
  35248. /**
  35249. * Returns a shape Vector3 array from positions float array
  35250. * @param positions float array
  35251. * @returns a vector3 array
  35252. * @hidden
  35253. */
  35254. private _posToShape;
  35255. /**
  35256. * Returns a shapeUV array from a float uvs (array deep copy)
  35257. * @param uvs as a float array
  35258. * @returns a shapeUV array
  35259. * @hidden
  35260. */
  35261. private _uvsToShapeUV;
  35262. /**
  35263. * Adds a new particle object in the particles array
  35264. * @param idx particle index in particles array
  35265. * @param id particle id
  35266. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  35267. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  35268. * @param model particle ModelShape object
  35269. * @param shapeId model shape identifier
  35270. * @param idxInShape index of the particle in the current model
  35271. * @param bInfo model bounding info object
  35272. * @param storage target storage array, if any
  35273. * @hidden
  35274. */
  35275. private _addParticle;
  35276. /**
  35277. * Adds some particles to the SPS from the model shape. Returns the shape id.
  35278. * Please read the doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  35279. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  35280. * @param nb (positive integer) the number of particles to be created from this model
  35281. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  35282. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  35283. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  35284. * @returns the number of shapes in the system
  35285. */
  35286. addShape(mesh: Mesh, nb: number, options?: {
  35287. positionFunction?: any;
  35288. vertexFunction?: any;
  35289. storage?: [];
  35290. }): number;
  35291. /**
  35292. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  35293. * @hidden
  35294. */
  35295. private _rebuildParticle;
  35296. /**
  35297. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  35298. * @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.
  35299. * @returns the SPS.
  35300. */
  35301. rebuildMesh(reset?: boolean): SolidParticleSystem;
  35302. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  35303. * Returns an array with the removed particles.
  35304. * 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.
  35305. * The SPS can't be empty so at least one particle needs to remain in place.
  35306. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  35307. * @param start index of the first particle to remove
  35308. * @param end index of the last particle to remove (included)
  35309. * @returns an array populated with the removed particles
  35310. */
  35311. removeParticles(start: number, end: number): SolidParticle[];
  35312. /**
  35313. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  35314. * @param solidParticleArray an array populated with Solid Particles objects
  35315. * @returns the SPS
  35316. */
  35317. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  35318. /**
  35319. * Creates a new particle and modifies the SPS mesh geometry :
  35320. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  35321. * - calls _addParticle() to populate the particle array
  35322. * factorized code from addShape() and insertParticlesFromArray()
  35323. * @param idx particle index in the particles array
  35324. * @param i particle index in its shape
  35325. * @param modelShape particle ModelShape object
  35326. * @param shape shape vertex array
  35327. * @param meshInd shape indices array
  35328. * @param meshUV shape uv array
  35329. * @param meshCol shape color array
  35330. * @param meshNor shape normals array
  35331. * @param bbInfo shape bounding info
  35332. * @param storage target particle storage
  35333. * @options addShape() passed options
  35334. * @hidden
  35335. */
  35336. private _insertNewParticle;
  35337. /**
  35338. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  35339. * This method calls `updateParticle()` for each particle of the SPS.
  35340. * For an animated SPS, it is usually called within the render loop.
  35341. * 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.
  35342. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  35343. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  35344. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  35345. * @returns the SPS.
  35346. */
  35347. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  35348. /**
  35349. * Disposes the SPS.
  35350. */
  35351. dispose(): void;
  35352. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  35353. * idx is the particle index in the SPS
  35354. * faceId is the picked face index counted within this particle.
  35355. * Returns null if the pickInfo can't identify a picked particle.
  35356. * @param pickingInfo (PickingInfo object)
  35357. * @returns {idx: number, faceId: number} or null
  35358. */
  35359. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  35360. idx: number;
  35361. faceId: number;
  35362. }>;
  35363. /**
  35364. * Returns a SolidParticle object from its identifier : particle.id
  35365. * @param id (integer) the particle Id
  35366. * @returns the searched particle or null if not found in the SPS.
  35367. */
  35368. getParticleById(id: number): Nullable<SolidParticle>;
  35369. /**
  35370. * Returns a new array populated with the particles having the passed shapeId.
  35371. * @param shapeId (integer) the shape identifier
  35372. * @returns a new solid particle array
  35373. */
  35374. getParticlesByShapeId(shapeId: number): SolidParticle[];
  35375. /**
  35376. * Populates the passed array "ref" with the particles having the passed shapeId.
  35377. * @param shapeId the shape identifier
  35378. * @returns the SPS
  35379. * @param ref
  35380. */
  35381. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  35382. /**
  35383. * Computes the required SubMeshes according the materials assigned to the particles.
  35384. * @returns the solid particle system.
  35385. * Does nothing if called before the SPS mesh is built.
  35386. */
  35387. computeSubMeshes(): SolidParticleSystem;
  35388. /**
  35389. * Sorts the solid particles by material when MultiMaterial is enabled.
  35390. * Updates the indices32 array.
  35391. * Updates the indicesByMaterial array.
  35392. * Updates the mesh indices array.
  35393. * @returns the SPS
  35394. * @hidden
  35395. */
  35396. private _sortParticlesByMaterial;
  35397. /**
  35398. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  35399. * @hidden
  35400. */
  35401. private _setMaterialIndexesById;
  35402. /**
  35403. * Returns an array with unique values of Materials from the passed array
  35404. * @param array the material array to be checked and filtered
  35405. * @hidden
  35406. */
  35407. private _filterUniqueMaterialId;
  35408. /**
  35409. * Sets a new Standard Material as _defaultMaterial if not already set.
  35410. * @hidden
  35411. */
  35412. private _setDefaultMaterial;
  35413. /**
  35414. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  35415. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  35416. * @returns the SPS.
  35417. */
  35418. refreshVisibleSize(): SolidParticleSystem;
  35419. /**
  35420. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  35421. * @param size the size (float) of the visibility box
  35422. * note : this doesn't lock the SPS mesh bounding box.
  35423. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  35424. */
  35425. setVisibilityBox(size: number): void;
  35426. /**
  35427. * Gets whether the SPS as always visible or not
  35428. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  35429. */
  35430. get isAlwaysVisible(): boolean;
  35431. /**
  35432. * Sets the SPS as always visible or not
  35433. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  35434. */
  35435. set isAlwaysVisible(val: boolean);
  35436. /**
  35437. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  35438. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  35439. */
  35440. set isVisibilityBoxLocked(val: boolean);
  35441. /**
  35442. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  35443. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  35444. */
  35445. get isVisibilityBoxLocked(): boolean;
  35446. /**
  35447. * Tells to `setParticles()` to compute the particle rotations or not.
  35448. * Default value : true. The SPS is faster when it's set to false.
  35449. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  35450. */
  35451. set computeParticleRotation(val: boolean);
  35452. /**
  35453. * Tells to `setParticles()` to compute the particle colors or not.
  35454. * Default value : true. The SPS is faster when it's set to false.
  35455. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  35456. */
  35457. set computeParticleColor(val: boolean);
  35458. set computeParticleTexture(val: boolean);
  35459. /**
  35460. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  35461. * Default value : false. The SPS is faster when it's set to false.
  35462. * Note : the particle custom vertex positions aren't stored values.
  35463. */
  35464. set computeParticleVertex(val: boolean);
  35465. /**
  35466. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  35467. */
  35468. set computeBoundingBox(val: boolean);
  35469. /**
  35470. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  35471. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  35472. * Default : `true`
  35473. */
  35474. set depthSortParticles(val: boolean);
  35475. /**
  35476. * Gets if `setParticles()` computes the particle rotations or not.
  35477. * Default value : true. The SPS is faster when it's set to false.
  35478. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  35479. */
  35480. get computeParticleRotation(): boolean;
  35481. /**
  35482. * Gets if `setParticles()` computes the particle colors or not.
  35483. * Default value : true. The SPS is faster when it's set to false.
  35484. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  35485. */
  35486. get computeParticleColor(): boolean;
  35487. /**
  35488. * Gets if `setParticles()` computes the particle textures or not.
  35489. * Default value : true. The SPS is faster when it's set to false.
  35490. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  35491. */
  35492. get computeParticleTexture(): boolean;
  35493. /**
  35494. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  35495. * Default value : false. The SPS is faster when it's set to false.
  35496. * Note : the particle custom vertex positions aren't stored values.
  35497. */
  35498. get computeParticleVertex(): boolean;
  35499. /**
  35500. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  35501. */
  35502. get computeBoundingBox(): boolean;
  35503. /**
  35504. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  35505. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  35506. * Default : `true`
  35507. */
  35508. get depthSortParticles(): boolean;
  35509. /**
  35510. * Gets if the SPS is created as expandable at construction time.
  35511. * Default : `false`
  35512. */
  35513. get expandable(): boolean;
  35514. /**
  35515. * Gets if the SPS supports the Multi Materials
  35516. */
  35517. get multimaterialEnabled(): boolean;
  35518. /**
  35519. * Gets if the SPS uses the model materials for its own multimaterial.
  35520. */
  35521. get useModelMaterial(): boolean;
  35522. /**
  35523. * The SPS used material array.
  35524. */
  35525. get materials(): Material[];
  35526. /**
  35527. * Sets the SPS MultiMaterial from the passed materials.
  35528. * Note : the passed array is internally copied and not used then by reference.
  35529. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  35530. */
  35531. setMultiMaterial(materials: Material[]): void;
  35532. /**
  35533. * The SPS computed multimaterial object
  35534. */
  35535. get multimaterial(): MultiMaterial;
  35536. set multimaterial(mm: MultiMaterial);
  35537. /**
  35538. * If the subMeshes must be updated on the next call to setParticles()
  35539. */
  35540. get autoUpdateSubMeshes(): boolean;
  35541. set autoUpdateSubMeshes(val: boolean);
  35542. /**
  35543. * This function does nothing. It may be overwritten to set all the particle first values.
  35544. * The SPS doesn't call this function, you may have to call it by your own.
  35545. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  35546. */
  35547. initParticles(): void;
  35548. /**
  35549. * This function does nothing. It may be overwritten to recycle a particle.
  35550. * The SPS doesn't call this function, you may have to call it by your own.
  35551. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  35552. * @param particle The particle to recycle
  35553. * @returns the recycled particle
  35554. */
  35555. recycleParticle(particle: SolidParticle): SolidParticle;
  35556. /**
  35557. * Updates a particle : this function should be overwritten by the user.
  35558. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  35559. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  35560. * @example : just set a particle position or velocity and recycle conditions
  35561. * @param particle The particle to update
  35562. * @returns the updated particle
  35563. */
  35564. updateParticle(particle: SolidParticle): SolidParticle;
  35565. /**
  35566. * Updates a vertex of a particle : it can be overwritten by the user.
  35567. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  35568. * @param particle the current particle
  35569. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  35570. * @param pt the index of the current vertex in the particle shape
  35571. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  35572. * @example : just set a vertex particle position or color
  35573. * @returns the sps
  35574. */
  35575. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  35576. /**
  35577. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  35578. * This does nothing and may be overwritten by the user.
  35579. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  35580. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  35581. * @param update the boolean update value actually passed to setParticles()
  35582. */
  35583. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  35584. /**
  35585. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  35586. * This will be passed three parameters.
  35587. * This does nothing and may be overwritten by the user.
  35588. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  35589. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  35590. * @param update the boolean update value actually passed to setParticles()
  35591. */
  35592. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  35593. }
  35594. }
  35595. declare module BABYLON {
  35596. /**
  35597. * Represents one particle of a solid particle system.
  35598. */
  35599. export class SolidParticle {
  35600. /**
  35601. * particle global index
  35602. */
  35603. idx: number;
  35604. /**
  35605. * particle identifier
  35606. */
  35607. id: number;
  35608. /**
  35609. * The color of the particle
  35610. */
  35611. color: Nullable<Color4>;
  35612. /**
  35613. * The world space position of the particle.
  35614. */
  35615. position: Vector3;
  35616. /**
  35617. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  35618. */
  35619. rotation: Vector3;
  35620. /**
  35621. * The world space rotation quaternion of the particle.
  35622. */
  35623. rotationQuaternion: Nullable<Quaternion>;
  35624. /**
  35625. * The scaling of the particle.
  35626. */
  35627. scaling: Vector3;
  35628. /**
  35629. * The uvs of the particle.
  35630. */
  35631. uvs: Vector4;
  35632. /**
  35633. * The current speed of the particle.
  35634. */
  35635. velocity: Vector3;
  35636. /**
  35637. * The pivot point in the particle local space.
  35638. */
  35639. pivot: Vector3;
  35640. /**
  35641. * Must the particle be translated from its pivot point in its local space ?
  35642. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  35643. * Default : false
  35644. */
  35645. translateFromPivot: boolean;
  35646. /**
  35647. * Is the particle active or not ?
  35648. */
  35649. alive: boolean;
  35650. /**
  35651. * Is the particle visible or not ?
  35652. */
  35653. isVisible: boolean;
  35654. /**
  35655. * Index of this particle in the global "positions" array (Internal use)
  35656. * @hidden
  35657. */
  35658. _pos: number;
  35659. /**
  35660. * @hidden Index of this particle in the global "indices" array (Internal use)
  35661. */
  35662. _ind: number;
  35663. /**
  35664. * @hidden ModelShape of this particle (Internal use)
  35665. */
  35666. _model: ModelShape;
  35667. /**
  35668. * ModelShape id of this particle
  35669. */
  35670. shapeId: number;
  35671. /**
  35672. * Index of the particle in its shape id
  35673. */
  35674. idxInShape: number;
  35675. /**
  35676. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  35677. */
  35678. _modelBoundingInfo: BoundingInfo;
  35679. /**
  35680. * @hidden Particle BoundingInfo object (Internal use)
  35681. */
  35682. _boundingInfo: BoundingInfo;
  35683. /**
  35684. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  35685. */
  35686. _sps: SolidParticleSystem;
  35687. /**
  35688. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  35689. */
  35690. _stillInvisible: boolean;
  35691. /**
  35692. * @hidden Last computed particle rotation matrix
  35693. */
  35694. _rotationMatrix: number[];
  35695. /**
  35696. * Parent particle Id, if any.
  35697. * Default null.
  35698. */
  35699. parentId: Nullable<number>;
  35700. /**
  35701. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  35702. */
  35703. materialIndex: Nullable<number>;
  35704. /**
  35705. * Custom object or properties.
  35706. */
  35707. props: Nullable<any>;
  35708. /**
  35709. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  35710. * The possible values are :
  35711. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  35712. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  35713. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  35714. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  35715. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  35716. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  35717. * */
  35718. cullingStrategy: number;
  35719. /**
  35720. * @hidden Internal global position in the SPS.
  35721. */
  35722. _globalPosition: Vector3;
  35723. /**
  35724. * Creates a Solid Particle object.
  35725. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  35726. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  35727. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  35728. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  35729. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  35730. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  35731. * @param shapeId (integer) is the model shape identifier in the SPS.
  35732. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  35733. * @param sps defines the sps it is associated to
  35734. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  35735. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  35736. */
  35737. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  35738. /**
  35739. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  35740. * @param target the particle target
  35741. * @returns the current particle
  35742. */
  35743. copyToRef(target: SolidParticle): SolidParticle;
  35744. /**
  35745. * Legacy support, changed scale to scaling
  35746. */
  35747. get scale(): Vector3;
  35748. /**
  35749. * Legacy support, changed scale to scaling
  35750. */
  35751. set scale(scale: Vector3);
  35752. /**
  35753. * Legacy support, changed quaternion to rotationQuaternion
  35754. */
  35755. get quaternion(): Nullable<Quaternion>;
  35756. /**
  35757. * Legacy support, changed quaternion to rotationQuaternion
  35758. */
  35759. set quaternion(q: Nullable<Quaternion>);
  35760. /**
  35761. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  35762. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  35763. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  35764. * @returns true if it intersects
  35765. */
  35766. intersectsMesh(target: Mesh | SolidParticle): boolean;
  35767. /**
  35768. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  35769. * A particle is in the frustum if its bounding box intersects the frustum
  35770. * @param frustumPlanes defines the frustum to test
  35771. * @returns true if the particle is in the frustum planes
  35772. */
  35773. isInFrustum(frustumPlanes: Plane[]): boolean;
  35774. /**
  35775. * get the rotation matrix of the particle
  35776. * @hidden
  35777. */
  35778. getRotationMatrix(m: Matrix): void;
  35779. }
  35780. /**
  35781. * Represents the shape of the model used by one particle of a solid particle system.
  35782. * SPS internal tool, don't use it manually.
  35783. */
  35784. export class ModelShape {
  35785. /**
  35786. * The shape id
  35787. * @hidden
  35788. */
  35789. shapeID: number;
  35790. /**
  35791. * flat array of model positions (internal use)
  35792. * @hidden
  35793. */
  35794. _shape: Vector3[];
  35795. /**
  35796. * flat array of model UVs (internal use)
  35797. * @hidden
  35798. */
  35799. _shapeUV: number[];
  35800. /**
  35801. * color array of the model
  35802. * @hidden
  35803. */
  35804. _shapeColors: number[];
  35805. /**
  35806. * indices array of the model
  35807. * @hidden
  35808. */
  35809. _indices: number[];
  35810. /**
  35811. * normals array of the model
  35812. * @hidden
  35813. */
  35814. _normals: number[];
  35815. /**
  35816. * length of the shape in the model indices array (internal use)
  35817. * @hidden
  35818. */
  35819. _indicesLength: number;
  35820. /**
  35821. * Custom position function (internal use)
  35822. * @hidden
  35823. */
  35824. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  35825. /**
  35826. * Custom vertex function (internal use)
  35827. * @hidden
  35828. */
  35829. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  35830. /**
  35831. * Model material (internal use)
  35832. * @hidden
  35833. */
  35834. _material: Nullable<Material>;
  35835. /**
  35836. * 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.
  35837. * SPS internal tool, don't use it manually.
  35838. * @hidden
  35839. */
  35840. 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>);
  35841. }
  35842. /**
  35843. * Represents a Depth Sorted Particle in the solid particle system.
  35844. * @hidden
  35845. */
  35846. export class DepthSortedParticle {
  35847. /**
  35848. * Particle index
  35849. */
  35850. idx: number;
  35851. /**
  35852. * Index of the particle in the "indices" array
  35853. */
  35854. ind: number;
  35855. /**
  35856. * Length of the particle shape in the "indices" array
  35857. */
  35858. indicesLength: number;
  35859. /**
  35860. * Squared distance from the particle to the camera
  35861. */
  35862. sqDistance: number;
  35863. /**
  35864. * Material index when used with MultiMaterials
  35865. */
  35866. materialIndex: number;
  35867. /**
  35868. * Creates a new sorted particle
  35869. * @param materialIndex
  35870. */
  35871. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  35872. }
  35873. /**
  35874. * Represents a solid particle vertex
  35875. */
  35876. export class SolidParticleVertex {
  35877. /**
  35878. * Vertex position
  35879. */
  35880. position: Vector3;
  35881. /**
  35882. * Vertex color
  35883. */
  35884. color: Color4;
  35885. /**
  35886. * Vertex UV
  35887. */
  35888. uv: Vector2;
  35889. /**
  35890. * Creates a new solid particle vertex
  35891. */
  35892. constructor();
  35893. /** Vertex x coordinate */
  35894. get x(): number;
  35895. set x(val: number);
  35896. /** Vertex y coordinate */
  35897. get y(): number;
  35898. set y(val: number);
  35899. /** Vertex z coordinate */
  35900. get z(): number;
  35901. set z(val: number);
  35902. }
  35903. }
  35904. declare module BABYLON {
  35905. /**
  35906. * @hidden
  35907. */
  35908. export class _MeshCollisionData {
  35909. _checkCollisions: boolean;
  35910. _collisionMask: number;
  35911. _collisionGroup: number;
  35912. _surroundingMeshes: Nullable<AbstractMesh[]>;
  35913. _collider: Nullable<Collider>;
  35914. _oldPositionForCollisions: Vector3;
  35915. _diffPositionForCollisions: Vector3;
  35916. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  35917. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  35918. _collisionResponse: boolean;
  35919. }
  35920. }
  35921. declare module BABYLON {
  35922. /** @hidden */
  35923. class _FacetDataStorage {
  35924. facetPositions: Vector3[];
  35925. facetNormals: Vector3[];
  35926. facetPartitioning: number[][];
  35927. facetNb: number;
  35928. partitioningSubdivisions: number;
  35929. partitioningBBoxRatio: number;
  35930. facetDataEnabled: boolean;
  35931. facetParameters: any;
  35932. bbSize: Vector3;
  35933. subDiv: {
  35934. max: number;
  35935. X: number;
  35936. Y: number;
  35937. Z: number;
  35938. };
  35939. facetDepthSort: boolean;
  35940. facetDepthSortEnabled: boolean;
  35941. depthSortedIndices: IndicesArray;
  35942. depthSortedFacets: {
  35943. ind: number;
  35944. sqDistance: number;
  35945. }[];
  35946. facetDepthSortFunction: (f1: {
  35947. ind: number;
  35948. sqDistance: number;
  35949. }, f2: {
  35950. ind: number;
  35951. sqDistance: number;
  35952. }) => number;
  35953. facetDepthSortFrom: Vector3;
  35954. facetDepthSortOrigin: Vector3;
  35955. invertedMatrix: Matrix;
  35956. }
  35957. /**
  35958. * @hidden
  35959. **/
  35960. class _InternalAbstractMeshDataInfo {
  35961. _hasVertexAlpha: boolean;
  35962. _useVertexColors: boolean;
  35963. _numBoneInfluencers: number;
  35964. _applyFog: boolean;
  35965. _receiveShadows: boolean;
  35966. _facetData: _FacetDataStorage;
  35967. _visibility: number;
  35968. _skeleton: Nullable<Skeleton>;
  35969. _layerMask: number;
  35970. _computeBonesUsingShaders: boolean;
  35971. _isActive: boolean;
  35972. _onlyForInstances: boolean;
  35973. _isActiveIntermediate: boolean;
  35974. _onlyForInstancesIntermediate: boolean;
  35975. _actAsRegularMesh: boolean;
  35976. _currentLOD: Nullable<AbstractMesh>;
  35977. _currentLODIsUpToDate: boolean;
  35978. }
  35979. /**
  35980. * Class used to store all common mesh properties
  35981. */
  35982. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  35983. /** No occlusion */
  35984. static OCCLUSION_TYPE_NONE: number;
  35985. /** Occlusion set to optimisitic */
  35986. static OCCLUSION_TYPE_OPTIMISTIC: number;
  35987. /** Occlusion set to strict */
  35988. static OCCLUSION_TYPE_STRICT: number;
  35989. /** Use an accurante occlusion algorithm */
  35990. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  35991. /** Use a conservative occlusion algorithm */
  35992. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  35993. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  35994. * Test order :
  35995. * Is the bounding sphere outside the frustum ?
  35996. * If not, are the bounding box vertices outside the frustum ?
  35997. * It not, then the cullable object is in the frustum.
  35998. */
  35999. static readonly CULLINGSTRATEGY_STANDARD: number;
  36000. /** Culling strategy : Bounding Sphere Only.
  36001. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  36002. * It's also less accurate than the standard because some not visible objects can still be selected.
  36003. * Test : is the bounding sphere outside the frustum ?
  36004. * If not, then the cullable object is in the frustum.
  36005. */
  36006. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  36007. /** Culling strategy : Optimistic Inclusion.
  36008. * This in an inclusion test first, then the standard exclusion test.
  36009. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  36010. * 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.
  36011. * Anyway, it's as accurate as the standard strategy.
  36012. * Test :
  36013. * Is the cullable object bounding sphere center in the frustum ?
  36014. * If not, apply the default culling strategy.
  36015. */
  36016. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  36017. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  36018. * This in an inclusion test first, then the bounding sphere only exclusion test.
  36019. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  36020. * 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.
  36021. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  36022. * Test :
  36023. * Is the cullable object bounding sphere center in the frustum ?
  36024. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  36025. */
  36026. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  36027. /**
  36028. * No billboard
  36029. */
  36030. static get BILLBOARDMODE_NONE(): number;
  36031. /** Billboard on X axis */
  36032. static get BILLBOARDMODE_X(): number;
  36033. /** Billboard on Y axis */
  36034. static get BILLBOARDMODE_Y(): number;
  36035. /** Billboard on Z axis */
  36036. static get BILLBOARDMODE_Z(): number;
  36037. /** Billboard on all axes */
  36038. static get BILLBOARDMODE_ALL(): number;
  36039. /** Billboard on using position instead of orientation */
  36040. static get BILLBOARDMODE_USE_POSITION(): number;
  36041. /** @hidden */
  36042. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  36043. /**
  36044. * The culling strategy to use to check whether the mesh must be rendered or not.
  36045. * This value can be changed at any time and will be used on the next render mesh selection.
  36046. * The possible values are :
  36047. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  36048. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  36049. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  36050. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  36051. * Please read each static variable documentation to get details about the culling process.
  36052. * */
  36053. cullingStrategy: number;
  36054. /**
  36055. * Gets the number of facets in the mesh
  36056. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  36057. */
  36058. get facetNb(): number;
  36059. /**
  36060. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  36061. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  36062. */
  36063. get partitioningSubdivisions(): number;
  36064. set partitioningSubdivisions(nb: number);
  36065. /**
  36066. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  36067. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  36068. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  36069. */
  36070. get partitioningBBoxRatio(): number;
  36071. set partitioningBBoxRatio(ratio: number);
  36072. /**
  36073. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  36074. * Works only for updatable meshes.
  36075. * Doesn't work with multi-materials
  36076. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  36077. */
  36078. get mustDepthSortFacets(): boolean;
  36079. set mustDepthSortFacets(sort: boolean);
  36080. /**
  36081. * The location (Vector3) where the facet depth sort must be computed from.
  36082. * By default, the active camera position.
  36083. * Used only when facet depth sort is enabled
  36084. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  36085. */
  36086. get facetDepthSortFrom(): Vector3;
  36087. set facetDepthSortFrom(location: Vector3);
  36088. /**
  36089. * gets a boolean indicating if facetData is enabled
  36090. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  36091. */
  36092. get isFacetDataEnabled(): boolean;
  36093. /** @hidden */
  36094. _updateNonUniformScalingState(value: boolean): boolean;
  36095. /**
  36096. * An event triggered when this mesh collides with another one
  36097. */
  36098. onCollideObservable: Observable<AbstractMesh>;
  36099. /** Set a function to call when this mesh collides with another one */
  36100. set onCollide(callback: () => void);
  36101. /**
  36102. * An event triggered when the collision's position changes
  36103. */
  36104. onCollisionPositionChangeObservable: Observable<Vector3>;
  36105. /** Set a function to call when the collision's position changes */
  36106. set onCollisionPositionChange(callback: () => void);
  36107. /**
  36108. * An event triggered when material is changed
  36109. */
  36110. onMaterialChangedObservable: Observable<AbstractMesh>;
  36111. /**
  36112. * Gets or sets the orientation for POV movement & rotation
  36113. */
  36114. definedFacingForward: boolean;
  36115. /** @hidden */
  36116. _occlusionQuery: Nullable<WebGLQuery>;
  36117. /** @hidden */
  36118. _renderingGroup: Nullable<RenderingGroup>;
  36119. /**
  36120. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  36121. */
  36122. get visibility(): number;
  36123. /**
  36124. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  36125. */
  36126. set visibility(value: number);
  36127. /** Gets or sets the alpha index used to sort transparent meshes
  36128. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  36129. */
  36130. alphaIndex: number;
  36131. /**
  36132. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  36133. */
  36134. isVisible: boolean;
  36135. /**
  36136. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  36137. */
  36138. isPickable: boolean;
  36139. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  36140. showSubMeshesBoundingBox: boolean;
  36141. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  36142. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  36143. */
  36144. isBlocker: boolean;
  36145. /**
  36146. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  36147. */
  36148. enablePointerMoveEvents: boolean;
  36149. private _renderingGroupId;
  36150. /**
  36151. * Specifies the rendering group id for this mesh (0 by default)
  36152. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  36153. */
  36154. get renderingGroupId(): number;
  36155. set renderingGroupId(value: number);
  36156. private _material;
  36157. /** Gets or sets current material */
  36158. get material(): Nullable<Material>;
  36159. set material(value: Nullable<Material>);
  36160. /**
  36161. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  36162. * @see https://doc.babylonjs.com/babylon101/shadows
  36163. */
  36164. get receiveShadows(): boolean;
  36165. set receiveShadows(value: boolean);
  36166. /** Defines color to use when rendering outline */
  36167. outlineColor: Color3;
  36168. /** Define width to use when rendering outline */
  36169. outlineWidth: number;
  36170. /** Defines color to use when rendering overlay */
  36171. overlayColor: Color3;
  36172. /** Defines alpha to use when rendering overlay */
  36173. overlayAlpha: number;
  36174. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  36175. get hasVertexAlpha(): boolean;
  36176. set hasVertexAlpha(value: boolean);
  36177. /** 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) */
  36178. get useVertexColors(): boolean;
  36179. set useVertexColors(value: boolean);
  36180. /**
  36181. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  36182. */
  36183. get computeBonesUsingShaders(): boolean;
  36184. set computeBonesUsingShaders(value: boolean);
  36185. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  36186. get numBoneInfluencers(): number;
  36187. set numBoneInfluencers(value: number);
  36188. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  36189. get applyFog(): boolean;
  36190. set applyFog(value: boolean);
  36191. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  36192. useOctreeForRenderingSelection: boolean;
  36193. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  36194. useOctreeForPicking: boolean;
  36195. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  36196. useOctreeForCollisions: boolean;
  36197. /**
  36198. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  36199. * @see https://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  36200. */
  36201. get layerMask(): number;
  36202. set layerMask(value: number);
  36203. /**
  36204. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  36205. */
  36206. alwaysSelectAsActiveMesh: boolean;
  36207. /**
  36208. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  36209. */
  36210. doNotSyncBoundingInfo: boolean;
  36211. /**
  36212. * Gets or sets the current action manager
  36213. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  36214. */
  36215. actionManager: Nullable<AbstractActionManager>;
  36216. private _meshCollisionData;
  36217. /**
  36218. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  36219. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36220. */
  36221. ellipsoid: Vector3;
  36222. /**
  36223. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  36224. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36225. */
  36226. ellipsoidOffset: Vector3;
  36227. /**
  36228. * Gets or sets a collision mask used to mask collisions (default is -1).
  36229. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  36230. */
  36231. get collisionMask(): number;
  36232. set collisionMask(mask: number);
  36233. /**
  36234. * Gets or sets a collision response flag (default is true).
  36235. * when collisionResponse is false, events are still triggered but colliding entity has no response
  36236. * This helps creating trigger volume when user wants collision feedback events but not position/velocity
  36237. * to respond to the collision.
  36238. */
  36239. get collisionResponse(): boolean;
  36240. set collisionResponse(response: boolean);
  36241. /**
  36242. * Gets or sets the current collision group mask (-1 by default).
  36243. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  36244. */
  36245. get collisionGroup(): number;
  36246. set collisionGroup(mask: number);
  36247. /**
  36248. * Gets or sets current surrounding meshes (null by default).
  36249. *
  36250. * By default collision detection is tested against every mesh in the scene.
  36251. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  36252. * meshes will be tested for the collision.
  36253. *
  36254. * Note: if set to an empty array no collision will happen when this mesh is moved.
  36255. */
  36256. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  36257. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  36258. /**
  36259. * Defines edge width used when edgesRenderer is enabled
  36260. * @see https://www.babylonjs-playground.com/#10OJSG#13
  36261. */
  36262. edgesWidth: number;
  36263. /**
  36264. * Defines edge color used when edgesRenderer is enabled
  36265. * @see https://www.babylonjs-playground.com/#10OJSG#13
  36266. */
  36267. edgesColor: Color4;
  36268. /** @hidden */
  36269. _edgesRenderer: Nullable<IEdgesRenderer>;
  36270. /** @hidden */
  36271. _masterMesh: Nullable<AbstractMesh>;
  36272. /** @hidden */
  36273. _boundingInfo: Nullable<BoundingInfo>;
  36274. /** @hidden */
  36275. _renderId: number;
  36276. /**
  36277. * Gets or sets the list of subMeshes
  36278. * @see https://doc.babylonjs.com/how_to/multi_materials
  36279. */
  36280. subMeshes: SubMesh[];
  36281. /** @hidden */
  36282. _intersectionsInProgress: AbstractMesh[];
  36283. /** @hidden */
  36284. _unIndexed: boolean;
  36285. /** @hidden */
  36286. _lightSources: Light[];
  36287. /** Gets the list of lights affecting that mesh */
  36288. get lightSources(): Light[];
  36289. /** @hidden */
  36290. get _positions(): Nullable<Vector3[]>;
  36291. /** @hidden */
  36292. _waitingData: {
  36293. lods: Nullable<any>;
  36294. actions: Nullable<any>;
  36295. freezeWorldMatrix: Nullable<boolean>;
  36296. };
  36297. /** @hidden */
  36298. _bonesTransformMatrices: Nullable<Float32Array>;
  36299. /** @hidden */
  36300. _transformMatrixTexture: Nullable<RawTexture>;
  36301. /**
  36302. * Gets or sets a skeleton to apply skining transformations
  36303. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  36304. */
  36305. set skeleton(value: Nullable<Skeleton>);
  36306. get skeleton(): Nullable<Skeleton>;
  36307. /**
  36308. * An event triggered when the mesh is rebuilt.
  36309. */
  36310. onRebuildObservable: Observable<AbstractMesh>;
  36311. /**
  36312. * The current mesh unifom buffer.
  36313. * @hidden Internal use only.
  36314. */
  36315. _uniformBuffer: UniformBuffer;
  36316. /**
  36317. * Creates a new AbstractMesh
  36318. * @param name defines the name of the mesh
  36319. * @param scene defines the hosting scene
  36320. */
  36321. constructor(name: string, scene?: Nullable<Scene>);
  36322. protected _buildUniformLayout(): void;
  36323. /**
  36324. * Transfer the mesh values to its UBO.
  36325. * @param world The world matrix associated with the mesh
  36326. */
  36327. transferToEffect(world: Matrix): void;
  36328. /**
  36329. * Gets the mesh uniform buffer.
  36330. * @return the uniform buffer of the mesh.
  36331. */
  36332. getMeshUniformBuffer(): UniformBuffer;
  36333. /**
  36334. * Returns the string "AbstractMesh"
  36335. * @returns "AbstractMesh"
  36336. */
  36337. getClassName(): string;
  36338. /**
  36339. * Gets a string representation of the current mesh
  36340. * @param fullDetails defines a boolean indicating if full details must be included
  36341. * @returns a string representation of the current mesh
  36342. */
  36343. toString(fullDetails?: boolean): string;
  36344. /**
  36345. * @hidden
  36346. */
  36347. protected _getEffectiveParent(): Nullable<Node>;
  36348. /** @hidden */
  36349. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  36350. /** @hidden */
  36351. _rebuild(): void;
  36352. /** @hidden */
  36353. _resyncLightSources(): void;
  36354. /** @hidden */
  36355. _resyncLightSource(light: Light): void;
  36356. /** @hidden */
  36357. _unBindEffect(): void;
  36358. /** @hidden */
  36359. _removeLightSource(light: Light, dispose: boolean): void;
  36360. private _markSubMeshesAsDirty;
  36361. /** @hidden */
  36362. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  36363. /** @hidden */
  36364. _markSubMeshesAsAttributesDirty(): void;
  36365. /** @hidden */
  36366. _markSubMeshesAsMiscDirty(): void;
  36367. /**
  36368. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  36369. */
  36370. get scaling(): Vector3;
  36371. set scaling(newScaling: Vector3);
  36372. /**
  36373. * Returns true if the mesh is blocked. Implemented by child classes
  36374. */
  36375. get isBlocked(): boolean;
  36376. /**
  36377. * Returns the mesh itself by default. Implemented by child classes
  36378. * @param camera defines the camera to use to pick the right LOD level
  36379. * @returns the currentAbstractMesh
  36380. */
  36381. getLOD(camera: Camera): Nullable<AbstractMesh>;
  36382. /**
  36383. * Returns 0 by default. Implemented by child classes
  36384. * @returns an integer
  36385. */
  36386. getTotalVertices(): number;
  36387. /**
  36388. * Returns a positive integer : the total number of indices in this mesh geometry.
  36389. * @returns the numner of indices or zero if the mesh has no geometry.
  36390. */
  36391. getTotalIndices(): number;
  36392. /**
  36393. * Returns null by default. Implemented by child classes
  36394. * @returns null
  36395. */
  36396. getIndices(): Nullable<IndicesArray>;
  36397. /**
  36398. * Returns the array of the requested vertex data kind. Implemented by child classes
  36399. * @param kind defines the vertex data kind to use
  36400. * @returns null
  36401. */
  36402. getVerticesData(kind: string): Nullable<FloatArray>;
  36403. /**
  36404. * Sets the vertex data of the mesh geometry for the requested `kind`.
  36405. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  36406. * Note that a new underlying VertexBuffer object is created each call.
  36407. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  36408. * @param kind defines vertex data kind:
  36409. * * VertexBuffer.PositionKind
  36410. * * VertexBuffer.UVKind
  36411. * * VertexBuffer.UV2Kind
  36412. * * VertexBuffer.UV3Kind
  36413. * * VertexBuffer.UV4Kind
  36414. * * VertexBuffer.UV5Kind
  36415. * * VertexBuffer.UV6Kind
  36416. * * VertexBuffer.ColorKind
  36417. * * VertexBuffer.MatricesIndicesKind
  36418. * * VertexBuffer.MatricesIndicesExtraKind
  36419. * * VertexBuffer.MatricesWeightsKind
  36420. * * VertexBuffer.MatricesWeightsExtraKind
  36421. * @param data defines the data source
  36422. * @param updatable defines if the data must be flagged as updatable (or static)
  36423. * @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
  36424. * @returns the current mesh
  36425. */
  36426. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  36427. /**
  36428. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  36429. * If the mesh has no geometry, it is simply returned as it is.
  36430. * @param kind defines vertex data kind:
  36431. * * VertexBuffer.PositionKind
  36432. * * VertexBuffer.UVKind
  36433. * * VertexBuffer.UV2Kind
  36434. * * VertexBuffer.UV3Kind
  36435. * * VertexBuffer.UV4Kind
  36436. * * VertexBuffer.UV5Kind
  36437. * * VertexBuffer.UV6Kind
  36438. * * VertexBuffer.ColorKind
  36439. * * VertexBuffer.MatricesIndicesKind
  36440. * * VertexBuffer.MatricesIndicesExtraKind
  36441. * * VertexBuffer.MatricesWeightsKind
  36442. * * VertexBuffer.MatricesWeightsExtraKind
  36443. * @param data defines the data source
  36444. * @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
  36445. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  36446. * @returns the current mesh
  36447. */
  36448. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  36449. /**
  36450. * Sets the mesh indices,
  36451. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  36452. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  36453. * @param totalVertices Defines the total number of vertices
  36454. * @returns the current mesh
  36455. */
  36456. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  36457. /**
  36458. * Gets a boolean indicating if specific vertex data is present
  36459. * @param kind defines the vertex data kind to use
  36460. * @returns true is data kind is present
  36461. */
  36462. isVerticesDataPresent(kind: string): boolean;
  36463. /**
  36464. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  36465. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  36466. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  36467. * @returns a BoundingInfo
  36468. */
  36469. getBoundingInfo(): BoundingInfo;
  36470. /**
  36471. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  36472. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  36473. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  36474. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  36475. * @returns the current mesh
  36476. */
  36477. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  36478. /**
  36479. * Overwrite the current bounding info
  36480. * @param boundingInfo defines the new bounding info
  36481. * @returns the current mesh
  36482. */
  36483. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  36484. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  36485. get useBones(): boolean;
  36486. /** @hidden */
  36487. _preActivate(): void;
  36488. /** @hidden */
  36489. _preActivateForIntermediateRendering(renderId: number): void;
  36490. /** @hidden */
  36491. _activate(renderId: number, intermediateRendering: boolean): boolean;
  36492. /** @hidden */
  36493. _postActivate(): void;
  36494. /** @hidden */
  36495. _freeze(): void;
  36496. /** @hidden */
  36497. _unFreeze(): void;
  36498. /**
  36499. * Gets the current world matrix
  36500. * @returns a Matrix
  36501. */
  36502. getWorldMatrix(): Matrix;
  36503. /** @hidden */
  36504. _getWorldMatrixDeterminant(): number;
  36505. /**
  36506. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  36507. */
  36508. get isAnInstance(): boolean;
  36509. /**
  36510. * Gets a boolean indicating if this mesh has instances
  36511. */
  36512. get hasInstances(): boolean;
  36513. /**
  36514. * Gets a boolean indicating if this mesh has thin instances
  36515. */
  36516. get hasThinInstances(): boolean;
  36517. /**
  36518. * Perform relative position change from the point of view of behind the front of the mesh.
  36519. * This is performed taking into account the meshes current rotation, so you do not have to care.
  36520. * Supports definition of mesh facing forward or backward
  36521. * @param amountRight defines the distance on the right axis
  36522. * @param amountUp defines the distance on the up axis
  36523. * @param amountForward defines the distance on the forward axis
  36524. * @returns the current mesh
  36525. */
  36526. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  36527. /**
  36528. * Calculate relative position change from the point of view of behind the front of the mesh.
  36529. * This is performed taking into account the meshes current rotation, so you do not have to care.
  36530. * Supports definition of mesh facing forward or backward
  36531. * @param amountRight defines the distance on the right axis
  36532. * @param amountUp defines the distance on the up axis
  36533. * @param amountForward defines the distance on the forward axis
  36534. * @returns the new displacement vector
  36535. */
  36536. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  36537. /**
  36538. * Perform relative rotation change from the point of view of behind the front of the mesh.
  36539. * Supports definition of mesh facing forward or backward
  36540. * @param flipBack defines the flip
  36541. * @param twirlClockwise defines the twirl
  36542. * @param tiltRight defines the tilt
  36543. * @returns the current mesh
  36544. */
  36545. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  36546. /**
  36547. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  36548. * Supports definition of mesh facing forward or backward.
  36549. * @param flipBack defines the flip
  36550. * @param twirlClockwise defines the twirl
  36551. * @param tiltRight defines the tilt
  36552. * @returns the new rotation vector
  36553. */
  36554. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  36555. /**
  36556. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  36557. * This means the mesh underlying bounding box and sphere are recomputed.
  36558. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  36559. * @returns the current mesh
  36560. */
  36561. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  36562. /** @hidden */
  36563. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  36564. /** @hidden */
  36565. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  36566. /** @hidden */
  36567. _updateBoundingInfo(): AbstractMesh;
  36568. /** @hidden */
  36569. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  36570. /** @hidden */
  36571. protected _afterComputeWorldMatrix(): void;
  36572. /** @hidden */
  36573. get _effectiveMesh(): AbstractMesh;
  36574. /**
  36575. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  36576. * A mesh is in the frustum if its bounding box intersects the frustum
  36577. * @param frustumPlanes defines the frustum to test
  36578. * @returns true if the mesh is in the frustum planes
  36579. */
  36580. isInFrustum(frustumPlanes: Plane[]): boolean;
  36581. /**
  36582. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  36583. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  36584. * @param frustumPlanes defines the frustum to test
  36585. * @returns true if the mesh is completely in the frustum planes
  36586. */
  36587. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  36588. /**
  36589. * True if the mesh intersects another mesh or a SolidParticle object
  36590. * @param mesh defines a target mesh or SolidParticle to test
  36591. * @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)
  36592. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  36593. * @returns true if there is an intersection
  36594. */
  36595. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  36596. /**
  36597. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  36598. * @param point defines the point to test
  36599. * @returns true if there is an intersection
  36600. */
  36601. intersectsPoint(point: Vector3): boolean;
  36602. /**
  36603. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  36604. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36605. */
  36606. get checkCollisions(): boolean;
  36607. set checkCollisions(collisionEnabled: boolean);
  36608. /**
  36609. * Gets Collider object used to compute collisions (not physics)
  36610. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36611. */
  36612. get collider(): Nullable<Collider>;
  36613. /**
  36614. * Move the mesh using collision engine
  36615. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36616. * @param displacement defines the requested displacement vector
  36617. * @returns the current mesh
  36618. */
  36619. moveWithCollisions(displacement: Vector3): AbstractMesh;
  36620. private _onCollisionPositionChange;
  36621. /** @hidden */
  36622. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  36623. /** @hidden */
  36624. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  36625. /** @hidden */
  36626. _checkCollision(collider: Collider): AbstractMesh;
  36627. /** @hidden */
  36628. _generatePointsArray(): boolean;
  36629. /**
  36630. * Checks if the passed Ray intersects with the mesh
  36631. * @param ray defines the ray to use
  36632. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  36633. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  36634. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  36635. * @param worldToUse defines the world matrix to use to get the world coordinate of the intersection point
  36636. * @param skipBoundingInfo a boolean indicating if we should skip the bounding info check
  36637. * @returns the picking info
  36638. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  36639. */
  36640. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean, worldToUse?: Matrix, skipBoundingInfo?: boolean): PickingInfo;
  36641. /**
  36642. * Clones the current mesh
  36643. * @param name defines the mesh name
  36644. * @param newParent defines the new mesh parent
  36645. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  36646. * @returns the new mesh
  36647. */
  36648. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  36649. /**
  36650. * Disposes all the submeshes of the current meshnp
  36651. * @returns the current mesh
  36652. */
  36653. releaseSubMeshes(): AbstractMesh;
  36654. /**
  36655. * Releases resources associated with this abstract mesh.
  36656. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  36657. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  36658. */
  36659. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  36660. /**
  36661. * Adds the passed mesh as a child to the current mesh
  36662. * @param mesh defines the child mesh
  36663. * @returns the current mesh
  36664. */
  36665. addChild(mesh: AbstractMesh): AbstractMesh;
  36666. /**
  36667. * Removes the passed mesh from the current mesh children list
  36668. * @param mesh defines the child mesh
  36669. * @returns the current mesh
  36670. */
  36671. removeChild(mesh: AbstractMesh): AbstractMesh;
  36672. /** @hidden */
  36673. private _initFacetData;
  36674. /**
  36675. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  36676. * This method can be called within the render loop.
  36677. * 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
  36678. * @returns the current mesh
  36679. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36680. */
  36681. updateFacetData(): AbstractMesh;
  36682. /**
  36683. * Returns the facetLocalNormals array.
  36684. * The normals are expressed in the mesh local spac
  36685. * @returns an array of Vector3
  36686. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36687. */
  36688. getFacetLocalNormals(): Vector3[];
  36689. /**
  36690. * Returns the facetLocalPositions array.
  36691. * The facet positions are expressed in the mesh local space
  36692. * @returns an array of Vector3
  36693. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36694. */
  36695. getFacetLocalPositions(): Vector3[];
  36696. /**
  36697. * Returns the facetLocalPartioning array
  36698. * @returns an array of array of numbers
  36699. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36700. */
  36701. getFacetLocalPartitioning(): number[][];
  36702. /**
  36703. * Returns the i-th facet position in the world system.
  36704. * This method allocates a new Vector3 per call
  36705. * @param i defines the facet index
  36706. * @returns a new Vector3
  36707. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36708. */
  36709. getFacetPosition(i: number): Vector3;
  36710. /**
  36711. * Sets the reference Vector3 with the i-th facet position in the world system
  36712. * @param i defines the facet index
  36713. * @param ref defines the target vector
  36714. * @returns the current mesh
  36715. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36716. */
  36717. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  36718. /**
  36719. * Returns the i-th facet normal in the world system.
  36720. * This method allocates a new Vector3 per call
  36721. * @param i defines the facet index
  36722. * @returns a new Vector3
  36723. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36724. */
  36725. getFacetNormal(i: number): Vector3;
  36726. /**
  36727. * Sets the reference Vector3 with the i-th facet normal in the world system
  36728. * @param i defines the facet index
  36729. * @param ref defines the target vector
  36730. * @returns the current mesh
  36731. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36732. */
  36733. getFacetNormalToRef(i: number, ref: Vector3): this;
  36734. /**
  36735. * 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)
  36736. * @param x defines x coordinate
  36737. * @param y defines y coordinate
  36738. * @param z defines z coordinate
  36739. * @returns the array of facet indexes
  36740. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36741. */
  36742. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  36743. /**
  36744. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  36745. * @param projected sets as the (x,y,z) world projection on the facet
  36746. * @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
  36747. * @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
  36748. * @param x defines x coordinate
  36749. * @param y defines y coordinate
  36750. * @param z defines z coordinate
  36751. * @returns the face index if found (or null instead)
  36752. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36753. */
  36754. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  36755. /**
  36756. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  36757. * @param projected sets as the (x,y,z) local projection on the facet
  36758. * @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
  36759. * @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
  36760. * @param x defines x coordinate
  36761. * @param y defines y coordinate
  36762. * @param z defines z coordinate
  36763. * @returns the face index if found (or null instead)
  36764. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36765. */
  36766. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  36767. /**
  36768. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  36769. * @returns the parameters
  36770. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36771. */
  36772. getFacetDataParameters(): any;
  36773. /**
  36774. * Disables the feature FacetData and frees the related memory
  36775. * @returns the current mesh
  36776. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36777. */
  36778. disableFacetData(): AbstractMesh;
  36779. /**
  36780. * Updates the AbstractMesh indices array
  36781. * @param indices defines the data source
  36782. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  36783. * @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)
  36784. * @returns the current mesh
  36785. */
  36786. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  36787. /**
  36788. * Creates new normals data for the mesh
  36789. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  36790. * @returns the current mesh
  36791. */
  36792. createNormals(updatable: boolean): AbstractMesh;
  36793. /**
  36794. * Align the mesh with a normal
  36795. * @param normal defines the normal to use
  36796. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  36797. * @returns the current mesh
  36798. */
  36799. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  36800. /** @hidden */
  36801. _checkOcclusionQuery(): boolean;
  36802. /**
  36803. * Disables the mesh edge rendering mode
  36804. * @returns the currentAbstractMesh
  36805. */
  36806. disableEdgesRendering(): AbstractMesh;
  36807. /**
  36808. * Enables the edge rendering mode on the mesh.
  36809. * This mode makes the mesh edges visible
  36810. * @param epsilon defines the maximal distance between two angles to detect a face
  36811. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  36812. * @param options options to the edge renderer
  36813. * @returns the currentAbstractMesh
  36814. * @see https://www.babylonjs-playground.com/#19O9TU#0
  36815. */
  36816. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean, options?: IEdgesRendererOptions): AbstractMesh;
  36817. /**
  36818. * This function returns all of the particle systems in the scene that use the mesh as an emitter.
  36819. * @returns an array of particle systems in the scene that use the mesh as an emitter
  36820. */
  36821. getConnectedParticleSystems(): IParticleSystem[];
  36822. }
  36823. }
  36824. declare module BABYLON {
  36825. /**
  36826. * Interface used to define ActionEvent
  36827. */
  36828. export interface IActionEvent {
  36829. /** The mesh or sprite that triggered the action */
  36830. source: any;
  36831. /** The X mouse cursor position at the time of the event */
  36832. pointerX: number;
  36833. /** The Y mouse cursor position at the time of the event */
  36834. pointerY: number;
  36835. /** The mesh that is currently pointed at (can be null) */
  36836. meshUnderPointer: Nullable<AbstractMesh>;
  36837. /** the original (browser) event that triggered the ActionEvent */
  36838. sourceEvent?: any;
  36839. /** additional data for the event */
  36840. additionalData?: any;
  36841. }
  36842. /**
  36843. * ActionEvent is the event being sent when an action is triggered.
  36844. */
  36845. export class ActionEvent implements IActionEvent {
  36846. /** The mesh or sprite that triggered the action */
  36847. source: any;
  36848. /** The X mouse cursor position at the time of the event */
  36849. pointerX: number;
  36850. /** The Y mouse cursor position at the time of the event */
  36851. pointerY: number;
  36852. /** The mesh that is currently pointed at (can be null) */
  36853. meshUnderPointer: Nullable<AbstractMesh>;
  36854. /** the original (browser) event that triggered the ActionEvent */
  36855. sourceEvent?: any;
  36856. /** additional data for the event */
  36857. additionalData?: any;
  36858. /**
  36859. * Creates a new ActionEvent
  36860. * @param source The mesh or sprite that triggered the action
  36861. * @param pointerX The X mouse cursor position at the time of the event
  36862. * @param pointerY The Y mouse cursor position at the time of the event
  36863. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  36864. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  36865. * @param additionalData additional data for the event
  36866. */
  36867. constructor(
  36868. /** The mesh or sprite that triggered the action */
  36869. source: any,
  36870. /** The X mouse cursor position at the time of the event */
  36871. pointerX: number,
  36872. /** The Y mouse cursor position at the time of the event */
  36873. pointerY: number,
  36874. /** The mesh that is currently pointed at (can be null) */
  36875. meshUnderPointer: Nullable<AbstractMesh>,
  36876. /** the original (browser) event that triggered the ActionEvent */
  36877. sourceEvent?: any,
  36878. /** additional data for the event */
  36879. additionalData?: any);
  36880. /**
  36881. * Helper function to auto-create an ActionEvent from a source mesh.
  36882. * @param source The source mesh that triggered the event
  36883. * @param evt The original (browser) event
  36884. * @param additionalData additional data for the event
  36885. * @returns the new ActionEvent
  36886. */
  36887. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  36888. /**
  36889. * Helper function to auto-create an ActionEvent from a source sprite
  36890. * @param source The source sprite that triggered the event
  36891. * @param scene Scene associated with the sprite
  36892. * @param evt The original (browser) event
  36893. * @param additionalData additional data for the event
  36894. * @returns the new ActionEvent
  36895. */
  36896. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  36897. /**
  36898. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  36899. * @param scene the scene where the event occurred
  36900. * @param evt The original (browser) event
  36901. * @returns the new ActionEvent
  36902. */
  36903. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  36904. /**
  36905. * Helper function to auto-create an ActionEvent from a primitive
  36906. * @param prim defines the target primitive
  36907. * @param pointerPos defines the pointer position
  36908. * @param evt The original (browser) event
  36909. * @param additionalData additional data for the event
  36910. * @returns the new ActionEvent
  36911. */
  36912. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  36913. }
  36914. }
  36915. declare module BABYLON {
  36916. /**
  36917. * Abstract class used to decouple action Manager from scene and meshes.
  36918. * Do not instantiate.
  36919. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  36920. */
  36921. export abstract class AbstractActionManager implements IDisposable {
  36922. /** Gets the list of active triggers */
  36923. static Triggers: {
  36924. [key: string]: number;
  36925. };
  36926. /** Gets the cursor to use when hovering items */
  36927. hoverCursor: string;
  36928. /** Gets the list of actions */
  36929. actions: IAction[];
  36930. /**
  36931. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  36932. */
  36933. isRecursive: boolean;
  36934. /**
  36935. * Releases all associated resources
  36936. */
  36937. abstract dispose(): void;
  36938. /**
  36939. * Does this action manager has pointer triggers
  36940. */
  36941. abstract get hasPointerTriggers(): boolean;
  36942. /**
  36943. * Does this action manager has pick triggers
  36944. */
  36945. abstract get hasPickTriggers(): boolean;
  36946. /**
  36947. * Process a specific trigger
  36948. * @param trigger defines the trigger to process
  36949. * @param evt defines the event details to be processed
  36950. */
  36951. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  36952. /**
  36953. * Does this action manager handles actions of any of the given triggers
  36954. * @param triggers defines the triggers to be tested
  36955. * @return a boolean indicating whether one (or more) of the triggers is handled
  36956. */
  36957. abstract hasSpecificTriggers(triggers: number[]): boolean;
  36958. /**
  36959. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  36960. * speed.
  36961. * @param triggerA defines the trigger to be tested
  36962. * @param triggerB defines the trigger to be tested
  36963. * @return a boolean indicating whether one (or more) of the triggers is handled
  36964. */
  36965. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  36966. /**
  36967. * Does this action manager handles actions of a given trigger
  36968. * @param trigger defines the trigger to be tested
  36969. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  36970. * @return whether the trigger is handled
  36971. */
  36972. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  36973. /**
  36974. * Serialize this manager to a JSON object
  36975. * @param name defines the property name to store this manager
  36976. * @returns a JSON representation of this manager
  36977. */
  36978. abstract serialize(name: string): any;
  36979. /**
  36980. * Registers an action to this action manager
  36981. * @param action defines the action to be registered
  36982. * @return the action amended (prepared) after registration
  36983. */
  36984. abstract registerAction(action: IAction): Nullable<IAction>;
  36985. /**
  36986. * Unregisters an action to this action manager
  36987. * @param action defines the action to be unregistered
  36988. * @return a boolean indicating whether the action has been unregistered
  36989. */
  36990. abstract unregisterAction(action: IAction): Boolean;
  36991. /**
  36992. * Does exist one action manager with at least one trigger
  36993. **/
  36994. static get HasTriggers(): boolean;
  36995. /**
  36996. * Does exist one action manager with at least one pick trigger
  36997. **/
  36998. static get HasPickTriggers(): boolean;
  36999. /**
  37000. * Does exist one action manager that handles actions of a given trigger
  37001. * @param trigger defines the trigger to be tested
  37002. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  37003. **/
  37004. static HasSpecificTrigger(trigger: number): boolean;
  37005. }
  37006. }
  37007. declare module BABYLON {
  37008. /**
  37009. * Defines how a node can be built from a string name.
  37010. */
  37011. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  37012. /**
  37013. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  37014. */
  37015. export class Node implements IBehaviorAware<Node> {
  37016. /** @hidden */
  37017. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  37018. private static _NodeConstructors;
  37019. /**
  37020. * Add a new node constructor
  37021. * @param type defines the type name of the node to construct
  37022. * @param constructorFunc defines the constructor function
  37023. */
  37024. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  37025. /**
  37026. * Returns a node constructor based on type name
  37027. * @param type defines the type name
  37028. * @param name defines the new node name
  37029. * @param scene defines the hosting scene
  37030. * @param options defines optional options to transmit to constructors
  37031. * @returns the new constructor or null
  37032. */
  37033. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  37034. /**
  37035. * Gets or sets the name of the node
  37036. */
  37037. name: string;
  37038. /**
  37039. * Gets or sets the id of the node
  37040. */
  37041. id: string;
  37042. /**
  37043. * Gets or sets the unique id of the node
  37044. */
  37045. uniqueId: number;
  37046. /**
  37047. * Gets or sets a string used to store user defined state for the node
  37048. */
  37049. state: string;
  37050. /**
  37051. * Gets or sets an object used to store user defined information for the node
  37052. */
  37053. metadata: any;
  37054. /**
  37055. * For internal use only. Please do not use.
  37056. */
  37057. reservedDataStore: any;
  37058. /**
  37059. * List of inspectable custom properties (used by the Inspector)
  37060. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  37061. */
  37062. inspectableCustomProperties: IInspectable[];
  37063. private _doNotSerialize;
  37064. /**
  37065. * Gets or sets a boolean used to define if the node must be serialized
  37066. */
  37067. get doNotSerialize(): boolean;
  37068. set doNotSerialize(value: boolean);
  37069. /** @hidden */
  37070. _isDisposed: boolean;
  37071. /**
  37072. * Gets a list of Animations associated with the node
  37073. */
  37074. animations: Animation[];
  37075. protected _ranges: {
  37076. [name: string]: Nullable<AnimationRange>;
  37077. };
  37078. /**
  37079. * Callback raised when the node is ready to be used
  37080. */
  37081. onReady: Nullable<(node: Node) => void>;
  37082. private _isEnabled;
  37083. private _isParentEnabled;
  37084. private _isReady;
  37085. /** @hidden */
  37086. _currentRenderId: number;
  37087. private _parentUpdateId;
  37088. /** @hidden */
  37089. _childUpdateId: number;
  37090. /** @hidden */
  37091. _waitingParentId: Nullable<string>;
  37092. /** @hidden */
  37093. _scene: Scene;
  37094. /** @hidden */
  37095. _cache: any;
  37096. private _parentNode;
  37097. private _children;
  37098. /** @hidden */
  37099. _worldMatrix: Matrix;
  37100. /** @hidden */
  37101. _worldMatrixDeterminant: number;
  37102. /** @hidden */
  37103. _worldMatrixDeterminantIsDirty: boolean;
  37104. /** @hidden */
  37105. private _sceneRootNodesIndex;
  37106. /**
  37107. * Gets a boolean indicating if the node has been disposed
  37108. * @returns true if the node was disposed
  37109. */
  37110. isDisposed(): boolean;
  37111. /**
  37112. * Gets or sets the parent of the node (without keeping the current position in the scene)
  37113. * @see https://doc.babylonjs.com/how_to/parenting
  37114. */
  37115. set parent(parent: Nullable<Node>);
  37116. get parent(): Nullable<Node>;
  37117. /** @hidden */
  37118. _addToSceneRootNodes(): void;
  37119. /** @hidden */
  37120. _removeFromSceneRootNodes(): void;
  37121. private _animationPropertiesOverride;
  37122. /**
  37123. * Gets or sets the animation properties override
  37124. */
  37125. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  37126. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  37127. /**
  37128. * Gets a string identifying the name of the class
  37129. * @returns "Node" string
  37130. */
  37131. getClassName(): string;
  37132. /** @hidden */
  37133. readonly _isNode: boolean;
  37134. /**
  37135. * An event triggered when the mesh is disposed
  37136. */
  37137. onDisposeObservable: Observable<Node>;
  37138. private _onDisposeObserver;
  37139. /**
  37140. * Sets a callback that will be raised when the node will be disposed
  37141. */
  37142. set onDispose(callback: () => void);
  37143. /**
  37144. * Creates a new Node
  37145. * @param name the name and id to be given to this node
  37146. * @param scene the scene this node will be added to
  37147. */
  37148. constructor(name: string, scene?: Nullable<Scene>);
  37149. /**
  37150. * Gets the scene of the node
  37151. * @returns a scene
  37152. */
  37153. getScene(): Scene;
  37154. /**
  37155. * Gets the engine of the node
  37156. * @returns a Engine
  37157. */
  37158. getEngine(): Engine;
  37159. private _behaviors;
  37160. /**
  37161. * Attach a behavior to the node
  37162. * @see https://doc.babylonjs.com/features/behaviour
  37163. * @param behavior defines the behavior to attach
  37164. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  37165. * @returns the current Node
  37166. */
  37167. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  37168. /**
  37169. * Remove an attached behavior
  37170. * @see https://doc.babylonjs.com/features/behaviour
  37171. * @param behavior defines the behavior to attach
  37172. * @returns the current Node
  37173. */
  37174. removeBehavior(behavior: Behavior<Node>): Node;
  37175. /**
  37176. * Gets the list of attached behaviors
  37177. * @see https://doc.babylonjs.com/features/behaviour
  37178. */
  37179. get behaviors(): Behavior<Node>[];
  37180. /**
  37181. * Gets an attached behavior by name
  37182. * @param name defines the name of the behavior to look for
  37183. * @see https://doc.babylonjs.com/features/behaviour
  37184. * @returns null if behavior was not found else the requested behavior
  37185. */
  37186. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  37187. /**
  37188. * Returns the latest update of the World matrix
  37189. * @returns a Matrix
  37190. */
  37191. getWorldMatrix(): Matrix;
  37192. /** @hidden */
  37193. _getWorldMatrixDeterminant(): number;
  37194. /**
  37195. * Returns directly the latest state of the mesh World matrix.
  37196. * A Matrix is returned.
  37197. */
  37198. get worldMatrixFromCache(): Matrix;
  37199. /** @hidden */
  37200. _initCache(): void;
  37201. /** @hidden */
  37202. updateCache(force?: boolean): void;
  37203. /** @hidden */
  37204. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  37205. /** @hidden */
  37206. _updateCache(ignoreParentClass?: boolean): void;
  37207. /** @hidden */
  37208. _isSynchronized(): boolean;
  37209. /** @hidden */
  37210. _markSyncedWithParent(): void;
  37211. /** @hidden */
  37212. isSynchronizedWithParent(): boolean;
  37213. /** @hidden */
  37214. isSynchronized(): boolean;
  37215. /**
  37216. * Is this node ready to be used/rendered
  37217. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  37218. * @return true if the node is ready
  37219. */
  37220. isReady(completeCheck?: boolean): boolean;
  37221. /**
  37222. * Is this node enabled?
  37223. * 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
  37224. * @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
  37225. * @return whether this node (and its parent) is enabled
  37226. */
  37227. isEnabled(checkAncestors?: boolean): boolean;
  37228. /** @hidden */
  37229. protected _syncParentEnabledState(): void;
  37230. /**
  37231. * Set the enabled state of this node
  37232. * @param value defines the new enabled state
  37233. */
  37234. setEnabled(value: boolean): void;
  37235. /**
  37236. * Is this node a descendant of the given node?
  37237. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  37238. * @param ancestor defines the parent node to inspect
  37239. * @returns a boolean indicating if this node is a descendant of the given node
  37240. */
  37241. isDescendantOf(ancestor: Node): boolean;
  37242. /** @hidden */
  37243. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  37244. /**
  37245. * Will return all nodes that have this node as ascendant
  37246. * @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
  37247. * @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
  37248. * @return all children nodes of all types
  37249. */
  37250. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  37251. /**
  37252. * Get all child-meshes of this node
  37253. * @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)
  37254. * @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
  37255. * @returns an array of AbstractMesh
  37256. */
  37257. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  37258. /**
  37259. * Get all direct children of this node
  37260. * @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
  37261. * @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)
  37262. * @returns an array of Node
  37263. */
  37264. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  37265. /** @hidden */
  37266. _setReady(state: boolean): void;
  37267. /**
  37268. * Get an animation by name
  37269. * @param name defines the name of the animation to look for
  37270. * @returns null if not found else the requested animation
  37271. */
  37272. getAnimationByName(name: string): Nullable<Animation>;
  37273. /**
  37274. * Creates an animation range for this node
  37275. * @param name defines the name of the range
  37276. * @param from defines the starting key
  37277. * @param to defines the end key
  37278. */
  37279. createAnimationRange(name: string, from: number, to: number): void;
  37280. /**
  37281. * Delete a specific animation range
  37282. * @param name defines the name of the range to delete
  37283. * @param deleteFrames defines if animation frames from the range must be deleted as well
  37284. */
  37285. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  37286. /**
  37287. * Get an animation range by name
  37288. * @param name defines the name of the animation range to look for
  37289. * @returns null if not found else the requested animation range
  37290. */
  37291. getAnimationRange(name: string): Nullable<AnimationRange>;
  37292. /**
  37293. * Gets the list of all animation ranges defined on this node
  37294. * @returns an array
  37295. */
  37296. getAnimationRanges(): Nullable<AnimationRange>[];
  37297. /**
  37298. * Will start the animation sequence
  37299. * @param name defines the range frames for animation sequence
  37300. * @param loop defines if the animation should loop (false by default)
  37301. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  37302. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  37303. * @returns the object created for this animation. If range does not exist, it will return null
  37304. */
  37305. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  37306. /**
  37307. * Serialize animation ranges into a JSON compatible object
  37308. * @returns serialization object
  37309. */
  37310. serializeAnimationRanges(): any;
  37311. /**
  37312. * Computes the world matrix of the node
  37313. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  37314. * @returns the world matrix
  37315. */
  37316. computeWorldMatrix(force?: boolean): Matrix;
  37317. /**
  37318. * Releases resources associated with this node.
  37319. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  37320. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  37321. */
  37322. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  37323. /**
  37324. * Parse animation range data from a serialization object and store them into a given node
  37325. * @param node defines where to store the animation ranges
  37326. * @param parsedNode defines the serialization object to read data from
  37327. * @param scene defines the hosting scene
  37328. */
  37329. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  37330. /**
  37331. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  37332. * @param includeDescendants Include bounding info from descendants as well (true by default)
  37333. * @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
  37334. * @returns the new bounding vectors
  37335. */
  37336. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  37337. min: Vector3;
  37338. max: Vector3;
  37339. };
  37340. }
  37341. }
  37342. declare module BABYLON {
  37343. /**
  37344. * @hidden
  37345. */
  37346. export class _IAnimationState {
  37347. key: number;
  37348. repeatCount: number;
  37349. workValue?: any;
  37350. loopMode?: number;
  37351. offsetValue?: any;
  37352. highLimitValue?: any;
  37353. }
  37354. /**
  37355. * Class used to store any kind of animation
  37356. */
  37357. export class Animation {
  37358. /**Name of the animation */
  37359. name: string;
  37360. /**Property to animate */
  37361. targetProperty: string;
  37362. /**The frames per second of the animation */
  37363. framePerSecond: number;
  37364. /**The data type of the animation */
  37365. dataType: number;
  37366. /**The loop mode of the animation */
  37367. loopMode?: number | undefined;
  37368. /**Specifies if blending should be enabled */
  37369. enableBlending?: boolean | undefined;
  37370. /**
  37371. * Use matrix interpolation instead of using direct key value when animating matrices
  37372. */
  37373. static AllowMatricesInterpolation: boolean;
  37374. /**
  37375. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  37376. */
  37377. static AllowMatrixDecomposeForInterpolation: boolean;
  37378. /** Define the Url to load snippets */
  37379. static SnippetUrl: string;
  37380. /** Snippet ID if the animation was created from the snippet server */
  37381. snippetId: string;
  37382. /**
  37383. * Stores the key frames of the animation
  37384. */
  37385. private _keys;
  37386. /**
  37387. * Stores the easing function of the animation
  37388. */
  37389. private _easingFunction;
  37390. /**
  37391. * @hidden Internal use only
  37392. */
  37393. _runtimeAnimations: RuntimeAnimation[];
  37394. /**
  37395. * The set of event that will be linked to this animation
  37396. */
  37397. private _events;
  37398. /**
  37399. * Stores an array of target property paths
  37400. */
  37401. targetPropertyPath: string[];
  37402. /**
  37403. * Stores the blending speed of the animation
  37404. */
  37405. blendingSpeed: number;
  37406. /**
  37407. * Stores the animation ranges for the animation
  37408. */
  37409. private _ranges;
  37410. /**
  37411. * @hidden Internal use
  37412. */
  37413. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  37414. /**
  37415. * Sets up an animation
  37416. * @param property The property to animate
  37417. * @param animationType The animation type to apply
  37418. * @param framePerSecond The frames per second of the animation
  37419. * @param easingFunction The easing function used in the animation
  37420. * @returns The created animation
  37421. */
  37422. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  37423. /**
  37424. * Create and start an animation on a node
  37425. * @param name defines the name of the global animation that will be run on all nodes
  37426. * @param node defines the root node where the animation will take place
  37427. * @param targetProperty defines property to animate
  37428. * @param framePerSecond defines the number of frame per second yo use
  37429. * @param totalFrame defines the number of frames in total
  37430. * @param from defines the initial value
  37431. * @param to defines the final value
  37432. * @param loopMode defines which loop mode you want to use (off by default)
  37433. * @param easingFunction defines the easing function to use (linear by default)
  37434. * @param onAnimationEnd defines the callback to call when animation end
  37435. * @returns the animatable created for this animation
  37436. */
  37437. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  37438. /**
  37439. * Create and start an animation on a node and its descendants
  37440. * @param name defines the name of the global animation that will be run on all nodes
  37441. * @param node defines the root node where the animation will take place
  37442. * @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
  37443. * @param targetProperty defines property to animate
  37444. * @param framePerSecond defines the number of frame per second to use
  37445. * @param totalFrame defines the number of frames in total
  37446. * @param from defines the initial value
  37447. * @param to defines the final value
  37448. * @param loopMode defines which loop mode you want to use (off by default)
  37449. * @param easingFunction defines the easing function to use (linear by default)
  37450. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  37451. * @returns the list of animatables created for all nodes
  37452. * @example https://www.babylonjs-playground.com/#MH0VLI
  37453. */
  37454. 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[]>;
  37455. /**
  37456. * Creates a new animation, merges it with the existing animations and starts it
  37457. * @param name Name of the animation
  37458. * @param node Node which contains the scene that begins the animations
  37459. * @param targetProperty Specifies which property to animate
  37460. * @param framePerSecond The frames per second of the animation
  37461. * @param totalFrame The total number of frames
  37462. * @param from The frame at the beginning of the animation
  37463. * @param to The frame at the end of the animation
  37464. * @param loopMode Specifies the loop mode of the animation
  37465. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  37466. * @param onAnimationEnd Callback to run once the animation is complete
  37467. * @returns Nullable animation
  37468. */
  37469. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  37470. /**
  37471. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  37472. * @param sourceAnimation defines the Animation containing keyframes to convert
  37473. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  37474. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  37475. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  37476. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  37477. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  37478. */
  37479. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  37480. /**
  37481. * Transition property of an host to the target Value
  37482. * @param property The property to transition
  37483. * @param targetValue The target Value of the property
  37484. * @param host The object where the property to animate belongs
  37485. * @param scene Scene used to run the animation
  37486. * @param frameRate Framerate (in frame/s) to use
  37487. * @param transition The transition type we want to use
  37488. * @param duration The duration of the animation, in milliseconds
  37489. * @param onAnimationEnd Callback trigger at the end of the animation
  37490. * @returns Nullable animation
  37491. */
  37492. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  37493. /**
  37494. * Return the array of runtime animations currently using this animation
  37495. */
  37496. get runtimeAnimations(): RuntimeAnimation[];
  37497. /**
  37498. * Specifies if any of the runtime animations are currently running
  37499. */
  37500. get hasRunningRuntimeAnimations(): boolean;
  37501. /**
  37502. * Initializes the animation
  37503. * @param name Name of the animation
  37504. * @param targetProperty Property to animate
  37505. * @param framePerSecond The frames per second of the animation
  37506. * @param dataType The data type of the animation
  37507. * @param loopMode The loop mode of the animation
  37508. * @param enableBlending Specifies if blending should be enabled
  37509. */
  37510. constructor(
  37511. /**Name of the animation */
  37512. name: string,
  37513. /**Property to animate */
  37514. targetProperty: string,
  37515. /**The frames per second of the animation */
  37516. framePerSecond: number,
  37517. /**The data type of the animation */
  37518. dataType: number,
  37519. /**The loop mode of the animation */
  37520. loopMode?: number | undefined,
  37521. /**Specifies if blending should be enabled */
  37522. enableBlending?: boolean | undefined);
  37523. /**
  37524. * Converts the animation to a string
  37525. * @param fullDetails support for multiple levels of logging within scene loading
  37526. * @returns String form of the animation
  37527. */
  37528. toString(fullDetails?: boolean): string;
  37529. /**
  37530. * Add an event to this animation
  37531. * @param event Event to add
  37532. */
  37533. addEvent(event: AnimationEvent): void;
  37534. /**
  37535. * Remove all events found at the given frame
  37536. * @param frame The frame to remove events from
  37537. */
  37538. removeEvents(frame: number): void;
  37539. /**
  37540. * Retrieves all the events from the animation
  37541. * @returns Events from the animation
  37542. */
  37543. getEvents(): AnimationEvent[];
  37544. /**
  37545. * Creates an animation range
  37546. * @param name Name of the animation range
  37547. * @param from Starting frame of the animation range
  37548. * @param to Ending frame of the animation
  37549. */
  37550. createRange(name: string, from: number, to: number): void;
  37551. /**
  37552. * Deletes an animation range by name
  37553. * @param name Name of the animation range to delete
  37554. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  37555. */
  37556. deleteRange(name: string, deleteFrames?: boolean): void;
  37557. /**
  37558. * Gets the animation range by name, or null if not defined
  37559. * @param name Name of the animation range
  37560. * @returns Nullable animation range
  37561. */
  37562. getRange(name: string): Nullable<AnimationRange>;
  37563. /**
  37564. * Gets the key frames from the animation
  37565. * @returns The key frames of the animation
  37566. */
  37567. getKeys(): Array<IAnimationKey>;
  37568. /**
  37569. * Gets the highest frame rate of the animation
  37570. * @returns Highest frame rate of the animation
  37571. */
  37572. getHighestFrame(): number;
  37573. /**
  37574. * Gets the easing function of the animation
  37575. * @returns Easing function of the animation
  37576. */
  37577. getEasingFunction(): IEasingFunction;
  37578. /**
  37579. * Sets the easing function of the animation
  37580. * @param easingFunction A custom mathematical formula for animation
  37581. */
  37582. setEasingFunction(easingFunction: EasingFunction): void;
  37583. /**
  37584. * Interpolates a scalar linearly
  37585. * @param startValue Start value of the animation curve
  37586. * @param endValue End value of the animation curve
  37587. * @param gradient Scalar amount to interpolate
  37588. * @returns Interpolated scalar value
  37589. */
  37590. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  37591. /**
  37592. * Interpolates a scalar cubically
  37593. * @param startValue Start value of the animation curve
  37594. * @param outTangent End tangent of the animation
  37595. * @param endValue End value of the animation curve
  37596. * @param inTangent Start tangent of the animation curve
  37597. * @param gradient Scalar amount to interpolate
  37598. * @returns Interpolated scalar value
  37599. */
  37600. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  37601. /**
  37602. * Interpolates a quaternion using a spherical linear interpolation
  37603. * @param startValue Start value of the animation curve
  37604. * @param endValue End value of the animation curve
  37605. * @param gradient Scalar amount to interpolate
  37606. * @returns Interpolated quaternion value
  37607. */
  37608. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  37609. /**
  37610. * Interpolates a quaternion cubically
  37611. * @param startValue Start value of the animation curve
  37612. * @param outTangent End tangent of the animation curve
  37613. * @param endValue End value of the animation curve
  37614. * @param inTangent Start tangent of the animation curve
  37615. * @param gradient Scalar amount to interpolate
  37616. * @returns Interpolated quaternion value
  37617. */
  37618. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  37619. /**
  37620. * Interpolates a Vector3 linearl
  37621. * @param startValue Start value of the animation curve
  37622. * @param endValue End value of the animation curve
  37623. * @param gradient Scalar amount to interpolate
  37624. * @returns Interpolated scalar value
  37625. */
  37626. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  37627. /**
  37628. * Interpolates a Vector3 cubically
  37629. * @param startValue Start value of the animation curve
  37630. * @param outTangent End tangent of the animation
  37631. * @param endValue End value of the animation curve
  37632. * @param inTangent Start tangent of the animation curve
  37633. * @param gradient Scalar amount to interpolate
  37634. * @returns InterpolatedVector3 value
  37635. */
  37636. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  37637. /**
  37638. * Interpolates a Vector2 linearly
  37639. * @param startValue Start value of the animation curve
  37640. * @param endValue End value of the animation curve
  37641. * @param gradient Scalar amount to interpolate
  37642. * @returns Interpolated Vector2 value
  37643. */
  37644. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  37645. /**
  37646. * Interpolates a Vector2 cubically
  37647. * @param startValue Start value of the animation curve
  37648. * @param outTangent End tangent of the animation
  37649. * @param endValue End value of the animation curve
  37650. * @param inTangent Start tangent of the animation curve
  37651. * @param gradient Scalar amount to interpolate
  37652. * @returns Interpolated Vector2 value
  37653. */
  37654. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  37655. /**
  37656. * Interpolates a size linearly
  37657. * @param startValue Start value of the animation curve
  37658. * @param endValue End value of the animation curve
  37659. * @param gradient Scalar amount to interpolate
  37660. * @returns Interpolated Size value
  37661. */
  37662. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  37663. /**
  37664. * Interpolates a Color3 linearly
  37665. * @param startValue Start value of the animation curve
  37666. * @param endValue End value of the animation curve
  37667. * @param gradient Scalar amount to interpolate
  37668. * @returns Interpolated Color3 value
  37669. */
  37670. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  37671. /**
  37672. * Interpolates a Color4 linearly
  37673. * @param startValue Start value of the animation curve
  37674. * @param endValue End value of the animation curve
  37675. * @param gradient Scalar amount to interpolate
  37676. * @returns Interpolated Color3 value
  37677. */
  37678. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  37679. /**
  37680. * @hidden Internal use only
  37681. */
  37682. _getKeyValue(value: any): any;
  37683. /**
  37684. * @hidden Internal use only
  37685. */
  37686. _interpolate(currentFrame: number, state: _IAnimationState): any;
  37687. /**
  37688. * Defines the function to use to interpolate matrices
  37689. * @param startValue defines the start matrix
  37690. * @param endValue defines the end matrix
  37691. * @param gradient defines the gradient between both matrices
  37692. * @param result defines an optional target matrix where to store the interpolation
  37693. * @returns the interpolated matrix
  37694. */
  37695. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  37696. /**
  37697. * Makes a copy of the animation
  37698. * @returns Cloned animation
  37699. */
  37700. clone(): Animation;
  37701. /**
  37702. * Sets the key frames of the animation
  37703. * @param values The animation key frames to set
  37704. */
  37705. setKeys(values: Array<IAnimationKey>): void;
  37706. /**
  37707. * Serializes the animation to an object
  37708. * @returns Serialized object
  37709. */
  37710. serialize(): any;
  37711. /**
  37712. * Float animation type
  37713. */
  37714. static readonly ANIMATIONTYPE_FLOAT: number;
  37715. /**
  37716. * Vector3 animation type
  37717. */
  37718. static readonly ANIMATIONTYPE_VECTOR3: number;
  37719. /**
  37720. * Quaternion animation type
  37721. */
  37722. static readonly ANIMATIONTYPE_QUATERNION: number;
  37723. /**
  37724. * Matrix animation type
  37725. */
  37726. static readonly ANIMATIONTYPE_MATRIX: number;
  37727. /**
  37728. * Color3 animation type
  37729. */
  37730. static readonly ANIMATIONTYPE_COLOR3: number;
  37731. /**
  37732. * Color3 animation type
  37733. */
  37734. static readonly ANIMATIONTYPE_COLOR4: number;
  37735. /**
  37736. * Vector2 animation type
  37737. */
  37738. static readonly ANIMATIONTYPE_VECTOR2: number;
  37739. /**
  37740. * Size animation type
  37741. */
  37742. static readonly ANIMATIONTYPE_SIZE: number;
  37743. /**
  37744. * Relative Loop Mode
  37745. */
  37746. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  37747. /**
  37748. * Cycle Loop Mode
  37749. */
  37750. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  37751. /**
  37752. * Constant Loop Mode
  37753. */
  37754. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  37755. /** @hidden */
  37756. static _UniversalLerp(left: any, right: any, amount: number): any;
  37757. /**
  37758. * Parses an animation object and creates an animation
  37759. * @param parsedAnimation Parsed animation object
  37760. * @returns Animation object
  37761. */
  37762. static Parse(parsedAnimation: any): Animation;
  37763. /**
  37764. * Appends the serialized animations from the source animations
  37765. * @param source Source containing the animations
  37766. * @param destination Target to store the animations
  37767. */
  37768. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  37769. /**
  37770. * Creates a new animation or an array of animations from a snippet saved in a remote file
  37771. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  37772. * @param url defines the url to load from
  37773. * @returns a promise that will resolve to the new animation or an array of animations
  37774. */
  37775. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  37776. /**
  37777. * Creates an animation or an array of animations from a snippet saved by the Inspector
  37778. * @param snippetId defines the snippet to load
  37779. * @returns a promise that will resolve to the new animation or a new array of animations
  37780. */
  37781. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  37782. }
  37783. }
  37784. declare module BABYLON {
  37785. /**
  37786. * Interface containing an array of animations
  37787. */
  37788. export interface IAnimatable {
  37789. /**
  37790. * Array of animations
  37791. */
  37792. animations: Nullable<Array<Animation>>;
  37793. }
  37794. }
  37795. declare module BABYLON {
  37796. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  37797. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37798. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37799. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37800. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37801. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37802. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37803. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37804. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37805. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37806. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37807. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37808. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37809. /**
  37810. * Decorator used to define property that can be serialized as reference to a camera
  37811. * @param sourceName defines the name of the property to decorate
  37812. */
  37813. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37814. /**
  37815. * Class used to help serialization objects
  37816. */
  37817. export class SerializationHelper {
  37818. /** @hidden */
  37819. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  37820. /** @hidden */
  37821. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  37822. /** @hidden */
  37823. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  37824. /** @hidden */
  37825. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  37826. /**
  37827. * Appends the serialized animations from the source animations
  37828. * @param source Source containing the animations
  37829. * @param destination Target to store the animations
  37830. */
  37831. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  37832. /**
  37833. * Static function used to serialized a specific entity
  37834. * @param entity defines the entity to serialize
  37835. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  37836. * @returns a JSON compatible object representing the serialization of the entity
  37837. */
  37838. static Serialize<T>(entity: T, serializationObject?: any): any;
  37839. /**
  37840. * Creates a new entity from a serialization data object
  37841. * @param creationFunction defines a function used to instanciated the new entity
  37842. * @param source defines the source serialization data
  37843. * @param scene defines the hosting scene
  37844. * @param rootUrl defines the root url for resources
  37845. * @returns a new entity
  37846. */
  37847. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  37848. /**
  37849. * Clones an object
  37850. * @param creationFunction defines the function used to instanciate the new object
  37851. * @param source defines the source object
  37852. * @returns the cloned object
  37853. */
  37854. static Clone<T>(creationFunction: () => T, source: T): T;
  37855. /**
  37856. * Instanciates a new object based on a source one (some data will be shared between both object)
  37857. * @param creationFunction defines the function used to instanciate the new object
  37858. * @param source defines the source object
  37859. * @returns the new object
  37860. */
  37861. static Instanciate<T>(creationFunction: () => T, source: T): T;
  37862. }
  37863. }
  37864. declare module BABYLON {
  37865. /**
  37866. * This is the base class of all the camera used in the application.
  37867. * @see https://doc.babylonjs.com/features/cameras
  37868. */
  37869. export class Camera extends Node {
  37870. /** @hidden */
  37871. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  37872. /**
  37873. * This is the default projection mode used by the cameras.
  37874. * It helps recreating a feeling of perspective and better appreciate depth.
  37875. * This is the best way to simulate real life cameras.
  37876. */
  37877. static readonly PERSPECTIVE_CAMERA: number;
  37878. /**
  37879. * This helps creating camera with an orthographic mode.
  37880. * 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.
  37881. */
  37882. static readonly ORTHOGRAPHIC_CAMERA: number;
  37883. /**
  37884. * This is the default FOV mode for perspective cameras.
  37885. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  37886. */
  37887. static readonly FOVMODE_VERTICAL_FIXED: number;
  37888. /**
  37889. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  37890. */
  37891. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  37892. /**
  37893. * This specifies ther is no need for a camera rig.
  37894. * Basically only one eye is rendered corresponding to the camera.
  37895. */
  37896. static readonly RIG_MODE_NONE: number;
  37897. /**
  37898. * Simulates a camera Rig with one blue eye and one red eye.
  37899. * This can be use with 3d blue and red glasses.
  37900. */
  37901. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  37902. /**
  37903. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  37904. */
  37905. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  37906. /**
  37907. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  37908. */
  37909. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  37910. /**
  37911. * Defines that both eyes of the camera will be rendered over under each other.
  37912. */
  37913. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  37914. /**
  37915. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  37916. */
  37917. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  37918. /**
  37919. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  37920. */
  37921. static readonly RIG_MODE_VR: number;
  37922. /**
  37923. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  37924. */
  37925. static readonly RIG_MODE_WEBVR: number;
  37926. /**
  37927. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  37928. */
  37929. static readonly RIG_MODE_CUSTOM: number;
  37930. /**
  37931. * Defines if by default attaching controls should prevent the default javascript event to continue.
  37932. */
  37933. static ForceAttachControlToAlwaysPreventDefault: boolean;
  37934. /**
  37935. * Define the input manager associated with the camera.
  37936. */
  37937. inputs: CameraInputsManager<Camera>;
  37938. /** @hidden */
  37939. _position: Vector3;
  37940. /**
  37941. * Define the current local position of the camera in the scene
  37942. */
  37943. get position(): Vector3;
  37944. set position(newPosition: Vector3);
  37945. protected _upVector: Vector3;
  37946. /**
  37947. * The vector the camera should consider as up.
  37948. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  37949. */
  37950. set upVector(vec: Vector3);
  37951. get upVector(): Vector3;
  37952. /**
  37953. * Define the current limit on the left side for an orthographic camera
  37954. * In scene unit
  37955. */
  37956. orthoLeft: Nullable<number>;
  37957. /**
  37958. * Define the current limit on the right side for an orthographic camera
  37959. * In scene unit
  37960. */
  37961. orthoRight: Nullable<number>;
  37962. /**
  37963. * Define the current limit on the bottom side for an orthographic camera
  37964. * In scene unit
  37965. */
  37966. orthoBottom: Nullable<number>;
  37967. /**
  37968. * Define the current limit on the top side for an orthographic camera
  37969. * In scene unit
  37970. */
  37971. orthoTop: Nullable<number>;
  37972. /**
  37973. * Field Of View is set in Radians. (default is 0.8)
  37974. */
  37975. fov: number;
  37976. /**
  37977. * Define the minimum distance the camera can see from.
  37978. * This is important to note that the depth buffer are not infinite and the closer it starts
  37979. * the more your scene might encounter depth fighting issue.
  37980. */
  37981. minZ: number;
  37982. /**
  37983. * Define the maximum distance the camera can see to.
  37984. * This is important to note that the depth buffer are not infinite and the further it end
  37985. * the more your scene might encounter depth fighting issue.
  37986. */
  37987. maxZ: number;
  37988. /**
  37989. * Define the default inertia of the camera.
  37990. * This helps giving a smooth feeling to the camera movement.
  37991. */
  37992. inertia: number;
  37993. /**
  37994. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  37995. */
  37996. mode: number;
  37997. /**
  37998. * Define whether the camera is intermediate.
  37999. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  38000. */
  38001. isIntermediate: boolean;
  38002. /**
  38003. * Define the viewport of the camera.
  38004. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  38005. */
  38006. viewport: Viewport;
  38007. /**
  38008. * Restricts the camera to viewing objects with the same layerMask.
  38009. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  38010. */
  38011. layerMask: number;
  38012. /**
  38013. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  38014. */
  38015. fovMode: number;
  38016. /**
  38017. * Rig mode of the camera.
  38018. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  38019. * This is normally controlled byt the camera themselves as internal use.
  38020. */
  38021. cameraRigMode: number;
  38022. /**
  38023. * Defines the distance between both "eyes" in case of a RIG
  38024. */
  38025. interaxialDistance: number;
  38026. /**
  38027. * Defines if stereoscopic rendering is done side by side or over under.
  38028. */
  38029. isStereoscopicSideBySide: boolean;
  38030. /**
  38031. * 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
  38032. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  38033. * else in the scene. (Eg. security camera)
  38034. *
  38035. * 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)
  38036. */
  38037. customRenderTargets: RenderTargetTexture[];
  38038. /**
  38039. * When set, the camera will render to this render target instead of the default canvas
  38040. *
  38041. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  38042. */
  38043. outputRenderTarget: Nullable<RenderTargetTexture>;
  38044. /**
  38045. * Observable triggered when the camera view matrix has changed.
  38046. */
  38047. onViewMatrixChangedObservable: Observable<Camera>;
  38048. /**
  38049. * Observable triggered when the camera Projection matrix has changed.
  38050. */
  38051. onProjectionMatrixChangedObservable: Observable<Camera>;
  38052. /**
  38053. * Observable triggered when the inputs have been processed.
  38054. */
  38055. onAfterCheckInputsObservable: Observable<Camera>;
  38056. /**
  38057. * Observable triggered when reset has been called and applied to the camera.
  38058. */
  38059. onRestoreStateObservable: Observable<Camera>;
  38060. /**
  38061. * Is this camera a part of a rig system?
  38062. */
  38063. isRigCamera: boolean;
  38064. /**
  38065. * If isRigCamera set to true this will be set with the parent camera.
  38066. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  38067. */
  38068. rigParent?: Camera;
  38069. /** @hidden */
  38070. _cameraRigParams: any;
  38071. /** @hidden */
  38072. _rigCameras: Camera[];
  38073. /** @hidden */
  38074. _rigPostProcess: Nullable<PostProcess>;
  38075. protected _webvrViewMatrix: Matrix;
  38076. /** @hidden */
  38077. _skipRendering: boolean;
  38078. /** @hidden */
  38079. _projectionMatrix: Matrix;
  38080. /** @hidden */
  38081. _postProcesses: Nullable<PostProcess>[];
  38082. /** @hidden */
  38083. _activeMeshes: SmartArray<AbstractMesh>;
  38084. protected _globalPosition: Vector3;
  38085. /** @hidden */
  38086. _computedViewMatrix: Matrix;
  38087. private _doNotComputeProjectionMatrix;
  38088. private _transformMatrix;
  38089. private _frustumPlanes;
  38090. private _refreshFrustumPlanes;
  38091. private _storedFov;
  38092. private _stateStored;
  38093. /**
  38094. * Instantiates a new camera object.
  38095. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  38096. * @see https://doc.babylonjs.com/features/cameras
  38097. * @param name Defines the name of the camera in the scene
  38098. * @param position Defines the position of the camera
  38099. * @param scene Defines the scene the camera belongs too
  38100. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  38101. */
  38102. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  38103. /**
  38104. * Store current camera state (fov, position, etc..)
  38105. * @returns the camera
  38106. */
  38107. storeState(): Camera;
  38108. /**
  38109. * Restores the camera state values if it has been stored. You must call storeState() first
  38110. */
  38111. protected _restoreStateValues(): boolean;
  38112. /**
  38113. * Restored camera state. You must call storeState() first.
  38114. * @returns true if restored and false otherwise
  38115. */
  38116. restoreState(): boolean;
  38117. /**
  38118. * Gets the class name of the camera.
  38119. * @returns the class name
  38120. */
  38121. getClassName(): string;
  38122. /** @hidden */
  38123. readonly _isCamera: boolean;
  38124. /**
  38125. * Gets a string representation of the camera useful for debug purpose.
  38126. * @param fullDetails Defines that a more verboe level of logging is required
  38127. * @returns the string representation
  38128. */
  38129. toString(fullDetails?: boolean): string;
  38130. /**
  38131. * Gets the current world space position of the camera.
  38132. */
  38133. get globalPosition(): Vector3;
  38134. /**
  38135. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  38136. * @returns the active meshe list
  38137. */
  38138. getActiveMeshes(): SmartArray<AbstractMesh>;
  38139. /**
  38140. * Check whether a mesh is part of the current active mesh list of the camera
  38141. * @param mesh Defines the mesh to check
  38142. * @returns true if active, false otherwise
  38143. */
  38144. isActiveMesh(mesh: Mesh): boolean;
  38145. /**
  38146. * Is this camera ready to be used/rendered
  38147. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  38148. * @return true if the camera is ready
  38149. */
  38150. isReady(completeCheck?: boolean): boolean;
  38151. /** @hidden */
  38152. _initCache(): void;
  38153. /** @hidden */
  38154. _updateCache(ignoreParentClass?: boolean): void;
  38155. /** @hidden */
  38156. _isSynchronized(): boolean;
  38157. /** @hidden */
  38158. _isSynchronizedViewMatrix(): boolean;
  38159. /** @hidden */
  38160. _isSynchronizedProjectionMatrix(): boolean;
  38161. /**
  38162. * Attach the input controls to a specific dom element to get the input from.
  38163. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38164. */
  38165. attachControl(noPreventDefault?: boolean): void;
  38166. /**
  38167. * Attach the input controls to a specific dom element to get the input from.
  38168. * @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
  38169. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38170. * BACK COMPAT SIGNATURE ONLY.
  38171. */
  38172. attachControl(ignored: any, noPreventDefault?: boolean): void;
  38173. /**
  38174. * Detach the current controls from the specified dom element.
  38175. */
  38176. detachControl(): void;
  38177. /**
  38178. * Detach the current controls from the specified dom element.
  38179. * @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
  38180. */
  38181. detachControl(ignored: any): void;
  38182. /**
  38183. * Update the camera state according to the different inputs gathered during the frame.
  38184. */
  38185. update(): void;
  38186. /** @hidden */
  38187. _checkInputs(): void;
  38188. /** @hidden */
  38189. get rigCameras(): Camera[];
  38190. /**
  38191. * Gets the post process used by the rig cameras
  38192. */
  38193. get rigPostProcess(): Nullable<PostProcess>;
  38194. /**
  38195. * Internal, gets the first post proces.
  38196. * @returns the first post process to be run on this camera.
  38197. */
  38198. _getFirstPostProcess(): Nullable<PostProcess>;
  38199. private _cascadePostProcessesToRigCams;
  38200. /**
  38201. * Attach a post process to the camera.
  38202. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  38203. * @param postProcess The post process to attach to the camera
  38204. * @param insertAt The position of the post process in case several of them are in use in the scene
  38205. * @returns the position the post process has been inserted at
  38206. */
  38207. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  38208. /**
  38209. * Detach a post process to the camera.
  38210. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  38211. * @param postProcess The post process to detach from the camera
  38212. */
  38213. detachPostProcess(postProcess: PostProcess): void;
  38214. /**
  38215. * Gets the current world matrix of the camera
  38216. */
  38217. getWorldMatrix(): Matrix;
  38218. /** @hidden */
  38219. _getViewMatrix(): Matrix;
  38220. /**
  38221. * Gets the current view matrix of the camera.
  38222. * @param force forces the camera to recompute the matrix without looking at the cached state
  38223. * @returns the view matrix
  38224. */
  38225. getViewMatrix(force?: boolean): Matrix;
  38226. /**
  38227. * Freeze the projection matrix.
  38228. * It will prevent the cache check of the camera projection compute and can speed up perf
  38229. * if no parameter of the camera are meant to change
  38230. * @param projection Defines manually a projection if necessary
  38231. */
  38232. freezeProjectionMatrix(projection?: Matrix): void;
  38233. /**
  38234. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  38235. */
  38236. unfreezeProjectionMatrix(): void;
  38237. /**
  38238. * Gets the current projection matrix of the camera.
  38239. * @param force forces the camera to recompute the matrix without looking at the cached state
  38240. * @returns the projection matrix
  38241. */
  38242. getProjectionMatrix(force?: boolean): Matrix;
  38243. /**
  38244. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  38245. * @returns a Matrix
  38246. */
  38247. getTransformationMatrix(): Matrix;
  38248. private _updateFrustumPlanes;
  38249. /**
  38250. * Checks if a cullable object (mesh...) is in the camera frustum
  38251. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  38252. * @param target The object to check
  38253. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  38254. * @returns true if the object is in frustum otherwise false
  38255. */
  38256. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  38257. /**
  38258. * Checks if a cullable object (mesh...) is in the camera frustum
  38259. * Unlike isInFrustum this cheks the full bounding box
  38260. * @param target The object to check
  38261. * @returns true if the object is in frustum otherwise false
  38262. */
  38263. isCompletelyInFrustum(target: ICullable): boolean;
  38264. /**
  38265. * Gets a ray in the forward direction from the camera.
  38266. * @param length Defines the length of the ray to create
  38267. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  38268. * @param origin Defines the start point of the ray which defaults to the camera position
  38269. * @returns the forward ray
  38270. */
  38271. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  38272. /**
  38273. * Gets a ray in the forward direction from the camera.
  38274. * @param refRay the ray to (re)use when setting the values
  38275. * @param length Defines the length of the ray to create
  38276. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  38277. * @param origin Defines the start point of the ray which defaults to the camera position
  38278. * @returns the forward ray
  38279. */
  38280. getForwardRayToRef(refRay: Ray, length?: number, transform?: Matrix, origin?: Vector3): Ray;
  38281. /**
  38282. * Releases resources associated with this node.
  38283. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  38284. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  38285. */
  38286. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  38287. /** @hidden */
  38288. _isLeftCamera: boolean;
  38289. /**
  38290. * Gets the left camera of a rig setup in case of Rigged Camera
  38291. */
  38292. get isLeftCamera(): boolean;
  38293. /** @hidden */
  38294. _isRightCamera: boolean;
  38295. /**
  38296. * Gets the right camera of a rig setup in case of Rigged Camera
  38297. */
  38298. get isRightCamera(): boolean;
  38299. /**
  38300. * Gets the left camera of a rig setup in case of Rigged Camera
  38301. */
  38302. get leftCamera(): Nullable<FreeCamera>;
  38303. /**
  38304. * Gets the right camera of a rig setup in case of Rigged Camera
  38305. */
  38306. get rightCamera(): Nullable<FreeCamera>;
  38307. /**
  38308. * Gets the left camera target of a rig setup in case of Rigged Camera
  38309. * @returns the target position
  38310. */
  38311. getLeftTarget(): Nullable<Vector3>;
  38312. /**
  38313. * Gets the right camera target of a rig setup in case of Rigged Camera
  38314. * @returns the target position
  38315. */
  38316. getRightTarget(): Nullable<Vector3>;
  38317. /**
  38318. * @hidden
  38319. */
  38320. setCameraRigMode(mode: number, rigParams: any): void;
  38321. /** @hidden */
  38322. static _setStereoscopicRigMode(camera: Camera): void;
  38323. /** @hidden */
  38324. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  38325. /** @hidden */
  38326. static _setVRRigMode(camera: Camera, rigParams: any): void;
  38327. /** @hidden */
  38328. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  38329. /** @hidden */
  38330. _getVRProjectionMatrix(): Matrix;
  38331. protected _updateCameraRotationMatrix(): void;
  38332. protected _updateWebVRCameraRotationMatrix(): void;
  38333. /**
  38334. * This function MUST be overwritten by the different WebVR cameras available.
  38335. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  38336. * @hidden
  38337. */
  38338. _getWebVRProjectionMatrix(): Matrix;
  38339. /**
  38340. * This function MUST be overwritten by the different WebVR cameras available.
  38341. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  38342. * @hidden
  38343. */
  38344. _getWebVRViewMatrix(): Matrix;
  38345. /** @hidden */
  38346. setCameraRigParameter(name: string, value: any): void;
  38347. /**
  38348. * needs to be overridden by children so sub has required properties to be copied
  38349. * @hidden
  38350. */
  38351. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  38352. /**
  38353. * May need to be overridden by children
  38354. * @hidden
  38355. */
  38356. _updateRigCameras(): void;
  38357. /** @hidden */
  38358. _setupInputs(): void;
  38359. /**
  38360. * Serialiaze the camera setup to a json represention
  38361. * @returns the JSON representation
  38362. */
  38363. serialize(): any;
  38364. /**
  38365. * Clones the current camera.
  38366. * @param name The cloned camera name
  38367. * @returns the cloned camera
  38368. */
  38369. clone(name: string): Camera;
  38370. /**
  38371. * Gets the direction of the camera relative to a given local axis.
  38372. * @param localAxis Defines the reference axis to provide a relative direction.
  38373. * @return the direction
  38374. */
  38375. getDirection(localAxis: Vector3): Vector3;
  38376. /**
  38377. * Returns the current camera absolute rotation
  38378. */
  38379. get absoluteRotation(): Quaternion;
  38380. /**
  38381. * Gets the direction of the camera relative to a given local axis into a passed vector.
  38382. * @param localAxis Defines the reference axis to provide a relative direction.
  38383. * @param result Defines the vector to store the result in
  38384. */
  38385. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  38386. /**
  38387. * Gets a camera constructor for a given camera type
  38388. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  38389. * @param name The name of the camera the result will be able to instantiate
  38390. * @param scene The scene the result will construct the camera in
  38391. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  38392. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  38393. * @returns a factory method to construc the camera
  38394. */
  38395. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  38396. /**
  38397. * Compute the world matrix of the camera.
  38398. * @returns the camera world matrix
  38399. */
  38400. computeWorldMatrix(): Matrix;
  38401. /**
  38402. * Parse a JSON and creates the camera from the parsed information
  38403. * @param parsedCamera The JSON to parse
  38404. * @param scene The scene to instantiate the camera in
  38405. * @returns the newly constructed camera
  38406. */
  38407. static Parse(parsedCamera: any, scene: Scene): Camera;
  38408. }
  38409. }
  38410. declare module BABYLON {
  38411. /**
  38412. * PostProcessManager is used to manage one or more post processes or post process pipelines
  38413. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  38414. */
  38415. export class PostProcessManager {
  38416. private _scene;
  38417. private _indexBuffer;
  38418. private _vertexBuffers;
  38419. /**
  38420. * Creates a new instance PostProcess
  38421. * @param scene The scene that the post process is associated with.
  38422. */
  38423. constructor(scene: Scene);
  38424. private _prepareBuffers;
  38425. private _buildIndexBuffer;
  38426. /**
  38427. * Rebuilds the vertex buffers of the manager.
  38428. * @hidden
  38429. */
  38430. _rebuild(): void;
  38431. /**
  38432. * Prepares a frame to be run through a post process.
  38433. * @param sourceTexture The input texture to the post procesess. (default: null)
  38434. * @param postProcesses An array of post processes to be run. (default: null)
  38435. * @returns True if the post processes were able to be run.
  38436. * @hidden
  38437. */
  38438. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  38439. /**
  38440. * Manually render a set of post processes to a texture.
  38441. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  38442. * @param postProcesses An array of post processes to be run.
  38443. * @param targetTexture The target texture to render to.
  38444. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  38445. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  38446. * @param lodLevel defines which lod of the texture to render to
  38447. * @param doNotBindFrambuffer If set to true, assumes that the framebuffer has been bound previously
  38448. */
  38449. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number, doNotBindFrambuffer?: boolean): void;
  38450. /**
  38451. * Finalize the result of the output of the postprocesses.
  38452. * @param doNotPresent If true the result will not be displayed to the screen.
  38453. * @param targetTexture The target texture to render to.
  38454. * @param faceIndex The index of the face to bind the target texture to.
  38455. * @param postProcesses The array of post processes to render.
  38456. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  38457. * @hidden
  38458. */
  38459. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  38460. /**
  38461. * Disposes of the post process manager.
  38462. */
  38463. dispose(): void;
  38464. }
  38465. }
  38466. declare module BABYLON {
  38467. /**
  38468. * This Helps creating a texture that will be created from a camera in your scene.
  38469. * It is basically a dynamic texture that could be used to create special effects for instance.
  38470. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  38471. */
  38472. export class RenderTargetTexture extends Texture {
  38473. /**
  38474. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  38475. */
  38476. static readonly REFRESHRATE_RENDER_ONCE: number;
  38477. /**
  38478. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  38479. */
  38480. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  38481. /**
  38482. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  38483. * the central point of your effect and can save a lot of performances.
  38484. */
  38485. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  38486. /**
  38487. * Use this predicate to dynamically define the list of mesh you want to render.
  38488. * If set, the renderList property will be overwritten.
  38489. */
  38490. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  38491. private _renderList;
  38492. /**
  38493. * Use this list to define the list of mesh you want to render.
  38494. */
  38495. get renderList(): Nullable<Array<AbstractMesh>>;
  38496. set renderList(value: Nullable<Array<AbstractMesh>>);
  38497. /**
  38498. * Use this function to overload the renderList array at rendering time.
  38499. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  38500. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  38501. * the cube (if the RTT is a cube, else layerOrFace=0).
  38502. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  38503. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  38504. * hold dummy elements!
  38505. */
  38506. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  38507. private _hookArray;
  38508. /**
  38509. * Define if particles should be rendered in your texture.
  38510. */
  38511. renderParticles: boolean;
  38512. /**
  38513. * Define if sprites should be rendered in your texture.
  38514. */
  38515. renderSprites: boolean;
  38516. /**
  38517. * Define the camera used to render the texture.
  38518. */
  38519. activeCamera: Nullable<Camera>;
  38520. /**
  38521. * Override the mesh isReady function with your own one.
  38522. */
  38523. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  38524. /**
  38525. * Override the render function of the texture with your own one.
  38526. */
  38527. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  38528. /**
  38529. * Define if camera post processes should be use while rendering the texture.
  38530. */
  38531. useCameraPostProcesses: boolean;
  38532. /**
  38533. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  38534. */
  38535. ignoreCameraViewport: boolean;
  38536. private _postProcessManager;
  38537. private _postProcesses;
  38538. private _resizeObserver;
  38539. /**
  38540. * An event triggered when the texture is unbind.
  38541. */
  38542. onBeforeBindObservable: Observable<RenderTargetTexture>;
  38543. /**
  38544. * An event triggered when the texture is unbind.
  38545. */
  38546. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  38547. private _onAfterUnbindObserver;
  38548. /**
  38549. * Set a after unbind callback in the texture.
  38550. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  38551. */
  38552. set onAfterUnbind(callback: () => void);
  38553. /**
  38554. * An event triggered before rendering the texture
  38555. */
  38556. onBeforeRenderObservable: Observable<number>;
  38557. private _onBeforeRenderObserver;
  38558. /**
  38559. * Set a before render callback in the texture.
  38560. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  38561. */
  38562. set onBeforeRender(callback: (faceIndex: number) => void);
  38563. /**
  38564. * An event triggered after rendering the texture
  38565. */
  38566. onAfterRenderObservable: Observable<number>;
  38567. private _onAfterRenderObserver;
  38568. /**
  38569. * Set a after render callback in the texture.
  38570. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  38571. */
  38572. set onAfterRender(callback: (faceIndex: number) => void);
  38573. /**
  38574. * An event triggered after the texture clear
  38575. */
  38576. onClearObservable: Observable<Engine>;
  38577. private _onClearObserver;
  38578. /**
  38579. * Set a clear callback in the texture.
  38580. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  38581. */
  38582. set onClear(callback: (Engine: Engine) => void);
  38583. /**
  38584. * An event triggered when the texture is resized.
  38585. */
  38586. onResizeObservable: Observable<RenderTargetTexture>;
  38587. /**
  38588. * Define the clear color of the Render Target if it should be different from the scene.
  38589. */
  38590. clearColor: Color4;
  38591. protected _size: number | {
  38592. width: number;
  38593. height: number;
  38594. layers?: number;
  38595. };
  38596. protected _initialSizeParameter: number | {
  38597. width: number;
  38598. height: number;
  38599. } | {
  38600. ratio: number;
  38601. };
  38602. protected _sizeRatio: Nullable<number>;
  38603. /** @hidden */
  38604. _generateMipMaps: boolean;
  38605. protected _renderingManager: RenderingManager;
  38606. /** @hidden */
  38607. _waitingRenderList?: string[];
  38608. protected _doNotChangeAspectRatio: boolean;
  38609. protected _currentRefreshId: number;
  38610. protected _refreshRate: number;
  38611. protected _textureMatrix: Matrix;
  38612. protected _samples: number;
  38613. protected _renderTargetOptions: RenderTargetCreationOptions;
  38614. /**
  38615. * Gets render target creation options that were used.
  38616. */
  38617. get renderTargetOptions(): RenderTargetCreationOptions;
  38618. protected _onRatioRescale(): void;
  38619. /**
  38620. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  38621. * It must define where the camera used to render the texture is set
  38622. */
  38623. boundingBoxPosition: Vector3;
  38624. private _boundingBoxSize;
  38625. /**
  38626. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  38627. * When defined, the cubemap will switch to local mode
  38628. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  38629. * @example https://www.babylonjs-playground.com/#RNASML
  38630. */
  38631. set boundingBoxSize(value: Vector3);
  38632. get boundingBoxSize(): Vector3;
  38633. /**
  38634. * In case the RTT has been created with a depth texture, get the associated
  38635. * depth texture.
  38636. * Otherwise, return null.
  38637. */
  38638. get depthStencilTexture(): Nullable<InternalTexture>;
  38639. /**
  38640. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  38641. * or used a shadow, depth texture...
  38642. * @param name The friendly name of the texture
  38643. * @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)
  38644. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  38645. * @param generateMipMaps True if mip maps need to be generated after render.
  38646. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  38647. * @param type The type of the buffer in the RTT (int, half float, float...)
  38648. * @param isCube True if a cube texture needs to be created
  38649. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  38650. * @param generateDepthBuffer True to generate a depth buffer
  38651. * @param generateStencilBuffer True to generate a stencil buffer
  38652. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  38653. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  38654. * @param delayAllocation if the texture allocation should be delayed (default: false)
  38655. * @param samples sample count to use when creating the RTT
  38656. */
  38657. constructor(name: string, size: number | {
  38658. width: number;
  38659. height: number;
  38660. layers?: number;
  38661. } | {
  38662. ratio: number;
  38663. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean, samples?: number);
  38664. /**
  38665. * Creates a depth stencil texture.
  38666. * This is only available in WebGL 2 or with the depth texture extension available.
  38667. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  38668. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  38669. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  38670. * @param samples sample count of the depth/stencil texture
  38671. */
  38672. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean, samples?: number): void;
  38673. private _processSizeParameter;
  38674. /**
  38675. * Define the number of samples to use in case of MSAA.
  38676. * It defaults to one meaning no MSAA has been enabled.
  38677. */
  38678. get samples(): number;
  38679. set samples(value: number);
  38680. /**
  38681. * Resets the refresh counter of the texture and start bak from scratch.
  38682. * Could be useful to regenerate the texture if it is setup to render only once.
  38683. */
  38684. resetRefreshCounter(): void;
  38685. /**
  38686. * Define the refresh rate of the texture or the rendering frequency.
  38687. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  38688. */
  38689. get refreshRate(): number;
  38690. set refreshRate(value: number);
  38691. /**
  38692. * Adds a post process to the render target rendering passes.
  38693. * @param postProcess define the post process to add
  38694. */
  38695. addPostProcess(postProcess: PostProcess): void;
  38696. /**
  38697. * Clear all the post processes attached to the render target
  38698. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  38699. */
  38700. clearPostProcesses(dispose?: boolean): void;
  38701. /**
  38702. * Remove one of the post process from the list of attached post processes to the texture
  38703. * @param postProcess define the post process to remove from the list
  38704. */
  38705. removePostProcess(postProcess: PostProcess): void;
  38706. /** @hidden */
  38707. _shouldRender(): boolean;
  38708. /**
  38709. * Gets the actual render size of the texture.
  38710. * @returns the width of the render size
  38711. */
  38712. getRenderSize(): number;
  38713. /**
  38714. * Gets the actual render width of the texture.
  38715. * @returns the width of the render size
  38716. */
  38717. getRenderWidth(): number;
  38718. /**
  38719. * Gets the actual render height of the texture.
  38720. * @returns the height of the render size
  38721. */
  38722. getRenderHeight(): number;
  38723. /**
  38724. * Gets the actual number of layers of the texture.
  38725. * @returns the number of layers
  38726. */
  38727. getRenderLayers(): number;
  38728. /**
  38729. * Get if the texture can be rescaled or not.
  38730. */
  38731. get canRescale(): boolean;
  38732. /**
  38733. * Resize the texture using a ratio.
  38734. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  38735. */
  38736. scale(ratio: number): void;
  38737. /**
  38738. * Get the texture reflection matrix used to rotate/transform the reflection.
  38739. * @returns the reflection matrix
  38740. */
  38741. getReflectionTextureMatrix(): Matrix;
  38742. /**
  38743. * Resize the texture to a new desired size.
  38744. * Be carrefull as it will recreate all the data in the new texture.
  38745. * @param size Define the new size. It can be:
  38746. * - a number for squared texture,
  38747. * - an object containing { width: number, height: number }
  38748. * - or an object containing a ratio { ratio: number }
  38749. */
  38750. resize(size: number | {
  38751. width: number;
  38752. height: number;
  38753. } | {
  38754. ratio: number;
  38755. }): void;
  38756. private _defaultRenderListPrepared;
  38757. /**
  38758. * Renders all the objects from the render list into the texture.
  38759. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  38760. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  38761. */
  38762. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  38763. private _bestReflectionRenderTargetDimension;
  38764. private _prepareRenderingManager;
  38765. /**
  38766. * @hidden
  38767. * @param faceIndex face index to bind to if this is a cubetexture
  38768. * @param layer defines the index of the texture to bind in the array
  38769. */
  38770. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  38771. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  38772. private renderToTarget;
  38773. /**
  38774. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  38775. * This allowed control for front to back rendering or reversly depending of the special needs.
  38776. *
  38777. * @param renderingGroupId The rendering group id corresponding to its index
  38778. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  38779. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  38780. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  38781. */
  38782. 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;
  38783. /**
  38784. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  38785. *
  38786. * @param renderingGroupId The rendering group id corresponding to its index
  38787. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  38788. */
  38789. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  38790. /**
  38791. * Clones the texture.
  38792. * @returns the cloned texture
  38793. */
  38794. clone(): RenderTargetTexture;
  38795. /**
  38796. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  38797. * @returns The JSON representation of the texture
  38798. */
  38799. serialize(): any;
  38800. /**
  38801. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  38802. */
  38803. disposeFramebufferObjects(): void;
  38804. /**
  38805. * Dispose the texture and release its associated resources.
  38806. */
  38807. dispose(): void;
  38808. /** @hidden */
  38809. _rebuild(): void;
  38810. /**
  38811. * Clear the info related to rendering groups preventing retention point in material dispose.
  38812. */
  38813. freeRenderingGroups(): void;
  38814. /**
  38815. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  38816. * @returns the view count
  38817. */
  38818. getViewCount(): number;
  38819. }
  38820. }
  38821. declare module BABYLON {
  38822. /**
  38823. * Options to be used when creating an effect.
  38824. */
  38825. export interface IEffectCreationOptions {
  38826. /**
  38827. * Atrributes that will be used in the shader.
  38828. */
  38829. attributes: string[];
  38830. /**
  38831. * Uniform varible names that will be set in the shader.
  38832. */
  38833. uniformsNames: string[];
  38834. /**
  38835. * Uniform buffer variable names that will be set in the shader.
  38836. */
  38837. uniformBuffersNames: string[];
  38838. /**
  38839. * Sampler texture variable names that will be set in the shader.
  38840. */
  38841. samplers: string[];
  38842. /**
  38843. * Define statements that will be set in the shader.
  38844. */
  38845. defines: any;
  38846. /**
  38847. * Possible fallbacks for this effect to improve performance when needed.
  38848. */
  38849. fallbacks: Nullable<IEffectFallbacks>;
  38850. /**
  38851. * Callback that will be called when the shader is compiled.
  38852. */
  38853. onCompiled: Nullable<(effect: Effect) => void>;
  38854. /**
  38855. * Callback that will be called if an error occurs during shader compilation.
  38856. */
  38857. onError: Nullable<(effect: Effect, errors: string) => void>;
  38858. /**
  38859. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  38860. */
  38861. indexParameters?: any;
  38862. /**
  38863. * Max number of lights that can be used in the shader.
  38864. */
  38865. maxSimultaneousLights?: number;
  38866. /**
  38867. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  38868. */
  38869. transformFeedbackVaryings?: Nullable<string[]>;
  38870. /**
  38871. * 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
  38872. */
  38873. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  38874. /**
  38875. * Is this effect rendering to several color attachments ?
  38876. */
  38877. multiTarget?: boolean;
  38878. }
  38879. /**
  38880. * Effect containing vertex and fragment shader that can be executed on an object.
  38881. */
  38882. export class Effect implements IDisposable {
  38883. /**
  38884. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  38885. */
  38886. static ShadersRepository: string;
  38887. /**
  38888. * Enable logging of the shader code when a compilation error occurs
  38889. */
  38890. static LogShaderCodeOnCompilationError: boolean;
  38891. /**
  38892. * Name of the effect.
  38893. */
  38894. name: any;
  38895. /**
  38896. * String container all the define statements that should be set on the shader.
  38897. */
  38898. defines: string;
  38899. /**
  38900. * Callback that will be called when the shader is compiled.
  38901. */
  38902. onCompiled: Nullable<(effect: Effect) => void>;
  38903. /**
  38904. * Callback that will be called if an error occurs during shader compilation.
  38905. */
  38906. onError: Nullable<(effect: Effect, errors: string) => void>;
  38907. /**
  38908. * Callback that will be called when effect is bound.
  38909. */
  38910. onBind: Nullable<(effect: Effect) => void>;
  38911. /**
  38912. * Unique ID of the effect.
  38913. */
  38914. uniqueId: number;
  38915. /**
  38916. * Observable that will be called when the shader is compiled.
  38917. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  38918. */
  38919. onCompileObservable: Observable<Effect>;
  38920. /**
  38921. * Observable that will be called if an error occurs during shader compilation.
  38922. */
  38923. onErrorObservable: Observable<Effect>;
  38924. /** @hidden */
  38925. _onBindObservable: Nullable<Observable<Effect>>;
  38926. /**
  38927. * @hidden
  38928. * Specifies if the effect was previously ready
  38929. */
  38930. _wasPreviouslyReady: boolean;
  38931. /**
  38932. * Observable that will be called when effect is bound.
  38933. */
  38934. get onBindObservable(): Observable<Effect>;
  38935. /** @hidden */
  38936. _bonesComputationForcedToCPU: boolean;
  38937. /** @hidden */
  38938. _uniformBuffersNames: {
  38939. [key: string]: number;
  38940. };
  38941. /** @hidden */
  38942. _samplerList: string[];
  38943. /** @hidden */
  38944. _multiTarget: boolean;
  38945. private static _uniqueIdSeed;
  38946. private _engine;
  38947. private _uniformBuffersNamesList;
  38948. private _uniformsNames;
  38949. private _samplers;
  38950. private _isReady;
  38951. private _compilationError;
  38952. private _allFallbacksProcessed;
  38953. private _attributesNames;
  38954. private _attributes;
  38955. private _attributeLocationByName;
  38956. private _uniforms;
  38957. /**
  38958. * Key for the effect.
  38959. * @hidden
  38960. */
  38961. _key: string;
  38962. private _indexParameters;
  38963. private _fallbacks;
  38964. private _vertexSourceCodeOverride;
  38965. private _fragmentSourceCodeOverride;
  38966. private _transformFeedbackVaryings;
  38967. /**
  38968. * Compiled shader to webGL program.
  38969. * @hidden
  38970. */
  38971. _pipelineContext: Nullable<IPipelineContext>;
  38972. /** @hidden */
  38973. _vertexSourceCode: string;
  38974. /** @hidden */
  38975. _fragmentSourceCode: string;
  38976. /** @hidden */
  38977. private _rawVertexSourceCode;
  38978. /** @hidden */
  38979. private _rawFragmentSourceCode;
  38980. private static _baseCache;
  38981. private _processingContext;
  38982. /**
  38983. * Instantiates an effect.
  38984. * An effect can be used to create/manage/execute vertex and fragment shaders.
  38985. * @param baseName Name of the effect.
  38986. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  38987. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  38988. * @param samplers List of sampler variables that will be passed to the shader.
  38989. * @param engine Engine to be used to render the effect
  38990. * @param defines Define statements to be added to the shader.
  38991. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  38992. * @param onCompiled Callback that will be called when the shader is compiled.
  38993. * @param onError Callback that will be called if an error occurs during shader compilation.
  38994. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  38995. * @param key Effect Key identifying uniquely compiled shader variants
  38996. */
  38997. 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, key?: string);
  38998. private _useFinalCode;
  38999. /**
  39000. * Unique key for this effect
  39001. */
  39002. get key(): string;
  39003. /**
  39004. * If the effect has been compiled and prepared.
  39005. * @returns if the effect is compiled and prepared.
  39006. */
  39007. isReady(): boolean;
  39008. private _isReadyInternal;
  39009. /**
  39010. * The engine the effect was initialized with.
  39011. * @returns the engine.
  39012. */
  39013. getEngine(): Engine;
  39014. /**
  39015. * The pipeline context for this effect
  39016. * @returns the associated pipeline context
  39017. */
  39018. getPipelineContext(): Nullable<IPipelineContext>;
  39019. /**
  39020. * The set of names of attribute variables for the shader.
  39021. * @returns An array of attribute names.
  39022. */
  39023. getAttributesNames(): string[];
  39024. /**
  39025. * Returns the attribute at the given index.
  39026. * @param index The index of the attribute.
  39027. * @returns The location of the attribute.
  39028. */
  39029. getAttributeLocation(index: number): number;
  39030. /**
  39031. * Returns the attribute based on the name of the variable.
  39032. * @param name of the attribute to look up.
  39033. * @returns the attribute location.
  39034. */
  39035. getAttributeLocationByName(name: string): number;
  39036. /**
  39037. * The number of attributes.
  39038. * @returns the numnber of attributes.
  39039. */
  39040. getAttributesCount(): number;
  39041. /**
  39042. * Gets the index of a uniform variable.
  39043. * @param uniformName of the uniform to look up.
  39044. * @returns the index.
  39045. */
  39046. getUniformIndex(uniformName: string): number;
  39047. /**
  39048. * Returns the attribute based on the name of the variable.
  39049. * @param uniformName of the uniform to look up.
  39050. * @returns the location of the uniform.
  39051. */
  39052. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  39053. /**
  39054. * Returns an array of sampler variable names
  39055. * @returns The array of sampler variable names.
  39056. */
  39057. getSamplers(): string[];
  39058. /**
  39059. * Returns an array of uniform variable names
  39060. * @returns The array of uniform variable names.
  39061. */
  39062. getUniformNames(): string[];
  39063. /**
  39064. * Returns an array of uniform buffer variable names
  39065. * @returns The array of uniform buffer variable names.
  39066. */
  39067. getUniformBuffersNames(): string[];
  39068. /**
  39069. * Returns the index parameters used to create the effect
  39070. * @returns The index parameters object
  39071. */
  39072. getIndexParameters(): any;
  39073. /**
  39074. * The error from the last compilation.
  39075. * @returns the error string.
  39076. */
  39077. getCompilationError(): string;
  39078. /**
  39079. * Gets a boolean indicating that all fallbacks were used during compilation
  39080. * @returns true if all fallbacks were used
  39081. */
  39082. allFallbacksProcessed(): boolean;
  39083. /**
  39084. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  39085. * @param func The callback to be used.
  39086. */
  39087. executeWhenCompiled(func: (effect: Effect) => void): void;
  39088. private _checkIsReady;
  39089. private _loadShader;
  39090. /**
  39091. * Gets the vertex shader source code of this effect
  39092. */
  39093. get vertexSourceCode(): string;
  39094. /**
  39095. * Gets the fragment shader source code of this effect
  39096. */
  39097. get fragmentSourceCode(): string;
  39098. /**
  39099. * Gets the vertex shader source code before it has been processed by the preprocessor
  39100. */
  39101. get rawVertexSourceCode(): string;
  39102. /**
  39103. * Gets the fragment shader source code before it has been processed by the preprocessor
  39104. */
  39105. get rawFragmentSourceCode(): string;
  39106. /**
  39107. * Recompiles the webGL program
  39108. * @param vertexSourceCode The source code for the vertex shader.
  39109. * @param fragmentSourceCode The source code for the fragment shader.
  39110. * @param onCompiled Callback called when completed.
  39111. * @param onError Callback called on error.
  39112. * @hidden
  39113. */
  39114. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  39115. /**
  39116. * Prepares the effect
  39117. * @hidden
  39118. */
  39119. _prepareEffect(): void;
  39120. private _getShaderCodeAndErrorLine;
  39121. private _processCompilationErrors;
  39122. /**
  39123. * Checks if the effect is supported. (Must be called after compilation)
  39124. */
  39125. get isSupported(): boolean;
  39126. /**
  39127. * Binds a texture to the engine to be used as output of the shader.
  39128. * @param channel Name of the output variable.
  39129. * @param texture Texture to bind.
  39130. * @hidden
  39131. */
  39132. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  39133. /**
  39134. * Sets a texture on the engine to be used in the shader.
  39135. * @param channel Name of the sampler variable.
  39136. * @param texture Texture to set.
  39137. */
  39138. setTexture(channel: string, texture: Nullable<ThinTexture>): void;
  39139. /**
  39140. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  39141. * @param channel Name of the sampler variable.
  39142. * @param texture Texture to set.
  39143. */
  39144. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  39145. /**
  39146. * Sets an array of textures on the engine to be used in the shader.
  39147. * @param channel Name of the variable.
  39148. * @param textures Textures to set.
  39149. */
  39150. setTextureArray(channel: string, textures: ThinTexture[]): void;
  39151. /**
  39152. * 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)
  39153. * @param channel Name of the sampler variable.
  39154. * @param postProcess Post process to get the input texture from.
  39155. */
  39156. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  39157. /**
  39158. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  39159. * 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)
  39160. * @param channel Name of the sampler variable.
  39161. * @param postProcess Post process to get the output texture from.
  39162. */
  39163. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  39164. /**
  39165. * Binds a buffer to a uniform.
  39166. * @param buffer Buffer to bind.
  39167. * @param name Name of the uniform variable to bind to.
  39168. */
  39169. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  39170. /**
  39171. * Binds block to a uniform.
  39172. * @param blockName Name of the block to bind.
  39173. * @param index Index to bind.
  39174. */
  39175. bindUniformBlock(blockName: string, index: number): void;
  39176. /**
  39177. * Sets an interger value on a uniform variable.
  39178. * @param uniformName Name of the variable.
  39179. * @param value Value to be set.
  39180. * @returns this effect.
  39181. */
  39182. setInt(uniformName: string, value: number): Effect;
  39183. /**
  39184. * Sets an int2 value on a uniform variable.
  39185. * @param uniformName Name of the variable.
  39186. * @param x First int in int2.
  39187. * @param y Second int in int2.
  39188. * @returns this effect.
  39189. */
  39190. setInt2(uniformName: string, x: number, y: number): Effect;
  39191. /**
  39192. * Sets an int3 value on a uniform variable.
  39193. * @param uniformName Name of the variable.
  39194. * @param x First int in int3.
  39195. * @param y Second int in int3.
  39196. * @param z Third int in int3.
  39197. * @returns this effect.
  39198. */
  39199. setInt3(uniformName: string, x: number, y: number, z: number): Effect;
  39200. /**
  39201. * Sets an int4 value on a uniform variable.
  39202. * @param uniformName Name of the variable.
  39203. * @param x First int in int4.
  39204. * @param y Second int in int4.
  39205. * @param z Third int in int4.
  39206. * @param w Fourth int in int4.
  39207. * @returns this effect.
  39208. */
  39209. setInt4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  39210. /**
  39211. * Sets an int array on a uniform variable.
  39212. * @param uniformName Name of the variable.
  39213. * @param array array to be set.
  39214. * @returns this effect.
  39215. */
  39216. setIntArray(uniformName: string, array: Int32Array): Effect;
  39217. /**
  39218. * 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)
  39219. * @param uniformName Name of the variable.
  39220. * @param array array to be set.
  39221. * @returns this effect.
  39222. */
  39223. setIntArray2(uniformName: string, array: Int32Array): Effect;
  39224. /**
  39225. * 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)
  39226. * @param uniformName Name of the variable.
  39227. * @param array array to be set.
  39228. * @returns this effect.
  39229. */
  39230. setIntArray3(uniformName: string, array: Int32Array): Effect;
  39231. /**
  39232. * 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)
  39233. * @param uniformName Name of the variable.
  39234. * @param array array to be set.
  39235. * @returns this effect.
  39236. */
  39237. setIntArray4(uniformName: string, array: Int32Array): Effect;
  39238. /**
  39239. * Sets an float array on a uniform variable.
  39240. * @param uniformName Name of the variable.
  39241. * @param array array to be set.
  39242. * @returns this effect.
  39243. */
  39244. setFloatArray(uniformName: string, array: FloatArray): Effect;
  39245. /**
  39246. * 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)
  39247. * @param uniformName Name of the variable.
  39248. * @param array array to be set.
  39249. * @returns this effect.
  39250. */
  39251. setFloatArray2(uniformName: string, array: FloatArray): Effect;
  39252. /**
  39253. * 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)
  39254. * @param uniformName Name of the variable.
  39255. * @param array array to be set.
  39256. * @returns this effect.
  39257. */
  39258. setFloatArray3(uniformName: string, array: FloatArray): Effect;
  39259. /**
  39260. * 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)
  39261. * @param uniformName Name of the variable.
  39262. * @param array array to be set.
  39263. * @returns this effect.
  39264. */
  39265. setFloatArray4(uniformName: string, array: FloatArray): Effect;
  39266. /**
  39267. * Sets an array on a uniform variable.
  39268. * @param uniformName Name of the variable.
  39269. * @param array array to be set.
  39270. * @returns this effect.
  39271. */
  39272. setArray(uniformName: string, array: number[]): Effect;
  39273. /**
  39274. * 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)
  39275. * @param uniformName Name of the variable.
  39276. * @param array array to be set.
  39277. * @returns this effect.
  39278. */
  39279. setArray2(uniformName: string, array: number[]): Effect;
  39280. /**
  39281. * 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)
  39282. * @param uniformName Name of the variable.
  39283. * @param array array to be set.
  39284. * @returns this effect.
  39285. */
  39286. setArray3(uniformName: string, array: number[]): Effect;
  39287. /**
  39288. * 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)
  39289. * @param uniformName Name of the variable.
  39290. * @param array array to be set.
  39291. * @returns this effect.
  39292. */
  39293. setArray4(uniformName: string, array: number[]): Effect;
  39294. /**
  39295. * Sets matrices on a uniform variable.
  39296. * @param uniformName Name of the variable.
  39297. * @param matrices matrices to be set.
  39298. * @returns this effect.
  39299. */
  39300. setMatrices(uniformName: string, matrices: Float32Array | Array<number>): Effect;
  39301. /**
  39302. * Sets matrix on a uniform variable.
  39303. * @param uniformName Name of the variable.
  39304. * @param matrix matrix to be set.
  39305. * @returns this effect.
  39306. */
  39307. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  39308. /**
  39309. * 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)
  39310. * @param uniformName Name of the variable.
  39311. * @param matrix matrix to be set.
  39312. * @returns this effect.
  39313. */
  39314. setMatrix3x3(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  39315. /**
  39316. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  39317. * @param uniformName Name of the variable.
  39318. * @param matrix matrix to be set.
  39319. * @returns this effect.
  39320. */
  39321. setMatrix2x2(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  39322. /**
  39323. * Sets a float on a uniform variable.
  39324. * @param uniformName Name of the variable.
  39325. * @param value value to be set.
  39326. * @returns this effect.
  39327. */
  39328. setFloat(uniformName: string, value: number): Effect;
  39329. /**
  39330. * Sets a boolean on a uniform variable.
  39331. * @param uniformName Name of the variable.
  39332. * @param bool value to be set.
  39333. * @returns this effect.
  39334. */
  39335. setBool(uniformName: string, bool: boolean): Effect;
  39336. /**
  39337. * Sets a Vector2 on a uniform variable.
  39338. * @param uniformName Name of the variable.
  39339. * @param vector2 vector2 to be set.
  39340. * @returns this effect.
  39341. */
  39342. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  39343. /**
  39344. * Sets a float2 on a uniform variable.
  39345. * @param uniformName Name of the variable.
  39346. * @param x First float in float2.
  39347. * @param y Second float in float2.
  39348. * @returns this effect.
  39349. */
  39350. setFloat2(uniformName: string, x: number, y: number): Effect;
  39351. /**
  39352. * Sets a Vector3 on a uniform variable.
  39353. * @param uniformName Name of the variable.
  39354. * @param vector3 Value to be set.
  39355. * @returns this effect.
  39356. */
  39357. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  39358. /**
  39359. * Sets a float3 on a uniform variable.
  39360. * @param uniformName Name of the variable.
  39361. * @param x First float in float3.
  39362. * @param y Second float in float3.
  39363. * @param z Third float in float3.
  39364. * @returns this effect.
  39365. */
  39366. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  39367. /**
  39368. * Sets a Vector4 on a uniform variable.
  39369. * @param uniformName Name of the variable.
  39370. * @param vector4 Value to be set.
  39371. * @returns this effect.
  39372. */
  39373. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  39374. /**
  39375. * Sets a float4 on a uniform variable.
  39376. * @param uniformName Name of the variable.
  39377. * @param x First float in float4.
  39378. * @param y Second float in float4.
  39379. * @param z Third float in float4.
  39380. * @param w Fourth float in float4.
  39381. * @returns this effect.
  39382. */
  39383. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  39384. /**
  39385. * Sets a Color3 on a uniform variable.
  39386. * @param uniformName Name of the variable.
  39387. * @param color3 Value to be set.
  39388. * @returns this effect.
  39389. */
  39390. setColor3(uniformName: string, color3: IColor3Like): Effect;
  39391. /**
  39392. * Sets a Color4 on a uniform variable.
  39393. * @param uniformName Name of the variable.
  39394. * @param color3 Value to be set.
  39395. * @param alpha Alpha value to be set.
  39396. * @returns this effect.
  39397. */
  39398. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  39399. /**
  39400. * Sets a Color4 on a uniform variable
  39401. * @param uniformName defines the name of the variable
  39402. * @param color4 defines the value to be set
  39403. * @returns this effect.
  39404. */
  39405. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  39406. /**
  39407. * Release all associated resources.
  39408. **/
  39409. dispose(): void;
  39410. /**
  39411. * This function will add a new shader to the shader store
  39412. * @param name the name of the shader
  39413. * @param pixelShader optional pixel shader content
  39414. * @param vertexShader optional vertex shader content
  39415. */
  39416. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  39417. /**
  39418. * Store of each shader (The can be looked up using effect.key)
  39419. */
  39420. static ShadersStore: {
  39421. [key: string]: string;
  39422. };
  39423. /**
  39424. * Store of each included file for a shader (The can be looked up using effect.key)
  39425. */
  39426. static IncludesShadersStore: {
  39427. [key: string]: string;
  39428. };
  39429. /**
  39430. * Resets the cache of effects.
  39431. */
  39432. static ResetCache(): void;
  39433. }
  39434. }
  39435. declare module BABYLON {
  39436. /**
  39437. * Interface used to describe the capabilities of the engine relatively to the current browser
  39438. */
  39439. export interface EngineCapabilities {
  39440. /** Maximum textures units per fragment shader */
  39441. maxTexturesImageUnits: number;
  39442. /** Maximum texture units per vertex shader */
  39443. maxVertexTextureImageUnits: number;
  39444. /** Maximum textures units in the entire pipeline */
  39445. maxCombinedTexturesImageUnits: number;
  39446. /** Maximum texture size */
  39447. maxTextureSize: number;
  39448. /** Maximum texture samples */
  39449. maxSamples?: number;
  39450. /** Maximum cube texture size */
  39451. maxCubemapTextureSize: number;
  39452. /** Maximum render texture size */
  39453. maxRenderTextureSize: number;
  39454. /** Maximum number of vertex attributes */
  39455. maxVertexAttribs: number;
  39456. /** Maximum number of varyings */
  39457. maxVaryingVectors: number;
  39458. /** Maximum number of uniforms per vertex shader */
  39459. maxVertexUniformVectors: number;
  39460. /** Maximum number of uniforms per fragment shader */
  39461. maxFragmentUniformVectors: number;
  39462. /** Defines if standard derivates (dx/dy) are supported */
  39463. standardDerivatives: boolean;
  39464. /** Defines if s3tc texture compression is supported */
  39465. s3tc?: WEBGL_compressed_texture_s3tc;
  39466. /** Defines if pvrtc texture compression is supported */
  39467. pvrtc: any;
  39468. /** Defines if etc1 texture compression is supported */
  39469. etc1: any;
  39470. /** Defines if etc2 texture compression is supported */
  39471. etc2: any;
  39472. /** Defines if astc texture compression is supported */
  39473. astc: any;
  39474. /** Defines if bptc texture compression is supported */
  39475. bptc: any;
  39476. /** Defines if float textures are supported */
  39477. textureFloat: boolean;
  39478. /** Defines if vertex array objects are supported */
  39479. vertexArrayObject: boolean;
  39480. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  39481. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  39482. /** Gets the maximum level of anisotropy supported */
  39483. maxAnisotropy: number;
  39484. /** Defines if instancing is supported */
  39485. instancedArrays: boolean;
  39486. /** Defines if 32 bits indices are supported */
  39487. uintIndices: boolean;
  39488. /** Defines if high precision shaders are supported */
  39489. highPrecisionShaderSupported: boolean;
  39490. /** Defines if depth reading in the fragment shader is supported */
  39491. fragmentDepthSupported: boolean;
  39492. /** Defines if float texture linear filtering is supported*/
  39493. textureFloatLinearFiltering: boolean;
  39494. /** Defines if rendering to float textures is supported */
  39495. textureFloatRender: boolean;
  39496. /** Defines if half float textures are supported*/
  39497. textureHalfFloat: boolean;
  39498. /** Defines if half float texture linear filtering is supported*/
  39499. textureHalfFloatLinearFiltering: boolean;
  39500. /** Defines if rendering to half float textures is supported */
  39501. textureHalfFloatRender: boolean;
  39502. /** Defines if textureLOD shader command is supported */
  39503. textureLOD: boolean;
  39504. /** Defines if draw buffers extension is supported */
  39505. drawBuffersExtension: boolean;
  39506. /** Defines if depth textures are supported */
  39507. depthTextureExtension: boolean;
  39508. /** Defines if float color buffer are supported */
  39509. colorBufferFloat: boolean;
  39510. /** Gets disjoint timer query extension (null if not supported) */
  39511. timerQuery?: EXT_disjoint_timer_query;
  39512. /** Defines if timestamp can be used with timer query */
  39513. canUseTimestampForTimerQuery: boolean;
  39514. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  39515. multiview?: any;
  39516. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  39517. oculusMultiview?: any;
  39518. /** Function used to let the system compiles shaders in background */
  39519. parallelShaderCompile?: {
  39520. COMPLETION_STATUS_KHR: number;
  39521. };
  39522. /** Max number of texture samples for MSAA */
  39523. maxMSAASamples: number;
  39524. /** Defines if the blend min max extension is supported */
  39525. blendMinMax: boolean;
  39526. /** In some iOS + WebGL1, gl_InstanceID (and gl_InstanceIDEXT) is undefined even if instancedArrays is true. So don't use gl_InstanceID in those cases */
  39527. canUseGLInstanceID: boolean;
  39528. }
  39529. }
  39530. declare module BABYLON {
  39531. /**
  39532. * @hidden
  39533. **/
  39534. export class DepthCullingState {
  39535. private _isDepthTestDirty;
  39536. private _isDepthMaskDirty;
  39537. private _isDepthFuncDirty;
  39538. private _isCullFaceDirty;
  39539. private _isCullDirty;
  39540. private _isZOffsetDirty;
  39541. private _isFrontFaceDirty;
  39542. private _depthTest;
  39543. private _depthMask;
  39544. private _depthFunc;
  39545. private _cull;
  39546. private _cullFace;
  39547. private _zOffset;
  39548. private _frontFace;
  39549. /**
  39550. * Initializes the state.
  39551. */
  39552. constructor();
  39553. get isDirty(): boolean;
  39554. get zOffset(): number;
  39555. set zOffset(value: number);
  39556. get cullFace(): Nullable<number>;
  39557. set cullFace(value: Nullable<number>);
  39558. get cull(): Nullable<boolean>;
  39559. set cull(value: Nullable<boolean>);
  39560. get depthFunc(): Nullable<number>;
  39561. set depthFunc(value: Nullable<number>);
  39562. get depthMask(): boolean;
  39563. set depthMask(value: boolean);
  39564. get depthTest(): boolean;
  39565. set depthTest(value: boolean);
  39566. get frontFace(): Nullable<number>;
  39567. set frontFace(value: Nullable<number>);
  39568. reset(): void;
  39569. apply(gl: WebGLRenderingContext): void;
  39570. }
  39571. }
  39572. declare module BABYLON {
  39573. /**
  39574. * @hidden
  39575. **/
  39576. export class StencilState {
  39577. /** 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 */
  39578. static readonly ALWAYS: number;
  39579. /** Passed to stencilOperation to specify that stencil value must be kept */
  39580. static readonly KEEP: number;
  39581. /** Passed to stencilOperation to specify that stencil value must be replaced */
  39582. static readonly REPLACE: number;
  39583. private _isStencilTestDirty;
  39584. private _isStencilMaskDirty;
  39585. private _isStencilFuncDirty;
  39586. private _isStencilOpDirty;
  39587. private _stencilTest;
  39588. private _stencilMask;
  39589. private _stencilFunc;
  39590. private _stencilFuncRef;
  39591. private _stencilFuncMask;
  39592. private _stencilOpStencilFail;
  39593. private _stencilOpDepthFail;
  39594. private _stencilOpStencilDepthPass;
  39595. get isDirty(): boolean;
  39596. get stencilFunc(): number;
  39597. set stencilFunc(value: number);
  39598. get stencilFuncRef(): number;
  39599. set stencilFuncRef(value: number);
  39600. get stencilFuncMask(): number;
  39601. set stencilFuncMask(value: number);
  39602. get stencilOpStencilFail(): number;
  39603. set stencilOpStencilFail(value: number);
  39604. get stencilOpDepthFail(): number;
  39605. set stencilOpDepthFail(value: number);
  39606. get stencilOpStencilDepthPass(): number;
  39607. set stencilOpStencilDepthPass(value: number);
  39608. get stencilMask(): number;
  39609. set stencilMask(value: number);
  39610. get stencilTest(): boolean;
  39611. set stencilTest(value: boolean);
  39612. constructor();
  39613. reset(): void;
  39614. apply(gl: WebGLRenderingContext): void;
  39615. }
  39616. }
  39617. declare module BABYLON {
  39618. /**
  39619. * @hidden
  39620. **/
  39621. export class AlphaState {
  39622. _blendFunctionParameters: Nullable<number>[];
  39623. _blendEquationParameters: Nullable<number>[];
  39624. _blendConstants: Nullable<number>[];
  39625. _isBlendConstantsDirty: boolean;
  39626. private _alphaBlend;
  39627. private _isAlphaBlendDirty;
  39628. private _isBlendFunctionParametersDirty;
  39629. private _isBlendEquationParametersDirty;
  39630. /**
  39631. * Initializes the state.
  39632. */
  39633. constructor();
  39634. get isDirty(): boolean;
  39635. get alphaBlend(): boolean;
  39636. set alphaBlend(value: boolean);
  39637. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  39638. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  39639. setAlphaEquationParameters(rgb: number, alpha: number): void;
  39640. reset(): void;
  39641. apply(gl: WebGLRenderingContext): void;
  39642. }
  39643. }
  39644. declare module BABYLON {
  39645. /** @hidden */
  39646. export class WebGLShaderProcessor implements IShaderProcessor {
  39647. postProcessor(code: string, defines: string[], isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>, engine: ThinEngine): string;
  39648. }
  39649. }
  39650. declare module BABYLON {
  39651. /** @hidden */
  39652. export class WebGL2ShaderProcessor implements IShaderProcessor {
  39653. attributeProcessor(attribute: string): string;
  39654. varyingProcessor(varying: string, isFragment: boolean): string;
  39655. postProcessor(code: string, defines: string[], isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>, engine: ThinEngine): string;
  39656. }
  39657. }
  39658. declare module BABYLON {
  39659. /**
  39660. * Interface for attribute information associated with buffer instanciation
  39661. */
  39662. export interface InstancingAttributeInfo {
  39663. /**
  39664. * Name of the GLSL attribute
  39665. * if attribute index is not specified, this is used to retrieve the index from the effect
  39666. */
  39667. attributeName: string;
  39668. /**
  39669. * Index/offset of the attribute in the vertex shader
  39670. * if not specified, this will be computes from the name.
  39671. */
  39672. index?: number;
  39673. /**
  39674. * size of the attribute, 1, 2, 3 or 4
  39675. */
  39676. attributeSize: number;
  39677. /**
  39678. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  39679. */
  39680. offset: number;
  39681. /**
  39682. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  39683. * default to 1
  39684. */
  39685. divisor?: number;
  39686. /**
  39687. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  39688. * default is FLOAT
  39689. */
  39690. attributeType?: number;
  39691. /**
  39692. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  39693. */
  39694. normalized?: boolean;
  39695. }
  39696. }
  39697. declare module BABYLON {
  39698. /** @hidden */
  39699. export interface EngineFeatures {
  39700. /** Force using Bitmap when Bitmap or HTMLImageElement can be used */
  39701. forceBitmapOverHTMLImageElement: boolean;
  39702. /** Indicates that the engine support rendering to as well as copying to lod float textures */
  39703. supportRenderAndCopyToLodForFloatTextures: boolean;
  39704. /** Indicates that the engine support handling depth/stencil textures */
  39705. supportDepthStencilTexture: boolean;
  39706. /** Indicates that the engine support shadow samplers */
  39707. supportShadowSamplers: boolean;
  39708. /** Indicates to check the matrix bytes per bytes to know if it has changed or not. If false, only the updateFlag of the matrix is checked */
  39709. uniformBufferHardCheckMatrix: boolean;
  39710. /** Indicates that prefiltered mipmaps can be generated in some processes (for eg when loading an HDR cube texture) */
  39711. allowTexturePrefiltering: boolean;
  39712. /** Indicates to track the usage of ubos and to create new ones as necessary during a frame duration */
  39713. trackUbosInFrame: boolean;
  39714. /** Indicates that the Cascaded Shadow Map technic is supported */
  39715. supportCSM: boolean;
  39716. /** Indicates that the textures transcoded by the basis transcoder must have power of 2 width and height */
  39717. basisNeedsPOT: boolean;
  39718. /** Indicates that the engine supports 3D textures */
  39719. support3DTextures: boolean;
  39720. /** Indicates that constants need a type suffix in shaders (used by realtime filtering...) */
  39721. needTypeSuffixInShaderConstants: boolean;
  39722. /** Indicates that MSAA is supported */
  39723. supportMSAA: boolean;
  39724. /** Indicates that SSAO2 is supported */
  39725. supportSSAO2: boolean;
  39726. /** Indicates that some additional texture formats are supported (like TEXTUREFORMAT_R for eg) */
  39727. supportExtendedTextureFormats: boolean;
  39728. /** Indicates that the switch/case construct is supported in shaders */
  39729. supportSwitchCaseInShader: boolean;
  39730. /** Indicates that synchronous texture reading is supported */
  39731. supportSyncTextureRead: boolean;
  39732. /** @hidden */
  39733. _collectUbosUpdatedInFrame: boolean;
  39734. }
  39735. }
  39736. declare module BABYLON {
  39737. /** @hidden */
  39738. export class WebGLHardwareTexture implements HardwareTextureWrapper {
  39739. private _webGLTexture;
  39740. private _context;
  39741. get underlyingResource(): Nullable<WebGLTexture>;
  39742. constructor(existingTexture: WebGLTexture | null | undefined, context: WebGLRenderingContext);
  39743. setUsage(textureSource: number, generateMipMaps: boolean, isCube: boolean, width: number, height: number): void;
  39744. set(hardwareTexture: WebGLTexture): void;
  39745. reset(): void;
  39746. release(): void;
  39747. }
  39748. }
  39749. declare module BABYLON {
  39750. interface ThinEngine {
  39751. /**
  39752. * Update a video texture
  39753. * @param texture defines the texture to update
  39754. * @param video defines the video element to use
  39755. * @param invertY defines if data must be stored with Y axis inverted
  39756. */
  39757. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  39758. }
  39759. }
  39760. declare module BABYLON {
  39761. interface ThinEngine {
  39762. /**
  39763. * Creates a dynamic texture
  39764. * @param width defines the width of the texture
  39765. * @param height defines the height of the texture
  39766. * @param generateMipMaps defines if the engine should generate the mip levels
  39767. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  39768. * @returns the dynamic texture inside an InternalTexture
  39769. */
  39770. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  39771. /**
  39772. * Update the content of a dynamic texture
  39773. * @param texture defines the texture to update
  39774. * @param source defines the source containing the data
  39775. * @param invertY defines if data must be stored with Y axis inverted
  39776. * @param premulAlpha defines if alpha is stored as premultiplied
  39777. * @param format defines the format of the data
  39778. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  39779. */
  39780. updateDynamicTexture(texture: Nullable<InternalTexture>, source: ImageBitmap | ImageData | HTMLImageElement | HTMLCanvasElement | HTMLVideoElement | OffscreenCanvas, invertY?: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  39781. }
  39782. }
  39783. declare module BABYLON {
  39784. /**
  39785. * Settings for finer control over video usage
  39786. */
  39787. export interface VideoTextureSettings {
  39788. /**
  39789. * Applies `autoplay` to video, if specified
  39790. */
  39791. autoPlay?: boolean;
  39792. /**
  39793. * Applies `muted` to video, if specified
  39794. */
  39795. muted?: boolean;
  39796. /**
  39797. * Applies `loop` to video, if specified
  39798. */
  39799. loop?: boolean;
  39800. /**
  39801. * Automatically updates internal texture from video at every frame in the render loop
  39802. */
  39803. autoUpdateTexture: boolean;
  39804. /**
  39805. * Image src displayed during the video loading or until the user interacts with the video.
  39806. */
  39807. poster?: string;
  39808. }
  39809. /**
  39810. * If you want to display a video in your scene, this is the special texture for that.
  39811. * This special texture works similar to other textures, with the exception of a few parameters.
  39812. * @see https://doc.babylonjs.com/how_to/video_texture
  39813. */
  39814. export class VideoTexture extends Texture {
  39815. /**
  39816. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  39817. */
  39818. readonly autoUpdateTexture: boolean;
  39819. /**
  39820. * The video instance used by the texture internally
  39821. */
  39822. readonly video: HTMLVideoElement;
  39823. private _onUserActionRequestedObservable;
  39824. /**
  39825. * Event triggerd when a dom action is required by the user to play the video.
  39826. * This happens due to recent changes in browser policies preventing video to auto start.
  39827. */
  39828. get onUserActionRequestedObservable(): Observable<Texture>;
  39829. private _generateMipMaps;
  39830. private _stillImageCaptured;
  39831. private _displayingPosterTexture;
  39832. private _settings;
  39833. private _createInternalTextureOnEvent;
  39834. private _frameId;
  39835. private _currentSrc;
  39836. /**
  39837. * Creates a video texture.
  39838. * If you want to display a video in your scene, this is the special texture for that.
  39839. * This special texture works similar to other textures, with the exception of a few parameters.
  39840. * @see https://doc.babylonjs.com/how_to/video_texture
  39841. * @param name optional name, will detect from video source, if not defined
  39842. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  39843. * @param scene is obviously the current scene.
  39844. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  39845. * @param invertY is false by default but can be used to invert video on Y axis
  39846. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  39847. * @param settings allows finer control over video usage
  39848. */
  39849. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  39850. private _getName;
  39851. private _getVideo;
  39852. private _createInternalTexture;
  39853. private reset;
  39854. /**
  39855. * @hidden Internal method to initiate `update`.
  39856. */
  39857. _rebuild(): void;
  39858. /**
  39859. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  39860. */
  39861. update(): void;
  39862. /**
  39863. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  39864. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  39865. */
  39866. updateTexture(isVisible: boolean): void;
  39867. protected _updateInternalTexture: () => void;
  39868. /**
  39869. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  39870. * @param url New url.
  39871. */
  39872. updateURL(url: string): void;
  39873. /**
  39874. * Clones the texture.
  39875. * @returns the cloned texture
  39876. */
  39877. clone(): VideoTexture;
  39878. /**
  39879. * Dispose the texture and release its associated resources.
  39880. */
  39881. dispose(): void;
  39882. /**
  39883. * Creates a video texture straight from a stream.
  39884. * @param scene Define the scene the texture should be created in
  39885. * @param stream Define the stream the texture should be created from
  39886. * @returns The created video texture as a promise
  39887. */
  39888. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  39889. /**
  39890. * Creates a video texture straight from your WebCam video feed.
  39891. * @param scene Define the scene the texture should be created in
  39892. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  39893. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  39894. * @returns The created video texture as a promise
  39895. */
  39896. static CreateFromWebCamAsync(scene: Scene, constraints: {
  39897. minWidth: number;
  39898. maxWidth: number;
  39899. minHeight: number;
  39900. maxHeight: number;
  39901. deviceId: string;
  39902. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  39903. /**
  39904. * Creates a video texture straight from your WebCam video feed.
  39905. * @param scene Define the scene the texture should be created in
  39906. * @param onReady Define a callback to triggered once the texture will be ready
  39907. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  39908. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  39909. */
  39910. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  39911. minWidth: number;
  39912. maxWidth: number;
  39913. minHeight: number;
  39914. maxHeight: number;
  39915. deviceId: string;
  39916. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  39917. }
  39918. }
  39919. declare module BABYLON {
  39920. /**
  39921. * Defines the interface used by objects working like Scene
  39922. * @hidden
  39923. */
  39924. export interface ISceneLike {
  39925. _addPendingData(data: any): void;
  39926. _removePendingData(data: any): void;
  39927. offlineProvider: IOfflineProvider;
  39928. }
  39929. /**
  39930. * Information about the current host
  39931. */
  39932. export interface HostInformation {
  39933. /**
  39934. * Defines if the current host is a mobile
  39935. */
  39936. isMobile: boolean;
  39937. }
  39938. /** Interface defining initialization parameters for Engine class */
  39939. export interface EngineOptions extends WebGLContextAttributes {
  39940. /**
  39941. * Defines if the engine should no exceed a specified device ratio
  39942. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  39943. */
  39944. limitDeviceRatio?: number;
  39945. /**
  39946. * Defines if webvr should be enabled automatically
  39947. * @see https://doc.babylonjs.com/how_to/webvr_camera
  39948. */
  39949. autoEnableWebVR?: boolean;
  39950. /**
  39951. * Defines if webgl2 should be turned off even if supported
  39952. * @see https://doc.babylonjs.com/features/webgl2
  39953. */
  39954. disableWebGL2Support?: boolean;
  39955. /**
  39956. * Defines if webaudio should be initialized as well
  39957. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  39958. */
  39959. audioEngine?: boolean;
  39960. /**
  39961. * Defines if animations should run using a deterministic lock step
  39962. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39963. */
  39964. deterministicLockstep?: boolean;
  39965. /** Defines the maximum steps to use with deterministic lock step mode */
  39966. lockstepMaxSteps?: number;
  39967. /** Defines the seconds between each deterministic lock step */
  39968. timeStep?: number;
  39969. /**
  39970. * Defines that engine should ignore context lost events
  39971. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  39972. */
  39973. doNotHandleContextLost?: boolean;
  39974. /**
  39975. * Defines that engine should ignore modifying touch action attribute and style
  39976. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  39977. */
  39978. doNotHandleTouchAction?: boolean;
  39979. /**
  39980. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  39981. */
  39982. useHighPrecisionFloats?: boolean;
  39983. /**
  39984. * Make the canvas XR Compatible for XR sessions
  39985. */
  39986. xrCompatible?: boolean;
  39987. /**
  39988. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  39989. */
  39990. useHighPrecisionMatrix?: boolean;
  39991. /**
  39992. * Will prevent the system from falling back to software implementation if a hardware device cannot be created
  39993. */
  39994. failIfMajorPerformanceCaveat?: boolean;
  39995. /**
  39996. * Defines whether to adapt to the device's viewport characteristics (default: false)
  39997. */
  39998. adaptToDeviceRatio?: boolean;
  39999. }
  40000. /**
  40001. * The base engine class (root of all engines)
  40002. */
  40003. export class ThinEngine {
  40004. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  40005. static ExceptionList: ({
  40006. key: string;
  40007. capture: string;
  40008. captureConstraint: number;
  40009. targets: string[];
  40010. } | {
  40011. key: string;
  40012. capture: null;
  40013. captureConstraint: null;
  40014. targets: string[];
  40015. })[];
  40016. /** @hidden */
  40017. static _TextureLoaders: IInternalTextureLoader[];
  40018. /**
  40019. * Returns the current npm package of the sdk
  40020. */
  40021. static get NpmPackage(): string;
  40022. /**
  40023. * Returns the current version of the framework
  40024. */
  40025. static get Version(): string;
  40026. /**
  40027. * Returns a string describing the current engine
  40028. */
  40029. get description(): string;
  40030. /**
  40031. * Returns the name of the engine
  40032. */
  40033. get name(): string;
  40034. /**
  40035. * Returns the version of the engine
  40036. */
  40037. get version(): number;
  40038. /**
  40039. * Gets or sets the epsilon value used by collision engine
  40040. */
  40041. static CollisionsEpsilon: number;
  40042. /**
  40043. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  40044. */
  40045. static get ShadersRepository(): string;
  40046. static set ShadersRepository(value: string);
  40047. /** @hidden */
  40048. _shaderProcessor: Nullable<IShaderProcessor>;
  40049. /**
  40050. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  40051. */
  40052. forcePOTTextures: boolean;
  40053. /**
  40054. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  40055. */
  40056. isFullscreen: boolean;
  40057. /**
  40058. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  40059. */
  40060. cullBackFaces: boolean;
  40061. /**
  40062. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  40063. */
  40064. renderEvenInBackground: boolean;
  40065. /**
  40066. * Gets or sets a boolean indicating that cache can be kept between frames
  40067. */
  40068. preventCacheWipeBetweenFrames: boolean;
  40069. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  40070. validateShaderPrograms: boolean;
  40071. /**
  40072. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  40073. * This can provide greater z depth for distant objects.
  40074. */
  40075. useReverseDepthBuffer: boolean;
  40076. /**
  40077. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  40078. */
  40079. disableUniformBuffers: boolean;
  40080. private _frameId;
  40081. /**
  40082. * Gets the current frame id
  40083. */
  40084. get frameId(): number;
  40085. /** @hidden */
  40086. _uniformBuffers: UniformBuffer[];
  40087. /**
  40088. * Gets a boolean indicating that the engine supports uniform buffers
  40089. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  40090. */
  40091. get supportsUniformBuffers(): boolean;
  40092. /** @hidden */
  40093. _gl: WebGLRenderingContext;
  40094. /** @hidden */
  40095. _webGLVersion: number;
  40096. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  40097. protected _windowIsBackground: boolean;
  40098. protected _creationOptions: EngineOptions;
  40099. protected _highPrecisionShadersAllowed: boolean;
  40100. /** @hidden */
  40101. get _shouldUseHighPrecisionShader(): boolean;
  40102. /**
  40103. * Gets a boolean indicating that only power of 2 textures are supported
  40104. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  40105. */
  40106. get needPOTTextures(): boolean;
  40107. /** @hidden */
  40108. _badOS: boolean;
  40109. /** @hidden */
  40110. _badDesktopOS: boolean;
  40111. protected _hardwareScalingLevel: number;
  40112. /** @hidden */
  40113. _caps: EngineCapabilities;
  40114. /** @hidden */
  40115. _features: EngineFeatures;
  40116. protected _isStencilEnable: boolean;
  40117. private _glVersion;
  40118. private _glRenderer;
  40119. private _glVendor;
  40120. /** @hidden */
  40121. _videoTextureSupported: boolean;
  40122. protected _renderingQueueLaunched: boolean;
  40123. protected _activeRenderLoops: (() => void)[];
  40124. /**
  40125. * Observable signaled when a context lost event is raised
  40126. */
  40127. onContextLostObservable: Observable<ThinEngine>;
  40128. /**
  40129. * Observable signaled when a context restored event is raised
  40130. */
  40131. onContextRestoredObservable: Observable<ThinEngine>;
  40132. private _onContextLost;
  40133. private _onContextRestored;
  40134. protected _contextWasLost: boolean;
  40135. /** @hidden */
  40136. _doNotHandleContextLost: boolean;
  40137. /**
  40138. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  40139. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  40140. */
  40141. get doNotHandleContextLost(): boolean;
  40142. set doNotHandleContextLost(value: boolean);
  40143. /**
  40144. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  40145. */
  40146. disableVertexArrayObjects: boolean;
  40147. /** @hidden */
  40148. protected _colorWrite: boolean;
  40149. /** @hidden */
  40150. protected _colorWriteChanged: boolean;
  40151. /** @hidden */
  40152. protected _depthCullingState: DepthCullingState;
  40153. /** @hidden */
  40154. protected _stencilState: StencilState;
  40155. /** @hidden */
  40156. _alphaState: AlphaState;
  40157. /** @hidden */
  40158. _alphaMode: number;
  40159. /** @hidden */
  40160. _alphaEquation: number;
  40161. /** @hidden */
  40162. _internalTexturesCache: InternalTexture[];
  40163. /** @hidden */
  40164. protected _activeChannel: number;
  40165. private _currentTextureChannel;
  40166. /** @hidden */
  40167. protected _boundTexturesCache: {
  40168. [key: string]: Nullable<InternalTexture>;
  40169. };
  40170. /** @hidden */
  40171. protected _currentEffect: Nullable<Effect>;
  40172. /** @hidden */
  40173. protected _currentProgram: Nullable<WebGLProgram>;
  40174. protected _compiledEffects: {
  40175. [key: string]: Effect;
  40176. };
  40177. private _vertexAttribArraysEnabled;
  40178. /** @hidden */
  40179. protected _cachedViewport: Nullable<IViewportLike>;
  40180. private _cachedVertexArrayObject;
  40181. /** @hidden */
  40182. protected _cachedVertexBuffers: any;
  40183. /** @hidden */
  40184. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  40185. /** @hidden */
  40186. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  40187. /** @hidden */
  40188. _currentRenderTarget: Nullable<InternalTexture>;
  40189. private _uintIndicesCurrentlySet;
  40190. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  40191. /** @hidden */
  40192. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  40193. /** @hidden */
  40194. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  40195. private _currentBufferPointers;
  40196. private _currentInstanceLocations;
  40197. private _currentInstanceBuffers;
  40198. private _textureUnits;
  40199. /** @hidden */
  40200. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  40201. /** @hidden */
  40202. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  40203. /** @hidden */
  40204. _boundRenderFunction: any;
  40205. private _vaoRecordInProgress;
  40206. private _mustWipeVertexAttributes;
  40207. private _emptyTexture;
  40208. private _emptyCubeTexture;
  40209. private _emptyTexture3D;
  40210. private _emptyTexture2DArray;
  40211. /** @hidden */
  40212. _frameHandler: number;
  40213. private _nextFreeTextureSlots;
  40214. private _maxSimultaneousTextures;
  40215. private _activeRequests;
  40216. /** @hidden */
  40217. _transformTextureUrl: Nullable<(url: string) => string>;
  40218. /**
  40219. * Gets information about the current host
  40220. */
  40221. hostInformation: HostInformation;
  40222. protected get _supportsHardwareTextureRescaling(): boolean;
  40223. private _framebufferDimensionsObject;
  40224. /**
  40225. * sets the object from which width and height will be taken from when getting render width and height
  40226. * Will fallback to the gl object
  40227. * @param dimensions the framebuffer width and height that will be used.
  40228. */
  40229. set framebufferDimensionsObject(dimensions: Nullable<{
  40230. framebufferWidth: number;
  40231. framebufferHeight: number;
  40232. }>);
  40233. /**
  40234. * Gets the current viewport
  40235. */
  40236. get currentViewport(): Nullable<IViewportLike>;
  40237. /**
  40238. * Gets the default empty texture
  40239. */
  40240. get emptyTexture(): InternalTexture;
  40241. /**
  40242. * Gets the default empty 3D texture
  40243. */
  40244. get emptyTexture3D(): InternalTexture;
  40245. /**
  40246. * Gets the default empty 2D array texture
  40247. */
  40248. get emptyTexture2DArray(): InternalTexture;
  40249. /**
  40250. * Gets the default empty cube texture
  40251. */
  40252. get emptyCubeTexture(): InternalTexture;
  40253. /**
  40254. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  40255. */
  40256. premultipliedAlpha: boolean;
  40257. /**
  40258. * Observable event triggered before each texture is initialized
  40259. */
  40260. onBeforeTextureInitObservable: Observable<Texture>;
  40261. /** @hidden */
  40262. protected _isWebGPU: boolean;
  40263. /**
  40264. * Gets a boolean indicating if the engine runs in WebGPU or not.
  40265. */
  40266. get isWebGPU(): boolean;
  40267. /** @hidden */
  40268. protected _shaderPlatformName: string;
  40269. /**
  40270. * Gets the shader platfrom name used by the effects.
  40271. */
  40272. get shaderPlatformName(): string;
  40273. /**
  40274. * Creates a new engine
  40275. * @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
  40276. * @param antialias defines enable antialiasing (default: false)
  40277. * @param options defines further options to be sent to the getContext() function
  40278. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  40279. */
  40280. constructor(canvasOrContext: Nullable<HTMLCanvasElement | OffscreenCanvas | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  40281. /**
  40282. * @hidden
  40283. */
  40284. _debugPushGroup(groupName: string, targetObject?: number): void;
  40285. /**
  40286. * @hidden
  40287. */
  40288. _debugPopGroup(targetObject?: number): void;
  40289. /**
  40290. * @hidden
  40291. */
  40292. _debugInsertMarker(text: string, targetObject?: number): void;
  40293. /**
  40294. * Shared initialization across engines types.
  40295. * @param canvas The canvas associated with this instance of the engine.
  40296. * @param doNotHandleTouchAction Defines that engine should ignore modifying touch action attribute and style
  40297. * @param audioEngine Defines if an audio engine should be created by default
  40298. */
  40299. protected _sharedInit(canvas: HTMLCanvasElement, doNotHandleTouchAction: boolean, audioEngine: boolean): void;
  40300. /**
  40301. * Gets a shader processor implementation fitting with the current engine type.
  40302. * @returns The shader processor implementation.
  40303. */
  40304. protected _getShaderProcessor(): Nullable<IShaderProcessor>;
  40305. /** @hidden */
  40306. _getShaderProcessingContext(): Nullable<ShaderProcessingContext>;
  40307. private _rebuildInternalTextures;
  40308. private _rebuildEffects;
  40309. /**
  40310. * Gets a boolean indicating if all created effects are ready
  40311. * @returns true if all effects are ready
  40312. */
  40313. areAllEffectsReady(): boolean;
  40314. protected _rebuildBuffers(): void;
  40315. protected _initGLContext(): void;
  40316. protected _initFeatures(): void;
  40317. /**
  40318. * Gets version of the current webGL context
  40319. * Keep it for back compat - use version instead
  40320. */
  40321. get webGLVersion(): number;
  40322. /**
  40323. * Gets a string identifying the name of the class
  40324. * @returns "Engine" string
  40325. */
  40326. getClassName(): string;
  40327. /**
  40328. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  40329. */
  40330. get isStencilEnable(): boolean;
  40331. /** @hidden */
  40332. _prepareWorkingCanvas(): void;
  40333. /**
  40334. * Reset the texture cache to empty state
  40335. */
  40336. resetTextureCache(): void;
  40337. /**
  40338. * Gets an object containing information about the current webGL context
  40339. * @returns an object containing the vender, the renderer and the version of the current webGL context
  40340. */
  40341. getGlInfo(): {
  40342. vendor: string;
  40343. renderer: string;
  40344. version: string;
  40345. };
  40346. /**
  40347. * Defines the hardware scaling level.
  40348. * By default the hardware scaling level is computed from the window device ratio.
  40349. * 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.
  40350. * @param level defines the level to use
  40351. */
  40352. setHardwareScalingLevel(level: number): void;
  40353. /**
  40354. * Gets the current hardware scaling level.
  40355. * By default the hardware scaling level is computed from the window device ratio.
  40356. * 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.
  40357. * @returns a number indicating the current hardware scaling level
  40358. */
  40359. getHardwareScalingLevel(): number;
  40360. /**
  40361. * Gets the list of loaded textures
  40362. * @returns an array containing all loaded textures
  40363. */
  40364. getLoadedTexturesCache(): InternalTexture[];
  40365. /**
  40366. * Gets the object containing all engine capabilities
  40367. * @returns the EngineCapabilities object
  40368. */
  40369. getCaps(): EngineCapabilities;
  40370. /**
  40371. * stop executing a render loop function and remove it from the execution array
  40372. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  40373. */
  40374. stopRenderLoop(renderFunction?: () => void): void;
  40375. /** @hidden */
  40376. _renderLoop(): void;
  40377. /**
  40378. * Gets the HTML canvas attached with the current webGL context
  40379. * @returns a HTML canvas
  40380. */
  40381. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  40382. /**
  40383. * Gets host window
  40384. * @returns the host window object
  40385. */
  40386. getHostWindow(): Nullable<Window>;
  40387. /**
  40388. * Gets the current render width
  40389. * @param useScreen defines if screen size must be used (or the current render target if any)
  40390. * @returns a number defining the current render width
  40391. */
  40392. getRenderWidth(useScreen?: boolean): number;
  40393. /**
  40394. * Gets the current render height
  40395. * @param useScreen defines if screen size must be used (or the current render target if any)
  40396. * @returns a number defining the current render height
  40397. */
  40398. getRenderHeight(useScreen?: boolean): number;
  40399. /**
  40400. * Can be used to override the current requestAnimationFrame requester.
  40401. * @hidden
  40402. */
  40403. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  40404. /**
  40405. * Register and execute a render loop. The engine can have more than one render function
  40406. * @param renderFunction defines the function to continuously execute
  40407. */
  40408. runRenderLoop(renderFunction: () => void): void;
  40409. /**
  40410. * Clear the current render buffer or the current render target (if any is set up)
  40411. * @param color defines the color to use
  40412. * @param backBuffer defines if the back buffer must be cleared
  40413. * @param depth defines if the depth buffer must be cleared
  40414. * @param stencil defines if the stencil buffer must be cleared
  40415. */
  40416. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  40417. protected _viewportCached: {
  40418. x: number;
  40419. y: number;
  40420. z: number;
  40421. w: number;
  40422. };
  40423. /** @hidden */
  40424. _viewport(x: number, y: number, width: number, height: number): void;
  40425. /**
  40426. * Set the WebGL's viewport
  40427. * @param viewport defines the viewport element to be used
  40428. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  40429. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  40430. */
  40431. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  40432. /**
  40433. * Begin a new frame
  40434. */
  40435. beginFrame(): void;
  40436. /**
  40437. * Enf the current frame
  40438. */
  40439. endFrame(): void;
  40440. /**
  40441. * Resize the view according to the canvas' size
  40442. * @param forceSetSize true to force setting the sizes of the underlying canvas
  40443. */
  40444. resize(forceSetSize?: boolean): void;
  40445. /**
  40446. * Force a specific size of the canvas
  40447. * @param width defines the new canvas' width
  40448. * @param height defines the new canvas' height
  40449. * @param forceSetSize true to force setting the sizes of the underlying canvas
  40450. * @returns true if the size was changed
  40451. */
  40452. setSize(width: number, height: number, forceSetSize?: boolean): boolean;
  40453. /**
  40454. * Binds the frame buffer to the specified texture.
  40455. * @param texture The texture to render to or null for the default canvas
  40456. * @param faceIndex The face of the texture to render to in case of cube texture
  40457. * @param requiredWidth The width of the target to render to
  40458. * @param requiredHeight The height of the target to render to
  40459. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  40460. * @param lodLevel defines the lod level to bind to the frame buffer
  40461. * @param layer defines the 2d array index to bind to frame buffer to
  40462. */
  40463. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  40464. /** @hidden */
  40465. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  40466. /**
  40467. * Unbind the current render target texture from the webGL context
  40468. * @param texture defines the render target texture to unbind
  40469. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  40470. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  40471. */
  40472. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  40473. /**
  40474. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  40475. */
  40476. flushFramebuffer(): void;
  40477. /**
  40478. * Unbind the current render target and bind the default framebuffer
  40479. */
  40480. restoreDefaultFramebuffer(): void;
  40481. /** @hidden */
  40482. protected _resetVertexBufferBinding(): void;
  40483. /**
  40484. * Creates a vertex buffer
  40485. * @param data the data for the vertex buffer
  40486. * @returns the new WebGL static buffer
  40487. */
  40488. createVertexBuffer(data: DataArray): DataBuffer;
  40489. private _createVertexBuffer;
  40490. /**
  40491. * Creates a dynamic vertex buffer
  40492. * @param data the data for the dynamic vertex buffer
  40493. * @returns the new WebGL dynamic buffer
  40494. */
  40495. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  40496. protected _resetIndexBufferBinding(): void;
  40497. /**
  40498. * Creates a new index buffer
  40499. * @param indices defines the content of the index buffer
  40500. * @param updatable defines if the index buffer must be updatable
  40501. * @returns a new webGL buffer
  40502. */
  40503. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  40504. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  40505. /**
  40506. * Bind a webGL buffer to the webGL context
  40507. * @param buffer defines the buffer to bind
  40508. */
  40509. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  40510. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  40511. private bindBuffer;
  40512. /**
  40513. * update the bound buffer with the given data
  40514. * @param data defines the data to update
  40515. */
  40516. updateArrayBuffer(data: Float32Array): void;
  40517. private _vertexAttribPointer;
  40518. /** @hidden */
  40519. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  40520. private _bindVertexBuffersAttributes;
  40521. /**
  40522. * Records a vertex array object
  40523. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  40524. * @param vertexBuffers defines the list of vertex buffers to store
  40525. * @param indexBuffer defines the index buffer to store
  40526. * @param effect defines the effect to store
  40527. * @param overrideVertexBuffers defines optional list of avertex buffers that overrides the entries in vertexBuffers
  40528. * @returns the new vertex array object
  40529. */
  40530. recordVertexArrayObject(vertexBuffers: {
  40531. [key: string]: VertexBuffer;
  40532. }, indexBuffer: Nullable<DataBuffer>, effect: Effect, overrideVertexBuffers?: {
  40533. [kind: string]: Nullable<VertexBuffer>;
  40534. }): WebGLVertexArrayObject;
  40535. /**
  40536. * Bind a specific vertex array object
  40537. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  40538. * @param vertexArrayObject defines the vertex array object to bind
  40539. * @param indexBuffer defines the index buffer to bind
  40540. */
  40541. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  40542. /**
  40543. * Bind webGl buffers directly to the webGL context
  40544. * @param vertexBuffer defines the vertex buffer to bind
  40545. * @param indexBuffer defines the index buffer to bind
  40546. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  40547. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  40548. * @param effect defines the effect associated with the vertex buffer
  40549. */
  40550. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  40551. private _unbindVertexArrayObject;
  40552. /**
  40553. * Bind a list of vertex buffers to the webGL context
  40554. * @param vertexBuffers defines the list of vertex buffers to bind
  40555. * @param indexBuffer defines the index buffer to bind
  40556. * @param effect defines the effect associated with the vertex buffers
  40557. * @param overrideVertexBuffers defines optional list of avertex buffers that overrides the entries in vertexBuffers
  40558. */
  40559. bindBuffers(vertexBuffers: {
  40560. [key: string]: Nullable<VertexBuffer>;
  40561. }, indexBuffer: Nullable<DataBuffer>, effect: Effect, overrideVertexBuffers?: {
  40562. [kind: string]: Nullable<VertexBuffer>;
  40563. }): void;
  40564. /**
  40565. * Unbind all instance attributes
  40566. */
  40567. unbindInstanceAttributes(): void;
  40568. /**
  40569. * Release and free the memory of a vertex array object
  40570. * @param vao defines the vertex array object to delete
  40571. */
  40572. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  40573. /** @hidden */
  40574. _releaseBuffer(buffer: DataBuffer): boolean;
  40575. protected _deleteBuffer(buffer: DataBuffer): void;
  40576. /**
  40577. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  40578. * @param instancesBuffer defines the webGL buffer to update and bind
  40579. * @param data defines the data to store in the buffer
  40580. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  40581. */
  40582. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  40583. /**
  40584. * Bind the content of a webGL buffer used with instantiation
  40585. * @param instancesBuffer defines the webGL buffer to bind
  40586. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  40587. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  40588. */
  40589. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  40590. /**
  40591. * Disable the instance attribute corresponding to the name in parameter
  40592. * @param name defines the name of the attribute to disable
  40593. */
  40594. disableInstanceAttributeByName(name: string): void;
  40595. /**
  40596. * Disable the instance attribute corresponding to the location in parameter
  40597. * @param attributeLocation defines the attribute location of the attribute to disable
  40598. */
  40599. disableInstanceAttribute(attributeLocation: number): void;
  40600. /**
  40601. * Disable the attribute corresponding to the location in parameter
  40602. * @param attributeLocation defines the attribute location of the attribute to disable
  40603. */
  40604. disableAttributeByIndex(attributeLocation: number): void;
  40605. /**
  40606. * Send a draw order
  40607. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  40608. * @param indexStart defines the starting index
  40609. * @param indexCount defines the number of index to draw
  40610. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  40611. */
  40612. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  40613. /**
  40614. * Draw a list of points
  40615. * @param verticesStart defines the index of first vertex to draw
  40616. * @param verticesCount defines the count of vertices to draw
  40617. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  40618. */
  40619. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  40620. /**
  40621. * Draw a list of unindexed primitives
  40622. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  40623. * @param verticesStart defines the index of first vertex to draw
  40624. * @param verticesCount defines the count of vertices to draw
  40625. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  40626. */
  40627. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  40628. /**
  40629. * Draw a list of indexed primitives
  40630. * @param fillMode defines the primitive to use
  40631. * @param indexStart defines the starting index
  40632. * @param indexCount defines the number of index to draw
  40633. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  40634. */
  40635. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  40636. /**
  40637. * Draw a list of unindexed primitives
  40638. * @param fillMode defines the primitive to use
  40639. * @param verticesStart defines the index of first vertex to draw
  40640. * @param verticesCount defines the count of vertices to draw
  40641. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  40642. */
  40643. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  40644. private _drawMode;
  40645. /** @hidden */
  40646. protected _reportDrawCall(): void;
  40647. /** @hidden */
  40648. _releaseEffect(effect: Effect): void;
  40649. /** @hidden */
  40650. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  40651. /**
  40652. * Create a new effect (used to store vertex/fragment shaders)
  40653. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  40654. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  40655. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  40656. * @param samplers defines an array of string used to represent textures
  40657. * @param defines defines the string containing the defines to use to compile the shaders
  40658. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  40659. * @param onCompiled defines a function to call when the effect creation is successful
  40660. * @param onError defines a function to call when the effect creation has failed
  40661. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  40662. * @returns the new Effect
  40663. */
  40664. 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;
  40665. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  40666. private _compileShader;
  40667. private _compileRawShader;
  40668. /** @hidden */
  40669. _getShaderSource(shader: WebGLShader): Nullable<string>;
  40670. /**
  40671. * Directly creates a webGL program
  40672. * @param pipelineContext defines the pipeline context to attach to
  40673. * @param vertexCode defines the vertex shader code to use
  40674. * @param fragmentCode defines the fragment shader code to use
  40675. * @param context defines the webGL context to use (if not set, the current one will be used)
  40676. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  40677. * @returns the new webGL program
  40678. */
  40679. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  40680. /**
  40681. * Creates a webGL program
  40682. * @param pipelineContext defines the pipeline context to attach to
  40683. * @param vertexCode defines the vertex shader code to use
  40684. * @param fragmentCode defines the fragment shader code to use
  40685. * @param defines defines the string containing the defines to use to compile the shaders
  40686. * @param context defines the webGL context to use (if not set, the current one will be used)
  40687. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  40688. * @returns the new webGL program
  40689. */
  40690. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  40691. /**
  40692. * Creates a new pipeline context
  40693. * @param shaderProcessingContext defines the shader processing context used during the processing if available
  40694. * @returns the new pipeline
  40695. */
  40696. createPipelineContext(shaderProcessingContext: Nullable<ShaderProcessingContext>): IPipelineContext;
  40697. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  40698. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  40699. /** @hidden */
  40700. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rawVertexSourceCode: string, rawFragmentSourceCode: string, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>, key: string): void;
  40701. /** @hidden */
  40702. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  40703. /** @hidden */
  40704. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  40705. /**
  40706. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  40707. * @param pipelineContext defines the pipeline context to use
  40708. * @param uniformsNames defines the list of uniform names
  40709. * @returns an array of webGL uniform locations
  40710. */
  40711. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  40712. /**
  40713. * Gets the list of active attributes for a given webGL program
  40714. * @param pipelineContext defines the pipeline context to use
  40715. * @param attributesNames defines the list of attribute names to get
  40716. * @returns an array of indices indicating the offset of each attribute
  40717. */
  40718. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  40719. /**
  40720. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  40721. * @param effect defines the effect to activate
  40722. */
  40723. enableEffect(effect: Nullable<Effect>): void;
  40724. /**
  40725. * Set the value of an uniform to a number (int)
  40726. * @param uniform defines the webGL uniform location where to store the value
  40727. * @param value defines the int number to store
  40728. * @returns true if the value was set
  40729. */
  40730. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  40731. /**
  40732. * Set the value of an uniform to a int2
  40733. * @param uniform defines the webGL uniform location where to store the value
  40734. * @param x defines the 1st component of the value
  40735. * @param y defines the 2nd component of the value
  40736. * @returns true if the value was set
  40737. */
  40738. setInt2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): boolean;
  40739. /**
  40740. * Set the value of an uniform to a int3
  40741. * @param uniform defines the webGL uniform location where to store the value
  40742. * @param x defines the 1st component of the value
  40743. * @param y defines the 2nd component of the value
  40744. * @param z defines the 3rd component of the value
  40745. * @returns true if the value was set
  40746. */
  40747. setInt3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): boolean;
  40748. /**
  40749. * Set the value of an uniform to a int4
  40750. * @param uniform defines the webGL uniform location where to store the value
  40751. * @param x defines the 1st component of the value
  40752. * @param y defines the 2nd component of the value
  40753. * @param z defines the 3rd component of the value
  40754. * @param w defines the 4th component of the value
  40755. * @returns true if the value was set
  40756. */
  40757. setInt4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): boolean;
  40758. /**
  40759. * Set the value of an uniform to an array of int32
  40760. * @param uniform defines the webGL uniform location where to store the value
  40761. * @param array defines the array of int32 to store
  40762. * @returns true if the value was set
  40763. */
  40764. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  40765. /**
  40766. * Set the value of an uniform to an array of int32 (stored as vec2)
  40767. * @param uniform defines the webGL uniform location where to store the value
  40768. * @param array defines the array of int32 to store
  40769. * @returns true if the value was set
  40770. */
  40771. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  40772. /**
  40773. * Set the value of an uniform to an array of int32 (stored as vec3)
  40774. * @param uniform defines the webGL uniform location where to store the value
  40775. * @param array defines the array of int32 to store
  40776. * @returns true if the value was set
  40777. */
  40778. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  40779. /**
  40780. * Set the value of an uniform to an array of int32 (stored as vec4)
  40781. * @param uniform defines the webGL uniform location where to store the value
  40782. * @param array defines the array of int32 to store
  40783. * @returns true if the value was set
  40784. */
  40785. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  40786. /**
  40787. * Set the value of an uniform to an array of number
  40788. * @param uniform defines the webGL uniform location where to store the value
  40789. * @param array defines the array of number to store
  40790. * @returns true if the value was set
  40791. */
  40792. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  40793. /**
  40794. * Set the value of an uniform to an array of number (stored as vec2)
  40795. * @param uniform defines the webGL uniform location where to store the value
  40796. * @param array defines the array of number to store
  40797. * @returns true if the value was set
  40798. */
  40799. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  40800. /**
  40801. * Set the value of an uniform to an array of number (stored as vec3)
  40802. * @param uniform defines the webGL uniform location where to store the value
  40803. * @param array defines the array of number to store
  40804. * @returns true if the value was set
  40805. */
  40806. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  40807. /**
  40808. * Set the value of an uniform to an array of number (stored as vec4)
  40809. * @param uniform defines the webGL uniform location where to store the value
  40810. * @param array defines the array of number to store
  40811. * @returns true if the value was set
  40812. */
  40813. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  40814. /**
  40815. * Set the value of an uniform to an array of float32 (stored as matrices)
  40816. * @param uniform defines the webGL uniform location where to store the value
  40817. * @param matrices defines the array of float32 to store
  40818. * @returns true if the value was set
  40819. */
  40820. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): boolean;
  40821. /**
  40822. * Set the value of an uniform to a matrix (3x3)
  40823. * @param uniform defines the webGL uniform location where to store the value
  40824. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  40825. * @returns true if the value was set
  40826. */
  40827. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  40828. /**
  40829. * Set the value of an uniform to a matrix (2x2)
  40830. * @param uniform defines the webGL uniform location where to store the value
  40831. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  40832. * @returns true if the value was set
  40833. */
  40834. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  40835. /**
  40836. * Set the value of an uniform to a number (float)
  40837. * @param uniform defines the webGL uniform location where to store the value
  40838. * @param value defines the float number to store
  40839. * @returns true if the value was transfered
  40840. */
  40841. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  40842. /**
  40843. * Set the value of an uniform to a vec2
  40844. * @param uniform defines the webGL uniform location where to store the value
  40845. * @param x defines the 1st component of the value
  40846. * @param y defines the 2nd component of the value
  40847. * @returns true if the value was set
  40848. */
  40849. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): boolean;
  40850. /**
  40851. * Set the value of an uniform to a vec3
  40852. * @param uniform defines the webGL uniform location where to store the value
  40853. * @param x defines the 1st component of the value
  40854. * @param y defines the 2nd component of the value
  40855. * @param z defines the 3rd component of the value
  40856. * @returns true if the value was set
  40857. */
  40858. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): boolean;
  40859. /**
  40860. * Set the value of an uniform to a vec4
  40861. * @param uniform defines the webGL uniform location where to store the value
  40862. * @param x defines the 1st component of the value
  40863. * @param y defines the 2nd component of the value
  40864. * @param z defines the 3rd component of the value
  40865. * @param w defines the 4th component of the value
  40866. * @returns true if the value was set
  40867. */
  40868. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): boolean;
  40869. /**
  40870. * Apply all cached states (depth, culling, stencil and alpha)
  40871. */
  40872. applyStates(): void;
  40873. /**
  40874. * Enable or disable color writing
  40875. * @param enable defines the state to set
  40876. */
  40877. setColorWrite(enable: boolean): void;
  40878. /**
  40879. * Gets a boolean indicating if color writing is enabled
  40880. * @returns the current color writing state
  40881. */
  40882. getColorWrite(): boolean;
  40883. /**
  40884. * Gets the depth culling state manager
  40885. */
  40886. get depthCullingState(): DepthCullingState;
  40887. /**
  40888. * Gets the alpha state manager
  40889. */
  40890. get alphaState(): AlphaState;
  40891. /**
  40892. * Gets the stencil state manager
  40893. */
  40894. get stencilState(): StencilState;
  40895. /**
  40896. * Clears the list of texture accessible through engine.
  40897. * This can help preventing texture load conflict due to name collision.
  40898. */
  40899. clearInternalTexturesCache(): void;
  40900. /**
  40901. * Force the entire cache to be cleared
  40902. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  40903. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  40904. */
  40905. wipeCaches(bruteForce?: boolean): void;
  40906. /** @hidden */
  40907. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  40908. min: number;
  40909. mag: number;
  40910. };
  40911. /** @hidden */
  40912. protected _createTexture(): WebGLTexture;
  40913. /** @hidden */
  40914. _createHardwareTexture(): HardwareTextureWrapper;
  40915. protected _createTextureBase(url: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode: number | undefined, onLoad: (() => void) | null | undefined, onError: ((message: string, exception: any) => void) | null | undefined, prepareTexture: (texture: InternalTexture, extension: string, scene: Nullable<ISceneLike>, img: HTMLImageElement | ImageBitmap | {
  40916. width: number;
  40917. height: number;
  40918. }, invertY: boolean, noMipmap: boolean, isCompressed: boolean, processFunction: (width: number, height: number, img: HTMLImageElement | ImageBitmap | {
  40919. width: number;
  40920. height: number;
  40921. }, extension: string, texture: InternalTexture, continuationCallback: () => void) => boolean, samplingMode: number) => void, prepareTextureProcessFunction: (width: number, height: number, img: HTMLImageElement | ImageBitmap | {
  40922. width: number;
  40923. height: number;
  40924. }, extension: string, texture: InternalTexture, continuationCallback: () => void) => boolean, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, mimeType?: string, loaderOptions?: any): InternalTexture;
  40925. /**
  40926. * Usually called from Texture.ts.
  40927. * Passed information to create a WebGLTexture
  40928. * @param url defines a value which contains one of the following:
  40929. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  40930. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  40931. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  40932. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  40933. * @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)
  40934. * @param scene needed for loading to the correct scene
  40935. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  40936. * @param onLoad optional callback to be called upon successful completion
  40937. * @param onError optional callback to be called upon failure
  40938. * @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
  40939. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  40940. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  40941. * @param forcedExtension defines the extension to use to pick the right loader
  40942. * @param mimeType defines an optional mime type
  40943. * @param loaderOptions options to be passed to the loader
  40944. * @returns a InternalTexture for assignment back into BABYLON.Texture
  40945. */
  40946. 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;
  40947. /**
  40948. * Loads an image as an HTMLImageElement.
  40949. * @param input url string, ArrayBuffer, or Blob to load
  40950. * @param onLoad callback called when the image successfully loads
  40951. * @param onError callback called when the image fails to load
  40952. * @param offlineProvider offline provider for caching
  40953. * @param mimeType optional mime type
  40954. * @returns the HTMLImageElement of the loaded image
  40955. * @hidden
  40956. */
  40957. 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>;
  40958. /**
  40959. * @hidden
  40960. */
  40961. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  40962. private _unpackFlipYCached;
  40963. /**
  40964. * In case you are sharing the context with other applications, it might
  40965. * be interested to not cache the unpack flip y state to ensure a consistent
  40966. * value would be set.
  40967. */
  40968. enableUnpackFlipYCached: boolean;
  40969. /** @hidden */
  40970. _unpackFlipY(value: boolean): void;
  40971. /** @hidden */
  40972. _getUnpackAlignement(): number;
  40973. private _getTextureTarget;
  40974. /**
  40975. * Update the sampling mode of a given texture
  40976. * @param samplingMode defines the required sampling mode
  40977. * @param texture defines the texture to update
  40978. * @param generateMipMaps defines whether to generate mipmaps for the texture
  40979. */
  40980. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  40981. /**
  40982. * Update the dimensions of a texture
  40983. * @param texture texture to update
  40984. * @param width new width of the texture
  40985. * @param height new height of the texture
  40986. * @param depth new depth of the texture
  40987. */
  40988. updateTextureDimensions(texture: InternalTexture, width: number, height: number, depth?: number): void;
  40989. /**
  40990. * Update the sampling mode of a given texture
  40991. * @param texture defines the texture to update
  40992. * @param wrapU defines the texture wrap mode of the u coordinates
  40993. * @param wrapV defines the texture wrap mode of the v coordinates
  40994. * @param wrapR defines the texture wrap mode of the r coordinates
  40995. */
  40996. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  40997. /** @hidden */
  40998. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  40999. width: number;
  41000. height: number;
  41001. layers?: number;
  41002. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number, samples?: number): void;
  41003. /** @hidden */
  41004. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  41005. /** @hidden */
  41006. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  41007. /**
  41008. * Update a portion of an internal texture
  41009. * @param texture defines the texture to update
  41010. * @param imageData defines the data to store into the texture
  41011. * @param xOffset defines the x coordinates of the update rectangle
  41012. * @param yOffset defines the y coordinates of the update rectangle
  41013. * @param width defines the width of the update rectangle
  41014. * @param height defines the height of the update rectangle
  41015. * @param faceIndex defines the face index if texture is a cube (0 by default)
  41016. * @param lod defines the lod level to update (0 by default)
  41017. */
  41018. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  41019. /** @hidden */
  41020. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  41021. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  41022. private _prepareWebGLTexture;
  41023. /** @hidden */
  41024. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  41025. private _getDepthStencilBuffer;
  41026. /** @hidden */
  41027. _releaseFramebufferObjects(texture: InternalTexture): void;
  41028. /** @hidden */
  41029. _releaseTexture(texture: InternalTexture): void;
  41030. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  41031. protected _setProgram(program: WebGLProgram): void;
  41032. protected _boundUniforms: {
  41033. [key: number]: WebGLUniformLocation;
  41034. };
  41035. /**
  41036. * Binds an effect to the webGL context
  41037. * @param effect defines the effect to bind
  41038. */
  41039. bindSamplers(effect: Effect): void;
  41040. private _activateCurrentTexture;
  41041. /** @hidden */
  41042. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  41043. /** @hidden */
  41044. _bindTexture(channel: number, texture: Nullable<InternalTexture>, name: string): void;
  41045. /**
  41046. * Unbind all textures from the webGL context
  41047. */
  41048. unbindAllTextures(): void;
  41049. /**
  41050. * Sets a texture to the according uniform.
  41051. * @param channel The texture channel
  41052. * @param uniform The uniform to set
  41053. * @param texture The texture to apply
  41054. * @param name The name of the uniform in the effect
  41055. */
  41056. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<ThinTexture>, name: string): void;
  41057. private _bindSamplerUniformToChannel;
  41058. private _getTextureWrapMode;
  41059. protected _setTexture(channel: number, texture: Nullable<ThinTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean, name?: string): boolean;
  41060. /**
  41061. * Sets an array of texture to the webGL context
  41062. * @param channel defines the channel where the texture array must be set
  41063. * @param uniform defines the associated uniform location
  41064. * @param textures defines the array of textures to bind
  41065. * @param name name of the channel
  41066. */
  41067. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: ThinTexture[], name: string): void;
  41068. /** @hidden */
  41069. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  41070. private _setTextureParameterFloat;
  41071. private _setTextureParameterInteger;
  41072. /**
  41073. * Unbind all vertex attributes from the webGL context
  41074. */
  41075. unbindAllAttributes(): void;
  41076. /**
  41077. * 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
  41078. */
  41079. releaseEffects(): void;
  41080. /**
  41081. * Dispose and release all associated resources
  41082. */
  41083. dispose(): void;
  41084. /**
  41085. * Attach a new callback raised when context lost event is fired
  41086. * @param callback defines the callback to call
  41087. */
  41088. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  41089. /**
  41090. * Attach a new callback raised when context restored event is fired
  41091. * @param callback defines the callback to call
  41092. */
  41093. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  41094. /**
  41095. * Get the current error code of the webGL context
  41096. * @returns the error code
  41097. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  41098. */
  41099. getError(): number;
  41100. private _canRenderToFloatFramebuffer;
  41101. private _canRenderToHalfFloatFramebuffer;
  41102. private _canRenderToFramebuffer;
  41103. /** @hidden */
  41104. _getWebGLTextureType(type: number): number;
  41105. /** @hidden */
  41106. _getInternalFormat(format: number): number;
  41107. /** @hidden */
  41108. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  41109. /** @hidden */
  41110. _getRGBAMultiSampleBufferFormat(type: number): number;
  41111. /** @hidden */
  41112. _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;
  41113. /**
  41114. * Loads a file from a url
  41115. * @param url url to load
  41116. * @param onSuccess callback called when the file successfully loads
  41117. * @param onProgress callback called while file is loading (if the server supports this mode)
  41118. * @param offlineProvider defines the offline provider for caching
  41119. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  41120. * @param onError callback called when the file fails to load
  41121. * @returns a file request object
  41122. * @hidden
  41123. */
  41124. 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;
  41125. /**
  41126. * Reads pixels from the current frame buffer. Please note that this function can be slow
  41127. * @param x defines the x coordinate of the rectangle where pixels must be read
  41128. * @param y defines the y coordinate of the rectangle where pixels must be read
  41129. * @param width defines the width of the rectangle where pixels must be read
  41130. * @param height defines the height of the rectangle where pixels must be read
  41131. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  41132. * @param flushRenderer true to flush the renderer from the pending commands before reading the pixels
  41133. * @returns a ArrayBufferView promise (Uint8Array) containing RGBA colors
  41134. */
  41135. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean, flushRenderer?: boolean): Promise<ArrayBufferView>;
  41136. private static _IsSupported;
  41137. private static _HasMajorPerformanceCaveat;
  41138. /**
  41139. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  41140. */
  41141. static get IsSupported(): boolean;
  41142. /**
  41143. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  41144. * @returns true if the engine can be created
  41145. * @ignorenaming
  41146. */
  41147. static isSupported(): boolean;
  41148. /**
  41149. * 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)
  41150. */
  41151. static get HasMajorPerformanceCaveat(): boolean;
  41152. /**
  41153. * Find the next highest power of two.
  41154. * @param x Number to start search from.
  41155. * @return Next highest power of two.
  41156. */
  41157. static CeilingPOT(x: number): number;
  41158. /**
  41159. * Find the next lowest power of two.
  41160. * @param x Number to start search from.
  41161. * @return Next lowest power of two.
  41162. */
  41163. static FloorPOT(x: number): number;
  41164. /**
  41165. * Find the nearest power of two.
  41166. * @param x Number to start search from.
  41167. * @return Next nearest power of two.
  41168. */
  41169. static NearestPOT(x: number): number;
  41170. /**
  41171. * Get the closest exponent of two
  41172. * @param value defines the value to approximate
  41173. * @param max defines the maximum value to return
  41174. * @param mode defines how to define the closest value
  41175. * @returns closest exponent of two of the given value
  41176. */
  41177. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  41178. /**
  41179. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  41180. * @param func - the function to be called
  41181. * @param requester - the object that will request the next frame. Falls back to window.
  41182. * @returns frame number
  41183. */
  41184. static QueueNewFrame(func: () => void, requester?: any): number;
  41185. /**
  41186. * Gets host document
  41187. * @returns the host document object
  41188. */
  41189. getHostDocument(): Nullable<Document>;
  41190. }
  41191. }
  41192. declare module BABYLON {
  41193. /**
  41194. * Defines the source of the internal texture
  41195. */
  41196. export enum InternalTextureSource {
  41197. /**
  41198. * The source of the texture data is unknown
  41199. */
  41200. Unknown = 0,
  41201. /**
  41202. * Texture data comes from an URL
  41203. */
  41204. Url = 1,
  41205. /**
  41206. * Texture data is only used for temporary storage
  41207. */
  41208. Temp = 2,
  41209. /**
  41210. * Texture data comes from raw data (ArrayBuffer)
  41211. */
  41212. Raw = 3,
  41213. /**
  41214. * Texture content is dynamic (video or dynamic texture)
  41215. */
  41216. Dynamic = 4,
  41217. /**
  41218. * Texture content is generated by rendering to it
  41219. */
  41220. RenderTarget = 5,
  41221. /**
  41222. * Texture content is part of a multi render target process
  41223. */
  41224. MultiRenderTarget = 6,
  41225. /**
  41226. * Texture data comes from a cube data file
  41227. */
  41228. Cube = 7,
  41229. /**
  41230. * Texture data comes from a raw cube data
  41231. */
  41232. CubeRaw = 8,
  41233. /**
  41234. * Texture data come from a prefiltered cube data file
  41235. */
  41236. CubePrefiltered = 9,
  41237. /**
  41238. * Texture content is raw 3D data
  41239. */
  41240. Raw3D = 10,
  41241. /**
  41242. * Texture content is raw 2D array data
  41243. */
  41244. Raw2DArray = 11,
  41245. /**
  41246. * Texture content is a depth texture
  41247. */
  41248. Depth = 12,
  41249. /**
  41250. * Texture data comes from a raw cube data encoded with RGBD
  41251. */
  41252. CubeRawRGBD = 13
  41253. }
  41254. /**
  41255. * Class used to store data associated with WebGL texture data for the engine
  41256. * This class should not be used directly
  41257. */
  41258. export class InternalTexture {
  41259. /** @hidden */
  41260. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  41261. /**
  41262. * Defines if the texture is ready
  41263. */
  41264. isReady: boolean;
  41265. /**
  41266. * Defines if the texture is a cube texture
  41267. */
  41268. isCube: boolean;
  41269. /**
  41270. * Defines if the texture contains 3D data
  41271. */
  41272. is3D: boolean;
  41273. /**
  41274. * Defines if the texture contains 2D array data
  41275. */
  41276. is2DArray: boolean;
  41277. /**
  41278. * Defines if the texture contains multiview data
  41279. */
  41280. isMultiview: boolean;
  41281. /**
  41282. * Gets the URL used to load this texture
  41283. */
  41284. url: string;
  41285. /** @hidden */
  41286. _originalUrl: string;
  41287. /**
  41288. * Gets the sampling mode of the texture
  41289. */
  41290. samplingMode: number;
  41291. /**
  41292. * Gets a boolean indicating if the texture needs mipmaps generation
  41293. */
  41294. generateMipMaps: boolean;
  41295. /**
  41296. * Gets the number of samples used by the texture (WebGL2+ only)
  41297. */
  41298. samples: number;
  41299. /**
  41300. * Gets the type of the texture (int, float...)
  41301. */
  41302. type: number;
  41303. /**
  41304. * Gets the format of the texture (RGB, RGBA...)
  41305. */
  41306. format: number;
  41307. /**
  41308. * Observable called when the texture is loaded
  41309. */
  41310. onLoadedObservable: Observable<InternalTexture>;
  41311. /**
  41312. * Gets the width of the texture
  41313. */
  41314. width: number;
  41315. /**
  41316. * Gets the height of the texture
  41317. */
  41318. height: number;
  41319. /**
  41320. * Gets the depth of the texture
  41321. */
  41322. depth: number;
  41323. /**
  41324. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  41325. */
  41326. baseWidth: number;
  41327. /**
  41328. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  41329. */
  41330. baseHeight: number;
  41331. /**
  41332. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  41333. */
  41334. baseDepth: number;
  41335. /**
  41336. * Gets a boolean indicating if the texture is inverted on Y axis
  41337. */
  41338. invertY: boolean;
  41339. /** @hidden */
  41340. _invertVScale: boolean;
  41341. /** @hidden */
  41342. _associatedChannel: number;
  41343. /** @hidden */
  41344. _source: InternalTextureSource;
  41345. /** @hidden */
  41346. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  41347. /** @hidden */
  41348. _bufferView: Nullable<ArrayBufferView>;
  41349. /** @hidden */
  41350. _bufferViewArray: Nullable<ArrayBufferView[]>;
  41351. /** @hidden */
  41352. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  41353. /** @hidden */
  41354. _size: number;
  41355. /** @hidden */
  41356. _extension: string;
  41357. /** @hidden */
  41358. _files: Nullable<string[]>;
  41359. /** @hidden */
  41360. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  41361. /** @hidden */
  41362. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  41363. /** @hidden */
  41364. _framebuffer: Nullable<WebGLFramebuffer>;
  41365. /** @hidden */
  41366. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  41367. /** @hidden */
  41368. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  41369. /** @hidden */
  41370. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  41371. /** @hidden */
  41372. _attachments: Nullable<number[]>;
  41373. /** @hidden */
  41374. _textureArray: Nullable<InternalTexture[]>;
  41375. /** @hidden */
  41376. _cachedCoordinatesMode: Nullable<number>;
  41377. /** @hidden */
  41378. _cachedWrapU: Nullable<number>;
  41379. /** @hidden */
  41380. _cachedWrapV: Nullable<number>;
  41381. /** @hidden */
  41382. _cachedWrapR: Nullable<number>;
  41383. /** @hidden */
  41384. _cachedAnisotropicFilteringLevel: Nullable<number>;
  41385. /** @hidden */
  41386. _isDisabled: boolean;
  41387. /** @hidden */
  41388. _compression: Nullable<string>;
  41389. /** @hidden */
  41390. _generateStencilBuffer: boolean;
  41391. /** @hidden */
  41392. _generateDepthBuffer: boolean;
  41393. /** @hidden */
  41394. _comparisonFunction: number;
  41395. /** @hidden */
  41396. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  41397. /** @hidden */
  41398. _sphericalPolynomialPromise: Nullable<Promise<SphericalPolynomial>>;
  41399. /** @hidden */
  41400. _sphericalPolynomialComputed: boolean;
  41401. /** @hidden */
  41402. _lodGenerationScale: number;
  41403. /** @hidden */
  41404. _lodGenerationOffset: number;
  41405. /** @hidden */
  41406. _depthStencilTexture: Nullable<InternalTexture>;
  41407. /** @hidden */
  41408. _colorTextureArray: Nullable<WebGLTexture>;
  41409. /** @hidden */
  41410. _depthStencilTextureArray: Nullable<WebGLTexture>;
  41411. /** @hidden */
  41412. _lodTextureHigh: Nullable<BaseTexture>;
  41413. /** @hidden */
  41414. _lodTextureMid: Nullable<BaseTexture>;
  41415. /** @hidden */
  41416. _lodTextureLow: Nullable<BaseTexture>;
  41417. /** @hidden */
  41418. _isRGBD: boolean;
  41419. /** @hidden */
  41420. _linearSpecularLOD: boolean;
  41421. /** @hidden */
  41422. _irradianceTexture: Nullable<BaseTexture>;
  41423. /** @hidden */
  41424. _hardwareTexture: Nullable<HardwareTextureWrapper>;
  41425. /** @hidden */
  41426. _references: number;
  41427. /** @hidden */
  41428. _gammaSpace: Nullable<boolean>;
  41429. private _engine;
  41430. private _uniqueId;
  41431. private static _Counter;
  41432. /** Gets the unique id of the internal texture */
  41433. get uniqueId(): number;
  41434. /**
  41435. * Gets the Engine the texture belongs to.
  41436. * @returns The babylon engine
  41437. */
  41438. getEngine(): ThinEngine;
  41439. /**
  41440. * Gets the data source type of the texture
  41441. */
  41442. get source(): InternalTextureSource;
  41443. /**
  41444. * Creates a new InternalTexture
  41445. * @param engine defines the engine to use
  41446. * @param source defines the type of data that will be used
  41447. * @param delayAllocation if the texture allocation should be delayed (default: false)
  41448. */
  41449. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  41450. /**
  41451. * Increments the number of references (ie. the number of Texture that point to it)
  41452. */
  41453. incrementReferences(): void;
  41454. /**
  41455. * Change the size of the texture (not the size of the content)
  41456. * @param width defines the new width
  41457. * @param height defines the new height
  41458. * @param depth defines the new depth (1 by default)
  41459. */
  41460. updateSize(width: int, height: int, depth?: int): void;
  41461. /** @hidden */
  41462. _rebuild(): void;
  41463. /** @hidden */
  41464. _swapAndDie(target: InternalTexture): void;
  41465. /**
  41466. * Dispose the current allocated resources
  41467. */
  41468. dispose(): void;
  41469. }
  41470. }
  41471. declare module BABYLON {
  41472. /**
  41473. * Interface used to present a loading screen while loading a scene
  41474. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41475. */
  41476. export interface ILoadingScreen {
  41477. /**
  41478. * Function called to display the loading screen
  41479. */
  41480. displayLoadingUI: () => void;
  41481. /**
  41482. * Function called to hide the loading screen
  41483. */
  41484. hideLoadingUI: () => void;
  41485. /**
  41486. * Gets or sets the color to use for the background
  41487. */
  41488. loadingUIBackgroundColor: string;
  41489. /**
  41490. * Gets or sets the text to display while loading
  41491. */
  41492. loadingUIText: string;
  41493. }
  41494. /**
  41495. * Class used for the default loading screen
  41496. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41497. */
  41498. export class DefaultLoadingScreen implements ILoadingScreen {
  41499. private _renderingCanvas;
  41500. private _loadingText;
  41501. private _loadingDivBackgroundColor;
  41502. private _loadingDiv;
  41503. private _loadingTextDiv;
  41504. /** Gets or sets the logo url to use for the default loading screen */
  41505. static DefaultLogoUrl: string;
  41506. /** Gets or sets the spinner url to use for the default loading screen */
  41507. static DefaultSpinnerUrl: string;
  41508. /**
  41509. * Creates a new default loading screen
  41510. * @param _renderingCanvas defines the canvas used to render the scene
  41511. * @param _loadingText defines the default text to display
  41512. * @param _loadingDivBackgroundColor defines the default background color
  41513. */
  41514. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  41515. /**
  41516. * Function called to display the loading screen
  41517. */
  41518. displayLoadingUI(): void;
  41519. /**
  41520. * Function called to hide the loading screen
  41521. */
  41522. hideLoadingUI(): void;
  41523. /**
  41524. * Gets or sets the text to display while loading
  41525. */
  41526. set loadingUIText(text: string);
  41527. get loadingUIText(): string;
  41528. /**
  41529. * Gets or sets the color to use for the background
  41530. */
  41531. get loadingUIBackgroundColor(): string;
  41532. set loadingUIBackgroundColor(color: string);
  41533. private _resizeLoadingUI;
  41534. }
  41535. }
  41536. declare module BABYLON {
  41537. /**
  41538. * Interface for any object that can request an animation frame
  41539. */
  41540. export interface ICustomAnimationFrameRequester {
  41541. /**
  41542. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  41543. */
  41544. renderFunction?: Function;
  41545. /**
  41546. * Called to request the next frame to render to
  41547. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  41548. */
  41549. requestAnimationFrame: Function;
  41550. /**
  41551. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  41552. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  41553. */
  41554. requestID?: number;
  41555. }
  41556. }
  41557. declare module BABYLON {
  41558. /**
  41559. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  41560. */
  41561. export class PerformanceMonitor {
  41562. private _enabled;
  41563. private _rollingFrameTime;
  41564. private _lastFrameTimeMs;
  41565. /**
  41566. * constructor
  41567. * @param frameSampleSize The number of samples required to saturate the sliding window
  41568. */
  41569. constructor(frameSampleSize?: number);
  41570. /**
  41571. * Samples current frame
  41572. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  41573. */
  41574. sampleFrame(timeMs?: number): void;
  41575. /**
  41576. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  41577. */
  41578. get averageFrameTime(): number;
  41579. /**
  41580. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  41581. */
  41582. get averageFrameTimeVariance(): number;
  41583. /**
  41584. * Returns the frame time of the most recent frame
  41585. */
  41586. get instantaneousFrameTime(): number;
  41587. /**
  41588. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  41589. */
  41590. get averageFPS(): number;
  41591. /**
  41592. * Returns the average framerate in frames per second using the most recent frame time
  41593. */
  41594. get instantaneousFPS(): number;
  41595. /**
  41596. * Returns true if enough samples have been taken to completely fill the sliding window
  41597. */
  41598. get isSaturated(): boolean;
  41599. /**
  41600. * Enables contributions to the sliding window sample set
  41601. */
  41602. enable(): void;
  41603. /**
  41604. * Disables contributions to the sliding window sample set
  41605. * Samples will not be interpolated over the disabled period
  41606. */
  41607. disable(): void;
  41608. /**
  41609. * Returns true if sampling is enabled
  41610. */
  41611. get isEnabled(): boolean;
  41612. /**
  41613. * Resets performance monitor
  41614. */
  41615. reset(): void;
  41616. }
  41617. /**
  41618. * RollingAverage
  41619. *
  41620. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  41621. */
  41622. export class RollingAverage {
  41623. /**
  41624. * Current average
  41625. */
  41626. average: number;
  41627. /**
  41628. * Current variance
  41629. */
  41630. variance: number;
  41631. protected _samples: Array<number>;
  41632. protected _sampleCount: number;
  41633. protected _pos: number;
  41634. protected _m2: number;
  41635. /**
  41636. * constructor
  41637. * @param length The number of samples required to saturate the sliding window
  41638. */
  41639. constructor(length: number);
  41640. /**
  41641. * Adds a sample to the sample set
  41642. * @param v The sample value
  41643. */
  41644. add(v: number): void;
  41645. /**
  41646. * Returns previously added values or null if outside of history or outside the sliding window domain
  41647. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  41648. * @return Value previously recorded with add() or null if outside of range
  41649. */
  41650. history(i: number): number;
  41651. /**
  41652. * Returns true if enough samples have been taken to completely fill the sliding window
  41653. * @return true if sample-set saturated
  41654. */
  41655. isSaturated(): boolean;
  41656. /**
  41657. * Resets the rolling average (equivalent to 0 samples taken so far)
  41658. */
  41659. reset(): void;
  41660. /**
  41661. * Wraps a value around the sample range boundaries
  41662. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  41663. * @return Wrapped position in sample range
  41664. */
  41665. protected _wrapPosition(i: number): number;
  41666. }
  41667. }
  41668. declare module BABYLON {
  41669. /**
  41670. * This class is used to track a performance counter which is number based.
  41671. * The user has access to many properties which give statistics of different nature.
  41672. *
  41673. * The implementer can track two kinds of Performance Counter: time and count.
  41674. * 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.
  41675. * 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.
  41676. */
  41677. export class PerfCounter {
  41678. /**
  41679. * Gets or sets a global boolean to turn on and off all the counters
  41680. */
  41681. static Enabled: boolean;
  41682. /**
  41683. * Returns the smallest value ever
  41684. */
  41685. get min(): number;
  41686. /**
  41687. * Returns the biggest value ever
  41688. */
  41689. get max(): number;
  41690. /**
  41691. * Returns the average value since the performance counter is running
  41692. */
  41693. get average(): number;
  41694. /**
  41695. * Returns the average value of the last second the counter was monitored
  41696. */
  41697. get lastSecAverage(): number;
  41698. /**
  41699. * Returns the current value
  41700. */
  41701. get current(): number;
  41702. /**
  41703. * Gets the accumulated total
  41704. */
  41705. get total(): number;
  41706. /**
  41707. * Gets the total value count
  41708. */
  41709. get count(): number;
  41710. /**
  41711. * Creates a new counter
  41712. */
  41713. constructor();
  41714. /**
  41715. * Call this method to start monitoring a new frame.
  41716. * 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.
  41717. */
  41718. fetchNewFrame(): void;
  41719. /**
  41720. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  41721. * @param newCount the count value to add to the monitored count
  41722. * @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.
  41723. */
  41724. addCount(newCount: number, fetchResult: boolean): void;
  41725. /**
  41726. * Start monitoring this performance counter
  41727. */
  41728. beginMonitoring(): void;
  41729. /**
  41730. * Compute the time lapsed since the previous beginMonitoring() call.
  41731. * @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
  41732. */
  41733. endMonitoring(newFrame?: boolean): void;
  41734. private _fetchResult;
  41735. private _startMonitoringTime;
  41736. private _min;
  41737. private _max;
  41738. private _average;
  41739. private _current;
  41740. private _totalValueCount;
  41741. private _totalAccumulated;
  41742. private _lastSecAverage;
  41743. private _lastSecAccumulated;
  41744. private _lastSecTime;
  41745. private _lastSecValueCount;
  41746. }
  41747. }
  41748. declare module BABYLON {
  41749. interface ThinEngine {
  41750. /** @hidden */
  41751. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>, flushRenderer?: boolean): Promise<ArrayBufferView>;
  41752. /** @hidden */
  41753. _readTexturePixelsSync(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>, flushRenderer?: boolean): ArrayBufferView;
  41754. }
  41755. }
  41756. declare module BABYLON {
  41757. /**
  41758. * Class used to work with sound analyzer using fast fourier transform (FFT)
  41759. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  41760. */
  41761. export class Analyser {
  41762. /**
  41763. * Gets or sets the smoothing
  41764. * @ignorenaming
  41765. */
  41766. SMOOTHING: number;
  41767. /**
  41768. * Gets or sets the FFT table size
  41769. * @ignorenaming
  41770. */
  41771. FFT_SIZE: number;
  41772. /**
  41773. * Gets or sets the bar graph amplitude
  41774. * @ignorenaming
  41775. */
  41776. BARGRAPHAMPLITUDE: number;
  41777. /**
  41778. * Gets or sets the position of the debug canvas
  41779. * @ignorenaming
  41780. */
  41781. DEBUGCANVASPOS: {
  41782. x: number;
  41783. y: number;
  41784. };
  41785. /**
  41786. * Gets or sets the debug canvas size
  41787. * @ignorenaming
  41788. */
  41789. DEBUGCANVASSIZE: {
  41790. width: number;
  41791. height: number;
  41792. };
  41793. private _byteFreqs;
  41794. private _byteTime;
  41795. private _floatFreqs;
  41796. private _webAudioAnalyser;
  41797. private _debugCanvas;
  41798. private _debugCanvasContext;
  41799. private _scene;
  41800. private _registerFunc;
  41801. private _audioEngine;
  41802. /**
  41803. * Creates a new analyser
  41804. * @param scene defines hosting scene
  41805. */
  41806. constructor(scene: Scene);
  41807. /**
  41808. * Get the number of data values you will have to play with for the visualization
  41809. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  41810. * @returns a number
  41811. */
  41812. getFrequencyBinCount(): number;
  41813. /**
  41814. * Gets the current frequency data as a byte array
  41815. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  41816. * @returns a Uint8Array
  41817. */
  41818. getByteFrequencyData(): Uint8Array;
  41819. /**
  41820. * Gets the current waveform as a byte array
  41821. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  41822. * @returns a Uint8Array
  41823. */
  41824. getByteTimeDomainData(): Uint8Array;
  41825. /**
  41826. * Gets the current frequency data as a float array
  41827. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  41828. * @returns a Float32Array
  41829. */
  41830. getFloatFrequencyData(): Float32Array;
  41831. /**
  41832. * Renders the debug canvas
  41833. */
  41834. drawDebugCanvas(): void;
  41835. /**
  41836. * Stops rendering the debug canvas and removes it
  41837. */
  41838. stopDebugCanvas(): void;
  41839. /**
  41840. * Connects two audio nodes
  41841. * @param inputAudioNode defines first node to connect
  41842. * @param outputAudioNode defines second node to connect
  41843. */
  41844. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  41845. /**
  41846. * Releases all associated resources
  41847. */
  41848. dispose(): void;
  41849. }
  41850. }
  41851. declare module BABYLON {
  41852. /**
  41853. * This represents an audio engine and it is responsible
  41854. * to play, synchronize and analyse sounds throughout the application.
  41855. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  41856. */
  41857. export interface IAudioEngine extends IDisposable {
  41858. /**
  41859. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  41860. */
  41861. readonly canUseWebAudio: boolean;
  41862. /**
  41863. * Gets the current AudioContext if available.
  41864. */
  41865. readonly audioContext: Nullable<AudioContext>;
  41866. /**
  41867. * The master gain node defines the global audio volume of your audio engine.
  41868. */
  41869. readonly masterGain: GainNode;
  41870. /**
  41871. * Gets whether or not mp3 are supported by your browser.
  41872. */
  41873. readonly isMP3supported: boolean;
  41874. /**
  41875. * Gets whether or not ogg are supported by your browser.
  41876. */
  41877. readonly isOGGsupported: boolean;
  41878. /**
  41879. * Defines if Babylon should emit a warning if WebAudio is not supported.
  41880. * @ignoreNaming
  41881. */
  41882. WarnedWebAudioUnsupported: boolean;
  41883. /**
  41884. * Defines if the audio engine relies on a custom unlocked button.
  41885. * In this case, the embedded button will not be displayed.
  41886. */
  41887. useCustomUnlockedButton: boolean;
  41888. /**
  41889. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  41890. */
  41891. readonly unlocked: boolean;
  41892. /**
  41893. * Event raised when audio has been unlocked on the browser.
  41894. */
  41895. onAudioUnlockedObservable: Observable<IAudioEngine>;
  41896. /**
  41897. * Event raised when audio has been locked on the browser.
  41898. */
  41899. onAudioLockedObservable: Observable<IAudioEngine>;
  41900. /**
  41901. * Flags the audio engine in Locked state.
  41902. * This happens due to new browser policies preventing audio to autoplay.
  41903. */
  41904. lock(): void;
  41905. /**
  41906. * Unlocks the audio engine once a user action has been done on the dom.
  41907. * This is helpful to resume play once browser policies have been satisfied.
  41908. */
  41909. unlock(): void;
  41910. /**
  41911. * Gets the global volume sets on the master gain.
  41912. * @returns the global volume if set or -1 otherwise
  41913. */
  41914. getGlobalVolume(): number;
  41915. /**
  41916. * Sets the global volume of your experience (sets on the master gain).
  41917. * @param newVolume Defines the new global volume of the application
  41918. */
  41919. setGlobalVolume(newVolume: number): void;
  41920. /**
  41921. * Connect the audio engine to an audio analyser allowing some amazing
  41922. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  41923. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  41924. * @param analyser The analyser to connect to the engine
  41925. */
  41926. connectToAnalyser(analyser: Analyser): void;
  41927. }
  41928. }
  41929. declare module BABYLON {
  41930. /**
  41931. * Defines the interface used by display changed events
  41932. */
  41933. export interface IDisplayChangedEventArgs {
  41934. /** Gets the vrDisplay object (if any) */
  41935. vrDisplay: Nullable<any>;
  41936. /** Gets a boolean indicating if webVR is supported */
  41937. vrSupported: boolean;
  41938. }
  41939. /**
  41940. * Defines the interface used by objects containing a viewport (like a camera)
  41941. */
  41942. interface IViewportOwnerLike {
  41943. /**
  41944. * Gets or sets the viewport
  41945. */
  41946. viewport: IViewportLike;
  41947. }
  41948. /**
  41949. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  41950. */
  41951. export class Engine extends ThinEngine {
  41952. /** Defines that alpha blending is disabled */
  41953. static readonly ALPHA_DISABLE: number;
  41954. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  41955. static readonly ALPHA_ADD: number;
  41956. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  41957. static readonly ALPHA_COMBINE: number;
  41958. /** Defines that alpha blending to DEST - SRC * DEST */
  41959. static readonly ALPHA_SUBTRACT: number;
  41960. /** Defines that alpha blending to SRC * DEST */
  41961. static readonly ALPHA_MULTIPLY: number;
  41962. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  41963. static readonly ALPHA_MAXIMIZED: number;
  41964. /** Defines that alpha blending to SRC + DEST */
  41965. static readonly ALPHA_ONEONE: number;
  41966. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  41967. static readonly ALPHA_PREMULTIPLIED: number;
  41968. /**
  41969. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  41970. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  41971. */
  41972. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  41973. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  41974. static readonly ALPHA_INTERPOLATE: number;
  41975. /**
  41976. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  41977. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  41978. */
  41979. static readonly ALPHA_SCREENMODE: number;
  41980. /** Defines that the ressource is not delayed*/
  41981. static readonly DELAYLOADSTATE_NONE: number;
  41982. /** Defines that the ressource was successfully delay loaded */
  41983. static readonly DELAYLOADSTATE_LOADED: number;
  41984. /** Defines that the ressource is currently delay loading */
  41985. static readonly DELAYLOADSTATE_LOADING: number;
  41986. /** Defines that the ressource is delayed and has not started loading */
  41987. static readonly DELAYLOADSTATE_NOTLOADED: number;
  41988. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  41989. static readonly NEVER: number;
  41990. /** 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 */
  41991. static readonly ALWAYS: number;
  41992. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  41993. static readonly LESS: number;
  41994. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  41995. static readonly EQUAL: number;
  41996. /** 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 */
  41997. static readonly LEQUAL: number;
  41998. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  41999. static readonly GREATER: number;
  42000. /** 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 */
  42001. static readonly GEQUAL: number;
  42002. /** 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 */
  42003. static readonly NOTEQUAL: number;
  42004. /** Passed to stencilOperation to specify that stencil value must be kept */
  42005. static readonly KEEP: number;
  42006. /** Passed to stencilOperation to specify that stencil value must be replaced */
  42007. static readonly REPLACE: number;
  42008. /** Passed to stencilOperation to specify that stencil value must be incremented */
  42009. static readonly INCR: number;
  42010. /** Passed to stencilOperation to specify that stencil value must be decremented */
  42011. static readonly DECR: number;
  42012. /** Passed to stencilOperation to specify that stencil value must be inverted */
  42013. static readonly INVERT: number;
  42014. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  42015. static readonly INCR_WRAP: number;
  42016. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  42017. static readonly DECR_WRAP: number;
  42018. /** Texture is not repeating outside of 0..1 UVs */
  42019. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  42020. /** Texture is repeating outside of 0..1 UVs */
  42021. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  42022. /** Texture is repeating and mirrored */
  42023. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  42024. /** ALPHA */
  42025. static readonly TEXTUREFORMAT_ALPHA: number;
  42026. /** LUMINANCE */
  42027. static readonly TEXTUREFORMAT_LUMINANCE: number;
  42028. /** LUMINANCE_ALPHA */
  42029. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  42030. /** RGB */
  42031. static readonly TEXTUREFORMAT_RGB: number;
  42032. /** RGBA */
  42033. static readonly TEXTUREFORMAT_RGBA: number;
  42034. /** RED */
  42035. static readonly TEXTUREFORMAT_RED: number;
  42036. /** RED (2nd reference) */
  42037. static readonly TEXTUREFORMAT_R: number;
  42038. /** RG */
  42039. static readonly TEXTUREFORMAT_RG: number;
  42040. /** RED_INTEGER */
  42041. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  42042. /** RED_INTEGER (2nd reference) */
  42043. static readonly TEXTUREFORMAT_R_INTEGER: number;
  42044. /** RG_INTEGER */
  42045. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  42046. /** RGB_INTEGER */
  42047. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  42048. /** RGBA_INTEGER */
  42049. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  42050. /** UNSIGNED_BYTE */
  42051. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  42052. /** UNSIGNED_BYTE (2nd reference) */
  42053. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  42054. /** FLOAT */
  42055. static readonly TEXTURETYPE_FLOAT: number;
  42056. /** HALF_FLOAT */
  42057. static readonly TEXTURETYPE_HALF_FLOAT: number;
  42058. /** BYTE */
  42059. static readonly TEXTURETYPE_BYTE: number;
  42060. /** SHORT */
  42061. static readonly TEXTURETYPE_SHORT: number;
  42062. /** UNSIGNED_SHORT */
  42063. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  42064. /** INT */
  42065. static readonly TEXTURETYPE_INT: number;
  42066. /** UNSIGNED_INT */
  42067. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  42068. /** UNSIGNED_SHORT_4_4_4_4 */
  42069. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  42070. /** UNSIGNED_SHORT_5_5_5_1 */
  42071. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  42072. /** UNSIGNED_SHORT_5_6_5 */
  42073. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  42074. /** UNSIGNED_INT_2_10_10_10_REV */
  42075. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  42076. /** UNSIGNED_INT_24_8 */
  42077. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  42078. /** UNSIGNED_INT_10F_11F_11F_REV */
  42079. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  42080. /** UNSIGNED_INT_5_9_9_9_REV */
  42081. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  42082. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  42083. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  42084. /** nearest is mag = nearest and min = nearest and mip = none */
  42085. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  42086. /** Bilinear is mag = linear and min = linear and mip = nearest */
  42087. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  42088. /** Trilinear is mag = linear and min = linear and mip = linear */
  42089. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  42090. /** nearest is mag = nearest and min = nearest and mip = linear */
  42091. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  42092. /** Bilinear is mag = linear and min = linear and mip = nearest */
  42093. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  42094. /** Trilinear is mag = linear and min = linear and mip = linear */
  42095. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  42096. /** mag = nearest and min = nearest and mip = nearest */
  42097. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  42098. /** mag = nearest and min = linear and mip = nearest */
  42099. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  42100. /** mag = nearest and min = linear and mip = linear */
  42101. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  42102. /** mag = nearest and min = linear and mip = none */
  42103. static readonly TEXTURE_NEAREST_LINEAR: number;
  42104. /** mag = nearest and min = nearest and mip = none */
  42105. static readonly TEXTURE_NEAREST_NEAREST: number;
  42106. /** mag = linear and min = nearest and mip = nearest */
  42107. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  42108. /** mag = linear and min = nearest and mip = linear */
  42109. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  42110. /** mag = linear and min = linear and mip = none */
  42111. static readonly TEXTURE_LINEAR_LINEAR: number;
  42112. /** mag = linear and min = nearest and mip = none */
  42113. static readonly TEXTURE_LINEAR_NEAREST: number;
  42114. /** Explicit coordinates mode */
  42115. static readonly TEXTURE_EXPLICIT_MODE: number;
  42116. /** Spherical coordinates mode */
  42117. static readonly TEXTURE_SPHERICAL_MODE: number;
  42118. /** Planar coordinates mode */
  42119. static readonly TEXTURE_PLANAR_MODE: number;
  42120. /** Cubic coordinates mode */
  42121. static readonly TEXTURE_CUBIC_MODE: number;
  42122. /** Projection coordinates mode */
  42123. static readonly TEXTURE_PROJECTION_MODE: number;
  42124. /** Skybox coordinates mode */
  42125. static readonly TEXTURE_SKYBOX_MODE: number;
  42126. /** Inverse Cubic coordinates mode */
  42127. static readonly TEXTURE_INVCUBIC_MODE: number;
  42128. /** Equirectangular coordinates mode */
  42129. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  42130. /** Equirectangular Fixed coordinates mode */
  42131. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  42132. /** Equirectangular Fixed Mirrored coordinates mode */
  42133. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  42134. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  42135. static readonly SCALEMODE_FLOOR: number;
  42136. /** Defines that texture rescaling will look for the nearest power of 2 size */
  42137. static readonly SCALEMODE_NEAREST: number;
  42138. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  42139. static readonly SCALEMODE_CEILING: number;
  42140. /**
  42141. * Returns the current npm package of the sdk
  42142. */
  42143. static get NpmPackage(): string;
  42144. /**
  42145. * Returns the current version of the framework
  42146. */
  42147. static get Version(): string;
  42148. /** Gets the list of created engines */
  42149. static get Instances(): Engine[];
  42150. /**
  42151. * Gets the latest created engine
  42152. */
  42153. static get LastCreatedEngine(): Nullable<Engine>;
  42154. /**
  42155. * Gets the latest created scene
  42156. */
  42157. static get LastCreatedScene(): Nullable<Scene>;
  42158. /**
  42159. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  42160. * @param flag defines which part of the materials must be marked as dirty
  42161. * @param predicate defines a predicate used to filter which materials should be affected
  42162. */
  42163. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  42164. /**
  42165. * Method called to create the default loading screen.
  42166. * This can be overriden in your own app.
  42167. * @param canvas The rendering canvas element
  42168. * @returns The loading screen
  42169. */
  42170. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  42171. /**
  42172. * Method called to create the default rescale post process on each engine.
  42173. */
  42174. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  42175. /**
  42176. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  42177. **/
  42178. enableOfflineSupport: boolean;
  42179. /**
  42180. * 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)
  42181. **/
  42182. disableManifestCheck: boolean;
  42183. /**
  42184. * Gets the list of created scenes
  42185. */
  42186. scenes: Scene[];
  42187. /**
  42188. * Event raised when a new scene is created
  42189. */
  42190. onNewSceneAddedObservable: Observable<Scene>;
  42191. /**
  42192. * Gets the list of created postprocesses
  42193. */
  42194. postProcesses: PostProcess[];
  42195. /**
  42196. * Gets a boolean indicating if the pointer is currently locked
  42197. */
  42198. isPointerLock: boolean;
  42199. /**
  42200. * Observable event triggered each time the rendering canvas is resized
  42201. */
  42202. onResizeObservable: Observable<Engine>;
  42203. /**
  42204. * Observable event triggered each time the canvas loses focus
  42205. */
  42206. onCanvasBlurObservable: Observable<Engine>;
  42207. /**
  42208. * Observable event triggered each time the canvas gains focus
  42209. */
  42210. onCanvasFocusObservable: Observable<Engine>;
  42211. /**
  42212. * Observable event triggered each time the canvas receives pointerout event
  42213. */
  42214. onCanvasPointerOutObservable: Observable<PointerEvent>;
  42215. /**
  42216. * Observable raised when the engine begins a new frame
  42217. */
  42218. onBeginFrameObservable: Observable<Engine>;
  42219. /**
  42220. * If set, will be used to request the next animation frame for the render loop
  42221. */
  42222. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  42223. /**
  42224. * Observable raised when the engine ends the current frame
  42225. */
  42226. onEndFrameObservable: Observable<Engine>;
  42227. /**
  42228. * Observable raised when the engine is about to compile a shader
  42229. */
  42230. onBeforeShaderCompilationObservable: Observable<Engine>;
  42231. /**
  42232. * Observable raised when the engine has jsut compiled a shader
  42233. */
  42234. onAfterShaderCompilationObservable: Observable<Engine>;
  42235. /**
  42236. * Gets the audio engine
  42237. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  42238. * @ignorenaming
  42239. */
  42240. static audioEngine: IAudioEngine;
  42241. /**
  42242. * Default AudioEngine factory responsible of creating the Audio Engine.
  42243. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  42244. */
  42245. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  42246. /**
  42247. * Default offline support factory responsible of creating a tool used to store data locally.
  42248. * By default, this will create a Database object if the workload has been embedded.
  42249. */
  42250. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  42251. private _loadingScreen;
  42252. private _pointerLockRequested;
  42253. private _rescalePostProcess;
  42254. protected _deterministicLockstep: boolean;
  42255. protected _lockstepMaxSteps: number;
  42256. protected _timeStep: number;
  42257. protected get _supportsHardwareTextureRescaling(): boolean;
  42258. private _fps;
  42259. private _deltaTime;
  42260. /** @hidden */
  42261. _drawCalls: PerfCounter;
  42262. /** 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 */
  42263. canvasTabIndex: number;
  42264. /**
  42265. * Turn this value on if you want to pause FPS computation when in background
  42266. */
  42267. disablePerformanceMonitorInBackground: boolean;
  42268. private _performanceMonitor;
  42269. /**
  42270. * Gets the performance monitor attached to this engine
  42271. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  42272. */
  42273. get performanceMonitor(): PerformanceMonitor;
  42274. private _onFocus;
  42275. private _onBlur;
  42276. private _onCanvasPointerOut;
  42277. private _onCanvasBlur;
  42278. private _onCanvasFocus;
  42279. private _onFullscreenChange;
  42280. private _onPointerLockChange;
  42281. /**
  42282. * Gets the HTML element used to attach event listeners
  42283. * @returns a HTML element
  42284. */
  42285. getInputElement(): Nullable<HTMLElement>;
  42286. /**
  42287. * Creates a new engine
  42288. * @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
  42289. * @param antialias defines enable antialiasing (default: false)
  42290. * @param options defines further options to be sent to the getContext() function
  42291. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  42292. */
  42293. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  42294. /**
  42295. * Shared initialization across engines types.
  42296. * @param canvas The canvas associated with this instance of the engine.
  42297. * @param doNotHandleTouchAction Defines that engine should ignore modifying touch action attribute and style
  42298. * @param audioEngine Defines if an audio engine should be created by default
  42299. */
  42300. protected _sharedInit(canvas: HTMLCanvasElement, doNotHandleTouchAction: boolean, audioEngine: boolean): void;
  42301. /**
  42302. * Gets current aspect ratio
  42303. * @param viewportOwner defines the camera to use to get the aspect ratio
  42304. * @param useScreen defines if screen size must be used (or the current render target if any)
  42305. * @returns a number defining the aspect ratio
  42306. */
  42307. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  42308. /**
  42309. * Gets current screen aspect ratio
  42310. * @returns a number defining the aspect ratio
  42311. */
  42312. getScreenAspectRatio(): number;
  42313. /**
  42314. * Gets the client rect of the HTML canvas attached with the current webGL context
  42315. * @returns a client rectanglee
  42316. */
  42317. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  42318. /**
  42319. * Gets the client rect of the HTML element used for events
  42320. * @returns a client rectanglee
  42321. */
  42322. getInputElementClientRect(): Nullable<ClientRect>;
  42323. /**
  42324. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  42325. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42326. * @returns true if engine is in deterministic lock step mode
  42327. */
  42328. isDeterministicLockStep(): boolean;
  42329. /**
  42330. * Gets the max steps when engine is running in deterministic lock step
  42331. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42332. * @returns the max steps
  42333. */
  42334. getLockstepMaxSteps(): number;
  42335. /**
  42336. * Returns the time in ms between steps when using deterministic lock step.
  42337. * @returns time step in (ms)
  42338. */
  42339. getTimeStep(): number;
  42340. /**
  42341. * Force the mipmap generation for the given render target texture
  42342. * @param texture defines the render target texture to use
  42343. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  42344. */
  42345. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  42346. /** States */
  42347. /**
  42348. * Set various states to the webGL context
  42349. * @param culling defines backface culling state
  42350. * @param zOffset defines the value to apply to zOffset (0 by default)
  42351. * @param force defines if states must be applied even if cache is up to date
  42352. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  42353. */
  42354. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  42355. /**
  42356. * Set the z offset to apply to current rendering
  42357. * @param value defines the offset to apply
  42358. */
  42359. setZOffset(value: number): void;
  42360. /**
  42361. * Gets the current value of the zOffset
  42362. * @returns the current zOffset state
  42363. */
  42364. getZOffset(): number;
  42365. /**
  42366. * Gets a boolean indicating if depth testing is enabled
  42367. * @returns the current state
  42368. */
  42369. getDepthBuffer(): boolean;
  42370. /**
  42371. * Enable or disable depth buffering
  42372. * @param enable defines the state to set
  42373. */
  42374. setDepthBuffer(enable: boolean): void;
  42375. /**
  42376. * Gets a boolean indicating if depth writing is enabled
  42377. * @returns the current depth writing state
  42378. */
  42379. getDepthWrite(): boolean;
  42380. /**
  42381. * Enable or disable depth writing
  42382. * @param enable defines the state to set
  42383. */
  42384. setDepthWrite(enable: boolean): void;
  42385. /**
  42386. * Gets a boolean indicating if stencil buffer is enabled
  42387. * @returns the current stencil buffer state
  42388. */
  42389. getStencilBuffer(): boolean;
  42390. /**
  42391. * Enable or disable the stencil buffer
  42392. * @param enable defines if the stencil buffer must be enabled or disabled
  42393. */
  42394. setStencilBuffer(enable: boolean): void;
  42395. /**
  42396. * Gets the current stencil mask
  42397. * @returns a number defining the new stencil mask to use
  42398. */
  42399. getStencilMask(): number;
  42400. /**
  42401. * Sets the current stencil mask
  42402. * @param mask defines the new stencil mask to use
  42403. */
  42404. setStencilMask(mask: number): void;
  42405. /**
  42406. * Gets the current stencil function
  42407. * @returns a number defining the stencil function to use
  42408. */
  42409. getStencilFunction(): number;
  42410. /**
  42411. * Gets the current stencil reference value
  42412. * @returns a number defining the stencil reference value to use
  42413. */
  42414. getStencilFunctionReference(): number;
  42415. /**
  42416. * Gets the current stencil mask
  42417. * @returns a number defining the stencil mask to use
  42418. */
  42419. getStencilFunctionMask(): number;
  42420. /**
  42421. * Sets the current stencil function
  42422. * @param stencilFunc defines the new stencil function to use
  42423. */
  42424. setStencilFunction(stencilFunc: number): void;
  42425. /**
  42426. * Sets the current stencil reference
  42427. * @param reference defines the new stencil reference to use
  42428. */
  42429. setStencilFunctionReference(reference: number): void;
  42430. /**
  42431. * Sets the current stencil mask
  42432. * @param mask defines the new stencil mask to use
  42433. */
  42434. setStencilFunctionMask(mask: number): void;
  42435. /**
  42436. * Gets the current stencil operation when stencil fails
  42437. * @returns a number defining stencil operation to use when stencil fails
  42438. */
  42439. getStencilOperationFail(): number;
  42440. /**
  42441. * Gets the current stencil operation when depth fails
  42442. * @returns a number defining stencil operation to use when depth fails
  42443. */
  42444. getStencilOperationDepthFail(): number;
  42445. /**
  42446. * Gets the current stencil operation when stencil passes
  42447. * @returns a number defining stencil operation to use when stencil passes
  42448. */
  42449. getStencilOperationPass(): number;
  42450. /**
  42451. * Sets the stencil operation to use when stencil fails
  42452. * @param operation defines the stencil operation to use when stencil fails
  42453. */
  42454. setStencilOperationFail(operation: number): void;
  42455. /**
  42456. * Sets the stencil operation to use when depth fails
  42457. * @param operation defines the stencil operation to use when depth fails
  42458. */
  42459. setStencilOperationDepthFail(operation: number): void;
  42460. /**
  42461. * Sets the stencil operation to use when stencil passes
  42462. * @param operation defines the stencil operation to use when stencil passes
  42463. */
  42464. setStencilOperationPass(operation: number): void;
  42465. /**
  42466. * Sets a boolean indicating if the dithering state is enabled or disabled
  42467. * @param value defines the dithering state
  42468. */
  42469. setDitheringState(value: boolean): void;
  42470. /**
  42471. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  42472. * @param value defines the rasterizer state
  42473. */
  42474. setRasterizerState(value: boolean): void;
  42475. /**
  42476. * Gets the current depth function
  42477. * @returns a number defining the depth function
  42478. */
  42479. getDepthFunction(): Nullable<number>;
  42480. /**
  42481. * Sets the current depth function
  42482. * @param depthFunc defines the function to use
  42483. */
  42484. setDepthFunction(depthFunc: number): void;
  42485. /**
  42486. * Sets the current depth function to GREATER
  42487. */
  42488. setDepthFunctionToGreater(): void;
  42489. /**
  42490. * Sets the current depth function to GEQUAL
  42491. */
  42492. setDepthFunctionToGreaterOrEqual(): void;
  42493. /**
  42494. * Sets the current depth function to LESS
  42495. */
  42496. setDepthFunctionToLess(): void;
  42497. /**
  42498. * Sets the current depth function to LEQUAL
  42499. */
  42500. setDepthFunctionToLessOrEqual(): void;
  42501. private _cachedStencilBuffer;
  42502. private _cachedStencilFunction;
  42503. private _cachedStencilMask;
  42504. private _cachedStencilOperationPass;
  42505. private _cachedStencilOperationFail;
  42506. private _cachedStencilOperationDepthFail;
  42507. private _cachedStencilReference;
  42508. /**
  42509. * Caches the the state of the stencil buffer
  42510. */
  42511. cacheStencilState(): void;
  42512. /**
  42513. * Restores the state of the stencil buffer
  42514. */
  42515. restoreStencilState(): void;
  42516. /**
  42517. * Directly set the WebGL Viewport
  42518. * @param x defines the x coordinate of the viewport (in screen space)
  42519. * @param y defines the y coordinate of the viewport (in screen space)
  42520. * @param width defines the width of the viewport (in screen space)
  42521. * @param height defines the height of the viewport (in screen space)
  42522. * @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
  42523. */
  42524. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  42525. /**
  42526. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  42527. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  42528. * @param y defines the y-coordinate of the corner of the clear rectangle
  42529. * @param width defines the width of the clear rectangle
  42530. * @param height defines the height of the clear rectangle
  42531. * @param clearColor defines the clear color
  42532. */
  42533. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  42534. /**
  42535. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  42536. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  42537. * @param y defines the y-coordinate of the corner of the clear rectangle
  42538. * @param width defines the width of the clear rectangle
  42539. * @param height defines the height of the clear rectangle
  42540. */
  42541. enableScissor(x: number, y: number, width: number, height: number): void;
  42542. /**
  42543. * Disable previously set scissor test rectangle
  42544. */
  42545. disableScissor(): void;
  42546. protected _reportDrawCall(): void;
  42547. /**
  42548. * Initializes a webVR display and starts listening to display change events
  42549. * The onVRDisplayChangedObservable will be notified upon these changes
  42550. * @returns The onVRDisplayChangedObservable
  42551. */
  42552. initWebVR(): Observable<IDisplayChangedEventArgs>;
  42553. /** @hidden */
  42554. _prepareVRComponent(): void;
  42555. /** @hidden */
  42556. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  42557. /** @hidden */
  42558. _submitVRFrame(): void;
  42559. /**
  42560. * Call this function to leave webVR mode
  42561. * Will do nothing if webVR is not supported or if there is no webVR device
  42562. * @see https://doc.babylonjs.com/how_to/webvr_camera
  42563. */
  42564. disableVR(): void;
  42565. /**
  42566. * Gets a boolean indicating that the system is in VR mode and is presenting
  42567. * @returns true if VR mode is engaged
  42568. */
  42569. isVRPresenting(): boolean;
  42570. /** @hidden */
  42571. _requestVRFrame(): void;
  42572. /** @hidden */
  42573. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  42574. /**
  42575. * Gets the source code of the vertex shader associated with a specific webGL program
  42576. * @param program defines the program to use
  42577. * @returns a string containing the source code of the vertex shader associated with the program
  42578. */
  42579. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  42580. /**
  42581. * Gets the source code of the fragment shader associated with a specific webGL program
  42582. * @param program defines the program to use
  42583. * @returns a string containing the source code of the fragment shader associated with the program
  42584. */
  42585. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  42586. /**
  42587. * Sets a depth stencil texture from a render target to the according uniform.
  42588. * @param channel The texture channel
  42589. * @param uniform The uniform to set
  42590. * @param texture The render target texture containing the depth stencil texture to apply
  42591. * @param name The texture name
  42592. */
  42593. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>, name?: string): void;
  42594. /**
  42595. * Sets a texture to the webGL context from a postprocess
  42596. * @param channel defines the channel to use
  42597. * @param postProcess defines the source postprocess
  42598. * @param name name of the channel
  42599. */
  42600. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>, name: string): void;
  42601. /**
  42602. * Binds the output of the passed in post process to the texture channel specified
  42603. * @param channel The channel the texture should be bound to
  42604. * @param postProcess The post process which's output should be bound
  42605. * @param name name of the channel
  42606. */
  42607. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>, name: string): void;
  42608. protected _rebuildBuffers(): void;
  42609. /** @hidden */
  42610. _renderFrame(): void;
  42611. _renderLoop(): void;
  42612. /** @hidden */
  42613. _renderViews(): boolean;
  42614. /**
  42615. * Toggle full screen mode
  42616. * @param requestPointerLock defines if a pointer lock should be requested from the user
  42617. */
  42618. switchFullscreen(requestPointerLock: boolean): void;
  42619. /**
  42620. * Enters full screen mode
  42621. * @param requestPointerLock defines if a pointer lock should be requested from the user
  42622. */
  42623. enterFullscreen(requestPointerLock: boolean): void;
  42624. /**
  42625. * Exits full screen mode
  42626. */
  42627. exitFullscreen(): void;
  42628. /**
  42629. * Enters Pointerlock mode
  42630. */
  42631. enterPointerlock(): void;
  42632. /**
  42633. * Exits Pointerlock mode
  42634. */
  42635. exitPointerlock(): void;
  42636. /**
  42637. * Begin a new frame
  42638. */
  42639. beginFrame(): void;
  42640. /**
  42641. * End the current frame
  42642. */
  42643. endFrame(): void;
  42644. /**
  42645. * Resize the view according to the canvas' size
  42646. * @param forceSetSize true to force setting the sizes of the underlying canvas
  42647. */
  42648. resize(forceSetSize?: boolean): void;
  42649. /**
  42650. * Force a specific size of the canvas
  42651. * @param width defines the new canvas' width
  42652. * @param height defines the new canvas' height
  42653. * @param forceSetSize true to force setting the sizes of the underlying canvas
  42654. * @returns true if the size was changed
  42655. */
  42656. setSize(width: number, height: number, forceSetSize?: boolean): boolean;
  42657. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  42658. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  42659. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  42660. _releaseTexture(texture: InternalTexture): void;
  42661. /**
  42662. * @hidden
  42663. * Rescales a texture
  42664. * @param source input texutre
  42665. * @param destination destination texture
  42666. * @param scene scene to use to render the resize
  42667. * @param internalFormat format to use when resizing
  42668. * @param onComplete callback to be called when resize has completed
  42669. */
  42670. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  42671. /**
  42672. * Gets the current framerate
  42673. * @returns a number representing the framerate
  42674. */
  42675. getFps(): number;
  42676. /**
  42677. * Gets the time spent between current and previous frame
  42678. * @returns a number representing the delta time in ms
  42679. */
  42680. getDeltaTime(): number;
  42681. private _measureFps;
  42682. /** @hidden */
  42683. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  42684. /**
  42685. * Updates the sample count of a render target texture
  42686. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  42687. * @param texture defines the texture to update
  42688. * @param samples defines the sample count to set
  42689. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  42690. */
  42691. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  42692. /**
  42693. * Updates a depth texture Comparison Mode and Function.
  42694. * If the comparison Function is equal to 0, the mode will be set to none.
  42695. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  42696. * @param texture The texture to set the comparison function for
  42697. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  42698. */
  42699. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  42700. /**
  42701. * Creates a webGL buffer to use with instanciation
  42702. * @param capacity defines the size of the buffer
  42703. * @returns the webGL buffer
  42704. */
  42705. createInstancesBuffer(capacity: number): DataBuffer;
  42706. /**
  42707. * Delete a webGL buffer used with instanciation
  42708. * @param buffer defines the webGL buffer to delete
  42709. */
  42710. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  42711. private _clientWaitAsync;
  42712. /** @hidden */
  42713. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Nullable<Promise<ArrayBufferView>>;
  42714. dispose(): void;
  42715. private _disableTouchAction;
  42716. /**
  42717. * Display the loading screen
  42718. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  42719. */
  42720. displayLoadingUI(): void;
  42721. /**
  42722. * Hide the loading screen
  42723. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  42724. */
  42725. hideLoadingUI(): void;
  42726. /**
  42727. * Gets the current loading screen object
  42728. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  42729. */
  42730. get loadingScreen(): ILoadingScreen;
  42731. /**
  42732. * Sets the current loading screen object
  42733. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  42734. */
  42735. set loadingScreen(loadingScreen: ILoadingScreen);
  42736. /**
  42737. * Sets the current loading screen text
  42738. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  42739. */
  42740. set loadingUIText(text: string);
  42741. /**
  42742. * Sets the current loading screen background color
  42743. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  42744. */
  42745. set loadingUIBackgroundColor(color: string);
  42746. /** Pointerlock and fullscreen */
  42747. /**
  42748. * Ask the browser to promote the current element to pointerlock mode
  42749. * @param element defines the DOM element to promote
  42750. */
  42751. static _RequestPointerlock(element: HTMLElement): void;
  42752. /**
  42753. * Asks the browser to exit pointerlock mode
  42754. */
  42755. static _ExitPointerlock(): void;
  42756. /**
  42757. * Ask the browser to promote the current element to fullscreen rendering mode
  42758. * @param element defines the DOM element to promote
  42759. */
  42760. static _RequestFullscreen(element: HTMLElement): void;
  42761. /**
  42762. * Asks the browser to exit fullscreen mode
  42763. */
  42764. static _ExitFullscreen(): void;
  42765. }
  42766. }
  42767. declare module BABYLON {
  42768. /**
  42769. * The engine store class is responsible to hold all the instances of Engine and Scene created
  42770. * during the life time of the application.
  42771. */
  42772. export class EngineStore {
  42773. /** Gets the list of created engines */
  42774. static Instances: Engine[];
  42775. /** @hidden */
  42776. static _LastCreatedScene: Nullable<Scene>;
  42777. /**
  42778. * Gets the latest created engine
  42779. */
  42780. static get LastCreatedEngine(): Nullable<Engine>;
  42781. /**
  42782. * Gets the latest created scene
  42783. */
  42784. static get LastCreatedScene(): Nullable<Scene>;
  42785. /**
  42786. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  42787. * @ignorenaming
  42788. */
  42789. static UseFallbackTexture: boolean;
  42790. /**
  42791. * Texture content used if a texture cannot loaded
  42792. * @ignorenaming
  42793. */
  42794. static FallbackTexture: string;
  42795. }
  42796. }
  42797. declare module BABYLON {
  42798. /**
  42799. * Helper class that provides a small promise polyfill
  42800. */
  42801. export class PromisePolyfill {
  42802. /**
  42803. * Static function used to check if the polyfill is required
  42804. * If this is the case then the function will inject the polyfill to window.Promise
  42805. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  42806. */
  42807. static Apply(force?: boolean): void;
  42808. }
  42809. }
  42810. declare module BABYLON {
  42811. /**
  42812. * Interface for screenshot methods with describe argument called `size` as object with options
  42813. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  42814. */
  42815. export interface IScreenshotSize {
  42816. /**
  42817. * number in pixels for canvas height
  42818. */
  42819. height?: number;
  42820. /**
  42821. * multiplier allowing render at a higher or lower resolution
  42822. * If value is defined then height and width will be ignored and taken from camera
  42823. */
  42824. precision?: number;
  42825. /**
  42826. * number in pixels for canvas width
  42827. */
  42828. width?: number;
  42829. }
  42830. }
  42831. declare module BABYLON {
  42832. interface IColor4Like {
  42833. r: float;
  42834. g: float;
  42835. b: float;
  42836. a: float;
  42837. }
  42838. /**
  42839. * Class containing a set of static utilities functions
  42840. */
  42841. export class Tools {
  42842. /**
  42843. * Gets or sets the base URL to use to load assets
  42844. */
  42845. static get BaseUrl(): string;
  42846. static set BaseUrl(value: string);
  42847. /**
  42848. * Enable/Disable Custom HTTP Request Headers globally.
  42849. * default = false
  42850. * @see CustomRequestHeaders
  42851. */
  42852. static UseCustomRequestHeaders: boolean;
  42853. /**
  42854. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  42855. * i.e. when loading files, where the server/service expects an Authorization header
  42856. */
  42857. static CustomRequestHeaders: {
  42858. [key: string]: string;
  42859. };
  42860. /**
  42861. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  42862. */
  42863. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  42864. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  42865. /**
  42866. * Default behaviour for cors in the application.
  42867. * It can be a string if the expected behavior is identical in the entire app.
  42868. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  42869. */
  42870. static get CorsBehavior(): string | ((url: string | string[]) => string);
  42871. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  42872. /**
  42873. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  42874. * @ignorenaming
  42875. */
  42876. static get UseFallbackTexture(): boolean;
  42877. static set UseFallbackTexture(value: boolean);
  42878. /**
  42879. * Use this object to register external classes like custom textures or material
  42880. * to allow the laoders to instantiate them
  42881. */
  42882. static get RegisteredExternalClasses(): {
  42883. [key: string]: Object;
  42884. };
  42885. static set RegisteredExternalClasses(classes: {
  42886. [key: string]: Object;
  42887. });
  42888. /**
  42889. * Texture content used if a texture cannot loaded
  42890. * @ignorenaming
  42891. */
  42892. static get fallbackTexture(): string;
  42893. static set fallbackTexture(value: string);
  42894. /**
  42895. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  42896. * @param u defines the coordinate on X axis
  42897. * @param v defines the coordinate on Y axis
  42898. * @param width defines the width of the source data
  42899. * @param height defines the height of the source data
  42900. * @param pixels defines the source byte array
  42901. * @param color defines the output color
  42902. */
  42903. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  42904. /**
  42905. * Interpolates between a and b via alpha
  42906. * @param a The lower value (returned when alpha = 0)
  42907. * @param b The upper value (returned when alpha = 1)
  42908. * @param alpha The interpolation-factor
  42909. * @return The mixed value
  42910. */
  42911. static Mix(a: number, b: number, alpha: number): number;
  42912. /**
  42913. * Tries to instantiate a new object from a given class name
  42914. * @param className defines the class name to instantiate
  42915. * @returns the new object or null if the system was not able to do the instantiation
  42916. */
  42917. static Instantiate(className: string): any;
  42918. /**
  42919. * Provides a slice function that will work even on IE
  42920. * @param data defines the array to slice
  42921. * @param start defines the start of the data (optional)
  42922. * @param end defines the end of the data (optional)
  42923. * @returns the new sliced array
  42924. */
  42925. static Slice<T>(data: T, start?: number, end?: number): T;
  42926. /**
  42927. * Provides a slice function that will work even on IE
  42928. * The difference between this and Slice is that this will force-convert to array
  42929. * @param data defines the array to slice
  42930. * @param start defines the start of the data (optional)
  42931. * @param end defines the end of the data (optional)
  42932. * @returns the new sliced array
  42933. */
  42934. static SliceToArray<T, P>(data: T, start?: number, end?: number): Array<P>;
  42935. /**
  42936. * Polyfill for setImmediate
  42937. * @param action defines the action to execute after the current execution block
  42938. */
  42939. static SetImmediate(action: () => void): void;
  42940. /**
  42941. * Function indicating if a number is an exponent of 2
  42942. * @param value defines the value to test
  42943. * @returns true if the value is an exponent of 2
  42944. */
  42945. static IsExponentOfTwo(value: number): boolean;
  42946. private static _tmpFloatArray;
  42947. /**
  42948. * Returns the nearest 32-bit single precision float representation of a Number
  42949. * @param value A Number. If the parameter is of a different type, it will get converted
  42950. * to a number or to NaN if it cannot be converted
  42951. * @returns number
  42952. */
  42953. static FloatRound(value: number): number;
  42954. /**
  42955. * Extracts the filename from a path
  42956. * @param path defines the path to use
  42957. * @returns the filename
  42958. */
  42959. static GetFilename(path: string): string;
  42960. /**
  42961. * Extracts the "folder" part of a path (everything before the filename).
  42962. * @param uri The URI to extract the info from
  42963. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  42964. * @returns The "folder" part of the path
  42965. */
  42966. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  42967. /**
  42968. * Extracts text content from a DOM element hierarchy
  42969. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  42970. */
  42971. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  42972. /**
  42973. * Convert an angle in radians to degrees
  42974. * @param angle defines the angle to convert
  42975. * @returns the angle in degrees
  42976. */
  42977. static ToDegrees(angle: number): number;
  42978. /**
  42979. * Convert an angle in degrees to radians
  42980. * @param angle defines the angle to convert
  42981. * @returns the angle in radians
  42982. */
  42983. static ToRadians(angle: number): number;
  42984. /**
  42985. * Returns an array if obj is not an array
  42986. * @param obj defines the object to evaluate as an array
  42987. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  42988. * @returns either obj directly if obj is an array or a new array containing obj
  42989. */
  42990. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  42991. /**
  42992. * Gets the pointer prefix to use
  42993. * @param engine defines the engine we are finding the prefix for
  42994. * @returns "pointer" if touch is enabled. Else returns "mouse"
  42995. */
  42996. static GetPointerPrefix(engine: Engine): string;
  42997. /**
  42998. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  42999. * @param url define the url we are trying
  43000. * @param element define the dom element where to configure the cors policy
  43001. */
  43002. static SetCorsBehavior(url: string | string[], element: {
  43003. crossOrigin: string | null;
  43004. }): void;
  43005. /**
  43006. * Removes unwanted characters from an url
  43007. * @param url defines the url to clean
  43008. * @returns the cleaned url
  43009. */
  43010. static CleanUrl(url: string): string;
  43011. /**
  43012. * Gets or sets a function used to pre-process url before using them to load assets
  43013. */
  43014. static get PreprocessUrl(): (url: string) => string;
  43015. static set PreprocessUrl(processor: (url: string) => string);
  43016. /**
  43017. * Loads an image as an HTMLImageElement.
  43018. * @param input url string, ArrayBuffer, or Blob to load
  43019. * @param onLoad callback called when the image successfully loads
  43020. * @param onError callback called when the image fails to load
  43021. * @param offlineProvider offline provider for caching
  43022. * @param mimeType optional mime type
  43023. * @returns the HTMLImageElement of the loaded image
  43024. */
  43025. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  43026. /**
  43027. * Loads a file from a url
  43028. * @param url url string, ArrayBuffer, or Blob to load
  43029. * @param onSuccess callback called when the file successfully loads
  43030. * @param onProgress callback called while file is loading (if the server supports this mode)
  43031. * @param offlineProvider defines the offline provider for caching
  43032. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  43033. * @param onError callback called when the file fails to load
  43034. * @returns a file request object
  43035. */
  43036. 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;
  43037. /**
  43038. * Loads a file from a url
  43039. * @param url the file url to load
  43040. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  43041. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  43042. */
  43043. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  43044. /**
  43045. * Load a script (identified by an url). When the url returns, the
  43046. * content of this file is added into a new script element, attached to the DOM (body element)
  43047. * @param scriptUrl defines the url of the script to laod
  43048. * @param onSuccess defines the callback called when the script is loaded
  43049. * @param onError defines the callback to call if an error occurs
  43050. * @param scriptId defines the id of the script element
  43051. */
  43052. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  43053. /**
  43054. * Load an asynchronous script (identified by an url). When the url returns, the
  43055. * content of this file is added into a new script element, attached to the DOM (body element)
  43056. * @param scriptUrl defines the url of the script to laod
  43057. * @param scriptId defines the id of the script element
  43058. * @returns a promise request object
  43059. */
  43060. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  43061. /**
  43062. * Loads a file from a blob
  43063. * @param fileToLoad defines the blob to use
  43064. * @param callback defines the callback to call when data is loaded
  43065. * @param progressCallback defines the callback to call during loading process
  43066. * @returns a file request object
  43067. */
  43068. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  43069. /**
  43070. * Reads a file from a File object
  43071. * @param file defines the file to load
  43072. * @param onSuccess defines the callback to call when data is loaded
  43073. * @param onProgress defines the callback to call during loading process
  43074. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  43075. * @param onError defines the callback to call when an error occurs
  43076. * @returns a file request object
  43077. */
  43078. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  43079. /**
  43080. * Creates a data url from a given string content
  43081. * @param content defines the content to convert
  43082. * @returns the new data url link
  43083. */
  43084. static FileAsURL(content: string): string;
  43085. /**
  43086. * Format the given number to a specific decimal format
  43087. * @param value defines the number to format
  43088. * @param decimals defines the number of decimals to use
  43089. * @returns the formatted string
  43090. */
  43091. static Format(value: number, decimals?: number): string;
  43092. /**
  43093. * Tries to copy an object by duplicating every property
  43094. * @param source defines the source object
  43095. * @param destination defines the target object
  43096. * @param doNotCopyList defines a list of properties to avoid
  43097. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  43098. */
  43099. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  43100. /**
  43101. * Gets a boolean indicating if the given object has no own property
  43102. * @param obj defines the object to test
  43103. * @returns true if object has no own property
  43104. */
  43105. static IsEmpty(obj: any): boolean;
  43106. /**
  43107. * Function used to register events at window level
  43108. * @param windowElement defines the Window object to use
  43109. * @param events defines the events to register
  43110. */
  43111. static RegisterTopRootEvents(windowElement: Window, events: {
  43112. name: string;
  43113. handler: Nullable<(e: FocusEvent) => any>;
  43114. }[]): void;
  43115. /**
  43116. * Function used to unregister events from window level
  43117. * @param windowElement defines the Window object to use
  43118. * @param events defines the events to unregister
  43119. */
  43120. static UnregisterTopRootEvents(windowElement: Window, events: {
  43121. name: string;
  43122. handler: Nullable<(e: FocusEvent) => any>;
  43123. }[]): void;
  43124. /**
  43125. * @ignore
  43126. */
  43127. static _ScreenshotCanvas: HTMLCanvasElement;
  43128. /**
  43129. * Dumps the current bound framebuffer
  43130. * @param width defines the rendering width
  43131. * @param height defines the rendering height
  43132. * @param engine defines the hosting engine
  43133. * @param successCallback defines the callback triggered once the data are available
  43134. * @param mimeType defines the mime type of the result
  43135. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  43136. * @return a void promise
  43137. */
  43138. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): Promise<void>;
  43139. /**
  43140. * Dumps an array buffer
  43141. * @param width defines the rendering width
  43142. * @param height defines the rendering height
  43143. * @param data the data array
  43144. * @param successCallback defines the callback triggered once the data are available
  43145. * @param mimeType defines the mime type of the result
  43146. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  43147. * @param invertY true to invert the picture in the Y dimension
  43148. * @param toArrayBuffer true to convert the data to an ArrayBuffer (encoded as `mimeType`) instead of a base64 string
  43149. */
  43150. static DumpData(width: number, height: number, data: ArrayBufferView, successCallback?: (data: string | ArrayBuffer) => void, mimeType?: string, fileName?: string, invertY?: boolean, toArrayBuffer?: boolean): void;
  43151. /**
  43152. * Dumps an array buffer
  43153. * @param width defines the rendering width
  43154. * @param height defines the rendering height
  43155. * @param data the data array
  43156. * @param successCallback defines the callback triggered once the data are available
  43157. * @param mimeType defines the mime type of the result
  43158. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  43159. * @param invertY true to invert the picture in the Y dimension
  43160. * @param toArrayBuffer true to convert the data to an ArrayBuffer (encoded as `mimeType`) instead of a base64 string
  43161. * @return a promise that resolve to the final data
  43162. */
  43163. static DumpDataAsync(width: number, height: number, data: ArrayBufferView, mimeType?: string, fileName?: string, invertY?: boolean, toArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  43164. /**
  43165. * Converts the canvas data to blob.
  43166. * This acts as a polyfill for browsers not supporting the to blob function.
  43167. * @param canvas Defines the canvas to extract the data from
  43168. * @param successCallback Defines the callback triggered once the data are available
  43169. * @param mimeType Defines the mime type of the result
  43170. */
  43171. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  43172. /**
  43173. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  43174. * @param successCallback defines the callback triggered once the data are available
  43175. * @param mimeType defines the mime type of the result
  43176. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  43177. * @param canvas canvas to get the data from. If not provided, use the default screenshot canvas
  43178. */
  43179. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string, canvas?: HTMLCanvasElement): void;
  43180. /**
  43181. * Downloads a blob in the browser
  43182. * @param blob defines the blob to download
  43183. * @param fileName defines the name of the downloaded file
  43184. */
  43185. static Download(blob: Blob, fileName: string): void;
  43186. /**
  43187. * Will return the right value of the noPreventDefault variable
  43188. * Needed to keep backwards compatibility to the old API.
  43189. *
  43190. * @param args arguments passed to the attachControl function
  43191. * @returns the correct value for noPreventDefault
  43192. */
  43193. static BackCompatCameraNoPreventDefault(args: IArguments): boolean;
  43194. /**
  43195. * Captures a screenshot of the current rendering
  43196. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  43197. * @param engine defines the rendering engine
  43198. * @param camera defines the source camera
  43199. * @param size This parameter can be set to a single number or to an object with the
  43200. * following (optional) properties: precision, width, height. If a single number is passed,
  43201. * it will be used for both width and height. If an object is passed, the screenshot size
  43202. * will be derived from the parameters. The precision property is a multiplier allowing
  43203. * rendering at a higher or lower resolution
  43204. * @param successCallback defines the callback receives a single parameter which contains the
  43205. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  43206. * src parameter of an <img> to display it
  43207. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  43208. * Check your browser for supported MIME types
  43209. */
  43210. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  43211. /**
  43212. * Captures a screenshot of the current rendering
  43213. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  43214. * @param engine defines the rendering engine
  43215. * @param camera defines the source camera
  43216. * @param size This parameter can be set to a single number or to an object with the
  43217. * following (optional) properties: precision, width, height. If a single number is passed,
  43218. * it will be used for both width and height. If an object is passed, the screenshot size
  43219. * will be derived from the parameters. The precision property is a multiplier allowing
  43220. * rendering at a higher or lower resolution
  43221. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  43222. * Check your browser for supported MIME types
  43223. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  43224. * to the src parameter of an <img> to display it
  43225. */
  43226. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  43227. /**
  43228. * Generates an image screenshot from the specified camera.
  43229. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  43230. * @param engine The engine to use for rendering
  43231. * @param camera The camera to use for rendering
  43232. * @param size This parameter can be set to a single number or to an object with the
  43233. * following (optional) properties: precision, width, height. If a single number is passed,
  43234. * it will be used for both width and height. If an object is passed, the screenshot size
  43235. * will be derived from the parameters. The precision property is a multiplier allowing
  43236. * rendering at a higher or lower resolution
  43237. * @param successCallback The callback receives a single parameter which contains the
  43238. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  43239. * src parameter of an <img> to display it
  43240. * @param mimeType The MIME type of the screenshot image (default: image/png).
  43241. * Check your browser for supported MIME types
  43242. * @param samples Texture samples (default: 1)
  43243. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  43244. * @param fileName A name for for the downloaded file.
  43245. */
  43246. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  43247. /**
  43248. * Generates an image screenshot from the specified camera.
  43249. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  43250. * @param engine The engine to use for rendering
  43251. * @param camera The camera to use for rendering
  43252. * @param size This parameter can be set to a single number or to an object with the
  43253. * following (optional) properties: precision, width, height. If a single number is passed,
  43254. * it will be used for both width and height. If an object is passed, the screenshot size
  43255. * will be derived from the parameters. The precision property is a multiplier allowing
  43256. * rendering at a higher or lower resolution
  43257. * @param mimeType The MIME type of the screenshot image (default: image/png).
  43258. * Check your browser for supported MIME types
  43259. * @param samples Texture samples (default: 1)
  43260. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  43261. * @param fileName A name for for the downloaded file.
  43262. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  43263. * to the src parameter of an <img> to display it
  43264. */
  43265. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  43266. /**
  43267. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  43268. * Be aware Math.random() could cause collisions, but:
  43269. * "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"
  43270. * @returns a pseudo random id
  43271. */
  43272. static RandomId(): string;
  43273. /**
  43274. * Test if the given uri is a base64 string
  43275. * @param uri The uri to test
  43276. * @return True if the uri is a base64 string or false otherwise
  43277. */
  43278. static IsBase64(uri: string): boolean;
  43279. /**
  43280. * Decode the given base64 uri.
  43281. * @param uri The uri to decode
  43282. * @return The decoded base64 data.
  43283. */
  43284. static DecodeBase64(uri: string): ArrayBuffer;
  43285. /**
  43286. * Gets the absolute url.
  43287. * @param url the input url
  43288. * @return the absolute url
  43289. */
  43290. static GetAbsoluteUrl(url: string): string;
  43291. /**
  43292. * No log
  43293. */
  43294. static readonly NoneLogLevel: number;
  43295. /**
  43296. * Only message logs
  43297. */
  43298. static readonly MessageLogLevel: number;
  43299. /**
  43300. * Only warning logs
  43301. */
  43302. static readonly WarningLogLevel: number;
  43303. /**
  43304. * Only error logs
  43305. */
  43306. static readonly ErrorLogLevel: number;
  43307. /**
  43308. * All logs
  43309. */
  43310. static readonly AllLogLevel: number;
  43311. /**
  43312. * Gets a value indicating the number of loading errors
  43313. * @ignorenaming
  43314. */
  43315. static get errorsCount(): number;
  43316. /**
  43317. * Callback called when a new log is added
  43318. */
  43319. static OnNewCacheEntry: (entry: string) => void;
  43320. /**
  43321. * Log a message to the console
  43322. * @param message defines the message to log
  43323. */
  43324. static Log(message: string): void;
  43325. /**
  43326. * Write a warning message to the console
  43327. * @param message defines the message to log
  43328. */
  43329. static Warn(message: string): void;
  43330. /**
  43331. * Write an error message to the console
  43332. * @param message defines the message to log
  43333. */
  43334. static Error(message: string): void;
  43335. /**
  43336. * Gets current log cache (list of logs)
  43337. */
  43338. static get LogCache(): string;
  43339. /**
  43340. * Clears the log cache
  43341. */
  43342. static ClearLogCache(): void;
  43343. /**
  43344. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  43345. */
  43346. static set LogLevels(level: number);
  43347. /**
  43348. * Checks if the window object exists
  43349. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  43350. */
  43351. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  43352. /**
  43353. * No performance log
  43354. */
  43355. static readonly PerformanceNoneLogLevel: number;
  43356. /**
  43357. * Use user marks to log performance
  43358. */
  43359. static readonly PerformanceUserMarkLogLevel: number;
  43360. /**
  43361. * Log performance to the console
  43362. */
  43363. static readonly PerformanceConsoleLogLevel: number;
  43364. private static _performance;
  43365. /**
  43366. * Sets the current performance log level
  43367. */
  43368. static set PerformanceLogLevel(level: number);
  43369. private static _StartPerformanceCounterDisabled;
  43370. private static _EndPerformanceCounterDisabled;
  43371. private static _StartUserMark;
  43372. private static _EndUserMark;
  43373. private static _StartPerformanceConsole;
  43374. private static _EndPerformanceConsole;
  43375. /**
  43376. * Starts a performance counter
  43377. */
  43378. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  43379. /**
  43380. * Ends a specific performance coutner
  43381. */
  43382. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  43383. /**
  43384. * Gets either window.performance.now() if supported or Date.now() else
  43385. */
  43386. static get Now(): number;
  43387. /**
  43388. * This method will return the name of the class used to create the instance of the given object.
  43389. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  43390. * @param object the object to get the class name from
  43391. * @param isType defines if the object is actually a type
  43392. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  43393. */
  43394. static GetClassName(object: any, isType?: boolean): string;
  43395. /**
  43396. * Gets the first element of an array satisfying a given predicate
  43397. * @param array defines the array to browse
  43398. * @param predicate defines the predicate to use
  43399. * @returns null if not found or the element
  43400. */
  43401. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  43402. /**
  43403. * This method will return the name of the full name of the class, including its owning module (if any).
  43404. * 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).
  43405. * @param object the object to get the class name from
  43406. * @param isType defines if the object is actually a type
  43407. * @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.
  43408. * @ignorenaming
  43409. */
  43410. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  43411. /**
  43412. * Returns a promise that resolves after the given amount of time.
  43413. * @param delay Number of milliseconds to delay
  43414. * @returns Promise that resolves after the given amount of time
  43415. */
  43416. static DelayAsync(delay: number): Promise<void>;
  43417. /**
  43418. * Utility function to detect if the current user agent is Safari
  43419. * @returns whether or not the current user agent is safari
  43420. */
  43421. static IsSafari(): boolean;
  43422. }
  43423. /**
  43424. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  43425. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  43426. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  43427. * @param name The name of the class, case should be preserved
  43428. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  43429. */
  43430. export function className(name: string, module?: string): (target: Object) => void;
  43431. /**
  43432. * An implementation of a loop for asynchronous functions.
  43433. */
  43434. export class AsyncLoop {
  43435. /**
  43436. * Defines the number of iterations for the loop
  43437. */
  43438. iterations: number;
  43439. /**
  43440. * Defines the current index of the loop.
  43441. */
  43442. index: number;
  43443. private _done;
  43444. private _fn;
  43445. private _successCallback;
  43446. /**
  43447. * Constructor.
  43448. * @param iterations the number of iterations.
  43449. * @param func the function to run each iteration
  43450. * @param successCallback the callback that will be called upon succesful execution
  43451. * @param offset starting offset.
  43452. */
  43453. constructor(
  43454. /**
  43455. * Defines the number of iterations for the loop
  43456. */
  43457. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  43458. /**
  43459. * Execute the next iteration. Must be called after the last iteration was finished.
  43460. */
  43461. executeNext(): void;
  43462. /**
  43463. * Break the loop and run the success callback.
  43464. */
  43465. breakLoop(): void;
  43466. /**
  43467. * Create and run an async loop.
  43468. * @param iterations the number of iterations.
  43469. * @param fn the function to run each iteration
  43470. * @param successCallback the callback that will be called upon succesful execution
  43471. * @param offset starting offset.
  43472. * @returns the created async loop object
  43473. */
  43474. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  43475. /**
  43476. * A for-loop that will run a given number of iterations synchronous and the rest async.
  43477. * @param iterations total number of iterations
  43478. * @param syncedIterations number of synchronous iterations in each async iteration.
  43479. * @param fn the function to call each iteration.
  43480. * @param callback a success call back that will be called when iterating stops.
  43481. * @param breakFunction a break condition (optional)
  43482. * @param timeout timeout settings for the setTimeout function. default - 0.
  43483. * @returns the created async loop object
  43484. */
  43485. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  43486. }
  43487. }
  43488. declare module BABYLON {
  43489. /**
  43490. * This class implement a typical dictionary using a string as key and the generic type T as value.
  43491. * The underlying implementation relies on an associative array to ensure the best performances.
  43492. * The value can be anything including 'null' but except 'undefined'
  43493. */
  43494. export class StringDictionary<T> {
  43495. /**
  43496. * This will clear this dictionary and copy the content from the 'source' one.
  43497. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  43498. * @param source the dictionary to take the content from and copy to this dictionary
  43499. */
  43500. copyFrom(source: StringDictionary<T>): void;
  43501. /**
  43502. * Get a value based from its key
  43503. * @param key the given key to get the matching value from
  43504. * @return the value if found, otherwise undefined is returned
  43505. */
  43506. get(key: string): T | undefined;
  43507. /**
  43508. * Get a value from its key or add it if it doesn't exist.
  43509. * This method will ensure you that a given key/data will be present in the dictionary.
  43510. * @param key the given key to get the matching value from
  43511. * @param factory the factory that will create the value if the key is not present in the dictionary.
  43512. * The factory will only be invoked if there's no data for the given key.
  43513. * @return the value corresponding to the key.
  43514. */
  43515. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  43516. /**
  43517. * Get a value from its key if present in the dictionary otherwise add it
  43518. * @param key the key to get the value from
  43519. * @param val if there's no such key/value pair in the dictionary add it with this value
  43520. * @return the value corresponding to the key
  43521. */
  43522. getOrAdd(key: string, val: T): T;
  43523. /**
  43524. * Check if there's a given key in the dictionary
  43525. * @param key the key to check for
  43526. * @return true if the key is present, false otherwise
  43527. */
  43528. contains(key: string): boolean;
  43529. /**
  43530. * Add a new key and its corresponding value
  43531. * @param key the key to add
  43532. * @param value the value corresponding to the key
  43533. * @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
  43534. */
  43535. add(key: string, value: T): boolean;
  43536. /**
  43537. * Update a specific value associated to a key
  43538. * @param key defines the key to use
  43539. * @param value defines the value to store
  43540. * @returns true if the value was updated (or false if the key was not found)
  43541. */
  43542. set(key: string, value: T): boolean;
  43543. /**
  43544. * Get the element of the given key and remove it from the dictionary
  43545. * @param key defines the key to search
  43546. * @returns the value associated with the key or null if not found
  43547. */
  43548. getAndRemove(key: string): Nullable<T>;
  43549. /**
  43550. * Remove a key/value from the dictionary.
  43551. * @param key the key to remove
  43552. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  43553. */
  43554. remove(key: string): boolean;
  43555. /**
  43556. * Clear the whole content of the dictionary
  43557. */
  43558. clear(): void;
  43559. /**
  43560. * Gets the current count
  43561. */
  43562. get count(): number;
  43563. /**
  43564. * Execute a callback on each key/val of the dictionary.
  43565. * Note that you can remove any element in this dictionary in the callback implementation
  43566. * @param callback the callback to execute on a given key/value pair
  43567. */
  43568. forEach(callback: (key: string, val: T) => void): void;
  43569. /**
  43570. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  43571. * If the callback returns null or undefined the method will iterate to the next key/value pair
  43572. * Note that you can remove any element in this dictionary in the callback implementation
  43573. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  43574. * @returns the first item
  43575. */
  43576. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  43577. private _count;
  43578. private _data;
  43579. }
  43580. }
  43581. declare module BABYLON {
  43582. /** @hidden */
  43583. export interface ICollisionCoordinator {
  43584. createCollider(): Collider;
  43585. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  43586. init(scene: Scene): void;
  43587. }
  43588. /** @hidden */
  43589. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  43590. private _scene;
  43591. private _scaledPosition;
  43592. private _scaledVelocity;
  43593. private _finalPosition;
  43594. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  43595. createCollider(): Collider;
  43596. init(scene: Scene): void;
  43597. private _collideWithWorld;
  43598. }
  43599. }
  43600. declare module BABYLON {
  43601. /**
  43602. * Class used to manage all inputs for the scene.
  43603. */
  43604. export class InputManager {
  43605. /** The distance in pixel that you have to move to prevent some events */
  43606. static DragMovementThreshold: number;
  43607. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  43608. static LongPressDelay: number;
  43609. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  43610. static DoubleClickDelay: number;
  43611. /** If you need to check double click without raising a single click at first click, enable this flag */
  43612. static ExclusiveDoubleClickMode: boolean;
  43613. /** 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. */
  43614. private _alreadyAttached;
  43615. private _alreadyAttachedTo;
  43616. private _wheelEventName;
  43617. private _onPointerMove;
  43618. private _onPointerDown;
  43619. private _onPointerUp;
  43620. private _initClickEvent;
  43621. private _initActionManager;
  43622. private _delayedSimpleClick;
  43623. private _delayedSimpleClickTimeout;
  43624. private _previousDelayedSimpleClickTimeout;
  43625. private _meshPickProceed;
  43626. private _previousButtonPressed;
  43627. private _currentPickResult;
  43628. private _previousPickResult;
  43629. private _totalPointersPressed;
  43630. private _doubleClickOccured;
  43631. private _pointerOverMesh;
  43632. private _pickedDownMesh;
  43633. private _pickedUpMesh;
  43634. private _pointerX;
  43635. private _pointerY;
  43636. private _unTranslatedPointerX;
  43637. private _unTranslatedPointerY;
  43638. private _startingPointerPosition;
  43639. private _previousStartingPointerPosition;
  43640. private _startingPointerTime;
  43641. private _previousStartingPointerTime;
  43642. private _pointerCaptures;
  43643. private _meshUnderPointerId;
  43644. private _onKeyDown;
  43645. private _onKeyUp;
  43646. private _keyboardIsAttached;
  43647. private _onCanvasFocusObserver;
  43648. private _onCanvasBlurObserver;
  43649. private _scene;
  43650. /**
  43651. * Creates a new InputManager
  43652. * @param scene defines the hosting scene
  43653. */
  43654. constructor(scene: Scene);
  43655. /**
  43656. * Gets the mesh that is currently under the pointer
  43657. */
  43658. get meshUnderPointer(): Nullable<AbstractMesh>;
  43659. /**
  43660. * When using more than one pointer (for example in XR) you can get the mesh under the specific pointer
  43661. * @param pointerId the pointer id to use
  43662. * @returns The mesh under this pointer id or null if not found
  43663. */
  43664. getMeshUnderPointerByPointerId(pointerId: number): Nullable<AbstractMesh>;
  43665. /**
  43666. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  43667. */
  43668. get unTranslatedPointer(): Vector2;
  43669. /**
  43670. * Gets or sets the current on-screen X position of the pointer
  43671. */
  43672. get pointerX(): number;
  43673. set pointerX(value: number);
  43674. /**
  43675. * Gets or sets the current on-screen Y position of the pointer
  43676. */
  43677. get pointerY(): number;
  43678. set pointerY(value: number);
  43679. private _updatePointerPosition;
  43680. private _processPointerMove;
  43681. private _setRayOnPointerInfo;
  43682. private _checkPrePointerObservable;
  43683. /**
  43684. * Use this method to simulate a pointer move on a mesh
  43685. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  43686. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  43687. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  43688. */
  43689. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  43690. /**
  43691. * Use this method to simulate a pointer down on a mesh
  43692. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  43693. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  43694. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  43695. */
  43696. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  43697. private _processPointerDown;
  43698. /** @hidden */
  43699. _isPointerSwiping(): boolean;
  43700. /**
  43701. * Use this method to simulate a pointer up on a mesh
  43702. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  43703. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  43704. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  43705. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  43706. */
  43707. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  43708. private _processPointerUp;
  43709. /**
  43710. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  43711. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  43712. * @returns true if the pointer was captured
  43713. */
  43714. isPointerCaptured(pointerId?: number): boolean;
  43715. /**
  43716. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  43717. * @param attachUp defines if you want to attach events to pointerup
  43718. * @param attachDown defines if you want to attach events to pointerdown
  43719. * @param attachMove defines if you want to attach events to pointermove
  43720. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  43721. */
  43722. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  43723. /**
  43724. * Detaches all event handlers
  43725. */
  43726. detachControl(): void;
  43727. /**
  43728. * Force the value of meshUnderPointer
  43729. * @param mesh defines the mesh to use
  43730. * @param pointerId optional pointer id when using more than one pointer. Defaults to 0
  43731. */
  43732. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  43733. /**
  43734. * Gets the mesh under the pointer
  43735. * @returns a Mesh or null if no mesh is under the pointer
  43736. */
  43737. getPointerOverMesh(): Nullable<AbstractMesh>;
  43738. }
  43739. }
  43740. declare module BABYLON {
  43741. /**
  43742. * This class defines the direct association between an animation and a target
  43743. */
  43744. export class TargetedAnimation {
  43745. /**
  43746. * Animation to perform
  43747. */
  43748. animation: Animation;
  43749. /**
  43750. * Target to animate
  43751. */
  43752. target: any;
  43753. /**
  43754. * Returns the string "TargetedAnimation"
  43755. * @returns "TargetedAnimation"
  43756. */
  43757. getClassName(): string;
  43758. /**
  43759. * Serialize the object
  43760. * @returns the JSON object representing the current entity
  43761. */
  43762. serialize(): any;
  43763. }
  43764. /**
  43765. * Use this class to create coordinated animations on multiple targets
  43766. */
  43767. export class AnimationGroup implements IDisposable {
  43768. /** The name of the animation group */
  43769. name: string;
  43770. private _scene;
  43771. private _targetedAnimations;
  43772. private _animatables;
  43773. private _from;
  43774. private _to;
  43775. private _isStarted;
  43776. private _isPaused;
  43777. private _speedRatio;
  43778. private _loopAnimation;
  43779. private _isAdditive;
  43780. /**
  43781. * Gets or sets the unique id of the node
  43782. */
  43783. uniqueId: number;
  43784. /**
  43785. * This observable will notify when one animation have ended
  43786. */
  43787. onAnimationEndObservable: Observable<TargetedAnimation>;
  43788. /**
  43789. * Observer raised when one animation loops
  43790. */
  43791. onAnimationLoopObservable: Observable<TargetedAnimation>;
  43792. /**
  43793. * Observer raised when all animations have looped
  43794. */
  43795. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  43796. /**
  43797. * This observable will notify when all animations have ended.
  43798. */
  43799. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  43800. /**
  43801. * This observable will notify when all animations have paused.
  43802. */
  43803. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  43804. /**
  43805. * This observable will notify when all animations are playing.
  43806. */
  43807. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  43808. /**
  43809. * Gets the first frame
  43810. */
  43811. get from(): number;
  43812. /**
  43813. * Gets the last frame
  43814. */
  43815. get to(): number;
  43816. /**
  43817. * Define if the animations are started
  43818. */
  43819. get isStarted(): boolean;
  43820. /**
  43821. * Gets a value indicating that the current group is playing
  43822. */
  43823. get isPlaying(): boolean;
  43824. /**
  43825. * Gets or sets the speed ratio to use for all animations
  43826. */
  43827. get speedRatio(): number;
  43828. /**
  43829. * Gets or sets the speed ratio to use for all animations
  43830. */
  43831. set speedRatio(value: number);
  43832. /**
  43833. * Gets or sets if all animations should loop or not
  43834. */
  43835. get loopAnimation(): boolean;
  43836. set loopAnimation(value: boolean);
  43837. /**
  43838. * Gets or sets if all animations should be evaluated additively
  43839. */
  43840. get isAdditive(): boolean;
  43841. set isAdditive(value: boolean);
  43842. /**
  43843. * Gets the targeted animations for this animation group
  43844. */
  43845. get targetedAnimations(): Array<TargetedAnimation>;
  43846. /**
  43847. * returning the list of animatables controlled by this animation group.
  43848. */
  43849. get animatables(): Array<Animatable>;
  43850. /**
  43851. * Gets the list of target animations
  43852. */
  43853. get children(): TargetedAnimation[];
  43854. /**
  43855. * Instantiates a new Animation Group.
  43856. * This helps managing several animations at once.
  43857. * @see https://doc.babylonjs.com/how_to/group
  43858. * @param name Defines the name of the group
  43859. * @param scene Defines the scene the group belongs to
  43860. */
  43861. constructor(
  43862. /** The name of the animation group */
  43863. name: string, scene?: Nullable<Scene>);
  43864. /**
  43865. * Add an animation (with its target) in the group
  43866. * @param animation defines the animation we want to add
  43867. * @param target defines the target of the animation
  43868. * @returns the TargetedAnimation object
  43869. */
  43870. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  43871. /**
  43872. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  43873. * It can add constant keys at begin or end
  43874. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  43875. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  43876. * @returns the animation group
  43877. */
  43878. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  43879. private _animationLoopCount;
  43880. private _animationLoopFlags;
  43881. private _processLoop;
  43882. /**
  43883. * Start all animations on given targets
  43884. * @param loop defines if animations must loop
  43885. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  43886. * @param from defines the from key (optional)
  43887. * @param to defines the to key (optional)
  43888. * @param isAdditive defines the additive state for the resulting animatables (optional)
  43889. * @returns the current animation group
  43890. */
  43891. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  43892. /**
  43893. * Pause all animations
  43894. * @returns the animation group
  43895. */
  43896. pause(): AnimationGroup;
  43897. /**
  43898. * Play all animations to initial state
  43899. * This function will start() the animations if they were not started or will restart() them if they were paused
  43900. * @param loop defines if animations must loop
  43901. * @returns the animation group
  43902. */
  43903. play(loop?: boolean): AnimationGroup;
  43904. /**
  43905. * Reset all animations to initial state
  43906. * @returns the animation group
  43907. */
  43908. reset(): AnimationGroup;
  43909. /**
  43910. * Restart animations from key 0
  43911. * @returns the animation group
  43912. */
  43913. restart(): AnimationGroup;
  43914. /**
  43915. * Stop all animations
  43916. * @returns the animation group
  43917. */
  43918. stop(): AnimationGroup;
  43919. /**
  43920. * Set animation weight for all animatables
  43921. * @param weight defines the weight to use
  43922. * @return the animationGroup
  43923. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  43924. */
  43925. setWeightForAllAnimatables(weight: number): AnimationGroup;
  43926. /**
  43927. * Synchronize and normalize all animatables with a source animatable
  43928. * @param root defines the root animatable to synchronize with
  43929. * @return the animationGroup
  43930. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  43931. */
  43932. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  43933. /**
  43934. * Goes to a specific frame in this animation group
  43935. * @param frame the frame number to go to
  43936. * @return the animationGroup
  43937. */
  43938. goToFrame(frame: number): AnimationGroup;
  43939. /**
  43940. * Dispose all associated resources
  43941. */
  43942. dispose(): void;
  43943. private _checkAnimationGroupEnded;
  43944. /**
  43945. * Clone the current animation group and returns a copy
  43946. * @param newName defines the name of the new group
  43947. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  43948. * @returns the new aniamtion group
  43949. */
  43950. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  43951. /**
  43952. * Serializes the animationGroup to an object
  43953. * @returns Serialized object
  43954. */
  43955. serialize(): any;
  43956. /**
  43957. * Returns a new AnimationGroup object parsed from the source provided.
  43958. * @param parsedAnimationGroup defines the source
  43959. * @param scene defines the scene that will receive the animationGroup
  43960. * @returns a new AnimationGroup
  43961. */
  43962. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  43963. /**
  43964. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  43965. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  43966. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  43967. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  43968. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  43969. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  43970. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  43971. */
  43972. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  43973. /**
  43974. * Returns the string "AnimationGroup"
  43975. * @returns "AnimationGroup"
  43976. */
  43977. getClassName(): string;
  43978. /**
  43979. * Creates a detailled string about the object
  43980. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  43981. * @returns a string representing the object
  43982. */
  43983. toString(fullDetails?: boolean): string;
  43984. }
  43985. }
  43986. declare module BABYLON {
  43987. /**
  43988. * @hidden
  43989. **/
  43990. export class _TimeToken {
  43991. _startTimeQuery: Nullable<WebGLQuery>;
  43992. _endTimeQuery: Nullable<WebGLQuery>;
  43993. _timeElapsedQuery: Nullable<WebGLQuery>;
  43994. _timeElapsedQueryEnded: boolean;
  43995. }
  43996. }
  43997. declare module BABYLON {
  43998. /** @hidden */
  43999. export enum ExtensionName {
  44000. DepthClamping = "depth-clamping",
  44001. Depth24UnormStencil8 = "depth24unorm-stencil8",
  44002. Depth32FloatStencil8 = "depth32float-stencil8",
  44003. PipelineStatisticsQuery = "pipeline-statistics-query",
  44004. TextureCompressionBC = "texture-compression-bc",
  44005. TimestampQuery = "timestamp-query"
  44006. }
  44007. /** @hidden */
  44008. export enum AddressMode {
  44009. ClampToEdge = "clamp-to-edge",
  44010. Repeat = "repeat",
  44011. MirrorRepeat = "mirror-repeat"
  44012. }
  44013. /** @hidden */
  44014. export enum BindingType {
  44015. UniformBuffer = "uniform-buffer",
  44016. StorageBuffer = "storage-buffer",
  44017. ReadonlyStorageBuffer = "readonly-storage-buffer",
  44018. Sampler = "sampler",
  44019. ComparisonSampler = "comparison-sampler",
  44020. SampledTexture = "sampled-texture",
  44021. ReadonlyStorageTexture = "readonly-storage-texture",
  44022. WriteonlyStorageTexture = "writeonly-storage-texture"
  44023. }
  44024. /** @hidden */
  44025. export enum BlendFactor {
  44026. Zero = "zero",
  44027. One = "one",
  44028. SrcColor = "src-color",
  44029. OneMinusSrcColor = "one-minus-src-color",
  44030. SrcAlpha = "src-alpha",
  44031. OneMinusSrcAlpha = "one-minus-src-alpha",
  44032. DstColor = "dst-color",
  44033. OneMinusDstColor = "one-minus-dst-color",
  44034. DstAlpha = "dst-alpha",
  44035. OneMinusDstAlpha = "one-minus-dst-alpha",
  44036. SrcAlphaSaturated = "src-alpha-saturated",
  44037. BlendColor = "blend-color",
  44038. OneMinusBlendColor = "one-minus-blend-color"
  44039. }
  44040. /** @hidden */
  44041. export enum BlendOperation {
  44042. Add = "add",
  44043. Subtract = "subtract",
  44044. ReverseSubtract = "reverse-subtract",
  44045. Min = "min",
  44046. Max = "max"
  44047. }
  44048. /** @hidden */
  44049. export enum CompareFunction {
  44050. Never = "never",
  44051. Less = "less",
  44052. Equal = "equal",
  44053. LessEqual = "less-equal",
  44054. Greater = "greater",
  44055. NotEqual = "not-equal",
  44056. GreaterEqual = "greater-equal",
  44057. Always = "always"
  44058. }
  44059. /** @hidden */
  44060. export enum CullMode {
  44061. None = "none",
  44062. Front = "front",
  44063. Back = "back"
  44064. }
  44065. /** @hidden */
  44066. export enum FilterMode {
  44067. Nearest = "nearest",
  44068. Linear = "linear"
  44069. }
  44070. /** @hidden */
  44071. export enum FrontFace {
  44072. CCW = "ccw",
  44073. CW = "cw"
  44074. }
  44075. /** @hidden */
  44076. export enum IndexFormat {
  44077. Uint16 = "uint16",
  44078. Uint32 = "uint32"
  44079. }
  44080. /** @hidden */
  44081. export enum InputStepMode {
  44082. Vertex = "vertex",
  44083. Instance = "instance"
  44084. }
  44085. /** @hidden */
  44086. export enum LoadOp {
  44087. Load = "load"
  44088. }
  44089. /** @hidden */
  44090. export enum PrimitiveTopology {
  44091. PointList = "point-list",
  44092. LineList = "line-list",
  44093. LineStrip = "line-strip",
  44094. TriangleList = "triangle-list",
  44095. TriangleStrip = "triangle-strip"
  44096. }
  44097. /** @hidden */
  44098. export enum StencilOperation {
  44099. Keep = "keep",
  44100. Zero = "zero",
  44101. Replace = "replace",
  44102. Invert = "invert",
  44103. IncrementClamp = "increment-clamp",
  44104. DecrementClamp = "decrement-clamp",
  44105. IncrementWrap = "increment-wrap",
  44106. DecrementWrap = "decrement-wrap"
  44107. }
  44108. /** @hidden */
  44109. export enum StoreOp {
  44110. Store = "store",
  44111. Clear = "clear"
  44112. }
  44113. /** @hidden */
  44114. export enum TextureDimension {
  44115. E1d = "1d",
  44116. E2d = "2d",
  44117. E3d = "3d"
  44118. }
  44119. /** @hidden */
  44120. export enum TextureFormat {
  44121. R8Unorm = "r8unorm",
  44122. R8Snorm = "r8snorm",
  44123. R8Uint = "r8uint",
  44124. R8Sint = "r8sint",
  44125. R16Uint = "r16uint",
  44126. R16Sint = "r16sint",
  44127. R16Float = "r16float",
  44128. RG8Unorm = "rg8unorm",
  44129. RG8Snorm = "rg8snorm",
  44130. RG8Uint = "rg8uint",
  44131. RG8Sint = "rg8sint",
  44132. R32Uint = "r32uint",
  44133. R32Sint = "r32sint",
  44134. R32Float = "r32float",
  44135. RG16Uint = "rg16uint",
  44136. RG16Sint = "rg16sint",
  44137. RG16Float = "rg16float",
  44138. RGBA8Unorm = "rgba8unorm",
  44139. RGBA8UnormSRGB = "rgba8unorm-srgb",
  44140. RGBA8Snorm = "rgba8snorm",
  44141. RGBA8Uint = "rgba8uint",
  44142. RGBA8Sint = "rgba8sint",
  44143. BGRA8Unorm = "bgra8unorm",
  44144. BGRA8UnormSRGB = "bgra8unorm-srgb",
  44145. RGB9E5UFloat = "rgb9e5ufloat",
  44146. RGB10A2Unorm = "rgb10a2unorm",
  44147. RG11B10UFloat = "rg11b10ufloat",
  44148. RG32Uint = "rg32uint",
  44149. RG32Sint = "rg32sint",
  44150. RG32Float = "rg32float",
  44151. RGBA16Uint = "rgba16uint",
  44152. RGBA16Sint = "rgba16sint",
  44153. RGBA16Float = "rgba16float",
  44154. RGBA32Uint = "rgba32uint",
  44155. RGBA32Sint = "rgba32sint",
  44156. RGBA32Float = "rgba32float",
  44157. Stencil8 = "stencil8",
  44158. Depth16Unorm = "depth16unorm",
  44159. Depth24Plus = "depth24plus",
  44160. Depth24PlusStencil8 = "depth24plus-stencil8",
  44161. Depth32Float = "depth32float",
  44162. BC1RGBAUNorm = "bc1-rgba-unorm",
  44163. BC1RGBAUnormSRGB = "bc1-rgba-unorm-srgb",
  44164. BC2RGBAUnorm = "bc2-rgba-unorm",
  44165. BC2RGBAUnormSRGB = "bc2-rgba-unorm-srgb",
  44166. BC3RGBAUnorm = "bc3-rgba-unorm",
  44167. BC3RGBAUnormSRGB = "bc3-rgba-unorm-srgb",
  44168. BC4RUnorm = "bc4-r-unorm",
  44169. BC4RSnorm = "bc4-r-snorm",
  44170. BC5RGUnorm = "bc5-rg-unorm",
  44171. BC5RGSnorm = "bc5-rg-snorm",
  44172. BC6HRGBUFloat = "bc6h-rgb-ufloat",
  44173. BC6HRGBFloat = "bc6h-rgb-float",
  44174. BC7RGBAUnorm = "bc7-rgba-unorm",
  44175. BC7RGBAUnormSRGB = "bc7-rgba-unorm-srgb",
  44176. Depth24UnormStencil8 = "depth24unorm-stencil8",
  44177. Depth32FloatStencil8 = "depth32float-stencil8"
  44178. }
  44179. /** @hidden */
  44180. export enum TextureComponentType {
  44181. Float = "float",
  44182. Sint = "sint",
  44183. Uint = "uint",
  44184. DepthComparison = "depth-comparison"
  44185. }
  44186. /** @hidden */
  44187. export enum TextureViewDimension {
  44188. E1d = "1d",
  44189. E2d = "2d",
  44190. E2dArray = "2d-array",
  44191. Cube = "cube",
  44192. CubeArray = "cube-array",
  44193. E3d = "3d"
  44194. }
  44195. /** @hidden */
  44196. export enum VertexFormat {
  44197. Uchar2 = "uchar2",
  44198. Uchar4 = "uchar4",
  44199. Char2 = "char2",
  44200. Char4 = "char4",
  44201. Uchar2Norm = "uchar2norm",
  44202. Uchar4Norm = "uchar4norm",
  44203. Char2Norm = "char2norm",
  44204. Char4Norm = "char4norm",
  44205. Ushort2 = "ushort2",
  44206. Ushort4 = "ushort4",
  44207. Short2 = "short2",
  44208. Short4 = "short4",
  44209. Ushort2Norm = "ushort2norm",
  44210. Ushort4Norm = "ushort4norm",
  44211. Short2Norm = "short2norm",
  44212. Short4Norm = "short4norm",
  44213. Half2 = "half2",
  44214. Half4 = "half4",
  44215. Float = "float",
  44216. Float2 = "float2",
  44217. Float3 = "float3",
  44218. Float4 = "float4",
  44219. Uint = "uint",
  44220. Uint2 = "uint2",
  44221. Uint3 = "uint3",
  44222. Uint4 = "uint4",
  44223. Int = "int",
  44224. Int2 = "int2",
  44225. Int3 = "int3",
  44226. Int4 = "int4"
  44227. }
  44228. /** @hidden */
  44229. export enum TextureAspect {
  44230. All = "all",
  44231. StencilOnly = "stencil-only",
  44232. DepthOnly = "depth-only"
  44233. }
  44234. /** @hidden */
  44235. export enum CompilationMessageType {
  44236. Error = "error",
  44237. Warning = "warning",
  44238. Info = "info"
  44239. }
  44240. /** @hidden */
  44241. export enum QueryType {
  44242. Occlusion = "occlusion"
  44243. }
  44244. /** @hidden */
  44245. export enum BufferUsage {
  44246. MapRead = 1,
  44247. MapWrite = 2,
  44248. CopySrc = 4,
  44249. CopyDst = 8,
  44250. Index = 16,
  44251. Vertex = 32,
  44252. Uniform = 64,
  44253. Storage = 128,
  44254. Indirect = 256,
  44255. QueryResolve = 512
  44256. }
  44257. /** @hidden */
  44258. export enum ColorWrite {
  44259. Red = 1,
  44260. Green = 2,
  44261. Blue = 4,
  44262. Alpha = 8,
  44263. All = 15
  44264. }
  44265. /** @hidden */
  44266. export enum ShaderStage {
  44267. Vertex = 1,
  44268. Fragment = 2,
  44269. Compute = 4
  44270. }
  44271. /** @hidden */
  44272. export enum TextureUsage {
  44273. CopySrc = 1,
  44274. CopyDst = 2,
  44275. Sampled = 4,
  44276. Storage = 8,
  44277. OutputAttachment = 16
  44278. }
  44279. /** @hidden */
  44280. export enum MapMode {
  44281. Read = 1,
  44282. Write = 2
  44283. }
  44284. }
  44285. declare module BABYLON {
  44286. /** @hidden */
  44287. export interface WebGPUBindingInfo {
  44288. setIndex: number;
  44289. bindingIndex: number;
  44290. }
  44291. /** @hidden */
  44292. export interface WebGPUTextureSamplerBindingDescription {
  44293. sampler: WebGPUBindingInfo;
  44294. isTextureArray: boolean;
  44295. textures: Array<WebGPUBindingInfo>;
  44296. }
  44297. /** @hidden
  44298. * If the binding is a UBO, isSampler=isTexture=false
  44299. */
  44300. export interface WebGPUBindingDescription {
  44301. name: string;
  44302. usedInVertex: boolean;
  44303. usedInFragment: boolean;
  44304. isSampler: boolean;
  44305. isComparisonSampler?: boolean;
  44306. isTexture: boolean;
  44307. componentType?: GPUTextureComponentType;
  44308. textureDimension?: GPUTextureViewDimension;
  44309. }
  44310. /**
  44311. * @hidden
  44312. */
  44313. export class WebGPUShaderProcessingContext implements ShaderProcessingContext {
  44314. uboNextBindingIndex: number;
  44315. freeSetIndex: number;
  44316. freeBindingIndex: number;
  44317. availableVaryings: {
  44318. [key: string]: number;
  44319. };
  44320. availableAttributes: {
  44321. [key: string]: number;
  44322. };
  44323. availableUBOs: {
  44324. [key: string]: {
  44325. setIndex: number;
  44326. bindingIndex: number;
  44327. };
  44328. };
  44329. availableSamplers: {
  44330. [key: string]: WebGPUTextureSamplerBindingDescription;
  44331. };
  44332. leftOverUniforms: {
  44333. name: string;
  44334. type: string;
  44335. length: number;
  44336. }[];
  44337. orderedAttributes: string[];
  44338. orderedUBOsAndSamplers: WebGPUBindingDescription[][];
  44339. uniformBufferNames: string[];
  44340. private _attributeNextLocation;
  44341. private _varyingNextLocation;
  44342. constructor();
  44343. getAttributeNextLocation(dataType: string, arrayLength?: number): number;
  44344. getVaryingNextLocation(dataType: string, arrayLength?: number): number;
  44345. getNextFreeUBOBinding(): {
  44346. setIndex: number;
  44347. bindingIndex: number;
  44348. };
  44349. private _getNextFreeBinding;
  44350. }
  44351. }
  44352. declare module BABYLON {
  44353. /** @hidden */
  44354. export interface IWebGPUPipelineContextSamplerCache {
  44355. samplerBinding: number;
  44356. firstTextureName: string;
  44357. }
  44358. /** @hidden */
  44359. export interface IWebGPUPipelineContextTextureCache {
  44360. textureBinding: number;
  44361. texture: InternalTexture;
  44362. }
  44363. /** @hidden */
  44364. export interface IWebGPUPipelineContextVertexInputsCache {
  44365. indexBuffer: Nullable<GPUBuffer>;
  44366. indexOffset: number;
  44367. vertexStartSlot: number;
  44368. vertexBuffers: GPUBuffer[];
  44369. vertexOffsets: number[];
  44370. }
  44371. /** @hidden */
  44372. export interface IWebGPURenderPipelineStageDescriptor {
  44373. vertexStage: GPUProgrammableStageDescriptor;
  44374. fragmentStage?: GPUProgrammableStageDescriptor;
  44375. }
  44376. /** @hidden */
  44377. export class WebGPUPipelineContext implements IPipelineContext {
  44378. engine: WebGPUEngine;
  44379. shaderProcessingContext: WebGPUShaderProcessingContext;
  44380. leftOverUniformsByName: {
  44381. [name: string]: string;
  44382. };
  44383. sources: {
  44384. vertex: string;
  44385. fragment: string;
  44386. rawVertex: string;
  44387. rawFragment: string;
  44388. };
  44389. stages: Nullable<IWebGPURenderPipelineStageDescriptor>;
  44390. samplers: {
  44391. [name: string]: Nullable<IWebGPUPipelineContextSamplerCache>;
  44392. };
  44393. textures: {
  44394. [name: string]: Nullable<IWebGPUPipelineContextTextureCache>;
  44395. };
  44396. bindGroupLayouts: GPUBindGroupLayout[];
  44397. bindGroupsCache: {
  44398. [key: string]: GPUBindGroup[];
  44399. };
  44400. /**
  44401. * Stores the uniform buffer
  44402. */
  44403. uniformBuffer: Nullable<UniformBuffer>;
  44404. onCompiled?: () => void;
  44405. get isAsync(): boolean;
  44406. get isReady(): boolean;
  44407. /** @hidden */
  44408. _name: string;
  44409. constructor(shaderProcessingContext: WebGPUShaderProcessingContext, engine: WebGPUEngine);
  44410. _handlesSpectorRebuildCallback(onCompiled: (program: any) => void): void;
  44411. _fillEffectInformation(effect: Effect, uniformBuffersNames: {
  44412. [key: string]: number;
  44413. }, uniformsNames: string[], uniforms: {
  44414. [key: string]: Nullable<WebGLUniformLocation>;
  44415. }, samplerList: string[], samplers: {
  44416. [key: string]: number;
  44417. }, attributesNames: string[], attributes: number[]): void;
  44418. /** @hidden */
  44419. /**
  44420. * Build the uniform buffer used in the material.
  44421. */
  44422. buildUniformLayout(): void;
  44423. /**
  44424. * Release all associated resources.
  44425. **/
  44426. dispose(): void;
  44427. /**
  44428. * Sets an integer value on a uniform variable.
  44429. * @param uniformName Name of the variable.
  44430. * @param value Value to be set.
  44431. */
  44432. setInt(uniformName: string, value: number): void;
  44433. /**
  44434. * Sets an int2 value on a uniform variable.
  44435. * @param uniformName Name of the variable.
  44436. * @param x First int in int2.
  44437. * @param y Second int in int2.
  44438. */
  44439. setInt2(uniformName: string, x: number, y: number): void;
  44440. /**
  44441. * Sets an int3 value on a uniform variable.
  44442. * @param uniformName Name of the variable.
  44443. * @param x First int in int3.
  44444. * @param y Second int in int3.
  44445. * @param z Third int in int3.
  44446. */
  44447. setInt3(uniformName: string, x: number, y: number, z: number): void;
  44448. /**
  44449. * Sets an int4 value on a uniform variable.
  44450. * @param uniformName Name of the variable.
  44451. * @param x First int in int4.
  44452. * @param y Second int in int4.
  44453. * @param z Third int in int4.
  44454. * @param w Fourth int in int4.
  44455. */
  44456. setInt4(uniformName: string, x: number, y: number, z: number, w: number): void;
  44457. /**
  44458. * Sets an int array on a uniform variable.
  44459. * @param uniformName Name of the variable.
  44460. * @param array array to be set.
  44461. */
  44462. setIntArray(uniformName: string, array: Int32Array): void;
  44463. /**
  44464. * 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)
  44465. * @param uniformName Name of the variable.
  44466. * @param array array to be set.
  44467. */
  44468. setIntArray2(uniformName: string, array: Int32Array): void;
  44469. /**
  44470. * 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)
  44471. * @param uniformName Name of the variable.
  44472. * @param array array to be set.
  44473. */
  44474. setIntArray3(uniformName: string, array: Int32Array): void;
  44475. /**
  44476. * 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)
  44477. * @param uniformName Name of the variable.
  44478. * @param array array to be set.
  44479. */
  44480. setIntArray4(uniformName: string, array: Int32Array): void;
  44481. /**
  44482. * Sets an array on a uniform variable.
  44483. * @param uniformName Name of the variable.
  44484. * @param array array to be set.
  44485. */
  44486. setArray(uniformName: string, array: number[]): void;
  44487. /**
  44488. * 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)
  44489. * @param uniformName Name of the variable.
  44490. * @param array array to be set.
  44491. */
  44492. setArray2(uniformName: string, array: number[]): void;
  44493. /**
  44494. * 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)
  44495. * @param uniformName Name of the variable.
  44496. * @param array array to be set.
  44497. * @returns this effect.
  44498. */
  44499. setArray3(uniformName: string, array: number[]): void;
  44500. /**
  44501. * 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)
  44502. * @param uniformName Name of the variable.
  44503. * @param array array to be set.
  44504. */
  44505. setArray4(uniformName: string, array: number[]): void;
  44506. /**
  44507. * Sets matrices on a uniform variable.
  44508. * @param uniformName Name of the variable.
  44509. * @param matrices matrices to be set.
  44510. */
  44511. setMatrices(uniformName: string, matrices: Float32Array): void;
  44512. /**
  44513. * Sets matrix on a uniform variable.
  44514. * @param uniformName Name of the variable.
  44515. * @param matrix matrix to be set.
  44516. */
  44517. setMatrix(uniformName: string, matrix: IMatrixLike): void;
  44518. /**
  44519. * 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)
  44520. * @param uniformName Name of the variable.
  44521. * @param matrix matrix to be set.
  44522. */
  44523. setMatrix3x3(uniformName: string, matrix: Float32Array): void;
  44524. /**
  44525. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  44526. * @param uniformName Name of the variable.
  44527. * @param matrix matrix to be set.
  44528. */
  44529. setMatrix2x2(uniformName: string, matrix: Float32Array): void;
  44530. /**
  44531. * Sets a float on a uniform variable.
  44532. * @param uniformName Name of the variable.
  44533. * @param value value to be set.
  44534. * @returns this effect.
  44535. */
  44536. setFloat(uniformName: string, value: number): void;
  44537. /**
  44538. * Sets a Vector2 on a uniform variable.
  44539. * @param uniformName Name of the variable.
  44540. * @param vector2 vector2 to be set.
  44541. */
  44542. setVector2(uniformName: string, vector2: IVector2Like): void;
  44543. /**
  44544. * Sets a float2 on a uniform variable.
  44545. * @param uniformName Name of the variable.
  44546. * @param x First float in float2.
  44547. * @param y Second float in float2.
  44548. */
  44549. setFloat2(uniformName: string, x: number, y: number): void;
  44550. /**
  44551. * Sets a Vector3 on a uniform variable.
  44552. * @param uniformName Name of the variable.
  44553. * @param vector3 Value to be set.
  44554. */
  44555. setVector3(uniformName: string, vector3: IVector3Like): void;
  44556. /**
  44557. * Sets a float3 on a uniform variable.
  44558. * @param uniformName Name of the variable.
  44559. * @param x First float in float3.
  44560. * @param y Second float in float3.
  44561. * @param z Third float in float3.
  44562. */
  44563. setFloat3(uniformName: string, x: number, y: number, z: number): void;
  44564. /**
  44565. * Sets a Vector4 on a uniform variable.
  44566. * @param uniformName Name of the variable.
  44567. * @param vector4 Value to be set.
  44568. */
  44569. setVector4(uniformName: string, vector4: IVector4Like): void;
  44570. /**
  44571. * Sets a float4 on a uniform variable.
  44572. * @param uniformName Name of the variable.
  44573. * @param x First float in float4.
  44574. * @param y Second float in float4.
  44575. * @param z Third float in float4.
  44576. * @param w Fourth float in float4.
  44577. * @returns this effect.
  44578. */
  44579. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): void;
  44580. /**
  44581. * Sets a Color3 on a uniform variable.
  44582. * @param uniformName Name of the variable.
  44583. * @param color3 Value to be set.
  44584. */
  44585. setColor3(uniformName: string, color3: IColor3Like): void;
  44586. /**
  44587. * Sets a Color4 on a uniform variable.
  44588. * @param uniformName Name of the variable.
  44589. * @param color3 Value to be set.
  44590. * @param alpha Alpha value to be set.
  44591. */
  44592. setColor4(uniformName: string, color3: IColor3Like, alpha: number): void;
  44593. /**
  44594. * Sets a Color4 on a uniform variable
  44595. * @param uniformName defines the name of the variable
  44596. * @param color4 defines the value to be set
  44597. */
  44598. setDirectColor4(uniformName: string, color4: IColor4Like): void;
  44599. _getVertexShaderCode(): string | null;
  44600. _getFragmentShaderCode(): string | null;
  44601. }
  44602. }
  44603. declare module BABYLON {
  44604. /** @hidden */
  44605. export class WebGPUDataBuffer extends DataBuffer {
  44606. private _buffer;
  44607. constructor(resource: GPUBuffer);
  44608. get underlyingResource(): any;
  44609. }
  44610. }
  44611. declare module BABYLON {
  44612. /**
  44613. * Class used to inline functions in shader code
  44614. */
  44615. export class ShaderCodeInliner {
  44616. private static readonly _RegexpFindFunctionNameAndType;
  44617. private _sourceCode;
  44618. private _functionDescr;
  44619. private _numMaxIterations;
  44620. /** Gets or sets the token used to mark the functions to inline */
  44621. inlineToken: string;
  44622. /** Gets or sets the debug mode */
  44623. debug: boolean;
  44624. /** Gets the code after the inlining process */
  44625. get code(): string;
  44626. /**
  44627. * Initializes the inliner
  44628. * @param sourceCode shader code source to inline
  44629. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  44630. */
  44631. constructor(sourceCode: string, numMaxIterations?: number);
  44632. /**
  44633. * Start the processing of the shader code
  44634. */
  44635. processCode(): void;
  44636. private _collectFunctions;
  44637. private _processInlining;
  44638. private _extractBetweenMarkers;
  44639. private _skipWhitespaces;
  44640. private _isIdentifierChar;
  44641. private _removeComments;
  44642. private _replaceFunctionCallsByCode;
  44643. private _findBackward;
  44644. private _escapeRegExp;
  44645. private _replaceNames;
  44646. }
  44647. }
  44648. declare module BABYLON {
  44649. /** @hidden */
  44650. export class WebGPUShaderProcessor implements IShaderProcessor {
  44651. protected _missingVaryings: Array<string>;
  44652. protected _textureArrayProcessing: Array<string>;
  44653. protected _preProcessors: {
  44654. [key: string]: string;
  44655. };
  44656. private _getArraySize;
  44657. initializeShaders(processingContext: Nullable<ShaderProcessingContext>): void;
  44658. varyingProcessor(varying: string, isFragment: boolean, preProcessors: {
  44659. [key: string]: string;
  44660. }, processingContext: Nullable<ShaderProcessingContext>): string;
  44661. attributeProcessor(attribute: string, preProcessors: {
  44662. [key: string]: string;
  44663. }, processingContext: Nullable<ShaderProcessingContext>): string;
  44664. uniformProcessor(uniform: string, isFragment: boolean, preProcessors: {
  44665. [key: string]: string;
  44666. }, processingContext: Nullable<ShaderProcessingContext>): string;
  44667. uniformBufferProcessor(uniformBuffer: string, isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>): string;
  44668. postProcessor(code: string, defines: string[], isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>): string;
  44669. private _applyTextureArrayProcessing;
  44670. finalizeShaders(vertexCode: string, fragmentCode: string, processingContext: Nullable<ShaderProcessingContext>): {
  44671. vertexCode: string;
  44672. fragmentCode: string;
  44673. };
  44674. }
  44675. }
  44676. declare module BABYLON {
  44677. /** @hidden */
  44678. export class WebGPUBufferManager {
  44679. private _device;
  44680. private _deferredReleaseBuffers;
  44681. private static _IsGPUBuffer;
  44682. constructor(device: GPUDevice);
  44683. createRawBuffer(viewOrSize: ArrayBufferView | number, flags: GPUBufferUsageFlags, mappedAtCreation?: boolean): GPUBuffer;
  44684. createBuffer(viewOrSize: ArrayBufferView | number, flags: GPUBufferUsageFlags): DataBuffer;
  44685. setSubData(dataBuffer: WebGPUDataBuffer, dstByteOffset: number, src: ArrayBufferView, srcByteOffset?: number, byteLength?: number): void;
  44686. private _FromHalfFloat;
  44687. private _GetHalfFloatAsFloatRGBAArrayBuffer;
  44688. readDataFromBuffer(gpuBuffer: GPUBuffer, size: number, width: number, height: number, bytesPerRow: number, bytesPerRowAligned: number, floatFormat?: number, offset?: number, buffer?: Nullable<ArrayBufferView>, destroyBuffer?: boolean): Promise<ArrayBufferView>;
  44689. releaseBuffer(buffer: DataBuffer | GPUBuffer): boolean;
  44690. destroyDeferredBuffers(): void;
  44691. }
  44692. }
  44693. declare module BABYLON {
  44694. /** @hidden */
  44695. export class WebGPUHardwareTexture implements HardwareTextureWrapper {
  44696. private _webgpuTexture;
  44697. private _webgpuMSAATexture;
  44698. get underlyingResource(): Nullable<GPUTexture>;
  44699. get msaaTexture(): Nullable<GPUTexture>;
  44700. set msaaTexture(texture: Nullable<GPUTexture>);
  44701. view: Nullable<GPUTextureView>;
  44702. format: GPUTextureFormat;
  44703. textureUsages: number;
  44704. constructor(existingTexture?: Nullable<GPUTexture>);
  44705. set(hardwareTexture: GPUTexture): void;
  44706. setMSAATexture(hardwareTexture: GPUTexture): void;
  44707. setUsage(textureSource: number, generateMipMaps: boolean, isCube: boolean, width: number, height: number): void;
  44708. createView(descriptor?: GPUTextureViewDescriptor): void;
  44709. reset(): void;
  44710. release(): void;
  44711. }
  44712. }
  44713. declare module BABYLON {
  44714. /** @hidden */
  44715. export class WebGPUTextureHelper {
  44716. private _device;
  44717. private _glslang;
  44718. private _bufferManager;
  44719. private _mipmapSampler;
  44720. private _invertYPreMultiplyAlphaSampler;
  44721. private _pipelines;
  44722. private _compiledShaders;
  44723. private _deferredReleaseTextures;
  44724. private _commandEncoderForCreation;
  44725. static ComputeNumMipmapLevels(width: number, height: number): number;
  44726. constructor(device: GPUDevice, glslang: any, bufferManager: WebGPUBufferManager);
  44727. private _getPipeline;
  44728. private static _GetTextureTypeFromFormat;
  44729. private static _GetBlockInformationFromFormat;
  44730. private static _IsHardwareTexture;
  44731. private static _IsInternalTexture;
  44732. static GetCompareFunction(compareFunction: Nullable<number>): GPUCompareFunction;
  44733. static IsImageBitmap(imageBitmap: ImageBitmap | {
  44734. width: number;
  44735. height: number;
  44736. }): imageBitmap is ImageBitmap;
  44737. static IsImageBitmapArray(imageBitmap: ImageBitmap[] | {
  44738. width: number;
  44739. height: number;
  44740. }): imageBitmap is ImageBitmap[];
  44741. setCommandEncoder(encoder: GPUCommandEncoder): void;
  44742. static IsCompressedFormat(format: GPUTextureFormat): boolean;
  44743. static GetWebGPUTextureFormat(type: number, format: number): GPUTextureFormat;
  44744. invertYPreMultiplyAlpha(gpuTexture: GPUTexture, width: number, height: number, format: GPUTextureFormat, invertY?: boolean, premultiplyAlpha?: boolean, faceIndex?: number, commandEncoder?: GPUCommandEncoder): void;
  44745. clear(format: GPUTextureFormat, color: IColor4Like, passEncoder: GPURenderPassEncoder): void;
  44746. createTexture(imageBitmap: ImageBitmap | {
  44747. width: number;
  44748. height: number;
  44749. layers: number;
  44750. }, hasMipmaps?: boolean, generateMipmaps?: boolean, invertY?: boolean, premultiplyAlpha?: boolean, is3D?: boolean, format?: GPUTextureFormat, sampleCount?: number, commandEncoder?: GPUCommandEncoder, usage?: number): GPUTexture;
  44751. createCubeTexture(imageBitmaps: ImageBitmap[] | {
  44752. width: number;
  44753. height: number;
  44754. }, hasMipmaps?: boolean, generateMipmaps?: boolean, invertY?: boolean, premultiplyAlpha?: boolean, format?: GPUTextureFormat, sampleCount?: number, commandEncoder?: GPUCommandEncoder, usage?: number): GPUTexture;
  44755. generateCubeMipmaps(gpuTexture: GPUTexture, format: GPUTextureFormat, mipLevelCount: number, commandEncoder?: GPUCommandEncoder): void;
  44756. generateMipmaps(gpuTexture: GPUTexture, format: GPUTextureFormat, mipLevelCount: number, faceIndex?: number, commandEncoder?: GPUCommandEncoder): void;
  44757. createGPUTextureForInternalTexture(texture: InternalTexture, width?: number, height?: number, depth?: number): WebGPUHardwareTexture;
  44758. createMSAATexture(texture: InternalTexture, samples: number): void;
  44759. updateCubeTextures(imageBitmaps: ImageBitmap[] | Uint8Array[], gpuTexture: GPUTexture, width: number, height: number, format: GPUTextureFormat, invertY?: boolean, premultiplyAlpha?: boolean, offsetX?: number, offsetY?: number, commandEncoder?: GPUCommandEncoder): void;
  44760. updateTexture(imageBitmap: ImageBitmap | Uint8Array, gpuTexture: GPUTexture, width: number, height: number, layers: number, format: GPUTextureFormat, faceIndex?: number, mipLevel?: number, invertY?: boolean, premultiplyAlpha?: boolean, offsetX?: number, offsetY?: number, commandEncoder?: GPUCommandEncoder): void;
  44761. readPixels(texture: GPUTexture, x: number, y: number, width: number, height: number, format: GPUTextureFormat, faceIndex?: number, mipLevel?: number, buffer?: Nullable<ArrayBufferView>): Promise<ArrayBufferView>;
  44762. releaseTexture(texture: InternalTexture | GPUTexture): void;
  44763. destroyDeferredTextures(): void;
  44764. }
  44765. }
  44766. declare module BABYLON {
  44767. /** @hidden */
  44768. export class WebGPURenderPassWrapper {
  44769. renderPassDescriptor: Nullable<GPURenderPassDescriptor>;
  44770. renderPass: Nullable<GPURenderPassEncoder>;
  44771. colorAttachmentViewDescriptor: Nullable<GPUTextureViewDescriptor>;
  44772. depthAttachmentViewDescriptor: Nullable<GPUTextureViewDescriptor>;
  44773. colorAttachmentGPUTextures: WebGPUHardwareTexture[];
  44774. depthTextureFormat: GPUTextureFormat | undefined;
  44775. constructor();
  44776. reset(fullReset?: boolean): void;
  44777. }
  44778. }
  44779. declare module BABYLON {
  44780. /** @hidden */
  44781. export class WebGPUCacheSampler {
  44782. private _samplers;
  44783. private _device;
  44784. disabled: boolean;
  44785. constructor(device: GPUDevice);
  44786. private static _GetSamplerHashCode;
  44787. private static _GetSamplerFilterDescriptor;
  44788. private static _GetWrappingMode;
  44789. private static _GetSamplerWrappingDescriptor;
  44790. private static _GetSamplerDescriptor;
  44791. getSampler(internalTexture: InternalTexture, bypassCache?: boolean): GPUSampler;
  44792. }
  44793. }
  44794. declare module BABYLON {
  44795. /** @hidden */
  44796. export class WebGPUShaderManager {
  44797. private _shaders;
  44798. private _device;
  44799. constructor(device: GPUDevice);
  44800. getCompiledShaders(name: string): IWebGPURenderPipelineStageDescriptor;
  44801. }
  44802. }
  44803. declare module BABYLON {
  44804. /** @hidden */
  44805. export class WebGPUCacheRenderPipeline {
  44806. static NumCacheHitWithoutHash: number;
  44807. static NumCacheHitWithHash: number;
  44808. static NumCacheMiss: number;
  44809. static NumPipelineCreationLastFrame: number;
  44810. disabled: boolean;
  44811. private static _Cache;
  44812. private static _NumPipelineCreationCurrentFrame;
  44813. private _device;
  44814. private _states;
  44815. private _isDirty;
  44816. private _currentRenderPipeline;
  44817. private _emptyVertexBuffer;
  44818. private _shaderId;
  44819. private _alphaToCoverageEnabled;
  44820. private _frontFace;
  44821. private _cullEnabled;
  44822. private _cullFace;
  44823. private _clampDepth;
  44824. private _rasterizationState;
  44825. private _depthBias;
  44826. private _depthBiasClamp;
  44827. private _depthBiasSlopeScale;
  44828. private _colorFormat;
  44829. private _webgpuColorFormat;
  44830. private _mrtAttachments1;
  44831. private _mrtAttachments2;
  44832. private _mrtFormats;
  44833. private _alphaBlendEnabled;
  44834. private _alphaBlendFuncParams;
  44835. private _alphaBlendEqParams;
  44836. private _writeMask;
  44837. private _colorStates;
  44838. private _depthStencilFormat;
  44839. private _webgpuDepthStencilFormat;
  44840. private _depthTestEnabled;
  44841. private _depthWriteEnabled;
  44842. private _depthCompare;
  44843. private _stencilEnabled;
  44844. private _stencilFrontCompare;
  44845. private _stencilFrontDepthFailOp;
  44846. private _stencilFrontPassOp;
  44847. private _stencilFrontFailOp;
  44848. private _stencilReadMask;
  44849. private _stencilWriteMask;
  44850. private _depthStencilState;
  44851. private _vertexBuffers;
  44852. private _overrideVertexBuffers;
  44853. private _indexBuffer;
  44854. constructor(device: GPUDevice, emptyVertexBuffer: VertexBuffer);
  44855. reset(): void;
  44856. getRenderPipeline(fillMode: number, effect: Effect, sampleCount: number): GPURenderPipeline;
  44857. endFrame(): void;
  44858. setAlphaToCoverage(enabled: boolean): void;
  44859. setFrontFace(frontFace: number): void;
  44860. setCullEnabled(enabled: boolean): void;
  44861. setCullFace(cullFace: number): void;
  44862. setClampDepth(clampDepth: boolean): void;
  44863. resetDepthCullingState(): void;
  44864. setDepthCullingState(cullEnabled: boolean, frontFace: number, cullFace: number, zOffset: number, depthTestEnabled: boolean, depthWriteEnabled: boolean, depthCompare: Nullable<number>): void;
  44865. setDepthBiasSlopeScale(depthBiasSlopeScale: number): void;
  44866. setColorFormat(format: GPUTextureFormat): void;
  44867. setMRTAttachments(attachments: number[], textureArray: InternalTexture[]): void;
  44868. setAlphaBlendEnabled(enabled: boolean): void;
  44869. setAlphaBlendFactors(factors: Array<Nullable<number>>, operations: Array<Nullable<number>>): void;
  44870. setWriteMask(mask: number): void;
  44871. setDepthStencilFormat(format: GPUTextureFormat | undefined): void;
  44872. setDepthTestEnabled(enabled: boolean): void;
  44873. setDepthWriteEnabled(enabled: boolean): void;
  44874. setDepthCompare(func: Nullable<number>): void;
  44875. setStencilEnabled(enabled: boolean): void;
  44876. setStencilCompare(func: Nullable<number>): void;
  44877. setStencilDepthFailOp(op: Nullable<number>): void;
  44878. setStencilPassOp(op: Nullable<number>): void;
  44879. setStencilFailOp(op: Nullable<number>): void;
  44880. setStencilReadMask(mask: number): void;
  44881. setStencilWriteMask(mask: number): void;
  44882. resetStencilState(): void;
  44883. setStencilState(stencilEnabled: boolean, compare: Nullable<number>, depthFailOp: Nullable<number>, passOp: Nullable<number>, failOp: Nullable<number>, readMask: number, writeMask: number): void;
  44884. setBuffers(vertexBuffers: Nullable<{
  44885. [key: string]: Nullable<VertexBuffer>;
  44886. }>, indexBuffer: Nullable<DataBuffer>, overrideVertexBuffers: Nullable<{
  44887. [key: string]: Nullable<VertexBuffer>;
  44888. }>): void;
  44889. private static _GetTopology;
  44890. private static _GetAphaBlendOperation;
  44891. private static _GetAphaBlendFactor;
  44892. private static _GetCompareFunction;
  44893. private static _GetStencilOpFunction;
  44894. private static _GetVertexInputDescriptorFormat;
  44895. private _getAphaBlendState;
  44896. private _getColorBlendState;
  44897. private _setShaderStage;
  44898. private _setRasterizationState;
  44899. private _setColorStates;
  44900. private _setDepthStencilState;
  44901. private _setVertexState;
  44902. private _createPipelineLayout;
  44903. private _getVertexInputDescriptor;
  44904. private _createRenderPipeline;
  44905. }
  44906. }
  44907. declare module BABYLON {
  44908. /** @hidden */
  44909. export var clearQuadVertexShader: {
  44910. name: string;
  44911. shader: string;
  44912. };
  44913. }
  44914. declare module BABYLON {
  44915. /** @hidden */
  44916. export var clearQuadPixelShader: {
  44917. name: string;
  44918. shader: string;
  44919. };
  44920. }
  44921. declare module BABYLON {
  44922. /**
  44923. * Options to load the associated Glslang library
  44924. */
  44925. export interface GlslangOptions {
  44926. /**
  44927. * Defines an existing instance of Glslang (usefull in modules who do not access the global instance).
  44928. */
  44929. glslang?: any;
  44930. /**
  44931. * Defines the URL of the glslang JS File.
  44932. */
  44933. jsPath?: string;
  44934. /**
  44935. * Defines the URL of the glslang WASM File.
  44936. */
  44937. wasmPath?: string;
  44938. }
  44939. /**
  44940. * Options to create the WebGPU engine
  44941. */
  44942. export interface WebGPUEngineOptions extends GPURequestAdapterOptions {
  44943. /**
  44944. * If delta time between frames should be constant
  44945. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  44946. */
  44947. deterministicLockstep?: boolean;
  44948. /**
  44949. * Maximum about of steps between frames (Default: 4)
  44950. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  44951. */
  44952. lockstepMaxSteps?: number;
  44953. /**
  44954. * Defines the seconds between each deterministic lock step
  44955. */
  44956. timeStep?: number;
  44957. /**
  44958. * Defines that engine should ignore modifying touch action attribute and style
  44959. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  44960. */
  44961. doNotHandleTouchAction?: boolean;
  44962. /**
  44963. * Defines if webaudio should be initialized as well
  44964. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  44965. */
  44966. audioEngine?: boolean;
  44967. /**
  44968. * Defines the category of adapter to use.
  44969. * Is it the discrete or integrated device.
  44970. */
  44971. powerPreference?: GPUPowerPreference;
  44972. /**
  44973. * Defines the device descriptor used to create a device.
  44974. */
  44975. deviceDescriptor?: GPUDeviceDescriptor;
  44976. /**
  44977. * Defines the requested Swap Chain Format.
  44978. */
  44979. swapChainFormat?: GPUTextureFormat;
  44980. /**
  44981. * Defines wether MSAA is enabled on the canvas.
  44982. */
  44983. antialiasing?: boolean;
  44984. /**
  44985. * Defines wether the stencil buffer should be enabled.
  44986. */
  44987. stencil?: boolean;
  44988. /**
  44989. * Defines wether we should generate debug markers in the gpu command lists (can be seen with PIX for eg)
  44990. */
  44991. enableGPUDebugMarkers?: boolean;
  44992. /**
  44993. * Options to load the associated Glslang library
  44994. */
  44995. glslangOptions?: GlslangOptions;
  44996. }
  44997. /**
  44998. * The web GPU engine class provides support for WebGPU version of babylon.js.
  44999. */
  45000. export class WebGPUEngine extends Engine {
  45001. private static readonly _glslangDefaultOptions;
  45002. private readonly _uploadEncoderDescriptor;
  45003. private readonly _renderEncoderDescriptor;
  45004. private readonly _renderTargetEncoderDescriptor;
  45005. private readonly _clearDepthValue;
  45006. private readonly _clearReverseDepthValue;
  45007. private readonly _clearStencilValue;
  45008. private readonly _defaultSampleCount;
  45009. private _canvas;
  45010. private _options;
  45011. private _glslang;
  45012. private _adapter;
  45013. private _adapterSupportedExtensions;
  45014. private _device;
  45015. private _deviceEnabledExtensions;
  45016. private _context;
  45017. private _swapChain;
  45018. private _swapChainTexture;
  45019. private _mainPassSampleCount;
  45020. private _textureHelper;
  45021. private _bufferManager;
  45022. private _shaderManager;
  45023. private _cacheSampler;
  45024. private _cacheRenderPipeline;
  45025. private _emptyVertexBuffer;
  45026. private _lastCachedWrapU;
  45027. private _lastCachedWrapV;
  45028. private _lastCachedWrapR;
  45029. private _mrtAttachments;
  45030. private _counters;
  45031. private _mainTexture;
  45032. private _depthTexture;
  45033. private _mainTextureExtends;
  45034. private _depthTextureFormat;
  45035. private _colorFormat;
  45036. private _uploadEncoder;
  45037. private _renderEncoder;
  45038. private _renderTargetEncoder;
  45039. private _commandBuffers;
  45040. private _currentRenderPass;
  45041. private _mainRenderPassWrapper;
  45042. private _rttRenderPassWrapper;
  45043. private _pendingDebugCommands;
  45044. private _currentVertexBuffers;
  45045. private _currentOverrideVertexBuffers;
  45046. private _currentIndexBuffer;
  45047. private __colorWrite;
  45048. private _uniformsBuffers;
  45049. private _forceEnableEffect;
  45050. /** @hidden */
  45051. dbgShowShaderCode: boolean;
  45052. /** @hidden */
  45053. dbgSanityChecks: boolean;
  45054. /** @hidden */
  45055. dbgGenerateLogs: boolean;
  45056. /** @hidden */
  45057. dbgVerboseLogsForFirstFrames: boolean;
  45058. /** @hidden */
  45059. dbgVerboseLogsNumFrames: number;
  45060. /** @hidden */
  45061. dbgShowWarningsNotImplemented: boolean;
  45062. /**
  45063. * Sets this to true to disable the cache for the samplers. You should do it only for testing purpose!
  45064. */
  45065. get disableCacheSamplers(): boolean;
  45066. set disableCacheSamplers(disable: boolean);
  45067. /**
  45068. * Sets this to true to disable the cache for the render pipelines. You should do it only for testing purpose!
  45069. */
  45070. get disableCacheRenderPipelines(): boolean;
  45071. set disableCacheRenderPipelines(disable: boolean);
  45072. /**
  45073. * Gets a boolean indicating if the engine can be instanciated (ie. if a WebGPU context can be found)
  45074. * @returns true if the engine can be created
  45075. */
  45076. static get IsSupported(): boolean;
  45077. /**
  45078. * Gets a boolean indicating that the engine supports uniform buffers
  45079. */
  45080. get supportsUniformBuffers(): boolean;
  45081. /** Gets the supported extensions by the WebGPU adapter */
  45082. get supportedExtensions(): Immutable<GPUExtensionName[]>;
  45083. /** Gets the currently enabled extensions on the WebGPU device */
  45084. get enabledExtensions(): Immutable<GPUExtensionName[]>;
  45085. /**
  45086. * Returns the name of the engine
  45087. */
  45088. get name(): string;
  45089. /**
  45090. * Returns a string describing the current engine
  45091. */
  45092. get description(): string;
  45093. /**
  45094. * Returns the version of the engine
  45095. */
  45096. get version(): number;
  45097. /**
  45098. * Create a new instance of the gpu engine asynchronously
  45099. * @param canvas Defines the canvas to use to display the result
  45100. * @param options Defines the options passed to the engine to create the GPU context dependencies
  45101. * @returns a promise that resolves with the created engine
  45102. */
  45103. static CreateAsync(canvas: HTMLCanvasElement, options?: WebGPUEngineOptions): Promise<WebGPUEngine>;
  45104. /**
  45105. * Create a new instance of the gpu engine.
  45106. * @param canvas Defines the canvas to use to display the result
  45107. * @param options Defines the options passed to the engine to create the GPU context dependencies
  45108. */
  45109. constructor(canvas: HTMLCanvasElement, options?: WebGPUEngineOptions);
  45110. /**
  45111. * Initializes the WebGPU context and dependencies.
  45112. * @param glslangOptions Defines the GLSLang compiler options if necessary
  45113. * @returns a promise notifying the readiness of the engine.
  45114. */
  45115. initAsync(glslangOptions?: GlslangOptions): Promise<void>;
  45116. private _initGlslang;
  45117. private _initializeLimits;
  45118. private _initializeContextAndSwapChain;
  45119. private _initializeMainAttachments;
  45120. /**
  45121. * Force a specific size of the canvas
  45122. * @param width defines the new canvas' width
  45123. * @param height defines the new canvas' height
  45124. * @param forceSetSize true to force setting the sizes of the underlying canvas
  45125. * @returns true if the size was changed
  45126. */
  45127. setSize(width: number, height: number, forceSetSize?: boolean): boolean;
  45128. /**
  45129. * Gets a shader processor implementation fitting with the current engine type.
  45130. * @returns The shader processor implementation.
  45131. */
  45132. protected _getShaderProcessor(): Nullable<IShaderProcessor>;
  45133. /** @hidden */
  45134. _getShaderProcessingContext(): Nullable<ShaderProcessingContext>;
  45135. /**
  45136. * Force the entire cache to be cleared
  45137. * You should not have to use this function unless your engine needs to share the WebGPU context with another engine
  45138. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  45139. */
  45140. wipeCaches(bruteForce?: boolean): void;
  45141. /**
  45142. * Enable or disable color writing
  45143. * @param enable defines the state to set
  45144. */
  45145. setColorWrite(enable: boolean): void;
  45146. /**
  45147. * Gets a boolean indicating if color writing is enabled
  45148. * @returns the current color writing state
  45149. */
  45150. getColorWrite(): boolean;
  45151. private _viewportsCurrent;
  45152. private _resetCurrentViewport;
  45153. private _applyViewport;
  45154. /** @hidden */
  45155. _viewport(x: number, y: number, width: number, height: number): void;
  45156. private _scissorsCurrent;
  45157. protected _scissorCached: {
  45158. x: number;
  45159. y: number;
  45160. z: number;
  45161. w: number;
  45162. };
  45163. private _resetCurrentScissor;
  45164. private _applyScissor;
  45165. private _scissorIsActive;
  45166. enableScissor(x: number, y: number, width: number, height: number): void;
  45167. disableScissor(): void;
  45168. /**
  45169. * Clear the current render buffer or the current render target (if any is set up)
  45170. * @param color defines the color to use
  45171. * @param backBuffer defines if the back buffer must be cleared
  45172. * @param depth defines if the depth buffer must be cleared
  45173. * @param stencil defines if the stencil buffer must be cleared
  45174. */
  45175. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  45176. /**
  45177. * Clears a list of attachments
  45178. * @param attachments list of the attachments
  45179. * @param colorMain clear color for the main attachment (the first one)
  45180. * @param colorOthers clear color for the other attachments
  45181. * @param clearDepth true to clear the depth buffer. Used only for the first attachment
  45182. * @param clearStencil true to clear the stencil buffer. Used only for the first attachment
  45183. */
  45184. clearAttachments(attachments: number[], colorMain: Nullable<IColor4Like>, colorOthers: Nullable<IColor4Like>, clearDepth: boolean, clearStencil: boolean): void;
  45185. /**
  45186. * Creates a vertex buffer
  45187. * @param data the data for the vertex buffer
  45188. * @returns the new buffer
  45189. */
  45190. createVertexBuffer(data: DataArray): DataBuffer;
  45191. /**
  45192. * Creates a vertex buffer
  45193. * @param data the data for the dynamic vertex buffer
  45194. * @returns the new buffer
  45195. */
  45196. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  45197. /**
  45198. * Updates a vertex buffer.
  45199. * @param vertexBuffer the vertex buffer to update
  45200. * @param data the data used to update the vertex buffer
  45201. * @param byteOffset the byte offset of the data
  45202. * @param byteLength the byte length of the data
  45203. */
  45204. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  45205. /**
  45206. * Creates a new index buffer
  45207. * @param indices defines the content of the index buffer
  45208. * @param updatable defines if the index buffer must be updatable - not used in WebGPU
  45209. * @returns a new buffer
  45210. */
  45211. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  45212. /**
  45213. * Update an index buffer
  45214. * @param indexBuffer defines the target index buffer
  45215. * @param indices defines the data to update
  45216. * @param offset defines the offset in the target index buffer where update should start
  45217. */
  45218. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  45219. /** @hidden */
  45220. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  45221. /** @hidden */
  45222. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  45223. /**
  45224. * Bind a list of vertex buffers with the engine
  45225. * @param vertexBuffers defines the list of vertex buffers to bind
  45226. * @param indexBuffer defines the index buffer to bind
  45227. * @param effect defines the effect associated with the vertex buffers
  45228. * @param overrideVertexBuffers defines optional list of avertex buffers that overrides the entries in vertexBuffers
  45229. */
  45230. bindBuffers(vertexBuffers: {
  45231. [key: string]: Nullable<VertexBuffer>;
  45232. }, indexBuffer: Nullable<DataBuffer>, effect: Effect, overrideVertexBuffers?: {
  45233. [kind: string]: Nullable<VertexBuffer>;
  45234. }): void;
  45235. /** @hidden */
  45236. _releaseBuffer(buffer: DataBuffer): boolean;
  45237. createUniformBuffer(elements: FloatArray): DataBuffer;
  45238. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  45239. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  45240. bindUniformBufferBase(buffer: DataBuffer, location: number, name: string): void;
  45241. /**
  45242. * Create a new effect (used to store vertex/fragment shaders)
  45243. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  45244. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  45245. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  45246. * @param samplers defines an array of string used to represent textures
  45247. * @param defines defines the string containing the defines to use to compile the shaders
  45248. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  45249. * @param onCompiled defines a function to call when the effect creation is successful
  45250. * @param onError defines a function to call when the effect creation has failed
  45251. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  45252. * @returns the new Effect
  45253. */
  45254. createEffect(baseName: any, attributesNamesOrOptions: string[] | IEffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: string[], defines?: string, fallbacks?: EffectFallbacks, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any): Effect;
  45255. private _compileRawShaderToSpirV;
  45256. private _compileShaderToSpirV;
  45257. private _createPipelineStageDescriptor;
  45258. private _compileRawPipelineStageDescriptor;
  45259. private _compilePipelineStageDescriptor;
  45260. /** @hidden */
  45261. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  45262. /** @hidden */
  45263. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  45264. /**
  45265. * Creates a new pipeline context
  45266. * @param shaderProcessingContext defines the shader processing context used during the processing if available
  45267. * @returns the new pipeline
  45268. */
  45269. createPipelineContext(shaderProcessingContext: Nullable<ShaderProcessingContext>): IPipelineContext;
  45270. /** @hidden */
  45271. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rawVertexSourceCode: string, rawFragmentSourceCode: string, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>, key: string): void;
  45272. /**
  45273. * Gets the list of active attributes for a given WebGPU program
  45274. * @param pipelineContext defines the pipeline context to use
  45275. * @param attributesNames defines the list of attribute names to get
  45276. * @returns an array of indices indicating the offset of each attribute
  45277. */
  45278. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  45279. /**
  45280. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  45281. * @param effect defines the effect to activate
  45282. */
  45283. enableEffect(effect: Nullable<Effect>): void;
  45284. /** @hidden */
  45285. _releaseEffect(effect: Effect): void;
  45286. /**
  45287. * 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
  45288. */
  45289. releaseEffects(): void;
  45290. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  45291. /**
  45292. * Gets a boolean indicating that only power of 2 textures are supported
  45293. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  45294. */
  45295. get needPOTTextures(): boolean;
  45296. /** @hidden */
  45297. _createHardwareTexture(): HardwareTextureWrapper;
  45298. /** @hidden */
  45299. _releaseTexture(texture: InternalTexture): void;
  45300. /** @hidden */
  45301. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  45302. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  45303. /**
  45304. * Usually called from Texture.ts.
  45305. * Passed information to create a hardware texture
  45306. * @param url defines a value which contains one of the following:
  45307. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  45308. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  45309. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  45310. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  45311. * @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)
  45312. * @param scene needed for loading to the correct scene
  45313. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  45314. * @param onLoad optional callback to be called upon successful completion
  45315. * @param onError optional callback to be called upon failure
  45316. * @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
  45317. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  45318. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  45319. * @param forcedExtension defines the extension to use to pick the right loader
  45320. * @param mimeType defines an optional mime type
  45321. * @param loaderOptions options to be passed to the loader
  45322. * @returns a InternalTexture for assignment back into BABYLON.Texture
  45323. */
  45324. 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;
  45325. /** @hidden */
  45326. _setCubeMapTextureParams(texture: InternalTexture, loadMipmap: boolean): void;
  45327. /**
  45328. * Creates a cube texture
  45329. * @param rootUrl defines the url where the files to load is located
  45330. * @param scene defines the current scene
  45331. * @param files defines the list of files to load (1 per face)
  45332. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  45333. * @param onLoad defines an optional callback raised when the texture is loaded
  45334. * @param onError defines an optional callback raised if there is an issue to load the texture
  45335. * @param format defines the format of the data
  45336. * @param forcedExtension defines the extension to use to pick the right loader
  45337. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  45338. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  45339. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  45340. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  45341. * @param loaderOptions options to be passed to the loader
  45342. * @returns the cube texture as an InternalTexture
  45343. */
  45344. 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;
  45345. /**
  45346. * Creates a raw texture
  45347. * @param data defines the data to store in the texture
  45348. * @param width defines the width of the texture
  45349. * @param height defines the height of the texture
  45350. * @param format defines the format of the data
  45351. * @param generateMipMaps defines if the engine should generate the mip levels
  45352. * @param invertY defines if data must be stored with Y axis inverted
  45353. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  45354. * @param compression defines the compression used (null by default)
  45355. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  45356. * @returns the raw texture inside an InternalTexture
  45357. */
  45358. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  45359. /**
  45360. * Creates a new raw cube texture
  45361. * @param data defines the array of data to use to create each face
  45362. * @param size defines the size of the textures
  45363. * @param format defines the format of the data
  45364. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  45365. * @param generateMipMaps defines if the engine should generate the mip levels
  45366. * @param invertY defines if data must be stored with Y axis inverted
  45367. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  45368. * @param compression defines the compression used (null by default)
  45369. * @returns the cube texture as an InternalTexture
  45370. */
  45371. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  45372. /**
  45373. * Creates a new raw cube texture from a specified url
  45374. * @param url defines the url where the data is located
  45375. * @param scene defines the current scene
  45376. * @param size defines the size of the textures
  45377. * @param format defines the format of the data
  45378. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  45379. * @param noMipmap defines if the engine should avoid generating the mip levels
  45380. * @param callback defines a callback used to extract texture data from loaded data
  45381. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  45382. * @param onLoad defines a callback called when texture is loaded
  45383. * @param onError defines a callback called if there is an error
  45384. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  45385. * @param invertY defines if data must be stored with Y axis inverted
  45386. * @returns the cube texture as an InternalTexture
  45387. */
  45388. 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;
  45389. /**
  45390. * Creates a new raw 2D array texture
  45391. * @param data defines the data used to create the texture
  45392. * @param width defines the width of the texture
  45393. * @param height defines the height of the texture
  45394. * @param depth defines the number of layers of the texture
  45395. * @param format defines the format of the texture
  45396. * @param generateMipMaps defines if the engine must generate mip levels
  45397. * @param invertY defines if data must be stored with Y axis inverted
  45398. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  45399. * @param compression defines the compressed used (can be null)
  45400. * @param textureType defines the compressed used (can be null)
  45401. * @returns a new raw 2D array texture (stored in an InternalTexture)
  45402. */
  45403. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  45404. /**
  45405. * Creates a new raw 3D texture
  45406. * @param data defines the data used to create the texture
  45407. * @param width defines the width of the texture
  45408. * @param height defines the height of the texture
  45409. * @param depth defines the depth of the texture
  45410. * @param format defines the format of the texture
  45411. * @param generateMipMaps defines if the engine must generate mip levels
  45412. * @param invertY defines if data must be stored with Y axis inverted
  45413. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  45414. * @param compression defines the compressed used (can be null)
  45415. * @param textureType defines the compressed used (can be null)
  45416. * @returns a new raw 3D texture (stored in an InternalTexture)
  45417. */
  45418. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  45419. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  45420. /**
  45421. * Update the sampling mode of a given texture
  45422. * @param samplingMode defines the required sampling mode
  45423. * @param texture defines the texture to update
  45424. * @param generateMipMaps defines whether to generate mipmaps for the texture
  45425. */
  45426. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  45427. /**
  45428. * Update the sampling mode of a given texture
  45429. * @param texture defines the texture to update
  45430. * @param wrapU defines the texture wrap mode of the u coordinates
  45431. * @param wrapV defines the texture wrap mode of the v coordinates
  45432. * @param wrapR defines the texture wrap mode of the r coordinates
  45433. */
  45434. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  45435. /**
  45436. * Update the dimensions of a texture
  45437. * @param texture texture to update
  45438. * @param width new width of the texture
  45439. * @param height new height of the texture
  45440. * @param depth new depth of the texture
  45441. */
  45442. updateTextureDimensions(texture: InternalTexture, width: number, height: number, depth?: number): void;
  45443. private _setInternalTexture;
  45444. /**
  45445. * Sets a texture to the according uniform.
  45446. * @param channel The texture channel
  45447. * @param unused unused parameter
  45448. * @param texture The texture to apply
  45449. * @param name The name of the uniform in the effect
  45450. */
  45451. setTexture(channel: number, unused: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>, name: string): void;
  45452. /**
  45453. * Sets an array of texture to the WebGPU context
  45454. * @param channel defines the channel where the texture array must be set
  45455. * @param unused unused parameter
  45456. * @param textures defines the array of textures to bind
  45457. * @param name name of the channel
  45458. */
  45459. setTextureArray(channel: number, unused: Nullable<WebGLUniformLocation>, textures: BaseTexture[], name: string): void;
  45460. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean, name?: string, baseName?: string, textureIndex?: number): boolean;
  45461. /** @hidden */
  45462. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  45463. /** @hidden */
  45464. _bindTexture(channel: number, texture: InternalTexture, name: string): void;
  45465. private _generateMipmaps;
  45466. /**
  45467. * Update the content of a texture
  45468. * @param texture defines the texture to update
  45469. * @param canvas defines the source containing the data
  45470. * @param invertY defines if data must be stored with Y axis inverted
  45471. * @param premulAlpha defines if alpha is stored as premultiplied
  45472. * @param format defines the format of the data
  45473. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  45474. */
  45475. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  45476. /**
  45477. * Update a portion of an internal texture
  45478. * @param texture defines the texture to update
  45479. * @param imageData defines the data to store into the texture
  45480. * @param xOffset defines the x coordinates of the update rectangle
  45481. * @param yOffset defines the y coordinates of the update rectangle
  45482. * @param width defines the width of the update rectangle
  45483. * @param height defines the height of the update rectangle
  45484. * @param faceIndex defines the face index if texture is a cube (0 by default)
  45485. * @param lod defines the lod level to update (0 by default)
  45486. */
  45487. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  45488. /**
  45489. * Update a video texture
  45490. * @param texture defines the texture to update
  45491. * @param video defines the video element to use
  45492. * @param invertY defines if data must be stored with Y axis inverted
  45493. */
  45494. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  45495. /** @hidden */
  45496. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45497. /** @hidden */
  45498. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  45499. /** @hidden */
  45500. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45501. /** @hidden */
  45502. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  45503. /**
  45504. * Update a raw texture
  45505. * @param texture defines the texture to update
  45506. * @param bufferView defines the data to store in the texture
  45507. * @param format defines the format of the data
  45508. * @param invertY defines if data must be stored with Y axis inverted
  45509. * @param compression defines the compression used (null by default)
  45510. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  45511. */
  45512. updateRawTexture(texture: Nullable<InternalTexture>, bufferView: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  45513. /**
  45514. * Update a raw cube texture
  45515. * @param texture defines the texture to udpdate
  45516. * @param bufferView defines the data to store
  45517. * @param format defines the data format
  45518. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  45519. * @param invertY defines if data must be stored with Y axis inverted
  45520. * @param compression defines the compression used (null by default)
  45521. * @param level defines which level of the texture to update
  45522. */
  45523. updateRawCubeTexture(texture: InternalTexture, bufferView: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  45524. /**
  45525. * Update a raw 2D array texture
  45526. * @param texture defines the texture to update
  45527. * @param bufferView defines the data to store
  45528. * @param format defines the data format
  45529. * @param invertY defines if data must be stored with Y axis inverted
  45530. * @param compression defines the used compression (can be null)
  45531. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  45532. */
  45533. updateRawTexture2DArray(texture: InternalTexture, bufferView: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  45534. /**
  45535. * Update a raw 3D texture
  45536. * @param texture defines the texture to update
  45537. * @param bufferView defines the data to store
  45538. * @param format defines the data format
  45539. * @param invertY defines if data must be stored with Y axis inverted
  45540. * @param compression defines the used compression (can be null)
  45541. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  45542. */
  45543. updateRawTexture3D(texture: InternalTexture, bufferView: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  45544. /**
  45545. * Reads pixels from the current frame buffer. Please note that this function can be slow
  45546. * @param x defines the x coordinate of the rectangle where pixels must be read
  45547. * @param y defines the y coordinate of the rectangle where pixels must be read
  45548. * @param width defines the width of the rectangle where pixels must be read
  45549. * @param height defines the height of the rectangle where pixels must be read
  45550. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  45551. * @param flushRenderer true to flush the renderer from the pending commands before reading the pixels
  45552. * @returns a ArrayBufferView promise (Uint8Array) containing RGBA colors
  45553. */
  45554. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean, flushRenderer?: boolean): Promise<ArrayBufferView>;
  45555. /** @hidden */
  45556. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>, flushRenderer?: boolean): Promise<ArrayBufferView>;
  45557. /** @hidden */
  45558. _readTexturePixelsSync(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>, flushRenderer?: boolean): ArrayBufferView;
  45559. /**
  45560. * Creates a new render target texture
  45561. * @param size defines the size of the texture
  45562. * @param options defines the options used to create the texture
  45563. * @returns a new render target texture stored in an InternalTexture
  45564. */
  45565. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  45566. /**
  45567. * Create a multi render target texture
  45568. * @param size defines the size of the texture
  45569. * @param options defines the creation options
  45570. * @returns the cube texture as an InternalTexture
  45571. */
  45572. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  45573. /**
  45574. * Creates a new render target cube texture
  45575. * @param size defines the size of the texture
  45576. * @param options defines the options used to create the texture
  45577. * @returns a new render target cube texture stored in an InternalTexture
  45578. */
  45579. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  45580. /** @hidden */
  45581. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  45582. width: number;
  45583. height: number;
  45584. layers?: number;
  45585. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number, samples?: number): void;
  45586. /** @hidden */
  45587. _createDepthStencilTexture(size: number | {
  45588. width: number;
  45589. height: number;
  45590. layers?: number;
  45591. }, options: DepthTextureCreationOptions): InternalTexture;
  45592. /** @hidden */
  45593. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  45594. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  45595. /**
  45596. * Update the sample count for a given multiple render target texture
  45597. * @param textures defines the textures to update
  45598. * @param samples defines the sample count to set
  45599. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  45600. */
  45601. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  45602. /**
  45603. * Begin a new frame
  45604. */
  45605. beginFrame(): void;
  45606. /**
  45607. * End the current frame
  45608. */
  45609. endFrame(): void;
  45610. /**
  45611. * Force a WebGPU flush (ie. a flush of all waiting commands)
  45612. */
  45613. flushFramebuffer(): void;
  45614. private _startRenderTargetRenderPass;
  45615. private _endRenderTargetRenderPass;
  45616. private _getCurrentRenderPass;
  45617. private _startMainRenderPass;
  45618. private _endMainRenderPass;
  45619. /**
  45620. * Restores the WebGPU state to only draw on the main color attachment
  45621. */
  45622. restoreSingleAttachment(): void;
  45623. /**
  45624. * Creates a layout object to draw/clear on specific textures in a MRT
  45625. * @param textureStatus textureStatus[i] indicates if the i-th is active
  45626. * @returns A layout to be fed to the engine, calling `bindAttachments`.
  45627. */
  45628. buildTextureLayout(textureStatus: boolean[]): number[];
  45629. /**
  45630. * Select a subsets of attachments to draw to.
  45631. * @param attachments index of attachments
  45632. */
  45633. bindAttachments(attachments: number[]): void;
  45634. /**
  45635. * Binds the frame buffer to the specified texture.
  45636. * @param texture The texture to render to or null for the default canvas
  45637. * @param faceIndex The face of the texture to render to in case of cube texture
  45638. * @param requiredWidth The width of the target to render to
  45639. * @param requiredHeight The height of the target to render to
  45640. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  45641. * @param lodLevel defines the lod level to bind to the frame buffer
  45642. * @param layer defines the 2d array index to bind to frame buffer to
  45643. */
  45644. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  45645. /**
  45646. * Unbind the current render target texture from the WebGPU context
  45647. * @param texture defines the render target texture to unbind
  45648. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  45649. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  45650. */
  45651. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  45652. /**
  45653. * Unbind a list of render target textures from the WebGPU context
  45654. * @param textures defines the render target textures to unbind
  45655. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  45656. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  45657. */
  45658. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  45659. /**
  45660. * Unbind the current render target and bind the default framebuffer
  45661. */
  45662. restoreDefaultFramebuffer(): void;
  45663. setZOffset(value: number): void;
  45664. private _setColorFormat;
  45665. private _setDepthTextureFormat;
  45666. setDepthBuffer(enable: boolean): void;
  45667. setDepthWrite(enable: boolean): void;
  45668. setStencilBuffer(enable: boolean): void;
  45669. setStencilMask(mask: number): void;
  45670. setStencilFunction(stencilFunc: number): void;
  45671. setStencilFunctionReference(reference: number): void;
  45672. setStencilFunctionMask(mask: number): void;
  45673. setStencilOperationFail(operation: number): void;
  45674. setStencilOperationDepthFail(operation: number): void;
  45675. setStencilOperationPass(operation: number): void;
  45676. setDitheringState(value: boolean): void;
  45677. setRasterizerState(value: boolean): void;
  45678. setDepthFunction(depthFunc: number): void;
  45679. setDepthFunctionToGreater(): void;
  45680. setDepthFunctionToGreaterOrEqual(): void;
  45681. setDepthFunctionToLess(): void;
  45682. setDepthFunctionToLessOrEqual(): void;
  45683. /**
  45684. * Set various states to the context
  45685. * @param culling defines backface culling state
  45686. * @param zOffset defines the value to apply to zOffset (0 by default)
  45687. * @param force defines if states must be applied even if cache is up to date
  45688. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  45689. */
  45690. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  45691. /**
  45692. * Sets the current alpha mode
  45693. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  45694. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  45695. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  45696. */
  45697. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  45698. /**
  45699. * Sets the current alpha equation
  45700. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  45701. */
  45702. setAlphaEquation(equation: number): void;
  45703. private _getBindGroupsToRender;
  45704. private _bindVertexInputs;
  45705. private _setRenderBindGroups;
  45706. private _setRenderPipeline;
  45707. /**
  45708. * Draw a list of indexed primitives
  45709. * @param fillMode defines the primitive to use
  45710. * @param indexStart defines the starting index
  45711. * @param indexCount defines the number of index to draw
  45712. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  45713. */
  45714. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  45715. /**
  45716. * Draw a list of unindexed primitives
  45717. * @param fillMode defines the primitive to use
  45718. * @param verticesStart defines the index of first vertex to draw
  45719. * @param verticesCount defines the count of vertices to draw
  45720. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  45721. */
  45722. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  45723. private _bundleEncoder;
  45724. /**
  45725. * Start recording all the gpu calls into a bundle.
  45726. */
  45727. startRecordBundle(): void;
  45728. /**
  45729. * Stops recording the bundle.
  45730. * @returns the recorded bundle
  45731. */
  45732. stopRecordBundle(): GPURenderBundle;
  45733. /**
  45734. * Execute the previously recorded bundle.
  45735. * @param bundles defines the bundle to replay
  45736. */
  45737. executeBundles(bundles: GPURenderBundle[]): void;
  45738. /**
  45739. * Dispose and release all associated resources
  45740. */
  45741. dispose(): void;
  45742. /**
  45743. * Gets the current render width
  45744. * @param useScreen defines if screen size must be used (or the current render target if any)
  45745. * @returns a number defining the current render width
  45746. */
  45747. getRenderWidth(useScreen?: boolean): number;
  45748. /**
  45749. * Gets the current render height
  45750. * @param useScreen defines if screen size must be used (or the current render target if any)
  45751. * @returns a number defining the current render height
  45752. */
  45753. getRenderHeight(useScreen?: boolean): number;
  45754. /**
  45755. * Gets the HTML canvas attached with the current WebGPU context
  45756. * @returns a HTML canvas
  45757. */
  45758. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  45759. /** @hidden */
  45760. _debugPushGroup(groupName: string, targetObject?: number): void;
  45761. /** @hidden */
  45762. _debugPopGroup(targetObject?: number): void;
  45763. /** @hidden */
  45764. _debugInsertMarker(text: string, targetObject?: number): void;
  45765. private _debugFlushPendingCommands;
  45766. /**
  45767. * Get the current error code of the WebGPU context
  45768. * @returns the error code
  45769. */
  45770. getError(): number;
  45771. /** @hidden */
  45772. bindSamplers(effect: Effect): void;
  45773. /** @hidden */
  45774. _bindTextureDirectly(target: number, texture: InternalTexture, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  45775. /** @hidden */
  45776. _releaseFramebufferObjects(texture: InternalTexture): void;
  45777. /** @hidden */
  45778. applyStates(): void;
  45779. /**
  45780. * Gets a boolean indicating if all created effects are ready
  45781. * @returns always true - No parallel shader compilation
  45782. */
  45783. areAllEffectsReady(): boolean;
  45784. /** @hidden */
  45785. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  45786. /** @hidden */
  45787. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  45788. /** @hidden */
  45789. _getUnpackAlignement(): number;
  45790. /** @hidden */
  45791. _unpackFlipY(value: boolean): void;
  45792. /** @hidden */
  45793. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  45794. min: number;
  45795. mag: number;
  45796. };
  45797. /** @hidden */
  45798. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  45799. /** @hidden */
  45800. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  45801. /** @hidden */
  45802. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  45803. /** @hidden */
  45804. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  45805. /** @hidden */
  45806. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  45807. /** @hidden */
  45808. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  45809. /** @hidden */
  45810. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  45811. /** @hidden */
  45812. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  45813. /** @hidden */
  45814. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  45815. /** @hidden */
  45816. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  45817. /** @hidden */
  45818. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  45819. /** @hidden */
  45820. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  45821. /** @hidden */
  45822. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  45823. /** @hidden */
  45824. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  45825. /** @hidden */
  45826. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  45827. /** @hidden */
  45828. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  45829. /** @hidden */
  45830. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  45831. }
  45832. }
  45833. declare module BABYLON {
  45834. /**
  45835. * Define an interface for all classes that will hold resources
  45836. */
  45837. export interface IDisposable {
  45838. /**
  45839. * Releases all held resources
  45840. */
  45841. dispose(): void;
  45842. }
  45843. /** Interface defining initialization parameters for Scene class */
  45844. export interface SceneOptions {
  45845. /**
  45846. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  45847. * It will improve performance when the number of geometries becomes important.
  45848. */
  45849. useGeometryUniqueIdsMap?: boolean;
  45850. /**
  45851. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  45852. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  45853. */
  45854. useMaterialMeshMap?: boolean;
  45855. /**
  45856. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  45857. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  45858. */
  45859. useClonedMeshMap?: boolean;
  45860. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  45861. virtual?: boolean;
  45862. }
  45863. /**
  45864. * Represents a scene to be rendered by the engine.
  45865. * @see https://doc.babylonjs.com/features/scene
  45866. */
  45867. export class Scene extends AbstractScene implements IAnimatable, IClipPlanesHolder {
  45868. /** The fog is deactivated */
  45869. static readonly FOGMODE_NONE: number;
  45870. /** The fog density is following an exponential function */
  45871. static readonly FOGMODE_EXP: number;
  45872. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  45873. static readonly FOGMODE_EXP2: number;
  45874. /** The fog density is following a linear function. */
  45875. static readonly FOGMODE_LINEAR: number;
  45876. /**
  45877. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  45878. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45879. */
  45880. static MinDeltaTime: number;
  45881. /**
  45882. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  45883. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45884. */
  45885. static MaxDeltaTime: number;
  45886. /**
  45887. * Factory used to create the default material.
  45888. * @param name The name of the material to create
  45889. * @param scene The scene to create the material for
  45890. * @returns The default material
  45891. */
  45892. static DefaultMaterialFactory(scene: Scene): Material;
  45893. /**
  45894. * Factory used to create the a collision coordinator.
  45895. * @returns The collision coordinator
  45896. */
  45897. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  45898. /** @hidden */
  45899. _inputManager: InputManager;
  45900. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  45901. cameraToUseForPointers: Nullable<Camera>;
  45902. /** @hidden */
  45903. readonly _isScene: boolean;
  45904. /** @hidden */
  45905. _blockEntityCollection: boolean;
  45906. /**
  45907. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  45908. */
  45909. autoClear: boolean;
  45910. /**
  45911. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  45912. */
  45913. autoClearDepthAndStencil: boolean;
  45914. /**
  45915. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  45916. */
  45917. clearColor: Color4;
  45918. /**
  45919. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  45920. */
  45921. ambientColor: Color3;
  45922. /**
  45923. * This is use to store the default BRDF lookup for PBR materials in your scene.
  45924. * It should only be one of the following (if not the default embedded one):
  45925. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  45926. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  45927. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  45928. * The material properties need to be setup according to the type of texture in use.
  45929. */
  45930. environmentBRDFTexture: BaseTexture;
  45931. /**
  45932. * Texture used in all pbr material as the reflection texture.
  45933. * As in the majority of the scene they are the same (exception for multi room and so on),
  45934. * this is easier to reference from here than from all the materials.
  45935. */
  45936. get environmentTexture(): Nullable<BaseTexture>;
  45937. /**
  45938. * Texture used in all pbr material as the reflection texture.
  45939. * As in the majority of the scene they are the same (exception for multi room and so on),
  45940. * this is easier to set here than in all the materials.
  45941. */
  45942. set environmentTexture(value: Nullable<BaseTexture>);
  45943. /** @hidden */
  45944. protected _environmentIntensity: number;
  45945. /**
  45946. * Intensity of the environment in all pbr material.
  45947. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  45948. * As in the majority of the scene they are the same (exception for multi room and so on),
  45949. * this is easier to reference from here than from all the materials.
  45950. */
  45951. get environmentIntensity(): number;
  45952. /**
  45953. * Intensity of the environment in all pbr material.
  45954. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  45955. * As in the majority of the scene they are the same (exception for multi room and so on),
  45956. * this is easier to set here than in all the materials.
  45957. */
  45958. set environmentIntensity(value: number);
  45959. /** @hidden */
  45960. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  45961. /**
  45962. * Default image processing configuration used either in the rendering
  45963. * Forward main pass or through the imageProcessingPostProcess if present.
  45964. * As in the majority of the scene they are the same (exception for multi camera),
  45965. * this is easier to reference from here than from all the materials and post process.
  45966. *
  45967. * No setter as we it is a shared configuration, you can set the values instead.
  45968. */
  45969. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  45970. private _forceWireframe;
  45971. /**
  45972. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  45973. */
  45974. set forceWireframe(value: boolean);
  45975. get forceWireframe(): boolean;
  45976. private _skipFrustumClipping;
  45977. /**
  45978. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  45979. */
  45980. set skipFrustumClipping(value: boolean);
  45981. get skipFrustumClipping(): boolean;
  45982. private _forcePointsCloud;
  45983. /**
  45984. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  45985. */
  45986. set forcePointsCloud(value: boolean);
  45987. get forcePointsCloud(): boolean;
  45988. /**
  45989. * Gets or sets the active clipplane 1
  45990. */
  45991. clipPlane: Nullable<Plane>;
  45992. /**
  45993. * Gets or sets the active clipplane 2
  45994. */
  45995. clipPlane2: Nullable<Plane>;
  45996. /**
  45997. * Gets or sets the active clipplane 3
  45998. */
  45999. clipPlane3: Nullable<Plane>;
  46000. /**
  46001. * Gets or sets the active clipplane 4
  46002. */
  46003. clipPlane4: Nullable<Plane>;
  46004. /**
  46005. * Gets or sets the active clipplane 5
  46006. */
  46007. clipPlane5: Nullable<Plane>;
  46008. /**
  46009. * Gets or sets the active clipplane 6
  46010. */
  46011. clipPlane6: Nullable<Plane>;
  46012. /**
  46013. * Gets or sets a boolean indicating if animations are enabled
  46014. */
  46015. animationsEnabled: boolean;
  46016. private _animationPropertiesOverride;
  46017. /**
  46018. * Gets or sets the animation properties override
  46019. */
  46020. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  46021. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  46022. /**
  46023. * Gets or sets a boolean indicating if a constant deltatime has to be used
  46024. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  46025. */
  46026. useConstantAnimationDeltaTime: boolean;
  46027. /**
  46028. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  46029. * Please note that it requires to run a ray cast through the scene on every frame
  46030. */
  46031. constantlyUpdateMeshUnderPointer: boolean;
  46032. /**
  46033. * Defines the HTML cursor to use when hovering over interactive elements
  46034. */
  46035. hoverCursor: string;
  46036. /**
  46037. * Defines the HTML default cursor to use (empty by default)
  46038. */
  46039. defaultCursor: string;
  46040. /**
  46041. * Defines whether cursors are handled by the scene.
  46042. */
  46043. doNotHandleCursors: boolean;
  46044. /**
  46045. * This is used to call preventDefault() on pointer down
  46046. * in order to block unwanted artifacts like system double clicks
  46047. */
  46048. preventDefaultOnPointerDown: boolean;
  46049. /**
  46050. * This is used to call preventDefault() on pointer up
  46051. * in order to block unwanted artifacts like system double clicks
  46052. */
  46053. preventDefaultOnPointerUp: boolean;
  46054. /**
  46055. * Gets or sets user defined metadata
  46056. */
  46057. metadata: any;
  46058. /**
  46059. * For internal use only. Please do not use.
  46060. */
  46061. reservedDataStore: any;
  46062. /**
  46063. * Gets the name of the plugin used to load this scene (null by default)
  46064. */
  46065. loadingPluginName: string;
  46066. /**
  46067. * Use this array to add regular expressions used to disable offline support for specific urls
  46068. */
  46069. disableOfflineSupportExceptionRules: RegExp[];
  46070. /**
  46071. * An event triggered when the scene is disposed.
  46072. */
  46073. onDisposeObservable: Observable<Scene>;
  46074. private _onDisposeObserver;
  46075. /** Sets a function to be executed when this scene is disposed. */
  46076. set onDispose(callback: () => void);
  46077. /**
  46078. * An event triggered before rendering the scene (right after animations and physics)
  46079. */
  46080. onBeforeRenderObservable: Observable<Scene>;
  46081. private _onBeforeRenderObserver;
  46082. /** Sets a function to be executed before rendering this scene */
  46083. set beforeRender(callback: Nullable<() => void>);
  46084. /**
  46085. * An event triggered after rendering the scene
  46086. */
  46087. onAfterRenderObservable: Observable<Scene>;
  46088. /**
  46089. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  46090. */
  46091. onAfterRenderCameraObservable: Observable<Camera>;
  46092. private _onAfterRenderObserver;
  46093. /** Sets a function to be executed after rendering this scene */
  46094. set afterRender(callback: Nullable<() => void>);
  46095. /**
  46096. * An event triggered before animating the scene
  46097. */
  46098. onBeforeAnimationsObservable: Observable<Scene>;
  46099. /**
  46100. * An event triggered after animations processing
  46101. */
  46102. onAfterAnimationsObservable: Observable<Scene>;
  46103. /**
  46104. * An event triggered before draw calls are ready to be sent
  46105. */
  46106. onBeforeDrawPhaseObservable: Observable<Scene>;
  46107. /**
  46108. * An event triggered after draw calls have been sent
  46109. */
  46110. onAfterDrawPhaseObservable: Observable<Scene>;
  46111. /**
  46112. * An event triggered when the scene is ready
  46113. */
  46114. onReadyObservable: Observable<Scene>;
  46115. /**
  46116. * An event triggered before rendering a camera
  46117. */
  46118. onBeforeCameraRenderObservable: Observable<Camera>;
  46119. private _onBeforeCameraRenderObserver;
  46120. /** Sets a function to be executed before rendering a camera*/
  46121. set beforeCameraRender(callback: () => void);
  46122. /**
  46123. * An event triggered after rendering a camera
  46124. */
  46125. onAfterCameraRenderObservable: Observable<Camera>;
  46126. private _onAfterCameraRenderObserver;
  46127. /** Sets a function to be executed after rendering a camera*/
  46128. set afterCameraRender(callback: () => void);
  46129. /**
  46130. * An event triggered when active meshes evaluation is about to start
  46131. */
  46132. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  46133. /**
  46134. * An event triggered when active meshes evaluation is done
  46135. */
  46136. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  46137. /**
  46138. * An event triggered when particles rendering is about to start
  46139. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  46140. */
  46141. onBeforeParticlesRenderingObservable: Observable<Scene>;
  46142. /**
  46143. * An event triggered when particles rendering is done
  46144. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  46145. */
  46146. onAfterParticlesRenderingObservable: Observable<Scene>;
  46147. /**
  46148. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  46149. */
  46150. onDataLoadedObservable: Observable<Scene>;
  46151. /**
  46152. * An event triggered when a camera is created
  46153. */
  46154. onNewCameraAddedObservable: Observable<Camera>;
  46155. /**
  46156. * An event triggered when a camera is removed
  46157. */
  46158. onCameraRemovedObservable: Observable<Camera>;
  46159. /**
  46160. * An event triggered when a light is created
  46161. */
  46162. onNewLightAddedObservable: Observable<Light>;
  46163. /**
  46164. * An event triggered when a light is removed
  46165. */
  46166. onLightRemovedObservable: Observable<Light>;
  46167. /**
  46168. * An event triggered when a geometry is created
  46169. */
  46170. onNewGeometryAddedObservable: Observable<Geometry>;
  46171. /**
  46172. * An event triggered when a geometry is removed
  46173. */
  46174. onGeometryRemovedObservable: Observable<Geometry>;
  46175. /**
  46176. * An event triggered when a transform node is created
  46177. */
  46178. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  46179. /**
  46180. * An event triggered when a transform node is removed
  46181. */
  46182. onTransformNodeRemovedObservable: Observable<TransformNode>;
  46183. /**
  46184. * An event triggered when a mesh is created
  46185. */
  46186. onNewMeshAddedObservable: Observable<AbstractMesh>;
  46187. /**
  46188. * An event triggered when a mesh is removed
  46189. */
  46190. onMeshRemovedObservable: Observable<AbstractMesh>;
  46191. /**
  46192. * An event triggered when a skeleton is created
  46193. */
  46194. onNewSkeletonAddedObservable: Observable<Skeleton>;
  46195. /**
  46196. * An event triggered when a skeleton is removed
  46197. */
  46198. onSkeletonRemovedObservable: Observable<Skeleton>;
  46199. /**
  46200. * An event triggered when a material is created
  46201. */
  46202. onNewMaterialAddedObservable: Observable<Material>;
  46203. /**
  46204. * An event triggered when a multi material is created
  46205. */
  46206. onNewMultiMaterialAddedObservable: Observable<MultiMaterial>;
  46207. /**
  46208. * An event triggered when a material is removed
  46209. */
  46210. onMaterialRemovedObservable: Observable<Material>;
  46211. /**
  46212. * An event triggered when a multi material is removed
  46213. */
  46214. onMultiMaterialRemovedObservable: Observable<MultiMaterial>;
  46215. /**
  46216. * An event triggered when a texture is created
  46217. */
  46218. onNewTextureAddedObservable: Observable<BaseTexture>;
  46219. /**
  46220. * An event triggered when a texture is removed
  46221. */
  46222. onTextureRemovedObservable: Observable<BaseTexture>;
  46223. /**
  46224. * An event triggered when render targets are about to be rendered
  46225. * Can happen multiple times per frame.
  46226. */
  46227. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  46228. /**
  46229. * An event triggered when render targets were rendered.
  46230. * Can happen multiple times per frame.
  46231. */
  46232. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  46233. /**
  46234. * An event triggered before calculating deterministic simulation step
  46235. */
  46236. onBeforeStepObservable: Observable<Scene>;
  46237. /**
  46238. * An event triggered after calculating deterministic simulation step
  46239. */
  46240. onAfterStepObservable: Observable<Scene>;
  46241. /**
  46242. * An event triggered when the activeCamera property is updated
  46243. */
  46244. onActiveCameraChanged: Observable<Scene>;
  46245. /**
  46246. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  46247. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  46248. * 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)
  46249. */
  46250. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  46251. /**
  46252. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  46253. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  46254. * 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)
  46255. */
  46256. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  46257. /**
  46258. * This Observable will when a mesh has been imported into the scene.
  46259. */
  46260. onMeshImportedObservable: Observable<AbstractMesh>;
  46261. /**
  46262. * This Observable will when an animation file has been imported into the scene.
  46263. */
  46264. onAnimationFileImportedObservable: Observable<Scene>;
  46265. /**
  46266. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  46267. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  46268. */
  46269. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  46270. /** @hidden */
  46271. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  46272. /**
  46273. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  46274. */
  46275. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  46276. /**
  46277. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  46278. */
  46279. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  46280. /**
  46281. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  46282. */
  46283. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  46284. /** Callback called when a pointer move is detected */
  46285. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  46286. /** Callback called when a pointer down is detected */
  46287. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  46288. /** Callback called when a pointer up is detected */
  46289. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  46290. /** Callback called when a pointer pick is detected */
  46291. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  46292. /**
  46293. * 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).
  46294. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  46295. */
  46296. onPrePointerObservable: Observable<PointerInfoPre>;
  46297. /**
  46298. * Observable event triggered each time an input event is received from the rendering canvas
  46299. */
  46300. onPointerObservable: Observable<PointerInfo>;
  46301. /**
  46302. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  46303. */
  46304. get unTranslatedPointer(): Vector2;
  46305. /**
  46306. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  46307. */
  46308. static get DragMovementThreshold(): number;
  46309. static set DragMovementThreshold(value: number);
  46310. /**
  46311. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  46312. */
  46313. static get LongPressDelay(): number;
  46314. static set LongPressDelay(value: number);
  46315. /**
  46316. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  46317. */
  46318. static get DoubleClickDelay(): number;
  46319. static set DoubleClickDelay(value: number);
  46320. /** If you need to check double click without raising a single click at first click, enable this flag */
  46321. static get ExclusiveDoubleClickMode(): boolean;
  46322. static set ExclusiveDoubleClickMode(value: boolean);
  46323. /** @hidden */
  46324. _mirroredCameraPosition: Nullable<Vector3>;
  46325. /**
  46326. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  46327. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  46328. */
  46329. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  46330. /**
  46331. * Observable event triggered each time an keyboard event is received from the hosting window
  46332. */
  46333. onKeyboardObservable: Observable<KeyboardInfo>;
  46334. private _useRightHandedSystem;
  46335. /**
  46336. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  46337. */
  46338. set useRightHandedSystem(value: boolean);
  46339. get useRightHandedSystem(): boolean;
  46340. private _timeAccumulator;
  46341. private _currentStepId;
  46342. private _currentInternalStep;
  46343. /**
  46344. * Sets the step Id used by deterministic lock step
  46345. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46346. * @param newStepId defines the step Id
  46347. */
  46348. setStepId(newStepId: number): void;
  46349. /**
  46350. * Gets the step Id used by deterministic lock step
  46351. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46352. * @returns the step Id
  46353. */
  46354. getStepId(): number;
  46355. /**
  46356. * Gets the internal step used by deterministic lock step
  46357. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46358. * @returns the internal step
  46359. */
  46360. getInternalStep(): number;
  46361. private _fogEnabled;
  46362. /**
  46363. * Gets or sets a boolean indicating if fog is enabled on this scene
  46364. * @see https://doc.babylonjs.com/babylon101/environment#fog
  46365. * (Default is true)
  46366. */
  46367. set fogEnabled(value: boolean);
  46368. get fogEnabled(): boolean;
  46369. private _fogMode;
  46370. /**
  46371. * Gets or sets the fog mode to use
  46372. * @see https://doc.babylonjs.com/babylon101/environment#fog
  46373. * | mode | value |
  46374. * | --- | --- |
  46375. * | FOGMODE_NONE | 0 |
  46376. * | FOGMODE_EXP | 1 |
  46377. * | FOGMODE_EXP2 | 2 |
  46378. * | FOGMODE_LINEAR | 3 |
  46379. */
  46380. set fogMode(value: number);
  46381. get fogMode(): number;
  46382. /**
  46383. * Gets or sets the fog color to use
  46384. * @see https://doc.babylonjs.com/babylon101/environment#fog
  46385. * (Default is Color3(0.2, 0.2, 0.3))
  46386. */
  46387. fogColor: Color3;
  46388. /**
  46389. * Gets or sets the fog density to use
  46390. * @see https://doc.babylonjs.com/babylon101/environment#fog
  46391. * (Default is 0.1)
  46392. */
  46393. fogDensity: number;
  46394. /**
  46395. * Gets or sets the fog start distance to use
  46396. * @see https://doc.babylonjs.com/babylon101/environment#fog
  46397. * (Default is 0)
  46398. */
  46399. fogStart: number;
  46400. /**
  46401. * Gets or sets the fog end distance to use
  46402. * @see https://doc.babylonjs.com/babylon101/environment#fog
  46403. * (Default is 1000)
  46404. */
  46405. fogEnd: number;
  46406. /**
  46407. * Flag indicating that the frame buffer binding is handled by another component
  46408. */
  46409. prePass: boolean;
  46410. private _shadowsEnabled;
  46411. /**
  46412. * Gets or sets a boolean indicating if shadows are enabled on this scene
  46413. */
  46414. set shadowsEnabled(value: boolean);
  46415. get shadowsEnabled(): boolean;
  46416. private _lightsEnabled;
  46417. /**
  46418. * Gets or sets a boolean indicating if lights are enabled on this scene
  46419. */
  46420. set lightsEnabled(value: boolean);
  46421. get lightsEnabled(): boolean;
  46422. /** All of the active cameras added to this scene. */
  46423. activeCameras: Nullable<Camera[]>;
  46424. /** @hidden */
  46425. _activeCamera: Nullable<Camera>;
  46426. /** Gets or sets the current active camera */
  46427. get activeCamera(): Nullable<Camera>;
  46428. set activeCamera(value: Nullable<Camera>);
  46429. private _defaultMaterial;
  46430. /** The default material used on meshes when no material is affected */
  46431. get defaultMaterial(): Material;
  46432. /** The default material used on meshes when no material is affected */
  46433. set defaultMaterial(value: Material);
  46434. private _texturesEnabled;
  46435. /**
  46436. * Gets or sets a boolean indicating if textures are enabled on this scene
  46437. */
  46438. set texturesEnabled(value: boolean);
  46439. get texturesEnabled(): boolean;
  46440. /**
  46441. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  46442. */
  46443. physicsEnabled: boolean;
  46444. /**
  46445. * Gets or sets a boolean indicating if particles are enabled on this scene
  46446. */
  46447. particlesEnabled: boolean;
  46448. /**
  46449. * Gets or sets a boolean indicating if sprites are enabled on this scene
  46450. */
  46451. spritesEnabled: boolean;
  46452. private _skeletonsEnabled;
  46453. /**
  46454. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  46455. */
  46456. set skeletonsEnabled(value: boolean);
  46457. get skeletonsEnabled(): boolean;
  46458. /**
  46459. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  46460. */
  46461. lensFlaresEnabled: boolean;
  46462. /**
  46463. * Gets or sets a boolean indicating if collisions are enabled on this scene
  46464. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  46465. */
  46466. collisionsEnabled: boolean;
  46467. private _collisionCoordinator;
  46468. /** @hidden */
  46469. get collisionCoordinator(): ICollisionCoordinator;
  46470. /**
  46471. * Defines the gravity applied to this scene (used only for collisions)
  46472. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  46473. */
  46474. gravity: Vector3;
  46475. /**
  46476. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  46477. */
  46478. postProcessesEnabled: boolean;
  46479. /**
  46480. * Gets the current postprocess manager
  46481. */
  46482. postProcessManager: PostProcessManager;
  46483. /**
  46484. * Gets or sets a boolean indicating if render targets are enabled on this scene
  46485. */
  46486. renderTargetsEnabled: boolean;
  46487. /**
  46488. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  46489. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  46490. */
  46491. dumpNextRenderTargets: boolean;
  46492. /**
  46493. * The list of user defined render targets added to the scene
  46494. */
  46495. customRenderTargets: RenderTargetTexture[];
  46496. /**
  46497. * Defines if texture loading must be delayed
  46498. * If true, textures will only be loaded when they need to be rendered
  46499. */
  46500. useDelayedTextureLoading: boolean;
  46501. /**
  46502. * Gets the list of meshes imported to the scene through SceneLoader
  46503. */
  46504. importedMeshesFiles: String[];
  46505. /**
  46506. * Gets or sets a boolean indicating if probes are enabled on this scene
  46507. */
  46508. probesEnabled: boolean;
  46509. /**
  46510. * Gets or sets the current offline provider to use to store scene data
  46511. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  46512. */
  46513. offlineProvider: IOfflineProvider;
  46514. /**
  46515. * Gets or sets the action manager associated with the scene
  46516. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  46517. */
  46518. actionManager: AbstractActionManager;
  46519. private _meshesForIntersections;
  46520. /**
  46521. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  46522. */
  46523. proceduralTexturesEnabled: boolean;
  46524. private _engine;
  46525. private _totalVertices;
  46526. /** @hidden */
  46527. _activeIndices: PerfCounter;
  46528. /** @hidden */
  46529. _activeParticles: PerfCounter;
  46530. /** @hidden */
  46531. _activeBones: PerfCounter;
  46532. private _animationRatio;
  46533. /** @hidden */
  46534. _animationTimeLast: number;
  46535. /** @hidden */
  46536. _animationTime: number;
  46537. /**
  46538. * Gets or sets a general scale for animation speed
  46539. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  46540. */
  46541. animationTimeScale: number;
  46542. /** @hidden */
  46543. _cachedMaterial: Nullable<Material>;
  46544. /** @hidden */
  46545. _cachedEffect: Nullable<Effect>;
  46546. /** @hidden */
  46547. _cachedVisibility: Nullable<number>;
  46548. private _renderId;
  46549. private _frameId;
  46550. private _executeWhenReadyTimeoutId;
  46551. private _intermediateRendering;
  46552. private _viewUpdateFlag;
  46553. private _projectionUpdateFlag;
  46554. /** @hidden */
  46555. _toBeDisposed: Nullable<IDisposable>[];
  46556. private _activeRequests;
  46557. /** @hidden */
  46558. _pendingData: any[];
  46559. private _isDisposed;
  46560. /**
  46561. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  46562. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  46563. */
  46564. dispatchAllSubMeshesOfActiveMeshes: boolean;
  46565. private _activeMeshes;
  46566. private _processedMaterials;
  46567. private _renderTargets;
  46568. /** @hidden */
  46569. _activeParticleSystems: SmartArray<IParticleSystem>;
  46570. private _activeSkeletons;
  46571. private _softwareSkinnedMeshes;
  46572. private _renderingManager;
  46573. /** @hidden */
  46574. _activeAnimatables: Animatable[];
  46575. private _transformMatrix;
  46576. private _sceneUbo;
  46577. /** @hidden */
  46578. _viewMatrix: Matrix;
  46579. /** @hidden */
  46580. _projectionMatrix: Matrix;
  46581. /** @hidden */
  46582. _forcedViewPosition: Nullable<Vector3>;
  46583. /** @hidden */
  46584. _frustumPlanes: Plane[];
  46585. /**
  46586. * Gets the list of frustum planes (built from the active camera)
  46587. */
  46588. get frustumPlanes(): Plane[];
  46589. /**
  46590. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  46591. * This is useful if there are more lights that the maximum simulteanous authorized
  46592. */
  46593. requireLightSorting: boolean;
  46594. /** @hidden */
  46595. readonly useMaterialMeshMap: boolean;
  46596. /** @hidden */
  46597. readonly useClonedMeshMap: boolean;
  46598. private _externalData;
  46599. private _uid;
  46600. /**
  46601. * @hidden
  46602. * Backing store of defined scene components.
  46603. */
  46604. _components: ISceneComponent[];
  46605. /**
  46606. * @hidden
  46607. * Backing store of defined scene components.
  46608. */
  46609. _serializableComponents: ISceneSerializableComponent[];
  46610. /**
  46611. * List of components to register on the next registration step.
  46612. */
  46613. private _transientComponents;
  46614. /**
  46615. * Registers the transient components if needed.
  46616. */
  46617. private _registerTransientComponents;
  46618. /**
  46619. * @hidden
  46620. * Add a component to the scene.
  46621. * Note that the ccomponent could be registered on th next frame if this is called after
  46622. * the register component stage.
  46623. * @param component Defines the component to add to the scene
  46624. */
  46625. _addComponent(component: ISceneComponent): void;
  46626. /**
  46627. * @hidden
  46628. * Gets a component from the scene.
  46629. * @param name defines the name of the component to retrieve
  46630. * @returns the component or null if not present
  46631. */
  46632. _getComponent(name: string): Nullable<ISceneComponent>;
  46633. /**
  46634. * @hidden
  46635. * Defines the actions happening before camera updates.
  46636. */
  46637. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  46638. /**
  46639. * @hidden
  46640. * Defines the actions happening before clear the canvas.
  46641. */
  46642. _beforeClearStage: Stage<SimpleStageAction>;
  46643. /**
  46644. * @hidden
  46645. * Defines the actions when collecting render targets for the frame.
  46646. */
  46647. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  46648. /**
  46649. * @hidden
  46650. * Defines the actions happening for one camera in the frame.
  46651. */
  46652. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  46653. /**
  46654. * @hidden
  46655. * Defines the actions happening during the per mesh ready checks.
  46656. */
  46657. _isReadyForMeshStage: Stage<MeshStageAction>;
  46658. /**
  46659. * @hidden
  46660. * Defines the actions happening before evaluate active mesh checks.
  46661. */
  46662. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  46663. /**
  46664. * @hidden
  46665. * Defines the actions happening during the evaluate sub mesh checks.
  46666. */
  46667. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  46668. /**
  46669. * @hidden
  46670. * Defines the actions happening during the active mesh stage.
  46671. */
  46672. _preActiveMeshStage: Stage<PreActiveMeshStageAction>;
  46673. /**
  46674. * @hidden
  46675. * Defines the actions happening during the per camera render target step.
  46676. */
  46677. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  46678. /**
  46679. * @hidden
  46680. * Defines the actions happening just before the active camera is drawing.
  46681. */
  46682. _beforeCameraDrawStage: Stage<CameraStageAction>;
  46683. /**
  46684. * @hidden
  46685. * Defines the actions happening just before a render target is drawing.
  46686. */
  46687. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  46688. /**
  46689. * @hidden
  46690. * Defines the actions happening just before a rendering group is drawing.
  46691. */
  46692. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  46693. /**
  46694. * @hidden
  46695. * Defines the actions happening just before a mesh is drawing.
  46696. */
  46697. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  46698. /**
  46699. * @hidden
  46700. * Defines the actions happening just after a mesh has been drawn.
  46701. */
  46702. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  46703. /**
  46704. * @hidden
  46705. * Defines the actions happening just after a rendering group has been drawn.
  46706. */
  46707. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  46708. /**
  46709. * @hidden
  46710. * Defines the actions happening just after the active camera has been drawn.
  46711. */
  46712. _afterCameraDrawStage: Stage<CameraStageAction>;
  46713. /**
  46714. * @hidden
  46715. * Defines the actions happening just after a render target has been drawn.
  46716. */
  46717. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  46718. /**
  46719. * @hidden
  46720. * Defines the actions happening just after rendering all cameras and computing intersections.
  46721. */
  46722. _afterRenderStage: Stage<SimpleStageAction>;
  46723. /**
  46724. * @hidden
  46725. * Defines the actions happening when a pointer move event happens.
  46726. */
  46727. _pointerMoveStage: Stage<PointerMoveStageAction>;
  46728. /**
  46729. * @hidden
  46730. * Defines the actions happening when a pointer down event happens.
  46731. */
  46732. _pointerDownStage: Stage<PointerUpDownStageAction>;
  46733. /**
  46734. * @hidden
  46735. * Defines the actions happening when a pointer up event happens.
  46736. */
  46737. _pointerUpStage: Stage<PointerUpDownStageAction>;
  46738. /**
  46739. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  46740. */
  46741. private geometriesByUniqueId;
  46742. private _renderBundles;
  46743. /**
  46744. * Creates a new Scene
  46745. * @param engine defines the engine to use to render this scene
  46746. * @param options defines the scene options
  46747. */
  46748. constructor(engine: Engine, options?: SceneOptions);
  46749. /**
  46750. * Gets a string identifying the name of the class
  46751. * @returns "Scene" string
  46752. */
  46753. getClassName(): string;
  46754. private _defaultMeshCandidates;
  46755. /**
  46756. * @hidden
  46757. */
  46758. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  46759. private _defaultSubMeshCandidates;
  46760. /**
  46761. * @hidden
  46762. */
  46763. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  46764. /**
  46765. * Sets the default candidate providers for the scene.
  46766. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  46767. * and getCollidingSubMeshCandidates to their default function
  46768. */
  46769. setDefaultCandidateProviders(): void;
  46770. /**
  46771. * Gets the mesh that is currently under the pointer
  46772. */
  46773. get meshUnderPointer(): Nullable<AbstractMesh>;
  46774. /**
  46775. * Gets or sets the current on-screen X position of the pointer
  46776. */
  46777. get pointerX(): number;
  46778. set pointerX(value: number);
  46779. /**
  46780. * Gets or sets the current on-screen Y position of the pointer
  46781. */
  46782. get pointerY(): number;
  46783. set pointerY(value: number);
  46784. /**
  46785. * Gets the cached material (ie. the latest rendered one)
  46786. * @returns the cached material
  46787. */
  46788. getCachedMaterial(): Nullable<Material>;
  46789. /**
  46790. * Gets the cached effect (ie. the latest rendered one)
  46791. * @returns the cached effect
  46792. */
  46793. getCachedEffect(): Nullable<Effect>;
  46794. /**
  46795. * Gets the cached visibility state (ie. the latest rendered one)
  46796. * @returns the cached visibility state
  46797. */
  46798. getCachedVisibility(): Nullable<number>;
  46799. /**
  46800. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  46801. * @param material defines the current material
  46802. * @param effect defines the current effect
  46803. * @param visibility defines the current visibility state
  46804. * @returns true if one parameter is not cached
  46805. */
  46806. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  46807. /**
  46808. * Gets the engine associated with the scene
  46809. * @returns an Engine
  46810. */
  46811. getEngine(): Engine;
  46812. /**
  46813. * Gets the total number of vertices rendered per frame
  46814. * @returns the total number of vertices rendered per frame
  46815. */
  46816. getTotalVertices(): number;
  46817. /**
  46818. * Gets the performance counter for total vertices
  46819. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  46820. */
  46821. get totalVerticesPerfCounter(): PerfCounter;
  46822. /**
  46823. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  46824. * @returns the total number of active indices rendered per frame
  46825. */
  46826. getActiveIndices(): number;
  46827. /**
  46828. * Gets the performance counter for active indices
  46829. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  46830. */
  46831. get totalActiveIndicesPerfCounter(): PerfCounter;
  46832. /**
  46833. * Gets the total number of active particles rendered per frame
  46834. * @returns the total number of active particles rendered per frame
  46835. */
  46836. getActiveParticles(): number;
  46837. /**
  46838. * Gets the performance counter for active particles
  46839. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  46840. */
  46841. get activeParticlesPerfCounter(): PerfCounter;
  46842. /**
  46843. * Gets the total number of active bones rendered per frame
  46844. * @returns the total number of active bones rendered per frame
  46845. */
  46846. getActiveBones(): number;
  46847. /**
  46848. * Gets the performance counter for active bones
  46849. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  46850. */
  46851. get activeBonesPerfCounter(): PerfCounter;
  46852. /**
  46853. * Gets the array of active meshes
  46854. * @returns an array of AbstractMesh
  46855. */
  46856. getActiveMeshes(): SmartArray<AbstractMesh>;
  46857. /**
  46858. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  46859. * @returns a number
  46860. */
  46861. getAnimationRatio(): number;
  46862. /**
  46863. * Gets an unique Id for the current render phase
  46864. * @returns a number
  46865. */
  46866. getRenderId(): number;
  46867. /**
  46868. * Gets an unique Id for the current frame
  46869. * @returns a number
  46870. */
  46871. getFrameId(): number;
  46872. /** Call this function if you want to manually increment the render Id*/
  46873. incrementRenderId(): void;
  46874. private _createUbo;
  46875. /**
  46876. * Use this method to simulate a pointer move on a mesh
  46877. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  46878. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  46879. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  46880. * @returns the current scene
  46881. */
  46882. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  46883. /**
  46884. * Use this method to simulate a pointer down on a mesh
  46885. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  46886. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  46887. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  46888. * @returns the current scene
  46889. */
  46890. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  46891. /**
  46892. * Use this method to simulate a pointer up on a mesh
  46893. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  46894. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  46895. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  46896. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  46897. * @returns the current scene
  46898. */
  46899. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  46900. /**
  46901. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  46902. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  46903. * @returns true if the pointer was captured
  46904. */
  46905. isPointerCaptured(pointerId?: number): boolean;
  46906. /**
  46907. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  46908. * @param attachUp defines if you want to attach events to pointerup
  46909. * @param attachDown defines if you want to attach events to pointerdown
  46910. * @param attachMove defines if you want to attach events to pointermove
  46911. */
  46912. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  46913. /** Detaches all event handlers*/
  46914. detachControl(): void;
  46915. /**
  46916. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  46917. * Delay loaded resources are not taking in account
  46918. * @return true if all required resources are ready
  46919. */
  46920. isReady(): boolean;
  46921. /** Resets all cached information relative to material (including effect and visibility) */
  46922. resetCachedMaterial(): void;
  46923. /**
  46924. * Registers a function to be called before every frame render
  46925. * @param func defines the function to register
  46926. */
  46927. registerBeforeRender(func: () => void): void;
  46928. /**
  46929. * Unregisters a function called before every frame render
  46930. * @param func defines the function to unregister
  46931. */
  46932. unregisterBeforeRender(func: () => void): void;
  46933. /**
  46934. * Registers a function to be called after every frame render
  46935. * @param func defines the function to register
  46936. */
  46937. registerAfterRender(func: () => void): void;
  46938. /**
  46939. * Unregisters a function called after every frame render
  46940. * @param func defines the function to unregister
  46941. */
  46942. unregisterAfterRender(func: () => void): void;
  46943. private _executeOnceBeforeRender;
  46944. /**
  46945. * The provided function will run before render once and will be disposed afterwards.
  46946. * A timeout delay can be provided so that the function will be executed in N ms.
  46947. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  46948. * @param func The function to be executed.
  46949. * @param timeout optional delay in ms
  46950. */
  46951. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  46952. /** @hidden */
  46953. _addPendingData(data: any): void;
  46954. /** @hidden */
  46955. _removePendingData(data: any): void;
  46956. /**
  46957. * Returns the number of items waiting to be loaded
  46958. * @returns the number of items waiting to be loaded
  46959. */
  46960. getWaitingItemsCount(): number;
  46961. /**
  46962. * Returns a boolean indicating if the scene is still loading data
  46963. */
  46964. get isLoading(): boolean;
  46965. /**
  46966. * Registers a function to be executed when the scene is ready
  46967. * @param {Function} func - the function to be executed
  46968. */
  46969. executeWhenReady(func: () => void): void;
  46970. /**
  46971. * Returns a promise that resolves when the scene is ready
  46972. * @returns A promise that resolves when the scene is ready
  46973. */
  46974. whenReadyAsync(): Promise<void>;
  46975. /** @hidden */
  46976. _checkIsReady(): void;
  46977. /**
  46978. * Gets all animatable attached to the scene
  46979. */
  46980. get animatables(): Animatable[];
  46981. /**
  46982. * Resets the last animation time frame.
  46983. * Useful to override when animations start running when loading a scene for the first time.
  46984. */
  46985. resetLastAnimationTimeFrame(): void;
  46986. /**
  46987. * Gets the current view matrix
  46988. * @returns a Matrix
  46989. */
  46990. getViewMatrix(): Matrix;
  46991. /**
  46992. * Gets the current projection matrix
  46993. * @returns a Matrix
  46994. */
  46995. getProjectionMatrix(): Matrix;
  46996. /**
  46997. * Gets the current transform matrix
  46998. * @returns a Matrix made of View * Projection
  46999. */
  47000. getTransformMatrix(): Matrix;
  47001. /**
  47002. * Sets the current transform matrix
  47003. * @param viewL defines the View matrix to use
  47004. * @param projectionL defines the Projection matrix to use
  47005. * @param viewR defines the right View matrix to use (if provided)
  47006. * @param projectionR defines the right Projection matrix to use (if provided)
  47007. */
  47008. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  47009. /**
  47010. * Gets the uniform buffer used to store scene data
  47011. * @returns a UniformBuffer
  47012. */
  47013. getSceneUniformBuffer(): UniformBuffer;
  47014. /**
  47015. * Gets an unique (relatively to the current scene) Id
  47016. * @returns an unique number for the scene
  47017. */
  47018. getUniqueId(): number;
  47019. /**
  47020. * Add a mesh to the list of scene's meshes
  47021. * @param newMesh defines the mesh to add
  47022. * @param recursive if all child meshes should also be added to the scene
  47023. */
  47024. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  47025. /**
  47026. * Remove a mesh for the list of scene's meshes
  47027. * @param toRemove defines the mesh to remove
  47028. * @param recursive if all child meshes should also be removed from the scene
  47029. * @returns the index where the mesh was in the mesh list
  47030. */
  47031. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  47032. /**
  47033. * Add a transform node to the list of scene's transform nodes
  47034. * @param newTransformNode defines the transform node to add
  47035. */
  47036. addTransformNode(newTransformNode: TransformNode): void;
  47037. /**
  47038. * Remove a transform node for the list of scene's transform nodes
  47039. * @param toRemove defines the transform node to remove
  47040. * @returns the index where the transform node was in the transform node list
  47041. */
  47042. removeTransformNode(toRemove: TransformNode): number;
  47043. /**
  47044. * Remove a skeleton for the list of scene's skeletons
  47045. * @param toRemove defines the skeleton to remove
  47046. * @returns the index where the skeleton was in the skeleton list
  47047. */
  47048. removeSkeleton(toRemove: Skeleton): number;
  47049. /**
  47050. * Remove a morph target for the list of scene's morph targets
  47051. * @param toRemove defines the morph target to remove
  47052. * @returns the index where the morph target was in the morph target list
  47053. */
  47054. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  47055. /**
  47056. * Remove a light for the list of scene's lights
  47057. * @param toRemove defines the light to remove
  47058. * @returns the index where the light was in the light list
  47059. */
  47060. removeLight(toRemove: Light): number;
  47061. /**
  47062. * Remove a camera for the list of scene's cameras
  47063. * @param toRemove defines the camera to remove
  47064. * @returns the index where the camera was in the camera list
  47065. */
  47066. removeCamera(toRemove: Camera): number;
  47067. /**
  47068. * Remove a particle system for the list of scene's particle systems
  47069. * @param toRemove defines the particle system to remove
  47070. * @returns the index where the particle system was in the particle system list
  47071. */
  47072. removeParticleSystem(toRemove: IParticleSystem): number;
  47073. /**
  47074. * Remove a animation for the list of scene's animations
  47075. * @param toRemove defines the animation to remove
  47076. * @returns the index where the animation was in the animation list
  47077. */
  47078. removeAnimation(toRemove: Animation): number;
  47079. /**
  47080. * Will stop the animation of the given target
  47081. * @param target - the target
  47082. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  47083. * @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)
  47084. */
  47085. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  47086. /**
  47087. * Removes the given animation group from this scene.
  47088. * @param toRemove The animation group to remove
  47089. * @returns The index of the removed animation group
  47090. */
  47091. removeAnimationGroup(toRemove: AnimationGroup): number;
  47092. /**
  47093. * Removes the given multi-material from this scene.
  47094. * @param toRemove The multi-material to remove
  47095. * @returns The index of the removed multi-material
  47096. */
  47097. removeMultiMaterial(toRemove: MultiMaterial): number;
  47098. /**
  47099. * Removes the given material from this scene.
  47100. * @param toRemove The material to remove
  47101. * @returns The index of the removed material
  47102. */
  47103. removeMaterial(toRemove: Material): number;
  47104. /**
  47105. * Removes the given action manager from this scene.
  47106. * @param toRemove The action manager to remove
  47107. * @returns The index of the removed action manager
  47108. */
  47109. removeActionManager(toRemove: AbstractActionManager): number;
  47110. /**
  47111. * Removes the given texture from this scene.
  47112. * @param toRemove The texture to remove
  47113. * @returns The index of the removed texture
  47114. */
  47115. removeTexture(toRemove: BaseTexture): number;
  47116. /**
  47117. * Adds the given light to this scene
  47118. * @param newLight The light to add
  47119. */
  47120. addLight(newLight: Light): void;
  47121. /**
  47122. * Sorts the list list based on light priorities
  47123. */
  47124. sortLightsByPriority(): void;
  47125. /**
  47126. * Adds the given camera to this scene
  47127. * @param newCamera The camera to add
  47128. */
  47129. addCamera(newCamera: Camera): void;
  47130. /**
  47131. * Adds the given skeleton to this scene
  47132. * @param newSkeleton The skeleton to add
  47133. */
  47134. addSkeleton(newSkeleton: Skeleton): void;
  47135. /**
  47136. * Adds the given particle system to this scene
  47137. * @param newParticleSystem The particle system to add
  47138. */
  47139. addParticleSystem(newParticleSystem: IParticleSystem): void;
  47140. /**
  47141. * Adds the given animation to this scene
  47142. * @param newAnimation The animation to add
  47143. */
  47144. addAnimation(newAnimation: Animation): void;
  47145. /**
  47146. * Adds the given animation group to this scene.
  47147. * @param newAnimationGroup The animation group to add
  47148. */
  47149. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  47150. /**
  47151. * Adds the given multi-material to this scene
  47152. * @param newMultiMaterial The multi-material to add
  47153. */
  47154. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  47155. /**
  47156. * Adds the given material to this scene
  47157. * @param newMaterial The material to add
  47158. */
  47159. addMaterial(newMaterial: Material): void;
  47160. /**
  47161. * Adds the given morph target to this scene
  47162. * @param newMorphTargetManager The morph target to add
  47163. */
  47164. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  47165. /**
  47166. * Adds the given geometry to this scene
  47167. * @param newGeometry The geometry to add
  47168. */
  47169. addGeometry(newGeometry: Geometry): void;
  47170. /**
  47171. * Adds the given action manager to this scene
  47172. * @param newActionManager The action manager to add
  47173. */
  47174. addActionManager(newActionManager: AbstractActionManager): void;
  47175. /**
  47176. * Adds the given texture to this scene.
  47177. * @param newTexture The texture to add
  47178. */
  47179. addTexture(newTexture: BaseTexture): void;
  47180. /**
  47181. * Switch active camera
  47182. * @param newCamera defines the new active camera
  47183. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  47184. */
  47185. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  47186. /**
  47187. * sets the active camera of the scene using its ID
  47188. * @param id defines the camera's ID
  47189. * @return the new active camera or null if none found.
  47190. */
  47191. setActiveCameraByID(id: string): Nullable<Camera>;
  47192. /**
  47193. * sets the active camera of the scene using its name
  47194. * @param name defines the camera's name
  47195. * @returns the new active camera or null if none found.
  47196. */
  47197. setActiveCameraByName(name: string): Nullable<Camera>;
  47198. /**
  47199. * get an animation group using its name
  47200. * @param name defines the material's name
  47201. * @return the animation group or null if none found.
  47202. */
  47203. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  47204. /**
  47205. * Get a material using its unique id
  47206. * @param uniqueId defines the material's unique id
  47207. * @return the material or null if none found.
  47208. */
  47209. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  47210. /**
  47211. * get a material using its id
  47212. * @param id defines the material's ID
  47213. * @return the material or null if none found.
  47214. */
  47215. getMaterialByID(id: string): Nullable<Material>;
  47216. /**
  47217. * Gets a the last added material using a given id
  47218. * @param id defines the material's ID
  47219. * @return the last material with the given id or null if none found.
  47220. */
  47221. getLastMaterialByID(id: string): Nullable<Material>;
  47222. /**
  47223. * Gets a material using its name
  47224. * @param name defines the material's name
  47225. * @return the material or null if none found.
  47226. */
  47227. getMaterialByName(name: string): Nullable<Material>;
  47228. /**
  47229. * Get a texture using its unique id
  47230. * @param uniqueId defines the texture's unique id
  47231. * @return the texture or null if none found.
  47232. */
  47233. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  47234. /**
  47235. * Gets a camera using its id
  47236. * @param id defines the id to look for
  47237. * @returns the camera or null if not found
  47238. */
  47239. getCameraByID(id: string): Nullable<Camera>;
  47240. /**
  47241. * Gets a camera using its unique id
  47242. * @param uniqueId defines the unique id to look for
  47243. * @returns the camera or null if not found
  47244. */
  47245. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  47246. /**
  47247. * Gets a camera using its name
  47248. * @param name defines the camera's name
  47249. * @return the camera or null if none found.
  47250. */
  47251. getCameraByName(name: string): Nullable<Camera>;
  47252. /**
  47253. * Gets a bone using its id
  47254. * @param id defines the bone's id
  47255. * @return the bone or null if not found
  47256. */
  47257. getBoneByID(id: string): Nullable<Bone>;
  47258. /**
  47259. * Gets a bone using its id
  47260. * @param name defines the bone's name
  47261. * @return the bone or null if not found
  47262. */
  47263. getBoneByName(name: string): Nullable<Bone>;
  47264. /**
  47265. * Gets a light node using its name
  47266. * @param name defines the the light's name
  47267. * @return the light or null if none found.
  47268. */
  47269. getLightByName(name: string): Nullable<Light>;
  47270. /**
  47271. * Gets a light node using its id
  47272. * @param id defines the light's id
  47273. * @return the light or null if none found.
  47274. */
  47275. getLightByID(id: string): Nullable<Light>;
  47276. /**
  47277. * Gets a light node using its scene-generated unique ID
  47278. * @param uniqueId defines the light's unique id
  47279. * @return the light or null if none found.
  47280. */
  47281. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  47282. /**
  47283. * Gets a particle system by id
  47284. * @param id defines the particle system id
  47285. * @return the corresponding system or null if none found
  47286. */
  47287. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  47288. /**
  47289. * Gets a geometry using its ID
  47290. * @param id defines the geometry's id
  47291. * @return the geometry or null if none found.
  47292. */
  47293. getGeometryByID(id: string): Nullable<Geometry>;
  47294. private _getGeometryByUniqueID;
  47295. /**
  47296. * Add a new geometry to this scene
  47297. * @param geometry defines the geometry to be added to the scene.
  47298. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  47299. * @return a boolean defining if the geometry was added or not
  47300. */
  47301. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  47302. /**
  47303. * Removes an existing geometry
  47304. * @param geometry defines the geometry to be removed from the scene
  47305. * @return a boolean defining if the geometry was removed or not
  47306. */
  47307. removeGeometry(geometry: Geometry): boolean;
  47308. /**
  47309. * Gets the list of geometries attached to the scene
  47310. * @returns an array of Geometry
  47311. */
  47312. getGeometries(): Geometry[];
  47313. /**
  47314. * Gets the first added mesh found of a given ID
  47315. * @param id defines the id to search for
  47316. * @return the mesh found or null if not found at all
  47317. */
  47318. getMeshByID(id: string): Nullable<AbstractMesh>;
  47319. /**
  47320. * Gets a list of meshes using their id
  47321. * @param id defines the id to search for
  47322. * @returns a list of meshes
  47323. */
  47324. getMeshesByID(id: string): Array<AbstractMesh>;
  47325. /**
  47326. * Gets the first added transform node found of a given ID
  47327. * @param id defines the id to search for
  47328. * @return the found transform node or null if not found at all.
  47329. */
  47330. getTransformNodeByID(id: string): Nullable<TransformNode>;
  47331. /**
  47332. * Gets a transform node with its auto-generated unique id
  47333. * @param uniqueId efines the unique id to search for
  47334. * @return the found transform node or null if not found at all.
  47335. */
  47336. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  47337. /**
  47338. * Gets a list of transform nodes using their id
  47339. * @param id defines the id to search for
  47340. * @returns a list of transform nodes
  47341. */
  47342. getTransformNodesByID(id: string): Array<TransformNode>;
  47343. /**
  47344. * Gets a mesh with its auto-generated unique id
  47345. * @param uniqueId defines the unique id to search for
  47346. * @return the found mesh or null if not found at all.
  47347. */
  47348. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  47349. /**
  47350. * Gets a the last added mesh using a given id
  47351. * @param id defines the id to search for
  47352. * @return the found mesh or null if not found at all.
  47353. */
  47354. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  47355. /**
  47356. * Gets a the last added node (Mesh, Camera, Light) using a given id
  47357. * @param id defines the id to search for
  47358. * @return the found node or null if not found at all
  47359. */
  47360. getLastEntryByID(id: string): Nullable<Node>;
  47361. /**
  47362. * Gets a node (Mesh, Camera, Light) using a given id
  47363. * @param id defines the id to search for
  47364. * @return the found node or null if not found at all
  47365. */
  47366. getNodeByID(id: string): Nullable<Node>;
  47367. /**
  47368. * Gets a node (Mesh, Camera, Light) using a given name
  47369. * @param name defines the name to search for
  47370. * @return the found node or null if not found at all.
  47371. */
  47372. getNodeByName(name: string): Nullable<Node>;
  47373. /**
  47374. * Gets a mesh using a given name
  47375. * @param name defines the name to search for
  47376. * @return the found mesh or null if not found at all.
  47377. */
  47378. getMeshByName(name: string): Nullable<AbstractMesh>;
  47379. /**
  47380. * Gets a transform node using a given name
  47381. * @param name defines the name to search for
  47382. * @return the found transform node or null if not found at all.
  47383. */
  47384. getTransformNodeByName(name: string): Nullable<TransformNode>;
  47385. /**
  47386. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  47387. * @param id defines the id to search for
  47388. * @return the found skeleton or null if not found at all.
  47389. */
  47390. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  47391. /**
  47392. * Gets a skeleton using a given auto generated unique id
  47393. * @param uniqueId defines the unique id to search for
  47394. * @return the found skeleton or null if not found at all.
  47395. */
  47396. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  47397. /**
  47398. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  47399. * @param id defines the id to search for
  47400. * @return the found skeleton or null if not found at all.
  47401. */
  47402. getSkeletonById(id: string): Nullable<Skeleton>;
  47403. /**
  47404. * Gets a skeleton using a given name
  47405. * @param name defines the name to search for
  47406. * @return the found skeleton or null if not found at all.
  47407. */
  47408. getSkeletonByName(name: string): Nullable<Skeleton>;
  47409. /**
  47410. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  47411. * @param id defines the id to search for
  47412. * @return the found morph target manager or null if not found at all.
  47413. */
  47414. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  47415. /**
  47416. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  47417. * @param id defines the id to search for
  47418. * @return the found morph target or null if not found at all.
  47419. */
  47420. getMorphTargetById(id: string): Nullable<MorphTarget>;
  47421. /**
  47422. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  47423. * @param name defines the name to search for
  47424. * @return the found morph target or null if not found at all.
  47425. */
  47426. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  47427. /**
  47428. * Gets a post process using a given name (if many are found, this function will pick the first one)
  47429. * @param name defines the name to search for
  47430. * @return the found post process or null if not found at all.
  47431. */
  47432. getPostProcessByName(name: string): Nullable<PostProcess>;
  47433. /**
  47434. * Gets a boolean indicating if the given mesh is active
  47435. * @param mesh defines the mesh to look for
  47436. * @returns true if the mesh is in the active list
  47437. */
  47438. isActiveMesh(mesh: AbstractMesh): boolean;
  47439. /**
  47440. * Return a unique id as a string which can serve as an identifier for the scene
  47441. */
  47442. get uid(): string;
  47443. /**
  47444. * Add an externaly attached data from its key.
  47445. * This method call will fail and return false, if such key already exists.
  47446. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  47447. * @param key the unique key that identifies the data
  47448. * @param data the data object to associate to the key for this Engine instance
  47449. * @return true if no such key were already present and the data was added successfully, false otherwise
  47450. */
  47451. addExternalData<T>(key: string, data: T): boolean;
  47452. /**
  47453. * Get an externaly attached data from its key
  47454. * @param key the unique key that identifies the data
  47455. * @return the associated data, if present (can be null), or undefined if not present
  47456. */
  47457. getExternalData<T>(key: string): Nullable<T>;
  47458. /**
  47459. * Get an externaly attached data from its key, create it using a factory if it's not already present
  47460. * @param key the unique key that identifies the data
  47461. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  47462. * @return the associated data, can be null if the factory returned null.
  47463. */
  47464. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  47465. /**
  47466. * Remove an externaly attached data from the Engine instance
  47467. * @param key the unique key that identifies the data
  47468. * @return true if the data was successfully removed, false if it doesn't exist
  47469. */
  47470. removeExternalData(key: string): boolean;
  47471. private _evaluateSubMesh;
  47472. /**
  47473. * Clear the processed materials smart array preventing retention point in material dispose.
  47474. */
  47475. freeProcessedMaterials(): void;
  47476. private _preventFreeActiveMeshesAndRenderingGroups;
  47477. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  47478. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  47479. * when disposing several meshes in a row or a hierarchy of meshes.
  47480. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  47481. */
  47482. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  47483. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  47484. /**
  47485. * Clear the active meshes smart array preventing retention point in mesh dispose.
  47486. */
  47487. freeActiveMeshes(): void;
  47488. /**
  47489. * Clear the info related to rendering groups preventing retention points during dispose.
  47490. */
  47491. freeRenderingGroups(): void;
  47492. /** @hidden */
  47493. _isInIntermediateRendering(): boolean;
  47494. /**
  47495. * Lambda returning the list of potentially active meshes.
  47496. */
  47497. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  47498. /**
  47499. * Lambda returning the list of potentially active sub meshes.
  47500. */
  47501. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  47502. /**
  47503. * Lambda returning the list of potentially intersecting sub meshes.
  47504. */
  47505. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  47506. /**
  47507. * Lambda returning the list of potentially colliding sub meshes.
  47508. */
  47509. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  47510. /** @hidden */
  47511. _activeMeshesFrozen: boolean;
  47512. private _skipEvaluateActiveMeshesCompletely;
  47513. /**
  47514. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  47515. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  47516. * @param onSuccess optional success callback
  47517. * @param onError optional error callback
  47518. * @returns the current scene
  47519. */
  47520. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean, onSuccess?: () => void, onError?: (message: string) => void): Scene;
  47521. /**
  47522. * Use this function to restart evaluating active meshes on every frame
  47523. * @returns the current scene
  47524. */
  47525. unfreezeActiveMeshes(): Scene;
  47526. private _evaluateActiveMeshes;
  47527. private _activeMesh;
  47528. /**
  47529. * Update the transform matrix to update from the current active camera
  47530. * @param force defines a boolean used to force the update even if cache is up to date
  47531. */
  47532. updateTransformMatrix(force?: boolean): void;
  47533. private _bindFrameBuffer;
  47534. /** @hidden */
  47535. _allowPostProcessClearColor: boolean;
  47536. /** @hidden */
  47537. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  47538. private _processSubCameras;
  47539. private _checkIntersections;
  47540. /** @hidden */
  47541. _advancePhysicsEngineStep(step: number): void;
  47542. /**
  47543. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  47544. */
  47545. getDeterministicFrameTime: () => number;
  47546. /** @hidden */
  47547. _animate(): void;
  47548. /** Execute all animations (for a frame) */
  47549. animate(): void;
  47550. /**
  47551. * Render the scene
  47552. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  47553. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  47554. */
  47555. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  47556. /**
  47557. * Freeze all materials
  47558. * A frozen material will not be updatable but should be faster to render
  47559. */
  47560. freezeMaterials(): void;
  47561. /**
  47562. * Unfreeze all materials
  47563. * A frozen material will not be updatable but should be faster to render
  47564. */
  47565. unfreezeMaterials(): void;
  47566. /**
  47567. * Releases all held ressources
  47568. */
  47569. dispose(): void;
  47570. /**
  47571. * Gets if the scene is already disposed
  47572. */
  47573. get isDisposed(): boolean;
  47574. /**
  47575. * Call this function to reduce memory footprint of the scene.
  47576. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  47577. */
  47578. clearCachedVertexData(): void;
  47579. /**
  47580. * This function will remove the local cached buffer data from texture.
  47581. * It will save memory but will prevent the texture from being rebuilt
  47582. */
  47583. cleanCachedTextureBuffer(): void;
  47584. /**
  47585. * Get the world extend vectors with an optional filter
  47586. *
  47587. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  47588. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  47589. */
  47590. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  47591. min: Vector3;
  47592. max: Vector3;
  47593. };
  47594. /**
  47595. * Creates a ray that can be used to pick in the scene
  47596. * @param x defines the x coordinate of the origin (on-screen)
  47597. * @param y defines the y coordinate of the origin (on-screen)
  47598. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  47599. * @param camera defines the camera to use for the picking
  47600. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  47601. * @returns a Ray
  47602. */
  47603. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  47604. /**
  47605. * Creates a ray that can be used to pick in the scene
  47606. * @param x defines the x coordinate of the origin (on-screen)
  47607. * @param y defines the y coordinate of the origin (on-screen)
  47608. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  47609. * @param result defines the ray where to store the picking ray
  47610. * @param camera defines the camera to use for the picking
  47611. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  47612. * @returns the current scene
  47613. */
  47614. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  47615. /**
  47616. * Creates a ray that can be used to pick in the scene
  47617. * @param x defines the x coordinate of the origin (on-screen)
  47618. * @param y defines the y coordinate of the origin (on-screen)
  47619. * @param camera defines the camera to use for the picking
  47620. * @returns a Ray
  47621. */
  47622. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  47623. /**
  47624. * Creates a ray that can be used to pick in the scene
  47625. * @param x defines the x coordinate of the origin (on-screen)
  47626. * @param y defines the y coordinate of the origin (on-screen)
  47627. * @param result defines the ray where to store the picking ray
  47628. * @param camera defines the camera to use for the picking
  47629. * @returns the current scene
  47630. */
  47631. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  47632. /** Launch a ray to try to pick a mesh in the scene
  47633. * @param x position on screen
  47634. * @param y position on screen
  47635. * @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
  47636. * @param fastCheck defines if the first intersection will be used (and not the closest)
  47637. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  47638. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  47639. * @returns a PickingInfo
  47640. */
  47641. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  47642. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  47643. * @param x position on screen
  47644. * @param y position on screen
  47645. * @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
  47646. * @param fastCheck defines if the first intersection will be used (and not the closest)
  47647. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  47648. * @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)
  47649. */
  47650. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  47651. /** Use the given ray to pick a mesh in the scene
  47652. * @param ray The ray to use to pick meshes
  47653. * @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
  47654. * @param fastCheck defines if the first intersection will be used (and not the closest)
  47655. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  47656. * @returns a PickingInfo
  47657. */
  47658. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  47659. /**
  47660. * Launch a ray to try to pick a mesh in the scene
  47661. * @param x X position on screen
  47662. * @param y Y position on screen
  47663. * @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
  47664. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  47665. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  47666. * @returns an array of PickingInfo
  47667. */
  47668. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  47669. /**
  47670. * Launch a ray to try to pick a mesh in the scene
  47671. * @param ray Ray to use
  47672. * @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
  47673. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  47674. * @returns an array of PickingInfo
  47675. */
  47676. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  47677. /**
  47678. * Force the value of meshUnderPointer
  47679. * @param mesh defines the mesh to use
  47680. * @param pointerId optional pointer id when using more than one pointer
  47681. */
  47682. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  47683. /**
  47684. * Gets the mesh under the pointer
  47685. * @returns a Mesh or null if no mesh is under the pointer
  47686. */
  47687. getPointerOverMesh(): Nullable<AbstractMesh>;
  47688. /** @hidden */
  47689. _rebuildGeometries(): void;
  47690. /** @hidden */
  47691. _rebuildTextures(): void;
  47692. private _getByTags;
  47693. /**
  47694. * Get a list of meshes by tags
  47695. * @param tagsQuery defines the tags query to use
  47696. * @param forEach defines a predicate used to filter results
  47697. * @returns an array of Mesh
  47698. */
  47699. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  47700. /**
  47701. * Get a list of cameras by tags
  47702. * @param tagsQuery defines the tags query to use
  47703. * @param forEach defines a predicate used to filter results
  47704. * @returns an array of Camera
  47705. */
  47706. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  47707. /**
  47708. * Get a list of lights by tags
  47709. * @param tagsQuery defines the tags query to use
  47710. * @param forEach defines a predicate used to filter results
  47711. * @returns an array of Light
  47712. */
  47713. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  47714. /**
  47715. * Get a list of materials by tags
  47716. * @param tagsQuery defines the tags query to use
  47717. * @param forEach defines a predicate used to filter results
  47718. * @returns an array of Material
  47719. */
  47720. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  47721. /**
  47722. * Get a list of transform nodes by tags
  47723. * @param tagsQuery defines the tags query to use
  47724. * @param forEach defines a predicate used to filter results
  47725. * @returns an array of TransformNode
  47726. */
  47727. getTransformNodesByTags(tagsQuery: string, forEach?: (transform: TransformNode) => void): TransformNode[];
  47728. /**
  47729. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  47730. * This allowed control for front to back rendering or reversly depending of the special needs.
  47731. *
  47732. * @param renderingGroupId The rendering group id corresponding to its index
  47733. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  47734. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  47735. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  47736. */
  47737. 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;
  47738. /**
  47739. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  47740. *
  47741. * @param renderingGroupId The rendering group id corresponding to its index
  47742. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  47743. * @param depth Automatically clears depth between groups if true and autoClear is true.
  47744. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  47745. */
  47746. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  47747. /**
  47748. * Gets the current auto clear configuration for one rendering group of the rendering
  47749. * manager.
  47750. * @param index the rendering group index to get the information for
  47751. * @returns The auto clear setup for the requested rendering group
  47752. */
  47753. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  47754. private _blockMaterialDirtyMechanism;
  47755. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  47756. get blockMaterialDirtyMechanism(): boolean;
  47757. set blockMaterialDirtyMechanism(value: boolean);
  47758. /**
  47759. * Will flag all materials as dirty to trigger new shader compilation
  47760. * @param flag defines the flag used to specify which material part must be marked as dirty
  47761. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  47762. */
  47763. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  47764. /** @hidden */
  47765. _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;
  47766. /** @hidden */
  47767. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  47768. /** @hidden */
  47769. _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;
  47770. /** @hidden */
  47771. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  47772. /** @hidden */
  47773. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  47774. /** @hidden */
  47775. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  47776. }
  47777. }
  47778. declare module BABYLON {
  47779. /**
  47780. * Set of assets to keep when moving a scene into an asset container.
  47781. */
  47782. export class KeepAssets extends AbstractScene {
  47783. }
  47784. /**
  47785. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  47786. */
  47787. export class InstantiatedEntries {
  47788. /**
  47789. * List of new root nodes (eg. nodes with no parent)
  47790. */
  47791. rootNodes: TransformNode[];
  47792. /**
  47793. * List of new skeletons
  47794. */
  47795. skeletons: Skeleton[];
  47796. /**
  47797. * List of new animation groups
  47798. */
  47799. animationGroups: AnimationGroup[];
  47800. }
  47801. /**
  47802. * Container with a set of assets that can be added or removed from a scene.
  47803. */
  47804. export class AssetContainer extends AbstractScene {
  47805. private _wasAddedToScene;
  47806. /**
  47807. * The scene the AssetContainer belongs to.
  47808. */
  47809. scene: Scene;
  47810. /**
  47811. * Instantiates an AssetContainer.
  47812. * @param scene The scene the AssetContainer belongs to.
  47813. */
  47814. constructor(scene: Scene);
  47815. /**
  47816. * Instantiate or clone all meshes and add the new ones to the scene.
  47817. * Skeletons and animation groups will all be cloned
  47818. * @param nameFunction defines an optional function used to get new names for clones
  47819. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  47820. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  47821. */
  47822. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  47823. /**
  47824. * Adds all the assets from the container to the scene.
  47825. */
  47826. addAllToScene(): void;
  47827. /**
  47828. * Removes all the assets in the container from the scene
  47829. */
  47830. removeAllFromScene(): void;
  47831. /**
  47832. * Disposes all the assets in the container
  47833. */
  47834. dispose(): void;
  47835. private _moveAssets;
  47836. /**
  47837. * Removes all the assets contained in the scene and adds them to the container.
  47838. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  47839. */
  47840. moveAllFromScene(keepAssets?: KeepAssets): void;
  47841. /**
  47842. * 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.
  47843. * @returns the root mesh
  47844. */
  47845. createRootMesh(): Mesh;
  47846. /**
  47847. * Merge animations (direct and animation groups) from this asset container into a scene
  47848. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  47849. * @param animatables set of animatables to retarget to a node from the scene
  47850. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  47851. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  47852. */
  47853. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  47854. }
  47855. }
  47856. declare module BABYLON {
  47857. /**
  47858. * Defines how the parser contract is defined.
  47859. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  47860. */
  47861. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  47862. /**
  47863. * Defines how the individual parser contract is defined.
  47864. * These parser can parse an individual asset
  47865. */
  47866. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  47867. /**
  47868. * Base class of the scene acting as a container for the different elements composing a scene.
  47869. * This class is dynamically extended by the different components of the scene increasing
  47870. * flexibility and reducing coupling
  47871. */
  47872. export abstract class AbstractScene {
  47873. /**
  47874. * Stores the list of available parsers in the application.
  47875. */
  47876. private static _BabylonFileParsers;
  47877. /**
  47878. * Stores the list of available individual parsers in the application.
  47879. */
  47880. private static _IndividualBabylonFileParsers;
  47881. /**
  47882. * Adds a parser in the list of available ones
  47883. * @param name Defines the name of the parser
  47884. * @param parser Defines the parser to add
  47885. */
  47886. static AddParser(name: string, parser: BabylonFileParser): void;
  47887. /**
  47888. * Gets a general parser from the list of avaialble ones
  47889. * @param name Defines the name of the parser
  47890. * @returns the requested parser or null
  47891. */
  47892. static GetParser(name: string): Nullable<BabylonFileParser>;
  47893. /**
  47894. * Adds n individual parser in the list of available ones
  47895. * @param name Defines the name of the parser
  47896. * @param parser Defines the parser to add
  47897. */
  47898. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  47899. /**
  47900. * Gets an individual parser from the list of avaialble ones
  47901. * @param name Defines the name of the parser
  47902. * @returns the requested parser or null
  47903. */
  47904. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  47905. /**
  47906. * Parser json data and populate both a scene and its associated container object
  47907. * @param jsonData Defines the data to parse
  47908. * @param scene Defines the scene to parse the data for
  47909. * @param container Defines the container attached to the parsing sequence
  47910. * @param rootUrl Defines the root url of the data
  47911. */
  47912. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  47913. /**
  47914. * Gets the list of root nodes (ie. nodes with no parent)
  47915. */
  47916. rootNodes: Node[];
  47917. /** All of the cameras added to this scene
  47918. * @see https://doc.babylonjs.com/babylon101/cameras
  47919. */
  47920. cameras: Camera[];
  47921. /**
  47922. * All of the lights added to this scene
  47923. * @see https://doc.babylonjs.com/babylon101/lights
  47924. */
  47925. lights: Light[];
  47926. /**
  47927. * All of the (abstract) meshes added to this scene
  47928. */
  47929. meshes: AbstractMesh[];
  47930. /**
  47931. * The list of skeletons added to the scene
  47932. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  47933. */
  47934. skeletons: Skeleton[];
  47935. /**
  47936. * All of the particle systems added to this scene
  47937. * @see https://doc.babylonjs.com/babylon101/particles
  47938. */
  47939. particleSystems: IParticleSystem[];
  47940. /**
  47941. * Gets a list of Animations associated with the scene
  47942. */
  47943. animations: Animation[];
  47944. /**
  47945. * All of the animation groups added to this scene
  47946. * @see https://doc.babylonjs.com/how_to/group
  47947. */
  47948. animationGroups: AnimationGroup[];
  47949. /**
  47950. * All of the multi-materials added to this scene
  47951. * @see https://doc.babylonjs.com/how_to/multi_materials
  47952. */
  47953. multiMaterials: MultiMaterial[];
  47954. /**
  47955. * All of the materials added to this scene
  47956. * In the context of a Scene, it is not supposed to be modified manually.
  47957. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  47958. * Note also that the order of the Material within the array is not significant and might change.
  47959. * @see https://doc.babylonjs.com/babylon101/materials
  47960. */
  47961. materials: Material[];
  47962. /**
  47963. * The list of morph target managers added to the scene
  47964. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  47965. */
  47966. morphTargetManagers: MorphTargetManager[];
  47967. /**
  47968. * The list of geometries used in the scene.
  47969. */
  47970. geometries: Geometry[];
  47971. /**
  47972. * All of the tranform nodes added to this scene
  47973. * In the context of a Scene, it is not supposed to be modified manually.
  47974. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  47975. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  47976. * @see https://doc.babylonjs.com/how_to/transformnode
  47977. */
  47978. transformNodes: TransformNode[];
  47979. /**
  47980. * ActionManagers available on the scene.
  47981. */
  47982. actionManagers: AbstractActionManager[];
  47983. /**
  47984. * Textures to keep.
  47985. */
  47986. textures: BaseTexture[];
  47987. /** @hidden */
  47988. protected _environmentTexture: Nullable<BaseTexture>;
  47989. /**
  47990. * Texture used in all pbr material as the reflection texture.
  47991. * As in the majority of the scene they are the same (exception for multi room and so on),
  47992. * this is easier to reference from here than from all the materials.
  47993. */
  47994. get environmentTexture(): Nullable<BaseTexture>;
  47995. set environmentTexture(value: Nullable<BaseTexture>);
  47996. /**
  47997. * The list of postprocesses added to the scene
  47998. */
  47999. postProcesses: PostProcess[];
  48000. /**
  48001. * @returns all meshes, lights, cameras, transformNodes and bones
  48002. */
  48003. getNodes(): Array<Node>;
  48004. }
  48005. }
  48006. declare module BABYLON {
  48007. /**
  48008. * Interface used to define options for Sound class
  48009. */
  48010. export interface ISoundOptions {
  48011. /**
  48012. * Does the sound autoplay once loaded.
  48013. */
  48014. autoplay?: boolean;
  48015. /**
  48016. * Does the sound loop after it finishes playing once.
  48017. */
  48018. loop?: boolean;
  48019. /**
  48020. * Sound's volume
  48021. */
  48022. volume?: number;
  48023. /**
  48024. * Is it a spatial sound?
  48025. */
  48026. spatialSound?: boolean;
  48027. /**
  48028. * Maximum distance to hear that sound
  48029. */
  48030. maxDistance?: number;
  48031. /**
  48032. * Uses user defined attenuation function
  48033. */
  48034. useCustomAttenuation?: boolean;
  48035. /**
  48036. * Define the roll off factor of spatial sounds.
  48037. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  48038. */
  48039. rolloffFactor?: number;
  48040. /**
  48041. * Define the reference distance the sound should be heard perfectly.
  48042. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  48043. */
  48044. refDistance?: number;
  48045. /**
  48046. * Define the distance attenuation model the sound will follow.
  48047. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  48048. */
  48049. distanceModel?: string;
  48050. /**
  48051. * Defines the playback speed (1 by default)
  48052. */
  48053. playbackRate?: number;
  48054. /**
  48055. * Defines if the sound is from a streaming source
  48056. */
  48057. streaming?: boolean;
  48058. /**
  48059. * Defines an optional length (in seconds) inside the sound file
  48060. */
  48061. length?: number;
  48062. /**
  48063. * Defines an optional offset (in seconds) inside the sound file
  48064. */
  48065. offset?: number;
  48066. /**
  48067. * If true, URLs will not be required to state the audio file codec to use.
  48068. */
  48069. skipCodecCheck?: boolean;
  48070. }
  48071. }
  48072. declare module BABYLON {
  48073. /**
  48074. * Defines a sound that can be played in the application.
  48075. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  48076. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  48077. */
  48078. export class Sound {
  48079. /**
  48080. * The name of the sound in the scene.
  48081. */
  48082. name: string;
  48083. /**
  48084. * Does the sound autoplay once loaded.
  48085. */
  48086. autoplay: boolean;
  48087. private _loop;
  48088. /**
  48089. * Does the sound loop after it finishes playing once.
  48090. */
  48091. get loop(): boolean;
  48092. set loop(value: boolean);
  48093. /**
  48094. * Does the sound use a custom attenuation curve to simulate the falloff
  48095. * happening when the source gets further away from the camera.
  48096. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  48097. */
  48098. useCustomAttenuation: boolean;
  48099. /**
  48100. * The sound track id this sound belongs to.
  48101. */
  48102. soundTrackId: number;
  48103. /**
  48104. * Is this sound currently played.
  48105. */
  48106. isPlaying: boolean;
  48107. /**
  48108. * Is this sound currently paused.
  48109. */
  48110. isPaused: boolean;
  48111. /**
  48112. * Does this sound enables spatial sound.
  48113. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  48114. */
  48115. spatialSound: boolean;
  48116. /**
  48117. * Define the reference distance the sound should be heard perfectly.
  48118. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  48119. */
  48120. refDistance: number;
  48121. /**
  48122. * Define the roll off factor of spatial sounds.
  48123. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  48124. */
  48125. rolloffFactor: number;
  48126. /**
  48127. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  48128. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  48129. */
  48130. maxDistance: number;
  48131. /**
  48132. * Define the distance attenuation model the sound will follow.
  48133. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  48134. */
  48135. distanceModel: string;
  48136. /**
  48137. * @hidden
  48138. * Back Compat
  48139. **/
  48140. onended: () => any;
  48141. /**
  48142. * Gets or sets an object used to store user defined information for the sound.
  48143. */
  48144. metadata: any;
  48145. /**
  48146. * Observable event when the current playing sound finishes.
  48147. */
  48148. onEndedObservable: Observable<Sound>;
  48149. /**
  48150. * Gets the current time for the sound.
  48151. */
  48152. get currentTime(): number;
  48153. private _panningModel;
  48154. private _playbackRate;
  48155. private _streaming;
  48156. private _startTime;
  48157. private _startOffset;
  48158. private _position;
  48159. /** @hidden */
  48160. _positionInEmitterSpace: boolean;
  48161. private _localDirection;
  48162. private _volume;
  48163. private _isReadyToPlay;
  48164. private _isDirectional;
  48165. private _readyToPlayCallback;
  48166. private _audioBuffer;
  48167. private _soundSource;
  48168. private _streamingSource;
  48169. private _soundPanner;
  48170. private _soundGain;
  48171. private _inputAudioNode;
  48172. private _outputAudioNode;
  48173. private _coneInnerAngle;
  48174. private _coneOuterAngle;
  48175. private _coneOuterGain;
  48176. private _scene;
  48177. private _connectedTransformNode;
  48178. private _customAttenuationFunction;
  48179. private _registerFunc;
  48180. private _isOutputConnected;
  48181. private _htmlAudioElement;
  48182. private _urlType;
  48183. private _length?;
  48184. private _offset?;
  48185. /** @hidden */
  48186. static _SceneComponentInitialization: (scene: Scene) => void;
  48187. /**
  48188. * Create a sound and attach it to a scene
  48189. * @param name Name of your sound
  48190. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  48191. * @param scene defines the scene the sound belongs to
  48192. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  48193. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  48194. */
  48195. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  48196. /**
  48197. * Release the sound and its associated resources
  48198. */
  48199. dispose(): void;
  48200. /**
  48201. * Gets if the sounds is ready to be played or not.
  48202. * @returns true if ready, otherwise false
  48203. */
  48204. isReady(): boolean;
  48205. /**
  48206. * Get the current class name.
  48207. * @returns current class name
  48208. */
  48209. getClassName(): string;
  48210. private _soundLoaded;
  48211. /**
  48212. * Sets the data of the sound from an audiobuffer
  48213. * @param audioBuffer The audioBuffer containing the data
  48214. */
  48215. setAudioBuffer(audioBuffer: AudioBuffer): void;
  48216. /**
  48217. * Updates the current sounds options such as maxdistance, loop...
  48218. * @param options A JSON object containing values named as the object properties
  48219. */
  48220. updateOptions(options: ISoundOptions): void;
  48221. private _createSpatialParameters;
  48222. private _updateSpatialParameters;
  48223. /**
  48224. * Switch the panning model to HRTF:
  48225. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  48226. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  48227. */
  48228. switchPanningModelToHRTF(): void;
  48229. /**
  48230. * Switch the panning model to Equal Power:
  48231. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  48232. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  48233. */
  48234. switchPanningModelToEqualPower(): void;
  48235. private _switchPanningModel;
  48236. /**
  48237. * Connect this sound to a sound track audio node like gain...
  48238. * @param soundTrackAudioNode the sound track audio node to connect to
  48239. */
  48240. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  48241. /**
  48242. * Transform this sound into a directional source
  48243. * @param coneInnerAngle Size of the inner cone in degree
  48244. * @param coneOuterAngle Size of the outer cone in degree
  48245. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  48246. */
  48247. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  48248. /**
  48249. * Gets or sets the inner angle for the directional cone.
  48250. */
  48251. get directionalConeInnerAngle(): number;
  48252. /**
  48253. * Gets or sets the inner angle for the directional cone.
  48254. */
  48255. set directionalConeInnerAngle(value: number);
  48256. /**
  48257. * Gets or sets the outer angle for the directional cone.
  48258. */
  48259. get directionalConeOuterAngle(): number;
  48260. /**
  48261. * Gets or sets the outer angle for the directional cone.
  48262. */
  48263. set directionalConeOuterAngle(value: number);
  48264. /**
  48265. * Sets the position of the emitter if spatial sound is enabled
  48266. * @param newPosition Defines the new posisiton
  48267. */
  48268. setPosition(newPosition: Vector3): void;
  48269. /**
  48270. * Sets the local direction of the emitter if spatial sound is enabled
  48271. * @param newLocalDirection Defines the new local direction
  48272. */
  48273. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  48274. private _updateDirection;
  48275. /** @hidden */
  48276. updateDistanceFromListener(): void;
  48277. /**
  48278. * Sets a new custom attenuation function for the sound.
  48279. * @param callback Defines the function used for the attenuation
  48280. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  48281. */
  48282. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  48283. /**
  48284. * Play the sound
  48285. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  48286. * @param offset (optional) Start the sound at a specific time in seconds
  48287. * @param length (optional) Sound duration (in seconds)
  48288. */
  48289. play(time?: number, offset?: number, length?: number): void;
  48290. private _onended;
  48291. /**
  48292. * Stop the sound
  48293. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  48294. */
  48295. stop(time?: number): void;
  48296. /**
  48297. * Put the sound in pause
  48298. */
  48299. pause(): void;
  48300. /**
  48301. * Sets a dedicated volume for this sounds
  48302. * @param newVolume Define the new volume of the sound
  48303. * @param time Define time for gradual change to new volume
  48304. */
  48305. setVolume(newVolume: number, time?: number): void;
  48306. /**
  48307. * Set the sound play back rate
  48308. * @param newPlaybackRate Define the playback rate the sound should be played at
  48309. */
  48310. setPlaybackRate(newPlaybackRate: number): void;
  48311. /**
  48312. * Gets the volume of the sound.
  48313. * @returns the volume of the sound
  48314. */
  48315. getVolume(): number;
  48316. /**
  48317. * Attach the sound to a dedicated mesh
  48318. * @param transformNode The transform node to connect the sound with
  48319. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  48320. */
  48321. attachToMesh(transformNode: TransformNode): void;
  48322. /**
  48323. * Detach the sound from the previously attached mesh
  48324. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  48325. */
  48326. detachFromMesh(): void;
  48327. private _onRegisterAfterWorldMatrixUpdate;
  48328. /**
  48329. * Clone the current sound in the scene.
  48330. * @returns the new sound clone
  48331. */
  48332. clone(): Nullable<Sound>;
  48333. /**
  48334. * Gets the current underlying audio buffer containing the data
  48335. * @returns the audio buffer
  48336. */
  48337. getAudioBuffer(): Nullable<AudioBuffer>;
  48338. /**
  48339. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  48340. * @returns the source node
  48341. */
  48342. getSoundSource(): Nullable<AudioBufferSourceNode>;
  48343. /**
  48344. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  48345. * @returns the gain node
  48346. */
  48347. getSoundGain(): Nullable<GainNode>;
  48348. /**
  48349. * Serializes the Sound in a JSON representation
  48350. * @returns the JSON representation of the sound
  48351. */
  48352. serialize(): any;
  48353. /**
  48354. * Parse a JSON representation of a sound to innstantiate in a given scene
  48355. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  48356. * @param scene Define the scene the new parsed sound should be created in
  48357. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  48358. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  48359. * @returns the newly parsed sound
  48360. */
  48361. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  48362. }
  48363. }
  48364. declare module BABYLON {
  48365. /**
  48366. * This defines an action helpful to play a defined sound on a triggered action.
  48367. */
  48368. export class PlaySoundAction extends Action {
  48369. private _sound;
  48370. /**
  48371. * Instantiate the action
  48372. * @param triggerOptions defines the trigger options
  48373. * @param sound defines the sound to play
  48374. * @param condition defines the trigger related conditions
  48375. */
  48376. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  48377. /** @hidden */
  48378. _prepare(): void;
  48379. /**
  48380. * Execute the action and play the sound.
  48381. */
  48382. execute(): void;
  48383. /**
  48384. * Serializes the actions and its related information.
  48385. * @param parent defines the object to serialize in
  48386. * @returns the serialized object
  48387. */
  48388. serialize(parent: any): any;
  48389. }
  48390. /**
  48391. * This defines an action helpful to stop a defined sound on a triggered action.
  48392. */
  48393. export class StopSoundAction extends Action {
  48394. private _sound;
  48395. /**
  48396. * Instantiate the action
  48397. * @param triggerOptions defines the trigger options
  48398. * @param sound defines the sound to stop
  48399. * @param condition defines the trigger related conditions
  48400. */
  48401. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  48402. /** @hidden */
  48403. _prepare(): void;
  48404. /**
  48405. * Execute the action and stop the sound.
  48406. */
  48407. execute(): void;
  48408. /**
  48409. * Serializes the actions and its related information.
  48410. * @param parent defines the object to serialize in
  48411. * @returns the serialized object
  48412. */
  48413. serialize(parent: any): any;
  48414. }
  48415. }
  48416. declare module BABYLON {
  48417. /**
  48418. * This defines an action responsible to change the value of a property
  48419. * by interpolating between its current value and the newly set one once triggered.
  48420. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  48421. */
  48422. export class InterpolateValueAction extends Action {
  48423. /**
  48424. * Defines the path of the property where the value should be interpolated
  48425. */
  48426. propertyPath: string;
  48427. /**
  48428. * Defines the target value at the end of the interpolation.
  48429. */
  48430. value: any;
  48431. /**
  48432. * Defines the time it will take for the property to interpolate to the value.
  48433. */
  48434. duration: number;
  48435. /**
  48436. * Defines if the other scene animations should be stopped when the action has been triggered
  48437. */
  48438. stopOtherAnimations?: boolean;
  48439. /**
  48440. * Defines a callback raised once the interpolation animation has been done.
  48441. */
  48442. onInterpolationDone?: () => void;
  48443. /**
  48444. * Observable triggered once the interpolation animation has been done.
  48445. */
  48446. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  48447. private _target;
  48448. private _effectiveTarget;
  48449. private _property;
  48450. /**
  48451. * Instantiate the action
  48452. * @param triggerOptions defines the trigger options
  48453. * @param target defines the object containing the value to interpolate
  48454. * @param propertyPath defines the path to the property in the target object
  48455. * @param value defines the target value at the end of the interpolation
  48456. * @param duration deines the time it will take for the property to interpolate to the value.
  48457. * @param condition defines the trigger related conditions
  48458. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  48459. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  48460. */
  48461. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  48462. /** @hidden */
  48463. _prepare(): void;
  48464. /**
  48465. * Execute the action starts the value interpolation.
  48466. */
  48467. execute(): void;
  48468. /**
  48469. * Serializes the actions and its related information.
  48470. * @param parent defines the object to serialize in
  48471. * @returns the serialized object
  48472. */
  48473. serialize(parent: any): any;
  48474. }
  48475. }
  48476. declare module BABYLON {
  48477. /**
  48478. * This represents the default audio engine used in babylon.
  48479. * It is responsible to play, synchronize and analyse sounds throughout the application.
  48480. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  48481. */
  48482. export class AudioEngine implements IAudioEngine {
  48483. private _audioContext;
  48484. private _audioContextInitialized;
  48485. private _muteButton;
  48486. private _hostElement;
  48487. /**
  48488. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  48489. */
  48490. canUseWebAudio: boolean;
  48491. /**
  48492. * The master gain node defines the global audio volume of your audio engine.
  48493. */
  48494. masterGain: GainNode;
  48495. /**
  48496. * Defines if Babylon should emit a warning if WebAudio is not supported.
  48497. * @ignoreNaming
  48498. */
  48499. WarnedWebAudioUnsupported: boolean;
  48500. /**
  48501. * Gets whether or not mp3 are supported by your browser.
  48502. */
  48503. isMP3supported: boolean;
  48504. /**
  48505. * Gets whether or not ogg are supported by your browser.
  48506. */
  48507. isOGGsupported: boolean;
  48508. /**
  48509. * Gets whether audio has been unlocked on the device.
  48510. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  48511. * a user interaction has happened.
  48512. */
  48513. unlocked: boolean;
  48514. /**
  48515. * Defines if the audio engine relies on a custom unlocked button.
  48516. * In this case, the embedded button will not be displayed.
  48517. */
  48518. useCustomUnlockedButton: boolean;
  48519. /**
  48520. * Event raised when audio has been unlocked on the browser.
  48521. */
  48522. onAudioUnlockedObservable: Observable<IAudioEngine>;
  48523. /**
  48524. * Event raised when audio has been locked on the browser.
  48525. */
  48526. onAudioLockedObservable: Observable<IAudioEngine>;
  48527. /**
  48528. * Gets the current AudioContext if available.
  48529. */
  48530. get audioContext(): Nullable<AudioContext>;
  48531. private _connectedAnalyser;
  48532. /**
  48533. * Instantiates a new audio engine.
  48534. *
  48535. * There should be only one per page as some browsers restrict the number
  48536. * of audio contexts you can create.
  48537. * @param hostElement defines the host element where to display the mute icon if necessary
  48538. */
  48539. constructor(hostElement?: Nullable<HTMLElement>);
  48540. /**
  48541. * Flags the audio engine in Locked state.
  48542. * This happens due to new browser policies preventing audio to autoplay.
  48543. */
  48544. lock(): void;
  48545. /**
  48546. * Unlocks the audio engine once a user action has been done on the dom.
  48547. * This is helpful to resume play once browser policies have been satisfied.
  48548. */
  48549. unlock(): void;
  48550. private _resumeAudioContext;
  48551. private _initializeAudioContext;
  48552. private _tryToRun;
  48553. private _triggerRunningState;
  48554. private _triggerSuspendedState;
  48555. private _displayMuteButton;
  48556. private _moveButtonToTopLeft;
  48557. private _onResize;
  48558. private _hideMuteButton;
  48559. /**
  48560. * Destroy and release the resources associated with the audio ccontext.
  48561. */
  48562. dispose(): void;
  48563. /**
  48564. * Gets the global volume sets on the master gain.
  48565. * @returns the global volume if set or -1 otherwise
  48566. */
  48567. getGlobalVolume(): number;
  48568. /**
  48569. * Sets the global volume of your experience (sets on the master gain).
  48570. * @param newVolume Defines the new global volume of the application
  48571. */
  48572. setGlobalVolume(newVolume: number): void;
  48573. /**
  48574. * Connect the audio engine to an audio analyser allowing some amazing
  48575. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  48576. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  48577. * @param analyser The analyser to connect to the engine
  48578. */
  48579. connectToAnalyser(analyser: Analyser): void;
  48580. }
  48581. }
  48582. declare module BABYLON {
  48583. /**
  48584. * Options allowed during the creation of a sound track.
  48585. */
  48586. export interface ISoundTrackOptions {
  48587. /**
  48588. * The volume the sound track should take during creation
  48589. */
  48590. volume?: number;
  48591. /**
  48592. * Define if the sound track is the main sound track of the scene
  48593. */
  48594. mainTrack?: boolean;
  48595. }
  48596. /**
  48597. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  48598. * It will be also used in a future release to apply effects on a specific track.
  48599. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  48600. */
  48601. export class SoundTrack {
  48602. /**
  48603. * The unique identifier of the sound track in the scene.
  48604. */
  48605. id: number;
  48606. /**
  48607. * The list of sounds included in the sound track.
  48608. */
  48609. soundCollection: Array<Sound>;
  48610. private _outputAudioNode;
  48611. private _scene;
  48612. private _connectedAnalyser;
  48613. private _options;
  48614. private _isInitialized;
  48615. /**
  48616. * Creates a new sound track.
  48617. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  48618. * @param scene Define the scene the sound track belongs to
  48619. * @param options
  48620. */
  48621. constructor(scene: Scene, options?: ISoundTrackOptions);
  48622. private _initializeSoundTrackAudioGraph;
  48623. /**
  48624. * Release the sound track and its associated resources
  48625. */
  48626. dispose(): void;
  48627. /**
  48628. * Adds a sound to this sound track
  48629. * @param sound define the cound to add
  48630. * @ignoreNaming
  48631. */
  48632. addSound(sound: Sound): void;
  48633. /**
  48634. * Removes a sound to this sound track
  48635. * @param sound define the cound to remove
  48636. * @ignoreNaming
  48637. */
  48638. removeSound(sound: Sound): void;
  48639. /**
  48640. * Set a global volume for the full sound track.
  48641. * @param newVolume Define the new volume of the sound track
  48642. */
  48643. setVolume(newVolume: number): void;
  48644. /**
  48645. * Switch the panning model to HRTF:
  48646. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  48647. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  48648. */
  48649. switchPanningModelToHRTF(): void;
  48650. /**
  48651. * Switch the panning model to Equal Power:
  48652. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  48653. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  48654. */
  48655. switchPanningModelToEqualPower(): void;
  48656. /**
  48657. * Connect the sound track to an audio analyser allowing some amazing
  48658. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  48659. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  48660. * @param analyser The analyser to connect to the engine
  48661. */
  48662. connectToAnalyser(analyser: Analyser): void;
  48663. }
  48664. }
  48665. declare module BABYLON {
  48666. interface AbstractScene {
  48667. /**
  48668. * The list of sounds used in the scene.
  48669. */
  48670. sounds: Nullable<Array<Sound>>;
  48671. }
  48672. interface Scene {
  48673. /**
  48674. * @hidden
  48675. * Backing field
  48676. */
  48677. _mainSoundTrack: SoundTrack;
  48678. /**
  48679. * The main sound track played by the scene.
  48680. * It cotains your primary collection of sounds.
  48681. */
  48682. mainSoundTrack: SoundTrack;
  48683. /**
  48684. * The list of sound tracks added to the scene
  48685. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  48686. */
  48687. soundTracks: Nullable<Array<SoundTrack>>;
  48688. /**
  48689. * Gets a sound using a given name
  48690. * @param name defines the name to search for
  48691. * @return the found sound or null if not found at all.
  48692. */
  48693. getSoundByName(name: string): Nullable<Sound>;
  48694. /**
  48695. * Gets or sets if audio support is enabled
  48696. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  48697. */
  48698. audioEnabled: boolean;
  48699. /**
  48700. * Gets or sets if audio will be output to headphones
  48701. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  48702. */
  48703. headphone: boolean;
  48704. /**
  48705. * Gets or sets custom audio listener position provider
  48706. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  48707. */
  48708. audioListenerPositionProvider: Nullable<() => Vector3>;
  48709. /**
  48710. * Gets or sets a refresh rate when using 3D audio positioning
  48711. */
  48712. audioPositioningRefreshRate: number;
  48713. }
  48714. /**
  48715. * Defines the sound scene component responsible to manage any sounds
  48716. * in a given scene.
  48717. */
  48718. export class AudioSceneComponent implements ISceneSerializableComponent {
  48719. private static _CameraDirectionLH;
  48720. private static _CameraDirectionRH;
  48721. /**
  48722. * The component name helpfull to identify the component in the list of scene components.
  48723. */
  48724. readonly name: string;
  48725. /**
  48726. * The scene the component belongs to.
  48727. */
  48728. scene: Scene;
  48729. private _audioEnabled;
  48730. /**
  48731. * Gets whether audio is enabled or not.
  48732. * Please use related enable/disable method to switch state.
  48733. */
  48734. get audioEnabled(): boolean;
  48735. private _headphone;
  48736. /**
  48737. * Gets whether audio is outputing to headphone or not.
  48738. * Please use the according Switch methods to change output.
  48739. */
  48740. get headphone(): boolean;
  48741. /**
  48742. * Gets or sets a refresh rate when using 3D audio positioning
  48743. */
  48744. audioPositioningRefreshRate: number;
  48745. private _audioListenerPositionProvider;
  48746. /**
  48747. * Gets the current audio listener position provider
  48748. */
  48749. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  48750. /**
  48751. * Sets a custom listener position for all sounds in the scene
  48752. * By default, this is the position of the first active camera
  48753. */
  48754. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  48755. /**
  48756. * Creates a new instance of the component for the given scene
  48757. * @param scene Defines the scene to register the component in
  48758. */
  48759. constructor(scene: Scene);
  48760. /**
  48761. * Registers the component in a given scene
  48762. */
  48763. register(): void;
  48764. /**
  48765. * Rebuilds the elements related to this component in case of
  48766. * context lost for instance.
  48767. */
  48768. rebuild(): void;
  48769. /**
  48770. * Serializes the component data to the specified json object
  48771. * @param serializationObject The object to serialize to
  48772. */
  48773. serialize(serializationObject: any): void;
  48774. /**
  48775. * Adds all the elements from the container to the scene
  48776. * @param container the container holding the elements
  48777. */
  48778. addFromContainer(container: AbstractScene): void;
  48779. /**
  48780. * Removes all the elements in the container from the scene
  48781. * @param container contains the elements to remove
  48782. * @param dispose if the removed element should be disposed (default: false)
  48783. */
  48784. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  48785. /**
  48786. * Disposes the component and the associated ressources.
  48787. */
  48788. dispose(): void;
  48789. /**
  48790. * Disables audio in the associated scene.
  48791. */
  48792. disableAudio(): void;
  48793. /**
  48794. * Enables audio in the associated scene.
  48795. */
  48796. enableAudio(): void;
  48797. /**
  48798. * Switch audio to headphone output.
  48799. */
  48800. switchAudioModeForHeadphones(): void;
  48801. /**
  48802. * Switch audio to normal speakers.
  48803. */
  48804. switchAudioModeForNormalSpeakers(): void;
  48805. private _cachedCameraDirection;
  48806. private _cachedCameraPosition;
  48807. private _lastCheck;
  48808. private _afterRender;
  48809. }
  48810. }
  48811. declare module BABYLON {
  48812. /**
  48813. * Wraps one or more Sound objects and selects one with random weight for playback.
  48814. */
  48815. export class WeightedSound {
  48816. /** When true a Sound will be selected and played when the current playing Sound completes. */
  48817. loop: boolean;
  48818. private _coneInnerAngle;
  48819. private _coneOuterAngle;
  48820. private _volume;
  48821. /** A Sound is currently playing. */
  48822. isPlaying: boolean;
  48823. /** A Sound is currently paused. */
  48824. isPaused: boolean;
  48825. private _sounds;
  48826. private _weights;
  48827. private _currentIndex?;
  48828. /**
  48829. * Creates a new WeightedSound from the list of sounds given.
  48830. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  48831. * @param sounds Array of Sounds that will be selected from.
  48832. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  48833. */
  48834. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  48835. /**
  48836. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  48837. */
  48838. get directionalConeInnerAngle(): number;
  48839. /**
  48840. * The size of cone in degress for a directional sound in which there will be no attenuation.
  48841. */
  48842. set directionalConeInnerAngle(value: number);
  48843. /**
  48844. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  48845. * Listener angles between innerAngle and outerAngle will falloff linearly.
  48846. */
  48847. get directionalConeOuterAngle(): number;
  48848. /**
  48849. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  48850. * Listener angles between innerAngle and outerAngle will falloff linearly.
  48851. */
  48852. set directionalConeOuterAngle(value: number);
  48853. /**
  48854. * Playback volume.
  48855. */
  48856. get volume(): number;
  48857. /**
  48858. * Playback volume.
  48859. */
  48860. set volume(value: number);
  48861. private _onended;
  48862. /**
  48863. * Suspend playback
  48864. */
  48865. pause(): void;
  48866. /**
  48867. * Stop playback
  48868. */
  48869. stop(): void;
  48870. /**
  48871. * Start playback.
  48872. * @param startOffset Position the clip head at a specific time in seconds.
  48873. */
  48874. play(startOffset?: number): void;
  48875. }
  48876. }
  48877. declare module BABYLON {
  48878. /**
  48879. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  48880. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  48881. */
  48882. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  48883. /**
  48884. * Gets the name of the behavior.
  48885. */
  48886. get name(): string;
  48887. /**
  48888. * The easing function used by animations
  48889. */
  48890. static EasingFunction: BackEase;
  48891. /**
  48892. * The easing mode used by animations
  48893. */
  48894. static EasingMode: number;
  48895. /**
  48896. * The duration of the animation, in milliseconds
  48897. */
  48898. transitionDuration: number;
  48899. /**
  48900. * Length of the distance animated by the transition when lower radius is reached
  48901. */
  48902. lowerRadiusTransitionRange: number;
  48903. /**
  48904. * Length of the distance animated by the transition when upper radius is reached
  48905. */
  48906. upperRadiusTransitionRange: number;
  48907. private _autoTransitionRange;
  48908. /**
  48909. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  48910. */
  48911. get autoTransitionRange(): boolean;
  48912. /**
  48913. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  48914. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  48915. */
  48916. set autoTransitionRange(value: boolean);
  48917. private _attachedCamera;
  48918. private _onAfterCheckInputsObserver;
  48919. private _onMeshTargetChangedObserver;
  48920. /**
  48921. * Initializes the behavior.
  48922. */
  48923. init(): void;
  48924. /**
  48925. * Attaches the behavior to its arc rotate camera.
  48926. * @param camera Defines the camera to attach the behavior to
  48927. */
  48928. attach(camera: ArcRotateCamera): void;
  48929. /**
  48930. * Detaches the behavior from its current arc rotate camera.
  48931. */
  48932. detach(): void;
  48933. private _radiusIsAnimating;
  48934. private _radiusBounceTransition;
  48935. private _animatables;
  48936. private _cachedWheelPrecision;
  48937. /**
  48938. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  48939. * @param radiusLimit The limit to check against.
  48940. * @return Bool to indicate if at limit.
  48941. */
  48942. private _isRadiusAtLimit;
  48943. /**
  48944. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  48945. * @param radiusDelta The delta by which to animate to. Can be negative.
  48946. */
  48947. private _applyBoundRadiusAnimation;
  48948. /**
  48949. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  48950. */
  48951. protected _clearAnimationLocks(): void;
  48952. /**
  48953. * Stops and removes all animations that have been applied to the camera
  48954. */
  48955. stopAllAnimations(): void;
  48956. }
  48957. }
  48958. declare module BABYLON {
  48959. /**
  48960. * 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.
  48961. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  48962. */
  48963. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  48964. /**
  48965. * Gets the name of the behavior.
  48966. */
  48967. get name(): string;
  48968. private _mode;
  48969. private _radiusScale;
  48970. private _positionScale;
  48971. private _defaultElevation;
  48972. private _elevationReturnTime;
  48973. private _elevationReturnWaitTime;
  48974. private _zoomStopsAnimation;
  48975. private _framingTime;
  48976. /**
  48977. * The easing function used by animations
  48978. */
  48979. static EasingFunction: ExponentialEase;
  48980. /**
  48981. * The easing mode used by animations
  48982. */
  48983. static EasingMode: number;
  48984. /**
  48985. * Sets the current mode used by the behavior
  48986. */
  48987. set mode(mode: number);
  48988. /**
  48989. * Gets current mode used by the behavior.
  48990. */
  48991. get mode(): number;
  48992. /**
  48993. * Sets the scale applied to the radius (1 by default)
  48994. */
  48995. set radiusScale(radius: number);
  48996. /**
  48997. * Gets the scale applied to the radius
  48998. */
  48999. get radiusScale(): number;
  49000. /**
  49001. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  49002. */
  49003. set positionScale(scale: number);
  49004. /**
  49005. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  49006. */
  49007. get positionScale(): number;
  49008. /**
  49009. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  49010. * behaviour is triggered, in radians.
  49011. */
  49012. set defaultElevation(elevation: number);
  49013. /**
  49014. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  49015. * behaviour is triggered, in radians.
  49016. */
  49017. get defaultElevation(): number;
  49018. /**
  49019. * Sets the time (in milliseconds) taken to return to the default beta position.
  49020. * Negative value indicates camera should not return to default.
  49021. */
  49022. set elevationReturnTime(speed: number);
  49023. /**
  49024. * Gets the time (in milliseconds) taken to return to the default beta position.
  49025. * Negative value indicates camera should not return to default.
  49026. */
  49027. get elevationReturnTime(): number;
  49028. /**
  49029. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  49030. */
  49031. set elevationReturnWaitTime(time: number);
  49032. /**
  49033. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  49034. */
  49035. get elevationReturnWaitTime(): number;
  49036. /**
  49037. * Sets the flag that indicates if user zooming should stop animation.
  49038. */
  49039. set zoomStopsAnimation(flag: boolean);
  49040. /**
  49041. * Gets the flag that indicates if user zooming should stop animation.
  49042. */
  49043. get zoomStopsAnimation(): boolean;
  49044. /**
  49045. * Sets the transition time when framing the mesh, in milliseconds
  49046. */
  49047. set framingTime(time: number);
  49048. /**
  49049. * Gets the transition time when framing the mesh, in milliseconds
  49050. */
  49051. get framingTime(): number;
  49052. /**
  49053. * Define if the behavior should automatically change the configured
  49054. * camera limits and sensibilities.
  49055. */
  49056. autoCorrectCameraLimitsAndSensibility: boolean;
  49057. private _onPrePointerObservableObserver;
  49058. private _onAfterCheckInputsObserver;
  49059. private _onMeshTargetChangedObserver;
  49060. private _attachedCamera;
  49061. private _isPointerDown;
  49062. private _lastInteractionTime;
  49063. /**
  49064. * Initializes the behavior.
  49065. */
  49066. init(): void;
  49067. /**
  49068. * Attaches the behavior to its arc rotate camera.
  49069. * @param camera Defines the camera to attach the behavior to
  49070. */
  49071. attach(camera: ArcRotateCamera): void;
  49072. /**
  49073. * Detaches the behavior from its current arc rotate camera.
  49074. */
  49075. detach(): void;
  49076. private _animatables;
  49077. private _betaIsAnimating;
  49078. private _betaTransition;
  49079. private _radiusTransition;
  49080. private _vectorTransition;
  49081. /**
  49082. * Targets the given mesh and updates zoom level accordingly.
  49083. * @param mesh The mesh to target.
  49084. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  49085. * @param onAnimationEnd Callback triggered at the end of the framing animation
  49086. */
  49087. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  49088. /**
  49089. * Targets the given mesh with its children and updates zoom level accordingly.
  49090. * @param mesh The mesh to target.
  49091. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  49092. * @param onAnimationEnd Callback triggered at the end of the framing animation
  49093. */
  49094. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  49095. /**
  49096. * Targets the given meshes with their children and updates zoom level accordingly.
  49097. * @param meshes The mesh to target.
  49098. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  49099. * @param onAnimationEnd Callback triggered at the end of the framing animation
  49100. */
  49101. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  49102. /**
  49103. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  49104. * @param minimumWorld Determines the smaller position of the bounding box extend
  49105. * @param maximumWorld Determines the bigger position of the bounding box extend
  49106. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  49107. * @param onAnimationEnd Callback triggered at the end of the framing animation
  49108. */
  49109. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  49110. /**
  49111. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  49112. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  49113. * frustum width.
  49114. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  49115. * to fully enclose the mesh in the viewing frustum.
  49116. */
  49117. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  49118. /**
  49119. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  49120. * is automatically returned to its default position (expected to be above ground plane).
  49121. */
  49122. private _maintainCameraAboveGround;
  49123. /**
  49124. * Returns the frustum slope based on the canvas ratio and camera FOV
  49125. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  49126. */
  49127. private _getFrustumSlope;
  49128. /**
  49129. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  49130. */
  49131. private _clearAnimationLocks;
  49132. /**
  49133. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  49134. */
  49135. private _applyUserInteraction;
  49136. /**
  49137. * Stops and removes all animations that have been applied to the camera
  49138. */
  49139. stopAllAnimations(): void;
  49140. /**
  49141. * Gets a value indicating if the user is moving the camera
  49142. */
  49143. get isUserIsMoving(): boolean;
  49144. /**
  49145. * The camera can move all the way towards the mesh.
  49146. */
  49147. static IgnoreBoundsSizeMode: number;
  49148. /**
  49149. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  49150. */
  49151. static FitFrustumSidesMode: number;
  49152. }
  49153. }
  49154. declare module BABYLON {
  49155. /**
  49156. * Base class for Camera Pointer Inputs.
  49157. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  49158. * for example usage.
  49159. */
  49160. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  49161. /**
  49162. * Defines the camera the input is attached to.
  49163. */
  49164. abstract camera: Camera;
  49165. /**
  49166. * Whether keyboard modifier keys are pressed at time of last mouse event.
  49167. */
  49168. protected _altKey: boolean;
  49169. protected _ctrlKey: boolean;
  49170. protected _metaKey: boolean;
  49171. protected _shiftKey: boolean;
  49172. /**
  49173. * Which mouse buttons were pressed at time of last mouse event.
  49174. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  49175. */
  49176. protected _buttonsPressed: number;
  49177. /**
  49178. * Defines the buttons associated with the input to handle camera move.
  49179. */
  49180. buttons: number[];
  49181. /**
  49182. * Attach the input controls to a specific dom element to get the input from.
  49183. * @param element Defines the element the controls should be listened from
  49184. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  49185. */
  49186. attachControl(noPreventDefault?: boolean): void;
  49187. /**
  49188. * Detach the current controls from the specified dom element.
  49189. */
  49190. detachControl(): void;
  49191. /**
  49192. * Gets the class name of the current input.
  49193. * @returns the class name
  49194. */
  49195. getClassName(): string;
  49196. /**
  49197. * Get the friendly name associated with the input class.
  49198. * @returns the input friendly name
  49199. */
  49200. getSimpleName(): string;
  49201. /**
  49202. * Called on pointer POINTERDOUBLETAP event.
  49203. * Override this method to provide functionality on POINTERDOUBLETAP event.
  49204. */
  49205. protected onDoubleTap(type: string): void;
  49206. /**
  49207. * Called on pointer POINTERMOVE event if only a single touch is active.
  49208. * Override this method to provide functionality.
  49209. */
  49210. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  49211. /**
  49212. * Called on pointer POINTERMOVE event if multiple touches are active.
  49213. * Override this method to provide functionality.
  49214. */
  49215. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  49216. /**
  49217. * Called on JS contextmenu event.
  49218. * Override this method to provide functionality.
  49219. */
  49220. protected onContextMenu(evt: PointerEvent): void;
  49221. /**
  49222. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  49223. * press.
  49224. * Override this method to provide functionality.
  49225. */
  49226. protected onButtonDown(evt: PointerEvent): void;
  49227. /**
  49228. * Called each time a new POINTERUP event occurs. Ie, for each button
  49229. * release.
  49230. * Override this method to provide functionality.
  49231. */
  49232. protected onButtonUp(evt: PointerEvent): void;
  49233. /**
  49234. * Called when window becomes inactive.
  49235. * Override this method to provide functionality.
  49236. */
  49237. protected onLostFocus(): void;
  49238. private _pointerInput;
  49239. private _observer;
  49240. private _onLostFocus;
  49241. private pointA;
  49242. private pointB;
  49243. }
  49244. }
  49245. declare module BABYLON {
  49246. /**
  49247. * Manage the pointers inputs to control an arc rotate camera.
  49248. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49249. */
  49250. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  49251. /**
  49252. * Defines the camera the input is attached to.
  49253. */
  49254. camera: ArcRotateCamera;
  49255. /**
  49256. * Gets the class name of the current input.
  49257. * @returns the class name
  49258. */
  49259. getClassName(): string;
  49260. /**
  49261. * Defines the buttons associated with the input to handle camera move.
  49262. */
  49263. buttons: number[];
  49264. /**
  49265. * Defines the pointer angular sensibility along the X axis or how fast is
  49266. * the camera rotating.
  49267. */
  49268. angularSensibilityX: number;
  49269. /**
  49270. * Defines the pointer angular sensibility along the Y axis or how fast is
  49271. * the camera rotating.
  49272. */
  49273. angularSensibilityY: number;
  49274. /**
  49275. * Defines the pointer pinch precision or how fast is the camera zooming.
  49276. */
  49277. pinchPrecision: number;
  49278. /**
  49279. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  49280. * from 0.
  49281. * It defines the percentage of current camera.radius to use as delta when
  49282. * pinch zoom is used.
  49283. */
  49284. pinchDeltaPercentage: number;
  49285. /**
  49286. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  49287. * that any object in the plane at the camera's target point will scale
  49288. * perfectly with finger motion.
  49289. * Overrides pinchDeltaPercentage and pinchPrecision.
  49290. */
  49291. useNaturalPinchZoom: boolean;
  49292. /**
  49293. * Defines whether zoom (2 fingers pinch) is enabled through multitouch
  49294. */
  49295. pinchZoom: boolean;
  49296. /**
  49297. * Defines the pointer panning sensibility or how fast is the camera moving.
  49298. */
  49299. panningSensibility: number;
  49300. /**
  49301. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  49302. */
  49303. multiTouchPanning: boolean;
  49304. /**
  49305. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  49306. * zoom (pinch) through multitouch.
  49307. */
  49308. multiTouchPanAndZoom: boolean;
  49309. /**
  49310. * Revers pinch action direction.
  49311. */
  49312. pinchInwards: boolean;
  49313. private _isPanClick;
  49314. private _twoFingerActivityCount;
  49315. private _isPinching;
  49316. /**
  49317. * Move camera from multi touch panning positions.
  49318. */
  49319. private _computeMultiTouchPanning;
  49320. /**
  49321. * Move camera from pinch zoom distances.
  49322. */
  49323. private _computePinchZoom;
  49324. /**
  49325. * Called on pointer POINTERMOVE event if only a single touch is active.
  49326. */
  49327. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  49328. /**
  49329. * Called on pointer POINTERDOUBLETAP event.
  49330. */
  49331. protected onDoubleTap(type: string): void;
  49332. /**
  49333. * Called on pointer POINTERMOVE event if multiple touches are active.
  49334. */
  49335. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  49336. /**
  49337. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  49338. * press.
  49339. */
  49340. protected onButtonDown(evt: PointerEvent): void;
  49341. /**
  49342. * Called each time a new POINTERUP event occurs. Ie, for each button
  49343. * release.
  49344. */
  49345. protected onButtonUp(evt: PointerEvent): void;
  49346. /**
  49347. * Called when window becomes inactive.
  49348. */
  49349. protected onLostFocus(): void;
  49350. }
  49351. }
  49352. declare module BABYLON {
  49353. /**
  49354. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  49355. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49356. */
  49357. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  49358. /**
  49359. * Defines the camera the input is attached to.
  49360. */
  49361. camera: ArcRotateCamera;
  49362. /**
  49363. * Defines the list of key codes associated with the up action (increase alpha)
  49364. */
  49365. keysUp: number[];
  49366. /**
  49367. * Defines the list of key codes associated with the down action (decrease alpha)
  49368. */
  49369. keysDown: number[];
  49370. /**
  49371. * Defines the list of key codes associated with the left action (increase beta)
  49372. */
  49373. keysLeft: number[];
  49374. /**
  49375. * Defines the list of key codes associated with the right action (decrease beta)
  49376. */
  49377. keysRight: number[];
  49378. /**
  49379. * Defines the list of key codes associated with the reset action.
  49380. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  49381. */
  49382. keysReset: number[];
  49383. /**
  49384. * Defines the panning sensibility of the inputs.
  49385. * (How fast is the camera panning)
  49386. */
  49387. panningSensibility: number;
  49388. /**
  49389. * Defines the zooming sensibility of the inputs.
  49390. * (How fast is the camera zooming)
  49391. */
  49392. zoomingSensibility: number;
  49393. /**
  49394. * Defines whether maintaining the alt key down switch the movement mode from
  49395. * orientation to zoom.
  49396. */
  49397. useAltToZoom: boolean;
  49398. /**
  49399. * Rotation speed of the camera
  49400. */
  49401. angularSpeed: number;
  49402. private _keys;
  49403. private _ctrlPressed;
  49404. private _altPressed;
  49405. private _onCanvasBlurObserver;
  49406. private _onKeyboardObserver;
  49407. private _engine;
  49408. private _scene;
  49409. /**
  49410. * Attach the input controls to a specific dom element to get the input from.
  49411. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  49412. */
  49413. attachControl(noPreventDefault?: boolean): void;
  49414. /**
  49415. * Detach the current controls from the specified dom element.
  49416. */
  49417. detachControl(): void;
  49418. /**
  49419. * Update the current camera state depending on the inputs that have been used this frame.
  49420. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  49421. */
  49422. checkInputs(): void;
  49423. /**
  49424. * Gets the class name of the current intput.
  49425. * @returns the class name
  49426. */
  49427. getClassName(): string;
  49428. /**
  49429. * Get the friendly name associated with the input class.
  49430. * @returns the input friendly name
  49431. */
  49432. getSimpleName(): string;
  49433. }
  49434. }
  49435. declare module BABYLON {
  49436. /**
  49437. * Manage the mouse wheel inputs to control an arc rotate camera.
  49438. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49439. */
  49440. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  49441. /**
  49442. * Defines the camera the input is attached to.
  49443. */
  49444. camera: ArcRotateCamera;
  49445. /**
  49446. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  49447. */
  49448. wheelPrecision: number;
  49449. /**
  49450. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  49451. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  49452. */
  49453. wheelDeltaPercentage: number;
  49454. private _wheel;
  49455. private _observer;
  49456. private computeDeltaFromMouseWheelLegacyEvent;
  49457. /**
  49458. * Attach the input controls to a specific dom element to get the input from.
  49459. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  49460. */
  49461. attachControl(noPreventDefault?: boolean): void;
  49462. /**
  49463. * Detach the current controls from the specified dom element.
  49464. */
  49465. detachControl(): void;
  49466. /**
  49467. * Gets the class name of the current intput.
  49468. * @returns the class name
  49469. */
  49470. getClassName(): string;
  49471. /**
  49472. * Get the friendly name associated with the input class.
  49473. * @returns the input friendly name
  49474. */
  49475. getSimpleName(): string;
  49476. }
  49477. }
  49478. declare module BABYLON {
  49479. /**
  49480. * Default Inputs manager for the ArcRotateCamera.
  49481. * It groups all the default supported inputs for ease of use.
  49482. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49483. */
  49484. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  49485. /**
  49486. * Instantiates a new ArcRotateCameraInputsManager.
  49487. * @param camera Defines the camera the inputs belong to
  49488. */
  49489. constructor(camera: ArcRotateCamera);
  49490. /**
  49491. * Add mouse wheel input support to the input manager.
  49492. * @returns the current input manager
  49493. */
  49494. addMouseWheel(): ArcRotateCameraInputsManager;
  49495. /**
  49496. * Add pointers input support to the input manager.
  49497. * @returns the current input manager
  49498. */
  49499. addPointers(): ArcRotateCameraInputsManager;
  49500. /**
  49501. * Add keyboard input support to the input manager.
  49502. * @returns the current input manager
  49503. */
  49504. addKeyboard(): ArcRotateCameraInputsManager;
  49505. }
  49506. }
  49507. declare module BABYLON {
  49508. /**
  49509. * This represents an orbital type of camera.
  49510. *
  49511. * 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.
  49512. * 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.
  49513. * @see https://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  49514. */
  49515. export class ArcRotateCamera extends TargetCamera {
  49516. /**
  49517. * Defines the rotation angle of the camera along the longitudinal axis.
  49518. */
  49519. alpha: number;
  49520. /**
  49521. * Defines the rotation angle of the camera along the latitudinal axis.
  49522. */
  49523. beta: number;
  49524. /**
  49525. * Defines the radius of the camera from it s target point.
  49526. */
  49527. radius: number;
  49528. protected _target: Vector3;
  49529. protected _targetHost: Nullable<AbstractMesh>;
  49530. /**
  49531. * Defines the target point of the camera.
  49532. * The camera looks towards it form the radius distance.
  49533. * Please note that you can set the target to a mesh and thus the target will be copied from mesh.position
  49534. */
  49535. get target(): Vector3;
  49536. set target(value: Vector3);
  49537. /**
  49538. * Define the current local position of the camera in the scene
  49539. */
  49540. get position(): Vector3;
  49541. set position(newPosition: Vector3);
  49542. protected _upToYMatrix: Matrix;
  49543. protected _YToUpMatrix: Matrix;
  49544. /**
  49545. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  49546. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  49547. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  49548. */
  49549. set upVector(vec: Vector3);
  49550. get upVector(): Vector3;
  49551. /**
  49552. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  49553. */
  49554. setMatUp(): void;
  49555. /**
  49556. * Current inertia value on the longitudinal axis.
  49557. * The bigger this number the longer it will take for the camera to stop.
  49558. */
  49559. inertialAlphaOffset: number;
  49560. /**
  49561. * Current inertia value on the latitudinal axis.
  49562. * The bigger this number the longer it will take for the camera to stop.
  49563. */
  49564. inertialBetaOffset: number;
  49565. /**
  49566. * Current inertia value on the radius axis.
  49567. * The bigger this number the longer it will take for the camera to stop.
  49568. */
  49569. inertialRadiusOffset: number;
  49570. /**
  49571. * Minimum allowed angle on the longitudinal axis.
  49572. * This can help limiting how the Camera is able to move in the scene.
  49573. */
  49574. lowerAlphaLimit: Nullable<number>;
  49575. /**
  49576. * Maximum allowed angle on the longitudinal axis.
  49577. * This can help limiting how the Camera is able to move in the scene.
  49578. */
  49579. upperAlphaLimit: Nullable<number>;
  49580. /**
  49581. * Minimum allowed angle on the latitudinal axis.
  49582. * This can help limiting how the Camera is able to move in the scene.
  49583. */
  49584. lowerBetaLimit: number;
  49585. /**
  49586. * Maximum allowed angle on the latitudinal axis.
  49587. * This can help limiting how the Camera is able to move in the scene.
  49588. */
  49589. upperBetaLimit: number;
  49590. /**
  49591. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  49592. * This can help limiting how the Camera is able to move in the scene.
  49593. */
  49594. lowerRadiusLimit: Nullable<number>;
  49595. /**
  49596. * Maximum allowed distance of the camera to the target (The camera can not get further).
  49597. * This can help limiting how the Camera is able to move in the scene.
  49598. */
  49599. upperRadiusLimit: Nullable<number>;
  49600. /**
  49601. * Defines the current inertia value used during panning of the camera along the X axis.
  49602. */
  49603. inertialPanningX: number;
  49604. /**
  49605. * Defines the current inertia value used during panning of the camera along the Y axis.
  49606. */
  49607. inertialPanningY: number;
  49608. /**
  49609. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  49610. * Basically if your fingers moves away from more than this distance you will be considered
  49611. * in pinch mode.
  49612. */
  49613. pinchToPanMaxDistance: number;
  49614. /**
  49615. * Defines the maximum distance the camera can pan.
  49616. * This could help keeping the cammera always in your scene.
  49617. */
  49618. panningDistanceLimit: Nullable<number>;
  49619. /**
  49620. * Defines the target of the camera before paning.
  49621. */
  49622. panningOriginTarget: Vector3;
  49623. /**
  49624. * Defines the value of the inertia used during panning.
  49625. * 0 would mean stop inertia and one would mean no decelleration at all.
  49626. */
  49627. panningInertia: number;
  49628. /**
  49629. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  49630. */
  49631. get angularSensibilityX(): number;
  49632. set angularSensibilityX(value: number);
  49633. /**
  49634. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  49635. */
  49636. get angularSensibilityY(): number;
  49637. set angularSensibilityY(value: number);
  49638. /**
  49639. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  49640. */
  49641. get pinchPrecision(): number;
  49642. set pinchPrecision(value: number);
  49643. /**
  49644. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  49645. * It will be used instead of pinchDeltaPrecision if different from 0.
  49646. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  49647. */
  49648. get pinchDeltaPercentage(): number;
  49649. set pinchDeltaPercentage(value: number);
  49650. /**
  49651. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  49652. * and pinch delta percentage.
  49653. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  49654. * that any object in the plane at the camera's target point will scale
  49655. * perfectly with finger motion.
  49656. */
  49657. get useNaturalPinchZoom(): boolean;
  49658. set useNaturalPinchZoom(value: boolean);
  49659. /**
  49660. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  49661. */
  49662. get panningSensibility(): number;
  49663. set panningSensibility(value: number);
  49664. /**
  49665. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  49666. */
  49667. get keysUp(): number[];
  49668. set keysUp(value: number[]);
  49669. /**
  49670. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  49671. */
  49672. get keysDown(): number[];
  49673. set keysDown(value: number[]);
  49674. /**
  49675. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  49676. */
  49677. get keysLeft(): number[];
  49678. set keysLeft(value: number[]);
  49679. /**
  49680. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  49681. */
  49682. get keysRight(): number[];
  49683. set keysRight(value: number[]);
  49684. /**
  49685. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  49686. */
  49687. get wheelPrecision(): number;
  49688. set wheelPrecision(value: number);
  49689. /**
  49690. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  49691. * It will be used instead of pinchDeltaPrecision if different from 0.
  49692. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  49693. */
  49694. get wheelDeltaPercentage(): number;
  49695. set wheelDeltaPercentage(value: number);
  49696. /**
  49697. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  49698. */
  49699. zoomOnFactor: number;
  49700. /**
  49701. * Defines a screen offset for the camera position.
  49702. */
  49703. targetScreenOffset: Vector2;
  49704. /**
  49705. * Allows the camera to be completely reversed.
  49706. * If false the camera can not arrive upside down.
  49707. */
  49708. allowUpsideDown: boolean;
  49709. /**
  49710. * Define if double tap/click is used to restore the previously saved state of the camera.
  49711. */
  49712. useInputToRestoreState: boolean;
  49713. /** @hidden */
  49714. _viewMatrix: Matrix;
  49715. /** @hidden */
  49716. _useCtrlForPanning: boolean;
  49717. /** @hidden */
  49718. _panningMouseButton: number;
  49719. /**
  49720. * Defines the input associated to the camera.
  49721. */
  49722. inputs: ArcRotateCameraInputsManager;
  49723. /** @hidden */
  49724. _reset: () => void;
  49725. /**
  49726. * Defines the allowed panning axis.
  49727. */
  49728. panningAxis: Vector3;
  49729. protected _transformedDirection: Vector3;
  49730. private _bouncingBehavior;
  49731. /**
  49732. * Gets the bouncing behavior of the camera if it has been enabled.
  49733. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  49734. */
  49735. get bouncingBehavior(): Nullable<BouncingBehavior>;
  49736. /**
  49737. * Defines if the bouncing behavior of the camera is enabled on the camera.
  49738. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  49739. */
  49740. get useBouncingBehavior(): boolean;
  49741. set useBouncingBehavior(value: boolean);
  49742. private _framingBehavior;
  49743. /**
  49744. * Gets the framing behavior of the camera if it has been enabled.
  49745. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  49746. */
  49747. get framingBehavior(): Nullable<FramingBehavior>;
  49748. /**
  49749. * Defines if the framing behavior of the camera is enabled on the camera.
  49750. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  49751. */
  49752. get useFramingBehavior(): boolean;
  49753. set useFramingBehavior(value: boolean);
  49754. private _autoRotationBehavior;
  49755. /**
  49756. * Gets the auto rotation behavior of the camera if it has been enabled.
  49757. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  49758. */
  49759. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  49760. /**
  49761. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  49762. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  49763. */
  49764. get useAutoRotationBehavior(): boolean;
  49765. set useAutoRotationBehavior(value: boolean);
  49766. /**
  49767. * Observable triggered when the mesh target has been changed on the camera.
  49768. */
  49769. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  49770. /**
  49771. * Event raised when the camera is colliding with a mesh.
  49772. */
  49773. onCollide: (collidedMesh: AbstractMesh) => void;
  49774. /**
  49775. * Defines whether the camera should check collision with the objects oh the scene.
  49776. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  49777. */
  49778. checkCollisions: boolean;
  49779. /**
  49780. * Defines the collision radius of the camera.
  49781. * This simulates a sphere around the camera.
  49782. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  49783. */
  49784. collisionRadius: Vector3;
  49785. protected _collider: Collider;
  49786. protected _previousPosition: Vector3;
  49787. protected _collisionVelocity: Vector3;
  49788. protected _newPosition: Vector3;
  49789. protected _previousAlpha: number;
  49790. protected _previousBeta: number;
  49791. protected _previousRadius: number;
  49792. protected _collisionTriggered: boolean;
  49793. protected _targetBoundingCenter: Nullable<Vector3>;
  49794. private _computationVector;
  49795. /**
  49796. * Instantiates a new ArcRotateCamera in a given scene
  49797. * @param name Defines the name of the camera
  49798. * @param alpha Defines the camera rotation along the logitudinal axis
  49799. * @param beta Defines the camera rotation along the latitudinal axis
  49800. * @param radius Defines the camera distance from its target
  49801. * @param target Defines the camera target
  49802. * @param scene Defines the scene the camera belongs to
  49803. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  49804. */
  49805. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  49806. /** @hidden */
  49807. _initCache(): void;
  49808. /** @hidden */
  49809. _updateCache(ignoreParentClass?: boolean): void;
  49810. protected _getTargetPosition(): Vector3;
  49811. private _storedAlpha;
  49812. private _storedBeta;
  49813. private _storedRadius;
  49814. private _storedTarget;
  49815. private _storedTargetScreenOffset;
  49816. /**
  49817. * Stores the current state of the camera (alpha, beta, radius and target)
  49818. * @returns the camera itself
  49819. */
  49820. storeState(): Camera;
  49821. /**
  49822. * @hidden
  49823. * Restored camera state. You must call storeState() first
  49824. */
  49825. _restoreStateValues(): boolean;
  49826. /** @hidden */
  49827. _isSynchronizedViewMatrix(): boolean;
  49828. /**
  49829. * Attach the input controls to a specific dom element to get the input from.
  49830. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  49831. */
  49832. attachControl(noPreventDefault?: boolean): void;
  49833. /**
  49834. * Attach the input controls to a specific dom element to get the input from.
  49835. * @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
  49836. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  49837. */
  49838. attachControl(ignored: any, noPreventDefault?: boolean): void;
  49839. /**
  49840. * Attached controls to the current camera.
  49841. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  49842. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  49843. */
  49844. attachControl(noPreventDefault: boolean, useCtrlForPanning: boolean): void;
  49845. /**
  49846. * Attached controls to the current camera.
  49847. * @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
  49848. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  49849. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  49850. */
  49851. attachControl(ignored: any, noPreventDefault: boolean, useCtrlForPanning: boolean): void;
  49852. /**
  49853. * Attached controls to the current camera.
  49854. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  49855. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  49856. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  49857. */
  49858. attachControl(noPreventDefault: boolean, useCtrlForPanning: boolean, panningMouseButton: number): void;
  49859. /**
  49860. * Detach the current controls from the specified dom element.
  49861. */
  49862. detachControl(): void;
  49863. /**
  49864. * Detach the current controls from the specified dom element.
  49865. * @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
  49866. */
  49867. detachControl(ignored: any): void;
  49868. /** @hidden */
  49869. _checkInputs(): void;
  49870. protected _checkLimits(): void;
  49871. /**
  49872. * Rebuilds angles (alpha, beta) and radius from the give position and target
  49873. */
  49874. rebuildAnglesAndRadius(): void;
  49875. /**
  49876. * Use a position to define the current camera related information like alpha, beta and radius
  49877. * @param position Defines the position to set the camera at
  49878. */
  49879. setPosition(position: Vector3): void;
  49880. /**
  49881. * Defines the target the camera should look at.
  49882. * This will automatically adapt alpha beta and radius to fit within the new target.
  49883. * @param target Defines the new target as a Vector or a mesh
  49884. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  49885. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  49886. */
  49887. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  49888. /** @hidden */
  49889. _getViewMatrix(): Matrix;
  49890. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  49891. /**
  49892. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  49893. * @param meshes Defines the mesh to zoom on
  49894. * @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)
  49895. */
  49896. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  49897. /**
  49898. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  49899. * The target will be changed but the radius
  49900. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  49901. * @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)
  49902. */
  49903. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  49904. min: Vector3;
  49905. max: Vector3;
  49906. distance: number;
  49907. }, doNotUpdateMaxZ?: boolean): void;
  49908. /**
  49909. * @override
  49910. * Override Camera.createRigCamera
  49911. */
  49912. createRigCamera(name: string, cameraIndex: number): Camera;
  49913. /**
  49914. * @hidden
  49915. * @override
  49916. * Override Camera._updateRigCameras
  49917. */
  49918. _updateRigCameras(): void;
  49919. /**
  49920. * Destroy the camera and release the current resources hold by it.
  49921. */
  49922. dispose(): void;
  49923. /**
  49924. * Gets the current object class name.
  49925. * @return the class name
  49926. */
  49927. getClassName(): string;
  49928. }
  49929. }
  49930. declare module BABYLON {
  49931. /**
  49932. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  49933. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  49934. */
  49935. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  49936. /**
  49937. * Gets the name of the behavior.
  49938. */
  49939. get name(): string;
  49940. private _zoomStopsAnimation;
  49941. private _idleRotationSpeed;
  49942. private _idleRotationWaitTime;
  49943. private _idleRotationSpinupTime;
  49944. /**
  49945. * Sets the flag that indicates if user zooming should stop animation.
  49946. */
  49947. set zoomStopsAnimation(flag: boolean);
  49948. /**
  49949. * Gets the flag that indicates if user zooming should stop animation.
  49950. */
  49951. get zoomStopsAnimation(): boolean;
  49952. /**
  49953. * Sets the default speed at which the camera rotates around the model.
  49954. */
  49955. set idleRotationSpeed(speed: number);
  49956. /**
  49957. * Gets the default speed at which the camera rotates around the model.
  49958. */
  49959. get idleRotationSpeed(): number;
  49960. /**
  49961. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  49962. */
  49963. set idleRotationWaitTime(time: number);
  49964. /**
  49965. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  49966. */
  49967. get idleRotationWaitTime(): number;
  49968. /**
  49969. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  49970. */
  49971. set idleRotationSpinupTime(time: number);
  49972. /**
  49973. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  49974. */
  49975. get idleRotationSpinupTime(): number;
  49976. /**
  49977. * Gets a value indicating if the camera is currently rotating because of this behavior
  49978. */
  49979. get rotationInProgress(): boolean;
  49980. private _onPrePointerObservableObserver;
  49981. private _onAfterCheckInputsObserver;
  49982. private _attachedCamera;
  49983. private _isPointerDown;
  49984. private _lastFrameTime;
  49985. private _lastInteractionTime;
  49986. private _cameraRotationSpeed;
  49987. /**
  49988. * Initializes the behavior.
  49989. */
  49990. init(): void;
  49991. /**
  49992. * Attaches the behavior to its arc rotate camera.
  49993. * @param camera Defines the camera to attach the behavior to
  49994. */
  49995. attach(camera: ArcRotateCamera): void;
  49996. /**
  49997. * Detaches the behavior from its current arc rotate camera.
  49998. */
  49999. detach(): void;
  50000. /**
  50001. * Returns true if user is scrolling.
  50002. * @return true if user is scrolling.
  50003. */
  50004. private _userIsZooming;
  50005. private _lastFrameRadius;
  50006. private _shouldAnimationStopForInteraction;
  50007. /**
  50008. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  50009. */
  50010. private _applyUserInteraction;
  50011. private _userIsMoving;
  50012. }
  50013. }
  50014. declare module BABYLON {
  50015. /**
  50016. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  50017. */
  50018. export class AttachToBoxBehavior implements Behavior<Mesh> {
  50019. private ui;
  50020. /**
  50021. * The name of the behavior
  50022. */
  50023. name: string;
  50024. /**
  50025. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  50026. */
  50027. distanceAwayFromFace: number;
  50028. /**
  50029. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  50030. */
  50031. distanceAwayFromBottomOfFace: number;
  50032. private _faceVectors;
  50033. private _target;
  50034. private _scene;
  50035. private _onRenderObserver;
  50036. private _tmpMatrix;
  50037. private _tmpVector;
  50038. /**
  50039. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  50040. * @param ui The transform node that should be attched to the mesh
  50041. */
  50042. constructor(ui: TransformNode);
  50043. /**
  50044. * Initializes the behavior
  50045. */
  50046. init(): void;
  50047. private _closestFace;
  50048. private _zeroVector;
  50049. private _lookAtTmpMatrix;
  50050. private _lookAtToRef;
  50051. /**
  50052. * Attaches the AttachToBoxBehavior to the passed in mesh
  50053. * @param target The mesh that the specified node will be attached to
  50054. */
  50055. attach(target: Mesh): void;
  50056. /**
  50057. * Detaches the behavior from the mesh
  50058. */
  50059. detach(): void;
  50060. }
  50061. }
  50062. declare module BABYLON {
  50063. /**
  50064. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  50065. */
  50066. export class FadeInOutBehavior implements Behavior<Mesh> {
  50067. /**
  50068. * Time in milliseconds to delay before fading in (Default: 0)
  50069. */
  50070. delay: number;
  50071. /**
  50072. * Time in milliseconds for the mesh to fade in (Default: 300)
  50073. */
  50074. fadeInTime: number;
  50075. private _millisecondsPerFrame;
  50076. private _hovered;
  50077. private _hoverValue;
  50078. private _ownerNode;
  50079. /**
  50080. * Instatiates the FadeInOutBehavior
  50081. */
  50082. constructor();
  50083. /**
  50084. * The name of the behavior
  50085. */
  50086. get name(): string;
  50087. /**
  50088. * Initializes the behavior
  50089. */
  50090. init(): void;
  50091. /**
  50092. * Attaches the fade behavior on the passed in mesh
  50093. * @param ownerNode The mesh that will be faded in/out once attached
  50094. */
  50095. attach(ownerNode: Mesh): void;
  50096. /**
  50097. * Detaches the behavior from the mesh
  50098. */
  50099. detach(): void;
  50100. /**
  50101. * Triggers the mesh to begin fading in or out
  50102. * @param value if the object should fade in or out (true to fade in)
  50103. */
  50104. fadeIn(value: boolean): void;
  50105. private _update;
  50106. private _setAllVisibility;
  50107. }
  50108. }
  50109. declare module BABYLON {
  50110. /**
  50111. * Class containing a set of static utilities functions for managing Pivots
  50112. * @hidden
  50113. */
  50114. export class PivotTools {
  50115. private static _PivotCached;
  50116. private static _OldPivotPoint;
  50117. private static _PivotTranslation;
  50118. private static _PivotTmpVector;
  50119. private static _PivotPostMultiplyPivotMatrix;
  50120. /** @hidden */
  50121. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  50122. /** @hidden */
  50123. static _RestorePivotPoint(mesh: AbstractMesh): void;
  50124. }
  50125. }
  50126. declare module BABYLON {
  50127. /**
  50128. * Class containing static functions to help procedurally build meshes
  50129. */
  50130. export class PlaneBuilder {
  50131. /**
  50132. * Creates a plane mesh
  50133. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  50134. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  50135. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  50136. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50137. * * 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
  50138. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50139. * @param name defines the name of the mesh
  50140. * @param options defines the options used to create the mesh
  50141. * @param scene defines the hosting scene
  50142. * @returns the plane mesh
  50143. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  50144. */
  50145. static CreatePlane(name: string, options: {
  50146. size?: number;
  50147. width?: number;
  50148. height?: number;
  50149. sideOrientation?: number;
  50150. frontUVs?: Vector4;
  50151. backUVs?: Vector4;
  50152. updatable?: boolean;
  50153. sourcePlane?: Plane;
  50154. }, scene?: Nullable<Scene>): Mesh;
  50155. }
  50156. }
  50157. declare module BABYLON {
  50158. /**
  50159. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  50160. */
  50161. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  50162. private static _AnyMouseID;
  50163. /**
  50164. * Abstract mesh the behavior is set on
  50165. */
  50166. attachedNode: AbstractMesh;
  50167. private _dragPlane;
  50168. private _scene;
  50169. private _pointerObserver;
  50170. private _beforeRenderObserver;
  50171. private static _planeScene;
  50172. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  50173. /**
  50174. * 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)
  50175. */
  50176. maxDragAngle: number;
  50177. /**
  50178. * @hidden
  50179. */
  50180. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  50181. /**
  50182. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  50183. */
  50184. currentDraggingPointerID: number;
  50185. /**
  50186. * The last position where the pointer hit the drag plane in world space
  50187. */
  50188. lastDragPosition: Vector3;
  50189. /**
  50190. * If the behavior is currently in a dragging state
  50191. */
  50192. dragging: boolean;
  50193. /**
  50194. * 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)
  50195. */
  50196. dragDeltaRatio: number;
  50197. /**
  50198. * If the drag plane orientation should be updated during the dragging (Default: true)
  50199. */
  50200. updateDragPlane: boolean;
  50201. private _debugMode;
  50202. private _moving;
  50203. /**
  50204. * Fires each time the attached mesh is dragged with the pointer
  50205. * * delta between last drag position and current drag position in world space
  50206. * * dragDistance along the drag axis
  50207. * * dragPlaneNormal normal of the current drag plane used during the drag
  50208. * * dragPlanePoint in world space where the drag intersects the drag plane
  50209. */
  50210. onDragObservable: Observable<{
  50211. delta: Vector3;
  50212. dragPlanePoint: Vector3;
  50213. dragPlaneNormal: Vector3;
  50214. dragDistance: number;
  50215. pointerId: number;
  50216. }>;
  50217. /**
  50218. * Fires each time a drag begins (eg. mouse down on mesh)
  50219. */
  50220. onDragStartObservable: Observable<{
  50221. dragPlanePoint: Vector3;
  50222. pointerId: number;
  50223. }>;
  50224. /**
  50225. * Fires each time a drag ends (eg. mouse release after drag)
  50226. */
  50227. onDragEndObservable: Observable<{
  50228. dragPlanePoint: Vector3;
  50229. pointerId: number;
  50230. }>;
  50231. /**
  50232. * If the attached mesh should be moved when dragged
  50233. */
  50234. moveAttached: boolean;
  50235. /**
  50236. * If the drag behavior will react to drag events (Default: true)
  50237. */
  50238. enabled: boolean;
  50239. /**
  50240. * If pointer events should start and release the drag (Default: true)
  50241. */
  50242. startAndReleaseDragOnPointerEvents: boolean;
  50243. /**
  50244. * If camera controls should be detached during the drag
  50245. */
  50246. detachCameraControls: boolean;
  50247. /**
  50248. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  50249. */
  50250. useObjectOrientationForDragging: boolean;
  50251. private _options;
  50252. /**
  50253. * Gets the options used by the behavior
  50254. */
  50255. get options(): {
  50256. dragAxis?: Vector3;
  50257. dragPlaneNormal?: Vector3;
  50258. };
  50259. /**
  50260. * Sets the options used by the behavior
  50261. */
  50262. set options(options: {
  50263. dragAxis?: Vector3;
  50264. dragPlaneNormal?: Vector3;
  50265. });
  50266. /**
  50267. * Creates a pointer drag behavior that can be attached to a mesh
  50268. * @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)
  50269. */
  50270. constructor(options?: {
  50271. dragAxis?: Vector3;
  50272. dragPlaneNormal?: Vector3;
  50273. });
  50274. /**
  50275. * Predicate to determine if it is valid to move the object to a new position when it is moved
  50276. */
  50277. validateDrag: (targetPosition: Vector3) => boolean;
  50278. /**
  50279. * The name of the behavior
  50280. */
  50281. get name(): string;
  50282. /**
  50283. * Initializes the behavior
  50284. */
  50285. init(): void;
  50286. private _tmpVector;
  50287. private _alternatePickedPoint;
  50288. private _worldDragAxis;
  50289. private _targetPosition;
  50290. private _attachedToElement;
  50291. /**
  50292. * Attaches the drag behavior the passed in mesh
  50293. * @param ownerNode The mesh that will be dragged around once attached
  50294. * @param predicate Predicate to use for pick filtering
  50295. */
  50296. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  50297. /**
  50298. * Force relase the drag action by code.
  50299. */
  50300. releaseDrag(): void;
  50301. private _startDragRay;
  50302. private _lastPointerRay;
  50303. /**
  50304. * Simulates the start of a pointer drag event on the behavior
  50305. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  50306. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  50307. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  50308. */
  50309. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  50310. protected _startDrag(pointerId: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  50311. private _dragDelta;
  50312. protected _moveDrag(ray: Ray): void;
  50313. private _pickWithRayOnDragPlane;
  50314. private _pointA;
  50315. private _pointC;
  50316. private _localAxis;
  50317. private _lookAt;
  50318. private _updateDragPlanePosition;
  50319. /**
  50320. * Detaches the behavior from the mesh
  50321. */
  50322. detach(): void;
  50323. }
  50324. }
  50325. declare module BABYLON {
  50326. /**
  50327. * A behavior that when attached to a mesh will allow the mesh to be scaled
  50328. */
  50329. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  50330. private _dragBehaviorA;
  50331. private _dragBehaviorB;
  50332. private _startDistance;
  50333. private _initialScale;
  50334. private _targetScale;
  50335. private _ownerNode;
  50336. private _sceneRenderObserver;
  50337. /**
  50338. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  50339. */
  50340. constructor();
  50341. /**
  50342. * The name of the behavior
  50343. */
  50344. get name(): string;
  50345. /**
  50346. * Initializes the behavior
  50347. */
  50348. init(): void;
  50349. private _getCurrentDistance;
  50350. /**
  50351. * Attaches the scale behavior the passed in mesh
  50352. * @param ownerNode The mesh that will be scaled around once attached
  50353. */
  50354. attach(ownerNode: Mesh): void;
  50355. /**
  50356. * Detaches the behavior from the mesh
  50357. */
  50358. detach(): void;
  50359. }
  50360. }
  50361. declare module BABYLON {
  50362. /**
  50363. * 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
  50364. */
  50365. export class SixDofDragBehavior implements Behavior<Mesh> {
  50366. private static _virtualScene;
  50367. private _ownerNode;
  50368. private _sceneRenderObserver;
  50369. private _scene;
  50370. private _targetPosition;
  50371. private _virtualOriginMesh;
  50372. private _virtualDragMesh;
  50373. private _pointerObserver;
  50374. private _moving;
  50375. private _startingOrientation;
  50376. private _attachedToElement;
  50377. /**
  50378. * 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)
  50379. */
  50380. private zDragFactor;
  50381. /**
  50382. * If the object should rotate to face the drag origin
  50383. */
  50384. rotateDraggedObject: boolean;
  50385. /**
  50386. * If the behavior is currently in a dragging state
  50387. */
  50388. dragging: boolean;
  50389. /**
  50390. * 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)
  50391. */
  50392. dragDeltaRatio: number;
  50393. /**
  50394. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  50395. */
  50396. currentDraggingPointerID: number;
  50397. /**
  50398. * If camera controls should be detached during the drag
  50399. */
  50400. detachCameraControls: boolean;
  50401. /**
  50402. * Fires each time a drag starts
  50403. */
  50404. onDragStartObservable: Observable<{}>;
  50405. /**
  50406. * Fires each time a drag happens
  50407. */
  50408. onDragObservable: Observable<void>;
  50409. /**
  50410. * Fires each time a drag ends (eg. mouse release after drag)
  50411. */
  50412. onDragEndObservable: Observable<{}>;
  50413. /**
  50414. * 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
  50415. */
  50416. constructor();
  50417. /**
  50418. * The name of the behavior
  50419. */
  50420. get name(): string;
  50421. /**
  50422. * Initializes the behavior
  50423. */
  50424. init(): void;
  50425. /**
  50426. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  50427. */
  50428. private get _pointerCamera();
  50429. /**
  50430. * Attaches the scale behavior the passed in mesh
  50431. * @param ownerNode The mesh that will be scaled around once attached
  50432. */
  50433. attach(ownerNode: Mesh): void;
  50434. /**
  50435. * Detaches the behavior from the mesh
  50436. */
  50437. detach(): void;
  50438. }
  50439. }
  50440. declare module BABYLON {
  50441. /**
  50442. * Class used to apply inverse kinematics to bones
  50443. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  50444. */
  50445. export class BoneIKController {
  50446. private static _tmpVecs;
  50447. private static _tmpQuat;
  50448. private static _tmpMats;
  50449. /**
  50450. * Gets or sets the target mesh
  50451. */
  50452. targetMesh: AbstractMesh;
  50453. /** Gets or sets the mesh used as pole */
  50454. poleTargetMesh: AbstractMesh;
  50455. /**
  50456. * Gets or sets the bone used as pole
  50457. */
  50458. poleTargetBone: Nullable<Bone>;
  50459. /**
  50460. * Gets or sets the target position
  50461. */
  50462. targetPosition: Vector3;
  50463. /**
  50464. * Gets or sets the pole target position
  50465. */
  50466. poleTargetPosition: Vector3;
  50467. /**
  50468. * Gets or sets the pole target local offset
  50469. */
  50470. poleTargetLocalOffset: Vector3;
  50471. /**
  50472. * Gets or sets the pole angle
  50473. */
  50474. poleAngle: number;
  50475. /**
  50476. * Gets or sets the mesh associated with the controller
  50477. */
  50478. mesh: AbstractMesh;
  50479. /**
  50480. * 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)
  50481. */
  50482. slerpAmount: number;
  50483. private _bone1Quat;
  50484. private _bone1Mat;
  50485. private _bone2Ang;
  50486. private _bone1;
  50487. private _bone2;
  50488. private _bone1Length;
  50489. private _bone2Length;
  50490. private _maxAngle;
  50491. private _maxReach;
  50492. private _rightHandedSystem;
  50493. private _bendAxis;
  50494. private _slerping;
  50495. private _adjustRoll;
  50496. /**
  50497. * Gets or sets maximum allowed angle
  50498. */
  50499. get maxAngle(): number;
  50500. set maxAngle(value: number);
  50501. /**
  50502. * Creates a new BoneIKController
  50503. * @param mesh defines the mesh to control
  50504. * @param bone defines the bone to control
  50505. * @param options defines options to set up the controller
  50506. */
  50507. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  50508. targetMesh?: AbstractMesh;
  50509. poleTargetMesh?: AbstractMesh;
  50510. poleTargetBone?: Bone;
  50511. poleTargetLocalOffset?: Vector3;
  50512. poleAngle?: number;
  50513. bendAxis?: Vector3;
  50514. maxAngle?: number;
  50515. slerpAmount?: number;
  50516. });
  50517. private _setMaxAngle;
  50518. /**
  50519. * Force the controller to update the bones
  50520. */
  50521. update(): void;
  50522. }
  50523. }
  50524. declare module BABYLON {
  50525. /**
  50526. * Class used to make a bone look toward a point in space
  50527. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  50528. */
  50529. export class BoneLookController {
  50530. private static _tmpVecs;
  50531. private static _tmpQuat;
  50532. private static _tmpMats;
  50533. /**
  50534. * The target Vector3 that the bone will look at
  50535. */
  50536. target: Vector3;
  50537. /**
  50538. * The mesh that the bone is attached to
  50539. */
  50540. mesh: AbstractMesh;
  50541. /**
  50542. * The bone that will be looking to the target
  50543. */
  50544. bone: Bone;
  50545. /**
  50546. * The up axis of the coordinate system that is used when the bone is rotated
  50547. */
  50548. upAxis: Vector3;
  50549. /**
  50550. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  50551. */
  50552. upAxisSpace: Space;
  50553. /**
  50554. * Used to make an adjustment to the yaw of the bone
  50555. */
  50556. adjustYaw: number;
  50557. /**
  50558. * Used to make an adjustment to the pitch of the bone
  50559. */
  50560. adjustPitch: number;
  50561. /**
  50562. * Used to make an adjustment to the roll of the bone
  50563. */
  50564. adjustRoll: number;
  50565. /**
  50566. * 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)
  50567. */
  50568. slerpAmount: number;
  50569. private _minYaw;
  50570. private _maxYaw;
  50571. private _minPitch;
  50572. private _maxPitch;
  50573. private _minYawSin;
  50574. private _minYawCos;
  50575. private _maxYawSin;
  50576. private _maxYawCos;
  50577. private _midYawConstraint;
  50578. private _minPitchTan;
  50579. private _maxPitchTan;
  50580. private _boneQuat;
  50581. private _slerping;
  50582. private _transformYawPitch;
  50583. private _transformYawPitchInv;
  50584. private _firstFrameSkipped;
  50585. private _yawRange;
  50586. private _fowardAxis;
  50587. /**
  50588. * Gets or sets the minimum yaw angle that the bone can look to
  50589. */
  50590. get minYaw(): number;
  50591. set minYaw(value: number);
  50592. /**
  50593. * Gets or sets the maximum yaw angle that the bone can look to
  50594. */
  50595. get maxYaw(): number;
  50596. set maxYaw(value: number);
  50597. /**
  50598. * Gets or sets the minimum pitch angle that the bone can look to
  50599. */
  50600. get minPitch(): number;
  50601. set minPitch(value: number);
  50602. /**
  50603. * Gets or sets the maximum pitch angle that the bone can look to
  50604. */
  50605. get maxPitch(): number;
  50606. set maxPitch(value: number);
  50607. /**
  50608. * Create a BoneLookController
  50609. * @param mesh the mesh that the bone belongs to
  50610. * @param bone the bone that will be looking to the target
  50611. * @param target the target Vector3 to look at
  50612. * @param options optional settings:
  50613. * * maxYaw: the maximum angle the bone will yaw to
  50614. * * minYaw: the minimum angle the bone will yaw to
  50615. * * maxPitch: the maximum angle the bone will pitch to
  50616. * * minPitch: the minimum angle the bone will yaw to
  50617. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  50618. * * upAxis: the up axis of the coordinate system
  50619. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  50620. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  50621. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  50622. * * adjustYaw: used to make an adjustment to the yaw of the bone
  50623. * * adjustPitch: used to make an adjustment to the pitch of the bone
  50624. * * adjustRoll: used to make an adjustment to the roll of the bone
  50625. **/
  50626. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  50627. maxYaw?: number;
  50628. minYaw?: number;
  50629. maxPitch?: number;
  50630. minPitch?: number;
  50631. slerpAmount?: number;
  50632. upAxis?: Vector3;
  50633. upAxisSpace?: Space;
  50634. yawAxis?: Vector3;
  50635. pitchAxis?: Vector3;
  50636. adjustYaw?: number;
  50637. adjustPitch?: number;
  50638. adjustRoll?: number;
  50639. });
  50640. /**
  50641. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  50642. */
  50643. update(): void;
  50644. private _getAngleDiff;
  50645. private _getAngleBetween;
  50646. private _isAngleBetween;
  50647. }
  50648. }
  50649. declare module BABYLON {
  50650. /**
  50651. * Manage the gamepad inputs to control an arc rotate camera.
  50652. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  50653. */
  50654. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  50655. /**
  50656. * Defines the camera the input is attached to.
  50657. */
  50658. camera: ArcRotateCamera;
  50659. /**
  50660. * Defines the gamepad the input is gathering event from.
  50661. */
  50662. gamepad: Nullable<Gamepad>;
  50663. /**
  50664. * Defines the gamepad rotation sensiblity.
  50665. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  50666. */
  50667. gamepadRotationSensibility: number;
  50668. /**
  50669. * Defines the gamepad move sensiblity.
  50670. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  50671. */
  50672. gamepadMoveSensibility: number;
  50673. private _yAxisScale;
  50674. /**
  50675. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  50676. */
  50677. get invertYAxis(): boolean;
  50678. set invertYAxis(value: boolean);
  50679. private _onGamepadConnectedObserver;
  50680. private _onGamepadDisconnectedObserver;
  50681. /**
  50682. * Attach the input controls to a specific dom element to get the input from.
  50683. */
  50684. attachControl(): void;
  50685. /**
  50686. * Detach the current controls from the specified dom element.
  50687. */
  50688. detachControl(): void;
  50689. /**
  50690. * Update the current camera state depending on the inputs that have been used this frame.
  50691. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  50692. */
  50693. checkInputs(): void;
  50694. /**
  50695. * Gets the class name of the current intput.
  50696. * @returns the class name
  50697. */
  50698. getClassName(): string;
  50699. /**
  50700. * Get the friendly name associated with the input class.
  50701. * @returns the input friendly name
  50702. */
  50703. getSimpleName(): string;
  50704. }
  50705. }
  50706. declare module BABYLON {
  50707. interface ArcRotateCameraInputsManager {
  50708. /**
  50709. * Add orientation input support to the input manager.
  50710. * @returns the current input manager
  50711. */
  50712. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  50713. }
  50714. /**
  50715. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  50716. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  50717. */
  50718. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  50719. /**
  50720. * Defines the camera the input is attached to.
  50721. */
  50722. camera: ArcRotateCamera;
  50723. /**
  50724. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  50725. */
  50726. alphaCorrection: number;
  50727. /**
  50728. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  50729. */
  50730. gammaCorrection: number;
  50731. private _alpha;
  50732. private _gamma;
  50733. private _dirty;
  50734. private _deviceOrientationHandler;
  50735. /**
  50736. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  50737. */
  50738. constructor();
  50739. /**
  50740. * Attach the input controls to a specific dom element to get the input from.
  50741. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  50742. */
  50743. attachControl(noPreventDefault?: boolean): void;
  50744. /** @hidden */
  50745. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  50746. /**
  50747. * Update the current camera state depending on the inputs that have been used this frame.
  50748. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  50749. */
  50750. checkInputs(): void;
  50751. /**
  50752. * Detach the current controls from the specified dom element.
  50753. */
  50754. detachControl(): void;
  50755. /**
  50756. * Gets the class name of the current intput.
  50757. * @returns the class name
  50758. */
  50759. getClassName(): string;
  50760. /**
  50761. * Get the friendly name associated with the input class.
  50762. * @returns the input friendly name
  50763. */
  50764. getSimpleName(): string;
  50765. }
  50766. }
  50767. declare module BABYLON {
  50768. /**
  50769. * Listen to mouse events to control the camera.
  50770. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  50771. */
  50772. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  50773. /**
  50774. * Defines the camera the input is attached to.
  50775. */
  50776. camera: FlyCamera;
  50777. /**
  50778. * Defines if touch is enabled. (Default is true.)
  50779. */
  50780. touchEnabled: boolean;
  50781. /**
  50782. * Defines the buttons associated with the input to handle camera rotation.
  50783. */
  50784. buttons: number[];
  50785. /**
  50786. * Assign buttons for Yaw control.
  50787. */
  50788. buttonsYaw: number[];
  50789. /**
  50790. * Assign buttons for Pitch control.
  50791. */
  50792. buttonsPitch: number[];
  50793. /**
  50794. * Assign buttons for Roll control.
  50795. */
  50796. buttonsRoll: number[];
  50797. /**
  50798. * Detect if any button is being pressed while mouse is moved.
  50799. * -1 = Mouse locked.
  50800. * 0 = Left button.
  50801. * 1 = Middle Button.
  50802. * 2 = Right Button.
  50803. */
  50804. activeButton: number;
  50805. /**
  50806. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  50807. * Higher values reduce its sensitivity.
  50808. */
  50809. angularSensibility: number;
  50810. private _observer;
  50811. private _rollObserver;
  50812. private previousPosition;
  50813. private noPreventDefault;
  50814. private element;
  50815. /**
  50816. * Listen to mouse events to control the camera.
  50817. * @param touchEnabled Define if touch is enabled. (Default is true.)
  50818. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  50819. */
  50820. constructor(touchEnabled?: boolean);
  50821. /**
  50822. * Attach the mouse control to the HTML DOM element.
  50823. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  50824. */
  50825. attachControl(noPreventDefault?: boolean): void;
  50826. /**
  50827. * Detach the current controls from the specified dom element.
  50828. */
  50829. detachControl(): void;
  50830. /**
  50831. * Gets the class name of the current input.
  50832. * @returns the class name.
  50833. */
  50834. getClassName(): string;
  50835. /**
  50836. * Get the friendly name associated with the input class.
  50837. * @returns the input's friendly name.
  50838. */
  50839. getSimpleName(): string;
  50840. private _pointerInput;
  50841. private _onMouseMove;
  50842. /**
  50843. * Rotate camera by mouse offset.
  50844. */
  50845. private rotateCamera;
  50846. }
  50847. }
  50848. declare module BABYLON {
  50849. /**
  50850. * Default Inputs manager for the FlyCamera.
  50851. * It groups all the default supported inputs for ease of use.
  50852. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  50853. */
  50854. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  50855. /**
  50856. * Instantiates a new FlyCameraInputsManager.
  50857. * @param camera Defines the camera the inputs belong to.
  50858. */
  50859. constructor(camera: FlyCamera);
  50860. /**
  50861. * Add keyboard input support to the input manager.
  50862. * @returns the new FlyCameraKeyboardMoveInput().
  50863. */
  50864. addKeyboard(): FlyCameraInputsManager;
  50865. /**
  50866. * Add mouse input support to the input manager.
  50867. * @param touchEnabled Enable touch screen support.
  50868. * @returns the new FlyCameraMouseInput().
  50869. */
  50870. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  50871. }
  50872. }
  50873. declare module BABYLON {
  50874. /**
  50875. * This is a flying camera, designed for 3D movement and rotation in all directions,
  50876. * such as in a 3D Space Shooter or a Flight Simulator.
  50877. */
  50878. export class FlyCamera extends TargetCamera {
  50879. /**
  50880. * Define the collision ellipsoid of the camera.
  50881. * This is helpful for simulating a camera body, like a player's body.
  50882. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  50883. */
  50884. ellipsoid: Vector3;
  50885. /**
  50886. * Define an offset for the position of the ellipsoid around the camera.
  50887. * This can be helpful if the camera is attached away from the player's body center,
  50888. * such as at its head.
  50889. */
  50890. ellipsoidOffset: Vector3;
  50891. /**
  50892. * Enable or disable collisions of the camera with the rest of the scene objects.
  50893. */
  50894. checkCollisions: boolean;
  50895. /**
  50896. * Enable or disable gravity on the camera.
  50897. */
  50898. applyGravity: boolean;
  50899. /**
  50900. * Define the current direction the camera is moving to.
  50901. */
  50902. cameraDirection: Vector3;
  50903. /**
  50904. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  50905. * This overrides and empties cameraRotation.
  50906. */
  50907. rotationQuaternion: Quaternion;
  50908. /**
  50909. * Track Roll to maintain the wanted Rolling when looking around.
  50910. */
  50911. _trackRoll: number;
  50912. /**
  50913. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  50914. */
  50915. rollCorrect: number;
  50916. /**
  50917. * Mimic a banked turn, Rolling the camera when Yawing.
  50918. * It's recommended to use rollCorrect = 10 for faster banking correction.
  50919. */
  50920. bankedTurn: boolean;
  50921. /**
  50922. * Limit in radians for how much Roll banking will add. (Default: 90°)
  50923. */
  50924. bankedTurnLimit: number;
  50925. /**
  50926. * Value of 0 disables the banked Roll.
  50927. * Value of 1 is equal to the Yaw angle in radians.
  50928. */
  50929. bankedTurnMultiplier: number;
  50930. /**
  50931. * The inputs manager loads all the input sources, such as keyboard and mouse.
  50932. */
  50933. inputs: FlyCameraInputsManager;
  50934. /**
  50935. * Gets the input sensibility for mouse input.
  50936. * Higher values reduce sensitivity.
  50937. */
  50938. get angularSensibility(): number;
  50939. /**
  50940. * Sets the input sensibility for a mouse input.
  50941. * Higher values reduce sensitivity.
  50942. */
  50943. set angularSensibility(value: number);
  50944. /**
  50945. * Get the keys for camera movement forward.
  50946. */
  50947. get keysForward(): number[];
  50948. /**
  50949. * Set the keys for camera movement forward.
  50950. */
  50951. set keysForward(value: number[]);
  50952. /**
  50953. * Get the keys for camera movement backward.
  50954. */
  50955. get keysBackward(): number[];
  50956. set keysBackward(value: number[]);
  50957. /**
  50958. * Get the keys for camera movement up.
  50959. */
  50960. get keysUp(): number[];
  50961. /**
  50962. * Set the keys for camera movement up.
  50963. */
  50964. set keysUp(value: number[]);
  50965. /**
  50966. * Get the keys for camera movement down.
  50967. */
  50968. get keysDown(): number[];
  50969. /**
  50970. * Set the keys for camera movement down.
  50971. */
  50972. set keysDown(value: number[]);
  50973. /**
  50974. * Get the keys for camera movement left.
  50975. */
  50976. get keysLeft(): number[];
  50977. /**
  50978. * Set the keys for camera movement left.
  50979. */
  50980. set keysLeft(value: number[]);
  50981. /**
  50982. * Set the keys for camera movement right.
  50983. */
  50984. get keysRight(): number[];
  50985. /**
  50986. * Set the keys for camera movement right.
  50987. */
  50988. set keysRight(value: number[]);
  50989. /**
  50990. * Event raised when the camera collides with a mesh in the scene.
  50991. */
  50992. onCollide: (collidedMesh: AbstractMesh) => void;
  50993. private _collider;
  50994. private _needMoveForGravity;
  50995. private _oldPosition;
  50996. private _diffPosition;
  50997. private _newPosition;
  50998. /** @hidden */
  50999. _localDirection: Vector3;
  51000. /** @hidden */
  51001. _transformedDirection: Vector3;
  51002. /**
  51003. * Instantiates a FlyCamera.
  51004. * This is a flying camera, designed for 3D movement and rotation in all directions,
  51005. * such as in a 3D Space Shooter or a Flight Simulator.
  51006. * @param name Define the name of the camera in the scene.
  51007. * @param position Define the starting position of the camera in the scene.
  51008. * @param scene Define the scene the camera belongs to.
  51009. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  51010. */
  51011. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  51012. /**
  51013. * Attach the input controls to a specific dom element to get the input from.
  51014. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  51015. */
  51016. attachControl(noPreventDefault?: boolean): void;
  51017. /**
  51018. * Detach a control from the HTML DOM element.
  51019. * The camera will stop reacting to that input.
  51020. */
  51021. detachControl(): void;
  51022. private _collisionMask;
  51023. /**
  51024. * Get the mask that the camera ignores in collision events.
  51025. */
  51026. get collisionMask(): number;
  51027. /**
  51028. * Set the mask that the camera ignores in collision events.
  51029. */
  51030. set collisionMask(mask: number);
  51031. /** @hidden */
  51032. _collideWithWorld(displacement: Vector3): void;
  51033. /** @hidden */
  51034. private _onCollisionPositionChange;
  51035. /** @hidden */
  51036. _checkInputs(): void;
  51037. /** @hidden */
  51038. _decideIfNeedsToMove(): boolean;
  51039. /** @hidden */
  51040. _updatePosition(): void;
  51041. /**
  51042. * Restore the Roll to its target value at the rate specified.
  51043. * @param rate - Higher means slower restoring.
  51044. * @hidden
  51045. */
  51046. restoreRoll(rate: number): void;
  51047. /**
  51048. * Destroy the camera and release the current resources held by it.
  51049. */
  51050. dispose(): void;
  51051. /**
  51052. * Get the current object class name.
  51053. * @returns the class name.
  51054. */
  51055. getClassName(): string;
  51056. }
  51057. }
  51058. declare module BABYLON {
  51059. /**
  51060. * Listen to keyboard events to control the camera.
  51061. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  51062. */
  51063. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  51064. /**
  51065. * Defines the camera the input is attached to.
  51066. */
  51067. camera: FlyCamera;
  51068. /**
  51069. * The list of keyboard keys used to control the forward move of the camera.
  51070. */
  51071. keysForward: number[];
  51072. /**
  51073. * The list of keyboard keys used to control the backward move of the camera.
  51074. */
  51075. keysBackward: number[];
  51076. /**
  51077. * The list of keyboard keys used to control the forward move of the camera.
  51078. */
  51079. keysUp: number[];
  51080. /**
  51081. * The list of keyboard keys used to control the backward move of the camera.
  51082. */
  51083. keysDown: number[];
  51084. /**
  51085. * The list of keyboard keys used to control the right strafe move of the camera.
  51086. */
  51087. keysRight: number[];
  51088. /**
  51089. * The list of keyboard keys used to control the left strafe move of the camera.
  51090. */
  51091. keysLeft: number[];
  51092. private _keys;
  51093. private _onCanvasBlurObserver;
  51094. private _onKeyboardObserver;
  51095. private _engine;
  51096. private _scene;
  51097. /**
  51098. * Attach the input controls to a specific dom element to get the input from.
  51099. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  51100. */
  51101. attachControl(noPreventDefault?: boolean): void;
  51102. /**
  51103. * Detach the current controls from the specified dom element.
  51104. */
  51105. detachControl(): void;
  51106. /**
  51107. * Gets the class name of the current intput.
  51108. * @returns the class name
  51109. */
  51110. getClassName(): string;
  51111. /** @hidden */
  51112. _onLostFocus(e: FocusEvent): void;
  51113. /**
  51114. * Get the friendly name associated with the input class.
  51115. * @returns the input friendly name
  51116. */
  51117. getSimpleName(): string;
  51118. /**
  51119. * Update the current camera state depending on the inputs that have been used this frame.
  51120. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  51121. */
  51122. checkInputs(): void;
  51123. }
  51124. }
  51125. declare module BABYLON {
  51126. /**
  51127. * Manage the mouse wheel inputs to control a follow camera.
  51128. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  51129. */
  51130. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  51131. /**
  51132. * Defines the camera the input is attached to.
  51133. */
  51134. camera: FollowCamera;
  51135. /**
  51136. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  51137. */
  51138. axisControlRadius: boolean;
  51139. /**
  51140. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  51141. */
  51142. axisControlHeight: boolean;
  51143. /**
  51144. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  51145. */
  51146. axisControlRotation: boolean;
  51147. /**
  51148. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  51149. * relation to mouseWheel events.
  51150. */
  51151. wheelPrecision: number;
  51152. /**
  51153. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  51154. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  51155. */
  51156. wheelDeltaPercentage: number;
  51157. private _wheel;
  51158. private _observer;
  51159. /**
  51160. * Attach the input controls to a specific dom element to get the input from.
  51161. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  51162. */
  51163. attachControl(noPreventDefault?: boolean): void;
  51164. /**
  51165. * Detach the current controls from the specified dom element.
  51166. */
  51167. detachControl(): void;
  51168. /**
  51169. * Gets the class name of the current intput.
  51170. * @returns the class name
  51171. */
  51172. getClassName(): string;
  51173. /**
  51174. * Get the friendly name associated with the input class.
  51175. * @returns the input friendly name
  51176. */
  51177. getSimpleName(): string;
  51178. }
  51179. }
  51180. declare module BABYLON {
  51181. /**
  51182. * Manage the pointers inputs to control an follow camera.
  51183. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  51184. */
  51185. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  51186. /**
  51187. * Defines the camera the input is attached to.
  51188. */
  51189. camera: FollowCamera;
  51190. /**
  51191. * Gets the class name of the current input.
  51192. * @returns the class name
  51193. */
  51194. getClassName(): string;
  51195. /**
  51196. * Defines the pointer angular sensibility along the X axis or how fast is
  51197. * the camera rotating.
  51198. * A negative number will reverse the axis direction.
  51199. */
  51200. angularSensibilityX: number;
  51201. /**
  51202. * Defines the pointer angular sensibility along the Y axis or how fast is
  51203. * the camera rotating.
  51204. * A negative number will reverse the axis direction.
  51205. */
  51206. angularSensibilityY: number;
  51207. /**
  51208. * Defines the pointer pinch precision or how fast is the camera zooming.
  51209. * A negative number will reverse the axis direction.
  51210. */
  51211. pinchPrecision: number;
  51212. /**
  51213. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  51214. * from 0.
  51215. * It defines the percentage of current camera.radius to use as delta when
  51216. * pinch zoom is used.
  51217. */
  51218. pinchDeltaPercentage: number;
  51219. /**
  51220. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  51221. */
  51222. axisXControlRadius: boolean;
  51223. /**
  51224. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  51225. */
  51226. axisXControlHeight: boolean;
  51227. /**
  51228. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  51229. */
  51230. axisXControlRotation: boolean;
  51231. /**
  51232. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  51233. */
  51234. axisYControlRadius: boolean;
  51235. /**
  51236. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  51237. */
  51238. axisYControlHeight: boolean;
  51239. /**
  51240. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  51241. */
  51242. axisYControlRotation: boolean;
  51243. /**
  51244. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  51245. */
  51246. axisPinchControlRadius: boolean;
  51247. /**
  51248. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  51249. */
  51250. axisPinchControlHeight: boolean;
  51251. /**
  51252. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  51253. */
  51254. axisPinchControlRotation: boolean;
  51255. /**
  51256. * Log error messages if basic misconfiguration has occurred.
  51257. */
  51258. warningEnable: boolean;
  51259. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  51260. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  51261. private _warningCounter;
  51262. private _warning;
  51263. }
  51264. }
  51265. declare module BABYLON {
  51266. /**
  51267. * Default Inputs manager for the FollowCamera.
  51268. * It groups all the default supported inputs for ease of use.
  51269. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  51270. */
  51271. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  51272. /**
  51273. * Instantiates a new FollowCameraInputsManager.
  51274. * @param camera Defines the camera the inputs belong to
  51275. */
  51276. constructor(camera: FollowCamera);
  51277. /**
  51278. * Add keyboard input support to the input manager.
  51279. * @returns the current input manager
  51280. */
  51281. addKeyboard(): FollowCameraInputsManager;
  51282. /**
  51283. * Add mouse wheel input support to the input manager.
  51284. * @returns the current input manager
  51285. */
  51286. addMouseWheel(): FollowCameraInputsManager;
  51287. /**
  51288. * Add pointers input support to the input manager.
  51289. * @returns the current input manager
  51290. */
  51291. addPointers(): FollowCameraInputsManager;
  51292. /**
  51293. * Add orientation input support to the input manager.
  51294. * @returns the current input manager
  51295. */
  51296. addVRDeviceOrientation(): FollowCameraInputsManager;
  51297. }
  51298. }
  51299. declare module BABYLON {
  51300. /**
  51301. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  51302. * an arc rotate version arcFollowCamera are available.
  51303. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  51304. */
  51305. export class FollowCamera extends TargetCamera {
  51306. /**
  51307. * Distance the follow camera should follow an object at
  51308. */
  51309. radius: number;
  51310. /**
  51311. * Minimum allowed distance of the camera to the axis of rotation
  51312. * (The camera can not get closer).
  51313. * This can help limiting how the Camera is able to move in the scene.
  51314. */
  51315. lowerRadiusLimit: Nullable<number>;
  51316. /**
  51317. * Maximum allowed distance of the camera to the axis of rotation
  51318. * (The camera can not get further).
  51319. * This can help limiting how the Camera is able to move in the scene.
  51320. */
  51321. upperRadiusLimit: Nullable<number>;
  51322. /**
  51323. * Define a rotation offset between the camera and the object it follows
  51324. */
  51325. rotationOffset: number;
  51326. /**
  51327. * Minimum allowed angle to camera position relative to target object.
  51328. * This can help limiting how the Camera is able to move in the scene.
  51329. */
  51330. lowerRotationOffsetLimit: Nullable<number>;
  51331. /**
  51332. * Maximum allowed angle to camera position relative to target object.
  51333. * This can help limiting how the Camera is able to move in the scene.
  51334. */
  51335. upperRotationOffsetLimit: Nullable<number>;
  51336. /**
  51337. * Define a height offset between the camera and the object it follows.
  51338. * It can help following an object from the top (like a car chaing a plane)
  51339. */
  51340. heightOffset: number;
  51341. /**
  51342. * Minimum allowed height of camera position relative to target object.
  51343. * This can help limiting how the Camera is able to move in the scene.
  51344. */
  51345. lowerHeightOffsetLimit: Nullable<number>;
  51346. /**
  51347. * Maximum allowed height of camera position relative to target object.
  51348. * This can help limiting how the Camera is able to move in the scene.
  51349. */
  51350. upperHeightOffsetLimit: Nullable<number>;
  51351. /**
  51352. * Define how fast the camera can accelerate to follow it s target.
  51353. */
  51354. cameraAcceleration: number;
  51355. /**
  51356. * Define the speed limit of the camera following an object.
  51357. */
  51358. maxCameraSpeed: number;
  51359. /**
  51360. * Define the target of the camera.
  51361. */
  51362. lockedTarget: Nullable<AbstractMesh>;
  51363. /**
  51364. * Defines the input associated with the camera.
  51365. */
  51366. inputs: FollowCameraInputsManager;
  51367. /**
  51368. * Instantiates the follow camera.
  51369. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  51370. * @param name Define the name of the camera in the scene
  51371. * @param position Define the position of the camera
  51372. * @param scene Define the scene the camera belong to
  51373. * @param lockedTarget Define the target of the camera
  51374. */
  51375. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  51376. private _follow;
  51377. /**
  51378. * Attach the input controls to a specific dom element to get the input from.
  51379. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  51380. */
  51381. attachControl(noPreventDefault?: boolean): void;
  51382. /**
  51383. * Detach the current controls from the specified dom element.
  51384. */
  51385. detachControl(): void;
  51386. /** @hidden */
  51387. _checkInputs(): void;
  51388. private _checkLimits;
  51389. /**
  51390. * Gets the camera class name.
  51391. * @returns the class name
  51392. */
  51393. getClassName(): string;
  51394. }
  51395. /**
  51396. * Arc Rotate version of the follow camera.
  51397. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  51398. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  51399. */
  51400. export class ArcFollowCamera extends TargetCamera {
  51401. /** The longitudinal angle of the camera */
  51402. alpha: number;
  51403. /** The latitudinal angle of the camera */
  51404. beta: number;
  51405. /** The radius of the camera from its target */
  51406. radius: number;
  51407. private _cartesianCoordinates;
  51408. /** Define the camera target (the mesh it should follow) */
  51409. private _meshTarget;
  51410. /**
  51411. * Instantiates a new ArcFollowCamera
  51412. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  51413. * @param name Define the name of the camera
  51414. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  51415. * @param beta Define the rotation angle of the camera around the elevation axis
  51416. * @param radius Define the radius of the camera from its target point
  51417. * @param target Define the target of the camera
  51418. * @param scene Define the scene the camera belongs to
  51419. */
  51420. constructor(name: string,
  51421. /** The longitudinal angle of the camera */
  51422. alpha: number,
  51423. /** The latitudinal angle of the camera */
  51424. beta: number,
  51425. /** The radius of the camera from its target */
  51426. radius: number,
  51427. /** Define the camera target (the mesh it should follow) */
  51428. target: Nullable<AbstractMesh>, scene: Scene);
  51429. private _follow;
  51430. /** @hidden */
  51431. _checkInputs(): void;
  51432. /**
  51433. * Returns the class name of the object.
  51434. * It is mostly used internally for serialization purposes.
  51435. */
  51436. getClassName(): string;
  51437. }
  51438. }
  51439. declare module BABYLON {
  51440. /**
  51441. * Manage the keyboard inputs to control the movement of a follow camera.
  51442. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  51443. */
  51444. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  51445. /**
  51446. * Defines the camera the input is attached to.
  51447. */
  51448. camera: FollowCamera;
  51449. /**
  51450. * Defines the list of key codes associated with the up action (increase heightOffset)
  51451. */
  51452. keysHeightOffsetIncr: number[];
  51453. /**
  51454. * Defines the list of key codes associated with the down action (decrease heightOffset)
  51455. */
  51456. keysHeightOffsetDecr: number[];
  51457. /**
  51458. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  51459. */
  51460. keysHeightOffsetModifierAlt: boolean;
  51461. /**
  51462. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  51463. */
  51464. keysHeightOffsetModifierCtrl: boolean;
  51465. /**
  51466. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  51467. */
  51468. keysHeightOffsetModifierShift: boolean;
  51469. /**
  51470. * Defines the list of key codes associated with the left action (increase rotationOffset)
  51471. */
  51472. keysRotationOffsetIncr: number[];
  51473. /**
  51474. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  51475. */
  51476. keysRotationOffsetDecr: number[];
  51477. /**
  51478. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  51479. */
  51480. keysRotationOffsetModifierAlt: boolean;
  51481. /**
  51482. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  51483. */
  51484. keysRotationOffsetModifierCtrl: boolean;
  51485. /**
  51486. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  51487. */
  51488. keysRotationOffsetModifierShift: boolean;
  51489. /**
  51490. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  51491. */
  51492. keysRadiusIncr: number[];
  51493. /**
  51494. * Defines the list of key codes associated with the zoom-out action (increase radius)
  51495. */
  51496. keysRadiusDecr: number[];
  51497. /**
  51498. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  51499. */
  51500. keysRadiusModifierAlt: boolean;
  51501. /**
  51502. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  51503. */
  51504. keysRadiusModifierCtrl: boolean;
  51505. /**
  51506. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  51507. */
  51508. keysRadiusModifierShift: boolean;
  51509. /**
  51510. * Defines the rate of change of heightOffset.
  51511. */
  51512. heightSensibility: number;
  51513. /**
  51514. * Defines the rate of change of rotationOffset.
  51515. */
  51516. rotationSensibility: number;
  51517. /**
  51518. * Defines the rate of change of radius.
  51519. */
  51520. radiusSensibility: number;
  51521. private _keys;
  51522. private _ctrlPressed;
  51523. private _altPressed;
  51524. private _shiftPressed;
  51525. private _onCanvasBlurObserver;
  51526. private _onKeyboardObserver;
  51527. private _engine;
  51528. private _scene;
  51529. /**
  51530. * Attach the input controls to a specific dom element to get the input from.
  51531. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  51532. */
  51533. attachControl(noPreventDefault?: boolean): void;
  51534. /**
  51535. * Detach the current controls from the specified dom element.
  51536. */
  51537. detachControl(): void;
  51538. /**
  51539. * Update the current camera state depending on the inputs that have been used this frame.
  51540. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  51541. */
  51542. checkInputs(): void;
  51543. /**
  51544. * Gets the class name of the current input.
  51545. * @returns the class name
  51546. */
  51547. getClassName(): string;
  51548. /**
  51549. * Get the friendly name associated with the input class.
  51550. * @returns the input friendly name
  51551. */
  51552. getSimpleName(): string;
  51553. /**
  51554. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  51555. * allow modification of the heightOffset value.
  51556. */
  51557. private _modifierHeightOffset;
  51558. /**
  51559. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  51560. * allow modification of the rotationOffset value.
  51561. */
  51562. private _modifierRotationOffset;
  51563. /**
  51564. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  51565. * allow modification of the radius value.
  51566. */
  51567. private _modifierRadius;
  51568. }
  51569. }
  51570. declare module BABYLON {
  51571. interface FreeCameraInputsManager {
  51572. /**
  51573. * @hidden
  51574. */
  51575. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  51576. /**
  51577. * Add orientation input support to the input manager.
  51578. * @returns the current input manager
  51579. */
  51580. addDeviceOrientation(): FreeCameraInputsManager;
  51581. }
  51582. /**
  51583. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  51584. * Screen rotation is taken into account.
  51585. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  51586. */
  51587. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  51588. private _camera;
  51589. private _screenOrientationAngle;
  51590. private _constantTranform;
  51591. private _screenQuaternion;
  51592. private _alpha;
  51593. private _beta;
  51594. private _gamma;
  51595. /**
  51596. * Can be used to detect if a device orientation sensor is available on a device
  51597. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  51598. * @returns a promise that will resolve on orientation change
  51599. */
  51600. static WaitForOrientationChangeAsync(timeout?: number): Promise<void>;
  51601. /**
  51602. * @hidden
  51603. */
  51604. _onDeviceOrientationChangedObservable: Observable<void>;
  51605. /**
  51606. * Instantiates a new input
  51607. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  51608. */
  51609. constructor();
  51610. /**
  51611. * Define the camera controlled by the input.
  51612. */
  51613. get camera(): FreeCamera;
  51614. set camera(camera: FreeCamera);
  51615. /**
  51616. * Attach the input controls to a specific dom element to get the input from.
  51617. */
  51618. attachControl(): void;
  51619. private _orientationChanged;
  51620. private _deviceOrientation;
  51621. /**
  51622. * Detach the current controls from the specified dom element.
  51623. */
  51624. detachControl(): void;
  51625. /**
  51626. * Update the current camera state depending on the inputs that have been used this frame.
  51627. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  51628. */
  51629. checkInputs(): void;
  51630. /**
  51631. * Gets the class name of the current intput.
  51632. * @returns the class name
  51633. */
  51634. getClassName(): string;
  51635. /**
  51636. * Get the friendly name associated with the input class.
  51637. * @returns the input friendly name
  51638. */
  51639. getSimpleName(): string;
  51640. }
  51641. }
  51642. declare module BABYLON {
  51643. /**
  51644. * Manage the gamepad inputs to control a free camera.
  51645. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  51646. */
  51647. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  51648. /**
  51649. * Define the camera the input is attached to.
  51650. */
  51651. camera: FreeCamera;
  51652. /**
  51653. * Define the Gamepad controlling the input
  51654. */
  51655. gamepad: Nullable<Gamepad>;
  51656. /**
  51657. * Defines the gamepad rotation sensiblity.
  51658. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  51659. */
  51660. gamepadAngularSensibility: number;
  51661. /**
  51662. * Defines the gamepad move sensiblity.
  51663. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  51664. */
  51665. gamepadMoveSensibility: number;
  51666. private _yAxisScale;
  51667. /**
  51668. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  51669. */
  51670. get invertYAxis(): boolean;
  51671. set invertYAxis(value: boolean);
  51672. private _onGamepadConnectedObserver;
  51673. private _onGamepadDisconnectedObserver;
  51674. private _cameraTransform;
  51675. private _deltaTransform;
  51676. private _vector3;
  51677. private _vector2;
  51678. /**
  51679. * Attach the input controls to a specific dom element to get the input from.
  51680. */
  51681. attachControl(): void;
  51682. /**
  51683. * Detach the current controls from the specified dom element.
  51684. */
  51685. detachControl(): void;
  51686. /**
  51687. * Update the current camera state depending on the inputs that have been used this frame.
  51688. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  51689. */
  51690. checkInputs(): void;
  51691. /**
  51692. * Gets the class name of the current intput.
  51693. * @returns the class name
  51694. */
  51695. getClassName(): string;
  51696. /**
  51697. * Get the friendly name associated with the input class.
  51698. * @returns the input friendly name
  51699. */
  51700. getSimpleName(): string;
  51701. }
  51702. }
  51703. declare module BABYLON {
  51704. /**
  51705. * Defines the potential axis of a Joystick
  51706. */
  51707. export enum JoystickAxis {
  51708. /** X axis */
  51709. X = 0,
  51710. /** Y axis */
  51711. Y = 1,
  51712. /** Z axis */
  51713. Z = 2
  51714. }
  51715. /**
  51716. * Represents the different customization options available
  51717. * for VirtualJoystick
  51718. */
  51719. interface VirtualJoystickCustomizations {
  51720. /**
  51721. * Size of the joystick's puck
  51722. */
  51723. puckSize: number;
  51724. /**
  51725. * Size of the joystick's container
  51726. */
  51727. containerSize: number;
  51728. /**
  51729. * Color of the joystick && puck
  51730. */
  51731. color: string;
  51732. /**
  51733. * Image URL for the joystick's puck
  51734. */
  51735. puckImage?: string;
  51736. /**
  51737. * Image URL for the joystick's container
  51738. */
  51739. containerImage?: string;
  51740. /**
  51741. * Defines the unmoving position of the joystick container
  51742. */
  51743. position?: {
  51744. x: number;
  51745. y: number;
  51746. };
  51747. /**
  51748. * Defines whether or not the joystick container is always visible
  51749. */
  51750. alwaysVisible: boolean;
  51751. /**
  51752. * Defines whether or not to limit the movement of the puck to the joystick's container
  51753. */
  51754. limitToContainer: boolean;
  51755. }
  51756. /**
  51757. * Class used to define virtual joystick (used in touch mode)
  51758. */
  51759. export class VirtualJoystick {
  51760. /**
  51761. * Gets or sets a boolean indicating that left and right values must be inverted
  51762. */
  51763. reverseLeftRight: boolean;
  51764. /**
  51765. * Gets or sets a boolean indicating that up and down values must be inverted
  51766. */
  51767. reverseUpDown: boolean;
  51768. /**
  51769. * Gets the offset value for the position (ie. the change of the position value)
  51770. */
  51771. deltaPosition: Vector3;
  51772. /**
  51773. * Gets a boolean indicating if the virtual joystick was pressed
  51774. */
  51775. pressed: boolean;
  51776. /**
  51777. * Canvas the virtual joystick will render onto, default z-index of this is 5
  51778. */
  51779. static Canvas: Nullable<HTMLCanvasElement>;
  51780. /**
  51781. * boolean indicating whether or not the joystick's puck's movement should be limited to the joystick's container area
  51782. */
  51783. limitToContainer: boolean;
  51784. private static _globalJoystickIndex;
  51785. private static _alwaysVisibleSticks;
  51786. private static vjCanvasContext;
  51787. private static vjCanvasWidth;
  51788. private static vjCanvasHeight;
  51789. private static halfWidth;
  51790. private static _GetDefaultOptions;
  51791. private _action;
  51792. private _axisTargetedByLeftAndRight;
  51793. private _axisTargetedByUpAndDown;
  51794. private _joystickSensibility;
  51795. private _inversedSensibility;
  51796. private _joystickPointerID;
  51797. private _joystickColor;
  51798. private _joystickPointerPos;
  51799. private _joystickPreviousPointerPos;
  51800. private _joystickPointerStartPos;
  51801. private _deltaJoystickVector;
  51802. private _leftJoystick;
  51803. private _touches;
  51804. private _joystickPosition;
  51805. private _alwaysVisible;
  51806. private _puckImage;
  51807. private _containerImage;
  51808. private _joystickPuckSize;
  51809. private _joystickContainerSize;
  51810. private _clearPuckSize;
  51811. private _clearContainerSize;
  51812. private _clearPuckSizeOffset;
  51813. private _clearContainerSizeOffset;
  51814. private _onPointerDownHandlerRef;
  51815. private _onPointerMoveHandlerRef;
  51816. private _onPointerUpHandlerRef;
  51817. private _onResize;
  51818. /**
  51819. * Creates a new virtual joystick
  51820. * @param leftJoystick defines that the joystick is for left hand (false by default)
  51821. * @param customizations Defines the options we want to customize the VirtualJoystick
  51822. */
  51823. constructor(leftJoystick?: boolean, customizations?: Partial<VirtualJoystickCustomizations>);
  51824. /**
  51825. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  51826. * @param newJoystickSensibility defines the new sensibility
  51827. */
  51828. setJoystickSensibility(newJoystickSensibility: number): void;
  51829. private _onPointerDown;
  51830. private _onPointerMove;
  51831. private _onPointerUp;
  51832. /**
  51833. * Change the color of the virtual joystick
  51834. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  51835. */
  51836. setJoystickColor(newColor: string): void;
  51837. /**
  51838. * Size of the joystick's container
  51839. */
  51840. set containerSize(newSize: number);
  51841. get containerSize(): number;
  51842. /**
  51843. * Size of the joystick's puck
  51844. */
  51845. set puckSize(newSize: number);
  51846. get puckSize(): number;
  51847. /**
  51848. * Clears the set position of the joystick
  51849. */
  51850. clearPosition(): void;
  51851. /**
  51852. * Defines whether or not the joystick container is always visible
  51853. */
  51854. set alwaysVisible(value: boolean);
  51855. get alwaysVisible(): boolean;
  51856. /**
  51857. * Sets the constant position of the Joystick container
  51858. * @param x X axis coordinate
  51859. * @param y Y axis coordinate
  51860. */
  51861. setPosition(x: number, y: number): void;
  51862. /**
  51863. * Defines a callback to call when the joystick is touched
  51864. * @param action defines the callback
  51865. */
  51866. setActionOnTouch(action: () => any): void;
  51867. /**
  51868. * Defines which axis you'd like to control for left & right
  51869. * @param axis defines the axis to use
  51870. */
  51871. setAxisForLeftRight(axis: JoystickAxis): void;
  51872. /**
  51873. * Defines which axis you'd like to control for up & down
  51874. * @param axis defines the axis to use
  51875. */
  51876. setAxisForUpDown(axis: JoystickAxis): void;
  51877. /**
  51878. * Clears the canvas from the previous puck / container draw
  51879. */
  51880. private _clearPreviousDraw;
  51881. /**
  51882. * Loads `urlPath` to be used for the container's image
  51883. * @param urlPath defines the urlPath of an image to use
  51884. */
  51885. setContainerImage(urlPath: string): void;
  51886. /**
  51887. * Loads `urlPath` to be used for the puck's image
  51888. * @param urlPath defines the urlPath of an image to use
  51889. */
  51890. setPuckImage(urlPath: string): void;
  51891. /**
  51892. * Draws the Virtual Joystick's container
  51893. */
  51894. private _drawContainer;
  51895. /**
  51896. * Draws the Virtual Joystick's puck
  51897. */
  51898. private _drawPuck;
  51899. private _drawVirtualJoystick;
  51900. /**
  51901. * Release internal HTML canvas
  51902. */
  51903. releaseCanvas(): void;
  51904. }
  51905. }
  51906. declare module BABYLON {
  51907. interface FreeCameraInputsManager {
  51908. /**
  51909. * Add virtual joystick input support to the input manager.
  51910. * @returns the current input manager
  51911. */
  51912. addVirtualJoystick(): FreeCameraInputsManager;
  51913. }
  51914. /**
  51915. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  51916. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  51917. */
  51918. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  51919. /**
  51920. * Defines the camera the input is attached to.
  51921. */
  51922. camera: FreeCamera;
  51923. private _leftjoystick;
  51924. private _rightjoystick;
  51925. /**
  51926. * Gets the left stick of the virtual joystick.
  51927. * @returns The virtual Joystick
  51928. */
  51929. getLeftJoystick(): VirtualJoystick;
  51930. /**
  51931. * Gets the right stick of the virtual joystick.
  51932. * @returns The virtual Joystick
  51933. */
  51934. getRightJoystick(): VirtualJoystick;
  51935. /**
  51936. * Update the current camera state depending on the inputs that have been used this frame.
  51937. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  51938. */
  51939. checkInputs(): void;
  51940. /**
  51941. * Attach the input controls to a specific dom element to get the input from.
  51942. */
  51943. attachControl(): void;
  51944. /**
  51945. * Detach the current controls from the specified dom element.
  51946. */
  51947. detachControl(): void;
  51948. /**
  51949. * Gets the class name of the current intput.
  51950. * @returns the class name
  51951. */
  51952. getClassName(): string;
  51953. /**
  51954. * Get the friendly name associated with the input class.
  51955. * @returns the input friendly name
  51956. */
  51957. getSimpleName(): string;
  51958. }
  51959. }
  51960. declare module BABYLON {
  51961. /**
  51962. * This represents a FPS type of camera controlled by touch.
  51963. * This is like a universal camera minus the Gamepad controls.
  51964. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  51965. */
  51966. export class TouchCamera extends FreeCamera {
  51967. /**
  51968. * Defines the touch sensibility for rotation.
  51969. * The higher the faster.
  51970. */
  51971. get touchAngularSensibility(): number;
  51972. set touchAngularSensibility(value: number);
  51973. /**
  51974. * Defines the touch sensibility for move.
  51975. * The higher the faster.
  51976. */
  51977. get touchMoveSensibility(): number;
  51978. set touchMoveSensibility(value: number);
  51979. /**
  51980. * Instantiates a new touch camera.
  51981. * This represents a FPS type of camera controlled by touch.
  51982. * This is like a universal camera minus the Gamepad controls.
  51983. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  51984. * @param name Define the name of the camera in the scene
  51985. * @param position Define the start position of the camera in the scene
  51986. * @param scene Define the scene the camera belongs to
  51987. */
  51988. constructor(name: string, position: Vector3, scene: Scene);
  51989. /**
  51990. * Gets the current object class name.
  51991. * @return the class name
  51992. */
  51993. getClassName(): string;
  51994. /** @hidden */
  51995. _setupInputs(): void;
  51996. }
  51997. }
  51998. declare module BABYLON {
  51999. /**
  52000. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  52001. * being tilted forward or back and left or right.
  52002. */
  52003. export class DeviceOrientationCamera extends FreeCamera {
  52004. private _initialQuaternion;
  52005. private _quaternionCache;
  52006. private _tmpDragQuaternion;
  52007. private _disablePointerInputWhenUsingDeviceOrientation;
  52008. /**
  52009. * Creates a new device orientation camera
  52010. * @param name The name of the camera
  52011. * @param position The start position camera
  52012. * @param scene The scene the camera belongs to
  52013. */
  52014. constructor(name: string, position: Vector3, scene: Scene);
  52015. /**
  52016. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  52017. */
  52018. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  52019. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  52020. private _dragFactor;
  52021. /**
  52022. * Enabled turning on the y axis when the orientation sensor is active
  52023. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  52024. */
  52025. enableHorizontalDragging(dragFactor?: number): void;
  52026. /**
  52027. * Gets the current instance class name ("DeviceOrientationCamera").
  52028. * This helps avoiding instanceof at run time.
  52029. * @returns the class name
  52030. */
  52031. getClassName(): string;
  52032. /**
  52033. * @hidden
  52034. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  52035. */
  52036. _checkInputs(): void;
  52037. /**
  52038. * Reset the camera to its default orientation on the specified axis only.
  52039. * @param axis The axis to reset
  52040. */
  52041. resetToCurrentRotation(axis?: Axis): void;
  52042. }
  52043. }
  52044. declare module BABYLON {
  52045. /**
  52046. * Defines supported buttons for XBox360 compatible gamepads
  52047. */
  52048. export enum Xbox360Button {
  52049. /** A */
  52050. A = 0,
  52051. /** B */
  52052. B = 1,
  52053. /** X */
  52054. X = 2,
  52055. /** Y */
  52056. Y = 3,
  52057. /** Left button */
  52058. LB = 4,
  52059. /** Right button */
  52060. RB = 5,
  52061. /** Back */
  52062. Back = 8,
  52063. /** Start */
  52064. Start = 9,
  52065. /** Left stick */
  52066. LeftStick = 10,
  52067. /** Right stick */
  52068. RightStick = 11
  52069. }
  52070. /** Defines values for XBox360 DPad */
  52071. export enum Xbox360Dpad {
  52072. /** Up */
  52073. Up = 12,
  52074. /** Down */
  52075. Down = 13,
  52076. /** Left */
  52077. Left = 14,
  52078. /** Right */
  52079. Right = 15
  52080. }
  52081. /**
  52082. * Defines a XBox360 gamepad
  52083. */
  52084. export class Xbox360Pad extends Gamepad {
  52085. private _leftTrigger;
  52086. private _rightTrigger;
  52087. private _onlefttriggerchanged;
  52088. private _onrighttriggerchanged;
  52089. private _onbuttondown;
  52090. private _onbuttonup;
  52091. private _ondpaddown;
  52092. private _ondpadup;
  52093. /** Observable raised when a button is pressed */
  52094. onButtonDownObservable: Observable<Xbox360Button>;
  52095. /** Observable raised when a button is released */
  52096. onButtonUpObservable: Observable<Xbox360Button>;
  52097. /** Observable raised when a pad is pressed */
  52098. onPadDownObservable: Observable<Xbox360Dpad>;
  52099. /** Observable raised when a pad is released */
  52100. onPadUpObservable: Observable<Xbox360Dpad>;
  52101. private _buttonA;
  52102. private _buttonB;
  52103. private _buttonX;
  52104. private _buttonY;
  52105. private _buttonBack;
  52106. private _buttonStart;
  52107. private _buttonLB;
  52108. private _buttonRB;
  52109. private _buttonLeftStick;
  52110. private _buttonRightStick;
  52111. private _dPadUp;
  52112. private _dPadDown;
  52113. private _dPadLeft;
  52114. private _dPadRight;
  52115. private _isXboxOnePad;
  52116. /**
  52117. * Creates a new XBox360 gamepad object
  52118. * @param id defines the id of this gamepad
  52119. * @param index defines its index
  52120. * @param gamepad defines the internal HTML gamepad object
  52121. * @param xboxOne defines if it is a XBox One gamepad
  52122. */
  52123. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  52124. /**
  52125. * Defines the callback to call when left trigger is pressed
  52126. * @param callback defines the callback to use
  52127. */
  52128. onlefttriggerchanged(callback: (value: number) => void): void;
  52129. /**
  52130. * Defines the callback to call when right trigger is pressed
  52131. * @param callback defines the callback to use
  52132. */
  52133. onrighttriggerchanged(callback: (value: number) => void): void;
  52134. /**
  52135. * Gets the left trigger value
  52136. */
  52137. get leftTrigger(): number;
  52138. /**
  52139. * Sets the left trigger value
  52140. */
  52141. set leftTrigger(newValue: number);
  52142. /**
  52143. * Gets the right trigger value
  52144. */
  52145. get rightTrigger(): number;
  52146. /**
  52147. * Sets the right trigger value
  52148. */
  52149. set rightTrigger(newValue: number);
  52150. /**
  52151. * Defines the callback to call when a button is pressed
  52152. * @param callback defines the callback to use
  52153. */
  52154. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  52155. /**
  52156. * Defines the callback to call when a button is released
  52157. * @param callback defines the callback to use
  52158. */
  52159. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  52160. /**
  52161. * Defines the callback to call when a pad is pressed
  52162. * @param callback defines the callback to use
  52163. */
  52164. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  52165. /**
  52166. * Defines the callback to call when a pad is released
  52167. * @param callback defines the callback to use
  52168. */
  52169. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  52170. private _setButtonValue;
  52171. private _setDPadValue;
  52172. /**
  52173. * Gets the value of the `A` button
  52174. */
  52175. get buttonA(): number;
  52176. /**
  52177. * Sets the value of the `A` button
  52178. */
  52179. set buttonA(value: number);
  52180. /**
  52181. * Gets the value of the `B` button
  52182. */
  52183. get buttonB(): number;
  52184. /**
  52185. * Sets the value of the `B` button
  52186. */
  52187. set buttonB(value: number);
  52188. /**
  52189. * Gets the value of the `X` button
  52190. */
  52191. get buttonX(): number;
  52192. /**
  52193. * Sets the value of the `X` button
  52194. */
  52195. set buttonX(value: number);
  52196. /**
  52197. * Gets the value of the `Y` button
  52198. */
  52199. get buttonY(): number;
  52200. /**
  52201. * Sets the value of the `Y` button
  52202. */
  52203. set buttonY(value: number);
  52204. /**
  52205. * Gets the value of the `Start` button
  52206. */
  52207. get buttonStart(): number;
  52208. /**
  52209. * Sets the value of the `Start` button
  52210. */
  52211. set buttonStart(value: number);
  52212. /**
  52213. * Gets the value of the `Back` button
  52214. */
  52215. get buttonBack(): number;
  52216. /**
  52217. * Sets the value of the `Back` button
  52218. */
  52219. set buttonBack(value: number);
  52220. /**
  52221. * Gets the value of the `Left` button
  52222. */
  52223. get buttonLB(): number;
  52224. /**
  52225. * Sets the value of the `Left` button
  52226. */
  52227. set buttonLB(value: number);
  52228. /**
  52229. * Gets the value of the `Right` button
  52230. */
  52231. get buttonRB(): number;
  52232. /**
  52233. * Sets the value of the `Right` button
  52234. */
  52235. set buttonRB(value: number);
  52236. /**
  52237. * Gets the value of the Left joystick
  52238. */
  52239. get buttonLeftStick(): number;
  52240. /**
  52241. * Sets the value of the Left joystick
  52242. */
  52243. set buttonLeftStick(value: number);
  52244. /**
  52245. * Gets the value of the Right joystick
  52246. */
  52247. get buttonRightStick(): number;
  52248. /**
  52249. * Sets the value of the Right joystick
  52250. */
  52251. set buttonRightStick(value: number);
  52252. /**
  52253. * Gets the value of D-pad up
  52254. */
  52255. get dPadUp(): number;
  52256. /**
  52257. * Sets the value of D-pad up
  52258. */
  52259. set dPadUp(value: number);
  52260. /**
  52261. * Gets the value of D-pad down
  52262. */
  52263. get dPadDown(): number;
  52264. /**
  52265. * Sets the value of D-pad down
  52266. */
  52267. set dPadDown(value: number);
  52268. /**
  52269. * Gets the value of D-pad left
  52270. */
  52271. get dPadLeft(): number;
  52272. /**
  52273. * Sets the value of D-pad left
  52274. */
  52275. set dPadLeft(value: number);
  52276. /**
  52277. * Gets the value of D-pad right
  52278. */
  52279. get dPadRight(): number;
  52280. /**
  52281. * Sets the value of D-pad right
  52282. */
  52283. set dPadRight(value: number);
  52284. /**
  52285. * Force the gamepad to synchronize with device values
  52286. */
  52287. update(): void;
  52288. /**
  52289. * Disposes the gamepad
  52290. */
  52291. dispose(): void;
  52292. }
  52293. }
  52294. declare module BABYLON {
  52295. /**
  52296. * Defines supported buttons for DualShock compatible gamepads
  52297. */
  52298. export enum DualShockButton {
  52299. /** Cross */
  52300. Cross = 0,
  52301. /** Circle */
  52302. Circle = 1,
  52303. /** Square */
  52304. Square = 2,
  52305. /** Triangle */
  52306. Triangle = 3,
  52307. /** L1 */
  52308. L1 = 4,
  52309. /** R1 */
  52310. R1 = 5,
  52311. /** Share */
  52312. Share = 8,
  52313. /** Options */
  52314. Options = 9,
  52315. /** Left stick */
  52316. LeftStick = 10,
  52317. /** Right stick */
  52318. RightStick = 11
  52319. }
  52320. /** Defines values for DualShock DPad */
  52321. export enum DualShockDpad {
  52322. /** Up */
  52323. Up = 12,
  52324. /** Down */
  52325. Down = 13,
  52326. /** Left */
  52327. Left = 14,
  52328. /** Right */
  52329. Right = 15
  52330. }
  52331. /**
  52332. * Defines a DualShock gamepad
  52333. */
  52334. export class DualShockPad extends Gamepad {
  52335. private _leftTrigger;
  52336. private _rightTrigger;
  52337. private _onlefttriggerchanged;
  52338. private _onrighttriggerchanged;
  52339. private _onbuttondown;
  52340. private _onbuttonup;
  52341. private _ondpaddown;
  52342. private _ondpadup;
  52343. /** Observable raised when a button is pressed */
  52344. onButtonDownObservable: Observable<DualShockButton>;
  52345. /** Observable raised when a button is released */
  52346. onButtonUpObservable: Observable<DualShockButton>;
  52347. /** Observable raised when a pad is pressed */
  52348. onPadDownObservable: Observable<DualShockDpad>;
  52349. /** Observable raised when a pad is released */
  52350. onPadUpObservable: Observable<DualShockDpad>;
  52351. private _buttonCross;
  52352. private _buttonCircle;
  52353. private _buttonSquare;
  52354. private _buttonTriangle;
  52355. private _buttonShare;
  52356. private _buttonOptions;
  52357. private _buttonL1;
  52358. private _buttonR1;
  52359. private _buttonLeftStick;
  52360. private _buttonRightStick;
  52361. private _dPadUp;
  52362. private _dPadDown;
  52363. private _dPadLeft;
  52364. private _dPadRight;
  52365. /**
  52366. * Creates a new DualShock gamepad object
  52367. * @param id defines the id of this gamepad
  52368. * @param index defines its index
  52369. * @param gamepad defines the internal HTML gamepad object
  52370. */
  52371. constructor(id: string, index: number, gamepad: any);
  52372. /**
  52373. * Defines the callback to call when left trigger is pressed
  52374. * @param callback defines the callback to use
  52375. */
  52376. onlefttriggerchanged(callback: (value: number) => void): void;
  52377. /**
  52378. * Defines the callback to call when right trigger is pressed
  52379. * @param callback defines the callback to use
  52380. */
  52381. onrighttriggerchanged(callback: (value: number) => void): void;
  52382. /**
  52383. * Gets the left trigger value
  52384. */
  52385. get leftTrigger(): number;
  52386. /**
  52387. * Sets the left trigger value
  52388. */
  52389. set leftTrigger(newValue: number);
  52390. /**
  52391. * Gets the right trigger value
  52392. */
  52393. get rightTrigger(): number;
  52394. /**
  52395. * Sets the right trigger value
  52396. */
  52397. set rightTrigger(newValue: number);
  52398. /**
  52399. * Defines the callback to call when a button is pressed
  52400. * @param callback defines the callback to use
  52401. */
  52402. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  52403. /**
  52404. * Defines the callback to call when a button is released
  52405. * @param callback defines the callback to use
  52406. */
  52407. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  52408. /**
  52409. * Defines the callback to call when a pad is pressed
  52410. * @param callback defines the callback to use
  52411. */
  52412. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  52413. /**
  52414. * Defines the callback to call when a pad is released
  52415. * @param callback defines the callback to use
  52416. */
  52417. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  52418. private _setButtonValue;
  52419. private _setDPadValue;
  52420. /**
  52421. * Gets the value of the `Cross` button
  52422. */
  52423. get buttonCross(): number;
  52424. /**
  52425. * Sets the value of the `Cross` button
  52426. */
  52427. set buttonCross(value: number);
  52428. /**
  52429. * Gets the value of the `Circle` button
  52430. */
  52431. get buttonCircle(): number;
  52432. /**
  52433. * Sets the value of the `Circle` button
  52434. */
  52435. set buttonCircle(value: number);
  52436. /**
  52437. * Gets the value of the `Square` button
  52438. */
  52439. get buttonSquare(): number;
  52440. /**
  52441. * Sets the value of the `Square` button
  52442. */
  52443. set buttonSquare(value: number);
  52444. /**
  52445. * Gets the value of the `Triangle` button
  52446. */
  52447. get buttonTriangle(): number;
  52448. /**
  52449. * Sets the value of the `Triangle` button
  52450. */
  52451. set buttonTriangle(value: number);
  52452. /**
  52453. * Gets the value of the `Options` button
  52454. */
  52455. get buttonOptions(): number;
  52456. /**
  52457. * Sets the value of the `Options` button
  52458. */
  52459. set buttonOptions(value: number);
  52460. /**
  52461. * Gets the value of the `Share` button
  52462. */
  52463. get buttonShare(): number;
  52464. /**
  52465. * Sets the value of the `Share` button
  52466. */
  52467. set buttonShare(value: number);
  52468. /**
  52469. * Gets the value of the `L1` button
  52470. */
  52471. get buttonL1(): number;
  52472. /**
  52473. * Sets the value of the `L1` button
  52474. */
  52475. set buttonL1(value: number);
  52476. /**
  52477. * Gets the value of the `R1` button
  52478. */
  52479. get buttonR1(): number;
  52480. /**
  52481. * Sets the value of the `R1` button
  52482. */
  52483. set buttonR1(value: number);
  52484. /**
  52485. * Gets the value of the Left joystick
  52486. */
  52487. get buttonLeftStick(): number;
  52488. /**
  52489. * Sets the value of the Left joystick
  52490. */
  52491. set buttonLeftStick(value: number);
  52492. /**
  52493. * Gets the value of the Right joystick
  52494. */
  52495. get buttonRightStick(): number;
  52496. /**
  52497. * Sets the value of the Right joystick
  52498. */
  52499. set buttonRightStick(value: number);
  52500. /**
  52501. * Gets the value of D-pad up
  52502. */
  52503. get dPadUp(): number;
  52504. /**
  52505. * Sets the value of D-pad up
  52506. */
  52507. set dPadUp(value: number);
  52508. /**
  52509. * Gets the value of D-pad down
  52510. */
  52511. get dPadDown(): number;
  52512. /**
  52513. * Sets the value of D-pad down
  52514. */
  52515. set dPadDown(value: number);
  52516. /**
  52517. * Gets the value of D-pad left
  52518. */
  52519. get dPadLeft(): number;
  52520. /**
  52521. * Sets the value of D-pad left
  52522. */
  52523. set dPadLeft(value: number);
  52524. /**
  52525. * Gets the value of D-pad right
  52526. */
  52527. get dPadRight(): number;
  52528. /**
  52529. * Sets the value of D-pad right
  52530. */
  52531. set dPadRight(value: number);
  52532. /**
  52533. * Force the gamepad to synchronize with device values
  52534. */
  52535. update(): void;
  52536. /**
  52537. * Disposes the gamepad
  52538. */
  52539. dispose(): void;
  52540. }
  52541. }
  52542. declare module BABYLON {
  52543. /**
  52544. * Manager for handling gamepads
  52545. */
  52546. export class GamepadManager {
  52547. private _scene?;
  52548. private _babylonGamepads;
  52549. private _oneGamepadConnected;
  52550. /** @hidden */
  52551. _isMonitoring: boolean;
  52552. private _gamepadEventSupported;
  52553. private _gamepadSupport?;
  52554. /**
  52555. * observable to be triggered when the gamepad controller has been connected
  52556. */
  52557. onGamepadConnectedObservable: Observable<Gamepad>;
  52558. /**
  52559. * observable to be triggered when the gamepad controller has been disconnected
  52560. */
  52561. onGamepadDisconnectedObservable: Observable<Gamepad>;
  52562. private _onGamepadConnectedEvent;
  52563. private _onGamepadDisconnectedEvent;
  52564. /**
  52565. * Initializes the gamepad manager
  52566. * @param _scene BabylonJS scene
  52567. */
  52568. constructor(_scene?: Scene | undefined);
  52569. /**
  52570. * The gamepads in the game pad manager
  52571. */
  52572. get gamepads(): Gamepad[];
  52573. /**
  52574. * Get the gamepad controllers based on type
  52575. * @param type The type of gamepad controller
  52576. * @returns Nullable gamepad
  52577. */
  52578. getGamepadByType(type?: number): Nullable<Gamepad>;
  52579. /**
  52580. * Disposes the gamepad manager
  52581. */
  52582. dispose(): void;
  52583. private _addNewGamepad;
  52584. private _startMonitoringGamepads;
  52585. private _stopMonitoringGamepads;
  52586. /** @hidden */
  52587. _checkGamepadsStatus(): void;
  52588. private _updateGamepadObjects;
  52589. }
  52590. }
  52591. declare module BABYLON {
  52592. interface Scene {
  52593. /** @hidden */
  52594. _gamepadManager: Nullable<GamepadManager>;
  52595. /**
  52596. * Gets the gamepad manager associated with the scene
  52597. * @see https://doc.babylonjs.com/how_to/how_to_use_gamepads
  52598. */
  52599. gamepadManager: GamepadManager;
  52600. }
  52601. /**
  52602. * Interface representing a free camera inputs manager
  52603. */
  52604. interface FreeCameraInputsManager {
  52605. /**
  52606. * Adds gamepad input support to the FreeCameraInputsManager.
  52607. * @returns the FreeCameraInputsManager
  52608. */
  52609. addGamepad(): FreeCameraInputsManager;
  52610. }
  52611. /**
  52612. * Interface representing an arc rotate camera inputs manager
  52613. */
  52614. interface ArcRotateCameraInputsManager {
  52615. /**
  52616. * Adds gamepad input support to the ArcRotateCamera InputManager.
  52617. * @returns the camera inputs manager
  52618. */
  52619. addGamepad(): ArcRotateCameraInputsManager;
  52620. }
  52621. /**
  52622. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  52623. */
  52624. export class GamepadSystemSceneComponent implements ISceneComponent {
  52625. /**
  52626. * The component name helpfull to identify the component in the list of scene components.
  52627. */
  52628. readonly name: string;
  52629. /**
  52630. * The scene the component belongs to.
  52631. */
  52632. scene: Scene;
  52633. /**
  52634. * Creates a new instance of the component for the given scene
  52635. * @param scene Defines the scene to register the component in
  52636. */
  52637. constructor(scene: Scene);
  52638. /**
  52639. * Registers the component in a given scene
  52640. */
  52641. register(): void;
  52642. /**
  52643. * Rebuilds the elements related to this component in case of
  52644. * context lost for instance.
  52645. */
  52646. rebuild(): void;
  52647. /**
  52648. * Disposes the component and the associated ressources
  52649. */
  52650. dispose(): void;
  52651. private _beforeCameraUpdate;
  52652. }
  52653. }
  52654. declare module BABYLON {
  52655. /**
  52656. * 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,
  52657. * which still works and will still be found in many Playgrounds.
  52658. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  52659. */
  52660. export class UniversalCamera extends TouchCamera {
  52661. /**
  52662. * Defines the gamepad rotation sensiblity.
  52663. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  52664. */
  52665. get gamepadAngularSensibility(): number;
  52666. set gamepadAngularSensibility(value: number);
  52667. /**
  52668. * Defines the gamepad move sensiblity.
  52669. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  52670. */
  52671. get gamepadMoveSensibility(): number;
  52672. set gamepadMoveSensibility(value: number);
  52673. /**
  52674. * 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,
  52675. * which still works and will still be found in many Playgrounds.
  52676. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  52677. * @param name Define the name of the camera in the scene
  52678. * @param position Define the start position of the camera in the scene
  52679. * @param scene Define the scene the camera belongs to
  52680. */
  52681. constructor(name: string, position: Vector3, scene: Scene);
  52682. /**
  52683. * Gets the current object class name.
  52684. * @return the class name
  52685. */
  52686. getClassName(): string;
  52687. }
  52688. }
  52689. declare module BABYLON {
  52690. /**
  52691. * This represents a FPS type of camera. This is only here for back compat purpose.
  52692. * Please use the UniversalCamera instead as both are identical.
  52693. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  52694. */
  52695. export class GamepadCamera extends UniversalCamera {
  52696. /**
  52697. * Instantiates a new Gamepad Camera
  52698. * This represents a FPS type of camera. This is only here for back compat purpose.
  52699. * Please use the UniversalCamera instead as both are identical.
  52700. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  52701. * @param name Define the name of the camera in the scene
  52702. * @param position Define the start position of the camera in the scene
  52703. * @param scene Define the scene the camera belongs to
  52704. */
  52705. constructor(name: string, position: Vector3, scene: Scene);
  52706. /**
  52707. * Gets the current object class name.
  52708. * @return the class name
  52709. */
  52710. getClassName(): string;
  52711. }
  52712. }
  52713. declare module BABYLON {
  52714. /** @hidden */
  52715. export var anaglyphPixelShader: {
  52716. name: string;
  52717. shader: string;
  52718. };
  52719. }
  52720. declare module BABYLON {
  52721. /**
  52722. * Postprocess used to generate anaglyphic rendering
  52723. */
  52724. export class AnaglyphPostProcess extends PostProcess {
  52725. private _passedProcess;
  52726. /**
  52727. * Gets a string identifying the name of the class
  52728. * @returns "AnaglyphPostProcess" string
  52729. */
  52730. getClassName(): string;
  52731. /**
  52732. * Creates a new AnaglyphPostProcess
  52733. * @param name defines postprocess name
  52734. * @param options defines creation options or target ratio scale
  52735. * @param rigCameras defines cameras using this postprocess
  52736. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  52737. * @param engine defines hosting engine
  52738. * @param reusable defines if the postprocess will be reused multiple times per frame
  52739. */
  52740. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  52741. }
  52742. }
  52743. declare module BABYLON {
  52744. /**
  52745. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  52746. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  52747. */
  52748. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  52749. /**
  52750. * Creates a new AnaglyphArcRotateCamera
  52751. * @param name defines camera name
  52752. * @param alpha defines alpha angle (in radians)
  52753. * @param beta defines beta angle (in radians)
  52754. * @param radius defines radius
  52755. * @param target defines camera target
  52756. * @param interaxialDistance defines distance between each color axis
  52757. * @param scene defines the hosting scene
  52758. */
  52759. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  52760. /**
  52761. * Gets camera class name
  52762. * @returns AnaglyphArcRotateCamera
  52763. */
  52764. getClassName(): string;
  52765. }
  52766. }
  52767. declare module BABYLON {
  52768. /**
  52769. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  52770. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  52771. */
  52772. export class AnaglyphFreeCamera extends FreeCamera {
  52773. /**
  52774. * Creates a new AnaglyphFreeCamera
  52775. * @param name defines camera name
  52776. * @param position defines initial position
  52777. * @param interaxialDistance defines distance between each color axis
  52778. * @param scene defines the hosting scene
  52779. */
  52780. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  52781. /**
  52782. * Gets camera class name
  52783. * @returns AnaglyphFreeCamera
  52784. */
  52785. getClassName(): string;
  52786. }
  52787. }
  52788. declare module BABYLON {
  52789. /**
  52790. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  52791. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  52792. */
  52793. export class AnaglyphGamepadCamera extends GamepadCamera {
  52794. /**
  52795. * Creates a new AnaglyphGamepadCamera
  52796. * @param name defines camera name
  52797. * @param position defines initial position
  52798. * @param interaxialDistance defines distance between each color axis
  52799. * @param scene defines the hosting scene
  52800. */
  52801. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  52802. /**
  52803. * Gets camera class name
  52804. * @returns AnaglyphGamepadCamera
  52805. */
  52806. getClassName(): string;
  52807. }
  52808. }
  52809. declare module BABYLON {
  52810. /**
  52811. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  52812. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  52813. */
  52814. export class AnaglyphUniversalCamera extends UniversalCamera {
  52815. /**
  52816. * Creates a new AnaglyphUniversalCamera
  52817. * @param name defines camera name
  52818. * @param position defines initial position
  52819. * @param interaxialDistance defines distance between each color axis
  52820. * @param scene defines the hosting scene
  52821. */
  52822. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  52823. /**
  52824. * Gets camera class name
  52825. * @returns AnaglyphUniversalCamera
  52826. */
  52827. getClassName(): string;
  52828. }
  52829. }
  52830. declare module BABYLON {
  52831. /** @hidden */
  52832. export var stereoscopicInterlacePixelShader: {
  52833. name: string;
  52834. shader: string;
  52835. };
  52836. }
  52837. declare module BABYLON {
  52838. /**
  52839. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  52840. */
  52841. export class StereoscopicInterlacePostProcessI extends PostProcess {
  52842. private _stepSize;
  52843. private _passedProcess;
  52844. /**
  52845. * Gets a string identifying the name of the class
  52846. * @returns "StereoscopicInterlacePostProcessI" string
  52847. */
  52848. getClassName(): string;
  52849. /**
  52850. * Initializes a StereoscopicInterlacePostProcessI
  52851. * @param name The name of the effect.
  52852. * @param rigCameras The rig cameras to be appled to the post process
  52853. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  52854. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  52855. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52856. * @param engine The engine which the post process will be applied. (default: current engine)
  52857. * @param reusable If the post process can be reused on the same frame. (default: false)
  52858. */
  52859. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  52860. }
  52861. /**
  52862. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  52863. */
  52864. export class StereoscopicInterlacePostProcess extends PostProcess {
  52865. private _stepSize;
  52866. private _passedProcess;
  52867. /**
  52868. * Gets a string identifying the name of the class
  52869. * @returns "StereoscopicInterlacePostProcess" string
  52870. */
  52871. getClassName(): string;
  52872. /**
  52873. * Initializes a StereoscopicInterlacePostProcess
  52874. * @param name The name of the effect.
  52875. * @param rigCameras The rig cameras to be appled to the post process
  52876. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  52877. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52878. * @param engine The engine which the post process will be applied. (default: current engine)
  52879. * @param reusable If the post process can be reused on the same frame. (default: false)
  52880. */
  52881. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  52882. }
  52883. }
  52884. declare module BABYLON {
  52885. /**
  52886. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  52887. * @see https://doc.babylonjs.com/features/cameras
  52888. */
  52889. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  52890. /**
  52891. * Creates a new StereoscopicArcRotateCamera
  52892. * @param name defines camera name
  52893. * @param alpha defines alpha angle (in radians)
  52894. * @param beta defines beta angle (in radians)
  52895. * @param radius defines radius
  52896. * @param target defines camera target
  52897. * @param interaxialDistance defines distance between each color axis
  52898. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  52899. * @param scene defines the hosting scene
  52900. */
  52901. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  52902. /**
  52903. * Gets camera class name
  52904. * @returns StereoscopicArcRotateCamera
  52905. */
  52906. getClassName(): string;
  52907. }
  52908. }
  52909. declare module BABYLON {
  52910. /**
  52911. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  52912. * @see https://doc.babylonjs.com/features/cameras
  52913. */
  52914. export class StereoscopicFreeCamera extends FreeCamera {
  52915. /**
  52916. * Creates a new StereoscopicFreeCamera
  52917. * @param name defines camera name
  52918. * @param position defines initial position
  52919. * @param interaxialDistance defines distance between each color axis
  52920. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  52921. * @param scene defines the hosting scene
  52922. */
  52923. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  52924. /**
  52925. * Gets camera class name
  52926. * @returns StereoscopicFreeCamera
  52927. */
  52928. getClassName(): string;
  52929. }
  52930. }
  52931. declare module BABYLON {
  52932. /**
  52933. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  52934. * @see https://doc.babylonjs.com/features/cameras
  52935. */
  52936. export class StereoscopicGamepadCamera extends GamepadCamera {
  52937. /**
  52938. * Creates a new StereoscopicGamepadCamera
  52939. * @param name defines camera name
  52940. * @param position defines initial position
  52941. * @param interaxialDistance defines distance between each color axis
  52942. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  52943. * @param scene defines the hosting scene
  52944. */
  52945. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  52946. /**
  52947. * Gets camera class name
  52948. * @returns StereoscopicGamepadCamera
  52949. */
  52950. getClassName(): string;
  52951. }
  52952. }
  52953. declare module BABYLON {
  52954. /**
  52955. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  52956. * @see https://doc.babylonjs.com/features/cameras
  52957. */
  52958. export class StereoscopicUniversalCamera extends UniversalCamera {
  52959. /**
  52960. * Creates a new StereoscopicUniversalCamera
  52961. * @param name defines camera name
  52962. * @param position defines initial position
  52963. * @param interaxialDistance defines distance between each color axis
  52964. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  52965. * @param scene defines the hosting scene
  52966. */
  52967. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  52968. /**
  52969. * Gets camera class name
  52970. * @returns StereoscopicUniversalCamera
  52971. */
  52972. getClassName(): string;
  52973. }
  52974. }
  52975. declare module BABYLON {
  52976. /**
  52977. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  52978. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  52979. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  52980. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  52981. */
  52982. export class VirtualJoysticksCamera extends FreeCamera {
  52983. /**
  52984. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  52985. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  52986. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  52987. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  52988. * @param name Define the name of the camera in the scene
  52989. * @param position Define the start position of the camera in the scene
  52990. * @param scene Define the scene the camera belongs to
  52991. */
  52992. constructor(name: string, position: Vector3, scene: Scene);
  52993. /**
  52994. * Gets the current object class name.
  52995. * @return the class name
  52996. */
  52997. getClassName(): string;
  52998. }
  52999. }
  53000. declare module BABYLON {
  53001. /**
  53002. * This represents all the required metrics to create a VR camera.
  53003. * @see https://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  53004. */
  53005. export class VRCameraMetrics {
  53006. /**
  53007. * Define the horizontal resolution off the screen.
  53008. */
  53009. hResolution: number;
  53010. /**
  53011. * Define the vertical resolution off the screen.
  53012. */
  53013. vResolution: number;
  53014. /**
  53015. * Define the horizontal screen size.
  53016. */
  53017. hScreenSize: number;
  53018. /**
  53019. * Define the vertical screen size.
  53020. */
  53021. vScreenSize: number;
  53022. /**
  53023. * Define the vertical screen center position.
  53024. */
  53025. vScreenCenter: number;
  53026. /**
  53027. * Define the distance of the eyes to the screen.
  53028. */
  53029. eyeToScreenDistance: number;
  53030. /**
  53031. * Define the distance between both lenses
  53032. */
  53033. lensSeparationDistance: number;
  53034. /**
  53035. * Define the distance between both viewer's eyes.
  53036. */
  53037. interpupillaryDistance: number;
  53038. /**
  53039. * Define the distortion factor of the VR postprocess.
  53040. * Please, touch with care.
  53041. */
  53042. distortionK: number[];
  53043. /**
  53044. * Define the chromatic aberration correction factors for the VR post process.
  53045. */
  53046. chromaAbCorrection: number[];
  53047. /**
  53048. * Define the scale factor of the post process.
  53049. * The smaller the better but the slower.
  53050. */
  53051. postProcessScaleFactor: number;
  53052. /**
  53053. * Define an offset for the lens center.
  53054. */
  53055. lensCenterOffset: number;
  53056. /**
  53057. * Define if the current vr camera should compensate the distortion of the lense or not.
  53058. */
  53059. compensateDistortion: boolean;
  53060. /**
  53061. * Defines if multiview should be enabled when rendering (Default: false)
  53062. */
  53063. multiviewEnabled: boolean;
  53064. /**
  53065. * Gets the rendering aspect ratio based on the provided resolutions.
  53066. */
  53067. get aspectRatio(): number;
  53068. /**
  53069. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  53070. */
  53071. get aspectRatioFov(): number;
  53072. /**
  53073. * @hidden
  53074. */
  53075. get leftHMatrix(): Matrix;
  53076. /**
  53077. * @hidden
  53078. */
  53079. get rightHMatrix(): Matrix;
  53080. /**
  53081. * @hidden
  53082. */
  53083. get leftPreViewMatrix(): Matrix;
  53084. /**
  53085. * @hidden
  53086. */
  53087. get rightPreViewMatrix(): Matrix;
  53088. /**
  53089. * Get the default VRMetrics based on the most generic setup.
  53090. * @returns the default vr metrics
  53091. */
  53092. static GetDefault(): VRCameraMetrics;
  53093. }
  53094. }
  53095. declare module BABYLON {
  53096. /** @hidden */
  53097. export var vrDistortionCorrectionPixelShader: {
  53098. name: string;
  53099. shader: string;
  53100. };
  53101. }
  53102. declare module BABYLON {
  53103. /**
  53104. * VRDistortionCorrectionPostProcess used for mobile VR
  53105. */
  53106. export class VRDistortionCorrectionPostProcess extends PostProcess {
  53107. private _isRightEye;
  53108. private _distortionFactors;
  53109. private _postProcessScaleFactor;
  53110. private _lensCenterOffset;
  53111. private _scaleIn;
  53112. private _scaleFactor;
  53113. private _lensCenter;
  53114. /**
  53115. * Gets a string identifying the name of the class
  53116. * @returns "VRDistortionCorrectionPostProcess" string
  53117. */
  53118. getClassName(): string;
  53119. /**
  53120. * Initializes the VRDistortionCorrectionPostProcess
  53121. * @param name The name of the effect.
  53122. * @param camera The camera to apply the render pass to.
  53123. * @param isRightEye If this is for the right eye distortion
  53124. * @param vrMetrics All the required metrics for the VR camera
  53125. */
  53126. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  53127. }
  53128. }
  53129. declare module BABYLON {
  53130. /**
  53131. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  53132. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  53133. */
  53134. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  53135. /**
  53136. * Creates a new VRDeviceOrientationArcRotateCamera
  53137. * @param name defines camera name
  53138. * @param alpha defines the camera rotation along the logitudinal axis
  53139. * @param beta defines the camera rotation along the latitudinal axis
  53140. * @param radius defines the camera distance from its target
  53141. * @param target defines the camera target
  53142. * @param scene defines the scene the camera belongs to
  53143. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  53144. * @param vrCameraMetrics defines the vr metrics associated to the camera
  53145. */
  53146. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  53147. /**
  53148. * Gets camera class name
  53149. * @returns VRDeviceOrientationArcRotateCamera
  53150. */
  53151. getClassName(): string;
  53152. }
  53153. }
  53154. declare module BABYLON {
  53155. /**
  53156. * Camera used to simulate VR rendering (based on FreeCamera)
  53157. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  53158. */
  53159. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  53160. /**
  53161. * Creates a new VRDeviceOrientationFreeCamera
  53162. * @param name defines camera name
  53163. * @param position defines the start position of the camera
  53164. * @param scene defines the scene the camera belongs to
  53165. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  53166. * @param vrCameraMetrics defines the vr metrics associated to the camera
  53167. */
  53168. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  53169. /**
  53170. * Gets camera class name
  53171. * @returns VRDeviceOrientationFreeCamera
  53172. */
  53173. getClassName(): string;
  53174. }
  53175. }
  53176. declare module BABYLON {
  53177. /**
  53178. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  53179. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  53180. */
  53181. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  53182. /**
  53183. * Creates a new VRDeviceOrientationGamepadCamera
  53184. * @param name defines camera name
  53185. * @param position defines the start position of the camera
  53186. * @param scene defines the scene the camera belongs to
  53187. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  53188. * @param vrCameraMetrics defines the vr metrics associated to the camera
  53189. */
  53190. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  53191. /**
  53192. * Gets camera class name
  53193. * @returns VRDeviceOrientationGamepadCamera
  53194. */
  53195. getClassName(): string;
  53196. }
  53197. }
  53198. declare module BABYLON {
  53199. /**
  53200. * A class extending Texture allowing drawing on a texture
  53201. * @see https://doc.babylonjs.com/how_to/dynamictexture
  53202. */
  53203. export class DynamicTexture extends Texture {
  53204. private _generateMipMaps;
  53205. private _canvas;
  53206. private _context;
  53207. /**
  53208. * Creates a DynamicTexture
  53209. * @param name defines the name of the texture
  53210. * @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
  53211. * @param scene defines the scene where you want the texture
  53212. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  53213. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  53214. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  53215. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  53216. */
  53217. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number, invertY?: boolean);
  53218. /**
  53219. * Get the current class name of the texture useful for serialization or dynamic coding.
  53220. * @returns "DynamicTexture"
  53221. */
  53222. getClassName(): string;
  53223. /**
  53224. * Gets the current state of canRescale
  53225. */
  53226. get canRescale(): boolean;
  53227. private _recreate;
  53228. /**
  53229. * Scales the texture
  53230. * @param ratio the scale factor to apply to both width and height
  53231. */
  53232. scale(ratio: number): void;
  53233. /**
  53234. * Resizes the texture
  53235. * @param width the new width
  53236. * @param height the new height
  53237. */
  53238. scaleTo(width: number, height: number): void;
  53239. /**
  53240. * Gets the context of the canvas used by the texture
  53241. * @returns the canvas context of the dynamic texture
  53242. */
  53243. getContext(): CanvasRenderingContext2D;
  53244. /**
  53245. * Clears the texture
  53246. */
  53247. clear(): void;
  53248. /**
  53249. * Updates the texture
  53250. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  53251. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  53252. */
  53253. update(invertY?: boolean, premulAlpha?: boolean): void;
  53254. /**
  53255. * Draws text onto the texture
  53256. * @param text defines the text to be drawn
  53257. * @param x defines the placement of the text from the left
  53258. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  53259. * @param font defines the font to be used with font-style, font-size, font-name
  53260. * @param color defines the color used for the text
  53261. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  53262. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  53263. * @param update defines whether texture is immediately update (default is true)
  53264. */
  53265. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  53266. /**
  53267. * Clones the texture
  53268. * @returns the clone of the texture.
  53269. */
  53270. clone(): DynamicTexture;
  53271. /**
  53272. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  53273. * @returns a serialized dynamic texture object
  53274. */
  53275. serialize(): any;
  53276. private _IsCanvasElement;
  53277. /** @hidden */
  53278. _rebuild(): void;
  53279. }
  53280. }
  53281. declare module BABYLON {
  53282. /**
  53283. * Class containing static functions to help procedurally build meshes
  53284. */
  53285. export class GroundBuilder {
  53286. /**
  53287. * Creates a ground mesh
  53288. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  53289. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  53290. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53291. * @param name defines the name of the mesh
  53292. * @param options defines the options used to create the mesh
  53293. * @param scene defines the hosting scene
  53294. * @returns the ground mesh
  53295. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  53296. */
  53297. static CreateGround(name: string, options: {
  53298. width?: number;
  53299. height?: number;
  53300. subdivisions?: number;
  53301. subdivisionsX?: number;
  53302. subdivisionsY?: number;
  53303. updatable?: boolean;
  53304. }, scene: any): Mesh;
  53305. /**
  53306. * Creates a tiled ground mesh
  53307. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  53308. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  53309. * * 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
  53310. * * 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
  53311. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53312. * @param name defines the name of the mesh
  53313. * @param options defines the options used to create the mesh
  53314. * @param scene defines the hosting scene
  53315. * @returns the tiled ground mesh
  53316. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  53317. */
  53318. static CreateTiledGround(name: string, options: {
  53319. xmin: number;
  53320. zmin: number;
  53321. xmax: number;
  53322. zmax: number;
  53323. subdivisions?: {
  53324. w: number;
  53325. h: number;
  53326. };
  53327. precision?: {
  53328. w: number;
  53329. h: number;
  53330. };
  53331. updatable?: boolean;
  53332. }, scene?: Nullable<Scene>): Mesh;
  53333. /**
  53334. * Creates a ground mesh from a height map
  53335. * * The parameter `url` sets the URL of the height map image resource.
  53336. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  53337. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  53338. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  53339. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  53340. * * 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.
  53341. * * 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).
  53342. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  53343. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53344. * @param name defines the name of the mesh
  53345. * @param url defines the url to the height map
  53346. * @param options defines the options used to create the mesh
  53347. * @param scene defines the hosting scene
  53348. * @returns the ground mesh
  53349. * @see https://doc.babylonjs.com/babylon101/height_map
  53350. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  53351. */
  53352. static CreateGroundFromHeightMap(name: string, url: string, options: {
  53353. width?: number;
  53354. height?: number;
  53355. subdivisions?: number;
  53356. minHeight?: number;
  53357. maxHeight?: number;
  53358. colorFilter?: Color3;
  53359. alphaFilter?: number;
  53360. updatable?: boolean;
  53361. onReady?: (mesh: GroundMesh) => void;
  53362. }, scene?: Nullable<Scene>): GroundMesh;
  53363. }
  53364. }
  53365. declare module BABYLON {
  53366. /**
  53367. * Class containing static functions to help procedurally build meshes
  53368. */
  53369. export class TorusBuilder {
  53370. /**
  53371. * Creates a torus mesh
  53372. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  53373. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  53374. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  53375. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53376. * * 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
  53377. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53378. * @param name defines the name of the mesh
  53379. * @param options defines the options used to create the mesh
  53380. * @param scene defines the hosting scene
  53381. * @returns the torus mesh
  53382. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  53383. */
  53384. static CreateTorus(name: string, options: {
  53385. diameter?: number;
  53386. thickness?: number;
  53387. tessellation?: number;
  53388. updatable?: boolean;
  53389. sideOrientation?: number;
  53390. frontUVs?: Vector4;
  53391. backUVs?: Vector4;
  53392. }, scene: any): Mesh;
  53393. }
  53394. }
  53395. declare module BABYLON {
  53396. /**
  53397. * Class containing static functions to help procedurally build meshes
  53398. */
  53399. export class CylinderBuilder {
  53400. /**
  53401. * Creates a cylinder or a cone mesh
  53402. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  53403. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  53404. * * 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.
  53405. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  53406. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  53407. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  53408. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  53409. * * 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).
  53410. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  53411. * * 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).
  53412. * * 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
  53413. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  53414. * * 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
  53415. * * 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.
  53416. * * If `enclose` is false, a ring surface is one element.
  53417. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  53418. * * 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
  53419. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53420. * * 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
  53421. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53422. * @param name defines the name of the mesh
  53423. * @param options defines the options used to create the mesh
  53424. * @param scene defines the hosting scene
  53425. * @returns the cylinder mesh
  53426. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  53427. */
  53428. static CreateCylinder(name: string, options: {
  53429. height?: number;
  53430. diameterTop?: number;
  53431. diameterBottom?: number;
  53432. diameter?: number;
  53433. tessellation?: number;
  53434. subdivisions?: number;
  53435. arc?: number;
  53436. faceColors?: Color4[];
  53437. faceUV?: Vector4[];
  53438. updatable?: boolean;
  53439. hasRings?: boolean;
  53440. enclose?: boolean;
  53441. cap?: number;
  53442. sideOrientation?: number;
  53443. frontUVs?: Vector4;
  53444. backUVs?: Vector4;
  53445. }, scene: any): Mesh;
  53446. }
  53447. }
  53448. declare module BABYLON {
  53449. /**
  53450. * States of the webXR experience
  53451. */
  53452. export enum WebXRState {
  53453. /**
  53454. * Transitioning to being in XR mode
  53455. */
  53456. ENTERING_XR = 0,
  53457. /**
  53458. * Transitioning to non XR mode
  53459. */
  53460. EXITING_XR = 1,
  53461. /**
  53462. * In XR mode and presenting
  53463. */
  53464. IN_XR = 2,
  53465. /**
  53466. * Not entered XR mode
  53467. */
  53468. NOT_IN_XR = 3
  53469. }
  53470. /**
  53471. * The state of the XR camera's tracking
  53472. */
  53473. export enum WebXRTrackingState {
  53474. /**
  53475. * No transformation received, device is not being tracked
  53476. */
  53477. NOT_TRACKING = 0,
  53478. /**
  53479. * Tracking lost - using emulated position
  53480. */
  53481. TRACKING_LOST = 1,
  53482. /**
  53483. * Transformation tracking works normally
  53484. */
  53485. TRACKING = 2
  53486. }
  53487. /**
  53488. * Abstraction of the XR render target
  53489. */
  53490. export interface WebXRRenderTarget extends IDisposable {
  53491. /**
  53492. * xrpresent context of the canvas which can be used to display/mirror xr content
  53493. */
  53494. canvasContext: WebGLRenderingContext;
  53495. /**
  53496. * xr layer for the canvas
  53497. */
  53498. xrLayer: Nullable<XRWebGLLayer>;
  53499. /**
  53500. * Initializes the xr layer for the session
  53501. * @param xrSession xr session
  53502. * @returns a promise that will resolve once the XR Layer has been created
  53503. */
  53504. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  53505. }
  53506. }
  53507. declare module BABYLON {
  53508. /**
  53509. * COnfiguration object for WebXR output canvas
  53510. */
  53511. export class WebXRManagedOutputCanvasOptions {
  53512. /**
  53513. * An optional canvas in case you wish to create it yourself and provide it here.
  53514. * If not provided, a new canvas will be created
  53515. */
  53516. canvasElement?: HTMLCanvasElement;
  53517. /**
  53518. * Options for this XR Layer output
  53519. */
  53520. canvasOptions?: XRWebGLLayerInit;
  53521. /**
  53522. * CSS styling for a newly created canvas (if not provided)
  53523. */
  53524. newCanvasCssStyle?: string;
  53525. /**
  53526. * Get the default values of the configuration object
  53527. * @param engine defines the engine to use (can be null)
  53528. * @returns default values of this configuration object
  53529. */
  53530. static GetDefaults(engine?: ThinEngine): WebXRManagedOutputCanvasOptions;
  53531. }
  53532. /**
  53533. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  53534. */
  53535. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  53536. private _options;
  53537. private _canvas;
  53538. private _engine;
  53539. private _originalCanvasSize;
  53540. /**
  53541. * Rendering context of the canvas which can be used to display/mirror xr content
  53542. */
  53543. canvasContext: WebGLRenderingContext;
  53544. /**
  53545. * xr layer for the canvas
  53546. */
  53547. xrLayer: Nullable<XRWebGLLayer>;
  53548. /**
  53549. * Obseervers registered here will be triggered when the xr layer was initialized
  53550. */
  53551. onXRLayerInitObservable: Observable<XRWebGLLayer>;
  53552. /**
  53553. * Initializes the canvas to be added/removed upon entering/exiting xr
  53554. * @param _xrSessionManager The XR Session manager
  53555. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  53556. */
  53557. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  53558. /**
  53559. * Disposes of the object
  53560. */
  53561. dispose(): void;
  53562. /**
  53563. * Initializes the xr layer for the session
  53564. * @param xrSession xr session
  53565. * @returns a promise that will resolve once the XR Layer has been created
  53566. */
  53567. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  53568. private _addCanvas;
  53569. private _removeCanvas;
  53570. private _setCanvasSize;
  53571. private _setManagedOutputCanvas;
  53572. }
  53573. }
  53574. declare module BABYLON {
  53575. /**
  53576. * Manages an XRSession to work with Babylon's engine
  53577. * @see https://doc.babylonjs.com/how_to/webxr_session_manager
  53578. */
  53579. export class WebXRSessionManager implements IDisposable {
  53580. /** The scene which the session should be created for */
  53581. scene: Scene;
  53582. private _referenceSpace;
  53583. private _rttProvider;
  53584. private _sessionEnded;
  53585. private _xrNavigator;
  53586. private baseLayer;
  53587. /**
  53588. * The base reference space from which the session started. good if you want to reset your
  53589. * reference space
  53590. */
  53591. baseReferenceSpace: XRReferenceSpace;
  53592. /**
  53593. * Current XR frame
  53594. */
  53595. currentFrame: Nullable<XRFrame>;
  53596. /** WebXR timestamp updated every frame */
  53597. currentTimestamp: number;
  53598. /**
  53599. * Used just in case of a failure to initialize an immersive session.
  53600. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  53601. */
  53602. defaultHeightCompensation: number;
  53603. /**
  53604. * Fires every time a new xrFrame arrives which can be used to update the camera
  53605. */
  53606. onXRFrameObservable: Observable<XRFrame>;
  53607. /**
  53608. * Fires when the reference space changed
  53609. */
  53610. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  53611. /**
  53612. * Fires when the xr session is ended either by the device or manually done
  53613. */
  53614. onXRSessionEnded: Observable<any>;
  53615. /**
  53616. * Fires when the xr session is ended either by the device or manually done
  53617. */
  53618. onXRSessionInit: Observable<XRSession>;
  53619. /**
  53620. * Underlying xr session
  53621. */
  53622. session: XRSession;
  53623. /**
  53624. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  53625. * or get the offset the player is currently at.
  53626. */
  53627. viewerReferenceSpace: XRReferenceSpace;
  53628. /**
  53629. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  53630. * @param scene The scene which the session should be created for
  53631. */
  53632. constructor(
  53633. /** The scene which the session should be created for */
  53634. scene: Scene);
  53635. /**
  53636. * The current reference space used in this session. This reference space can constantly change!
  53637. * It is mainly used to offset the camera's position.
  53638. */
  53639. get referenceSpace(): XRReferenceSpace;
  53640. /**
  53641. * Set a new reference space and triggers the observable
  53642. */
  53643. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  53644. /**
  53645. * Disposes of the session manager
  53646. */
  53647. dispose(): void;
  53648. /**
  53649. * Stops the xrSession and restores the render loop
  53650. * @returns Promise which resolves after it exits XR
  53651. */
  53652. exitXRAsync(): Promise<void>;
  53653. /**
  53654. * Gets the correct render target texture to be rendered this frame for this eye
  53655. * @param eye the eye for which to get the render target
  53656. * @returns the render target for the specified eye
  53657. */
  53658. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  53659. /**
  53660. * Creates a WebXRRenderTarget object for the XR session
  53661. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  53662. * @param options optional options to provide when creating a new render target
  53663. * @returns a WebXR render target to which the session can render
  53664. */
  53665. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  53666. /**
  53667. * Initializes the manager
  53668. * After initialization enterXR can be called to start an XR session
  53669. * @returns Promise which resolves after it is initialized
  53670. */
  53671. initializeAsync(): Promise<void>;
  53672. /**
  53673. * Initializes an xr session
  53674. * @param xrSessionMode mode to initialize
  53675. * @param xrSessionInit defines optional and required values to pass to the session builder
  53676. * @returns a promise which will resolve once the session has been initialized
  53677. */
  53678. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  53679. /**
  53680. * Checks if a session would be supported for the creation options specified
  53681. * @param sessionMode session mode to check if supported eg. immersive-vr
  53682. * @returns A Promise that resolves to true if supported and false if not
  53683. */
  53684. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  53685. /**
  53686. * Resets the reference space to the one started the session
  53687. */
  53688. resetReferenceSpace(): void;
  53689. /**
  53690. * Starts rendering to the xr layer
  53691. */
  53692. runXRRenderLoop(): void;
  53693. /**
  53694. * Sets the reference space on the xr session
  53695. * @param referenceSpaceType space to set
  53696. * @returns a promise that will resolve once the reference space has been set
  53697. */
  53698. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  53699. /**
  53700. * Updates the render state of the session
  53701. * @param state state to set
  53702. * @returns a promise that resolves once the render state has been updated
  53703. */
  53704. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  53705. /**
  53706. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  53707. * @param sessionMode defines the session to test
  53708. * @returns a promise with boolean as final value
  53709. */
  53710. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  53711. /**
  53712. * Returns true if Babylon.js is using the BabylonNative backend, otherwise false
  53713. */
  53714. get isNative(): boolean;
  53715. private _createRenderTargetTexture;
  53716. }
  53717. }
  53718. declare module BABYLON {
  53719. /**
  53720. * WebXR Camera which holds the views for the xrSession
  53721. * @see https://doc.babylonjs.com/how_to/webxr_camera
  53722. */
  53723. export class WebXRCamera extends FreeCamera {
  53724. private _xrSessionManager;
  53725. private _firstFrame;
  53726. private _referenceQuaternion;
  53727. private _referencedPosition;
  53728. private _xrInvPositionCache;
  53729. private _xrInvQuaternionCache;
  53730. private _trackingState;
  53731. /**
  53732. * Observable raised before camera teleportation
  53733. */
  53734. onBeforeCameraTeleport: Observable<Vector3>;
  53735. /**
  53736. * Observable raised after camera teleportation
  53737. */
  53738. onAfterCameraTeleport: Observable<Vector3>;
  53739. /**
  53740. * Notifies when the camera's tracking state has changed.
  53741. * Notice - will also be triggered when tracking has started (at the beginning of the session)
  53742. */
  53743. onTrackingStateChanged: Observable<WebXRTrackingState>;
  53744. /**
  53745. * Should position compensation execute on first frame.
  53746. * This is used when copying the position from a native (non XR) camera
  53747. */
  53748. compensateOnFirstFrame: boolean;
  53749. /**
  53750. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  53751. * @param name the name of the camera
  53752. * @param scene the scene to add the camera to
  53753. * @param _xrSessionManager a constructed xr session manager
  53754. */
  53755. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  53756. /**
  53757. * Get the current XR tracking state of the camera
  53758. */
  53759. get trackingState(): WebXRTrackingState;
  53760. private _setTrackingState;
  53761. /**
  53762. * Return the user's height, unrelated to the current ground.
  53763. * This will be the y position of this camera, when ground level is 0.
  53764. */
  53765. get realWorldHeight(): number;
  53766. /** @hidden */
  53767. _updateForDualEyeDebugging(): void;
  53768. /**
  53769. * Sets this camera's transformation based on a non-vr camera
  53770. * @param otherCamera the non-vr camera to copy the transformation from
  53771. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  53772. */
  53773. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  53774. /**
  53775. * Gets the current instance class name ("WebXRCamera").
  53776. * @returns the class name
  53777. */
  53778. getClassName(): string;
  53779. private _rotate180;
  53780. private _updateFromXRSession;
  53781. private _updateNumberOfRigCameras;
  53782. private _updateReferenceSpace;
  53783. private _updateReferenceSpaceOffset;
  53784. }
  53785. }
  53786. declare module BABYLON {
  53787. /**
  53788. * Defining the interface required for a (webxr) feature
  53789. */
  53790. export interface IWebXRFeature extends IDisposable {
  53791. /**
  53792. * Is this feature attached
  53793. */
  53794. attached: boolean;
  53795. /**
  53796. * Should auto-attach be disabled?
  53797. */
  53798. disableAutoAttach: boolean;
  53799. /**
  53800. * Attach the feature to the session
  53801. * Will usually be called by the features manager
  53802. *
  53803. * @param force should attachment be forced (even when already attached)
  53804. * @returns true if successful.
  53805. */
  53806. attach(force?: boolean): boolean;
  53807. /**
  53808. * Detach the feature from the session
  53809. * Will usually be called by the features manager
  53810. *
  53811. * @returns true if successful.
  53812. */
  53813. detach(): boolean;
  53814. /**
  53815. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  53816. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  53817. *
  53818. * @returns whether or not the feature is compatible in this environment
  53819. */
  53820. isCompatible(): boolean;
  53821. /**
  53822. * Was this feature disposed;
  53823. */
  53824. isDisposed: boolean;
  53825. /**
  53826. * The name of the native xr feature name, if applicable (like anchor, hit-test, or hand-tracking)
  53827. */
  53828. xrNativeFeatureName?: string;
  53829. /**
  53830. * A list of (Babylon WebXR) features this feature depends on
  53831. */
  53832. dependsOn?: string[];
  53833. /**
  53834. * If this feature requires to extend the XRSessionInit object, this function will return the partial XR session init object
  53835. */
  53836. getXRSessionInitExtension?: () => Promise<Partial<XRSessionInit>>;
  53837. }
  53838. /**
  53839. * A list of the currently available features without referencing them
  53840. */
  53841. export class WebXRFeatureName {
  53842. /**
  53843. * The name of the anchor system feature
  53844. */
  53845. static readonly ANCHOR_SYSTEM: string;
  53846. /**
  53847. * The name of the background remover feature
  53848. */
  53849. static readonly BACKGROUND_REMOVER: string;
  53850. /**
  53851. * The name of the hit test feature
  53852. */
  53853. static readonly HIT_TEST: string;
  53854. /**
  53855. * The name of the mesh detection feature
  53856. */
  53857. static readonly MESH_DETECTION: string;
  53858. /**
  53859. * physics impostors for xr controllers feature
  53860. */
  53861. static readonly PHYSICS_CONTROLLERS: string;
  53862. /**
  53863. * The name of the plane detection feature
  53864. */
  53865. static readonly PLANE_DETECTION: string;
  53866. /**
  53867. * The name of the pointer selection feature
  53868. */
  53869. static readonly POINTER_SELECTION: string;
  53870. /**
  53871. * The name of the teleportation feature
  53872. */
  53873. static readonly TELEPORTATION: string;
  53874. /**
  53875. * The name of the feature points feature.
  53876. */
  53877. static readonly FEATURE_POINTS: string;
  53878. /**
  53879. * The name of the hand tracking feature.
  53880. */
  53881. static readonly HAND_TRACKING: string;
  53882. /**
  53883. * The name of the image tracking feature
  53884. */
  53885. static readonly IMAGE_TRACKING: string;
  53886. }
  53887. /**
  53888. * Defining the constructor of a feature. Used to register the modules.
  53889. */
  53890. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => () => IWebXRFeature;
  53891. /**
  53892. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  53893. * It is mainly used in AR sessions.
  53894. *
  53895. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  53896. */
  53897. export class WebXRFeaturesManager implements IDisposable {
  53898. private _xrSessionManager;
  53899. private static readonly _AvailableFeatures;
  53900. private _features;
  53901. /**
  53902. * constructs a new features manages.
  53903. *
  53904. * @param _xrSessionManager an instance of WebXRSessionManager
  53905. */
  53906. constructor(_xrSessionManager: WebXRSessionManager);
  53907. /**
  53908. * Used to register a module. After calling this function a developer can use this feature in the scene.
  53909. * Mainly used internally.
  53910. *
  53911. * @param featureName the name of the feature to register
  53912. * @param constructorFunction the function used to construct the module
  53913. * @param version the (babylon) version of the module
  53914. * @param stable is that a stable version of this module
  53915. */
  53916. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  53917. /**
  53918. * Returns a constructor of a specific feature.
  53919. *
  53920. * @param featureName the name of the feature to construct
  53921. * @param version the version of the feature to load
  53922. * @param xrSessionManager the xrSessionManager. Used to construct the module
  53923. * @param options optional options provided to the module.
  53924. * @returns a function that, when called, will return a new instance of this feature
  53925. */
  53926. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): () => IWebXRFeature;
  53927. /**
  53928. * Can be used to return the list of features currently registered
  53929. *
  53930. * @returns an Array of available features
  53931. */
  53932. static GetAvailableFeatures(): string[];
  53933. /**
  53934. * Gets the versions available for a specific feature
  53935. * @param featureName the name of the feature
  53936. * @returns an array with the available versions
  53937. */
  53938. static GetAvailableVersions(featureName: string): string[];
  53939. /**
  53940. * Return the latest unstable version of this feature
  53941. * @param featureName the name of the feature to search
  53942. * @returns the version number. if not found will return -1
  53943. */
  53944. static GetLatestVersionOfFeature(featureName: string): number;
  53945. /**
  53946. * Return the latest stable version of this feature
  53947. * @param featureName the name of the feature to search
  53948. * @returns the version number. if not found will return -1
  53949. */
  53950. static GetStableVersionOfFeature(featureName: string): number;
  53951. /**
  53952. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  53953. * Can be used during a session to start a feature
  53954. * @param featureName the name of feature to attach
  53955. */
  53956. attachFeature(featureName: string): void;
  53957. /**
  53958. * Can be used inside a session or when the session ends to detach a specific feature
  53959. * @param featureName the name of the feature to detach
  53960. */
  53961. detachFeature(featureName: string): void;
  53962. /**
  53963. * Used to disable an already-enabled feature
  53964. * The feature will be disposed and will be recreated once enabled.
  53965. * @param featureName the feature to disable
  53966. * @returns true if disable was successful
  53967. */
  53968. disableFeature(featureName: string | {
  53969. Name: string;
  53970. }): boolean;
  53971. /**
  53972. * dispose this features manager
  53973. */
  53974. dispose(): void;
  53975. /**
  53976. * 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.
  53977. * 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.
  53978. *
  53979. * @param featureName the name of the feature to load or the class of the feature
  53980. * @param version optional version to load. if not provided the latest version will be enabled
  53981. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  53982. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  53983. * @param required is this feature required to the app. If set to true the session init will fail if the feature is not available.
  53984. * @returns a new constructed feature or throws an error if feature not found.
  53985. */
  53986. enableFeature(featureName: string | {
  53987. Name: string;
  53988. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean, required?: boolean): IWebXRFeature;
  53989. /**
  53990. * get the implementation of an enabled feature.
  53991. * @param featureName the name of the feature to load
  53992. * @returns the feature class, if found
  53993. */
  53994. getEnabledFeature(featureName: string): IWebXRFeature;
  53995. /**
  53996. * Get the list of enabled features
  53997. * @returns an array of enabled features
  53998. */
  53999. getEnabledFeatures(): string[];
  54000. /**
  54001. * This function will extend the session creation configuration object with enabled features.
  54002. * If, for example, the anchors feature is enabled, it will be automatically added to the optional or required features list,
  54003. * according to the defined "required" variable, provided during enableFeature call
  54004. * @param xrSessionInit the xr Session init object to extend
  54005. *
  54006. * @returns an extended XRSessionInit object
  54007. */
  54008. _extendXRSessionInitObject(xrSessionInit: XRSessionInit): Promise<XRSessionInit>;
  54009. }
  54010. }
  54011. declare module BABYLON {
  54012. /**
  54013. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  54014. * @see https://doc.babylonjs.com/how_to/webxr_experience_helpers
  54015. */
  54016. export class WebXRExperienceHelper implements IDisposable {
  54017. private scene;
  54018. private _nonVRCamera;
  54019. private _originalSceneAutoClear;
  54020. private _supported;
  54021. /**
  54022. * Camera used to render xr content
  54023. */
  54024. camera: WebXRCamera;
  54025. /** A features manager for this xr session */
  54026. featuresManager: WebXRFeaturesManager;
  54027. /**
  54028. * Observers registered here will be triggered after the camera's initial transformation is set
  54029. * This can be used to set a different ground level or an extra rotation.
  54030. *
  54031. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  54032. * to the position set after this observable is done executing.
  54033. */
  54034. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  54035. /**
  54036. * Fires when the state of the experience helper has changed
  54037. */
  54038. onStateChangedObservable: Observable<WebXRState>;
  54039. /** Session manager used to keep track of xr session */
  54040. sessionManager: WebXRSessionManager;
  54041. /**
  54042. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  54043. */
  54044. state: WebXRState;
  54045. /**
  54046. * Creates a WebXRExperienceHelper
  54047. * @param scene The scene the helper should be created in
  54048. */
  54049. private constructor();
  54050. /**
  54051. * Creates the experience helper
  54052. * @param scene the scene to attach the experience helper to
  54053. * @returns a promise for the experience helper
  54054. */
  54055. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  54056. /**
  54057. * Disposes of the experience helper
  54058. */
  54059. dispose(): void;
  54060. /**
  54061. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  54062. * @param sessionMode options for the XR session
  54063. * @param referenceSpaceType frame of reference of the XR session
  54064. * @param renderTarget the output canvas that will be used to enter XR mode
  54065. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  54066. * @returns promise that resolves after xr mode has entered
  54067. */
  54068. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  54069. /**
  54070. * Exits XR mode and returns the scene to its original state
  54071. * @returns promise that resolves after xr mode has exited
  54072. */
  54073. exitXRAsync(): Promise<void>;
  54074. private _nonXRToXRCamera;
  54075. private _setState;
  54076. }
  54077. }
  54078. declare module BABYLON {
  54079. /**
  54080. * X-Y values for axes in WebXR
  54081. */
  54082. export interface IWebXRMotionControllerAxesValue {
  54083. /**
  54084. * The value of the x axis
  54085. */
  54086. x: number;
  54087. /**
  54088. * The value of the y-axis
  54089. */
  54090. y: number;
  54091. }
  54092. /**
  54093. * changed / previous values for the values of this component
  54094. */
  54095. export interface IWebXRMotionControllerComponentChangesValues<T> {
  54096. /**
  54097. * current (this frame) value
  54098. */
  54099. current: T;
  54100. /**
  54101. * previous (last change) value
  54102. */
  54103. previous: T;
  54104. }
  54105. /**
  54106. * Represents changes in the component between current frame and last values recorded
  54107. */
  54108. export interface IWebXRMotionControllerComponentChanges {
  54109. /**
  54110. * will be populated with previous and current values if axes changed
  54111. */
  54112. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  54113. /**
  54114. * will be populated with previous and current values if pressed changed
  54115. */
  54116. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  54117. /**
  54118. * will be populated with previous and current values if touched changed
  54119. */
  54120. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  54121. /**
  54122. * will be populated with previous and current values if value changed
  54123. */
  54124. value?: IWebXRMotionControllerComponentChangesValues<number>;
  54125. }
  54126. /**
  54127. * This class represents a single component (for example button or thumbstick) of a motion controller
  54128. */
  54129. export class WebXRControllerComponent implements IDisposable {
  54130. /**
  54131. * the id of this component
  54132. */
  54133. id: string;
  54134. /**
  54135. * the type of the component
  54136. */
  54137. type: MotionControllerComponentType;
  54138. private _buttonIndex;
  54139. private _axesIndices;
  54140. private _axes;
  54141. private _changes;
  54142. private _currentValue;
  54143. private _hasChanges;
  54144. private _pressed;
  54145. private _touched;
  54146. /**
  54147. * button component type
  54148. */
  54149. static BUTTON_TYPE: MotionControllerComponentType;
  54150. /**
  54151. * squeeze component type
  54152. */
  54153. static SQUEEZE_TYPE: MotionControllerComponentType;
  54154. /**
  54155. * Thumbstick component type
  54156. */
  54157. static THUMBSTICK_TYPE: MotionControllerComponentType;
  54158. /**
  54159. * Touchpad component type
  54160. */
  54161. static TOUCHPAD_TYPE: MotionControllerComponentType;
  54162. /**
  54163. * trigger component type
  54164. */
  54165. static TRIGGER_TYPE: MotionControllerComponentType;
  54166. /**
  54167. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  54168. * the axes data changes
  54169. */
  54170. onAxisValueChangedObservable: Observable<{
  54171. x: number;
  54172. y: number;
  54173. }>;
  54174. /**
  54175. * Observers registered here will be triggered when the state of a button changes
  54176. * State change is either pressed / touched / value
  54177. */
  54178. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  54179. /**
  54180. * Creates a new component for a motion controller.
  54181. * It is created by the motion controller itself
  54182. *
  54183. * @param id the id of this component
  54184. * @param type the type of the component
  54185. * @param _buttonIndex index in the buttons array of the gamepad
  54186. * @param _axesIndices indices of the values in the axes array of the gamepad
  54187. */
  54188. constructor(
  54189. /**
  54190. * the id of this component
  54191. */
  54192. id: string,
  54193. /**
  54194. * the type of the component
  54195. */
  54196. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  54197. /**
  54198. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  54199. */
  54200. get axes(): IWebXRMotionControllerAxesValue;
  54201. /**
  54202. * Get the changes. Elements will be populated only if they changed with their previous and current value
  54203. */
  54204. get changes(): IWebXRMotionControllerComponentChanges;
  54205. /**
  54206. * Return whether or not the component changed the last frame
  54207. */
  54208. get hasChanges(): boolean;
  54209. /**
  54210. * is the button currently pressed
  54211. */
  54212. get pressed(): boolean;
  54213. /**
  54214. * is the button currently touched
  54215. */
  54216. get touched(): boolean;
  54217. /**
  54218. * Get the current value of this component
  54219. */
  54220. get value(): number;
  54221. /**
  54222. * Dispose this component
  54223. */
  54224. dispose(): void;
  54225. /**
  54226. * Are there axes correlating to this component
  54227. * @return true is axes data is available
  54228. */
  54229. isAxes(): boolean;
  54230. /**
  54231. * Is this component a button (hence - pressable)
  54232. * @returns true if can be pressed
  54233. */
  54234. isButton(): boolean;
  54235. /**
  54236. * update this component using the gamepad object it is in. Called on every frame
  54237. * @param nativeController the native gamepad controller object
  54238. */
  54239. update(nativeController: IMinimalMotionControllerObject): void;
  54240. }
  54241. }
  54242. declare module BABYLON {
  54243. /**
  54244. * Type used for the success callback of ImportMesh
  54245. */
  54246. export type SceneLoaderSuccessCallback = (meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], animationGroups: AnimationGroup[], transformNodes: TransformNode[], geometries: Geometry[], lights: Light[]) => void;
  54247. /**
  54248. * Interface used for the result of ImportMeshAsync
  54249. */
  54250. export interface ISceneLoaderAsyncResult {
  54251. /**
  54252. * The array of loaded meshes
  54253. */
  54254. readonly meshes: AbstractMesh[];
  54255. /**
  54256. * The array of loaded particle systems
  54257. */
  54258. readonly particleSystems: IParticleSystem[];
  54259. /**
  54260. * The array of loaded skeletons
  54261. */
  54262. readonly skeletons: Skeleton[];
  54263. /**
  54264. * The array of loaded animation groups
  54265. */
  54266. readonly animationGroups: AnimationGroup[];
  54267. /**
  54268. * The array of loaded transform nodes
  54269. */
  54270. readonly transformNodes: TransformNode[];
  54271. /**
  54272. * The array of loaded geometries
  54273. */
  54274. readonly geometries: Geometry[];
  54275. /**
  54276. * The array of loaded lights
  54277. */
  54278. readonly lights: Light[];
  54279. }
  54280. /**
  54281. * Interface used to represent data loading progression
  54282. */
  54283. export interface ISceneLoaderProgressEvent {
  54284. /**
  54285. * Defines if data length to load can be evaluated
  54286. */
  54287. readonly lengthComputable: boolean;
  54288. /**
  54289. * Defines the loaded data length
  54290. */
  54291. readonly loaded: number;
  54292. /**
  54293. * Defines the data length to load
  54294. */
  54295. readonly total: number;
  54296. }
  54297. /**
  54298. * Interface used by SceneLoader plugins to define supported file extensions
  54299. */
  54300. export interface ISceneLoaderPluginExtensions {
  54301. /**
  54302. * Defines the list of supported extensions
  54303. */
  54304. [extension: string]: {
  54305. isBinary: boolean;
  54306. };
  54307. }
  54308. /**
  54309. * Interface used by SceneLoader plugin factory
  54310. */
  54311. export interface ISceneLoaderPluginFactory {
  54312. /**
  54313. * Defines the name of the factory
  54314. */
  54315. name: string;
  54316. /**
  54317. * Function called to create a new plugin
  54318. * @return the new plugin
  54319. */
  54320. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  54321. /**
  54322. * The callback that returns true if the data can be directly loaded.
  54323. * @param data string containing the file data
  54324. * @returns if the data can be loaded directly
  54325. */
  54326. canDirectLoad?(data: string): boolean;
  54327. }
  54328. /**
  54329. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  54330. */
  54331. export interface ISceneLoaderPluginBase {
  54332. /**
  54333. * The friendly name of this plugin.
  54334. */
  54335. name: string;
  54336. /**
  54337. * The file extensions supported by this plugin.
  54338. */
  54339. extensions: string | ISceneLoaderPluginExtensions;
  54340. /**
  54341. * The callback called when loading from a url.
  54342. * @param scene scene loading this url
  54343. * @param url url to load
  54344. * @param onSuccess callback called when the file successfully loads
  54345. * @param onProgress callback called while file is loading (if the server supports this mode)
  54346. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  54347. * @param onError callback called when the file fails to load
  54348. * @returns a file request object
  54349. */
  54350. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  54351. /**
  54352. * The callback called when loading from a file object.
  54353. * @param scene scene loading this file
  54354. * @param file defines the file to load
  54355. * @param onSuccess defines the callback to call when data is loaded
  54356. * @param onProgress defines the callback to call during loading process
  54357. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  54358. * @param onError defines the callback to call when an error occurs
  54359. * @returns a file request object
  54360. */
  54361. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  54362. /**
  54363. * The callback that returns true if the data can be directly loaded.
  54364. * @param data string containing the file data
  54365. * @returns if the data can be loaded directly
  54366. */
  54367. canDirectLoad?(data: string): boolean;
  54368. /**
  54369. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  54370. * @param scene scene loading this data
  54371. * @param data string containing the data
  54372. * @returns data to pass to the plugin
  54373. */
  54374. directLoad?(scene: Scene, data: string): any;
  54375. /**
  54376. * The callback that allows custom handling of the root url based on the response url.
  54377. * @param rootUrl the original root url
  54378. * @param responseURL the response url if available
  54379. * @returns the new root url
  54380. */
  54381. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  54382. }
  54383. /**
  54384. * Interface used to define a SceneLoader plugin
  54385. */
  54386. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  54387. /**
  54388. * Import meshes into a scene.
  54389. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  54390. * @param scene The scene to import into
  54391. * @param data The data to import
  54392. * @param rootUrl The root url for scene and resources
  54393. * @param meshes The meshes array to import into
  54394. * @param particleSystems The particle systems array to import into
  54395. * @param skeletons The skeletons array to import into
  54396. * @param onError The callback when import fails
  54397. * @returns True if successful or false otherwise
  54398. */
  54399. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  54400. /**
  54401. * Load into a scene.
  54402. * @param scene The scene to load into
  54403. * @param data The data to import
  54404. * @param rootUrl The root url for scene and resources
  54405. * @param onError The callback when import fails
  54406. * @returns True if successful or false otherwise
  54407. */
  54408. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  54409. /**
  54410. * Load into an asset container.
  54411. * @param scene The scene to load into
  54412. * @param data The data to import
  54413. * @param rootUrl The root url for scene and resources
  54414. * @param onError The callback when import fails
  54415. * @returns The loaded asset container
  54416. */
  54417. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  54418. }
  54419. /**
  54420. * Interface used to define an async SceneLoader plugin
  54421. */
  54422. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  54423. /**
  54424. * Import meshes into a scene.
  54425. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  54426. * @param scene The scene to import into
  54427. * @param data The data to import
  54428. * @param rootUrl The root url for scene and resources
  54429. * @param onProgress The callback when the load progresses
  54430. * @param fileName Defines the name of the file to load
  54431. * @returns The loaded objects (e.g. meshes, particle systems, skeletons, animation groups, etc.)
  54432. */
  54433. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<ISceneLoaderAsyncResult>;
  54434. /**
  54435. * Load into a scene.
  54436. * @param scene The scene to load into
  54437. * @param data The data to import
  54438. * @param rootUrl The root url for scene and resources
  54439. * @param onProgress The callback when the load progresses
  54440. * @param fileName Defines the name of the file to load
  54441. * @returns Nothing
  54442. */
  54443. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  54444. /**
  54445. * Load into an asset container.
  54446. * @param scene The scene to load into
  54447. * @param data The data to import
  54448. * @param rootUrl The root url for scene and resources
  54449. * @param onProgress The callback when the load progresses
  54450. * @param fileName Defines the name of the file to load
  54451. * @returns The loaded asset container
  54452. */
  54453. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  54454. }
  54455. /**
  54456. * Mode that determines how to handle old animation groups before loading new ones.
  54457. */
  54458. export enum SceneLoaderAnimationGroupLoadingMode {
  54459. /**
  54460. * Reset all old animations to initial state then dispose them.
  54461. */
  54462. Clean = 0,
  54463. /**
  54464. * Stop all old animations.
  54465. */
  54466. Stop = 1,
  54467. /**
  54468. * Restart old animations from first frame.
  54469. */
  54470. Sync = 2,
  54471. /**
  54472. * Old animations remains untouched.
  54473. */
  54474. NoSync = 3
  54475. }
  54476. /**
  54477. * Defines a plugin registered by the SceneLoader
  54478. */
  54479. interface IRegisteredPlugin {
  54480. /**
  54481. * Defines the plugin to use
  54482. */
  54483. plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  54484. /**
  54485. * Defines if the plugin supports binary data
  54486. */
  54487. isBinary: boolean;
  54488. }
  54489. /**
  54490. * Class used to load scene from various file formats using registered plugins
  54491. * @see https://doc.babylonjs.com/how_to/load_from_any_file_type
  54492. */
  54493. export class SceneLoader {
  54494. /**
  54495. * No logging while loading
  54496. */
  54497. static readonly NO_LOGGING: number;
  54498. /**
  54499. * Minimal logging while loading
  54500. */
  54501. static readonly MINIMAL_LOGGING: number;
  54502. /**
  54503. * Summary logging while loading
  54504. */
  54505. static readonly SUMMARY_LOGGING: number;
  54506. /**
  54507. * Detailled logging while loading
  54508. */
  54509. static readonly DETAILED_LOGGING: number;
  54510. /**
  54511. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  54512. */
  54513. static get ForceFullSceneLoadingForIncremental(): boolean;
  54514. static set ForceFullSceneLoadingForIncremental(value: boolean);
  54515. /**
  54516. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  54517. */
  54518. static get ShowLoadingScreen(): boolean;
  54519. static set ShowLoadingScreen(value: boolean);
  54520. /**
  54521. * Defines the current logging level (while loading the scene)
  54522. * @ignorenaming
  54523. */
  54524. static get loggingLevel(): number;
  54525. static set loggingLevel(value: number);
  54526. /**
  54527. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  54528. */
  54529. static get CleanBoneMatrixWeights(): boolean;
  54530. static set CleanBoneMatrixWeights(value: boolean);
  54531. /**
  54532. * Event raised when a plugin is used to load a scene
  54533. */
  54534. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  54535. private static _registeredPlugins;
  54536. private static _showingLoadingScreen;
  54537. /**
  54538. * Gets the default plugin (used to load Babylon files)
  54539. * @returns the .babylon plugin
  54540. */
  54541. static GetDefaultPlugin(): IRegisteredPlugin;
  54542. private static _GetPluginForExtension;
  54543. private static _GetPluginForDirectLoad;
  54544. private static _GetPluginForFilename;
  54545. private static _GetDirectLoad;
  54546. private static _LoadData;
  54547. private static _GetFileInfo;
  54548. /**
  54549. * Gets a plugin that can load the given extension
  54550. * @param extension defines the extension to load
  54551. * @returns a plugin or null if none works
  54552. */
  54553. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  54554. /**
  54555. * Gets a boolean indicating that the given extension can be loaded
  54556. * @param extension defines the extension to load
  54557. * @returns true if the extension is supported
  54558. */
  54559. static IsPluginForExtensionAvailable(extension: string): boolean;
  54560. /**
  54561. * Adds a new plugin to the list of registered plugins
  54562. * @param plugin defines the plugin to add
  54563. */
  54564. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  54565. /**
  54566. * Import meshes into a scene
  54567. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  54568. * @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)
  54569. * @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)
  54570. * @param scene the instance of BABYLON.Scene to append to
  54571. * @param onSuccess a callback with a list of imported meshes, particleSystems, skeletons, and animationGroups when import succeeds
  54572. * @param onProgress a callback with a progress event for each file being loaded
  54573. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  54574. * @param pluginExtension the extension used to determine the plugin
  54575. * @returns The loaded plugin
  54576. */
  54577. 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>;
  54578. /**
  54579. * Import meshes into a scene
  54580. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  54581. * @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)
  54582. * @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)
  54583. * @param scene the instance of BABYLON.Scene to append to
  54584. * @param onProgress a callback with a progress event for each file being loaded
  54585. * @param pluginExtension the extension used to determine the plugin
  54586. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  54587. */
  54588. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<ISceneLoaderAsyncResult>;
  54589. /**
  54590. * Load a scene
  54591. * @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)
  54592. * @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)
  54593. * @param engine is the instance of BABYLON.Engine to use to create the scene
  54594. * @param onSuccess a callback with the scene when import succeeds
  54595. * @param onProgress a callback with a progress event for each file being loaded
  54596. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  54597. * @param pluginExtension the extension used to determine the plugin
  54598. * @returns The loaded plugin
  54599. */
  54600. 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>;
  54601. /**
  54602. * Load a scene
  54603. * @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)
  54604. * @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)
  54605. * @param engine is the instance of BABYLON.Engine to use to create the scene
  54606. * @param onProgress a callback with a progress event for each file being loaded
  54607. * @param pluginExtension the extension used to determine the plugin
  54608. * @returns The loaded scene
  54609. */
  54610. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  54611. /**
  54612. * Append a scene
  54613. * @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)
  54614. * @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)
  54615. * @param scene is the instance of BABYLON.Scene to append to
  54616. * @param onSuccess a callback with the scene when import succeeds
  54617. * @param onProgress a callback with a progress event for each file being loaded
  54618. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  54619. * @param pluginExtension the extension used to determine the plugin
  54620. * @returns The loaded plugin
  54621. */
  54622. 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>;
  54623. /**
  54624. * Append a scene
  54625. * @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)
  54626. * @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)
  54627. * @param scene is the instance of BABYLON.Scene to append to
  54628. * @param onProgress a callback with a progress event for each file being loaded
  54629. * @param pluginExtension the extension used to determine the plugin
  54630. * @returns The given scene
  54631. */
  54632. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  54633. /**
  54634. * Load a scene into an asset container
  54635. * @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)
  54636. * @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)
  54637. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  54638. * @param onSuccess a callback with the scene when import succeeds
  54639. * @param onProgress a callback with a progress event for each file being loaded
  54640. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  54641. * @param pluginExtension the extension used to determine the plugin
  54642. * @returns The loaded plugin
  54643. */
  54644. 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>;
  54645. /**
  54646. * Load a scene into an asset container
  54647. * @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)
  54648. * @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)
  54649. * @param scene is the instance of Scene to append to
  54650. * @param onProgress a callback with a progress event for each file being loaded
  54651. * @param pluginExtension the extension used to determine the plugin
  54652. * @returns The loaded asset container
  54653. */
  54654. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  54655. /**
  54656. * Import animations from a file into a scene
  54657. * @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)
  54658. * @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)
  54659. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  54660. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  54661. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  54662. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  54663. * @param onSuccess a callback with the scene when import succeeds
  54664. * @param onProgress a callback with a progress event for each file being loaded
  54665. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  54666. * @param pluginExtension the extension used to determine the plugin
  54667. */
  54668. 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;
  54669. /**
  54670. * Import animations from a file into a scene
  54671. * @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)
  54672. * @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)
  54673. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  54674. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  54675. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  54676. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  54677. * @param onSuccess a callback with the scene when import succeeds
  54678. * @param onProgress a callback with a progress event for each file being loaded
  54679. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  54680. * @param pluginExtension the extension used to determine the plugin
  54681. * @returns the updated scene with imported animations
  54682. */
  54683. 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>;
  54684. }
  54685. }
  54686. declare module BABYLON {
  54687. /**
  54688. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  54689. */
  54690. export type MotionControllerHandedness = "none" | "left" | "right";
  54691. /**
  54692. * The type of components available in motion controllers.
  54693. * This is not the name of the component.
  54694. */
  54695. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  54696. /**
  54697. * The state of a controller component
  54698. */
  54699. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  54700. /**
  54701. * The schema of motion controller layout.
  54702. * No object will be initialized using this interface
  54703. * This is used just to define the profile.
  54704. */
  54705. export interface IMotionControllerLayout {
  54706. /**
  54707. * Path to load the assets. Usually relative to the base path
  54708. */
  54709. assetPath: string;
  54710. /**
  54711. * Available components (unsorted)
  54712. */
  54713. components: {
  54714. /**
  54715. * A map of component Ids
  54716. */
  54717. [componentId: string]: {
  54718. /**
  54719. * The type of input the component outputs
  54720. */
  54721. type: MotionControllerComponentType;
  54722. /**
  54723. * The indices of this component in the gamepad object
  54724. */
  54725. gamepadIndices: {
  54726. /**
  54727. * Index of button
  54728. */
  54729. button?: number;
  54730. /**
  54731. * If available, index of x-axis
  54732. */
  54733. xAxis?: number;
  54734. /**
  54735. * If available, index of y-axis
  54736. */
  54737. yAxis?: number;
  54738. };
  54739. /**
  54740. * The mesh's root node name
  54741. */
  54742. rootNodeName: string;
  54743. /**
  54744. * Animation definitions for this model
  54745. */
  54746. visualResponses: {
  54747. [stateKey: string]: {
  54748. /**
  54749. * What property will be animated
  54750. */
  54751. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  54752. /**
  54753. * What states influence this visual response
  54754. */
  54755. states: MotionControllerComponentStateType[];
  54756. /**
  54757. * Type of animation - movement or visibility
  54758. */
  54759. valueNodeProperty: "transform" | "visibility";
  54760. /**
  54761. * Base node name to move. Its position will be calculated according to the min and max nodes
  54762. */
  54763. valueNodeName?: string;
  54764. /**
  54765. * Minimum movement node
  54766. */
  54767. minNodeName?: string;
  54768. /**
  54769. * Max movement node
  54770. */
  54771. maxNodeName?: string;
  54772. };
  54773. };
  54774. /**
  54775. * If touch enabled, what is the name of node to display user feedback
  54776. */
  54777. touchPointNodeName?: string;
  54778. };
  54779. };
  54780. /**
  54781. * Is it xr standard mapping or not
  54782. */
  54783. gamepadMapping: "" | "xr-standard";
  54784. /**
  54785. * Base root node of this entire model
  54786. */
  54787. rootNodeName: string;
  54788. /**
  54789. * Defines the main button component id
  54790. */
  54791. selectComponentId: string;
  54792. }
  54793. /**
  54794. * A definition for the layout map in the input profile
  54795. */
  54796. export interface IMotionControllerLayoutMap {
  54797. /**
  54798. * Layouts with handedness type as a key
  54799. */
  54800. [handedness: string]: IMotionControllerLayout;
  54801. }
  54802. /**
  54803. * The XR Input profile schema
  54804. * Profiles can be found here:
  54805. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  54806. */
  54807. export interface IMotionControllerProfile {
  54808. /**
  54809. * fallback profiles for this profileId
  54810. */
  54811. fallbackProfileIds: string[];
  54812. /**
  54813. * The layout map, with handedness as key
  54814. */
  54815. layouts: IMotionControllerLayoutMap;
  54816. /**
  54817. * The id of this profile
  54818. * correlates to the profile(s) in the xrInput.profiles array
  54819. */
  54820. profileId: string;
  54821. }
  54822. /**
  54823. * A helper-interface for the 3 meshes needed for controller button animation
  54824. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  54825. */
  54826. export interface IMotionControllerButtonMeshMap {
  54827. /**
  54828. * the mesh that defines the pressed value mesh position.
  54829. * This is used to find the max-position of this button
  54830. */
  54831. pressedMesh: AbstractMesh;
  54832. /**
  54833. * the mesh that defines the unpressed value mesh position.
  54834. * This is used to find the min (or initial) position of this button
  54835. */
  54836. unpressedMesh: AbstractMesh;
  54837. /**
  54838. * The mesh that will be changed when value changes
  54839. */
  54840. valueMesh: AbstractMesh;
  54841. }
  54842. /**
  54843. * A helper-interface for the 3 meshes needed for controller axis animation.
  54844. * This will be expanded when touchpad animations are fully supported
  54845. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  54846. */
  54847. export interface IMotionControllerMeshMap {
  54848. /**
  54849. * the mesh that defines the maximum value mesh position.
  54850. */
  54851. maxMesh?: AbstractMesh;
  54852. /**
  54853. * the mesh that defines the minimum value mesh position.
  54854. */
  54855. minMesh?: AbstractMesh;
  54856. /**
  54857. * The mesh that will be changed when axis value changes
  54858. */
  54859. valueMesh?: AbstractMesh;
  54860. }
  54861. /**
  54862. * The elements needed for change-detection of the gamepad objects in motion controllers
  54863. */
  54864. export interface IMinimalMotionControllerObject {
  54865. /**
  54866. * Available axes of this controller
  54867. */
  54868. axes: number[];
  54869. /**
  54870. * An array of available buttons
  54871. */
  54872. buttons: Array<{
  54873. /**
  54874. * Value of the button/trigger
  54875. */
  54876. value: number;
  54877. /**
  54878. * If the button/trigger is currently touched
  54879. */
  54880. touched: boolean;
  54881. /**
  54882. * If the button/trigger is currently pressed
  54883. */
  54884. pressed: boolean;
  54885. }>;
  54886. /**
  54887. * EXPERIMENTAL haptic support.
  54888. */
  54889. hapticActuators?: Array<{
  54890. pulse: (value: number, duration: number) => Promise<boolean>;
  54891. }>;
  54892. }
  54893. /**
  54894. * An Abstract Motion controller
  54895. * This class receives an xrInput and a profile layout and uses those to initialize the components
  54896. * Each component has an observable to check for changes in value and state
  54897. */
  54898. export abstract class WebXRAbstractMotionController implements IDisposable {
  54899. protected scene: Scene;
  54900. protected layout: IMotionControllerLayout;
  54901. /**
  54902. * The gamepad object correlating to this controller
  54903. */
  54904. gamepadObject: IMinimalMotionControllerObject;
  54905. /**
  54906. * handedness (left/right/none) of this controller
  54907. */
  54908. handedness: MotionControllerHandedness;
  54909. private _initComponent;
  54910. private _modelReady;
  54911. /**
  54912. * A map of components (WebXRControllerComponent) in this motion controller
  54913. * Components have a ComponentType and can also have both button and axis definitions
  54914. */
  54915. readonly components: {
  54916. [id: string]: WebXRControllerComponent;
  54917. };
  54918. /**
  54919. * Disable the model's animation. Can be set at any time.
  54920. */
  54921. disableAnimation: boolean;
  54922. /**
  54923. * Observers registered here will be triggered when the model of this controller is done loading
  54924. */
  54925. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  54926. /**
  54927. * The profile id of this motion controller
  54928. */
  54929. abstract profileId: string;
  54930. /**
  54931. * The root mesh of the model. It is null if the model was not yet initialized
  54932. */
  54933. rootMesh: Nullable<AbstractMesh>;
  54934. /**
  54935. * constructs a new abstract motion controller
  54936. * @param scene the scene to which the model of the controller will be added
  54937. * @param layout The profile layout to load
  54938. * @param gamepadObject The gamepad object correlating to this controller
  54939. * @param handedness handedness (left/right/none) of this controller
  54940. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  54941. */
  54942. constructor(scene: Scene, layout: IMotionControllerLayout,
  54943. /**
  54944. * The gamepad object correlating to this controller
  54945. */
  54946. gamepadObject: IMinimalMotionControllerObject,
  54947. /**
  54948. * handedness (left/right/none) of this controller
  54949. */
  54950. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  54951. /**
  54952. * Dispose this controller, the model mesh and all its components
  54953. */
  54954. dispose(): void;
  54955. /**
  54956. * Returns all components of specific type
  54957. * @param type the type to search for
  54958. * @return an array of components with this type
  54959. */
  54960. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  54961. /**
  54962. * get a component based an its component id as defined in layout.components
  54963. * @param id the id of the component
  54964. * @returns the component correlates to the id or undefined if not found
  54965. */
  54966. getComponent(id: string): WebXRControllerComponent;
  54967. /**
  54968. * Get the list of components available in this motion controller
  54969. * @returns an array of strings correlating to available components
  54970. */
  54971. getComponentIds(): string[];
  54972. /**
  54973. * Get the first component of specific type
  54974. * @param type type of component to find
  54975. * @return a controller component or null if not found
  54976. */
  54977. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  54978. /**
  54979. * Get the main (Select) component of this controller as defined in the layout
  54980. * @returns the main component of this controller
  54981. */
  54982. getMainComponent(): WebXRControllerComponent;
  54983. /**
  54984. * Loads the model correlating to this controller
  54985. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  54986. * @returns A promise fulfilled with the result of the model loading
  54987. */
  54988. loadModel(): Promise<boolean>;
  54989. /**
  54990. * Update this model using the current XRFrame
  54991. * @param xrFrame the current xr frame to use and update the model
  54992. */
  54993. updateFromXRFrame(xrFrame: XRFrame): void;
  54994. /**
  54995. * Backwards compatibility due to a deeply-integrated typo
  54996. */
  54997. get handness(): XREye;
  54998. /**
  54999. * Pulse (vibrate) this controller
  55000. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  55001. * Consecutive calls to this function will cancel the last pulse call
  55002. *
  55003. * @param value the strength of the pulse in 0.0...1.0 range
  55004. * @param duration Duration of the pulse in milliseconds
  55005. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  55006. * @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
  55007. */
  55008. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  55009. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  55010. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  55011. /**
  55012. * Moves the axis on the controller mesh based on its current state
  55013. * @param axis the index of the axis
  55014. * @param axisValue the value of the axis which determines the meshes new position
  55015. * @hidden
  55016. */
  55017. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  55018. /**
  55019. * Update the model itself with the current frame data
  55020. * @param xrFrame the frame to use for updating the model mesh
  55021. */
  55022. protected updateModel(xrFrame: XRFrame): void;
  55023. /**
  55024. * Get the filename and path for this controller's model
  55025. * @returns a map of filename and path
  55026. */
  55027. protected abstract _getFilenameAndPath(): {
  55028. filename: string;
  55029. path: string;
  55030. };
  55031. /**
  55032. * This function is called before the mesh is loaded. It checks for loading constraints.
  55033. * For example, this function can check if the GLB loader is available
  55034. * If this function returns false, the generic controller will be loaded instead
  55035. * @returns Is the client ready to load the mesh
  55036. */
  55037. protected abstract _getModelLoadingConstraints(): boolean;
  55038. /**
  55039. * This function will be called after the model was successfully loaded and can be used
  55040. * for mesh transformations before it is available for the user
  55041. * @param meshes the loaded meshes
  55042. */
  55043. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  55044. /**
  55045. * Set the root mesh for this controller. Important for the WebXR controller class
  55046. * @param meshes the loaded meshes
  55047. */
  55048. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  55049. /**
  55050. * A function executed each frame that updates the mesh (if needed)
  55051. * @param xrFrame the current xrFrame
  55052. */
  55053. protected abstract _updateModel(xrFrame: XRFrame): void;
  55054. private _getGenericFilenameAndPath;
  55055. private _getGenericParentMesh;
  55056. }
  55057. }
  55058. declare module BABYLON {
  55059. /**
  55060. * A generic trigger-only motion controller for WebXR
  55061. */
  55062. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  55063. /**
  55064. * Static version of the profile id of this controller
  55065. */
  55066. static ProfileId: string;
  55067. profileId: string;
  55068. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  55069. protected _getFilenameAndPath(): {
  55070. filename: string;
  55071. path: string;
  55072. };
  55073. protected _getModelLoadingConstraints(): boolean;
  55074. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  55075. protected _setRootMesh(meshes: AbstractMesh[]): void;
  55076. protected _updateModel(): void;
  55077. }
  55078. }
  55079. declare module BABYLON {
  55080. /**
  55081. * Class containing static functions to help procedurally build meshes
  55082. */
  55083. export class SphereBuilder {
  55084. /**
  55085. * Creates a sphere mesh
  55086. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  55087. * * 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`)
  55088. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  55089. * * 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
  55090. * * 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)
  55091. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55092. * * 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
  55093. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55094. * @param name defines the name of the mesh
  55095. * @param options defines the options used to create the mesh
  55096. * @param scene defines the hosting scene
  55097. * @returns the sphere mesh
  55098. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  55099. */
  55100. static CreateSphere(name: string, options: {
  55101. segments?: number;
  55102. diameter?: number;
  55103. diameterX?: number;
  55104. diameterY?: number;
  55105. diameterZ?: number;
  55106. arc?: number;
  55107. slice?: number;
  55108. sideOrientation?: number;
  55109. frontUVs?: Vector4;
  55110. backUVs?: Vector4;
  55111. updatable?: boolean;
  55112. }, scene?: Nullable<Scene>): Mesh;
  55113. }
  55114. }
  55115. declare module BABYLON {
  55116. /**
  55117. * A profiled motion controller has its profile loaded from an online repository.
  55118. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  55119. */
  55120. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  55121. private _repositoryUrl;
  55122. private _buttonMeshMapping;
  55123. private _touchDots;
  55124. /**
  55125. * The profile ID of this controller. Will be populated when the controller initializes.
  55126. */
  55127. profileId: string;
  55128. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  55129. dispose(): void;
  55130. protected _getFilenameAndPath(): {
  55131. filename: string;
  55132. path: string;
  55133. };
  55134. protected _getModelLoadingConstraints(): boolean;
  55135. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  55136. protected _setRootMesh(meshes: AbstractMesh[]): void;
  55137. protected _updateModel(_xrFrame: XRFrame): void;
  55138. }
  55139. }
  55140. declare module BABYLON {
  55141. /**
  55142. * A construction function type to create a new controller based on an xrInput object
  55143. */
  55144. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  55145. /**
  55146. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  55147. *
  55148. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  55149. * it should be replaced with auto-loaded controllers.
  55150. *
  55151. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  55152. */
  55153. export class WebXRMotionControllerManager {
  55154. private static _AvailableControllers;
  55155. private static _Fallbacks;
  55156. private static _ProfileLoadingPromises;
  55157. private static _ProfilesList;
  55158. /**
  55159. * The base URL of the online controller repository. Can be changed at any time.
  55160. */
  55161. static BaseRepositoryUrl: string;
  55162. /**
  55163. * Which repository gets priority - local or online
  55164. */
  55165. static PrioritizeOnlineRepository: boolean;
  55166. /**
  55167. * Use the online repository, or use only locally-defined controllers
  55168. */
  55169. static UseOnlineRepository: boolean;
  55170. /**
  55171. * Clear the cache used for profile loading and reload when requested again
  55172. */
  55173. static ClearProfilesCache(): void;
  55174. /**
  55175. * Register the default fallbacks.
  55176. * This function is called automatically when this file is imported.
  55177. */
  55178. static DefaultFallbacks(): void;
  55179. /**
  55180. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  55181. * @param profileId the profile to which a fallback needs to be found
  55182. * @return an array with corresponding fallback profiles
  55183. */
  55184. static FindFallbackWithProfileId(profileId: string): string[];
  55185. /**
  55186. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  55187. * The order of search:
  55188. *
  55189. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  55190. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  55191. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  55192. * 4) return the generic trigger controller if none were found
  55193. *
  55194. * @param xrInput the xrInput to which a new controller is initialized
  55195. * @param scene the scene to which the model will be added
  55196. * @param forceProfile force a certain profile for this controller
  55197. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  55198. */
  55199. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  55200. /**
  55201. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  55202. *
  55203. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  55204. *
  55205. * @param type the profile type to register
  55206. * @param constructFunction the function to be called when loading this profile
  55207. */
  55208. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  55209. /**
  55210. * Register a fallback to a specific profile.
  55211. * @param profileId the profileId that will receive the fallbacks
  55212. * @param fallbacks A list of fallback profiles
  55213. */
  55214. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  55215. /**
  55216. * Will update the list of profiles available in the repository
  55217. * @return a promise that resolves to a map of profiles available online
  55218. */
  55219. static UpdateProfilesList(): Promise<{
  55220. [profile: string]: string;
  55221. }>;
  55222. private static _LoadProfileFromRepository;
  55223. private static _LoadProfilesFromAvailableControllers;
  55224. }
  55225. }
  55226. declare module BABYLON {
  55227. /**
  55228. * Configuration options for the WebXR controller creation
  55229. */
  55230. export interface IWebXRControllerOptions {
  55231. /**
  55232. * Should the controller mesh be animated when a user interacts with it
  55233. * The pressed buttons / thumbstick and touchpad animations will be disabled
  55234. */
  55235. disableMotionControllerAnimation?: boolean;
  55236. /**
  55237. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  55238. */
  55239. doNotLoadControllerMesh?: boolean;
  55240. /**
  55241. * Force a specific controller type for this controller.
  55242. * This can be used when creating your own profile or when testing different controllers
  55243. */
  55244. forceControllerProfile?: string;
  55245. /**
  55246. * Defines a rendering group ID for meshes that will be loaded.
  55247. * This is for the default controllers only.
  55248. */
  55249. renderingGroupId?: number;
  55250. }
  55251. /**
  55252. * Represents an XR controller
  55253. */
  55254. export class WebXRInputSource {
  55255. private _scene;
  55256. /** The underlying input source for the controller */
  55257. inputSource: XRInputSource;
  55258. private _options;
  55259. private _tmpVector;
  55260. private _uniqueId;
  55261. private _disposed;
  55262. /**
  55263. * 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
  55264. */
  55265. grip?: AbstractMesh;
  55266. /**
  55267. * If available, this is the gamepad object related to this controller.
  55268. * Using this object it is possible to get click events and trackpad changes of the
  55269. * webxr controller that is currently being used.
  55270. */
  55271. motionController?: WebXRAbstractMotionController;
  55272. /**
  55273. * Event that fires when the controller is removed/disposed.
  55274. * The object provided as event data is this controller, after associated assets were disposed.
  55275. * uniqueId is still available.
  55276. */
  55277. onDisposeObservable: Observable<WebXRInputSource>;
  55278. /**
  55279. * Will be triggered when the mesh associated with the motion controller is done loading.
  55280. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  55281. * A shortened version of controller -> motion controller -> on mesh loaded.
  55282. */
  55283. onMeshLoadedObservable: Observable<AbstractMesh>;
  55284. /**
  55285. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  55286. */
  55287. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  55288. /**
  55289. * Pointer which can be used to select objects or attach a visible laser to
  55290. */
  55291. pointer: AbstractMesh;
  55292. /**
  55293. * Creates the input source object
  55294. * @see https://doc.babylonjs.com/how_to/webxr_controllers_support
  55295. * @param _scene the scene which the controller should be associated to
  55296. * @param inputSource the underlying input source for the controller
  55297. * @param _options options for this controller creation
  55298. */
  55299. constructor(_scene: Scene,
  55300. /** The underlying input source for the controller */
  55301. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  55302. /**
  55303. * Get this controllers unique id
  55304. */
  55305. get uniqueId(): string;
  55306. /**
  55307. * Disposes of the object
  55308. */
  55309. dispose(): void;
  55310. /**
  55311. * Gets a world space ray coming from the pointer or grip
  55312. * @param result the resulting ray
  55313. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  55314. */
  55315. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  55316. /**
  55317. * Updates the controller pose based on the given XRFrame
  55318. * @param xrFrame xr frame to update the pose with
  55319. * @param referenceSpace reference space to use
  55320. */
  55321. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  55322. }
  55323. }
  55324. declare module BABYLON {
  55325. /**
  55326. * The schema for initialization options of the XR Input class
  55327. */
  55328. export interface IWebXRInputOptions {
  55329. /**
  55330. * If set to true no model will be automatically loaded
  55331. */
  55332. doNotLoadControllerMeshes?: boolean;
  55333. /**
  55334. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  55335. * If not found, the xr input profile data will be used.
  55336. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  55337. */
  55338. forceInputProfile?: string;
  55339. /**
  55340. * Do not send a request to the controller repository to load the profile.
  55341. *
  55342. * Instead, use the controllers available in babylon itself.
  55343. */
  55344. disableOnlineControllerRepository?: boolean;
  55345. /**
  55346. * A custom URL for the controllers repository
  55347. */
  55348. customControllersRepositoryURL?: string;
  55349. /**
  55350. * Should the controller model's components not move according to the user input
  55351. */
  55352. disableControllerAnimation?: boolean;
  55353. /**
  55354. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  55355. */
  55356. controllerOptions?: IWebXRControllerOptions;
  55357. }
  55358. /**
  55359. * XR input used to track XR inputs such as controllers/rays
  55360. */
  55361. export class WebXRInput implements IDisposable {
  55362. /**
  55363. * the xr session manager for this session
  55364. */
  55365. xrSessionManager: WebXRSessionManager;
  55366. /**
  55367. * the WebXR camera for this session. Mainly used for teleportation
  55368. */
  55369. xrCamera: WebXRCamera;
  55370. private readonly options;
  55371. /**
  55372. * XR controllers being tracked
  55373. */
  55374. controllers: Array<WebXRInputSource>;
  55375. private _frameObserver;
  55376. private _sessionEndedObserver;
  55377. private _sessionInitObserver;
  55378. /**
  55379. * Event when a controller has been connected/added
  55380. */
  55381. onControllerAddedObservable: Observable<WebXRInputSource>;
  55382. /**
  55383. * Event when a controller has been removed/disconnected
  55384. */
  55385. onControllerRemovedObservable: Observable<WebXRInputSource>;
  55386. /**
  55387. * Initializes the WebXRInput
  55388. * @param xrSessionManager the xr session manager for this session
  55389. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  55390. * @param options = initialization options for this xr input
  55391. */
  55392. constructor(
  55393. /**
  55394. * the xr session manager for this session
  55395. */
  55396. xrSessionManager: WebXRSessionManager,
  55397. /**
  55398. * the WebXR camera for this session. Mainly used for teleportation
  55399. */
  55400. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  55401. private _onInputSourcesChange;
  55402. private _addAndRemoveControllers;
  55403. /**
  55404. * Disposes of the object
  55405. */
  55406. dispose(): void;
  55407. }
  55408. }
  55409. declare module BABYLON {
  55410. /**
  55411. * This is the base class for all WebXR features.
  55412. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  55413. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  55414. */
  55415. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  55416. protected _xrSessionManager: WebXRSessionManager;
  55417. private _attached;
  55418. private _removeOnDetach;
  55419. /**
  55420. * Is this feature disposed?
  55421. */
  55422. isDisposed: boolean;
  55423. /**
  55424. * Should auto-attach be disabled?
  55425. */
  55426. disableAutoAttach: boolean;
  55427. /**
  55428. * The name of the native xr feature name (like anchor, hit-test, or hand-tracking)
  55429. */
  55430. xrNativeFeatureName: string;
  55431. /**
  55432. * Construct a new (abstract) WebXR feature
  55433. * @param _xrSessionManager the xr session manager for this feature
  55434. */
  55435. constructor(_xrSessionManager: WebXRSessionManager);
  55436. /**
  55437. * Is this feature attached
  55438. */
  55439. get attached(): boolean;
  55440. /**
  55441. * attach this feature
  55442. *
  55443. * @param force should attachment be forced (even when already attached)
  55444. * @returns true if successful, false is failed or already attached
  55445. */
  55446. attach(force?: boolean): boolean;
  55447. /**
  55448. * detach this feature.
  55449. *
  55450. * @returns true if successful, false if failed or already detached
  55451. */
  55452. detach(): boolean;
  55453. /**
  55454. * Dispose this feature and all of the resources attached
  55455. */
  55456. dispose(): void;
  55457. /**
  55458. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  55459. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  55460. *
  55461. * @returns whether or not the feature is compatible in this environment
  55462. */
  55463. isCompatible(): boolean;
  55464. /**
  55465. * This is used to register callbacks that will automatically be removed when detach is called.
  55466. * @param observable the observable to which the observer will be attached
  55467. * @param callback the callback to register
  55468. */
  55469. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  55470. /**
  55471. * Code in this function will be executed on each xrFrame received from the browser.
  55472. * This function will not execute after the feature is detached.
  55473. * @param _xrFrame the current frame
  55474. */
  55475. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  55476. }
  55477. }
  55478. declare module BABYLON {
  55479. /**
  55480. * Renders a layer on top of an existing scene
  55481. */
  55482. export class UtilityLayerRenderer implements IDisposable {
  55483. /** the original scene that will be rendered on top of */
  55484. originalScene: Scene;
  55485. private _pointerCaptures;
  55486. private _lastPointerEvents;
  55487. private static _DefaultUtilityLayer;
  55488. private static _DefaultKeepDepthUtilityLayer;
  55489. private _sharedGizmoLight;
  55490. private _renderCamera;
  55491. /**
  55492. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  55493. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  55494. * @returns the camera that is used when rendering the utility layer
  55495. */
  55496. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  55497. /**
  55498. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  55499. * @param cam the camera that should be used when rendering the utility layer
  55500. */
  55501. setRenderCamera(cam: Nullable<Camera>): void;
  55502. /**
  55503. * @hidden
  55504. * Light which used by gizmos to get light shading
  55505. */
  55506. _getSharedGizmoLight(): HemisphericLight;
  55507. /**
  55508. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  55509. */
  55510. pickUtilitySceneFirst: boolean;
  55511. /**
  55512. * 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)
  55513. */
  55514. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  55515. /**
  55516. * 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)
  55517. */
  55518. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  55519. /**
  55520. * The scene that is rendered on top of the original scene
  55521. */
  55522. utilityLayerScene: Scene;
  55523. /**
  55524. * If the utility layer should automatically be rendered on top of existing scene
  55525. */
  55526. shouldRender: boolean;
  55527. /**
  55528. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  55529. */
  55530. onlyCheckPointerDownEvents: boolean;
  55531. /**
  55532. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  55533. */
  55534. processAllEvents: boolean;
  55535. /**
  55536. * Observable raised when the pointer move from the utility layer scene to the main scene
  55537. */
  55538. onPointerOutObservable: Observable<number>;
  55539. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  55540. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  55541. private _afterRenderObserver;
  55542. private _sceneDisposeObserver;
  55543. private _originalPointerObserver;
  55544. /**
  55545. * Instantiates a UtilityLayerRenderer
  55546. * @param originalScene the original scene that will be rendered on top of
  55547. * @param handleEvents boolean indicating if the utility layer should handle events
  55548. */
  55549. constructor(
  55550. /** the original scene that will be rendered on top of */
  55551. originalScene: Scene, handleEvents?: boolean);
  55552. private _notifyObservers;
  55553. /**
  55554. * Renders the utility layers scene on top of the original scene
  55555. */
  55556. render(): void;
  55557. /**
  55558. * Disposes of the renderer
  55559. */
  55560. dispose(): void;
  55561. private _updateCamera;
  55562. }
  55563. }
  55564. declare module BABYLON {
  55565. /**
  55566. * Options interface for the pointer selection module
  55567. */
  55568. export interface IWebXRControllerPointerSelectionOptions {
  55569. /**
  55570. * if provided, this scene will be used to render meshes.
  55571. */
  55572. customUtilityLayerScene?: Scene;
  55573. /**
  55574. * 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)
  55575. * If not disabled, the last picked point will be used to execute a pointer up event
  55576. * If disabled, pointer up event will be triggered right after the pointer down event.
  55577. * Used in screen and gaze target ray mode only
  55578. */
  55579. disablePointerUpOnTouchOut: boolean;
  55580. /**
  55581. * For gaze mode for tracked-pointer / controllers (time to select instead of button press)
  55582. */
  55583. forceGazeMode: boolean;
  55584. /**
  55585. * 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
  55586. * to start a new countdown to the pointer down event.
  55587. * Defaults to 1.
  55588. */
  55589. gazeModePointerMovedFactor?: number;
  55590. /**
  55591. * Different button type to use instead of the main component
  55592. */
  55593. overrideButtonId?: string;
  55594. /**
  55595. * use this rendering group id for the meshes (optional)
  55596. */
  55597. renderingGroupId?: number;
  55598. /**
  55599. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  55600. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  55601. * 3000 means 3 seconds between pointing at something and selecting it
  55602. */
  55603. timeToSelect?: number;
  55604. /**
  55605. * Should meshes created here be added to a utility layer or the main scene
  55606. */
  55607. useUtilityLayer?: boolean;
  55608. /**
  55609. * Optional WebXR camera to be used for gaze selection
  55610. */
  55611. gazeCamera?: WebXRCamera;
  55612. /**
  55613. * the xr input to use with this pointer selection
  55614. */
  55615. xrInput: WebXRInput;
  55616. /**
  55617. * Should the scene pointerX and pointerY update be disabled
  55618. * This is required for fullscreen AR GUI, but might slow down other experiences.
  55619. * Disable in VR, if not needed.
  55620. * The first rig camera (left eye) will be used to calculate the projection
  55621. */
  55622. disableScenePointerVectorUpdate: boolean;
  55623. /**
  55624. * Enable pointer selection on all controllers instead of switching between them
  55625. */
  55626. enablePointerSelectionOnAllControllers?: boolean;
  55627. /**
  55628. * The preferred hand to give the pointer selection to. This will be prioritized when the controller initialize.
  55629. * If switch is enabled, it will still allow the user to switch between the different controllers
  55630. */
  55631. preferredHandedness?: XRHandedness;
  55632. /**
  55633. * Disable switching the pointer selection from one controller to the other.
  55634. * 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
  55635. */
  55636. disableSwitchOnClick?: boolean;
  55637. /**
  55638. * The maximum distance of the pointer selection feature. Defaults to 100.
  55639. */
  55640. maxPointerDistance?: number;
  55641. }
  55642. /**
  55643. * A module that will enable pointer selection for motion controllers of XR Input Sources
  55644. */
  55645. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  55646. private readonly _options;
  55647. private static _idCounter;
  55648. private _attachController;
  55649. private _controllers;
  55650. private _scene;
  55651. private _tmpVectorForPickCompare;
  55652. private _attachedController;
  55653. /**
  55654. * The module's name
  55655. */
  55656. static readonly Name: string;
  55657. /**
  55658. * The (Babylon) version of this module.
  55659. * This is an integer representing the implementation version.
  55660. * This number does not correspond to the WebXR specs version
  55661. */
  55662. static readonly Version: number;
  55663. /**
  55664. * Disable lighting on the laser pointer (so it will always be visible)
  55665. */
  55666. disablePointerLighting: boolean;
  55667. /**
  55668. * Disable lighting on the selection mesh (so it will always be visible)
  55669. */
  55670. disableSelectionMeshLighting: boolean;
  55671. /**
  55672. * Should the laser pointer be displayed
  55673. */
  55674. displayLaserPointer: boolean;
  55675. /**
  55676. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  55677. */
  55678. displaySelectionMesh: boolean;
  55679. /**
  55680. * This color will be set to the laser pointer when selection is triggered
  55681. */
  55682. laserPointerPickedColor: Color3;
  55683. /**
  55684. * Default color of the laser pointer
  55685. */
  55686. laserPointerDefaultColor: Color3;
  55687. /**
  55688. * default color of the selection ring
  55689. */
  55690. selectionMeshDefaultColor: Color3;
  55691. /**
  55692. * This color will be applied to the selection ring when selection is triggered
  55693. */
  55694. selectionMeshPickedColor: Color3;
  55695. /**
  55696. * Optional filter to be used for ray selection. This predicate shares behavior with
  55697. * scene.pointerMovePredicate which takes priority if it is also assigned.
  55698. */
  55699. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  55700. /**
  55701. * constructs a new background remover module
  55702. * @param _xrSessionManager the session manager for this module
  55703. * @param _options read-only options to be used in this module
  55704. */
  55705. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  55706. /**
  55707. * attach this feature
  55708. * Will usually be called by the features manager
  55709. *
  55710. * @returns true if successful.
  55711. */
  55712. attach(): boolean;
  55713. /**
  55714. * detach this feature.
  55715. * Will usually be called by the features manager
  55716. *
  55717. * @returns true if successful.
  55718. */
  55719. detach(): boolean;
  55720. /**
  55721. * Will get the mesh under a specific pointer.
  55722. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  55723. * @param controllerId the controllerId to check
  55724. * @returns The mesh under pointer or null if no mesh is under the pointer
  55725. */
  55726. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  55727. /**
  55728. * Get the xr controller that correlates to the pointer id in the pointer event
  55729. *
  55730. * @param id the pointer id to search for
  55731. * @returns the controller that correlates to this id or null if not found
  55732. */
  55733. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  55734. private _identityMatrix;
  55735. private _screenCoordinatesRef;
  55736. private _viewportRef;
  55737. protected _onXRFrame(_xrFrame: XRFrame): void;
  55738. private _attachGazeMode;
  55739. private _attachScreenRayMode;
  55740. private _attachTrackedPointerRayMode;
  55741. private _convertNormalToDirectionOfRay;
  55742. private _detachController;
  55743. private _generateNewMeshPair;
  55744. private _pickingMoved;
  55745. private _updatePointerDistance;
  55746. /** @hidden */
  55747. get lasterPointerDefaultColor(): Color3;
  55748. }
  55749. }
  55750. declare module BABYLON {
  55751. /**
  55752. * Button which can be used to enter a different mode of XR
  55753. */
  55754. export class WebXREnterExitUIButton {
  55755. /** button element */
  55756. element: HTMLElement;
  55757. /** XR initialization options for the button */
  55758. sessionMode: XRSessionMode;
  55759. /** Reference space type */
  55760. referenceSpaceType: XRReferenceSpaceType;
  55761. /**
  55762. * Creates a WebXREnterExitUIButton
  55763. * @param element button element
  55764. * @param sessionMode XR initialization session mode
  55765. * @param referenceSpaceType the type of reference space to be used
  55766. */
  55767. constructor(
  55768. /** button element */
  55769. element: HTMLElement,
  55770. /** XR initialization options for the button */
  55771. sessionMode: XRSessionMode,
  55772. /** Reference space type */
  55773. referenceSpaceType: XRReferenceSpaceType);
  55774. /**
  55775. * Extendable function which can be used to update the button's visuals when the state changes
  55776. * @param activeButton the current active button in the UI
  55777. */
  55778. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  55779. }
  55780. /**
  55781. * Options to create the webXR UI
  55782. */
  55783. export class WebXREnterExitUIOptions {
  55784. /**
  55785. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  55786. */
  55787. customButtons?: Array<WebXREnterExitUIButton>;
  55788. /**
  55789. * A reference space type to use when creating the default button.
  55790. * Default is local-floor
  55791. */
  55792. referenceSpaceType?: XRReferenceSpaceType;
  55793. /**
  55794. * Context to enter xr with
  55795. */
  55796. renderTarget?: Nullable<WebXRRenderTarget>;
  55797. /**
  55798. * A session mode to use when creating the default button.
  55799. * Default is immersive-vr
  55800. */
  55801. sessionMode?: XRSessionMode;
  55802. /**
  55803. * A list of optional features to init the session with
  55804. */
  55805. optionalFeatures?: string[];
  55806. /**
  55807. * A list of optional features to init the session with
  55808. */
  55809. requiredFeatures?: string[];
  55810. /**
  55811. * If defined, this function will be executed if the UI encounters an error when entering XR
  55812. */
  55813. onError?: (error: any) => void;
  55814. }
  55815. /**
  55816. * UI to allow the user to enter/exit XR mode
  55817. */
  55818. export class WebXREnterExitUI implements IDisposable {
  55819. private scene;
  55820. /** version of the options passed to this UI */
  55821. options: WebXREnterExitUIOptions;
  55822. private _activeButton;
  55823. private _buttons;
  55824. /**
  55825. * The HTML Div Element to which buttons are added.
  55826. */
  55827. readonly overlay: HTMLDivElement;
  55828. /**
  55829. * Fired every time the active button is changed.
  55830. *
  55831. * When xr is entered via a button that launches xr that button will be the callback parameter
  55832. *
  55833. * When exiting xr the callback parameter will be null)
  55834. */
  55835. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  55836. /**
  55837. *
  55838. * @param scene babylon scene object to use
  55839. * @param options (read-only) version of the options passed to this UI
  55840. */
  55841. private constructor();
  55842. /**
  55843. * Creates UI to allow the user to enter/exit XR mode
  55844. * @param scene the scene to add the ui to
  55845. * @param helper the xr experience helper to enter/exit xr with
  55846. * @param options options to configure the UI
  55847. * @returns the created ui
  55848. */
  55849. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  55850. /**
  55851. * Disposes of the XR UI component
  55852. */
  55853. dispose(): void;
  55854. private _updateButtons;
  55855. }
  55856. }
  55857. declare module BABYLON {
  55858. /**
  55859. * Class containing static functions to help procedurally build meshes
  55860. */
  55861. export class LinesBuilder {
  55862. /**
  55863. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  55864. * * 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
  55865. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  55866. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  55867. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  55868. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  55869. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  55870. * * 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
  55871. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  55872. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55873. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  55874. * @param name defines the name of the new line system
  55875. * @param options defines the options used to create the line system
  55876. * @param scene defines the hosting scene
  55877. * @returns a new line system mesh
  55878. */
  55879. static CreateLineSystem(name: string, options: {
  55880. lines: Vector3[][];
  55881. updatable?: boolean;
  55882. instance?: Nullable<LinesMesh>;
  55883. colors?: Nullable<Color4[][]>;
  55884. useVertexAlpha?: boolean;
  55885. }, scene: Nullable<Scene>): LinesMesh;
  55886. /**
  55887. * Creates a line mesh
  55888. * 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
  55889. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  55890. * * The parameter `points` is an array successive Vector3
  55891. * * 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
  55892. * * The optional parameter `colors` is an array of successive Color4, one per line point
  55893. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  55894. * * When updating an instance, remember that only point positions can change, not the number of points
  55895. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55896. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  55897. * @param name defines the name of the new line system
  55898. * @param options defines the options used to create the line system
  55899. * @param scene defines the hosting scene
  55900. * @returns a new line mesh
  55901. */
  55902. static CreateLines(name: string, options: {
  55903. points: Vector3[];
  55904. updatable?: boolean;
  55905. instance?: Nullable<LinesMesh>;
  55906. colors?: Color4[];
  55907. useVertexAlpha?: boolean;
  55908. }, scene?: Nullable<Scene>): LinesMesh;
  55909. /**
  55910. * Creates a dashed line mesh
  55911. * * 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
  55912. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  55913. * * The parameter `points` is an array successive Vector3
  55914. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  55915. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  55916. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  55917. * * 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
  55918. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  55919. * * When updating an instance, remember that only point positions can change, not the number of points
  55920. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55921. * @param name defines the name of the mesh
  55922. * @param options defines the options used to create the mesh
  55923. * @param scene defines the hosting scene
  55924. * @returns the dashed line mesh
  55925. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  55926. */
  55927. static CreateDashedLines(name: string, options: {
  55928. points: Vector3[];
  55929. dashSize?: number;
  55930. gapSize?: number;
  55931. dashNb?: number;
  55932. updatable?: boolean;
  55933. instance?: LinesMesh;
  55934. useVertexAlpha?: boolean;
  55935. }, scene?: Nullable<Scene>): LinesMesh;
  55936. }
  55937. }
  55938. declare module BABYLON {
  55939. /**
  55940. * Construction options for a timer
  55941. */
  55942. export interface ITimerOptions<T> {
  55943. /**
  55944. * Time-to-end
  55945. */
  55946. timeout: number;
  55947. /**
  55948. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  55949. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  55950. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  55951. */
  55952. contextObservable: Observable<T>;
  55953. /**
  55954. * Optional parameters when adding an observer to the observable
  55955. */
  55956. observableParameters?: {
  55957. mask?: number;
  55958. insertFirst?: boolean;
  55959. scope?: any;
  55960. };
  55961. /**
  55962. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  55963. */
  55964. breakCondition?: (data?: ITimerData<T>) => boolean;
  55965. /**
  55966. * Will be triggered when the time condition has met
  55967. */
  55968. onEnded?: (data: ITimerData<any>) => void;
  55969. /**
  55970. * Will be triggered when the break condition has met (prematurely ended)
  55971. */
  55972. onAborted?: (data: ITimerData<any>) => void;
  55973. /**
  55974. * Optional function to execute on each tick (or count)
  55975. */
  55976. onTick?: (data: ITimerData<any>) => void;
  55977. }
  55978. /**
  55979. * An interface defining the data sent by the timer
  55980. */
  55981. export interface ITimerData<T> {
  55982. /**
  55983. * When did it start
  55984. */
  55985. startTime: number;
  55986. /**
  55987. * Time now
  55988. */
  55989. currentTime: number;
  55990. /**
  55991. * Time passed since started
  55992. */
  55993. deltaTime: number;
  55994. /**
  55995. * How much is completed, in [0.0...1.0].
  55996. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  55997. */
  55998. completeRate: number;
  55999. /**
  56000. * What the registered observable sent in the last count
  56001. */
  56002. payload: T;
  56003. }
  56004. /**
  56005. * The current state of the timer
  56006. */
  56007. export enum TimerState {
  56008. /**
  56009. * Timer initialized, not yet started
  56010. */
  56011. INIT = 0,
  56012. /**
  56013. * Timer started and counting
  56014. */
  56015. STARTED = 1,
  56016. /**
  56017. * Timer ended (whether aborted or time reached)
  56018. */
  56019. ENDED = 2
  56020. }
  56021. /**
  56022. * A simple version of the timer. Will take options and start the timer immediately after calling it
  56023. *
  56024. * @param options options with which to initialize this timer
  56025. */
  56026. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  56027. /**
  56028. * An advanced implementation of a timer class
  56029. */
  56030. export class AdvancedTimer<T = any> implements IDisposable {
  56031. /**
  56032. * Will notify each time the timer calculates the remaining time
  56033. */
  56034. onEachCountObservable: Observable<ITimerData<T>>;
  56035. /**
  56036. * Will trigger when the timer was aborted due to the break condition
  56037. */
  56038. onTimerAbortedObservable: Observable<ITimerData<T>>;
  56039. /**
  56040. * Will trigger when the timer ended successfully
  56041. */
  56042. onTimerEndedObservable: Observable<ITimerData<T>>;
  56043. /**
  56044. * Will trigger when the timer state has changed
  56045. */
  56046. onStateChangedObservable: Observable<TimerState>;
  56047. private _observer;
  56048. private _contextObservable;
  56049. private _observableParameters;
  56050. private _startTime;
  56051. private _timer;
  56052. private _state;
  56053. private _breakCondition;
  56054. private _timeToEnd;
  56055. private _breakOnNextTick;
  56056. /**
  56057. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  56058. * @param options construction options for this advanced timer
  56059. */
  56060. constructor(options: ITimerOptions<T>);
  56061. /**
  56062. * set a breaking condition for this timer. Default is to never break during count
  56063. * @param predicate the new break condition. Returns true to break, false otherwise
  56064. */
  56065. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  56066. /**
  56067. * Reset ALL associated observables in this advanced timer
  56068. */
  56069. clearObservables(): void;
  56070. /**
  56071. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  56072. *
  56073. * @param timeToEnd how much time to measure until timer ended
  56074. */
  56075. start(timeToEnd?: number): void;
  56076. /**
  56077. * Will force a stop on the next tick.
  56078. */
  56079. stop(): void;
  56080. /**
  56081. * Dispose this timer, clearing all resources
  56082. */
  56083. dispose(): void;
  56084. private _setState;
  56085. private _tick;
  56086. private _stop;
  56087. }
  56088. }
  56089. declare module BABYLON {
  56090. /**
  56091. * The options container for the teleportation module
  56092. */
  56093. export interface IWebXRTeleportationOptions {
  56094. /**
  56095. * if provided, this scene will be used to render meshes.
  56096. */
  56097. customUtilityLayerScene?: Scene;
  56098. /**
  56099. * Values to configure the default target mesh
  56100. */
  56101. defaultTargetMeshOptions?: {
  56102. /**
  56103. * Fill color of the teleportation area
  56104. */
  56105. teleportationFillColor?: string;
  56106. /**
  56107. * Border color for the teleportation area
  56108. */
  56109. teleportationBorderColor?: string;
  56110. /**
  56111. * Disable the mesh's animation sequence
  56112. */
  56113. disableAnimation?: boolean;
  56114. /**
  56115. * Disable lighting on the material or the ring and arrow
  56116. */
  56117. disableLighting?: boolean;
  56118. /**
  56119. * Override the default material of the torus and arrow
  56120. */
  56121. torusArrowMaterial?: Material;
  56122. };
  56123. /**
  56124. * A list of meshes to use as floor meshes.
  56125. * Meshes can be added and removed after initializing the feature using the
  56126. * addFloorMesh and removeFloorMesh functions
  56127. * If empty, rotation will still work
  56128. */
  56129. floorMeshes?: AbstractMesh[];
  56130. /**
  56131. * use this rendering group id for the meshes (optional)
  56132. */
  56133. renderingGroupId?: number;
  56134. /**
  56135. * Should teleportation move only to snap points
  56136. */
  56137. snapPointsOnly?: boolean;
  56138. /**
  56139. * An array of points to which the teleportation will snap to.
  56140. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  56141. */
  56142. snapPositions?: Vector3[];
  56143. /**
  56144. * How close should the teleportation ray be in order to snap to position.
  56145. * Default to 0.8 units (meters)
  56146. */
  56147. snapToPositionRadius?: number;
  56148. /**
  56149. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  56150. * If you want to support rotation, make sure your mesh has a direction indicator.
  56151. *
  56152. * When left untouched, the default mesh will be initialized.
  56153. */
  56154. teleportationTargetMesh?: AbstractMesh;
  56155. /**
  56156. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  56157. */
  56158. timeToTeleport?: number;
  56159. /**
  56160. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  56161. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  56162. */
  56163. useMainComponentOnly?: boolean;
  56164. /**
  56165. * Should meshes created here be added to a utility layer or the main scene
  56166. */
  56167. useUtilityLayer?: boolean;
  56168. /**
  56169. * Babylon XR Input class for controller
  56170. */
  56171. xrInput: WebXRInput;
  56172. /**
  56173. * Meshes that the teleportation ray cannot go through
  56174. */
  56175. pickBlockerMeshes?: AbstractMesh[];
  56176. /**
  56177. * Should teleport work only on a specific hand?
  56178. */
  56179. forceHandedness?: XRHandedness;
  56180. /**
  56181. * If provided, this function will be used to generate the ray mesh instead of the lines mesh being used per default
  56182. */
  56183. generateRayPathMesh?: (points: Vector3[]) => AbstractMesh;
  56184. }
  56185. /**
  56186. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  56187. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  56188. * the input of the attached controllers.
  56189. */
  56190. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  56191. private _options;
  56192. private _controllers;
  56193. private _currentTeleportationControllerId;
  56194. private _floorMeshes;
  56195. private _quadraticBezierCurve;
  56196. private _selectionFeature;
  56197. private _snapToPositions;
  56198. private _snappedToPoint;
  56199. private _teleportationRingMaterial?;
  56200. private _tmpRay;
  56201. private _tmpVector;
  56202. private _tmpQuaternion;
  56203. /**
  56204. * The module's name
  56205. */
  56206. static readonly Name: string;
  56207. /**
  56208. * The (Babylon) version of this module.
  56209. * This is an integer representing the implementation version.
  56210. * This number does not correspond to the webxr specs version
  56211. */
  56212. static readonly Version: number;
  56213. /**
  56214. * Is movement backwards enabled
  56215. */
  56216. backwardsMovementEnabled: boolean;
  56217. /**
  56218. * Distance to travel when moving backwards
  56219. */
  56220. backwardsTeleportationDistance: number;
  56221. /**
  56222. * The distance from the user to the inspection point in the direction of the controller
  56223. * A higher number will allow the user to move further
  56224. * defaults to 5 (meters, in xr units)
  56225. */
  56226. parabolicCheckRadius: number;
  56227. /**
  56228. * Should the module support parabolic ray on top of direct ray
  56229. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  56230. * Very helpful when moving between floors / different heights
  56231. */
  56232. parabolicRayEnabled: boolean;
  56233. /**
  56234. * The second type of ray - straight line.
  56235. * Should it be enabled or should the parabolic line be the only one.
  56236. */
  56237. straightRayEnabled: boolean;
  56238. /**
  56239. * How much rotation should be applied when rotating right and left
  56240. */
  56241. rotationAngle: number;
  56242. private _rotationEnabled;
  56243. /**
  56244. * Is rotation enabled when moving forward?
  56245. * Disabling this feature will prevent the user from deciding the direction when teleporting
  56246. */
  56247. get rotationEnabled(): boolean;
  56248. /**
  56249. * Sets wether rotation is enabled or not
  56250. * @param enabled is rotation enabled when teleportation is shown
  56251. */
  56252. set rotationEnabled(enabled: boolean);
  56253. /**
  56254. * Exposes the currently set teleportation target mesh.
  56255. */
  56256. get teleportationTargetMesh(): Nullable<AbstractMesh>;
  56257. /**
  56258. * constructs a new anchor system
  56259. * @param _xrSessionManager an instance of WebXRSessionManager
  56260. * @param _options configuration object for this feature
  56261. */
  56262. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  56263. /**
  56264. * Get the snapPointsOnly flag
  56265. */
  56266. get snapPointsOnly(): boolean;
  56267. /**
  56268. * Sets the snapPointsOnly flag
  56269. * @param snapToPoints should teleportation be exclusively to snap points
  56270. */
  56271. set snapPointsOnly(snapToPoints: boolean);
  56272. /**
  56273. * Add a new mesh to the floor meshes array
  56274. * @param mesh the mesh to use as floor mesh
  56275. */
  56276. addFloorMesh(mesh: AbstractMesh): void;
  56277. /**
  56278. * Add a new snap-to point to fix teleportation to this position
  56279. * @param newSnapPoint The new Snap-To point
  56280. */
  56281. addSnapPoint(newSnapPoint: Vector3): void;
  56282. attach(): boolean;
  56283. detach(): boolean;
  56284. dispose(): void;
  56285. /**
  56286. * Remove a mesh from the floor meshes array
  56287. * @param mesh the mesh to remove
  56288. */
  56289. removeFloorMesh(mesh: AbstractMesh): void;
  56290. /**
  56291. * Remove a mesh from the floor meshes array using its name
  56292. * @param name the mesh name to remove
  56293. */
  56294. removeFloorMeshByName(name: string): void;
  56295. /**
  56296. * 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
  56297. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  56298. * @returns was the point found and removed or not
  56299. */
  56300. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  56301. /**
  56302. * This function sets a selection feature that will be disabled when
  56303. * the forward ray is shown and will be reattached when hidden.
  56304. * This is used to remove the selection rays when moving.
  56305. * @param selectionFeature the feature to disable when forward movement is enabled
  56306. */
  56307. setSelectionFeature(selectionFeature: Nullable<IWebXRFeature>): void;
  56308. protected _onXRFrame(_xrFrame: XRFrame): void;
  56309. private _attachController;
  56310. private _createDefaultTargetMesh;
  56311. private _detachController;
  56312. private _findClosestSnapPointWithRadius;
  56313. private _setTargetMeshPosition;
  56314. private _setTargetMeshVisibility;
  56315. private _showParabolicPath;
  56316. private _teleportForward;
  56317. }
  56318. }
  56319. declare module BABYLON {
  56320. /**
  56321. * Options for the default xr helper
  56322. */
  56323. export class WebXRDefaultExperienceOptions {
  56324. /**
  56325. * Enable or disable default UI to enter XR
  56326. */
  56327. disableDefaultUI?: boolean;
  56328. /**
  56329. * Should teleportation not initialize. defaults to false.
  56330. */
  56331. disableTeleportation?: boolean;
  56332. /**
  56333. * Floor meshes that will be used for teleport
  56334. */
  56335. floorMeshes?: Array<AbstractMesh>;
  56336. /**
  56337. * If set to true, the first frame will not be used to reset position
  56338. * The first frame is mainly used when copying transformation from the old camera
  56339. * Mainly used in AR
  56340. */
  56341. ignoreNativeCameraTransformation?: boolean;
  56342. /**
  56343. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  56344. */
  56345. inputOptions?: IWebXRInputOptions;
  56346. /**
  56347. * optional configuration for the output canvas
  56348. */
  56349. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  56350. /**
  56351. * optional UI options. This can be used among other to change session mode and reference space type
  56352. */
  56353. uiOptions?: WebXREnterExitUIOptions;
  56354. /**
  56355. * When loading teleportation and pointer select, use stable versions instead of latest.
  56356. */
  56357. useStablePlugins?: boolean;
  56358. /**
  56359. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  56360. */
  56361. renderingGroupId?: number;
  56362. /**
  56363. * A list of optional features to init the session with
  56364. * If set to true, all features we support will be added
  56365. */
  56366. optionalFeatures?: boolean | string[];
  56367. }
  56368. /**
  56369. * Default experience which provides a similar setup to the previous webVRExperience
  56370. */
  56371. export class WebXRDefaultExperience {
  56372. /**
  56373. * Base experience
  56374. */
  56375. baseExperience: WebXRExperienceHelper;
  56376. /**
  56377. * Enables ui for entering/exiting xr
  56378. */
  56379. enterExitUI: WebXREnterExitUI;
  56380. /**
  56381. * Input experience extension
  56382. */
  56383. input: WebXRInput;
  56384. /**
  56385. * Enables laser pointer and selection
  56386. */
  56387. pointerSelection: WebXRControllerPointerSelection;
  56388. /**
  56389. * Default target xr should render to
  56390. */
  56391. renderTarget: WebXRRenderTarget;
  56392. /**
  56393. * Enables teleportation
  56394. */
  56395. teleportation: WebXRMotionControllerTeleportation;
  56396. private constructor();
  56397. /**
  56398. * Creates the default xr experience
  56399. * @param scene scene
  56400. * @param options options for basic configuration
  56401. * @returns resulting WebXRDefaultExperience
  56402. */
  56403. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  56404. /**
  56405. * DIsposes of the experience helper
  56406. */
  56407. dispose(): void;
  56408. }
  56409. }
  56410. declare module BABYLON {
  56411. /**
  56412. * Options to modify the vr teleportation behavior.
  56413. */
  56414. export interface VRTeleportationOptions {
  56415. /**
  56416. * The name of the mesh which should be used as the teleportation floor. (default: null)
  56417. */
  56418. floorMeshName?: string;
  56419. /**
  56420. * A list of meshes to be used as the teleportation floor. (default: empty)
  56421. */
  56422. floorMeshes?: Mesh[];
  56423. /**
  56424. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  56425. */
  56426. teleportationMode?: number;
  56427. /**
  56428. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  56429. */
  56430. teleportationTime?: number;
  56431. /**
  56432. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  56433. */
  56434. teleportationSpeed?: number;
  56435. /**
  56436. * The easing function used in the animation or null for Linear. (default CircleEase)
  56437. */
  56438. easingFunction?: EasingFunction;
  56439. }
  56440. /**
  56441. * Options to modify the vr experience helper's behavior.
  56442. */
  56443. export interface VRExperienceHelperOptions extends WebVROptions {
  56444. /**
  56445. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  56446. */
  56447. createDeviceOrientationCamera?: boolean;
  56448. /**
  56449. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  56450. */
  56451. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  56452. /**
  56453. * Uses the main button on the controller to toggle the laser casted. (default: true)
  56454. */
  56455. laserToggle?: boolean;
  56456. /**
  56457. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  56458. */
  56459. floorMeshes?: Mesh[];
  56460. /**
  56461. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  56462. */
  56463. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  56464. /**
  56465. * Defines if WebXR should be used instead of WebVR (if available)
  56466. */
  56467. useXR?: boolean;
  56468. }
  56469. /**
  56470. * Event containing information after VR has been entered
  56471. */
  56472. export class OnAfterEnteringVRObservableEvent {
  56473. /**
  56474. * If entering vr was successful
  56475. */
  56476. success: boolean;
  56477. }
  56478. /**
  56479. * Helps to quickly add VR support to an existing scene.
  56480. * See https://doc.babylonjs.com/how_to/webvr_helper
  56481. */
  56482. export class VRExperienceHelper {
  56483. /** Options to modify the vr experience helper's behavior. */
  56484. webVROptions: VRExperienceHelperOptions;
  56485. private _scene;
  56486. private _position;
  56487. private _btnVR;
  56488. private _btnVRDisplayed;
  56489. private _webVRsupported;
  56490. private _webVRready;
  56491. private _webVRrequesting;
  56492. private _webVRpresenting;
  56493. private _hasEnteredVR;
  56494. private _fullscreenVRpresenting;
  56495. private _inputElement;
  56496. private _webVRCamera;
  56497. private _vrDeviceOrientationCamera;
  56498. private _deviceOrientationCamera;
  56499. private _existingCamera;
  56500. private _onKeyDown;
  56501. private _onVrDisplayPresentChange;
  56502. private _onVRDisplayChanged;
  56503. private _onVRRequestPresentStart;
  56504. private _onVRRequestPresentComplete;
  56505. /**
  56506. * 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)
  56507. */
  56508. enableGazeEvenWhenNoPointerLock: boolean;
  56509. /**
  56510. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  56511. */
  56512. exitVROnDoubleTap: boolean;
  56513. /**
  56514. * Observable raised right before entering VR.
  56515. */
  56516. onEnteringVRObservable: Observable<VRExperienceHelper>;
  56517. /**
  56518. * Observable raised when entering VR has completed.
  56519. */
  56520. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  56521. /**
  56522. * Observable raised when exiting VR.
  56523. */
  56524. onExitingVRObservable: Observable<VRExperienceHelper>;
  56525. /**
  56526. * Observable raised when controller mesh is loaded.
  56527. */
  56528. onControllerMeshLoadedObservable: Observable<WebVRController>;
  56529. /** Return this.onEnteringVRObservable
  56530. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  56531. */
  56532. get onEnteringVR(): Observable<VRExperienceHelper>;
  56533. /** Return this.onExitingVRObservable
  56534. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  56535. */
  56536. get onExitingVR(): Observable<VRExperienceHelper>;
  56537. /** Return this.onControllerMeshLoadedObservable
  56538. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  56539. */
  56540. get onControllerMeshLoaded(): Observable<WebVRController>;
  56541. private _rayLength;
  56542. private _useCustomVRButton;
  56543. private _teleportationRequested;
  56544. private _teleportActive;
  56545. private _floorMeshName;
  56546. private _floorMeshesCollection;
  56547. private _teleportationMode;
  56548. private _teleportationTime;
  56549. private _teleportationSpeed;
  56550. private _teleportationEasing;
  56551. private _rotationAllowed;
  56552. private _teleportBackwardsVector;
  56553. private _teleportationTarget;
  56554. private _isDefaultTeleportationTarget;
  56555. private _postProcessMove;
  56556. private _teleportationFillColor;
  56557. private _teleportationBorderColor;
  56558. private _rotationAngle;
  56559. private _haloCenter;
  56560. private _cameraGazer;
  56561. private _padSensibilityUp;
  56562. private _padSensibilityDown;
  56563. private _leftController;
  56564. private _rightController;
  56565. private _gazeColor;
  56566. private _laserColor;
  56567. private _pickedLaserColor;
  56568. private _pickedGazeColor;
  56569. /**
  56570. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  56571. */
  56572. onNewMeshSelected: Observable<AbstractMesh>;
  56573. /**
  56574. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  56575. * This observable will provide the mesh and the controller used to select the mesh
  56576. */
  56577. onMeshSelectedWithController: Observable<{
  56578. mesh: AbstractMesh;
  56579. controller: WebVRController;
  56580. }>;
  56581. /**
  56582. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  56583. */
  56584. onNewMeshPicked: Observable<PickingInfo>;
  56585. private _circleEase;
  56586. /**
  56587. * Observable raised before camera teleportation
  56588. */
  56589. onBeforeCameraTeleport: Observable<Vector3>;
  56590. /**
  56591. * Observable raised after camera teleportation
  56592. */
  56593. onAfterCameraTeleport: Observable<Vector3>;
  56594. /**
  56595. * Observable raised when current selected mesh gets unselected
  56596. */
  56597. onSelectedMeshUnselected: Observable<AbstractMesh>;
  56598. private _raySelectionPredicate;
  56599. /**
  56600. * To be optionaly changed by user to define custom ray selection
  56601. */
  56602. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  56603. /**
  56604. * To be optionaly changed by user to define custom selection logic (after ray selection)
  56605. */
  56606. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  56607. /**
  56608. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  56609. */
  56610. teleportationEnabled: boolean;
  56611. private _defaultHeight;
  56612. private _teleportationInitialized;
  56613. private _interactionsEnabled;
  56614. private _interactionsRequested;
  56615. private _displayGaze;
  56616. private _displayLaserPointer;
  56617. /**
  56618. * The mesh used to display where the user is going to teleport.
  56619. */
  56620. get teleportationTarget(): Mesh;
  56621. /**
  56622. * Sets the mesh to be used to display where the user is going to teleport.
  56623. */
  56624. set teleportationTarget(value: Mesh);
  56625. /**
  56626. * 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
  56627. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  56628. * See https://doc.babylonjs.com/resources/baking_transformations
  56629. */
  56630. get gazeTrackerMesh(): Mesh;
  56631. set gazeTrackerMesh(value: Mesh);
  56632. /**
  56633. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  56634. */
  56635. updateGazeTrackerScale: boolean;
  56636. /**
  56637. * If the gaze trackers color should be updated when selecting meshes
  56638. */
  56639. updateGazeTrackerColor: boolean;
  56640. /**
  56641. * If the controller laser color should be updated when selecting meshes
  56642. */
  56643. updateControllerLaserColor: boolean;
  56644. /**
  56645. * The gaze tracking mesh corresponding to the left controller
  56646. */
  56647. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  56648. /**
  56649. * The gaze tracking mesh corresponding to the right controller
  56650. */
  56651. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  56652. /**
  56653. * If the ray of the gaze should be displayed.
  56654. */
  56655. get displayGaze(): boolean;
  56656. /**
  56657. * Sets if the ray of the gaze should be displayed.
  56658. */
  56659. set displayGaze(value: boolean);
  56660. /**
  56661. * If the ray of the LaserPointer should be displayed.
  56662. */
  56663. get displayLaserPointer(): boolean;
  56664. /**
  56665. * Sets if the ray of the LaserPointer should be displayed.
  56666. */
  56667. set displayLaserPointer(value: boolean);
  56668. /**
  56669. * The deviceOrientationCamera used as the camera when not in VR.
  56670. */
  56671. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  56672. /**
  56673. * Based on the current WebVR support, returns the current VR camera used.
  56674. */
  56675. get currentVRCamera(): Nullable<Camera>;
  56676. /**
  56677. * The webVRCamera which is used when in VR.
  56678. */
  56679. get webVRCamera(): WebVRFreeCamera;
  56680. /**
  56681. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  56682. */
  56683. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  56684. /**
  56685. * The html button that is used to trigger entering into VR.
  56686. */
  56687. get vrButton(): Nullable<HTMLButtonElement>;
  56688. private get _teleportationRequestInitiated();
  56689. /**
  56690. * Defines whether or not Pointer lock should be requested when switching to
  56691. * full screen.
  56692. */
  56693. requestPointerLockOnFullScreen: boolean;
  56694. /**
  56695. * If asking to force XR, this will be populated with the default xr experience
  56696. */
  56697. xr: WebXRDefaultExperience;
  56698. /**
  56699. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  56700. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  56701. */
  56702. xrTestDone: boolean;
  56703. /**
  56704. * Instantiates a VRExperienceHelper.
  56705. * Helps to quickly add VR support to an existing scene.
  56706. * @param scene The scene the VRExperienceHelper belongs to.
  56707. * @param webVROptions Options to modify the vr experience helper's behavior.
  56708. */
  56709. constructor(scene: Scene,
  56710. /** Options to modify the vr experience helper's behavior. */
  56711. webVROptions?: VRExperienceHelperOptions);
  56712. private completeVRInit;
  56713. private _onDefaultMeshLoaded;
  56714. private _onResize;
  56715. private _onFullscreenChange;
  56716. /**
  56717. * Gets a value indicating if we are currently in VR mode.
  56718. */
  56719. get isInVRMode(): boolean;
  56720. private onVrDisplayPresentChange;
  56721. private onVRDisplayChanged;
  56722. private moveButtonToBottomRight;
  56723. private displayVRButton;
  56724. private updateButtonVisibility;
  56725. private _cachedAngularSensibility;
  56726. /**
  56727. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  56728. * Otherwise, will use the fullscreen API.
  56729. */
  56730. enterVR(): void;
  56731. /**
  56732. * Attempt to exit VR, or fullscreen.
  56733. */
  56734. exitVR(): void;
  56735. /**
  56736. * The position of the vr experience helper.
  56737. */
  56738. get position(): Vector3;
  56739. /**
  56740. * Sets the position of the vr experience helper.
  56741. */
  56742. set position(value: Vector3);
  56743. /**
  56744. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  56745. */
  56746. enableInteractions(): void;
  56747. private get _noControllerIsActive();
  56748. private beforeRender;
  56749. private _isTeleportationFloor;
  56750. /**
  56751. * Adds a floor mesh to be used for teleportation.
  56752. * @param floorMesh the mesh to be used for teleportation.
  56753. */
  56754. addFloorMesh(floorMesh: Mesh): void;
  56755. /**
  56756. * Removes a floor mesh from being used for teleportation.
  56757. * @param floorMesh the mesh to be removed.
  56758. */
  56759. removeFloorMesh(floorMesh: Mesh): void;
  56760. /**
  56761. * Enables interactions and teleportation using the VR controllers and gaze.
  56762. * @param vrTeleportationOptions options to modify teleportation behavior.
  56763. */
  56764. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  56765. private _onNewGamepadConnected;
  56766. private _tryEnableInteractionOnController;
  56767. private _onNewGamepadDisconnected;
  56768. private _enableInteractionOnController;
  56769. private _checkTeleportWithRay;
  56770. private _checkRotate;
  56771. private _checkTeleportBackwards;
  56772. private _enableTeleportationOnController;
  56773. private _createTeleportationCircles;
  56774. private _displayTeleportationTarget;
  56775. private _hideTeleportationTarget;
  56776. private _rotateCamera;
  56777. private _moveTeleportationSelectorTo;
  56778. private _workingVector;
  56779. private _workingQuaternion;
  56780. private _workingMatrix;
  56781. /**
  56782. * Time Constant Teleportation Mode
  56783. */
  56784. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  56785. /**
  56786. * Speed Constant Teleportation Mode
  56787. */
  56788. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  56789. /**
  56790. * Teleports the users feet to the desired location
  56791. * @param location The location where the user's feet should be placed
  56792. */
  56793. teleportCamera(location: Vector3): void;
  56794. private _convertNormalToDirectionOfRay;
  56795. private _castRayAndSelectObject;
  56796. private _notifySelectedMeshUnselected;
  56797. /**
  56798. * Permanently set new colors for the laser pointer
  56799. * @param color the new laser color
  56800. * @param pickedColor the new laser color when picked mesh detected
  56801. */
  56802. setLaserColor(color: Color3, pickedColor?: Color3): void;
  56803. /**
  56804. * Set lighting enabled / disabled on the laser pointer of both controllers
  56805. * @param enabled should the lighting be enabled on the laser pointer
  56806. */
  56807. setLaserLightingState(enabled?: boolean): void;
  56808. /**
  56809. * Permanently set new colors for the gaze pointer
  56810. * @param color the new gaze color
  56811. * @param pickedColor the new gaze color when picked mesh detected
  56812. */
  56813. setGazeColor(color: Color3, pickedColor?: Color3): void;
  56814. /**
  56815. * Sets the color of the laser ray from the vr controllers.
  56816. * @param color new color for the ray.
  56817. */
  56818. changeLaserColor(color: Color3): void;
  56819. /**
  56820. * Sets the color of the ray from the vr headsets gaze.
  56821. * @param color new color for the ray.
  56822. */
  56823. changeGazeColor(color: Color3): void;
  56824. /**
  56825. * Exits VR and disposes of the vr experience helper
  56826. */
  56827. dispose(): void;
  56828. /**
  56829. * Gets the name of the VRExperienceHelper class
  56830. * @returns "VRExperienceHelper"
  56831. */
  56832. getClassName(): string;
  56833. }
  56834. }
  56835. declare module BABYLON {
  56836. /**
  56837. * Contains an array of blocks representing the octree
  56838. */
  56839. export interface IOctreeContainer<T> {
  56840. /**
  56841. * Blocks within the octree
  56842. */
  56843. blocks: Array<OctreeBlock<T>>;
  56844. }
  56845. /**
  56846. * Class used to store a cell in an octree
  56847. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  56848. */
  56849. export class OctreeBlock<T> {
  56850. /**
  56851. * Gets the content of the current block
  56852. */
  56853. entries: T[];
  56854. /**
  56855. * Gets the list of block children
  56856. */
  56857. blocks: Array<OctreeBlock<T>>;
  56858. private _depth;
  56859. private _maxDepth;
  56860. private _capacity;
  56861. private _minPoint;
  56862. private _maxPoint;
  56863. private _boundingVectors;
  56864. private _creationFunc;
  56865. /**
  56866. * Creates a new block
  56867. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  56868. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  56869. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  56870. * @param depth defines the current depth of this block in the octree
  56871. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  56872. * @param creationFunc defines a callback to call when an element is added to the block
  56873. */
  56874. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  56875. /**
  56876. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  56877. */
  56878. get capacity(): number;
  56879. /**
  56880. * Gets the minimum vector (in world space) of the block's bounding box
  56881. */
  56882. get minPoint(): Vector3;
  56883. /**
  56884. * Gets the maximum vector (in world space) of the block's bounding box
  56885. */
  56886. get maxPoint(): Vector3;
  56887. /**
  56888. * Add a new element to this block
  56889. * @param entry defines the element to add
  56890. */
  56891. addEntry(entry: T): void;
  56892. /**
  56893. * Remove an element from this block
  56894. * @param entry defines the element to remove
  56895. */
  56896. removeEntry(entry: T): void;
  56897. /**
  56898. * Add an array of elements to this block
  56899. * @param entries defines the array of elements to add
  56900. */
  56901. addEntries(entries: T[]): void;
  56902. /**
  56903. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  56904. * @param frustumPlanes defines the frustum planes to test
  56905. * @param selection defines the array to store current content if selection is positive
  56906. * @param allowDuplicate defines if the selection array can contains duplicated entries
  56907. */
  56908. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  56909. /**
  56910. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  56911. * @param sphereCenter defines the bounding sphere center
  56912. * @param sphereRadius defines the bounding sphere radius
  56913. * @param selection defines the array to store current content if selection is positive
  56914. * @param allowDuplicate defines if the selection array can contains duplicated entries
  56915. */
  56916. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  56917. /**
  56918. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  56919. * @param ray defines the ray to test with
  56920. * @param selection defines the array to store current content if selection is positive
  56921. */
  56922. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  56923. /**
  56924. * Subdivide the content into child blocks (this block will then be empty)
  56925. */
  56926. createInnerBlocks(): void;
  56927. /**
  56928. * @hidden
  56929. */
  56930. 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;
  56931. }
  56932. }
  56933. declare module BABYLON {
  56934. /**
  56935. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  56936. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  56937. */
  56938. export class Octree<T> {
  56939. /** 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.) */
  56940. maxDepth: number;
  56941. /**
  56942. * Blocks within the octree containing objects
  56943. */
  56944. blocks: Array<OctreeBlock<T>>;
  56945. /**
  56946. * Content stored in the octree
  56947. */
  56948. dynamicContent: T[];
  56949. private _maxBlockCapacity;
  56950. private _selectionContent;
  56951. private _creationFunc;
  56952. /**
  56953. * Creates a octree
  56954. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  56955. * @param creationFunc function to be used to instatiate the octree
  56956. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  56957. * @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.)
  56958. */
  56959. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  56960. /** 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.) */
  56961. maxDepth?: number);
  56962. /**
  56963. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  56964. * @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);
  56965. * @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);
  56966. * @param entries meshes to be added to the octree blocks
  56967. */
  56968. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  56969. /**
  56970. * Adds a mesh to the octree
  56971. * @param entry Mesh to add to the octree
  56972. */
  56973. addMesh(entry: T): void;
  56974. /**
  56975. * Remove an element from the octree
  56976. * @param entry defines the element to remove
  56977. */
  56978. removeMesh(entry: T): void;
  56979. /**
  56980. * Selects an array of meshes within the frustum
  56981. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  56982. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  56983. * @returns array of meshes within the frustum
  56984. */
  56985. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  56986. /**
  56987. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  56988. * @param sphereCenter defines the bounding sphere center
  56989. * @param sphereRadius defines the bounding sphere radius
  56990. * @param allowDuplicate defines if the selection array can contains duplicated entries
  56991. * @returns an array of objects that intersect the sphere
  56992. */
  56993. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  56994. /**
  56995. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  56996. * @param ray defines the ray to test with
  56997. * @returns array of intersected objects
  56998. */
  56999. intersectsRay(ray: Ray): SmartArray<T>;
  57000. /**
  57001. * Adds a mesh into the octree block if it intersects the block
  57002. */
  57003. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  57004. /**
  57005. * Adds a submesh into the octree block if it intersects the block
  57006. */
  57007. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  57008. }
  57009. }
  57010. declare module BABYLON {
  57011. interface Scene {
  57012. /**
  57013. * @hidden
  57014. * Backing Filed
  57015. */
  57016. _selectionOctree: Octree<AbstractMesh>;
  57017. /**
  57018. * Gets the octree used to boost mesh selection (picking)
  57019. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  57020. */
  57021. selectionOctree: Octree<AbstractMesh>;
  57022. /**
  57023. * Creates or updates the octree used to boost selection (picking)
  57024. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  57025. * @param maxCapacity defines the maximum capacity per leaf
  57026. * @param maxDepth defines the maximum depth of the octree
  57027. * @returns an octree of AbstractMesh
  57028. */
  57029. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  57030. }
  57031. interface AbstractMesh {
  57032. /**
  57033. * @hidden
  57034. * Backing Field
  57035. */
  57036. _submeshesOctree: Octree<SubMesh>;
  57037. /**
  57038. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  57039. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  57040. * @param maxCapacity defines the maximum size of each block (64 by default)
  57041. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  57042. * @returns the new octree
  57043. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  57044. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  57045. */
  57046. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  57047. }
  57048. /**
  57049. * Defines the octree scene component responsible to manage any octrees
  57050. * in a given scene.
  57051. */
  57052. export class OctreeSceneComponent {
  57053. /**
  57054. * The component name help to identify the component in the list of scene components.
  57055. */
  57056. readonly name: string;
  57057. /**
  57058. * The scene the component belongs to.
  57059. */
  57060. scene: Scene;
  57061. /**
  57062. * Indicates if the meshes have been checked to make sure they are isEnabled()
  57063. */
  57064. readonly checksIsEnabled: boolean;
  57065. /**
  57066. * Creates a new instance of the component for the given scene
  57067. * @param scene Defines the scene to register the component in
  57068. */
  57069. constructor(scene: Scene);
  57070. /**
  57071. * Registers the component in a given scene
  57072. */
  57073. register(): void;
  57074. /**
  57075. * Return the list of active meshes
  57076. * @returns the list of active meshes
  57077. */
  57078. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  57079. /**
  57080. * Return the list of active sub meshes
  57081. * @param mesh The mesh to get the candidates sub meshes from
  57082. * @returns the list of active sub meshes
  57083. */
  57084. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  57085. private _tempRay;
  57086. /**
  57087. * Return the list of sub meshes intersecting with a given local ray
  57088. * @param mesh defines the mesh to find the submesh for
  57089. * @param localRay defines the ray in local space
  57090. * @returns the list of intersecting sub meshes
  57091. */
  57092. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  57093. /**
  57094. * Return the list of sub meshes colliding with a collider
  57095. * @param mesh defines the mesh to find the submesh for
  57096. * @param collider defines the collider to evaluate the collision against
  57097. * @returns the list of colliding sub meshes
  57098. */
  57099. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  57100. /**
  57101. * Rebuilds the elements related to this component in case of
  57102. * context lost for instance.
  57103. */
  57104. rebuild(): void;
  57105. /**
  57106. * Disposes the component and the associated ressources.
  57107. */
  57108. dispose(): void;
  57109. }
  57110. }
  57111. declare module BABYLON {
  57112. /**
  57113. * Cache built by each axis. Used for managing state between all elements of gizmo for enhanced UI
  57114. */
  57115. export interface GizmoAxisCache {
  57116. /** Mesh used to runder the Gizmo */
  57117. gizmoMeshes: Mesh[];
  57118. /** Mesh used to detect user interaction with Gizmo */
  57119. colliderMeshes: Mesh[];
  57120. /** Material used to inicate color of gizmo mesh */
  57121. material: StandardMaterial;
  57122. /** Material used to inicate hover state of the Gizmo */
  57123. hoverMaterial: StandardMaterial;
  57124. /** Material used to inicate disabled state of the Gizmo */
  57125. disableMaterial: StandardMaterial;
  57126. /** Used to indicate Active state of the Gizmo */
  57127. active: boolean;
  57128. }
  57129. /**
  57130. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  57131. */
  57132. export class Gizmo implements IDisposable {
  57133. /** The utility layer the gizmo will be added to */
  57134. gizmoLayer: UtilityLayerRenderer;
  57135. /**
  57136. * The root mesh of the gizmo
  57137. */
  57138. _rootMesh: Mesh;
  57139. private _attachedMesh;
  57140. private _attachedNode;
  57141. /**
  57142. * Ratio for the scale of the gizmo (Default: 1)
  57143. */
  57144. protected _scaleRatio: number;
  57145. /**
  57146. * boolean updated by pointermove when a gizmo mesh is hovered
  57147. */
  57148. protected _isHovered: boolean;
  57149. /**
  57150. * Ratio for the scale of the gizmo (Default: 1)
  57151. */
  57152. set scaleRatio(value: number);
  57153. get scaleRatio(): number;
  57154. /**
  57155. * True when the mouse pointer is hovered a gizmo mesh
  57156. */
  57157. get isHovered(): boolean;
  57158. /**
  57159. * If a custom mesh has been set (Default: false)
  57160. */
  57161. protected _customMeshSet: boolean;
  57162. /**
  57163. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  57164. * * When set, interactions will be enabled
  57165. */
  57166. get attachedMesh(): Nullable<AbstractMesh>;
  57167. set attachedMesh(value: Nullable<AbstractMesh>);
  57168. /**
  57169. * Node that the gizmo will be attached to. (eg. on a drag gizmo the mesh, bone or NodeTransform that will be dragged)
  57170. * * When set, interactions will be enabled
  57171. */
  57172. get attachedNode(): Nullable<Node>;
  57173. set attachedNode(value: Nullable<Node>);
  57174. /**
  57175. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  57176. * @param mesh The mesh to replace the default mesh of the gizmo
  57177. */
  57178. setCustomMesh(mesh: Mesh): void;
  57179. protected _updateGizmoRotationToMatchAttachedMesh: boolean;
  57180. /**
  57181. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  57182. */
  57183. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  57184. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  57185. /**
  57186. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  57187. */
  57188. updateGizmoPositionToMatchAttachedMesh: boolean;
  57189. /**
  57190. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  57191. */
  57192. updateScale: boolean;
  57193. protected _interactionsEnabled: boolean;
  57194. protected _attachedNodeChanged(value: Nullable<Node>): void;
  57195. private _beforeRenderObserver;
  57196. private _tempQuaternion;
  57197. private _tempVector;
  57198. private _tempVector2;
  57199. private _tempMatrix1;
  57200. private _tempMatrix2;
  57201. private _rightHandtoLeftHandMatrix;
  57202. /**
  57203. * Creates a gizmo
  57204. * @param gizmoLayer The utility layer the gizmo will be added to
  57205. */
  57206. constructor(
  57207. /** The utility layer the gizmo will be added to */
  57208. gizmoLayer?: UtilityLayerRenderer);
  57209. /**
  57210. * Updates the gizmo to match the attached mesh's position/rotation
  57211. */
  57212. protected _update(): void;
  57213. /**
  57214. * computes the rotation/scaling/position of the transform once the Node world matrix has changed.
  57215. * @param value Node, TransformNode or mesh
  57216. */
  57217. protected _matrixChanged(): void;
  57218. /**
  57219. * Subscribes to pointer up, down, and hover events. Used for responsive gizmos.
  57220. * @param gizmoLayer The utility layer the gizmo will be added to
  57221. * @param gizmoAxisCache Gizmo axis definition used for reactive gizmo UI
  57222. * @returns {Observer<PointerInfo>} pointerObserver
  57223. */
  57224. static GizmoAxisPointerObserver(gizmoLayer: UtilityLayerRenderer, gizmoAxisCache: Map<Mesh, GizmoAxisCache>): Observer<PointerInfo>;
  57225. /**
  57226. * Disposes of the gizmo
  57227. */
  57228. dispose(): void;
  57229. }
  57230. }
  57231. declare module BABYLON {
  57232. /**
  57233. * Single plane drag gizmo
  57234. */
  57235. export class PlaneDragGizmo extends Gizmo {
  57236. /**
  57237. * Drag behavior responsible for the gizmos dragging interactions
  57238. */
  57239. dragBehavior: PointerDragBehavior;
  57240. private _pointerObserver;
  57241. /**
  57242. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  57243. */
  57244. snapDistance: number;
  57245. /**
  57246. * Event that fires each time the gizmo snaps to a new location.
  57247. * * snapDistance is the the change in distance
  57248. */
  57249. onSnapObservable: Observable<{
  57250. snapDistance: number;
  57251. }>;
  57252. private _gizmoMesh;
  57253. private _coloredMaterial;
  57254. private _hoverMaterial;
  57255. private _disableMaterial;
  57256. private _isEnabled;
  57257. private _parent;
  57258. private _dragging;
  57259. /** @hidden */
  57260. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  57261. /**
  57262. * Creates a PlaneDragGizmo
  57263. * @param gizmoLayer The utility layer the gizmo will be added to
  57264. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  57265. * @param color The color of the gizmo
  57266. */
  57267. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  57268. protected _attachedNodeChanged(value: Nullable<Node>): void;
  57269. /**
  57270. * If the gizmo is enabled
  57271. */
  57272. set isEnabled(value: boolean);
  57273. get isEnabled(): boolean;
  57274. /**
  57275. * Disposes of the gizmo
  57276. */
  57277. dispose(): void;
  57278. }
  57279. }
  57280. declare module BABYLON {
  57281. /**
  57282. * Single plane rotation gizmo
  57283. */
  57284. export class PlaneRotationGizmo extends Gizmo {
  57285. /**
  57286. * Drag behavior responsible for the gizmos dragging interactions
  57287. */
  57288. dragBehavior: PointerDragBehavior;
  57289. private _pointerObserver;
  57290. /**
  57291. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  57292. */
  57293. snapDistance: number;
  57294. /**
  57295. * Event that fires each time the gizmo snaps to a new location.
  57296. * * snapDistance is the the change in distance
  57297. */
  57298. onSnapObservable: Observable<{
  57299. snapDistance: number;
  57300. }>;
  57301. private _isEnabled;
  57302. private _parent;
  57303. private _coloredMaterial;
  57304. private _hoverMaterial;
  57305. private _disableMaterial;
  57306. private _gizmoMesh;
  57307. private _rotationCircle;
  57308. private _dragging;
  57309. private static _CircleConstants;
  57310. /**
  57311. * Creates a PlaneRotationGizmo
  57312. * @param gizmoLayer The utility layer the gizmo will be added to
  57313. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  57314. * @param color The color of the gizmo
  57315. * @param tessellation Amount of tessellation to be used when creating rotation circles
  57316. * @param useEulerRotation Use and update Euler angle instead of quaternion
  57317. * @param thickness display gizmo axis thickness
  57318. */
  57319. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean, thickness?: number);
  57320. /** Create Geometry for Gizmo */
  57321. private _createGizmoMesh;
  57322. protected _attachedNodeChanged(value: Nullable<Node>): void;
  57323. private setupRotationCircle;
  57324. private updateRotationPath;
  57325. private updateRotationCircle;
  57326. /**
  57327. * If the gizmo is enabled
  57328. */
  57329. set isEnabled(value: boolean);
  57330. get isEnabled(): boolean;
  57331. /**
  57332. * Disposes of the gizmo
  57333. */
  57334. dispose(): void;
  57335. }
  57336. }
  57337. declare module BABYLON {
  57338. /**
  57339. * Gizmo that enables rotating a mesh along 3 axis
  57340. */
  57341. export class RotationGizmo extends Gizmo {
  57342. /**
  57343. * Internal gizmo used for interactions on the x axis
  57344. */
  57345. xGizmo: PlaneRotationGizmo;
  57346. /**
  57347. * Internal gizmo used for interactions on the y axis
  57348. */
  57349. yGizmo: PlaneRotationGizmo;
  57350. /**
  57351. * Internal gizmo used for interactions on the z axis
  57352. */
  57353. zGizmo: PlaneRotationGizmo;
  57354. /** Fires an event when any of it's sub gizmos are dragged */
  57355. onDragStartObservable: Observable<unknown>;
  57356. /** Fires an event when any of it's sub gizmos are released from dragging */
  57357. onDragEndObservable: Observable<unknown>;
  57358. private _meshAttached;
  57359. private _nodeAttached;
  57360. private _observables;
  57361. /** Node Caching for quick lookup */
  57362. private _gizmoAxisCache;
  57363. get attachedMesh(): Nullable<AbstractMesh>;
  57364. set attachedMesh(mesh: Nullable<AbstractMesh>);
  57365. get attachedNode(): Nullable<Node>;
  57366. set attachedNode(node: Nullable<Node>);
  57367. protected _checkBillboardTransform(): void;
  57368. /**
  57369. * True when the mouse pointer is hovering a gizmo mesh
  57370. */
  57371. get isHovered(): boolean;
  57372. /**
  57373. * Creates a RotationGizmo
  57374. * @param gizmoLayer The utility layer the gizmo will be added to
  57375. * @param tessellation Amount of tessellation to be used when creating rotation circles
  57376. * @param useEulerRotation Use and update Euler angle instead of quaternion
  57377. * @param thickness display gizmo axis thickness
  57378. */
  57379. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean, thickness?: number, gizmoManager?: GizmoManager);
  57380. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  57381. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  57382. /**
  57383. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  57384. */
  57385. set snapDistance(value: number);
  57386. get snapDistance(): number;
  57387. /**
  57388. * Ratio for the scale of the gizmo (Default: 1)
  57389. */
  57390. set scaleRatio(value: number);
  57391. get scaleRatio(): number;
  57392. /**
  57393. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  57394. * @param mesh Axis gizmo mesh
  57395. * @param cache Gizmo axis definition used for reactive gizmo UI
  57396. */
  57397. addToAxisCache(mesh: Mesh, cache: GizmoAxisCache): void;
  57398. /**
  57399. * Disposes of the gizmo
  57400. */
  57401. dispose(): void;
  57402. /**
  57403. * CustomMeshes are not supported by this gizmo
  57404. * @param mesh The mesh to replace the default mesh of the gizmo
  57405. */
  57406. setCustomMesh(mesh: Mesh): void;
  57407. }
  57408. }
  57409. declare module BABYLON {
  57410. /**
  57411. * Class containing static functions to help procedurally build meshes
  57412. */
  57413. export class PolyhedronBuilder {
  57414. /**
  57415. * Creates a polyhedron mesh
  57416. * * 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
  57417. * * The parameter `size` (positive float, default 1) sets the polygon size
  57418. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  57419. * * 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`
  57420. * * 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
  57421. * * 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)`)
  57422. * * 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
  57423. * * 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
  57424. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57425. * * 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
  57426. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57427. * @param name defines the name of the mesh
  57428. * @param options defines the options used to create the mesh
  57429. * @param scene defines the hosting scene
  57430. * @returns the polyhedron mesh
  57431. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  57432. */
  57433. static CreatePolyhedron(name: string, options: {
  57434. type?: number;
  57435. size?: number;
  57436. sizeX?: number;
  57437. sizeY?: number;
  57438. sizeZ?: number;
  57439. custom?: any;
  57440. faceUV?: Vector4[];
  57441. faceColors?: Color4[];
  57442. flat?: boolean;
  57443. updatable?: boolean;
  57444. sideOrientation?: number;
  57445. frontUVs?: Vector4;
  57446. backUVs?: Vector4;
  57447. }, scene?: Nullable<Scene>): Mesh;
  57448. }
  57449. }
  57450. declare module BABYLON {
  57451. /**
  57452. * Class containing static functions to help procedurally build meshes
  57453. */
  57454. export class BoxBuilder {
  57455. /**
  57456. * Creates a box mesh
  57457. * * The parameter `size` sets the size (float) of each box side (default 1)
  57458. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  57459. * * 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)
  57460. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  57461. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57462. * * 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
  57463. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57464. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  57465. * @param name defines the name of the mesh
  57466. * @param options defines the options used to create the mesh
  57467. * @param scene defines the hosting scene
  57468. * @returns the box mesh
  57469. */
  57470. static CreateBox(name: string, options: {
  57471. size?: number;
  57472. width?: number;
  57473. height?: number;
  57474. depth?: number;
  57475. faceUV?: Vector4[];
  57476. faceColors?: Color4[];
  57477. sideOrientation?: number;
  57478. frontUVs?: Vector4;
  57479. backUVs?: Vector4;
  57480. wrap?: boolean;
  57481. topBaseAt?: number;
  57482. bottomBaseAt?: number;
  57483. updatable?: boolean;
  57484. }, scene?: Nullable<Scene>): Mesh;
  57485. }
  57486. }
  57487. declare module BABYLON {
  57488. /**
  57489. * Single axis scale gizmo
  57490. */
  57491. export class AxisScaleGizmo extends Gizmo {
  57492. /**
  57493. * Drag behavior responsible for the gizmos dragging interactions
  57494. */
  57495. dragBehavior: PointerDragBehavior;
  57496. private _pointerObserver;
  57497. /**
  57498. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  57499. */
  57500. snapDistance: number;
  57501. /**
  57502. * Event that fires each time the gizmo snaps to a new location.
  57503. * * snapDistance is the the change in distance
  57504. */
  57505. onSnapObservable: Observable<{
  57506. snapDistance: number;
  57507. }>;
  57508. /**
  57509. * If the scaling operation should be done on all axis (default: false)
  57510. */
  57511. uniformScaling: boolean;
  57512. /**
  57513. * Custom sensitivity value for the drag strength
  57514. */
  57515. sensitivity: number;
  57516. private _isEnabled;
  57517. private _parent;
  57518. private _gizmoMesh;
  57519. private _coloredMaterial;
  57520. private _hoverMaterial;
  57521. private _disableMaterial;
  57522. private _dragging;
  57523. private _tmpVector;
  57524. private _tmpMatrix;
  57525. private _tmpMatrix2;
  57526. /**
  57527. * Creates an AxisScaleGizmo
  57528. * @param gizmoLayer The utility layer the gizmo will be added to
  57529. * @param dragAxis The axis which the gizmo will be able to scale on
  57530. * @param color The color of the gizmo
  57531. * @param thickness display gizmo axis thickness
  57532. */
  57533. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>, thickness?: number);
  57534. /** Create Geometry for Gizmo */
  57535. private _createGizmoMesh;
  57536. protected _attachedNodeChanged(value: Nullable<Node>): void;
  57537. /**
  57538. * If the gizmo is enabled
  57539. */
  57540. set isEnabled(value: boolean);
  57541. get isEnabled(): boolean;
  57542. /**
  57543. * Disposes of the gizmo
  57544. */
  57545. dispose(): void;
  57546. /**
  57547. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  57548. * @param mesh The mesh to replace the default mesh of the gizmo
  57549. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  57550. */
  57551. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  57552. }
  57553. }
  57554. declare module BABYLON {
  57555. /**
  57556. * Gizmo that enables scaling a mesh along 3 axis
  57557. */
  57558. export class ScaleGizmo extends Gizmo {
  57559. /**
  57560. * Internal gizmo used for interactions on the x axis
  57561. */
  57562. xGizmo: AxisScaleGizmo;
  57563. /**
  57564. * Internal gizmo used for interactions on the y axis
  57565. */
  57566. yGizmo: AxisScaleGizmo;
  57567. /**
  57568. * Internal gizmo used for interactions on the z axis
  57569. */
  57570. zGizmo: AxisScaleGizmo;
  57571. /**
  57572. * Internal gizmo used to scale all axis equally
  57573. */
  57574. uniformScaleGizmo: AxisScaleGizmo;
  57575. private _meshAttached;
  57576. private _nodeAttached;
  57577. private _snapDistance;
  57578. private _uniformScalingMesh;
  57579. private _octahedron;
  57580. private _sensitivity;
  57581. private _coloredMaterial;
  57582. private _hoverMaterial;
  57583. private _disableMaterial;
  57584. private _observables;
  57585. /** Node Caching for quick lookup */
  57586. private _gizmoAxisCache;
  57587. /** Fires an event when any of it's sub gizmos are dragged */
  57588. onDragStartObservable: Observable<unknown>;
  57589. /** Fires an event when any of it's sub gizmos are released from dragging */
  57590. onDragEndObservable: Observable<unknown>;
  57591. get attachedMesh(): Nullable<AbstractMesh>;
  57592. set attachedMesh(mesh: Nullable<AbstractMesh>);
  57593. get attachedNode(): Nullable<Node>;
  57594. set attachedNode(node: Nullable<Node>);
  57595. /**
  57596. * True when the mouse pointer is hovering a gizmo mesh
  57597. */
  57598. get isHovered(): boolean;
  57599. /**
  57600. * Creates a ScaleGizmo
  57601. * @param gizmoLayer The utility layer the gizmo will be added to
  57602. * @param thickness display gizmo axis thickness
  57603. */
  57604. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number, gizmoManager?: GizmoManager);
  57605. /** Create Geometry for Gizmo */
  57606. private _createUniformScaleMesh;
  57607. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  57608. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  57609. /**
  57610. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  57611. */
  57612. set snapDistance(value: number);
  57613. get snapDistance(): number;
  57614. /**
  57615. * Ratio for the scale of the gizmo (Default: 1)
  57616. */
  57617. set scaleRatio(value: number);
  57618. get scaleRatio(): number;
  57619. /**
  57620. * Sensitivity factor for dragging (Default: 1)
  57621. */
  57622. set sensitivity(value: number);
  57623. get sensitivity(): number;
  57624. /**
  57625. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  57626. * @param mesh Axis gizmo mesh
  57627. * @param cache Gizmo axis definition used for reactive gizmo UI
  57628. */
  57629. addToAxisCache(mesh: Mesh, cache: GizmoAxisCache): void;
  57630. /**
  57631. * Disposes of the gizmo
  57632. */
  57633. dispose(): void;
  57634. }
  57635. }
  57636. declare module BABYLON {
  57637. /**
  57638. * Bounding box gizmo
  57639. */
  57640. export class BoundingBoxGizmo extends Gizmo {
  57641. private _lineBoundingBox;
  57642. private _rotateSpheresParent;
  57643. private _scaleBoxesParent;
  57644. private _boundingDimensions;
  57645. private _renderObserver;
  57646. private _pointerObserver;
  57647. private _scaleDragSpeed;
  57648. private _tmpQuaternion;
  57649. private _tmpVector;
  57650. private _tmpRotationMatrix;
  57651. /**
  57652. * 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)
  57653. */
  57654. ignoreChildren: boolean;
  57655. /**
  57656. * 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)
  57657. */
  57658. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  57659. /**
  57660. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  57661. */
  57662. rotationSphereSize: number;
  57663. /**
  57664. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  57665. */
  57666. scaleBoxSize: number;
  57667. /**
  57668. * 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)
  57669. * Note : fixedDragMeshScreenSize takes precedence over fixedDragMeshBoundsSize if both are true
  57670. */
  57671. fixedDragMeshScreenSize: boolean;
  57672. /**
  57673. * If set, the rotation spheres and scale boxes will increase in size based on the size of the bounding box
  57674. * Note : fixedDragMeshScreenSize takes precedence over fixedDragMeshBoundsSize if both are true
  57675. */
  57676. fixedDragMeshBoundsSize: boolean;
  57677. /**
  57678. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  57679. */
  57680. fixedDragMeshScreenSizeDistanceFactor: number;
  57681. /**
  57682. * Fired when a rotation sphere or scale box is dragged
  57683. */
  57684. onDragStartObservable: Observable<{}>;
  57685. /**
  57686. * Fired when a scale box is dragged
  57687. */
  57688. onScaleBoxDragObservable: Observable<{}>;
  57689. /**
  57690. * Fired when a scale box drag is ended
  57691. */
  57692. onScaleBoxDragEndObservable: Observable<{}>;
  57693. /**
  57694. * Fired when a rotation sphere is dragged
  57695. */
  57696. onRotationSphereDragObservable: Observable<{}>;
  57697. /**
  57698. * Fired when a rotation sphere drag is ended
  57699. */
  57700. onRotationSphereDragEndObservable: Observable<{}>;
  57701. /**
  57702. * 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)
  57703. */
  57704. scalePivot: Nullable<Vector3>;
  57705. /**
  57706. * Mesh used as a pivot to rotate the attached node
  57707. */
  57708. private _anchorMesh;
  57709. private _existingMeshScale;
  57710. private _dragMesh;
  57711. private pointerDragBehavior;
  57712. private coloredMaterial;
  57713. private hoverColoredMaterial;
  57714. /**
  57715. * Sets the color of the bounding box gizmo
  57716. * @param color the color to set
  57717. */
  57718. setColor(color: Color3): void;
  57719. /**
  57720. * Creates an BoundingBoxGizmo
  57721. * @param gizmoLayer The utility layer the gizmo will be added to
  57722. * @param color The color of the gizmo
  57723. */
  57724. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  57725. protected _attachedNodeChanged(value: Nullable<AbstractMesh>): void;
  57726. private _selectNode;
  57727. /**
  57728. * Updates the bounding box information for the Gizmo
  57729. */
  57730. updateBoundingBox(): void;
  57731. private _updateRotationSpheres;
  57732. private _updateScaleBoxes;
  57733. /**
  57734. * Enables rotation on the specified axis and disables rotation on the others
  57735. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  57736. */
  57737. setEnabledRotationAxis(axis: string): void;
  57738. /**
  57739. * Enables/disables scaling
  57740. * @param enable if scaling should be enabled
  57741. * @param homogeneousScaling defines if scaling should only be homogeneous
  57742. */
  57743. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  57744. private _updateDummy;
  57745. /**
  57746. * Enables a pointer drag behavior on the bounding box of the gizmo
  57747. */
  57748. enableDragBehavior(): void;
  57749. /**
  57750. * Disposes of the gizmo
  57751. */
  57752. dispose(): void;
  57753. /**
  57754. * 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)
  57755. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  57756. * @returns the bounding box mesh with the passed in mesh as a child
  57757. */
  57758. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  57759. /**
  57760. * CustomMeshes are not supported by this gizmo
  57761. * @param mesh The mesh to replace the default mesh of the gizmo
  57762. */
  57763. setCustomMesh(mesh: Mesh): void;
  57764. }
  57765. }
  57766. declare module BABYLON {
  57767. /**
  57768. * Helps setup gizmo's in the scene to rotate/scale/position nodes
  57769. */
  57770. export class GizmoManager implements IDisposable {
  57771. private scene;
  57772. /**
  57773. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  57774. */
  57775. gizmos: {
  57776. positionGizmo: Nullable<PositionGizmo>;
  57777. rotationGizmo: Nullable<RotationGizmo>;
  57778. scaleGizmo: Nullable<ScaleGizmo>;
  57779. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  57780. };
  57781. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  57782. clearGizmoOnEmptyPointerEvent: boolean;
  57783. /** Fires an event when the manager is attached to a mesh */
  57784. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  57785. /** Fires an event when the manager is attached to a node */
  57786. onAttachedToNodeObservable: Observable<Nullable<Node>>;
  57787. private _gizmosEnabled;
  57788. private _pointerObservers;
  57789. private _attachedMesh;
  57790. private _attachedNode;
  57791. private _boundingBoxColor;
  57792. private _defaultUtilityLayer;
  57793. private _defaultKeepDepthUtilityLayer;
  57794. private _thickness;
  57795. /** Node Caching for quick lookup */
  57796. private _gizmoAxisCache;
  57797. /**
  57798. * When bounding box gizmo is enabled, this can be used to track drag/end events
  57799. */
  57800. boundingBoxDragBehavior: SixDofDragBehavior;
  57801. /**
  57802. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  57803. */
  57804. attachableMeshes: Nullable<Array<AbstractMesh>>;
  57805. /**
  57806. * Array of nodes which will have the gizmo attached when a pointer selected them. If null, all nodes are attachable. (Default: null)
  57807. */
  57808. attachableNodes: Nullable<Array<Node>>;
  57809. /**
  57810. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh/attachToNode. (Default: true)
  57811. */
  57812. usePointerToAttachGizmos: boolean;
  57813. /**
  57814. * Utility layer that the bounding box gizmo belongs to
  57815. */
  57816. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  57817. /**
  57818. * Utility layer that all gizmos besides bounding box belong to
  57819. */
  57820. get utilityLayer(): UtilityLayerRenderer;
  57821. /**
  57822. * True when the mouse pointer is hovering a gizmo mesh
  57823. */
  57824. get isHovered(): boolean;
  57825. /**
  57826. * Instatiates a gizmo manager
  57827. * @param scene the scene to overlay the gizmos on top of
  57828. * @param thickness display gizmo axis thickness
  57829. * @param utilityLayer the layer where gizmos are rendered
  57830. * @param keepDepthUtilityLayer the layer where occluded gizmos are rendered
  57831. */
  57832. constructor(scene: Scene, thickness?: number, utilityLayer?: UtilityLayerRenderer, keepDepthUtilityLayer?: UtilityLayerRenderer);
  57833. /**
  57834. * Subscribes to pointer down events, for attaching and detaching mesh
  57835. * @param scene The sceme layer the observer will be added to
  57836. */
  57837. private _attachToMeshPointerObserver;
  57838. /**
  57839. * Attaches a set of gizmos to the specified mesh
  57840. * @param mesh The mesh the gizmo's should be attached to
  57841. */
  57842. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  57843. /**
  57844. * Attaches a set of gizmos to the specified node
  57845. * @param node The node the gizmo's should be attached to
  57846. */
  57847. attachToNode(node: Nullable<Node>): void;
  57848. /**
  57849. * If the position gizmo is enabled
  57850. */
  57851. set positionGizmoEnabled(value: boolean);
  57852. get positionGizmoEnabled(): boolean;
  57853. /**
  57854. * If the rotation gizmo is enabled
  57855. */
  57856. set rotationGizmoEnabled(value: boolean);
  57857. get rotationGizmoEnabled(): boolean;
  57858. /**
  57859. * If the scale gizmo is enabled
  57860. */
  57861. set scaleGizmoEnabled(value: boolean);
  57862. get scaleGizmoEnabled(): boolean;
  57863. /**
  57864. * If the boundingBox gizmo is enabled
  57865. */
  57866. set boundingBoxGizmoEnabled(value: boolean);
  57867. get boundingBoxGizmoEnabled(): boolean;
  57868. /**
  57869. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  57870. * @param gizmoAxisCache Gizmo axis definition used for reactive gizmo UI
  57871. */
  57872. addToAxisCache(gizmoAxisCache: Map<Mesh, GizmoAxisCache>): void;
  57873. /**
  57874. * Disposes of the gizmo manager
  57875. */
  57876. dispose(): void;
  57877. }
  57878. }
  57879. declare module BABYLON {
  57880. /**
  57881. * Gizmo that enables dragging a mesh along 3 axis
  57882. */
  57883. export class PositionGizmo extends Gizmo {
  57884. /**
  57885. * Internal gizmo used for interactions on the x axis
  57886. */
  57887. xGizmo: AxisDragGizmo;
  57888. /**
  57889. * Internal gizmo used for interactions on the y axis
  57890. */
  57891. yGizmo: AxisDragGizmo;
  57892. /**
  57893. * Internal gizmo used for interactions on the z axis
  57894. */
  57895. zGizmo: AxisDragGizmo;
  57896. /**
  57897. * Internal gizmo used for interactions on the yz plane
  57898. */
  57899. xPlaneGizmo: PlaneDragGizmo;
  57900. /**
  57901. * Internal gizmo used for interactions on the xz plane
  57902. */
  57903. yPlaneGizmo: PlaneDragGizmo;
  57904. /**
  57905. * Internal gizmo used for interactions on the xy plane
  57906. */
  57907. zPlaneGizmo: PlaneDragGizmo;
  57908. /**
  57909. * private variables
  57910. */
  57911. private _meshAttached;
  57912. private _nodeAttached;
  57913. private _snapDistance;
  57914. private _observables;
  57915. /** Node Caching for quick lookup */
  57916. private _gizmoAxisCache;
  57917. /** Fires an event when any of it's sub gizmos are dragged */
  57918. onDragStartObservable: Observable<unknown>;
  57919. /** Fires an event when any of it's sub gizmos are released from dragging */
  57920. onDragEndObservable: Observable<unknown>;
  57921. /**
  57922. * If set to true, planar drag is enabled
  57923. */
  57924. private _planarGizmoEnabled;
  57925. get attachedMesh(): Nullable<AbstractMesh>;
  57926. set attachedMesh(mesh: Nullable<AbstractMesh>);
  57927. get attachedNode(): Nullable<Node>;
  57928. set attachedNode(node: Nullable<Node>);
  57929. /**
  57930. * True when the mouse pointer is hovering a gizmo mesh
  57931. */
  57932. get isHovered(): boolean;
  57933. /**
  57934. * Creates a PositionGizmo
  57935. * @param gizmoLayer The utility layer the gizmo will be added to
  57936. @param thickness display gizmo axis thickness
  57937. */
  57938. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number, gizmoManager?: GizmoManager);
  57939. /**
  57940. * If the planar drag gizmo is enabled
  57941. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  57942. */
  57943. set planarGizmoEnabled(value: boolean);
  57944. get planarGizmoEnabled(): boolean;
  57945. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  57946. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  57947. /**
  57948. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  57949. */
  57950. set snapDistance(value: number);
  57951. get snapDistance(): number;
  57952. /**
  57953. * Ratio for the scale of the gizmo (Default: 1)
  57954. */
  57955. set scaleRatio(value: number);
  57956. get scaleRatio(): number;
  57957. /**
  57958. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  57959. * @param mesh Axis gizmo mesh
  57960. * @param cache Gizmo axis definition used for reactive gizmo UI
  57961. */
  57962. addToAxisCache(mesh: Mesh, cache: GizmoAxisCache): void;
  57963. /**
  57964. * Disposes of the gizmo
  57965. */
  57966. dispose(): void;
  57967. /**
  57968. * CustomMeshes are not supported by this gizmo
  57969. * @param mesh The mesh to replace the default mesh of the gizmo
  57970. */
  57971. setCustomMesh(mesh: Mesh): void;
  57972. }
  57973. }
  57974. declare module BABYLON {
  57975. /**
  57976. * Single axis drag gizmo
  57977. */
  57978. export class AxisDragGizmo extends Gizmo {
  57979. /**
  57980. * Drag behavior responsible for the gizmos dragging interactions
  57981. */
  57982. dragBehavior: PointerDragBehavior;
  57983. private _pointerObserver;
  57984. /**
  57985. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  57986. */
  57987. snapDistance: number;
  57988. /**
  57989. * Event that fires each time the gizmo snaps to a new location.
  57990. * * snapDistance is the the change in distance
  57991. */
  57992. onSnapObservable: Observable<{
  57993. snapDistance: number;
  57994. }>;
  57995. private _isEnabled;
  57996. private _parent;
  57997. private _gizmoMesh;
  57998. private _coloredMaterial;
  57999. private _hoverMaterial;
  58000. private _disableMaterial;
  58001. private _dragging;
  58002. /** @hidden */
  58003. static _CreateArrow(scene: Scene, material: StandardMaterial, thickness?: number, isCollider?: boolean): TransformNode;
  58004. /** @hidden */
  58005. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  58006. /**
  58007. * Creates an AxisDragGizmo
  58008. * @param gizmoLayer The utility layer the gizmo will be added to
  58009. * @param dragAxis The axis which the gizmo will be able to drag on
  58010. * @param color The color of the gizmo
  58011. * @param thickness display gizmo axis thickness
  58012. */
  58013. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>, thickness?: number);
  58014. protected _attachedNodeChanged(value: Nullable<Node>): void;
  58015. /**
  58016. * If the gizmo is enabled
  58017. */
  58018. set isEnabled(value: boolean);
  58019. get isEnabled(): boolean;
  58020. /**
  58021. * Disposes of the gizmo
  58022. */
  58023. dispose(): void;
  58024. }
  58025. }
  58026. declare module BABYLON.Debug {
  58027. /**
  58028. * The Axes viewer will show 3 axes in a specific point in space
  58029. */
  58030. export class AxesViewer {
  58031. private _xAxis;
  58032. private _yAxis;
  58033. private _zAxis;
  58034. private _scaleLinesFactor;
  58035. private _instanced;
  58036. /**
  58037. * Gets the hosting scene
  58038. */
  58039. scene: Nullable<Scene>;
  58040. /**
  58041. * Gets or sets a number used to scale line length
  58042. */
  58043. scaleLines: number;
  58044. /** Gets the node hierarchy used to render x-axis */
  58045. get xAxis(): TransformNode;
  58046. /** Gets the node hierarchy used to render y-axis */
  58047. get yAxis(): TransformNode;
  58048. /** Gets the node hierarchy used to render z-axis */
  58049. get zAxis(): TransformNode;
  58050. /**
  58051. * Creates a new AxesViewer
  58052. * @param scene defines the hosting scene
  58053. * @param scaleLines defines a number used to scale line length (1 by default)
  58054. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  58055. * @param xAxis defines the node hierarchy used to render the x-axis
  58056. * @param yAxis defines the node hierarchy used to render the y-axis
  58057. * @param zAxis defines the node hierarchy used to render the z-axis
  58058. */
  58059. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  58060. /**
  58061. * Force the viewer to update
  58062. * @param position defines the position of the viewer
  58063. * @param xaxis defines the x axis of the viewer
  58064. * @param yaxis defines the y axis of the viewer
  58065. * @param zaxis defines the z axis of the viewer
  58066. */
  58067. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  58068. /**
  58069. * Creates an instance of this axes viewer.
  58070. * @returns a new axes viewer with instanced meshes
  58071. */
  58072. createInstance(): AxesViewer;
  58073. /** Releases resources */
  58074. dispose(): void;
  58075. private static _SetRenderingGroupId;
  58076. }
  58077. }
  58078. declare module BABYLON.Debug {
  58079. /**
  58080. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  58081. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  58082. */
  58083. export class BoneAxesViewer extends AxesViewer {
  58084. /**
  58085. * Gets or sets the target mesh where to display the axes viewer
  58086. */
  58087. mesh: Nullable<Mesh>;
  58088. /**
  58089. * Gets or sets the target bone where to display the axes viewer
  58090. */
  58091. bone: Nullable<Bone>;
  58092. /** Gets current position */
  58093. pos: Vector3;
  58094. /** Gets direction of X axis */
  58095. xaxis: Vector3;
  58096. /** Gets direction of Y axis */
  58097. yaxis: Vector3;
  58098. /** Gets direction of Z axis */
  58099. zaxis: Vector3;
  58100. /**
  58101. * Creates a new BoneAxesViewer
  58102. * @param scene defines the hosting scene
  58103. * @param bone defines the target bone
  58104. * @param mesh defines the target mesh
  58105. * @param scaleLines defines a scaling factor for line length (1 by default)
  58106. */
  58107. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  58108. /**
  58109. * Force the viewer to update
  58110. */
  58111. update(): void;
  58112. /** Releases resources */
  58113. dispose(): void;
  58114. }
  58115. }
  58116. declare module BABYLON {
  58117. /**
  58118. * Interface used to define scene explorer extensibility option
  58119. */
  58120. export interface IExplorerExtensibilityOption {
  58121. /**
  58122. * Define the option label
  58123. */
  58124. label: string;
  58125. /**
  58126. * Defines the action to execute on click
  58127. */
  58128. action: (entity: any) => void;
  58129. }
  58130. /**
  58131. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  58132. */
  58133. export interface IExplorerExtensibilityGroup {
  58134. /**
  58135. * Defines a predicate to test if a given type mut be extended
  58136. */
  58137. predicate: (entity: any) => boolean;
  58138. /**
  58139. * Gets the list of options added to a type
  58140. */
  58141. entries: IExplorerExtensibilityOption[];
  58142. }
  58143. /**
  58144. * Interface used to define the options to use to create the Inspector
  58145. */
  58146. export interface IInspectorOptions {
  58147. /**
  58148. * Display in overlay mode (default: false)
  58149. */
  58150. overlay?: boolean;
  58151. /**
  58152. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  58153. */
  58154. globalRoot?: HTMLElement;
  58155. /**
  58156. * Display the Scene explorer
  58157. */
  58158. showExplorer?: boolean;
  58159. /**
  58160. * Display the property inspector
  58161. */
  58162. showInspector?: boolean;
  58163. /**
  58164. * Display in embed mode (both panes on the right)
  58165. */
  58166. embedMode?: boolean;
  58167. /**
  58168. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  58169. */
  58170. handleResize?: boolean;
  58171. /**
  58172. * Allow the panes to popup (default: true)
  58173. */
  58174. enablePopup?: boolean;
  58175. /**
  58176. * Allow the panes to be closed by users (default: true)
  58177. */
  58178. enableClose?: boolean;
  58179. /**
  58180. * Optional list of extensibility entries
  58181. */
  58182. explorerExtensibility?: IExplorerExtensibilityGroup[];
  58183. /**
  58184. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  58185. */
  58186. inspectorURL?: string;
  58187. /**
  58188. * Optional initial tab (default to DebugLayerTab.Properties)
  58189. */
  58190. initialTab?: DebugLayerTab;
  58191. }
  58192. interface Scene {
  58193. /**
  58194. * @hidden
  58195. * Backing field
  58196. */
  58197. _debugLayer: DebugLayer;
  58198. /**
  58199. * Gets the debug layer (aka Inspector) associated with the scene
  58200. * @see https://doc.babylonjs.com/features/playground_debuglayer
  58201. */
  58202. debugLayer: DebugLayer;
  58203. }
  58204. /**
  58205. * Enum of inspector action tab
  58206. */
  58207. export enum DebugLayerTab {
  58208. /**
  58209. * Properties tag (default)
  58210. */
  58211. Properties = 0,
  58212. /**
  58213. * Debug tab
  58214. */
  58215. Debug = 1,
  58216. /**
  58217. * Statistics tab
  58218. */
  58219. Statistics = 2,
  58220. /**
  58221. * Tools tab
  58222. */
  58223. Tools = 3,
  58224. /**
  58225. * Settings tab
  58226. */
  58227. Settings = 4
  58228. }
  58229. /**
  58230. * The debug layer (aka Inspector) is the go to tool in order to better understand
  58231. * what is happening in your scene
  58232. * @see https://doc.babylonjs.com/features/playground_debuglayer
  58233. */
  58234. export class DebugLayer {
  58235. /**
  58236. * Define the url to get the inspector script from.
  58237. * By default it uses the babylonjs CDN.
  58238. * @ignoreNaming
  58239. */
  58240. static InspectorURL: string;
  58241. private _scene;
  58242. private BJSINSPECTOR;
  58243. private _onPropertyChangedObservable?;
  58244. /**
  58245. * Observable triggered when a property is changed through the inspector.
  58246. */
  58247. get onPropertyChangedObservable(): any;
  58248. /**
  58249. * Instantiates a new debug layer.
  58250. * The debug layer (aka Inspector) is the go to tool in order to better understand
  58251. * what is happening in your scene
  58252. * @see https://doc.babylonjs.com/features/playground_debuglayer
  58253. * @param scene Defines the scene to inspect
  58254. */
  58255. constructor(scene: Scene);
  58256. /** Creates the inspector window. */
  58257. private _createInspector;
  58258. /**
  58259. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  58260. * @param entity defines the entity to select
  58261. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  58262. */
  58263. select(entity: any, lineContainerTitles?: string | string[]): void;
  58264. /** Get the inspector from bundle or global */
  58265. private _getGlobalInspector;
  58266. /**
  58267. * Get if the inspector is visible or not.
  58268. * @returns true if visible otherwise, false
  58269. */
  58270. isVisible(): boolean;
  58271. /**
  58272. * Hide the inspector and close its window.
  58273. */
  58274. hide(): void;
  58275. /**
  58276. * Update the scene in the inspector
  58277. */
  58278. setAsActiveScene(): void;
  58279. /**
  58280. * Launch the debugLayer.
  58281. * @param config Define the configuration of the inspector
  58282. * @return a promise fulfilled when the debug layer is visible
  58283. */
  58284. show(config?: IInspectorOptions): Promise<DebugLayer>;
  58285. }
  58286. }
  58287. declare module BABYLON.Debug {
  58288. /**
  58289. * Used to show the physics impostor around the specific mesh
  58290. */
  58291. export class PhysicsViewer {
  58292. /** @hidden */
  58293. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  58294. /** @hidden */
  58295. protected _meshes: Array<Nullable<AbstractMesh>>;
  58296. /** @hidden */
  58297. protected _scene: Nullable<Scene>;
  58298. /** @hidden */
  58299. protected _numMeshes: number;
  58300. /** @hidden */
  58301. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  58302. private _renderFunction;
  58303. private _utilityLayer;
  58304. private _debugBoxMesh;
  58305. private _debugSphereMesh;
  58306. private _debugCylinderMesh;
  58307. private _debugMaterial;
  58308. private _debugMeshMeshes;
  58309. /**
  58310. * Creates a new PhysicsViewer
  58311. * @param scene defines the hosting scene
  58312. */
  58313. constructor(scene: Scene);
  58314. /** @hidden */
  58315. protected _updateDebugMeshes(): void;
  58316. /**
  58317. * Renders a specified physic impostor
  58318. * @param impostor defines the impostor to render
  58319. * @param targetMesh defines the mesh represented by the impostor
  58320. * @returns the new debug mesh used to render the impostor
  58321. */
  58322. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  58323. /**
  58324. * Hides a specified physic impostor
  58325. * @param impostor defines the impostor to hide
  58326. */
  58327. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  58328. private _getDebugMaterial;
  58329. private _getDebugBoxMesh;
  58330. private _getDebugSphereMesh;
  58331. private _getDebugCylinderMesh;
  58332. private _getDebugMeshMesh;
  58333. private _getDebugMesh;
  58334. /** Releases all resources */
  58335. dispose(): void;
  58336. }
  58337. }
  58338. declare module BABYLON {
  58339. /**
  58340. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  58341. * in order to better appreciate the issue one might have.
  58342. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  58343. */
  58344. export class RayHelper {
  58345. /**
  58346. * Defines the ray we are currently tryin to visualize.
  58347. */
  58348. ray: Nullable<Ray>;
  58349. private _renderPoints;
  58350. private _renderLine;
  58351. private _renderFunction;
  58352. private _scene;
  58353. private _onAfterRenderObserver;
  58354. private _onAfterStepObserver;
  58355. private _attachedToMesh;
  58356. private _meshSpaceDirection;
  58357. private _meshSpaceOrigin;
  58358. /**
  58359. * Helper function to create a colored helper in a scene in one line.
  58360. * @param ray Defines the ray we are currently tryin to visualize
  58361. * @param scene Defines the scene the ray is used in
  58362. * @param color Defines the color we want to see the ray in
  58363. * @returns The newly created ray helper.
  58364. */
  58365. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  58366. /**
  58367. * Instantiate a new ray helper.
  58368. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  58369. * in order to better appreciate the issue one might have.
  58370. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  58371. * @param ray Defines the ray we are currently tryin to visualize
  58372. */
  58373. constructor(ray: Ray);
  58374. /**
  58375. * Shows the ray we are willing to debug.
  58376. * @param scene Defines the scene the ray needs to be rendered in
  58377. * @param color Defines the color the ray needs to be rendered in
  58378. */
  58379. show(scene: Scene, color?: Color3): void;
  58380. /**
  58381. * Hides the ray we are debugging.
  58382. */
  58383. hide(): void;
  58384. private _render;
  58385. /**
  58386. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  58387. * @param mesh Defines the mesh we want the helper attached to
  58388. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  58389. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  58390. * @param length Defines the length of the ray
  58391. */
  58392. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  58393. /**
  58394. * Detach the ray helper from the mesh it has previously been attached to.
  58395. */
  58396. detachFromMesh(): void;
  58397. private _updateToMesh;
  58398. /**
  58399. * Dispose the helper and release its associated resources.
  58400. */
  58401. dispose(): void;
  58402. }
  58403. }
  58404. declare module BABYLON {
  58405. /**
  58406. * Defines the options associated with the creation of a SkeletonViewer.
  58407. */
  58408. export interface ISkeletonViewerOptions {
  58409. /** Should the system pause animations before building the Viewer? */
  58410. pauseAnimations: boolean;
  58411. /** Should the system return the skeleton to rest before building? */
  58412. returnToRest: boolean;
  58413. /** public Display Mode of the Viewer */
  58414. displayMode: number;
  58415. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  58416. displayOptions: ISkeletonViewerDisplayOptions;
  58417. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  58418. computeBonesUsingShaders: boolean;
  58419. /** Flag ignore non weighted bones */
  58420. useAllBones: boolean;
  58421. }
  58422. /**
  58423. * Defines how to display the various bone meshes for the viewer.
  58424. */
  58425. export interface ISkeletonViewerDisplayOptions {
  58426. /** How far down to start tapering the bone spurs */
  58427. midStep?: number;
  58428. /** How big is the midStep? */
  58429. midStepFactor?: number;
  58430. /** Base for the Sphere Size */
  58431. sphereBaseSize?: number;
  58432. /** The ratio of the sphere to the longest bone in units */
  58433. sphereScaleUnit?: number;
  58434. /** Ratio for the Sphere Size */
  58435. sphereFactor?: number;
  58436. /** Whether a spur should attach its far end to the child bone position */
  58437. spurFollowsChild?: boolean;
  58438. /** Whether to show local axes or not */
  58439. showLocalAxes?: boolean;
  58440. /** Length of each local axis */
  58441. localAxesSize?: number;
  58442. }
  58443. /**
  58444. * Defines the constructor options for the BoneWeight Shader.
  58445. */
  58446. export interface IBoneWeightShaderOptions {
  58447. /** Skeleton to Map */
  58448. skeleton: Skeleton;
  58449. /** Colors for Uninfluenced bones */
  58450. colorBase?: Color3;
  58451. /** Colors for 0.0-0.25 Weight bones */
  58452. colorZero?: Color3;
  58453. /** Color for 0.25-0.5 Weight Influence */
  58454. colorQuarter?: Color3;
  58455. /** Color for 0.5-0.75 Weight Influence */
  58456. colorHalf?: Color3;
  58457. /** Color for 0.75-1 Weight Influence */
  58458. colorFull?: Color3;
  58459. /** Color for Zero Weight Influence */
  58460. targetBoneIndex?: number;
  58461. }
  58462. /**
  58463. * Simple structure of the gradient steps for the Color Map.
  58464. */
  58465. export interface ISkeletonMapShaderColorMapKnot {
  58466. /** Color of the Knot */
  58467. color: Color3;
  58468. /** Location of the Knot */
  58469. location: number;
  58470. }
  58471. /**
  58472. * Defines the constructor options for the SkeletonMap Shader.
  58473. */
  58474. export interface ISkeletonMapShaderOptions {
  58475. /** Skeleton to Map */
  58476. skeleton: Skeleton;
  58477. /** Array of ColorMapKnots that make the gradient must be ordered with knot[i].location < knot[i+1].location*/
  58478. colorMap?: ISkeletonMapShaderColorMapKnot[];
  58479. }
  58480. }
  58481. declare module BABYLON {
  58482. /**
  58483. * Class containing static functions to help procedurally build meshes
  58484. */
  58485. export class RibbonBuilder {
  58486. /**
  58487. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  58488. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  58489. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  58490. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  58491. * * 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
  58492. * * 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
  58493. * * 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
  58494. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58495. * * 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
  58496. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  58497. * * 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
  58498. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  58499. * * 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
  58500. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  58501. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58502. * @param name defines the name of the mesh
  58503. * @param options defines the options used to create the mesh
  58504. * @param scene defines the hosting scene
  58505. * @returns the ribbon mesh
  58506. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  58507. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58508. */
  58509. static CreateRibbon(name: string, options: {
  58510. pathArray: Vector3[][];
  58511. closeArray?: boolean;
  58512. closePath?: boolean;
  58513. offset?: number;
  58514. updatable?: boolean;
  58515. sideOrientation?: number;
  58516. frontUVs?: Vector4;
  58517. backUVs?: Vector4;
  58518. instance?: Mesh;
  58519. invertUV?: boolean;
  58520. uvs?: Vector2[];
  58521. colors?: Color4[];
  58522. }, scene?: Nullable<Scene>): Mesh;
  58523. }
  58524. }
  58525. declare module BABYLON {
  58526. /**
  58527. * Class containing static functions to help procedurally build meshes
  58528. */
  58529. export class ShapeBuilder {
  58530. /**
  58531. * 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.
  58532. * * 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.
  58533. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  58534. * * 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.
  58535. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  58536. * * 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
  58537. * * 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
  58538. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  58539. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58540. * * 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
  58541. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  58542. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  58543. * @param name defines the name of the mesh
  58544. * @param options defines the options used to create the mesh
  58545. * @param scene defines the hosting scene
  58546. * @returns the extruded shape mesh
  58547. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58548. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  58549. */
  58550. static ExtrudeShape(name: string, options: {
  58551. shape: Vector3[];
  58552. path: Vector3[];
  58553. scale?: number;
  58554. rotation?: number;
  58555. cap?: number;
  58556. updatable?: boolean;
  58557. sideOrientation?: number;
  58558. frontUVs?: Vector4;
  58559. backUVs?: Vector4;
  58560. instance?: Mesh;
  58561. invertUV?: boolean;
  58562. }, scene?: Nullable<Scene>): Mesh;
  58563. /**
  58564. * Creates an custom extruded shape mesh.
  58565. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  58566. * * 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.
  58567. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  58568. * * 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
  58569. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  58570. * * 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
  58571. * * It must returns a float value that will be the scale value applied to the shape on each path point
  58572. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  58573. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  58574. * * 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
  58575. * * 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
  58576. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  58577. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58578. * * 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
  58579. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  58580. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58581. * @param name defines the name of the mesh
  58582. * @param options defines the options used to create the mesh
  58583. * @param scene defines the hosting scene
  58584. * @returns the custom extruded shape mesh
  58585. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  58586. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58587. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  58588. */
  58589. static ExtrudeShapeCustom(name: string, options: {
  58590. shape: Vector3[];
  58591. path: Vector3[];
  58592. scaleFunction?: any;
  58593. rotationFunction?: any;
  58594. ribbonCloseArray?: boolean;
  58595. ribbonClosePath?: boolean;
  58596. cap?: number;
  58597. updatable?: boolean;
  58598. sideOrientation?: number;
  58599. frontUVs?: Vector4;
  58600. backUVs?: Vector4;
  58601. instance?: Mesh;
  58602. invertUV?: boolean;
  58603. }, scene?: Nullable<Scene>): Mesh;
  58604. private static _ExtrudeShapeGeneric;
  58605. }
  58606. }
  58607. declare module BABYLON.Debug {
  58608. /**
  58609. * Class used to render a debug view of a given skeleton
  58610. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  58611. */
  58612. export class SkeletonViewer {
  58613. /** defines the skeleton to render */
  58614. skeleton: Skeleton;
  58615. /** defines the mesh attached to the skeleton */
  58616. mesh: AbstractMesh;
  58617. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  58618. autoUpdateBonesMatrices: boolean;
  58619. /** defines the rendering group id to use with the viewer */
  58620. renderingGroupId: number;
  58621. /** is the options for the viewer */
  58622. options: Partial<ISkeletonViewerOptions>;
  58623. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_LINES */
  58624. static readonly DISPLAY_LINES: number;
  58625. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERES */
  58626. static readonly DISPLAY_SPHERES: number;
  58627. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERE_AND_SPURS */
  58628. static readonly DISPLAY_SPHERE_AND_SPURS: number;
  58629. /** public static method to create a BoneWeight Shader
  58630. * @param options The constructor options
  58631. * @param scene The scene that the shader is scoped to
  58632. * @returns The created ShaderMaterial
  58633. * @see http://www.babylonjs-playground.com/#1BZJVJ#395
  58634. */
  58635. static CreateBoneWeightShader(options: IBoneWeightShaderOptions, scene: Scene): ShaderMaterial;
  58636. /** public static method to create a BoneWeight Shader
  58637. * @param options The constructor options
  58638. * @param scene The scene that the shader is scoped to
  58639. * @returns The created ShaderMaterial
  58640. */
  58641. static CreateSkeletonMapShader(options: ISkeletonMapShaderOptions, scene: Scene): ShaderMaterial;
  58642. /** private static method to create a BoneWeight Shader
  58643. * @param size The size of the buffer to create (usually the bone count)
  58644. * @param colorMap The gradient data to generate
  58645. * @param scene The scene that the shader is scoped to
  58646. * @returns an Array of floats from the color gradient values
  58647. */
  58648. private static _CreateBoneMapColorBuffer;
  58649. /** If SkeletonViewer scene scope. */
  58650. private _scene;
  58651. /** Gets or sets the color used to render the skeleton */
  58652. color: Color3;
  58653. /** Array of the points of the skeleton fo the line view. */
  58654. private _debugLines;
  58655. /** The SkeletonViewers Mesh. */
  58656. private _debugMesh;
  58657. /** The local axes Meshes. */
  58658. private _localAxes;
  58659. /** If SkeletonViewer is enabled. */
  58660. private _isEnabled;
  58661. /** If SkeletonViewer is ready. */
  58662. private _ready;
  58663. /** SkeletonViewer render observable. */
  58664. private _obs;
  58665. /** The Utility Layer to render the gizmos in. */
  58666. private _utilityLayer;
  58667. private _boneIndices;
  58668. /** Gets the Scene. */
  58669. get scene(): Scene;
  58670. /** Gets the utilityLayer. */
  58671. get utilityLayer(): Nullable<UtilityLayerRenderer>;
  58672. /** Checks Ready Status. */
  58673. get isReady(): Boolean;
  58674. /** Sets Ready Status. */
  58675. set ready(value: boolean);
  58676. /** Gets the debugMesh */
  58677. get debugMesh(): Nullable<AbstractMesh> | Nullable<LinesMesh>;
  58678. /** Sets the debugMesh */
  58679. set debugMesh(value: Nullable<AbstractMesh> | Nullable<LinesMesh>);
  58680. /** Gets the displayMode */
  58681. get displayMode(): number;
  58682. /** Sets the displayMode */
  58683. set displayMode(value: number);
  58684. /**
  58685. * Creates a new SkeletonViewer
  58686. * @param skeleton defines the skeleton to render
  58687. * @param mesh defines the mesh attached to the skeleton
  58688. * @param scene defines the hosting scene
  58689. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  58690. * @param renderingGroupId defines the rendering group id to use with the viewer
  58691. * @param options All of the extra constructor options for the SkeletonViewer
  58692. */
  58693. constructor(
  58694. /** defines the skeleton to render */
  58695. skeleton: Skeleton,
  58696. /** defines the mesh attached to the skeleton */
  58697. mesh: AbstractMesh,
  58698. /** The Scene scope*/
  58699. scene: Scene,
  58700. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  58701. autoUpdateBonesMatrices?: boolean,
  58702. /** defines the rendering group id to use with the viewer */
  58703. renderingGroupId?: number,
  58704. /** is the options for the viewer */
  58705. options?: Partial<ISkeletonViewerOptions>);
  58706. /** The Dynamic bindings for the update functions */
  58707. private _bindObs;
  58708. /** Update the viewer to sync with current skeleton state, only used to manually update. */
  58709. update(): void;
  58710. /** Gets or sets a boolean indicating if the viewer is enabled */
  58711. set isEnabled(value: boolean);
  58712. get isEnabled(): boolean;
  58713. private _getBonePosition;
  58714. private _getLinesForBonesWithLength;
  58715. private _getLinesForBonesNoLength;
  58716. /** function to revert the mesh and scene back to the initial state. */
  58717. private _revert;
  58718. /** function to get the absolute bind pose of a bone by accumulating transformations up the bone hierarchy. */
  58719. private _getAbsoluteBindPoseToRef;
  58720. /** function to build and bind sphere joint points and spur bone representations. */
  58721. private _buildSpheresAndSpurs;
  58722. private _buildLocalAxes;
  58723. /** Update the viewer to sync with current skeleton state, only used for the line display. */
  58724. private _displayLinesUpdate;
  58725. /** Changes the displayMode of the skeleton viewer
  58726. * @param mode The displayMode numerical value
  58727. */
  58728. changeDisplayMode(mode: number): void;
  58729. /** Sets a display option of the skeleton viewer
  58730. *
  58731. * | Option | Type | Default | Description |
  58732. * | ---------------- | ------- | ------- | ----------- |
  58733. * | 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`. |
  58734. * | 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`. |
  58735. * | sphereBaseSize | float | 2 | Sphere base size. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  58736. * | 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`. |
  58737. * | spurFollowsChild | boolean | false | Whether a spur should attach its far end to the child bone. |
  58738. * | showLocalAxes | boolean | false | Displays local axes on all bones. |
  58739. * | localAxesSize | float | 0.075 | Determines the length of each local axis. |
  58740. *
  58741. * @param option String of the option name
  58742. * @param value The numerical option value
  58743. */
  58744. changeDisplayOptions(option: string, value: number): void;
  58745. /** Release associated resources */
  58746. dispose(): void;
  58747. }
  58748. }
  58749. declare module BABYLON {
  58750. /**
  58751. * Enum for Device Types
  58752. */
  58753. export enum DeviceType {
  58754. /** Generic */
  58755. Generic = 0,
  58756. /** Keyboard */
  58757. Keyboard = 1,
  58758. /** Mouse */
  58759. Mouse = 2,
  58760. /** Touch Pointers */
  58761. Touch = 3,
  58762. /** PS4 Dual Shock */
  58763. DualShock = 4,
  58764. /** Xbox */
  58765. Xbox = 5,
  58766. /** Switch Controller */
  58767. Switch = 6
  58768. }
  58769. /**
  58770. * Enum for All Pointers (Touch/Mouse)
  58771. */
  58772. export enum PointerInput {
  58773. /** Horizontal Axis */
  58774. Horizontal = 0,
  58775. /** Vertical Axis */
  58776. Vertical = 1,
  58777. /** Left Click or Touch */
  58778. LeftClick = 2,
  58779. /** Middle Click */
  58780. MiddleClick = 3,
  58781. /** Right Click */
  58782. RightClick = 4,
  58783. /** Browser Back */
  58784. BrowserBack = 5,
  58785. /** Browser Forward */
  58786. BrowserForward = 6
  58787. }
  58788. /**
  58789. * Enum for Dual Shock Gamepad
  58790. */
  58791. export enum DualShockInput {
  58792. /** Cross */
  58793. Cross = 0,
  58794. /** Circle */
  58795. Circle = 1,
  58796. /** Square */
  58797. Square = 2,
  58798. /** Triangle */
  58799. Triangle = 3,
  58800. /** L1 */
  58801. L1 = 4,
  58802. /** R1 */
  58803. R1 = 5,
  58804. /** L2 */
  58805. L2 = 6,
  58806. /** R2 */
  58807. R2 = 7,
  58808. /** Share */
  58809. Share = 8,
  58810. /** Options */
  58811. Options = 9,
  58812. /** L3 */
  58813. L3 = 10,
  58814. /** R3 */
  58815. R3 = 11,
  58816. /** DPadUp */
  58817. DPadUp = 12,
  58818. /** DPadDown */
  58819. DPadDown = 13,
  58820. /** DPadLeft */
  58821. DPadLeft = 14,
  58822. /** DRight */
  58823. DPadRight = 15,
  58824. /** Home */
  58825. Home = 16,
  58826. /** TouchPad */
  58827. TouchPad = 17,
  58828. /** LStickXAxis */
  58829. LStickXAxis = 18,
  58830. /** LStickYAxis */
  58831. LStickYAxis = 19,
  58832. /** RStickXAxis */
  58833. RStickXAxis = 20,
  58834. /** RStickYAxis */
  58835. RStickYAxis = 21
  58836. }
  58837. /**
  58838. * Enum for Xbox Gamepad
  58839. */
  58840. export enum XboxInput {
  58841. /** A */
  58842. A = 0,
  58843. /** B */
  58844. B = 1,
  58845. /** X */
  58846. X = 2,
  58847. /** Y */
  58848. Y = 3,
  58849. /** LB */
  58850. LB = 4,
  58851. /** RB */
  58852. RB = 5,
  58853. /** LT */
  58854. LT = 6,
  58855. /** RT */
  58856. RT = 7,
  58857. /** Back */
  58858. Back = 8,
  58859. /** Start */
  58860. Start = 9,
  58861. /** LS */
  58862. LS = 10,
  58863. /** RS */
  58864. RS = 11,
  58865. /** DPadUp */
  58866. DPadUp = 12,
  58867. /** DPadDown */
  58868. DPadDown = 13,
  58869. /** DPadLeft */
  58870. DPadLeft = 14,
  58871. /** DRight */
  58872. DPadRight = 15,
  58873. /** Home */
  58874. Home = 16,
  58875. /** LStickXAxis */
  58876. LStickXAxis = 17,
  58877. /** LStickYAxis */
  58878. LStickYAxis = 18,
  58879. /** RStickXAxis */
  58880. RStickXAxis = 19,
  58881. /** RStickYAxis */
  58882. RStickYAxis = 20
  58883. }
  58884. /**
  58885. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  58886. */
  58887. export enum SwitchInput {
  58888. /** B */
  58889. B = 0,
  58890. /** A */
  58891. A = 1,
  58892. /** Y */
  58893. Y = 2,
  58894. /** X */
  58895. X = 3,
  58896. /** L */
  58897. L = 4,
  58898. /** R */
  58899. R = 5,
  58900. /** ZL */
  58901. ZL = 6,
  58902. /** ZR */
  58903. ZR = 7,
  58904. /** Minus */
  58905. Minus = 8,
  58906. /** Plus */
  58907. Plus = 9,
  58908. /** LS */
  58909. LS = 10,
  58910. /** RS */
  58911. RS = 11,
  58912. /** DPadUp */
  58913. DPadUp = 12,
  58914. /** DPadDown */
  58915. DPadDown = 13,
  58916. /** DPadLeft */
  58917. DPadLeft = 14,
  58918. /** DRight */
  58919. DPadRight = 15,
  58920. /** Home */
  58921. Home = 16,
  58922. /** Capture */
  58923. Capture = 17,
  58924. /** LStickXAxis */
  58925. LStickXAxis = 18,
  58926. /** LStickYAxis */
  58927. LStickYAxis = 19,
  58928. /** RStickXAxis */
  58929. RStickXAxis = 20,
  58930. /** RStickYAxis */
  58931. RStickYAxis = 21
  58932. }
  58933. }
  58934. declare module BABYLON {
  58935. /**
  58936. * This class will take all inputs from Keyboard, Pointer, and
  58937. * any Gamepads and provide a polling system that all devices
  58938. * will use. This class assumes that there will only be one
  58939. * pointer device and one keyboard.
  58940. */
  58941. export class DeviceInputSystem implements IDisposable {
  58942. /**
  58943. * Returns onDeviceConnected callback property
  58944. * @returns Callback with function to execute when a device is connected
  58945. */
  58946. get onDeviceConnected(): (deviceType: DeviceType, deviceSlot: number) => void;
  58947. /**
  58948. * Sets callback function when a device is connected and executes against all connected devices
  58949. * @param callback Function to execute when a device is connected
  58950. */
  58951. set onDeviceConnected(callback: (deviceType: DeviceType, deviceSlot: number) => void);
  58952. /**
  58953. * Callback to be triggered when a device is disconnected
  58954. */
  58955. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  58956. /**
  58957. * Callback to be triggered when event driven input is updated
  58958. */
  58959. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  58960. private _inputs;
  58961. private _gamepads;
  58962. private _keyboardActive;
  58963. private _pointerActive;
  58964. private _elementToAttachTo;
  58965. private _keyboardDownEvent;
  58966. private _keyboardUpEvent;
  58967. private _pointerMoveEvent;
  58968. private _pointerDownEvent;
  58969. private _pointerUpEvent;
  58970. private _gamepadConnectedEvent;
  58971. private _gamepadDisconnectedEvent;
  58972. private _onDeviceConnected;
  58973. private static _MAX_KEYCODES;
  58974. private static _MAX_POINTER_INPUTS;
  58975. private constructor();
  58976. /**
  58977. * Creates a new DeviceInputSystem instance
  58978. * @param engine Engine to pull input element from
  58979. * @returns The new instance
  58980. */
  58981. static Create(engine: Engine): DeviceInputSystem;
  58982. /**
  58983. * Checks for current device input value, given an id and input index
  58984. * @param deviceName Id of connected device
  58985. * @param inputIndex Index of device input
  58986. * @returns Current value of input
  58987. */
  58988. /**
  58989. * Checks for current device input value, given an id and input index. Throws exception if requested device not initialized.
  58990. * @param deviceType Enum specifiying device type
  58991. * @param deviceSlot "Slot" or index that device is referenced in
  58992. * @param inputIndex Id of input to be checked
  58993. * @returns Current value of input
  58994. */
  58995. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): number;
  58996. /**
  58997. * Dispose of all the eventlisteners
  58998. */
  58999. dispose(): void;
  59000. /**
  59001. * Checks for existing connections to devices and register them, if necessary
  59002. * Currently handles gamepads and mouse
  59003. */
  59004. private _checkForConnectedDevices;
  59005. /**
  59006. * Add a gamepad to the DeviceInputSystem
  59007. * @param gamepad A single DOM Gamepad object
  59008. */
  59009. private _addGamePad;
  59010. /**
  59011. * Add pointer device to DeviceInputSystem
  59012. * @param deviceType Type of Pointer to add
  59013. * @param deviceSlot Pointer ID (0 for mouse, pointerId for Touch)
  59014. * @param currentX Current X at point of adding
  59015. * @param currentY Current Y at point of adding
  59016. */
  59017. private _addPointerDevice;
  59018. /**
  59019. * Add device and inputs to device array
  59020. * @param deviceType Enum specifiying device type
  59021. * @param deviceSlot "Slot" or index that device is referenced in
  59022. * @param numberOfInputs Number of input entries to create for given device
  59023. */
  59024. private _registerDevice;
  59025. /**
  59026. * Given a specific device name, remove that device from the device map
  59027. * @param deviceType Enum specifiying device type
  59028. * @param deviceSlot "Slot" or index that device is referenced in
  59029. */
  59030. private _unregisterDevice;
  59031. /**
  59032. * Handle all actions that come from keyboard interaction
  59033. */
  59034. private _handleKeyActions;
  59035. /**
  59036. * Handle all actions that come from pointer interaction
  59037. */
  59038. private _handlePointerActions;
  59039. /**
  59040. * Handle all actions that come from gamepad interaction
  59041. */
  59042. private _handleGamepadActions;
  59043. /**
  59044. * Update all non-event based devices with each frame
  59045. * @param deviceType Enum specifiying device type
  59046. * @param deviceSlot "Slot" or index that device is referenced in
  59047. * @param inputIndex Id of input to be checked
  59048. */
  59049. private _updateDevice;
  59050. /**
  59051. * Gets DeviceType from the device name
  59052. * @param deviceName Name of Device from DeviceInputSystem
  59053. * @returns DeviceType enum value
  59054. */
  59055. private _getGamepadDeviceType;
  59056. }
  59057. }
  59058. declare module BABYLON {
  59059. /**
  59060. * Type to handle enforcement of inputs
  59061. */
  59062. 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;
  59063. }
  59064. declare module BABYLON {
  59065. /**
  59066. * Class that handles all input for a specific device
  59067. */
  59068. export class DeviceSource<T extends DeviceType> {
  59069. /** Type of device */
  59070. readonly deviceType: DeviceType;
  59071. /** "Slot" or index that device is referenced in */
  59072. readonly deviceSlot: number;
  59073. /**
  59074. * Observable to handle device input changes per device
  59075. */
  59076. readonly onInputChangedObservable: Observable<{
  59077. inputIndex: DeviceInput<T>;
  59078. previousState: Nullable<number>;
  59079. currentState: Nullable<number>;
  59080. }>;
  59081. private readonly _deviceInputSystem;
  59082. /**
  59083. * Default Constructor
  59084. * @param deviceInputSystem Reference to DeviceInputSystem
  59085. * @param deviceType Type of device
  59086. * @param deviceSlot "Slot" or index that device is referenced in
  59087. */
  59088. constructor(deviceInputSystem: DeviceInputSystem,
  59089. /** Type of device */
  59090. deviceType: DeviceType,
  59091. /** "Slot" or index that device is referenced in */
  59092. deviceSlot?: number);
  59093. /**
  59094. * Get input for specific input
  59095. * @param inputIndex index of specific input on device
  59096. * @returns Input value from DeviceInputSystem
  59097. */
  59098. getInput(inputIndex: DeviceInput<T>): number;
  59099. }
  59100. /**
  59101. * Class to keep track of devices
  59102. */
  59103. export class DeviceSourceManager implements IDisposable {
  59104. /**
  59105. * Observable to be triggered when after a device is connected, any new observers added will be triggered against already connected devices
  59106. */
  59107. readonly onDeviceConnectedObservable: Observable<DeviceSource<DeviceType>>;
  59108. /**
  59109. * Observable to be triggered when after a device is disconnected
  59110. */
  59111. readonly onDeviceDisconnectedObservable: Observable<DeviceSource<DeviceType>>;
  59112. private readonly _devices;
  59113. private readonly _firstDevice;
  59114. private readonly _deviceInputSystem;
  59115. /**
  59116. * Default Constructor
  59117. * @param engine engine to pull input element from
  59118. */
  59119. constructor(engine: Engine);
  59120. /**
  59121. * Gets a DeviceSource, given a type and slot
  59122. * @param deviceType Enum specifying device type
  59123. * @param deviceSlot "Slot" or index that device is referenced in
  59124. * @returns DeviceSource object
  59125. */
  59126. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  59127. /**
  59128. * Gets an array of DeviceSource objects for a given device type
  59129. * @param deviceType Enum specifying device type
  59130. * @returns Array of DeviceSource objects
  59131. */
  59132. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  59133. /**
  59134. * Returns a read-only list of all available devices
  59135. * @returns Read-only array with active devices
  59136. */
  59137. getDevices(): ReadonlyArray<DeviceSource<DeviceType>>;
  59138. /**
  59139. * Dispose of DeviceInputSystem and other parts
  59140. */
  59141. dispose(): void;
  59142. /**
  59143. * Function to add device name to device list
  59144. * @param deviceType Enum specifying device type
  59145. * @param deviceSlot "Slot" or index that device is referenced in
  59146. */
  59147. private _addDevice;
  59148. /**
  59149. * Function to remove device name to device list
  59150. * @param deviceType Enum specifying device type
  59151. * @param deviceSlot "Slot" or index that device is referenced in
  59152. */
  59153. private _removeDevice;
  59154. /**
  59155. * Updates array storing first connected device of each type
  59156. * @param type Type of Device
  59157. */
  59158. private _updateFirstDevices;
  59159. }
  59160. }
  59161. declare module BABYLON {
  59162. /**
  59163. * Options to create the null engine
  59164. */
  59165. export class NullEngineOptions {
  59166. /**
  59167. * Render width (Default: 512)
  59168. */
  59169. renderWidth: number;
  59170. /**
  59171. * Render height (Default: 256)
  59172. */
  59173. renderHeight: number;
  59174. /**
  59175. * Texture size (Default: 512)
  59176. */
  59177. textureSize: number;
  59178. /**
  59179. * If delta time between frames should be constant
  59180. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  59181. */
  59182. deterministicLockstep: boolean;
  59183. /**
  59184. * Maximum about of steps between frames (Default: 4)
  59185. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  59186. */
  59187. lockstepMaxSteps: number;
  59188. /**
  59189. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  59190. */
  59191. useHighPrecisionMatrix?: boolean;
  59192. }
  59193. /**
  59194. * The null engine class provides support for headless version of babylon.js.
  59195. * This can be used in server side scenario or for testing purposes
  59196. */
  59197. export class NullEngine extends Engine {
  59198. private _options;
  59199. /**
  59200. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  59201. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  59202. * @returns true if engine is in deterministic lock step mode
  59203. */
  59204. isDeterministicLockStep(): boolean;
  59205. /**
  59206. * Gets the max steps when engine is running in deterministic lock step
  59207. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  59208. * @returns the max steps
  59209. */
  59210. getLockstepMaxSteps(): number;
  59211. /**
  59212. * Gets the current hardware scaling level.
  59213. * By default the hardware scaling level is computed from the window device ratio.
  59214. * 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.
  59215. * @returns a number indicating the current hardware scaling level
  59216. */
  59217. getHardwareScalingLevel(): number;
  59218. constructor(options?: NullEngineOptions);
  59219. /**
  59220. * Creates a vertex buffer
  59221. * @param vertices the data for the vertex buffer
  59222. * @returns the new WebGL static buffer
  59223. */
  59224. createVertexBuffer(vertices: FloatArray): DataBuffer;
  59225. /**
  59226. * Creates a new index buffer
  59227. * @param indices defines the content of the index buffer
  59228. * @param updatable defines if the index buffer must be updatable
  59229. * @returns a new webGL buffer
  59230. */
  59231. createIndexBuffer(indices: IndicesArray): DataBuffer;
  59232. /**
  59233. * Clear the current render buffer or the current render target (if any is set up)
  59234. * @param color defines the color to use
  59235. * @param backBuffer defines if the back buffer must be cleared
  59236. * @param depth defines if the depth buffer must be cleared
  59237. * @param stencil defines if the stencil buffer must be cleared
  59238. */
  59239. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  59240. /**
  59241. * Gets the current render width
  59242. * @param useScreen defines if screen size must be used (or the current render target if any)
  59243. * @returns a number defining the current render width
  59244. */
  59245. getRenderWidth(useScreen?: boolean): number;
  59246. /**
  59247. * Gets the current render height
  59248. * @param useScreen defines if screen size must be used (or the current render target if any)
  59249. * @returns a number defining the current render height
  59250. */
  59251. getRenderHeight(useScreen?: boolean): number;
  59252. /**
  59253. * Set the WebGL's viewport
  59254. * @param viewport defines the viewport element to be used
  59255. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  59256. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  59257. */
  59258. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  59259. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  59260. /**
  59261. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  59262. * @param pipelineContext defines the pipeline context to use
  59263. * @param uniformsNames defines the list of uniform names
  59264. * @returns an array of webGL uniform locations
  59265. */
  59266. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  59267. /**
  59268. * Gets the lsit of active attributes for a given webGL program
  59269. * @param pipelineContext defines the pipeline context to use
  59270. * @param attributesNames defines the list of attribute names to get
  59271. * @returns an array of indices indicating the offset of each attribute
  59272. */
  59273. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  59274. /**
  59275. * Binds an effect to the webGL context
  59276. * @param effect defines the effect to bind
  59277. */
  59278. bindSamplers(effect: Effect): void;
  59279. /**
  59280. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  59281. * @param effect defines the effect to activate
  59282. */
  59283. enableEffect(effect: Effect): void;
  59284. /**
  59285. * Set various states to the webGL context
  59286. * @param culling defines backface culling state
  59287. * @param zOffset defines the value to apply to zOffset (0 by default)
  59288. * @param force defines if states must be applied even if cache is up to date
  59289. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  59290. */
  59291. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  59292. /**
  59293. * Set the value of an uniform to an array of int32
  59294. * @param uniform defines the webGL uniform location where to store the value
  59295. * @param array defines the array of int32 to store
  59296. * @returns true if value was set
  59297. */
  59298. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  59299. /**
  59300. * Set the value of an uniform to an array of int32 (stored as vec2)
  59301. * @param uniform defines the webGL uniform location where to store the value
  59302. * @param array defines the array of int32 to store
  59303. * @returns true if value was set
  59304. */
  59305. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  59306. /**
  59307. * Set the value of an uniform to an array of int32 (stored as vec3)
  59308. * @param uniform defines the webGL uniform location where to store the value
  59309. * @param array defines the array of int32 to store
  59310. * @returns true if value was set
  59311. */
  59312. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  59313. /**
  59314. * Set the value of an uniform to an array of int32 (stored as vec4)
  59315. * @param uniform defines the webGL uniform location where to store the value
  59316. * @param array defines the array of int32 to store
  59317. * @returns true if value was set
  59318. */
  59319. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  59320. /**
  59321. * Set the value of an uniform to an array of float32
  59322. * @param uniform defines the webGL uniform location where to store the value
  59323. * @param array defines the array of float32 to store
  59324. * @returns true if value was set
  59325. */
  59326. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  59327. /**
  59328. * Set the value of an uniform to an array of float32 (stored as vec2)
  59329. * @param uniform defines the webGL uniform location where to store the value
  59330. * @param array defines the array of float32 to store
  59331. * @returns true if value was set
  59332. */
  59333. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  59334. /**
  59335. * Set the value of an uniform to an array of float32 (stored as vec3)
  59336. * @param uniform defines the webGL uniform location where to store the value
  59337. * @param array defines the array of float32 to store
  59338. * @returns true if value was set
  59339. */
  59340. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  59341. /**
  59342. * Set the value of an uniform to an array of float32 (stored as vec4)
  59343. * @param uniform defines the webGL uniform location where to store the value
  59344. * @param array defines the array of float32 to store
  59345. * @returns true if value was set
  59346. */
  59347. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  59348. /**
  59349. * Set the value of an uniform to an array of number
  59350. * @param uniform defines the webGL uniform location where to store the value
  59351. * @param array defines the array of number to store
  59352. * @returns true if value was set
  59353. */
  59354. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  59355. /**
  59356. * Set the value of an uniform to an array of number (stored as vec2)
  59357. * @param uniform defines the webGL uniform location where to store the value
  59358. * @param array defines the array of number to store
  59359. * @returns true if value was set
  59360. */
  59361. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  59362. /**
  59363. * Set the value of an uniform to an array of number (stored as vec3)
  59364. * @param uniform defines the webGL uniform location where to store the value
  59365. * @param array defines the array of number to store
  59366. * @returns true if value was set
  59367. */
  59368. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  59369. /**
  59370. * Set the value of an uniform to an array of number (stored as vec4)
  59371. * @param uniform defines the webGL uniform location where to store the value
  59372. * @param array defines the array of number to store
  59373. * @returns true if value was set
  59374. */
  59375. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  59376. /**
  59377. * Set the value of an uniform to an array of float32 (stored as matrices)
  59378. * @param uniform defines the webGL uniform location where to store the value
  59379. * @param matrices defines the array of float32 to store
  59380. * @returns true if value was set
  59381. */
  59382. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  59383. /**
  59384. * Set the value of an uniform to a matrix (3x3)
  59385. * @param uniform defines the webGL uniform location where to store the value
  59386. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  59387. * @returns true if value was set
  59388. */
  59389. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  59390. /**
  59391. * Set the value of an uniform to a matrix (2x2)
  59392. * @param uniform defines the webGL uniform location where to store the value
  59393. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  59394. * @returns true if value was set
  59395. */
  59396. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  59397. /**
  59398. * Set the value of an uniform to a number (float)
  59399. * @param uniform defines the webGL uniform location where to store the value
  59400. * @param value defines the float number to store
  59401. * @returns true if value was set
  59402. */
  59403. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  59404. /**
  59405. * Set the value of an uniform to a vec2
  59406. * @param uniform defines the webGL uniform location where to store the value
  59407. * @param x defines the 1st component of the value
  59408. * @param y defines the 2nd component of the value
  59409. * @returns true if value was set
  59410. */
  59411. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  59412. /**
  59413. * Set the value of an uniform to a vec3
  59414. * @param uniform defines the webGL uniform location where to store the value
  59415. * @param x defines the 1st component of the value
  59416. * @param y defines the 2nd component of the value
  59417. * @param z defines the 3rd component of the value
  59418. * @returns true if value was set
  59419. */
  59420. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  59421. /**
  59422. * Set the value of an uniform to a boolean
  59423. * @param uniform defines the webGL uniform location where to store the value
  59424. * @param bool defines the boolean to store
  59425. * @returns true if value was set
  59426. */
  59427. setBool(uniform: WebGLUniformLocation, bool: number): boolean;
  59428. /**
  59429. * Set the value of an uniform to a vec4
  59430. * @param uniform defines the webGL uniform location where to store the value
  59431. * @param x defines the 1st component of the value
  59432. * @param y defines the 2nd component of the value
  59433. * @param z defines the 3rd component of the value
  59434. * @param w defines the 4th component of the value
  59435. * @returns true if value was set
  59436. */
  59437. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  59438. /**
  59439. * Sets the current alpha mode
  59440. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  59441. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  59442. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  59443. */
  59444. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  59445. /**
  59446. * Bind webGl buffers directly to the webGL context
  59447. * @param vertexBuffers defines the vertex buffer to bind
  59448. * @param indexBuffer defines the index buffer to bind
  59449. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  59450. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  59451. * @param effect defines the effect associated with the vertex buffer
  59452. */
  59453. bindBuffers(vertexBuffers: {
  59454. [key: string]: VertexBuffer;
  59455. }, indexBuffer: DataBuffer, effect: Effect): void;
  59456. /**
  59457. * Force the entire cache to be cleared
  59458. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  59459. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  59460. */
  59461. wipeCaches(bruteForce?: boolean): void;
  59462. /**
  59463. * Send a draw order
  59464. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  59465. * @param indexStart defines the starting index
  59466. * @param indexCount defines the number of index to draw
  59467. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  59468. */
  59469. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  59470. /**
  59471. * Draw a list of indexed primitives
  59472. * @param fillMode defines the primitive to use
  59473. * @param indexStart defines the starting index
  59474. * @param indexCount defines the number of index to draw
  59475. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  59476. */
  59477. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  59478. /**
  59479. * Draw a list of unindexed primitives
  59480. * @param fillMode defines the primitive to use
  59481. * @param verticesStart defines the index of first vertex to draw
  59482. * @param verticesCount defines the count of vertices to draw
  59483. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  59484. */
  59485. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  59486. /** @hidden */
  59487. protected _createTexture(): WebGLTexture;
  59488. /** @hidden */
  59489. _releaseTexture(texture: InternalTexture): void;
  59490. /**
  59491. * Usually called from Texture.ts.
  59492. * Passed information to create a WebGLTexture
  59493. * @param urlArg defines a value which contains one of the following:
  59494. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  59495. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  59496. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  59497. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  59498. * @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)
  59499. * @param scene needed for loading to the correct scene
  59500. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  59501. * @param onLoad optional callback to be called upon successful completion
  59502. * @param onError optional callback to be called upon failure
  59503. * @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
  59504. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  59505. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  59506. * @param forcedExtension defines the extension to use to pick the right loader
  59507. * @param mimeType defines an optional mime type
  59508. * @returns a InternalTexture for assignment back into BABYLON.Texture
  59509. */
  59510. 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;
  59511. /**
  59512. * Creates a new render target texture
  59513. * @param size defines the size of the texture
  59514. * @param options defines the options used to create the texture
  59515. * @returns a new render target texture stored in an InternalTexture
  59516. */
  59517. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  59518. /**
  59519. * Update the sampling mode of a given texture
  59520. * @param samplingMode defines the required sampling mode
  59521. * @param texture defines the texture to update
  59522. */
  59523. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  59524. /**
  59525. * Binds the frame buffer to the specified texture.
  59526. * @param texture The texture to render to or null for the default canvas
  59527. * @param faceIndex The face of the texture to render to in case of cube texture
  59528. * @param requiredWidth The width of the target to render to
  59529. * @param requiredHeight The height of the target to render to
  59530. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  59531. * @param lodLevel defines le lod level to bind to the frame buffer
  59532. */
  59533. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  59534. /**
  59535. * Unbind the current render target texture from the webGL context
  59536. * @param texture defines the render target texture to unbind
  59537. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  59538. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  59539. */
  59540. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  59541. /**
  59542. * Creates a dynamic vertex buffer
  59543. * @param vertices the data for the dynamic vertex buffer
  59544. * @returns the new WebGL dynamic buffer
  59545. */
  59546. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  59547. /**
  59548. * Update the content of a dynamic texture
  59549. * @param texture defines the texture to update
  59550. * @param canvas defines the canvas containing the source
  59551. * @param invertY defines if data must be stored with Y axis inverted
  59552. * @param premulAlpha defines if alpha is stored as premultiplied
  59553. * @param format defines the format of the data
  59554. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  59555. */
  59556. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  59557. /**
  59558. * Gets a boolean indicating if all created effects are ready
  59559. * @returns true if all effects are ready
  59560. */
  59561. areAllEffectsReady(): boolean;
  59562. /**
  59563. * @hidden
  59564. * Get the current error code of the webGL context
  59565. * @returns the error code
  59566. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  59567. */
  59568. getError(): number;
  59569. /** @hidden */
  59570. _getUnpackAlignement(): number;
  59571. /** @hidden */
  59572. _unpackFlipY(value: boolean): void;
  59573. /**
  59574. * Update a dynamic index buffer
  59575. * @param indexBuffer defines the target index buffer
  59576. * @param indices defines the data to update
  59577. * @param offset defines the offset in the target index buffer where update should start
  59578. */
  59579. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  59580. /**
  59581. * Updates a dynamic vertex buffer.
  59582. * @param vertexBuffer the vertex buffer to update
  59583. * @param vertices the data used to update the vertex buffer
  59584. * @param byteOffset the byte offset of the data (optional)
  59585. * @param byteLength the byte length of the data (optional)
  59586. */
  59587. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  59588. /** @hidden */
  59589. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  59590. /** @hidden */
  59591. _bindTexture(channel: number, texture: InternalTexture): void;
  59592. protected _deleteBuffer(buffer: WebGLBuffer): void;
  59593. /**
  59594. * 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
  59595. */
  59596. releaseEffects(): void;
  59597. displayLoadingUI(): void;
  59598. hideLoadingUI(): void;
  59599. /** @hidden */
  59600. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  59601. /** @hidden */
  59602. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  59603. /** @hidden */
  59604. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  59605. /** @hidden */
  59606. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  59607. }
  59608. }
  59609. declare module BABYLON {
  59610. /** @hidden */
  59611. export class _OcclusionDataStorage {
  59612. /** @hidden */
  59613. occlusionInternalRetryCounter: number;
  59614. /** @hidden */
  59615. isOcclusionQueryInProgress: boolean;
  59616. /** @hidden */
  59617. isOccluded: boolean;
  59618. /** @hidden */
  59619. occlusionRetryCount: number;
  59620. /** @hidden */
  59621. occlusionType: number;
  59622. /** @hidden */
  59623. occlusionQueryAlgorithmType: number;
  59624. }
  59625. interface Engine {
  59626. /**
  59627. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  59628. * @return the new query
  59629. */
  59630. createQuery(): WebGLQuery;
  59631. /**
  59632. * Delete and release a webGL query
  59633. * @param query defines the query to delete
  59634. * @return the current engine
  59635. */
  59636. deleteQuery(query: WebGLQuery): Engine;
  59637. /**
  59638. * Check if a given query has resolved and got its value
  59639. * @param query defines the query to check
  59640. * @returns true if the query got its value
  59641. */
  59642. isQueryResultAvailable(query: WebGLQuery): boolean;
  59643. /**
  59644. * Gets the value of a given query
  59645. * @param query defines the query to check
  59646. * @returns the value of the query
  59647. */
  59648. getQueryResult(query: WebGLQuery): number;
  59649. /**
  59650. * Initiates an occlusion query
  59651. * @param algorithmType defines the algorithm to use
  59652. * @param query defines the query to use
  59653. * @returns the current engine
  59654. * @see https://doc.babylonjs.com/features/occlusionquery
  59655. */
  59656. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  59657. /**
  59658. * Ends an occlusion query
  59659. * @see https://doc.babylonjs.com/features/occlusionquery
  59660. * @param algorithmType defines the algorithm to use
  59661. * @returns the current engine
  59662. */
  59663. endOcclusionQuery(algorithmType: number): Engine;
  59664. /**
  59665. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  59666. * Please note that only one query can be issued at a time
  59667. * @returns a time token used to track the time span
  59668. */
  59669. startTimeQuery(): Nullable<_TimeToken>;
  59670. /**
  59671. * Ends a time query
  59672. * @param token defines the token used to measure the time span
  59673. * @returns the time spent (in ns)
  59674. */
  59675. endTimeQuery(token: _TimeToken): int;
  59676. /** @hidden */
  59677. _currentNonTimestampToken: Nullable<_TimeToken>;
  59678. /** @hidden */
  59679. _createTimeQuery(): WebGLQuery;
  59680. /** @hidden */
  59681. _deleteTimeQuery(query: WebGLQuery): void;
  59682. /** @hidden */
  59683. _getGlAlgorithmType(algorithmType: number): number;
  59684. /** @hidden */
  59685. _getTimeQueryResult(query: WebGLQuery): any;
  59686. /** @hidden */
  59687. _getTimeQueryAvailability(query: WebGLQuery): any;
  59688. }
  59689. interface AbstractMesh {
  59690. /**
  59691. * Backing filed
  59692. * @hidden
  59693. */
  59694. __occlusionDataStorage: _OcclusionDataStorage;
  59695. /**
  59696. * Access property
  59697. * @hidden
  59698. */
  59699. _occlusionDataStorage: _OcclusionDataStorage;
  59700. /**
  59701. * 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.
  59702. * The default value is -1 which means don't break the query and wait till the result
  59703. * @see https://doc.babylonjs.com/features/occlusionquery
  59704. */
  59705. occlusionRetryCount: number;
  59706. /**
  59707. * 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:
  59708. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  59709. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  59710. * * 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.
  59711. * @see https://doc.babylonjs.com/features/occlusionquery
  59712. */
  59713. occlusionType: number;
  59714. /**
  59715. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  59716. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  59717. * * 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.
  59718. * @see https://doc.babylonjs.com/features/occlusionquery
  59719. */
  59720. occlusionQueryAlgorithmType: number;
  59721. /**
  59722. * 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
  59723. * @see https://doc.babylonjs.com/features/occlusionquery
  59724. */
  59725. isOccluded: boolean;
  59726. /**
  59727. * Flag to check the progress status of the query
  59728. * @see https://doc.babylonjs.com/features/occlusionquery
  59729. */
  59730. isOcclusionQueryInProgress: boolean;
  59731. }
  59732. }
  59733. declare module BABYLON {
  59734. /** @hidden */
  59735. export var _forceTransformFeedbackToBundle: boolean;
  59736. interface Engine {
  59737. /**
  59738. * Creates a webGL transform feedback object
  59739. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  59740. * @returns the webGL transform feedback object
  59741. */
  59742. createTransformFeedback(): WebGLTransformFeedback;
  59743. /**
  59744. * Delete a webGL transform feedback object
  59745. * @param value defines the webGL transform feedback object to delete
  59746. */
  59747. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  59748. /**
  59749. * Bind a webGL transform feedback object to the webgl context
  59750. * @param value defines the webGL transform feedback object to bind
  59751. */
  59752. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  59753. /**
  59754. * Begins a transform feedback operation
  59755. * @param usePoints defines if points or triangles must be used
  59756. */
  59757. beginTransformFeedback(usePoints: boolean): void;
  59758. /**
  59759. * Ends a transform feedback operation
  59760. */
  59761. endTransformFeedback(): void;
  59762. /**
  59763. * Specify the varyings to use with transform feedback
  59764. * @param program defines the associated webGL program
  59765. * @param value defines the list of strings representing the varying names
  59766. */
  59767. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  59768. /**
  59769. * Bind a webGL buffer for a transform feedback operation
  59770. * @param value defines the webGL buffer to bind
  59771. */
  59772. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  59773. }
  59774. }
  59775. declare module BABYLON {
  59776. /**
  59777. * Class used to define an additional view for the engine
  59778. * @see https://doc.babylonjs.com/how_to/multi_canvases
  59779. */
  59780. export class EngineView {
  59781. /** Defines the canvas where to render the view */
  59782. target: HTMLCanvasElement;
  59783. /** Defines an optional camera used to render the view (will use active camera else) */
  59784. camera?: Camera;
  59785. }
  59786. interface Engine {
  59787. /**
  59788. * Gets or sets the HTML element to use for attaching events
  59789. */
  59790. inputElement: Nullable<HTMLElement>;
  59791. /**
  59792. * Gets the current engine view
  59793. * @see https://doc.babylonjs.com/how_to/multi_canvases
  59794. */
  59795. activeView: Nullable<EngineView>;
  59796. /** Gets or sets the list of views */
  59797. views: EngineView[];
  59798. /**
  59799. * Register a new child canvas
  59800. * @param canvas defines the canvas to register
  59801. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  59802. * @returns the associated view
  59803. */
  59804. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  59805. /**
  59806. * Remove a registered child canvas
  59807. * @param canvas defines the canvas to remove
  59808. * @returns the current engine
  59809. */
  59810. unRegisterView(canvas: HTMLCanvasElement): Engine;
  59811. }
  59812. }
  59813. declare module BABYLON {
  59814. interface Engine {
  59815. /** @hidden */
  59816. _excludedCompressedTextures: string[];
  59817. /** @hidden */
  59818. _textureFormatInUse: string;
  59819. /**
  59820. * Gets the list of texture formats supported
  59821. */
  59822. readonly texturesSupported: Array<string>;
  59823. /**
  59824. * Gets the texture format in use
  59825. */
  59826. readonly textureFormatInUse: Nullable<string>;
  59827. /**
  59828. * Set the compressed texture extensions or file names to skip.
  59829. *
  59830. * @param skippedFiles defines the list of those texture files you want to skip
  59831. * Example: [".dds", ".env", "myfile.png"]
  59832. */
  59833. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  59834. /**
  59835. * Set the compressed texture format to use, based on the formats you have, and the formats
  59836. * supported by the hardware / browser.
  59837. *
  59838. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  59839. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  59840. * to API arguments needed to compressed textures. This puts the burden on the container
  59841. * generator to house the arcane code for determining these for current & future formats.
  59842. *
  59843. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  59844. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  59845. *
  59846. * Note: The result of this call is not taken into account when a texture is base64.
  59847. *
  59848. * @param formatsAvailable defines the list of those format families you have created
  59849. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  59850. *
  59851. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  59852. * @returns The extension selected.
  59853. */
  59854. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  59855. }
  59856. }
  59857. declare module BABYLON {
  59858. /** @hidden */
  59859. export var rgbdEncodePixelShader: {
  59860. name: string;
  59861. shader: string;
  59862. };
  59863. }
  59864. declare module BABYLON {
  59865. /**
  59866. * Raw texture data and descriptor sufficient for WebGL texture upload
  59867. */
  59868. export interface EnvironmentTextureInfo {
  59869. /**
  59870. * Version of the environment map
  59871. */
  59872. version: number;
  59873. /**
  59874. * Width of image
  59875. */
  59876. width: number;
  59877. /**
  59878. * Irradiance information stored in the file.
  59879. */
  59880. irradiance: any;
  59881. /**
  59882. * Specular information stored in the file.
  59883. */
  59884. specular: any;
  59885. }
  59886. /**
  59887. * Defines One Image in the file. It requires only the position in the file
  59888. * as well as the length.
  59889. */
  59890. interface BufferImageData {
  59891. /**
  59892. * Length of the image data.
  59893. */
  59894. length: number;
  59895. /**
  59896. * Position of the data from the null terminator delimiting the end of the JSON.
  59897. */
  59898. position: number;
  59899. }
  59900. /**
  59901. * Defines the specular data enclosed in the file.
  59902. * This corresponds to the version 1 of the data.
  59903. */
  59904. export interface EnvironmentTextureSpecularInfoV1 {
  59905. /**
  59906. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  59907. */
  59908. specularDataPosition?: number;
  59909. /**
  59910. * This contains all the images data needed to reconstruct the cubemap.
  59911. */
  59912. mipmaps: Array<BufferImageData>;
  59913. /**
  59914. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  59915. */
  59916. lodGenerationScale: number;
  59917. }
  59918. /**
  59919. * Sets of helpers addressing the serialization and deserialization of environment texture
  59920. * stored in a BabylonJS env file.
  59921. * Those files are usually stored as .env files.
  59922. */
  59923. export class EnvironmentTextureTools {
  59924. /**
  59925. * Magic number identifying the env file.
  59926. */
  59927. private static _MagicBytes;
  59928. /**
  59929. * Gets the environment info from an env file.
  59930. * @param data The array buffer containing the .env bytes.
  59931. * @returns the environment file info (the json header) if successfully parsed.
  59932. */
  59933. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  59934. /**
  59935. * Creates an environment texture from a loaded cube texture.
  59936. * @param texture defines the cube texture to convert in env file
  59937. * @return a promise containing the environment data if succesfull.
  59938. */
  59939. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  59940. /**
  59941. * Creates a JSON representation of the spherical data.
  59942. * @param texture defines the texture containing the polynomials
  59943. * @return the JSON representation of the spherical info
  59944. */
  59945. private static _CreateEnvTextureIrradiance;
  59946. /**
  59947. * Creates the ArrayBufferViews used for initializing environment texture image data.
  59948. * @param data the image data
  59949. * @param info parameters that determine what views will be created for accessing the underlying buffer
  59950. * @return the views described by info providing access to the underlying buffer
  59951. */
  59952. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  59953. /**
  59954. * Uploads the texture info contained in the env file to the GPU.
  59955. * @param texture defines the internal texture to upload to
  59956. * @param data defines the data to load
  59957. * @param info defines the texture info retrieved through the GetEnvInfo method
  59958. * @returns a promise
  59959. */
  59960. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  59961. private static _OnImageReadyAsync;
  59962. /**
  59963. * Uploads the levels of image data to the GPU.
  59964. * @param texture defines the internal texture to upload to
  59965. * @param imageData defines the array buffer views of image data [mipmap][face]
  59966. * @returns a promise
  59967. */
  59968. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  59969. /**
  59970. * Uploads spherical polynomials information to the texture.
  59971. * @param texture defines the texture we are trying to upload the information to
  59972. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  59973. */
  59974. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  59975. /** @hidden */
  59976. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  59977. }
  59978. }
  59979. declare module BABYLON {
  59980. /**
  59981. * Container for accessors for natively-stored mesh data buffers.
  59982. */
  59983. class NativeDataBuffer extends DataBuffer {
  59984. /**
  59985. * Accessor value used to identify/retrieve a natively-stored index buffer.
  59986. */
  59987. nativeIndexBuffer?: any;
  59988. /**
  59989. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  59990. */
  59991. nativeVertexBuffer?: any;
  59992. }
  59993. /** @hidden */
  59994. class NativeTexture extends InternalTexture {
  59995. getInternalTexture(): InternalTexture;
  59996. getViewCount(): number;
  59997. }
  59998. /** @hidden */
  59999. export class NativeEngine extends Engine {
  60000. private readonly _native;
  60001. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  60002. private readonly INVALID_HANDLE;
  60003. private _boundBuffersVertexArray;
  60004. private _currentDepthTest;
  60005. getHardwareScalingLevel(): number;
  60006. constructor();
  60007. dispose(): void;
  60008. /**
  60009. * Can be used to override the current requestAnimationFrame requester.
  60010. * @hidden
  60011. */
  60012. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  60013. /**
  60014. * Override default engine behavior.
  60015. * @param color
  60016. * @param backBuffer
  60017. * @param depth
  60018. * @param stencil
  60019. */
  60020. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  60021. /**
  60022. * Gets host document
  60023. * @returns the host document object
  60024. */
  60025. getHostDocument(): Nullable<Document>;
  60026. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  60027. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  60028. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  60029. protected _recordVertexArrayObject(vertexArray: any, vertexBuffers: {
  60030. [key: string]: VertexBuffer;
  60031. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  60032. bindBuffers(vertexBuffers: {
  60033. [key: string]: VertexBuffer;
  60034. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  60035. recordVertexArrayObject(vertexBuffers: {
  60036. [key: string]: VertexBuffer;
  60037. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  60038. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  60039. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  60040. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  60041. /**
  60042. * Draw a list of indexed primitives
  60043. * @param fillMode defines the primitive to use
  60044. * @param indexStart defines the starting index
  60045. * @param indexCount defines the number of index to draw
  60046. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  60047. */
  60048. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  60049. /**
  60050. * Draw a list of unindexed primitives
  60051. * @param fillMode defines the primitive to use
  60052. * @param verticesStart defines the index of first vertex to draw
  60053. * @param verticesCount defines the count of vertices to draw
  60054. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  60055. */
  60056. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  60057. createPipelineContext(): IPipelineContext;
  60058. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rawVertexSourceCode: string, rawFragmentSourceCode: string, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  60059. /** @hidden */
  60060. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  60061. /** @hidden */
  60062. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  60063. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  60064. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  60065. protected _setProgram(program: WebGLProgram): void;
  60066. _releaseEffect(effect: Effect): void;
  60067. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  60068. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  60069. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  60070. bindSamplers(effect: Effect): void;
  60071. setMatrix(uniform: WebGLUniformLocation, matrix: IMatrixLike): void;
  60072. getRenderWidth(useScreen?: boolean): number;
  60073. getRenderHeight(useScreen?: boolean): number;
  60074. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  60075. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  60076. /**
  60077. * Set the z offset to apply to current rendering
  60078. * @param value defines the offset to apply
  60079. */
  60080. setZOffset(value: number): void;
  60081. /**
  60082. * Gets the current value of the zOffset
  60083. * @returns the current zOffset state
  60084. */
  60085. getZOffset(): number;
  60086. /**
  60087. * Enable or disable depth buffering
  60088. * @param enable defines the state to set
  60089. */
  60090. setDepthBuffer(enable: boolean): void;
  60091. /**
  60092. * Gets a boolean indicating if depth writing is enabled
  60093. * @returns the current depth writing state
  60094. */
  60095. getDepthWrite(): boolean;
  60096. setDepthFunctionToGreater(): void;
  60097. setDepthFunctionToGreaterOrEqual(): void;
  60098. setDepthFunctionToLess(): void;
  60099. setDepthFunctionToLessOrEqual(): void;
  60100. /**
  60101. * Enable or disable depth writing
  60102. * @param enable defines the state to set
  60103. */
  60104. setDepthWrite(enable: boolean): void;
  60105. /**
  60106. * Enable or disable color writing
  60107. * @param enable defines the state to set
  60108. */
  60109. setColorWrite(enable: boolean): void;
  60110. /**
  60111. * Gets a boolean indicating if color writing is enabled
  60112. * @returns the current color writing state
  60113. */
  60114. getColorWrite(): boolean;
  60115. /**
  60116. * Sets alpha constants used by some alpha blending modes
  60117. * @param r defines the red component
  60118. * @param g defines the green component
  60119. * @param b defines the blue component
  60120. * @param a defines the alpha component
  60121. */
  60122. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  60123. /**
  60124. * Sets the current alpha mode
  60125. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  60126. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  60127. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  60128. */
  60129. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  60130. /**
  60131. * Gets the current alpha mode
  60132. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  60133. * @returns the current alpha mode
  60134. */
  60135. getAlphaMode(): number;
  60136. setInt(uniform: WebGLUniformLocation, int: number): boolean;
  60137. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  60138. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  60139. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  60140. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  60141. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  60142. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  60143. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  60144. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  60145. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  60146. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  60147. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  60148. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  60149. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  60150. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  60151. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  60152. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  60153. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  60154. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  60155. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  60156. setColor3(uniform: WebGLUniformLocation, color3: IColor3Like): boolean;
  60157. setColor4(uniform: WebGLUniformLocation, color3: IColor3Like, alpha: number): boolean;
  60158. wipeCaches(bruteForce?: boolean): void;
  60159. protected _createTexture(): WebGLTexture;
  60160. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  60161. /**
  60162. * Update the content of a dynamic texture
  60163. * @param texture defines the texture to update
  60164. * @param canvas defines the canvas containing the source
  60165. * @param invertY defines if data must be stored with Y axis inverted
  60166. * @param premulAlpha defines if alpha is stored as premultiplied
  60167. * @param format defines the format of the data
  60168. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  60169. */
  60170. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  60171. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  60172. updateRawTexture(texture: Nullable<InternalTexture>, bufferView: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  60173. /**
  60174. * Usually called from Texture.ts.
  60175. * Passed information to create a WebGLTexture
  60176. * @param url defines a value which contains one of the following:
  60177. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  60178. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  60179. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  60180. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  60181. * @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)
  60182. * @param scene needed for loading to the correct scene
  60183. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  60184. * @param onLoad optional callback to be called upon successful completion
  60185. * @param onError optional callback to be called upon failure
  60186. * @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
  60187. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  60188. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  60189. * @param forcedExtension defines the extension to use to pick the right loader
  60190. * @param mimeType defines an optional mime type
  60191. * @param loaderOptions options to be passed to the loader
  60192. * @returns a InternalTexture for assignment back into BABYLON.Texture
  60193. */
  60194. 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;
  60195. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): NativeTexture;
  60196. _releaseFramebufferObjects(texture: InternalTexture): void;
  60197. /**
  60198. * Creates a cube texture
  60199. * @param rootUrl defines the url where the files to load is located
  60200. * @param scene defines the current scene
  60201. * @param files defines the list of files to load (1 per face)
  60202. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  60203. * @param onLoad defines an optional callback raised when the texture is loaded
  60204. * @param onError defines an optional callback raised if there is an issue to load the texture
  60205. * @param format defines the format of the data
  60206. * @param forcedExtension defines the extension to use to pick the right loader
  60207. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  60208. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  60209. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  60210. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  60211. * @returns the cube texture as an InternalTexture
  60212. */
  60213. 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;
  60214. createRenderTargetTexture(size: number | {
  60215. width: number;
  60216. height: number;
  60217. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  60218. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  60219. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  60220. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  60221. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  60222. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  60223. /**
  60224. * Updates a dynamic vertex buffer.
  60225. * @param vertexBuffer the vertex buffer to update
  60226. * @param data the data used to update the vertex buffer
  60227. * @param byteOffset the byte offset of the data (optional)
  60228. * @param byteLength the byte length of the data (optional)
  60229. */
  60230. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  60231. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  60232. private _updateAnisotropicLevel;
  60233. private _getAddressMode;
  60234. /** @hidden */
  60235. _bindTexture(channel: number, texture: InternalTexture): void;
  60236. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  60237. releaseEffects(): void;
  60238. /** @hidden */
  60239. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  60240. /** @hidden */
  60241. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  60242. /** @hidden */
  60243. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  60244. /** @hidden */
  60245. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  60246. private _getNativeSamplingMode;
  60247. private _getNativeTextureFormat;
  60248. private _getNativeAlphaMode;
  60249. private _getNativeAttribType;
  60250. }
  60251. }
  60252. declare module BABYLON {
  60253. /**
  60254. * Helper class to create the best engine depending on the current hardware
  60255. */
  60256. export class EngineFactory {
  60257. /**
  60258. * Creates an engine based on the capabilities of the underlying hardware
  60259. * @param canvas Defines the canvas to use to display the result
  60260. * @param options Defines the options passed to the engine to create the context dependencies
  60261. * @returns a promise that resolves with the created engine
  60262. */
  60263. static CreateAsync(canvas: HTMLCanvasElement, options: any): Promise<ThinEngine>;
  60264. }
  60265. }
  60266. declare module BABYLON {
  60267. /**
  60268. * Gather the list of clipboard event types as constants.
  60269. */
  60270. export class ClipboardEventTypes {
  60271. /**
  60272. * The clipboard event is fired when a copy command is active (pressed).
  60273. */
  60274. static readonly COPY: number;
  60275. /**
  60276. * The clipboard event is fired when a cut command is active (pressed).
  60277. */
  60278. static readonly CUT: number;
  60279. /**
  60280. * The clipboard event is fired when a paste command is active (pressed).
  60281. */
  60282. static readonly PASTE: number;
  60283. }
  60284. /**
  60285. * This class is used to store clipboard related info for the onClipboardObservable event.
  60286. */
  60287. export class ClipboardInfo {
  60288. /**
  60289. * Defines the type of event (BABYLON.ClipboardEventTypes)
  60290. */
  60291. type: number;
  60292. /**
  60293. * Defines the related dom event
  60294. */
  60295. event: ClipboardEvent;
  60296. /**
  60297. *Creates an instance of ClipboardInfo.
  60298. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  60299. * @param event Defines the related dom event
  60300. */
  60301. constructor(
  60302. /**
  60303. * Defines the type of event (BABYLON.ClipboardEventTypes)
  60304. */
  60305. type: number,
  60306. /**
  60307. * Defines the related dom event
  60308. */
  60309. event: ClipboardEvent);
  60310. /**
  60311. * Get the clipboard event's type from the keycode.
  60312. * @param keyCode Defines the keyCode for the current keyboard event.
  60313. * @return {number}
  60314. */
  60315. static GetTypeFromCharacter(keyCode: number): number;
  60316. }
  60317. }
  60318. declare module BABYLON {
  60319. /**
  60320. * Google Daydream controller
  60321. */
  60322. export class DaydreamController extends WebVRController {
  60323. /**
  60324. * Base Url for the controller model.
  60325. */
  60326. static MODEL_BASE_URL: string;
  60327. /**
  60328. * File name for the controller model.
  60329. */
  60330. static MODEL_FILENAME: string;
  60331. /**
  60332. * Gamepad Id prefix used to identify Daydream Controller.
  60333. */
  60334. static readonly GAMEPAD_ID_PREFIX: string;
  60335. /**
  60336. * Creates a new DaydreamController from a gamepad
  60337. * @param vrGamepad the gamepad that the controller should be created from
  60338. */
  60339. constructor(vrGamepad: any);
  60340. /**
  60341. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  60342. * @param scene scene in which to add meshes
  60343. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  60344. */
  60345. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  60346. /**
  60347. * Called once for each button that changed state since the last frame
  60348. * @param buttonIdx Which button index changed
  60349. * @param state New state of the button
  60350. * @param changes Which properties on the state changed since last frame
  60351. */
  60352. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  60353. }
  60354. }
  60355. declare module BABYLON {
  60356. /**
  60357. * Gear VR Controller
  60358. */
  60359. export class GearVRController extends WebVRController {
  60360. /**
  60361. * Base Url for the controller model.
  60362. */
  60363. static MODEL_BASE_URL: string;
  60364. /**
  60365. * File name for the controller model.
  60366. */
  60367. static MODEL_FILENAME: string;
  60368. /**
  60369. * Gamepad Id prefix used to identify this controller.
  60370. */
  60371. static readonly GAMEPAD_ID_PREFIX: string;
  60372. private readonly _buttonIndexToObservableNameMap;
  60373. /**
  60374. * Creates a new GearVRController from a gamepad
  60375. * @param vrGamepad the gamepad that the controller should be created from
  60376. */
  60377. constructor(vrGamepad: any);
  60378. /**
  60379. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  60380. * @param scene scene in which to add meshes
  60381. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  60382. */
  60383. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  60384. /**
  60385. * Called once for each button that changed state since the last frame
  60386. * @param buttonIdx Which button index changed
  60387. * @param state New state of the button
  60388. * @param changes Which properties on the state changed since last frame
  60389. */
  60390. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  60391. }
  60392. }
  60393. declare module BABYLON {
  60394. /**
  60395. * Generic Controller
  60396. */
  60397. export class GenericController extends WebVRController {
  60398. /**
  60399. * Base Url for the controller model.
  60400. */
  60401. static readonly MODEL_BASE_URL: string;
  60402. /**
  60403. * File name for the controller model.
  60404. */
  60405. static readonly MODEL_FILENAME: string;
  60406. /**
  60407. * Creates a new GenericController from a gamepad
  60408. * @param vrGamepad the gamepad that the controller should be created from
  60409. */
  60410. constructor(vrGamepad: any);
  60411. /**
  60412. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  60413. * @param scene scene in which to add meshes
  60414. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  60415. */
  60416. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  60417. /**
  60418. * Called once for each button that changed state since the last frame
  60419. * @param buttonIdx Which button index changed
  60420. * @param state New state of the button
  60421. * @param changes Which properties on the state changed since last frame
  60422. */
  60423. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  60424. }
  60425. }
  60426. declare module BABYLON {
  60427. /**
  60428. * Oculus Touch Controller
  60429. */
  60430. export class OculusTouchController extends WebVRController {
  60431. /**
  60432. * Base Url for the controller model.
  60433. */
  60434. static MODEL_BASE_URL: string;
  60435. /**
  60436. * File name for the left controller model.
  60437. */
  60438. static MODEL_LEFT_FILENAME: string;
  60439. /**
  60440. * File name for the right controller model.
  60441. */
  60442. static MODEL_RIGHT_FILENAME: string;
  60443. /**
  60444. * Base Url for the Quest controller model.
  60445. */
  60446. static QUEST_MODEL_BASE_URL: string;
  60447. /**
  60448. * @hidden
  60449. * If the controllers are running on a device that needs the updated Quest controller models
  60450. */
  60451. static _IsQuest: boolean;
  60452. /**
  60453. * Fired when the secondary trigger on this controller is modified
  60454. */
  60455. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  60456. /**
  60457. * Fired when the thumb rest on this controller is modified
  60458. */
  60459. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  60460. /**
  60461. * Creates a new OculusTouchController from a gamepad
  60462. * @param vrGamepad the gamepad that the controller should be created from
  60463. */
  60464. constructor(vrGamepad: any);
  60465. /**
  60466. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  60467. * @param scene scene in which to add meshes
  60468. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  60469. */
  60470. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  60471. /**
  60472. * Fired when the A button on this controller is modified
  60473. */
  60474. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60475. /**
  60476. * Fired when the B button on this controller is modified
  60477. */
  60478. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60479. /**
  60480. * Fired when the X button on this controller is modified
  60481. */
  60482. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60483. /**
  60484. * Fired when the Y button on this controller is modified
  60485. */
  60486. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60487. /**
  60488. * Called once for each button that changed state since the last frame
  60489. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  60490. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  60491. * 2) secondary trigger (same)
  60492. * 3) A (right) X (left), touch, pressed = value
  60493. * 4) B / Y
  60494. * 5) thumb rest
  60495. * @param buttonIdx Which button index changed
  60496. * @param state New state of the button
  60497. * @param changes Which properties on the state changed since last frame
  60498. */
  60499. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  60500. }
  60501. }
  60502. declare module BABYLON {
  60503. /**
  60504. * Vive Controller
  60505. */
  60506. export class ViveController extends WebVRController {
  60507. /**
  60508. * Base Url for the controller model.
  60509. */
  60510. static MODEL_BASE_URL: string;
  60511. /**
  60512. * File name for the controller model.
  60513. */
  60514. static MODEL_FILENAME: string;
  60515. /**
  60516. * Creates a new ViveController from a gamepad
  60517. * @param vrGamepad the gamepad that the controller should be created from
  60518. */
  60519. constructor(vrGamepad: any);
  60520. /**
  60521. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  60522. * @param scene scene in which to add meshes
  60523. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  60524. */
  60525. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  60526. /**
  60527. * Fired when the left button on this controller is modified
  60528. */
  60529. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60530. /**
  60531. * Fired when the right button on this controller is modified
  60532. */
  60533. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60534. /**
  60535. * Fired when the menu button on this controller is modified
  60536. */
  60537. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60538. /**
  60539. * Called once for each button that changed state since the last frame
  60540. * Vive mapping:
  60541. * 0: touchpad
  60542. * 1: trigger
  60543. * 2: left AND right buttons
  60544. * 3: menu button
  60545. * @param buttonIdx Which button index changed
  60546. * @param state New state of the button
  60547. * @param changes Which properties on the state changed since last frame
  60548. */
  60549. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  60550. }
  60551. }
  60552. declare module BABYLON {
  60553. /**
  60554. * Defines the WindowsMotionController object that the state of the windows motion controller
  60555. */
  60556. export class WindowsMotionController extends WebVRController {
  60557. /**
  60558. * The base url used to load the left and right controller models
  60559. */
  60560. static MODEL_BASE_URL: string;
  60561. /**
  60562. * The name of the left controller model file
  60563. */
  60564. static MODEL_LEFT_FILENAME: string;
  60565. /**
  60566. * The name of the right controller model file
  60567. */
  60568. static MODEL_RIGHT_FILENAME: string;
  60569. /**
  60570. * The controller name prefix for this controller type
  60571. */
  60572. static readonly GAMEPAD_ID_PREFIX: string;
  60573. /**
  60574. * The controller id pattern for this controller type
  60575. */
  60576. private static readonly GAMEPAD_ID_PATTERN;
  60577. private _loadedMeshInfo;
  60578. protected readonly _mapping: {
  60579. buttons: string[];
  60580. buttonMeshNames: {
  60581. trigger: string;
  60582. menu: string;
  60583. grip: string;
  60584. thumbstick: string;
  60585. trackpad: string;
  60586. };
  60587. buttonObservableNames: {
  60588. trigger: string;
  60589. menu: string;
  60590. grip: string;
  60591. thumbstick: string;
  60592. trackpad: string;
  60593. };
  60594. axisMeshNames: string[];
  60595. pointingPoseMeshName: string;
  60596. };
  60597. /**
  60598. * Fired when the trackpad on this controller is clicked
  60599. */
  60600. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  60601. /**
  60602. * Fired when the trackpad on this controller is modified
  60603. */
  60604. onTrackpadValuesChangedObservable: Observable<StickValues>;
  60605. /**
  60606. * The current x and y values of this controller's trackpad
  60607. */
  60608. trackpad: StickValues;
  60609. /**
  60610. * Creates a new WindowsMotionController from a gamepad
  60611. * @param vrGamepad the gamepad that the controller should be created from
  60612. */
  60613. constructor(vrGamepad: any);
  60614. /**
  60615. * Fired when the trigger on this controller is modified
  60616. */
  60617. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60618. /**
  60619. * Fired when the menu button on this controller is modified
  60620. */
  60621. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60622. /**
  60623. * Fired when the grip button on this controller is modified
  60624. */
  60625. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60626. /**
  60627. * Fired when the thumbstick button on this controller is modified
  60628. */
  60629. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60630. /**
  60631. * Fired when the touchpad button on this controller is modified
  60632. */
  60633. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60634. /**
  60635. * Fired when the touchpad values on this controller are modified
  60636. */
  60637. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  60638. protected _updateTrackpad(): void;
  60639. /**
  60640. * Called once per frame by the engine.
  60641. */
  60642. update(): void;
  60643. /**
  60644. * Called once for each button that changed state since the last frame
  60645. * @param buttonIdx Which button index changed
  60646. * @param state New state of the button
  60647. * @param changes Which properties on the state changed since last frame
  60648. */
  60649. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  60650. /**
  60651. * Moves the buttons on the controller mesh based on their current state
  60652. * @param buttonName the name of the button to move
  60653. * @param buttonValue the value of the button which determines the buttons new position
  60654. */
  60655. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  60656. /**
  60657. * Moves the axis on the controller mesh based on its current state
  60658. * @param axis the index of the axis
  60659. * @param axisValue the value of the axis which determines the meshes new position
  60660. * @hidden
  60661. */
  60662. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  60663. /**
  60664. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  60665. * @param scene scene in which to add meshes
  60666. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  60667. */
  60668. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  60669. /**
  60670. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  60671. * can be transformed by button presses and axes values, based on this._mapping.
  60672. *
  60673. * @param scene scene in which the meshes exist
  60674. * @param meshes list of meshes that make up the controller model to process
  60675. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  60676. */
  60677. private processModel;
  60678. private createMeshInfo;
  60679. /**
  60680. * Gets the ray of the controller in the direction the controller is pointing
  60681. * @param length the length the resulting ray should be
  60682. * @returns a ray in the direction the controller is pointing
  60683. */
  60684. getForwardRay(length?: number): Ray;
  60685. /**
  60686. * Disposes of the controller
  60687. */
  60688. dispose(): void;
  60689. }
  60690. /**
  60691. * This class represents a new windows motion controller in XR.
  60692. */
  60693. export class XRWindowsMotionController extends WindowsMotionController {
  60694. /**
  60695. * Changing the original WIndowsMotionController mapping to fir the new mapping
  60696. */
  60697. protected readonly _mapping: {
  60698. buttons: string[];
  60699. buttonMeshNames: {
  60700. trigger: string;
  60701. menu: string;
  60702. grip: string;
  60703. thumbstick: string;
  60704. trackpad: string;
  60705. };
  60706. buttonObservableNames: {
  60707. trigger: string;
  60708. menu: string;
  60709. grip: string;
  60710. thumbstick: string;
  60711. trackpad: string;
  60712. };
  60713. axisMeshNames: string[];
  60714. pointingPoseMeshName: string;
  60715. };
  60716. /**
  60717. * Construct a new XR-Based windows motion controller
  60718. *
  60719. * @param gamepadInfo the gamepad object from the browser
  60720. */
  60721. constructor(gamepadInfo: any);
  60722. /**
  60723. * holds the thumbstick values (X,Y)
  60724. */
  60725. thumbstickValues: StickValues;
  60726. /**
  60727. * Fired when the thumbstick on this controller is clicked
  60728. */
  60729. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  60730. /**
  60731. * Fired when the thumbstick on this controller is modified
  60732. */
  60733. onThumbstickValuesChangedObservable: Observable<StickValues>;
  60734. /**
  60735. * Fired when the touchpad button on this controller is modified
  60736. */
  60737. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  60738. /**
  60739. * Fired when the touchpad values on this controller are modified
  60740. */
  60741. onTrackpadValuesChangedObservable: Observable<StickValues>;
  60742. /**
  60743. * Fired when the thumbstick button on this controller is modified
  60744. * here to prevent breaking changes
  60745. */
  60746. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60747. /**
  60748. * updating the thumbstick(!) and not the trackpad.
  60749. * This is named this way due to the difference between WebVR and XR and to avoid
  60750. * changing the parent class.
  60751. */
  60752. protected _updateTrackpad(): void;
  60753. /**
  60754. * Disposes the class with joy
  60755. */
  60756. dispose(): void;
  60757. }
  60758. }
  60759. declare module BABYLON {
  60760. /**
  60761. * A directional light is defined by a direction (what a surprise!).
  60762. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  60763. * 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.
  60764. * Documentation: https://doc.babylonjs.com/babylon101/lights
  60765. */
  60766. export class DirectionalLight extends ShadowLight {
  60767. private _shadowFrustumSize;
  60768. /**
  60769. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  60770. */
  60771. get shadowFrustumSize(): number;
  60772. /**
  60773. * Specifies a fix frustum size for the shadow generation.
  60774. */
  60775. set shadowFrustumSize(value: number);
  60776. private _shadowOrthoScale;
  60777. /**
  60778. * Gets the shadow projection scale against the optimal computed one.
  60779. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  60780. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  60781. */
  60782. get shadowOrthoScale(): number;
  60783. /**
  60784. * Sets the shadow projection scale against the optimal computed one.
  60785. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  60786. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  60787. */
  60788. set shadowOrthoScale(value: number);
  60789. /**
  60790. * Automatically compute the projection matrix to best fit (including all the casters)
  60791. * on each frame.
  60792. */
  60793. autoUpdateExtends: boolean;
  60794. /**
  60795. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  60796. * on each frame. autoUpdateExtends must be set to true for this to work
  60797. */
  60798. autoCalcShadowZBounds: boolean;
  60799. private _orthoLeft;
  60800. private _orthoRight;
  60801. private _orthoTop;
  60802. private _orthoBottom;
  60803. /**
  60804. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  60805. * The directional light is emitted from everywhere in the given direction.
  60806. * It can cast shadows.
  60807. * Documentation : https://doc.babylonjs.com/babylon101/lights
  60808. * @param name The friendly name of the light
  60809. * @param direction The direction of the light
  60810. * @param scene The scene the light belongs to
  60811. */
  60812. constructor(name: string, direction: Vector3, scene: Scene);
  60813. /**
  60814. * Returns the string "DirectionalLight".
  60815. * @return The class name
  60816. */
  60817. getClassName(): string;
  60818. /**
  60819. * Returns the integer 1.
  60820. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  60821. */
  60822. getTypeID(): number;
  60823. /**
  60824. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  60825. * Returns the DirectionalLight Shadow projection matrix.
  60826. */
  60827. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  60828. /**
  60829. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  60830. * Returns the DirectionalLight Shadow projection matrix.
  60831. */
  60832. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  60833. /**
  60834. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  60835. * Returns the DirectionalLight Shadow projection matrix.
  60836. */
  60837. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  60838. protected _buildUniformLayout(): void;
  60839. /**
  60840. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  60841. * @param effect The effect to update
  60842. * @param lightIndex The index of the light in the effect to update
  60843. * @returns The directional light
  60844. */
  60845. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  60846. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  60847. /**
  60848. * Gets the minZ used for shadow according to both the scene and the light.
  60849. *
  60850. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  60851. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  60852. * @param activeCamera The camera we are returning the min for
  60853. * @returns the depth min z
  60854. */
  60855. getDepthMinZ(activeCamera: Camera): number;
  60856. /**
  60857. * Gets the maxZ used for shadow according to both the scene and the light.
  60858. *
  60859. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  60860. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  60861. * @param activeCamera The camera we are returning the max for
  60862. * @returns the depth max z
  60863. */
  60864. getDepthMaxZ(activeCamera: Camera): number;
  60865. /**
  60866. * Prepares the list of defines specific to the light type.
  60867. * @param defines the list of defines
  60868. * @param lightIndex defines the index of the light for the effect
  60869. */
  60870. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  60871. }
  60872. }
  60873. declare module BABYLON {
  60874. /**
  60875. * Class containing static functions to help procedurally build meshes
  60876. */
  60877. export class HemisphereBuilder {
  60878. /**
  60879. * Creates a hemisphere mesh
  60880. * @param name defines the name of the mesh
  60881. * @param options defines the options used to create the mesh
  60882. * @param scene defines the hosting scene
  60883. * @returns the hemisphere mesh
  60884. */
  60885. static CreateHemisphere(name: string, options: {
  60886. segments?: number;
  60887. diameter?: number;
  60888. sideOrientation?: number;
  60889. }, scene: any): Mesh;
  60890. }
  60891. }
  60892. declare module BABYLON {
  60893. /**
  60894. * A spot light is defined by a position, a direction, an angle, and an exponent.
  60895. * These values define a cone of light starting from the position, emitting toward the direction.
  60896. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  60897. * and the exponent defines the speed of the decay of the light with distance (reach).
  60898. * Documentation: https://doc.babylonjs.com/babylon101/lights
  60899. */
  60900. export class SpotLight extends ShadowLight {
  60901. private _angle;
  60902. private _innerAngle;
  60903. private _cosHalfAngle;
  60904. private _lightAngleScale;
  60905. private _lightAngleOffset;
  60906. /**
  60907. * Gets the cone angle of the spot light in Radians.
  60908. */
  60909. get angle(): number;
  60910. /**
  60911. * Sets the cone angle of the spot light in Radians.
  60912. */
  60913. set angle(value: number);
  60914. /**
  60915. * Only used in gltf falloff mode, this defines the angle where
  60916. * the directional falloff will start before cutting at angle which could be seen
  60917. * as outer angle.
  60918. */
  60919. get innerAngle(): number;
  60920. /**
  60921. * Only used in gltf falloff mode, this defines the angle where
  60922. * the directional falloff will start before cutting at angle which could be seen
  60923. * as outer angle.
  60924. */
  60925. set innerAngle(value: number);
  60926. private _shadowAngleScale;
  60927. /**
  60928. * Allows scaling the angle of the light for shadow generation only.
  60929. */
  60930. get shadowAngleScale(): number;
  60931. /**
  60932. * Allows scaling the angle of the light for shadow generation only.
  60933. */
  60934. set shadowAngleScale(value: number);
  60935. /**
  60936. * The light decay speed with the distance from the emission spot.
  60937. */
  60938. exponent: number;
  60939. private _projectionTextureMatrix;
  60940. /**
  60941. * Allows reading the projecton texture
  60942. */
  60943. get projectionTextureMatrix(): Matrix;
  60944. protected _projectionTextureLightNear: number;
  60945. /**
  60946. * Gets the near clip of the Spotlight for texture projection.
  60947. */
  60948. get projectionTextureLightNear(): number;
  60949. /**
  60950. * Sets the near clip of the Spotlight for texture projection.
  60951. */
  60952. set projectionTextureLightNear(value: number);
  60953. protected _projectionTextureLightFar: number;
  60954. /**
  60955. * Gets the far clip of the Spotlight for texture projection.
  60956. */
  60957. get projectionTextureLightFar(): number;
  60958. /**
  60959. * Sets the far clip of the Spotlight for texture projection.
  60960. */
  60961. set projectionTextureLightFar(value: number);
  60962. protected _projectionTextureUpDirection: Vector3;
  60963. /**
  60964. * Gets the Up vector of the Spotlight for texture projection.
  60965. */
  60966. get projectionTextureUpDirection(): Vector3;
  60967. /**
  60968. * Sets the Up vector of the Spotlight for texture projection.
  60969. */
  60970. set projectionTextureUpDirection(value: Vector3);
  60971. private _projectionTexture;
  60972. /**
  60973. * Gets the projection texture of the light.
  60974. */
  60975. get projectionTexture(): Nullable<BaseTexture>;
  60976. /**
  60977. * Sets the projection texture of the light.
  60978. */
  60979. set projectionTexture(value: Nullable<BaseTexture>);
  60980. private static _IsProceduralTexture;
  60981. private static _IsTexture;
  60982. private _projectionTextureViewLightDirty;
  60983. private _projectionTextureProjectionLightDirty;
  60984. private _projectionTextureDirty;
  60985. private _projectionTextureViewTargetVector;
  60986. private _projectionTextureViewLightMatrix;
  60987. private _projectionTextureProjectionLightMatrix;
  60988. private _projectionTextureScalingMatrix;
  60989. /**
  60990. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  60991. * It can cast shadows.
  60992. * Documentation : https://doc.babylonjs.com/babylon101/lights
  60993. * @param name The light friendly name
  60994. * @param position The position of the spot light in the scene
  60995. * @param direction The direction of the light in the scene
  60996. * @param angle The cone angle of the light in Radians
  60997. * @param exponent The light decay speed with the distance from the emission spot
  60998. * @param scene The scene the lights belongs to
  60999. */
  61000. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  61001. /**
  61002. * Returns the string "SpotLight".
  61003. * @returns the class name
  61004. */
  61005. getClassName(): string;
  61006. /**
  61007. * Returns the integer 2.
  61008. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  61009. */
  61010. getTypeID(): number;
  61011. /**
  61012. * Overrides the direction setter to recompute the projection texture view light Matrix.
  61013. */
  61014. protected _setDirection(value: Vector3): void;
  61015. /**
  61016. * Overrides the position setter to recompute the projection texture view light Matrix.
  61017. */
  61018. protected _setPosition(value: Vector3): void;
  61019. /**
  61020. * 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.
  61021. * Returns the SpotLight.
  61022. */
  61023. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  61024. protected _computeProjectionTextureViewLightMatrix(): void;
  61025. protected _computeProjectionTextureProjectionLightMatrix(): void;
  61026. /**
  61027. * Main function for light texture projection matrix computing.
  61028. */
  61029. protected _computeProjectionTextureMatrix(): void;
  61030. protected _buildUniformLayout(): void;
  61031. private _computeAngleValues;
  61032. /**
  61033. * Sets the passed Effect "effect" with the Light textures.
  61034. * @param effect The effect to update
  61035. * @param lightIndex The index of the light in the effect to update
  61036. * @returns The light
  61037. */
  61038. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  61039. /**
  61040. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  61041. * @param effect The effect to update
  61042. * @param lightIndex The index of the light in the effect to update
  61043. * @returns The spot light
  61044. */
  61045. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  61046. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  61047. /**
  61048. * Disposes the light and the associated resources.
  61049. */
  61050. dispose(): void;
  61051. /**
  61052. * Prepares the list of defines specific to the light type.
  61053. * @param defines the list of defines
  61054. * @param lightIndex defines the index of the light for the effect
  61055. */
  61056. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  61057. }
  61058. }
  61059. declare module BABYLON {
  61060. /**
  61061. * Gizmo that enables viewing a light
  61062. */
  61063. export class LightGizmo extends Gizmo {
  61064. private _lightMesh;
  61065. private _material;
  61066. private _cachedPosition;
  61067. private _cachedForward;
  61068. private _attachedMeshParent;
  61069. private _pointerObserver;
  61070. /**
  61071. * Event that fires each time the gizmo is clicked
  61072. */
  61073. onClickedObservable: Observable<Light>;
  61074. /**
  61075. * Creates a LightGizmo
  61076. * @param gizmoLayer The utility layer the gizmo will be added to
  61077. */
  61078. constructor(gizmoLayer?: UtilityLayerRenderer);
  61079. private _light;
  61080. /**
  61081. * The light that the gizmo is attached to
  61082. */
  61083. set light(light: Nullable<Light>);
  61084. get light(): Nullable<Light>;
  61085. /**
  61086. * Gets the material used to render the light gizmo
  61087. */
  61088. get material(): StandardMaterial;
  61089. /**
  61090. * @hidden
  61091. * Updates the gizmo to match the attached mesh's position/rotation
  61092. */
  61093. protected _update(): void;
  61094. private static _Scale;
  61095. /**
  61096. * Creates the lines for a light mesh
  61097. */
  61098. private static _CreateLightLines;
  61099. /**
  61100. * Disposes of the light gizmo
  61101. */
  61102. dispose(): void;
  61103. private static _CreateHemisphericLightMesh;
  61104. private static _CreatePointLightMesh;
  61105. private static _CreateSpotLightMesh;
  61106. private static _CreateDirectionalLightMesh;
  61107. }
  61108. }
  61109. declare module BABYLON {
  61110. /**
  61111. * Gizmo that enables viewing a camera
  61112. */
  61113. export class CameraGizmo extends Gizmo {
  61114. private _cameraMesh;
  61115. private _cameraLinesMesh;
  61116. private _material;
  61117. private _pointerObserver;
  61118. /**
  61119. * Event that fires each time the gizmo is clicked
  61120. */
  61121. onClickedObservable: Observable<Camera>;
  61122. /**
  61123. * Creates a CameraGizmo
  61124. * @param gizmoLayer The utility layer the gizmo will be added to
  61125. */
  61126. constructor(gizmoLayer?: UtilityLayerRenderer);
  61127. private _camera;
  61128. /** Gets or sets a boolean indicating if frustum lines must be rendered (true by default)) */
  61129. get displayFrustum(): boolean;
  61130. set displayFrustum(value: boolean);
  61131. /**
  61132. * The camera that the gizmo is attached to
  61133. */
  61134. set camera(camera: Nullable<Camera>);
  61135. get camera(): Nullable<Camera>;
  61136. /**
  61137. * Gets the material used to render the camera gizmo
  61138. */
  61139. get material(): StandardMaterial;
  61140. /**
  61141. * @hidden
  61142. * Updates the gizmo to match the attached mesh's position/rotation
  61143. */
  61144. protected _update(): void;
  61145. private static _Scale;
  61146. private _invProjection;
  61147. /**
  61148. * Disposes of the camera gizmo
  61149. */
  61150. dispose(): void;
  61151. private static _CreateCameraMesh;
  61152. private static _CreateCameraFrustum;
  61153. }
  61154. }
  61155. declare module BABYLON {
  61156. /** @hidden */
  61157. export var backgroundFragmentDeclaration: {
  61158. name: string;
  61159. shader: string;
  61160. };
  61161. }
  61162. declare module BABYLON {
  61163. /** @hidden */
  61164. export var backgroundUboDeclaration: {
  61165. name: string;
  61166. shader: string;
  61167. };
  61168. }
  61169. declare module BABYLON {
  61170. /** @hidden */
  61171. export var backgroundPixelShader: {
  61172. name: string;
  61173. shader: string;
  61174. };
  61175. }
  61176. declare module BABYLON {
  61177. /** @hidden */
  61178. export var backgroundVertexDeclaration: {
  61179. name: string;
  61180. shader: string;
  61181. };
  61182. }
  61183. declare module BABYLON {
  61184. /** @hidden */
  61185. export var backgroundVertexShader: {
  61186. name: string;
  61187. shader: string;
  61188. };
  61189. }
  61190. declare module BABYLON {
  61191. /**
  61192. * Background material used to create an efficient environement around your scene.
  61193. */
  61194. export class BackgroundMaterial extends PushMaterial {
  61195. /**
  61196. * Standard reflectance value at parallel view angle.
  61197. */
  61198. static StandardReflectance0: number;
  61199. /**
  61200. * Standard reflectance value at grazing angle.
  61201. */
  61202. static StandardReflectance90: number;
  61203. protected _primaryColor: Color3;
  61204. /**
  61205. * Key light Color (multiply against the environement texture)
  61206. */
  61207. primaryColor: Color3;
  61208. protected __perceptualColor: Nullable<Color3>;
  61209. /**
  61210. * Experimental Internal Use Only.
  61211. *
  61212. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  61213. * This acts as a helper to set the primary color to a more "human friendly" value.
  61214. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  61215. * output color as close as possible from the chosen value.
  61216. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  61217. * part of lighting setup.)
  61218. */
  61219. get _perceptualColor(): Nullable<Color3>;
  61220. set _perceptualColor(value: Nullable<Color3>);
  61221. protected _primaryColorShadowLevel: float;
  61222. /**
  61223. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  61224. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  61225. */
  61226. get primaryColorShadowLevel(): float;
  61227. set primaryColorShadowLevel(value: float);
  61228. protected _primaryColorHighlightLevel: float;
  61229. /**
  61230. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  61231. * The primary color is used at the level chosen to define what the white area would look.
  61232. */
  61233. get primaryColorHighlightLevel(): float;
  61234. set primaryColorHighlightLevel(value: float);
  61235. protected _reflectionTexture: Nullable<BaseTexture>;
  61236. /**
  61237. * Reflection Texture used in the material.
  61238. * Should be author in a specific way for the best result (refer to the documentation).
  61239. */
  61240. reflectionTexture: Nullable<BaseTexture>;
  61241. protected _reflectionBlur: float;
  61242. /**
  61243. * Reflection Texture level of blur.
  61244. *
  61245. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  61246. * texture twice.
  61247. */
  61248. reflectionBlur: float;
  61249. protected _diffuseTexture: Nullable<BaseTexture>;
  61250. /**
  61251. * Diffuse Texture used in the material.
  61252. * Should be author in a specific way for the best result (refer to the documentation).
  61253. */
  61254. diffuseTexture: Nullable<BaseTexture>;
  61255. protected _shadowLights: Nullable<IShadowLight[]>;
  61256. /**
  61257. * Specify the list of lights casting shadow on the material.
  61258. * All scene shadow lights will be included if null.
  61259. */
  61260. shadowLights: Nullable<IShadowLight[]>;
  61261. protected _shadowLevel: float;
  61262. /**
  61263. * Helps adjusting the shadow to a softer level if required.
  61264. * 0 means black shadows and 1 means no shadows.
  61265. */
  61266. shadowLevel: float;
  61267. protected _sceneCenter: Vector3;
  61268. /**
  61269. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  61270. * It is usually zero but might be interesting to modify according to your setup.
  61271. */
  61272. sceneCenter: Vector3;
  61273. protected _opacityFresnel: boolean;
  61274. /**
  61275. * This helps specifying that the material is falling off to the sky box at grazing angle.
  61276. * This helps ensuring a nice transition when the camera goes under the ground.
  61277. */
  61278. opacityFresnel: boolean;
  61279. protected _reflectionFresnel: boolean;
  61280. /**
  61281. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  61282. * This helps adding a mirror texture on the ground.
  61283. */
  61284. reflectionFresnel: boolean;
  61285. protected _reflectionFalloffDistance: number;
  61286. /**
  61287. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  61288. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  61289. */
  61290. reflectionFalloffDistance: number;
  61291. protected _reflectionAmount: number;
  61292. /**
  61293. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  61294. */
  61295. reflectionAmount: number;
  61296. protected _reflectionReflectance0: number;
  61297. /**
  61298. * This specifies the weight of the reflection at grazing angle.
  61299. */
  61300. reflectionReflectance0: number;
  61301. protected _reflectionReflectance90: number;
  61302. /**
  61303. * This specifies the weight of the reflection at a perpendicular point of view.
  61304. */
  61305. reflectionReflectance90: number;
  61306. /**
  61307. * Sets the reflection reflectance fresnel values according to the default standard
  61308. * empirically know to work well :-)
  61309. */
  61310. set reflectionStandardFresnelWeight(value: number);
  61311. protected _useRGBColor: boolean;
  61312. /**
  61313. * Helps to directly use the maps channels instead of their level.
  61314. */
  61315. useRGBColor: boolean;
  61316. protected _enableNoise: boolean;
  61317. /**
  61318. * This helps reducing the banding effect that could occur on the background.
  61319. */
  61320. enableNoise: boolean;
  61321. /**
  61322. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  61323. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  61324. * Recommended to be keep at 1.0 except for special cases.
  61325. */
  61326. get fovMultiplier(): number;
  61327. set fovMultiplier(value: number);
  61328. private _fovMultiplier;
  61329. /**
  61330. * Enable the FOV adjustment feature controlled by fovMultiplier.
  61331. */
  61332. useEquirectangularFOV: boolean;
  61333. private _maxSimultaneousLights;
  61334. /**
  61335. * Number of Simultaneous lights allowed on the material.
  61336. */
  61337. maxSimultaneousLights: int;
  61338. private _shadowOnly;
  61339. /**
  61340. * Make the material only render shadows
  61341. */
  61342. shadowOnly: boolean;
  61343. /**
  61344. * Default configuration related to image processing available in the Background Material.
  61345. */
  61346. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  61347. /**
  61348. * Keep track of the image processing observer to allow dispose and replace.
  61349. */
  61350. private _imageProcessingObserver;
  61351. /**
  61352. * Attaches a new image processing configuration to the PBR Material.
  61353. * @param configuration (if null the scene configuration will be use)
  61354. */
  61355. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  61356. /**
  61357. * Gets the image processing configuration used either in this material.
  61358. */
  61359. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  61360. /**
  61361. * Sets the Default image processing configuration used either in the this material.
  61362. *
  61363. * If sets to null, the scene one is in use.
  61364. */
  61365. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  61366. /**
  61367. * Gets wether the color curves effect is enabled.
  61368. */
  61369. get cameraColorCurvesEnabled(): boolean;
  61370. /**
  61371. * Sets wether the color curves effect is enabled.
  61372. */
  61373. set cameraColorCurvesEnabled(value: boolean);
  61374. /**
  61375. * Gets wether the color grading effect is enabled.
  61376. */
  61377. get cameraColorGradingEnabled(): boolean;
  61378. /**
  61379. * Gets wether the color grading effect is enabled.
  61380. */
  61381. set cameraColorGradingEnabled(value: boolean);
  61382. /**
  61383. * Gets wether tonemapping is enabled or not.
  61384. */
  61385. get cameraToneMappingEnabled(): boolean;
  61386. /**
  61387. * Sets wether tonemapping is enabled or not
  61388. */
  61389. set cameraToneMappingEnabled(value: boolean);
  61390. /**
  61391. * The camera exposure used on this material.
  61392. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  61393. * This corresponds to a photographic exposure.
  61394. */
  61395. get cameraExposure(): float;
  61396. /**
  61397. * The camera exposure used on this material.
  61398. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  61399. * This corresponds to a photographic exposure.
  61400. */
  61401. set cameraExposure(value: float);
  61402. /**
  61403. * Gets The camera contrast used on this material.
  61404. */
  61405. get cameraContrast(): float;
  61406. /**
  61407. * Sets The camera contrast used on this material.
  61408. */
  61409. set cameraContrast(value: float);
  61410. /**
  61411. * Gets the Color Grading 2D Lookup Texture.
  61412. */
  61413. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  61414. /**
  61415. * Sets the Color Grading 2D Lookup Texture.
  61416. */
  61417. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  61418. /**
  61419. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  61420. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  61421. * 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;
  61422. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  61423. */
  61424. get cameraColorCurves(): Nullable<ColorCurves>;
  61425. /**
  61426. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  61427. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  61428. * 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;
  61429. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  61430. */
  61431. set cameraColorCurves(value: Nullable<ColorCurves>);
  61432. /**
  61433. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  61434. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  61435. */
  61436. switchToBGR: boolean;
  61437. private _renderTargets;
  61438. private _reflectionControls;
  61439. private _white;
  61440. private _primaryShadowColor;
  61441. private _primaryHighlightColor;
  61442. /**
  61443. * Instantiates a Background Material in the given scene
  61444. * @param name The friendly name of the material
  61445. * @param scene The scene to add the material to
  61446. */
  61447. constructor(name: string, scene: Scene);
  61448. /**
  61449. * Gets a boolean indicating that current material needs to register RTT
  61450. */
  61451. get hasRenderTargetTextures(): boolean;
  61452. /**
  61453. * The entire material has been created in order to prevent overdraw.
  61454. * @returns false
  61455. */
  61456. needAlphaTesting(): boolean;
  61457. /**
  61458. * The entire material has been created in order to prevent overdraw.
  61459. * @returns true if blending is enable
  61460. */
  61461. needAlphaBlending(): boolean;
  61462. /**
  61463. * Checks wether the material is ready to be rendered for a given mesh.
  61464. * @param mesh The mesh to render
  61465. * @param subMesh The submesh to check against
  61466. * @param useInstances Specify wether or not the material is used with instances
  61467. * @returns true if all the dependencies are ready (Textures, Effects...)
  61468. */
  61469. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  61470. /**
  61471. * Compute the primary color according to the chosen perceptual color.
  61472. */
  61473. private _computePrimaryColorFromPerceptualColor;
  61474. /**
  61475. * Compute the highlights and shadow colors according to their chosen levels.
  61476. */
  61477. private _computePrimaryColors;
  61478. /**
  61479. * Build the uniform buffer used in the material.
  61480. */
  61481. buildUniformLayout(): void;
  61482. /**
  61483. * Unbind the material.
  61484. */
  61485. unbind(): void;
  61486. /**
  61487. * Bind only the world matrix to the material.
  61488. * @param world The world matrix to bind.
  61489. */
  61490. bindOnlyWorldMatrix(world: Matrix): void;
  61491. /**
  61492. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  61493. * @param world The world matrix to bind.
  61494. * @param subMesh The submesh to bind for.
  61495. */
  61496. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  61497. /**
  61498. * Checks to see if a texture is used in the material.
  61499. * @param texture - Base texture to use.
  61500. * @returns - Boolean specifying if a texture is used in the material.
  61501. */
  61502. hasTexture(texture: BaseTexture): boolean;
  61503. /**
  61504. * Dispose the material.
  61505. * @param forceDisposeEffect Force disposal of the associated effect.
  61506. * @param forceDisposeTextures Force disposal of the associated textures.
  61507. */
  61508. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  61509. /**
  61510. * Clones the material.
  61511. * @param name The cloned name.
  61512. * @returns The cloned material.
  61513. */
  61514. clone(name: string): BackgroundMaterial;
  61515. /**
  61516. * Serializes the current material to its JSON representation.
  61517. * @returns The JSON representation.
  61518. */
  61519. serialize(): any;
  61520. /**
  61521. * Gets the class name of the material
  61522. * @returns "BackgroundMaterial"
  61523. */
  61524. getClassName(): string;
  61525. /**
  61526. * Parse a JSON input to create back a background material.
  61527. * @param source The JSON data to parse
  61528. * @param scene The scene to create the parsed material in
  61529. * @param rootUrl The root url of the assets the material depends upon
  61530. * @returns the instantiated BackgroundMaterial.
  61531. */
  61532. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  61533. }
  61534. }
  61535. declare module BABYLON {
  61536. /**
  61537. * Represents the different options available during the creation of
  61538. * a Environment helper.
  61539. *
  61540. * This can control the default ground, skybox and image processing setup of your scene.
  61541. */
  61542. export interface IEnvironmentHelperOptions {
  61543. /**
  61544. * Specifies whether or not to create a ground.
  61545. * True by default.
  61546. */
  61547. createGround: boolean;
  61548. /**
  61549. * Specifies the ground size.
  61550. * 15 by default.
  61551. */
  61552. groundSize: number;
  61553. /**
  61554. * The texture used on the ground for the main color.
  61555. * Comes from the BabylonJS CDN by default.
  61556. *
  61557. * Remarks: Can be either a texture or a url.
  61558. */
  61559. groundTexture: string | BaseTexture;
  61560. /**
  61561. * The color mixed in the ground texture by default.
  61562. * BabylonJS clearColor by default.
  61563. */
  61564. groundColor: Color3;
  61565. /**
  61566. * Specifies the ground opacity.
  61567. * 1 by default.
  61568. */
  61569. groundOpacity: number;
  61570. /**
  61571. * Enables the ground to receive shadows.
  61572. * True by default.
  61573. */
  61574. enableGroundShadow: boolean;
  61575. /**
  61576. * Helps preventing the shadow to be fully black on the ground.
  61577. * 0.5 by default.
  61578. */
  61579. groundShadowLevel: number;
  61580. /**
  61581. * Creates a mirror texture attach to the ground.
  61582. * false by default.
  61583. */
  61584. enableGroundMirror: boolean;
  61585. /**
  61586. * Specifies the ground mirror size ratio.
  61587. * 0.3 by default as the default kernel is 64.
  61588. */
  61589. groundMirrorSizeRatio: number;
  61590. /**
  61591. * Specifies the ground mirror blur kernel size.
  61592. * 64 by default.
  61593. */
  61594. groundMirrorBlurKernel: number;
  61595. /**
  61596. * Specifies the ground mirror visibility amount.
  61597. * 1 by default
  61598. */
  61599. groundMirrorAmount: number;
  61600. /**
  61601. * Specifies the ground mirror reflectance weight.
  61602. * This uses the standard weight of the background material to setup the fresnel effect
  61603. * of the mirror.
  61604. * 1 by default.
  61605. */
  61606. groundMirrorFresnelWeight: number;
  61607. /**
  61608. * Specifies the ground mirror Falloff distance.
  61609. * This can helps reducing the size of the reflection.
  61610. * 0 by Default.
  61611. */
  61612. groundMirrorFallOffDistance: number;
  61613. /**
  61614. * Specifies the ground mirror texture type.
  61615. * Unsigned Int by Default.
  61616. */
  61617. groundMirrorTextureType: number;
  61618. /**
  61619. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  61620. * the shown objects.
  61621. */
  61622. groundYBias: number;
  61623. /**
  61624. * Specifies whether or not to create a skybox.
  61625. * True by default.
  61626. */
  61627. createSkybox: boolean;
  61628. /**
  61629. * Specifies the skybox size.
  61630. * 20 by default.
  61631. */
  61632. skyboxSize: number;
  61633. /**
  61634. * The texture used on the skybox for the main color.
  61635. * Comes from the BabylonJS CDN by default.
  61636. *
  61637. * Remarks: Can be either a texture or a url.
  61638. */
  61639. skyboxTexture: string | BaseTexture;
  61640. /**
  61641. * The color mixed in the skybox texture by default.
  61642. * BabylonJS clearColor by default.
  61643. */
  61644. skyboxColor: Color3;
  61645. /**
  61646. * The background rotation around the Y axis of the scene.
  61647. * This helps aligning the key lights of your scene with the background.
  61648. * 0 by default.
  61649. */
  61650. backgroundYRotation: number;
  61651. /**
  61652. * Compute automatically the size of the elements to best fit with the scene.
  61653. */
  61654. sizeAuto: boolean;
  61655. /**
  61656. * Default position of the rootMesh if autoSize is not true.
  61657. */
  61658. rootPosition: Vector3;
  61659. /**
  61660. * Sets up the image processing in the scene.
  61661. * true by default.
  61662. */
  61663. setupImageProcessing: boolean;
  61664. /**
  61665. * The texture used as your environment texture in the scene.
  61666. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  61667. *
  61668. * Remarks: Can be either a texture or a url.
  61669. */
  61670. environmentTexture: string | BaseTexture;
  61671. /**
  61672. * The value of the exposure to apply to the scene.
  61673. * 0.6 by default if setupImageProcessing is true.
  61674. */
  61675. cameraExposure: number;
  61676. /**
  61677. * The value of the contrast to apply to the scene.
  61678. * 1.6 by default if setupImageProcessing is true.
  61679. */
  61680. cameraContrast: number;
  61681. /**
  61682. * Specifies whether or not tonemapping should be enabled in the scene.
  61683. * true by default if setupImageProcessing is true.
  61684. */
  61685. toneMappingEnabled: boolean;
  61686. }
  61687. /**
  61688. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  61689. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  61690. * It also helps with the default setup of your imageProcessing configuration.
  61691. */
  61692. export class EnvironmentHelper {
  61693. /**
  61694. * Default ground texture URL.
  61695. */
  61696. private static _groundTextureCDNUrl;
  61697. /**
  61698. * Default skybox texture URL.
  61699. */
  61700. private static _skyboxTextureCDNUrl;
  61701. /**
  61702. * Default environment texture URL.
  61703. */
  61704. private static _environmentTextureCDNUrl;
  61705. /**
  61706. * Creates the default options for the helper.
  61707. */
  61708. private static _getDefaultOptions;
  61709. private _rootMesh;
  61710. /**
  61711. * Gets the root mesh created by the helper.
  61712. */
  61713. get rootMesh(): Mesh;
  61714. private _skybox;
  61715. /**
  61716. * Gets the skybox created by the helper.
  61717. */
  61718. get skybox(): Nullable<Mesh>;
  61719. private _skyboxTexture;
  61720. /**
  61721. * Gets the skybox texture created by the helper.
  61722. */
  61723. get skyboxTexture(): Nullable<BaseTexture>;
  61724. private _skyboxMaterial;
  61725. /**
  61726. * Gets the skybox material created by the helper.
  61727. */
  61728. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  61729. private _ground;
  61730. /**
  61731. * Gets the ground mesh created by the helper.
  61732. */
  61733. get ground(): Nullable<Mesh>;
  61734. private _groundTexture;
  61735. /**
  61736. * Gets the ground texture created by the helper.
  61737. */
  61738. get groundTexture(): Nullable<BaseTexture>;
  61739. private _groundMirror;
  61740. /**
  61741. * Gets the ground mirror created by the helper.
  61742. */
  61743. get groundMirror(): Nullable<MirrorTexture>;
  61744. /**
  61745. * Gets the ground mirror render list to helps pushing the meshes
  61746. * you wish in the ground reflection.
  61747. */
  61748. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  61749. private _groundMaterial;
  61750. /**
  61751. * Gets the ground material created by the helper.
  61752. */
  61753. get groundMaterial(): Nullable<BackgroundMaterial>;
  61754. /**
  61755. * Stores the creation options.
  61756. */
  61757. private readonly _scene;
  61758. private _options;
  61759. /**
  61760. * This observable will be notified with any error during the creation of the environment,
  61761. * mainly texture creation errors.
  61762. */
  61763. onErrorObservable: Observable<{
  61764. message?: string;
  61765. exception?: any;
  61766. }>;
  61767. /**
  61768. * constructor
  61769. * @param options Defines the options we want to customize the helper
  61770. * @param scene The scene to add the material to
  61771. */
  61772. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  61773. /**
  61774. * Updates the background according to the new options
  61775. * @param options
  61776. */
  61777. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  61778. /**
  61779. * Sets the primary color of all the available elements.
  61780. * @param color the main color to affect to the ground and the background
  61781. */
  61782. setMainColor(color: Color3): void;
  61783. /**
  61784. * Setup the image processing according to the specified options.
  61785. */
  61786. private _setupImageProcessing;
  61787. /**
  61788. * Setup the environment texture according to the specified options.
  61789. */
  61790. private _setupEnvironmentTexture;
  61791. /**
  61792. * Setup the background according to the specified options.
  61793. */
  61794. private _setupBackground;
  61795. /**
  61796. * Get the scene sizes according to the setup.
  61797. */
  61798. private _getSceneSize;
  61799. /**
  61800. * Setup the ground according to the specified options.
  61801. */
  61802. private _setupGround;
  61803. /**
  61804. * Setup the ground material according to the specified options.
  61805. */
  61806. private _setupGroundMaterial;
  61807. /**
  61808. * Setup the ground diffuse texture according to the specified options.
  61809. */
  61810. private _setupGroundDiffuseTexture;
  61811. /**
  61812. * Setup the ground mirror texture according to the specified options.
  61813. */
  61814. private _setupGroundMirrorTexture;
  61815. /**
  61816. * Setup the ground to receive the mirror texture.
  61817. */
  61818. private _setupMirrorInGroundMaterial;
  61819. /**
  61820. * Setup the skybox according to the specified options.
  61821. */
  61822. private _setupSkybox;
  61823. /**
  61824. * Setup the skybox material according to the specified options.
  61825. */
  61826. private _setupSkyboxMaterial;
  61827. /**
  61828. * Setup the skybox reflection texture according to the specified options.
  61829. */
  61830. private _setupSkyboxReflectionTexture;
  61831. private _errorHandler;
  61832. /**
  61833. * Dispose all the elements created by the Helper.
  61834. */
  61835. dispose(): void;
  61836. }
  61837. }
  61838. declare module BABYLON {
  61839. /**
  61840. * Display a 360/180 degree texture on an approximately spherical surface, useful for VR applications or skyboxes.
  61841. * As a subclass of TransformNode, this allow parenting to the camera or multiple textures with different locations in the scene.
  61842. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  61843. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  61844. */
  61845. export abstract class TextureDome<T extends Texture> extends TransformNode {
  61846. protected onError: Nullable<(message?: string, exception?: any) => void>;
  61847. /**
  61848. * Define the source as a Monoscopic panoramic 360/180.
  61849. */
  61850. static readonly MODE_MONOSCOPIC: number;
  61851. /**
  61852. * Define the source as a Stereoscopic TopBottom/OverUnder panoramic 360/180.
  61853. */
  61854. static readonly MODE_TOPBOTTOM: number;
  61855. /**
  61856. * Define the source as a Stereoscopic Side by Side panoramic 360/180.
  61857. */
  61858. static readonly MODE_SIDEBYSIDE: number;
  61859. private _halfDome;
  61860. private _crossEye;
  61861. protected _useDirectMapping: boolean;
  61862. /**
  61863. * The texture being displayed on the sphere
  61864. */
  61865. protected _texture: T;
  61866. /**
  61867. * Gets the texture being displayed on the sphere
  61868. */
  61869. get texture(): T;
  61870. /**
  61871. * Sets the texture being displayed on the sphere
  61872. */
  61873. set texture(newTexture: T);
  61874. /**
  61875. * The skybox material
  61876. */
  61877. protected _material: BackgroundMaterial;
  61878. /**
  61879. * The surface used for the dome
  61880. */
  61881. protected _mesh: Mesh;
  61882. /**
  61883. * Gets the mesh used for the dome.
  61884. */
  61885. get mesh(): Mesh;
  61886. /**
  61887. * A mesh that will be used to mask the back of the dome in case it is a 180 degree movie.
  61888. */
  61889. private _halfDomeMask;
  61890. /**
  61891. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  61892. * Also see the options.resolution property.
  61893. */
  61894. get fovMultiplier(): number;
  61895. set fovMultiplier(value: number);
  61896. protected _textureMode: number;
  61897. /**
  61898. * Gets or set the current texture mode for the texture. It can be:
  61899. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  61900. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  61901. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  61902. */
  61903. get textureMode(): number;
  61904. /**
  61905. * Sets the current texture mode for the texture. It can be:
  61906. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  61907. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  61908. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  61909. */
  61910. set textureMode(value: number);
  61911. /**
  61912. * Is it a 180 degrees dome (half dome) or 360 texture (full dome)
  61913. */
  61914. get halfDome(): boolean;
  61915. /**
  61916. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  61917. */
  61918. set halfDome(enabled: boolean);
  61919. /**
  61920. * Set the cross-eye mode. If set, images that can be seen when crossing eyes will render correctly
  61921. */
  61922. set crossEye(enabled: boolean);
  61923. /**
  61924. * Is it a cross-eye texture?
  61925. */
  61926. get crossEye(): boolean;
  61927. /**
  61928. * The background material of this dome.
  61929. */
  61930. get material(): BackgroundMaterial;
  61931. /**
  61932. * Oberserver used in Stereoscopic VR Mode.
  61933. */
  61934. private _onBeforeCameraRenderObserver;
  61935. /**
  61936. * Observable raised when an error occured while loading the 360 image
  61937. */
  61938. onLoadErrorObservable: Observable<string>;
  61939. /**
  61940. * Create an instance of this class and pass through the parameters to the relevant classes- Texture, StandardMaterial, and Mesh.
  61941. * @param name Element's name, child elements will append suffixes for their own names.
  61942. * @param textureUrlOrElement defines the url(s) or the (video) HTML element to use
  61943. * @param options An object containing optional or exposed sub element properties
  61944. */
  61945. constructor(name: string, textureUrlOrElement: string | string[] | HTMLVideoElement, options: {
  61946. resolution?: number;
  61947. clickToPlay?: boolean;
  61948. autoPlay?: boolean;
  61949. loop?: boolean;
  61950. size?: number;
  61951. poster?: string;
  61952. faceForward?: boolean;
  61953. useDirectMapping?: boolean;
  61954. halfDomeMode?: boolean;
  61955. crossEyeMode?: boolean;
  61956. generateMipMaps?: boolean;
  61957. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  61958. protected abstract _initTexture(urlsOrElement: string | string[] | HTMLElement, scene: Scene, options: any): T;
  61959. protected _changeTextureMode(value: number): void;
  61960. /**
  61961. * Releases resources associated with this node.
  61962. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  61963. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  61964. */
  61965. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  61966. }
  61967. }
  61968. declare module BABYLON {
  61969. /**
  61970. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  61971. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  61972. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  61973. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  61974. */
  61975. export class PhotoDome extends TextureDome<Texture> {
  61976. /**
  61977. * Define the image as a Monoscopic panoramic 360 image.
  61978. */
  61979. static readonly MODE_MONOSCOPIC: number;
  61980. /**
  61981. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  61982. */
  61983. static readonly MODE_TOPBOTTOM: number;
  61984. /**
  61985. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  61986. */
  61987. static readonly MODE_SIDEBYSIDE: number;
  61988. /**
  61989. * Gets or sets the texture being displayed on the sphere
  61990. */
  61991. get photoTexture(): Texture;
  61992. /**
  61993. * sets the texture being displayed on the sphere
  61994. */
  61995. set photoTexture(value: Texture);
  61996. /**
  61997. * Gets the current video mode for the video. It can be:
  61998. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  61999. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  62000. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  62001. */
  62002. get imageMode(): number;
  62003. /**
  62004. * Sets the current video mode for the video. It can be:
  62005. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  62006. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  62007. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  62008. */
  62009. set imageMode(value: number);
  62010. protected _initTexture(urlsOrElement: string, scene: Scene, options: any): Texture;
  62011. }
  62012. }
  62013. declare module BABYLON {
  62014. /**
  62015. * Direct draw surface info
  62016. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  62017. */
  62018. export interface DDSInfo {
  62019. /**
  62020. * Width of the texture
  62021. */
  62022. width: number;
  62023. /**
  62024. * Width of the texture
  62025. */
  62026. height: number;
  62027. /**
  62028. * Number of Mipmaps for the texture
  62029. * @see https://en.wikipedia.org/wiki/Mipmap
  62030. */
  62031. mipmapCount: number;
  62032. /**
  62033. * If the textures format is a known fourCC format
  62034. * @see https://www.fourcc.org/
  62035. */
  62036. isFourCC: boolean;
  62037. /**
  62038. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  62039. */
  62040. isRGB: boolean;
  62041. /**
  62042. * If the texture is a lumincance format
  62043. */
  62044. isLuminance: boolean;
  62045. /**
  62046. * If this is a cube texture
  62047. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  62048. */
  62049. isCube: boolean;
  62050. /**
  62051. * If the texture is a compressed format eg. FOURCC_DXT1
  62052. */
  62053. isCompressed: boolean;
  62054. /**
  62055. * The dxgiFormat of the texture
  62056. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  62057. */
  62058. dxgiFormat: number;
  62059. /**
  62060. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  62061. */
  62062. textureType: number;
  62063. /**
  62064. * Sphericle polynomial created for the dds texture
  62065. */
  62066. sphericalPolynomial?: SphericalPolynomial;
  62067. }
  62068. /**
  62069. * Class used to provide DDS decompression tools
  62070. */
  62071. export class DDSTools {
  62072. /**
  62073. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  62074. */
  62075. static StoreLODInAlphaChannel: boolean;
  62076. /**
  62077. * Gets DDS information from an array buffer
  62078. * @param data defines the array buffer view to read data from
  62079. * @returns the DDS information
  62080. */
  62081. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  62082. private static _FloatView;
  62083. private static _Int32View;
  62084. private static _ToHalfFloat;
  62085. private static _FromHalfFloat;
  62086. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  62087. private static _GetHalfFloatRGBAArrayBuffer;
  62088. private static _GetFloatRGBAArrayBuffer;
  62089. private static _GetFloatAsUIntRGBAArrayBuffer;
  62090. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  62091. private static _GetRGBAArrayBuffer;
  62092. private static _ExtractLongWordOrder;
  62093. private static _GetRGBArrayBuffer;
  62094. private static _GetLuminanceArrayBuffer;
  62095. /**
  62096. * Uploads DDS Levels to a Babylon Texture
  62097. * @hidden
  62098. */
  62099. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  62100. }
  62101. interface ThinEngine {
  62102. /**
  62103. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  62104. * @param rootUrl defines the url where the file to load is located
  62105. * @param scene defines the current scene
  62106. * @param lodScale defines scale to apply to the mip map selection
  62107. * @param lodOffset defines offset to apply to the mip map selection
  62108. * @param onLoad defines an optional callback raised when the texture is loaded
  62109. * @param onError defines an optional callback raised if there is an issue to load the texture
  62110. * @param format defines the format of the data
  62111. * @param forcedExtension defines the extension to use to pick the right loader
  62112. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  62113. * @returns the cube texture as an InternalTexture
  62114. */
  62115. 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;
  62116. }
  62117. }
  62118. declare module BABYLON {
  62119. /**
  62120. * Implementation of the DDS Texture Loader.
  62121. * @hidden
  62122. */
  62123. export class _DDSTextureLoader implements IInternalTextureLoader {
  62124. /**
  62125. * Defines wether the loader supports cascade loading the different faces.
  62126. */
  62127. readonly supportCascades: boolean;
  62128. /**
  62129. * This returns if the loader support the current file information.
  62130. * @param extension defines the file extension of the file being loaded
  62131. * @returns true if the loader can load the specified file
  62132. */
  62133. canLoad(extension: string): boolean;
  62134. /**
  62135. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  62136. * @param data contains the texture data
  62137. * @param texture defines the BabylonJS internal texture
  62138. * @param createPolynomials will be true if polynomials have been requested
  62139. * @param onLoad defines the callback to trigger once the texture is ready
  62140. * @param onError defines the callback to trigger in case of error
  62141. */
  62142. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  62143. /**
  62144. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  62145. * @param data contains the texture data
  62146. * @param texture defines the BabylonJS internal texture
  62147. * @param callback defines the method to call once ready to upload
  62148. */
  62149. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  62150. }
  62151. }
  62152. declare module BABYLON {
  62153. /**
  62154. * Implementation of the ENV Texture Loader.
  62155. * @hidden
  62156. */
  62157. export class _ENVTextureLoader implements IInternalTextureLoader {
  62158. /**
  62159. * Defines wether the loader supports cascade loading the different faces.
  62160. */
  62161. readonly supportCascades: boolean;
  62162. /**
  62163. * This returns if the loader support the current file information.
  62164. * @param extension defines the file extension of the file being loaded
  62165. * @returns true if the loader can load the specified file
  62166. */
  62167. canLoad(extension: string): boolean;
  62168. /**
  62169. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  62170. * @param data contains the texture data
  62171. * @param texture defines the BabylonJS internal texture
  62172. * @param createPolynomials will be true if polynomials have been requested
  62173. * @param onLoad defines the callback to trigger once the texture is ready
  62174. * @param onError defines the callback to trigger in case of error
  62175. */
  62176. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  62177. /**
  62178. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  62179. * @param data contains the texture data
  62180. * @param texture defines the BabylonJS internal texture
  62181. * @param callback defines the method to call once ready to upload
  62182. */
  62183. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  62184. }
  62185. }
  62186. declare module BABYLON {
  62187. /**
  62188. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  62189. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  62190. */
  62191. export class KhronosTextureContainer {
  62192. /** contents of the KTX container file */
  62193. data: ArrayBufferView;
  62194. private static HEADER_LEN;
  62195. private static COMPRESSED_2D;
  62196. private static COMPRESSED_3D;
  62197. private static TEX_2D;
  62198. private static TEX_3D;
  62199. /**
  62200. * Gets the openGL type
  62201. */
  62202. glType: number;
  62203. /**
  62204. * Gets the openGL type size
  62205. */
  62206. glTypeSize: number;
  62207. /**
  62208. * Gets the openGL format
  62209. */
  62210. glFormat: number;
  62211. /**
  62212. * Gets the openGL internal format
  62213. */
  62214. glInternalFormat: number;
  62215. /**
  62216. * Gets the base internal format
  62217. */
  62218. glBaseInternalFormat: number;
  62219. /**
  62220. * Gets image width in pixel
  62221. */
  62222. pixelWidth: number;
  62223. /**
  62224. * Gets image height in pixel
  62225. */
  62226. pixelHeight: number;
  62227. /**
  62228. * Gets image depth in pixels
  62229. */
  62230. pixelDepth: number;
  62231. /**
  62232. * Gets the number of array elements
  62233. */
  62234. numberOfArrayElements: number;
  62235. /**
  62236. * Gets the number of faces
  62237. */
  62238. numberOfFaces: number;
  62239. /**
  62240. * Gets the number of mipmap levels
  62241. */
  62242. numberOfMipmapLevels: number;
  62243. /**
  62244. * Gets the bytes of key value data
  62245. */
  62246. bytesOfKeyValueData: number;
  62247. /**
  62248. * Gets the load type
  62249. */
  62250. loadType: number;
  62251. /**
  62252. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  62253. */
  62254. isInvalid: boolean;
  62255. /**
  62256. * Creates a new KhronosTextureContainer
  62257. * @param data contents of the KTX container file
  62258. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  62259. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  62260. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  62261. */
  62262. constructor(
  62263. /** contents of the KTX container file */
  62264. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  62265. /**
  62266. * Uploads KTX content to a Babylon Texture.
  62267. * It is assumed that the texture has already been created & is currently bound
  62268. * @hidden
  62269. */
  62270. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  62271. private _upload2DCompressedLevels;
  62272. /**
  62273. * Checks if the given data starts with a KTX file identifier.
  62274. * @param data the data to check
  62275. * @returns true if the data is a KTX file or false otherwise
  62276. */
  62277. static IsValid(data: ArrayBufferView): boolean;
  62278. }
  62279. }
  62280. declare module BABYLON {
  62281. /**
  62282. * Helper class to push actions to a pool of workers.
  62283. */
  62284. export class WorkerPool implements IDisposable {
  62285. private _workerInfos;
  62286. private _pendingActions;
  62287. /**
  62288. * Constructor
  62289. * @param workers Array of workers to use for actions
  62290. */
  62291. constructor(workers: Array<Worker>);
  62292. /**
  62293. * Terminates all workers and clears any pending actions.
  62294. */
  62295. dispose(): void;
  62296. /**
  62297. * Pushes an action to the worker pool. If all the workers are active, the action will be
  62298. * pended until a worker has completed its action.
  62299. * @param action The action to perform. Call onComplete when the action is complete.
  62300. */
  62301. push(action: (worker: Worker, onComplete: () => void) => void): void;
  62302. private _execute;
  62303. }
  62304. }
  62305. declare module BABYLON {
  62306. /**
  62307. * Class for loading KTX2 files
  62308. */
  62309. export class KhronosTextureContainer2 {
  62310. private static _WorkerPoolPromise?;
  62311. private static _Initialized;
  62312. private static _Ktx2Decoder;
  62313. /**
  62314. * URLs to use when loading the KTX2 decoder module as well as its dependencies
  62315. * If a url is null, the default url is used (pointing to https://preview.babylonjs.com)
  62316. * Note that jsDecoderModule can't be null and that the other dependencies will only be loaded if necessary
  62317. * Urls you can change:
  62318. * URLConfig.jsDecoderModule
  62319. * URLConfig.wasmUASTCToASTC
  62320. * URLConfig.wasmUASTCToBC7
  62321. * URLConfig.wasmUASTCToRGBA_UNORM
  62322. * URLConfig.wasmUASTCToRGBA_SRGB
  62323. * URLConfig.jsMSCTranscoder
  62324. * URLConfig.wasmMSCTranscoder
  62325. * You can see their default values in this PG: https://playground.babylonjs.com/#EIJH8L#22
  62326. */
  62327. static URLConfig: {
  62328. jsDecoderModule: string;
  62329. wasmUASTCToASTC: null;
  62330. wasmUASTCToBC7: null;
  62331. wasmUASTCToRGBA_UNORM: null;
  62332. wasmUASTCToRGBA_SRGB: null;
  62333. jsMSCTranscoder: null;
  62334. wasmMSCTranscoder: null;
  62335. };
  62336. /**
  62337. * Default number of workers used to handle data decoding
  62338. */
  62339. static DefaultNumWorkers: number;
  62340. private static GetDefaultNumWorkers;
  62341. private _engine;
  62342. private static _CreateWorkerPool;
  62343. /**
  62344. * Constructor
  62345. * @param engine The engine to use
  62346. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  62347. */
  62348. constructor(engine: ThinEngine, numWorkers?: number);
  62349. /** @hidden */
  62350. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture, options?: any): Promise<void>;
  62351. /**
  62352. * Stop all async operations and release resources.
  62353. */
  62354. dispose(): void;
  62355. protected _createTexture(data: any, internalTexture: InternalTexture, options?: any): void;
  62356. /**
  62357. * Checks if the given data starts with a KTX2 file identifier.
  62358. * @param data the data to check
  62359. * @returns true if the data is a KTX2 file or false otherwise
  62360. */
  62361. static IsValid(data: ArrayBufferView): boolean;
  62362. }
  62363. }
  62364. declare module BABYLON {
  62365. /**
  62366. * Implementation of the KTX Texture Loader.
  62367. * @hidden
  62368. */
  62369. export class _KTXTextureLoader implements IInternalTextureLoader {
  62370. /**
  62371. * Defines wether the loader supports cascade loading the different faces.
  62372. */
  62373. readonly supportCascades: boolean;
  62374. /**
  62375. * This returns if the loader support the current file information.
  62376. * @param extension defines the file extension of the file being loaded
  62377. * @param mimeType defines the optional mime type of the file being loaded
  62378. * @returns true if the loader can load the specified file
  62379. */
  62380. canLoad(extension: string, mimeType?: string): boolean;
  62381. /**
  62382. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  62383. * @param data contains the texture data
  62384. * @param texture defines the BabylonJS internal texture
  62385. * @param createPolynomials will be true if polynomials have been requested
  62386. * @param onLoad defines the callback to trigger once the texture is ready
  62387. * @param onError defines the callback to trigger in case of error
  62388. */
  62389. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  62390. /**
  62391. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  62392. * @param data contains the texture data
  62393. * @param texture defines the BabylonJS internal texture
  62394. * @param callback defines the method to call once ready to upload
  62395. */
  62396. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void, options?: any): void;
  62397. }
  62398. }
  62399. declare module BABYLON {
  62400. /** @hidden */
  62401. export var _forceSceneHelpersToBundle: boolean;
  62402. interface Scene {
  62403. /**
  62404. * Creates a default light for the scene.
  62405. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  62406. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  62407. */
  62408. createDefaultLight(replace?: boolean): void;
  62409. /**
  62410. * Creates a default camera for the scene.
  62411. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  62412. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  62413. * @param replace has default false, when true replaces the active camera in the scene
  62414. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  62415. */
  62416. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  62417. /**
  62418. * Creates a default camera and a default light.
  62419. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  62420. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  62421. * @param replace has the default false, when true replaces the active camera/light in the scene
  62422. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  62423. */
  62424. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  62425. /**
  62426. * Creates a new sky box
  62427. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  62428. * @param environmentTexture defines the texture to use as environment texture
  62429. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  62430. * @param scale defines the overall scale of the skybox
  62431. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  62432. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  62433. * @returns a new mesh holding the sky box
  62434. */
  62435. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  62436. /**
  62437. * Creates a new environment
  62438. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  62439. * @param options defines the options you can use to configure the environment
  62440. * @returns the new EnvironmentHelper
  62441. */
  62442. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  62443. /**
  62444. * Creates a new VREXperienceHelper
  62445. * @see https://doc.babylonjs.com/how_to/webvr_helper
  62446. * @param webVROptions defines the options used to create the new VREXperienceHelper
  62447. * @returns a new VREXperienceHelper
  62448. */
  62449. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  62450. /**
  62451. * Creates a new WebXRDefaultExperience
  62452. * @see https://doc.babylonjs.com/how_to/introduction_to_webxr
  62453. * @param options experience options
  62454. * @returns a promise for a new WebXRDefaultExperience
  62455. */
  62456. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  62457. }
  62458. }
  62459. declare module BABYLON {
  62460. /**
  62461. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  62462. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  62463. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  62464. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  62465. */
  62466. export class VideoDome extends TextureDome<VideoTexture> {
  62467. /**
  62468. * Define the video source as a Monoscopic panoramic 360 video.
  62469. */
  62470. static readonly MODE_MONOSCOPIC: number;
  62471. /**
  62472. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  62473. */
  62474. static readonly MODE_TOPBOTTOM: number;
  62475. /**
  62476. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  62477. */
  62478. static readonly MODE_SIDEBYSIDE: number;
  62479. /**
  62480. * Get the video texture associated with this video dome
  62481. */
  62482. get videoTexture(): VideoTexture;
  62483. /**
  62484. * Get the video mode of this dome
  62485. */
  62486. get videoMode(): number;
  62487. /**
  62488. * Set the video mode of this dome.
  62489. * @see textureMode
  62490. */
  62491. set videoMode(value: number);
  62492. protected _initTexture(urlsOrElement: string | string[] | HTMLVideoElement, scene: Scene, options: any): VideoTexture;
  62493. }
  62494. }
  62495. declare module BABYLON {
  62496. /**
  62497. * This class can be used to get instrumentation data from a Babylon engine
  62498. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  62499. */
  62500. export class EngineInstrumentation implements IDisposable {
  62501. /**
  62502. * Define the instrumented engine.
  62503. */
  62504. engine: Engine;
  62505. private _captureGPUFrameTime;
  62506. private _gpuFrameTimeToken;
  62507. private _gpuFrameTime;
  62508. private _captureShaderCompilationTime;
  62509. private _shaderCompilationTime;
  62510. private _onBeginFrameObserver;
  62511. private _onEndFrameObserver;
  62512. private _onBeforeShaderCompilationObserver;
  62513. private _onAfterShaderCompilationObserver;
  62514. /**
  62515. * Gets the perf counter used for GPU frame time
  62516. */
  62517. get gpuFrameTimeCounter(): PerfCounter;
  62518. /**
  62519. * Gets the GPU frame time capture status
  62520. */
  62521. get captureGPUFrameTime(): boolean;
  62522. /**
  62523. * Enable or disable the GPU frame time capture
  62524. */
  62525. set captureGPUFrameTime(value: boolean);
  62526. /**
  62527. * Gets the perf counter used for shader compilation time
  62528. */
  62529. get shaderCompilationTimeCounter(): PerfCounter;
  62530. /**
  62531. * Gets the shader compilation time capture status
  62532. */
  62533. get captureShaderCompilationTime(): boolean;
  62534. /**
  62535. * Enable or disable the shader compilation time capture
  62536. */
  62537. set captureShaderCompilationTime(value: boolean);
  62538. /**
  62539. * Instantiates a new engine instrumentation.
  62540. * This class can be used to get instrumentation data from a Babylon engine
  62541. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  62542. * @param engine Defines the engine to instrument
  62543. */
  62544. constructor(
  62545. /**
  62546. * Define the instrumented engine.
  62547. */
  62548. engine: Engine);
  62549. /**
  62550. * Dispose and release associated resources.
  62551. */
  62552. dispose(): void;
  62553. }
  62554. }
  62555. declare module BABYLON {
  62556. /**
  62557. * This class can be used to get instrumentation data from a Babylon engine
  62558. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  62559. */
  62560. export class SceneInstrumentation implements IDisposable {
  62561. /**
  62562. * Defines the scene to instrument
  62563. */
  62564. scene: Scene;
  62565. private _captureActiveMeshesEvaluationTime;
  62566. private _activeMeshesEvaluationTime;
  62567. private _captureRenderTargetsRenderTime;
  62568. private _renderTargetsRenderTime;
  62569. private _captureFrameTime;
  62570. private _frameTime;
  62571. private _captureRenderTime;
  62572. private _renderTime;
  62573. private _captureInterFrameTime;
  62574. private _interFrameTime;
  62575. private _captureParticlesRenderTime;
  62576. private _particlesRenderTime;
  62577. private _captureSpritesRenderTime;
  62578. private _spritesRenderTime;
  62579. private _capturePhysicsTime;
  62580. private _physicsTime;
  62581. private _captureAnimationsTime;
  62582. private _animationsTime;
  62583. private _captureCameraRenderTime;
  62584. private _cameraRenderTime;
  62585. private _onBeforeActiveMeshesEvaluationObserver;
  62586. private _onAfterActiveMeshesEvaluationObserver;
  62587. private _onBeforeRenderTargetsRenderObserver;
  62588. private _onAfterRenderTargetsRenderObserver;
  62589. private _onAfterRenderObserver;
  62590. private _onBeforeDrawPhaseObserver;
  62591. private _onAfterDrawPhaseObserver;
  62592. private _onBeforeAnimationsObserver;
  62593. private _onBeforeParticlesRenderingObserver;
  62594. private _onAfterParticlesRenderingObserver;
  62595. private _onBeforeSpritesRenderingObserver;
  62596. private _onAfterSpritesRenderingObserver;
  62597. private _onBeforePhysicsObserver;
  62598. private _onAfterPhysicsObserver;
  62599. private _onAfterAnimationsObserver;
  62600. private _onBeforeCameraRenderObserver;
  62601. private _onAfterCameraRenderObserver;
  62602. /**
  62603. * Gets the perf counter used for active meshes evaluation time
  62604. */
  62605. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  62606. /**
  62607. * Gets the active meshes evaluation time capture status
  62608. */
  62609. get captureActiveMeshesEvaluationTime(): boolean;
  62610. /**
  62611. * Enable or disable the active meshes evaluation time capture
  62612. */
  62613. set captureActiveMeshesEvaluationTime(value: boolean);
  62614. /**
  62615. * Gets the perf counter used for render targets render time
  62616. */
  62617. get renderTargetsRenderTimeCounter(): PerfCounter;
  62618. /**
  62619. * Gets the render targets render time capture status
  62620. */
  62621. get captureRenderTargetsRenderTime(): boolean;
  62622. /**
  62623. * Enable or disable the render targets render time capture
  62624. */
  62625. set captureRenderTargetsRenderTime(value: boolean);
  62626. /**
  62627. * Gets the perf counter used for particles render time
  62628. */
  62629. get particlesRenderTimeCounter(): PerfCounter;
  62630. /**
  62631. * Gets the particles render time capture status
  62632. */
  62633. get captureParticlesRenderTime(): boolean;
  62634. /**
  62635. * Enable or disable the particles render time capture
  62636. */
  62637. set captureParticlesRenderTime(value: boolean);
  62638. /**
  62639. * Gets the perf counter used for sprites render time
  62640. */
  62641. get spritesRenderTimeCounter(): PerfCounter;
  62642. /**
  62643. * Gets the sprites render time capture status
  62644. */
  62645. get captureSpritesRenderTime(): boolean;
  62646. /**
  62647. * Enable or disable the sprites render time capture
  62648. */
  62649. set captureSpritesRenderTime(value: boolean);
  62650. /**
  62651. * Gets the perf counter used for physics time
  62652. */
  62653. get physicsTimeCounter(): PerfCounter;
  62654. /**
  62655. * Gets the physics time capture status
  62656. */
  62657. get capturePhysicsTime(): boolean;
  62658. /**
  62659. * Enable or disable the physics time capture
  62660. */
  62661. set capturePhysicsTime(value: boolean);
  62662. /**
  62663. * Gets the perf counter used for animations time
  62664. */
  62665. get animationsTimeCounter(): PerfCounter;
  62666. /**
  62667. * Gets the animations time capture status
  62668. */
  62669. get captureAnimationsTime(): boolean;
  62670. /**
  62671. * Enable or disable the animations time capture
  62672. */
  62673. set captureAnimationsTime(value: boolean);
  62674. /**
  62675. * Gets the perf counter used for frame time capture
  62676. */
  62677. get frameTimeCounter(): PerfCounter;
  62678. /**
  62679. * Gets the frame time capture status
  62680. */
  62681. get captureFrameTime(): boolean;
  62682. /**
  62683. * Enable or disable the frame time capture
  62684. */
  62685. set captureFrameTime(value: boolean);
  62686. /**
  62687. * Gets the perf counter used for inter-frames time capture
  62688. */
  62689. get interFrameTimeCounter(): PerfCounter;
  62690. /**
  62691. * Gets the inter-frames time capture status
  62692. */
  62693. get captureInterFrameTime(): boolean;
  62694. /**
  62695. * Enable or disable the inter-frames time capture
  62696. */
  62697. set captureInterFrameTime(value: boolean);
  62698. /**
  62699. * Gets the perf counter used for render time capture
  62700. */
  62701. get renderTimeCounter(): PerfCounter;
  62702. /**
  62703. * Gets the render time capture status
  62704. */
  62705. get captureRenderTime(): boolean;
  62706. /**
  62707. * Enable or disable the render time capture
  62708. */
  62709. set captureRenderTime(value: boolean);
  62710. /**
  62711. * Gets the perf counter used for camera render time capture
  62712. */
  62713. get cameraRenderTimeCounter(): PerfCounter;
  62714. /**
  62715. * Gets the camera render time capture status
  62716. */
  62717. get captureCameraRenderTime(): boolean;
  62718. /**
  62719. * Enable or disable the camera render time capture
  62720. */
  62721. set captureCameraRenderTime(value: boolean);
  62722. /**
  62723. * Gets the perf counter used for draw calls
  62724. */
  62725. get drawCallsCounter(): PerfCounter;
  62726. /**
  62727. * Instantiates a new scene instrumentation.
  62728. * This class can be used to get instrumentation data from a Babylon engine
  62729. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  62730. * @param scene Defines the scene to instrument
  62731. */
  62732. constructor(
  62733. /**
  62734. * Defines the scene to instrument
  62735. */
  62736. scene: Scene);
  62737. /**
  62738. * Dispose and release associated resources.
  62739. */
  62740. dispose(): void;
  62741. }
  62742. }
  62743. declare module BABYLON {
  62744. /** @hidden */
  62745. export var glowMapGenerationPixelShader: {
  62746. name: string;
  62747. shader: string;
  62748. };
  62749. }
  62750. declare module BABYLON {
  62751. /** @hidden */
  62752. export var glowMapGenerationVertexShader: {
  62753. name: string;
  62754. shader: string;
  62755. };
  62756. }
  62757. declare module BABYLON {
  62758. /**
  62759. * Effect layer options. This helps customizing the behaviour
  62760. * of the effect layer.
  62761. */
  62762. export interface IEffectLayerOptions {
  62763. /**
  62764. * Multiplication factor apply to the canvas size to compute the render target size
  62765. * used to generated the objects (the smaller the faster).
  62766. */
  62767. mainTextureRatio: number;
  62768. /**
  62769. * Enforces a fixed size texture to ensure effect stability across devices.
  62770. */
  62771. mainTextureFixedSize?: number;
  62772. /**
  62773. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  62774. */
  62775. alphaBlendingMode: number;
  62776. /**
  62777. * The camera attached to the layer.
  62778. */
  62779. camera: Nullable<Camera>;
  62780. /**
  62781. * The rendering group to draw the layer in.
  62782. */
  62783. renderingGroupId: number;
  62784. }
  62785. /**
  62786. * The effect layer Helps adding post process effect blended with the main pass.
  62787. *
  62788. * This can be for instance use to generate glow or higlight effects on the scene.
  62789. *
  62790. * The effect layer class can not be used directly and is intented to inherited from to be
  62791. * customized per effects.
  62792. */
  62793. export abstract class EffectLayer {
  62794. private _vertexBuffers;
  62795. private _indexBuffer;
  62796. private _cachedDefines;
  62797. private _effectLayerMapGenerationEffect;
  62798. private _effectLayerOptions;
  62799. private _mergeEffect;
  62800. protected _scene: Scene;
  62801. protected _engine: Engine;
  62802. protected _maxSize: number;
  62803. protected _mainTextureDesiredSize: ISize;
  62804. protected _mainTexture: RenderTargetTexture;
  62805. protected _shouldRender: boolean;
  62806. protected _postProcesses: PostProcess[];
  62807. protected _textures: BaseTexture[];
  62808. protected _emissiveTextureAndColor: {
  62809. texture: Nullable<BaseTexture>;
  62810. color: Color4;
  62811. };
  62812. /**
  62813. * The name of the layer
  62814. */
  62815. name: string;
  62816. /**
  62817. * The clear color of the texture used to generate the glow map.
  62818. */
  62819. neutralColor: Color4;
  62820. /**
  62821. * Specifies whether the highlight layer is enabled or not.
  62822. */
  62823. isEnabled: boolean;
  62824. /**
  62825. * Gets the camera attached to the layer.
  62826. */
  62827. get camera(): Nullable<Camera>;
  62828. /**
  62829. * Gets the rendering group id the layer should render in.
  62830. */
  62831. get renderingGroupId(): number;
  62832. set renderingGroupId(renderingGroupId: number);
  62833. /**
  62834. * Specifies if the bounding boxes should be rendered normally or if they should undergo the effect of the layer
  62835. */
  62836. disableBoundingBoxesFromEffectLayer: boolean;
  62837. /**
  62838. * An event triggered when the effect layer has been disposed.
  62839. */
  62840. onDisposeObservable: Observable<EffectLayer>;
  62841. /**
  62842. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  62843. */
  62844. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  62845. /**
  62846. * An event triggered when the generated texture is being merged in the scene.
  62847. */
  62848. onBeforeComposeObservable: Observable<EffectLayer>;
  62849. /**
  62850. * An event triggered when the mesh is rendered into the effect render target.
  62851. */
  62852. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  62853. /**
  62854. * An event triggered after the mesh has been rendered into the effect render target.
  62855. */
  62856. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  62857. /**
  62858. * An event triggered when the generated texture has been merged in the scene.
  62859. */
  62860. onAfterComposeObservable: Observable<EffectLayer>;
  62861. /**
  62862. * An event triggered when the efffect layer changes its size.
  62863. */
  62864. onSizeChangedObservable: Observable<EffectLayer>;
  62865. /** @hidden */
  62866. static _SceneComponentInitialization: (scene: Scene) => void;
  62867. /**
  62868. * Instantiates a new effect Layer and references it in the scene.
  62869. * @param name The name of the layer
  62870. * @param scene The scene to use the layer in
  62871. */
  62872. constructor(
  62873. /** The Friendly of the effect in the scene */
  62874. name: string, scene: Scene);
  62875. /**
  62876. * Get the effect name of the layer.
  62877. * @return The effect name
  62878. */
  62879. abstract getEffectName(): string;
  62880. /**
  62881. * Checks for the readiness of the element composing the layer.
  62882. * @param subMesh the mesh to check for
  62883. * @param useInstances specify whether or not to use instances to render the mesh
  62884. * @return true if ready otherwise, false
  62885. */
  62886. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  62887. /**
  62888. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  62889. * @returns true if the effect requires stencil during the main canvas render pass.
  62890. */
  62891. abstract needStencil(): boolean;
  62892. /**
  62893. * Create the merge effect. This is the shader use to blit the information back
  62894. * to the main canvas at the end of the scene rendering.
  62895. * @returns The effect containing the shader used to merge the effect on the main canvas
  62896. */
  62897. protected abstract _createMergeEffect(): Effect;
  62898. /**
  62899. * Creates the render target textures and post processes used in the effect layer.
  62900. */
  62901. protected abstract _createTextureAndPostProcesses(): void;
  62902. /**
  62903. * Implementation specific of rendering the generating effect on the main canvas.
  62904. * @param effect The effect used to render through
  62905. */
  62906. protected abstract _internalRender(effect: Effect): void;
  62907. /**
  62908. * Sets the required values for both the emissive texture and and the main color.
  62909. */
  62910. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  62911. /**
  62912. * Free any resources and references associated to a mesh.
  62913. * Internal use
  62914. * @param mesh The mesh to free.
  62915. */
  62916. abstract _disposeMesh(mesh: Mesh): void;
  62917. /**
  62918. * Serializes this layer (Glow or Highlight for example)
  62919. * @returns a serialized layer object
  62920. */
  62921. abstract serialize?(): any;
  62922. /**
  62923. * Initializes the effect layer with the required options.
  62924. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  62925. */
  62926. protected _init(options: Partial<IEffectLayerOptions>): void;
  62927. /**
  62928. * Generates the index buffer of the full screen quad blending to the main canvas.
  62929. */
  62930. private _generateIndexBuffer;
  62931. /**
  62932. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  62933. */
  62934. private _generateVertexBuffer;
  62935. /**
  62936. * Sets the main texture desired size which is the closest power of two
  62937. * of the engine canvas size.
  62938. */
  62939. private _setMainTextureSize;
  62940. /**
  62941. * Creates the main texture for the effect layer.
  62942. */
  62943. protected _createMainTexture(): void;
  62944. /**
  62945. * Adds specific effects defines.
  62946. * @param defines The defines to add specifics to.
  62947. */
  62948. protected _addCustomEffectDefines(defines: string[]): void;
  62949. /**
  62950. * Checks for the readiness of the element composing the layer.
  62951. * @param subMesh the mesh to check for
  62952. * @param useInstances specify whether or not to use instances to render the mesh
  62953. * @param emissiveTexture the associated emissive texture used to generate the glow
  62954. * @return true if ready otherwise, false
  62955. */
  62956. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  62957. /**
  62958. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  62959. */
  62960. render(): void;
  62961. /**
  62962. * Determine if a given mesh will be used in the current effect.
  62963. * @param mesh mesh to test
  62964. * @returns true if the mesh will be used
  62965. */
  62966. hasMesh(mesh: AbstractMesh): boolean;
  62967. /**
  62968. * Returns true if the layer contains information to display, otherwise false.
  62969. * @returns true if the glow layer should be rendered
  62970. */
  62971. shouldRender(): boolean;
  62972. /**
  62973. * Returns true if the mesh should render, otherwise false.
  62974. * @param mesh The mesh to render
  62975. * @returns true if it should render otherwise false
  62976. */
  62977. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  62978. /**
  62979. * Returns true if the mesh can be rendered, otherwise false.
  62980. * @param mesh The mesh to render
  62981. * @param material The material used on the mesh
  62982. * @returns true if it can be rendered otherwise false
  62983. */
  62984. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  62985. /**
  62986. * Returns true if the mesh should render, otherwise false.
  62987. * @param mesh The mesh to render
  62988. * @returns true if it should render otherwise false
  62989. */
  62990. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  62991. /**
  62992. * Renders the submesh passed in parameter to the generation map.
  62993. */
  62994. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  62995. /**
  62996. * Defines whether the current material of the mesh should be use to render the effect.
  62997. * @param mesh defines the current mesh to render
  62998. */
  62999. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  63000. /**
  63001. * Rebuild the required buffers.
  63002. * @hidden Internal use only.
  63003. */
  63004. _rebuild(): void;
  63005. /**
  63006. * Dispose only the render target textures and post process.
  63007. */
  63008. private _disposeTextureAndPostProcesses;
  63009. /**
  63010. * Dispose the highlight layer and free resources.
  63011. */
  63012. dispose(): void;
  63013. /**
  63014. * Gets the class name of the effect layer
  63015. * @returns the string with the class name of the effect layer
  63016. */
  63017. getClassName(): string;
  63018. /**
  63019. * Creates an effect layer from parsed effect layer data
  63020. * @param parsedEffectLayer defines effect layer data
  63021. * @param scene defines the current scene
  63022. * @param rootUrl defines the root URL containing the effect layer information
  63023. * @returns a parsed effect Layer
  63024. */
  63025. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  63026. }
  63027. }
  63028. declare module BABYLON {
  63029. interface AbstractScene {
  63030. /**
  63031. * The list of effect layers (highlights/glow) added to the scene
  63032. * @see https://doc.babylonjs.com/how_to/highlight_layer
  63033. * @see https://doc.babylonjs.com/how_to/glow_layer
  63034. */
  63035. effectLayers: Array<EffectLayer>;
  63036. /**
  63037. * Removes the given effect layer from this scene.
  63038. * @param toRemove defines the effect layer to remove
  63039. * @returns the index of the removed effect layer
  63040. */
  63041. removeEffectLayer(toRemove: EffectLayer): number;
  63042. /**
  63043. * Adds the given effect layer to this scene
  63044. * @param newEffectLayer defines the effect layer to add
  63045. */
  63046. addEffectLayer(newEffectLayer: EffectLayer): void;
  63047. }
  63048. /**
  63049. * Defines the layer scene component responsible to manage any effect layers
  63050. * in a given scene.
  63051. */
  63052. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  63053. /**
  63054. * The component name helpfull to identify the component in the list of scene components.
  63055. */
  63056. readonly name: string;
  63057. /**
  63058. * The scene the component belongs to.
  63059. */
  63060. scene: Scene;
  63061. private _engine;
  63062. private _renderEffects;
  63063. private _needStencil;
  63064. private _previousStencilState;
  63065. /**
  63066. * Creates a new instance of the component for the given scene
  63067. * @param scene Defines the scene to register the component in
  63068. */
  63069. constructor(scene: Scene);
  63070. /**
  63071. * Registers the component in a given scene
  63072. */
  63073. register(): void;
  63074. /**
  63075. * Rebuilds the elements related to this component in case of
  63076. * context lost for instance.
  63077. */
  63078. rebuild(): void;
  63079. /**
  63080. * Serializes the component data to the specified json object
  63081. * @param serializationObject The object to serialize to
  63082. */
  63083. serialize(serializationObject: any): void;
  63084. /**
  63085. * Adds all the elements from the container to the scene
  63086. * @param container the container holding the elements
  63087. */
  63088. addFromContainer(container: AbstractScene): void;
  63089. /**
  63090. * Removes all the elements in the container from the scene
  63091. * @param container contains the elements to remove
  63092. * @param dispose if the removed element should be disposed (default: false)
  63093. */
  63094. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  63095. /**
  63096. * Disposes the component and the associated ressources.
  63097. */
  63098. dispose(): void;
  63099. private _isReadyForMesh;
  63100. private _renderMainTexture;
  63101. private _setStencil;
  63102. private _setStencilBack;
  63103. private _draw;
  63104. private _drawCamera;
  63105. private _drawRenderingGroup;
  63106. }
  63107. }
  63108. declare module BABYLON {
  63109. /** @hidden */
  63110. export var glowMapMergePixelShader: {
  63111. name: string;
  63112. shader: string;
  63113. };
  63114. }
  63115. declare module BABYLON {
  63116. /** @hidden */
  63117. export var glowMapMergeVertexShader: {
  63118. name: string;
  63119. shader: string;
  63120. };
  63121. }
  63122. declare module BABYLON {
  63123. interface AbstractScene {
  63124. /**
  63125. * Return a the first highlight layer of the scene with a given name.
  63126. * @param name The name of the highlight layer to look for.
  63127. * @return The highlight layer if found otherwise null.
  63128. */
  63129. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  63130. }
  63131. /**
  63132. * Glow layer options. This helps customizing the behaviour
  63133. * of the glow layer.
  63134. */
  63135. export interface IGlowLayerOptions {
  63136. /**
  63137. * Multiplication factor apply to the canvas size to compute the render target size
  63138. * used to generated the glowing objects (the smaller the faster).
  63139. */
  63140. mainTextureRatio: number;
  63141. /**
  63142. * Enforces a fixed size texture to ensure resize independant blur.
  63143. */
  63144. mainTextureFixedSize?: number;
  63145. /**
  63146. * How big is the kernel of the blur texture.
  63147. */
  63148. blurKernelSize: number;
  63149. /**
  63150. * The camera attached to the layer.
  63151. */
  63152. camera: Nullable<Camera>;
  63153. /**
  63154. * Enable MSAA by chosing the number of samples.
  63155. */
  63156. mainTextureSamples?: number;
  63157. /**
  63158. * The rendering group to draw the layer in.
  63159. */
  63160. renderingGroupId: number;
  63161. }
  63162. /**
  63163. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  63164. *
  63165. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  63166. *
  63167. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  63168. */
  63169. export class GlowLayer extends EffectLayer {
  63170. /**
  63171. * Effect Name of the layer.
  63172. */
  63173. static readonly EffectName: string;
  63174. /**
  63175. * The default blur kernel size used for the glow.
  63176. */
  63177. static DefaultBlurKernelSize: number;
  63178. /**
  63179. * The default texture size ratio used for the glow.
  63180. */
  63181. static DefaultTextureRatio: number;
  63182. /**
  63183. * Sets the kernel size of the blur.
  63184. */
  63185. set blurKernelSize(value: number);
  63186. /**
  63187. * Gets the kernel size of the blur.
  63188. */
  63189. get blurKernelSize(): number;
  63190. /**
  63191. * Sets the glow intensity.
  63192. */
  63193. set intensity(value: number);
  63194. /**
  63195. * Gets the glow intensity.
  63196. */
  63197. get intensity(): number;
  63198. private _options;
  63199. private _intensity;
  63200. private _horizontalBlurPostprocess1;
  63201. private _verticalBlurPostprocess1;
  63202. private _horizontalBlurPostprocess2;
  63203. private _verticalBlurPostprocess2;
  63204. private _blurTexture1;
  63205. private _blurTexture2;
  63206. private _postProcesses1;
  63207. private _postProcesses2;
  63208. private _includedOnlyMeshes;
  63209. private _excludedMeshes;
  63210. private _meshesUsingTheirOwnMaterials;
  63211. /**
  63212. * Callback used to let the user override the color selection on a per mesh basis
  63213. */
  63214. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  63215. /**
  63216. * Callback used to let the user override the texture selection on a per mesh basis
  63217. */
  63218. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  63219. /**
  63220. * Instantiates a new glow Layer and references it to the scene.
  63221. * @param name The name of the layer
  63222. * @param scene The scene to use the layer in
  63223. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  63224. */
  63225. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  63226. /**
  63227. * Get the effect name of the layer.
  63228. * @return The effect name
  63229. */
  63230. getEffectName(): string;
  63231. /**
  63232. * Create the merge effect. This is the shader use to blit the information back
  63233. * to the main canvas at the end of the scene rendering.
  63234. */
  63235. protected _createMergeEffect(): Effect;
  63236. /**
  63237. * Creates the render target textures and post processes used in the glow layer.
  63238. */
  63239. protected _createTextureAndPostProcesses(): void;
  63240. /**
  63241. * Checks for the readiness of the element composing the layer.
  63242. * @param subMesh the mesh to check for
  63243. * @param useInstances specify wether or not to use instances to render the mesh
  63244. * @param emissiveTexture the associated emissive texture used to generate the glow
  63245. * @return true if ready otherwise, false
  63246. */
  63247. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  63248. /**
  63249. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  63250. */
  63251. needStencil(): boolean;
  63252. /**
  63253. * Returns true if the mesh can be rendered, otherwise false.
  63254. * @param mesh The mesh to render
  63255. * @param material The material used on the mesh
  63256. * @returns true if it can be rendered otherwise false
  63257. */
  63258. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  63259. /**
  63260. * Implementation specific of rendering the generating effect on the main canvas.
  63261. * @param effect The effect used to render through
  63262. */
  63263. protected _internalRender(effect: Effect): void;
  63264. /**
  63265. * Sets the required values for both the emissive texture and and the main color.
  63266. */
  63267. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  63268. /**
  63269. * Returns true if the mesh should render, otherwise false.
  63270. * @param mesh The mesh to render
  63271. * @returns true if it should render otherwise false
  63272. */
  63273. protected _shouldRenderMesh(mesh: Mesh): boolean;
  63274. /**
  63275. * Adds specific effects defines.
  63276. * @param defines The defines to add specifics to.
  63277. */
  63278. protected _addCustomEffectDefines(defines: string[]): void;
  63279. /**
  63280. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  63281. * @param mesh The mesh to exclude from the glow layer
  63282. */
  63283. addExcludedMesh(mesh: Mesh): void;
  63284. /**
  63285. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  63286. * @param mesh The mesh to remove
  63287. */
  63288. removeExcludedMesh(mesh: Mesh): void;
  63289. /**
  63290. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  63291. * @param mesh The mesh to include in the glow layer
  63292. */
  63293. addIncludedOnlyMesh(mesh: Mesh): void;
  63294. /**
  63295. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  63296. * @param mesh The mesh to remove
  63297. */
  63298. removeIncludedOnlyMesh(mesh: Mesh): void;
  63299. /**
  63300. * Determine if a given mesh will be used in the glow layer
  63301. * @param mesh The mesh to test
  63302. * @returns true if the mesh will be highlighted by the current glow layer
  63303. */
  63304. hasMesh(mesh: AbstractMesh): boolean;
  63305. /**
  63306. * Defines whether the current material of the mesh should be use to render the effect.
  63307. * @param mesh defines the current mesh to render
  63308. */
  63309. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  63310. /**
  63311. * Add a mesh to be rendered through its own material and not with emissive only.
  63312. * @param mesh The mesh for which we need to use its material
  63313. */
  63314. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  63315. /**
  63316. * Remove a mesh from being rendered through its own material and not with emissive only.
  63317. * @param mesh The mesh for which we need to not use its material
  63318. */
  63319. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  63320. /**
  63321. * Free any resources and references associated to a mesh.
  63322. * Internal use
  63323. * @param mesh The mesh to free.
  63324. * @hidden
  63325. */
  63326. _disposeMesh(mesh: Mesh): void;
  63327. /**
  63328. * Gets the class name of the effect layer
  63329. * @returns the string with the class name of the effect layer
  63330. */
  63331. getClassName(): string;
  63332. /**
  63333. * Serializes this glow layer
  63334. * @returns a serialized glow layer object
  63335. */
  63336. serialize(): any;
  63337. /**
  63338. * Creates a Glow Layer from parsed glow layer data
  63339. * @param parsedGlowLayer defines glow layer data
  63340. * @param scene defines the current scene
  63341. * @param rootUrl defines the root URL containing the glow layer information
  63342. * @returns a parsed Glow Layer
  63343. */
  63344. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  63345. }
  63346. }
  63347. declare module BABYLON {
  63348. /** @hidden */
  63349. export var glowBlurPostProcessPixelShader: {
  63350. name: string;
  63351. shader: string;
  63352. };
  63353. }
  63354. declare module BABYLON {
  63355. interface AbstractScene {
  63356. /**
  63357. * Return a the first highlight layer of the scene with a given name.
  63358. * @param name The name of the highlight layer to look for.
  63359. * @return The highlight layer if found otherwise null.
  63360. */
  63361. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  63362. }
  63363. /**
  63364. * Highlight layer options. This helps customizing the behaviour
  63365. * of the highlight layer.
  63366. */
  63367. export interface IHighlightLayerOptions {
  63368. /**
  63369. * Multiplication factor apply to the canvas size to compute the render target size
  63370. * used to generated the glowing objects (the smaller the faster).
  63371. */
  63372. mainTextureRatio: number;
  63373. /**
  63374. * Enforces a fixed size texture to ensure resize independant blur.
  63375. */
  63376. mainTextureFixedSize?: number;
  63377. /**
  63378. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  63379. * of the picture to blur (the smaller the faster).
  63380. */
  63381. blurTextureSizeRatio: number;
  63382. /**
  63383. * How big in texel of the blur texture is the vertical blur.
  63384. */
  63385. blurVerticalSize: number;
  63386. /**
  63387. * How big in texel of the blur texture is the horizontal blur.
  63388. */
  63389. blurHorizontalSize: number;
  63390. /**
  63391. * Alpha blending mode used to apply the blur. Default is combine.
  63392. */
  63393. alphaBlendingMode: number;
  63394. /**
  63395. * The camera attached to the layer.
  63396. */
  63397. camera: Nullable<Camera>;
  63398. /**
  63399. * Should we display highlight as a solid stroke?
  63400. */
  63401. isStroke?: boolean;
  63402. /**
  63403. * The rendering group to draw the layer in.
  63404. */
  63405. renderingGroupId: number;
  63406. }
  63407. /**
  63408. * The highlight layer Helps adding a glow effect around a mesh.
  63409. *
  63410. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  63411. * glowy meshes to your scene.
  63412. *
  63413. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  63414. */
  63415. export class HighlightLayer extends EffectLayer {
  63416. name: string;
  63417. /**
  63418. * Effect Name of the highlight layer.
  63419. */
  63420. static readonly EffectName: string;
  63421. /**
  63422. * The neutral color used during the preparation of the glow effect.
  63423. * This is black by default as the blend operation is a blend operation.
  63424. */
  63425. static NeutralColor: Color4;
  63426. /**
  63427. * Stencil value used for glowing meshes.
  63428. */
  63429. static GlowingMeshStencilReference: number;
  63430. /**
  63431. * Stencil value used for the other meshes in the scene.
  63432. */
  63433. static NormalMeshStencilReference: number;
  63434. /**
  63435. * Specifies whether or not the inner glow is ACTIVE in the layer.
  63436. */
  63437. innerGlow: boolean;
  63438. /**
  63439. * Specifies whether or not the outer glow is ACTIVE in the layer.
  63440. */
  63441. outerGlow: boolean;
  63442. /**
  63443. * Specifies the horizontal size of the blur.
  63444. */
  63445. set blurHorizontalSize(value: number);
  63446. /**
  63447. * Specifies the vertical size of the blur.
  63448. */
  63449. set blurVerticalSize(value: number);
  63450. /**
  63451. * Gets the horizontal size of the blur.
  63452. */
  63453. get blurHorizontalSize(): number;
  63454. /**
  63455. * Gets the vertical size of the blur.
  63456. */
  63457. get blurVerticalSize(): number;
  63458. /**
  63459. * An event triggered when the highlight layer is being blurred.
  63460. */
  63461. onBeforeBlurObservable: Observable<HighlightLayer>;
  63462. /**
  63463. * An event triggered when the highlight layer has been blurred.
  63464. */
  63465. onAfterBlurObservable: Observable<HighlightLayer>;
  63466. private _instanceGlowingMeshStencilReference;
  63467. private _options;
  63468. private _downSamplePostprocess;
  63469. private _horizontalBlurPostprocess;
  63470. private _verticalBlurPostprocess;
  63471. private _blurTexture;
  63472. private _meshes;
  63473. private _excludedMeshes;
  63474. /**
  63475. * Instantiates a new highlight Layer and references it to the scene..
  63476. * @param name The name of the layer
  63477. * @param scene The scene to use the layer in
  63478. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  63479. */
  63480. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  63481. /**
  63482. * Get the effect name of the layer.
  63483. * @return The effect name
  63484. */
  63485. getEffectName(): string;
  63486. /**
  63487. * Create the merge effect. This is the shader use to blit the information back
  63488. * to the main canvas at the end of the scene rendering.
  63489. */
  63490. protected _createMergeEffect(): Effect;
  63491. /**
  63492. * Creates the render target textures and post processes used in the highlight layer.
  63493. */
  63494. protected _createTextureAndPostProcesses(): void;
  63495. /**
  63496. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  63497. */
  63498. needStencil(): boolean;
  63499. /**
  63500. * Checks for the readiness of the element composing the layer.
  63501. * @param subMesh the mesh to check for
  63502. * @param useInstances specify wether or not to use instances to render the mesh
  63503. * @param emissiveTexture the associated emissive texture used to generate the glow
  63504. * @return true if ready otherwise, false
  63505. */
  63506. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  63507. /**
  63508. * Implementation specific of rendering the generating effect on the main canvas.
  63509. * @param effect The effect used to render through
  63510. */
  63511. protected _internalRender(effect: Effect): void;
  63512. /**
  63513. * Returns true if the layer contains information to display, otherwise false.
  63514. */
  63515. shouldRender(): boolean;
  63516. /**
  63517. * Returns true if the mesh should render, otherwise false.
  63518. * @param mesh The mesh to render
  63519. * @returns true if it should render otherwise false
  63520. */
  63521. protected _shouldRenderMesh(mesh: Mesh): boolean;
  63522. /**
  63523. * Returns true if the mesh can be rendered, otherwise false.
  63524. * @param mesh The mesh to render
  63525. * @param material The material used on the mesh
  63526. * @returns true if it can be rendered otherwise false
  63527. */
  63528. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  63529. /**
  63530. * Adds specific effects defines.
  63531. * @param defines The defines to add specifics to.
  63532. */
  63533. protected _addCustomEffectDefines(defines: string[]): void;
  63534. /**
  63535. * Sets the required values for both the emissive texture and and the main color.
  63536. */
  63537. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  63538. /**
  63539. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  63540. * @param mesh The mesh to exclude from the highlight layer
  63541. */
  63542. addExcludedMesh(mesh: Mesh): void;
  63543. /**
  63544. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  63545. * @param mesh The mesh to highlight
  63546. */
  63547. removeExcludedMesh(mesh: Mesh): void;
  63548. /**
  63549. * Determine if a given mesh will be highlighted by the current HighlightLayer
  63550. * @param mesh mesh to test
  63551. * @returns true if the mesh will be highlighted by the current HighlightLayer
  63552. */
  63553. hasMesh(mesh: AbstractMesh): boolean;
  63554. /**
  63555. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  63556. * @param mesh The mesh to highlight
  63557. * @param color The color of the highlight
  63558. * @param glowEmissiveOnly Extract the glow from the emissive texture
  63559. */
  63560. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  63561. /**
  63562. * Remove a mesh from the highlight layer in order to make it stop glowing.
  63563. * @param mesh The mesh to highlight
  63564. */
  63565. removeMesh(mesh: Mesh): void;
  63566. /**
  63567. * Remove all the meshes currently referenced in the highlight layer
  63568. */
  63569. removeAllMeshes(): void;
  63570. /**
  63571. * Force the stencil to the normal expected value for none glowing parts
  63572. */
  63573. private _defaultStencilReference;
  63574. /**
  63575. * Free any resources and references associated to a mesh.
  63576. * Internal use
  63577. * @param mesh The mesh to free.
  63578. * @hidden
  63579. */
  63580. _disposeMesh(mesh: Mesh): void;
  63581. /**
  63582. * Dispose the highlight layer and free resources.
  63583. */
  63584. dispose(): void;
  63585. /**
  63586. * Gets the class name of the effect layer
  63587. * @returns the string with the class name of the effect layer
  63588. */
  63589. getClassName(): string;
  63590. /**
  63591. * Serializes this Highlight layer
  63592. * @returns a serialized Highlight layer object
  63593. */
  63594. serialize(): any;
  63595. /**
  63596. * Creates a Highlight layer from parsed Highlight layer data
  63597. * @param parsedHightlightLayer defines the Highlight layer data
  63598. * @param scene defines the current scene
  63599. * @param rootUrl defines the root URL containing the Highlight layer information
  63600. * @returns a parsed Highlight layer
  63601. */
  63602. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  63603. }
  63604. }
  63605. declare module BABYLON {
  63606. interface AbstractScene {
  63607. /**
  63608. * The list of layers (background and foreground) of the scene
  63609. */
  63610. layers: Array<Layer>;
  63611. }
  63612. /**
  63613. * Defines the layer scene component responsible to manage any layers
  63614. * in a given scene.
  63615. */
  63616. export class LayerSceneComponent implements ISceneComponent {
  63617. /**
  63618. * The component name helpfull to identify the component in the list of scene components.
  63619. */
  63620. readonly name: string;
  63621. /**
  63622. * The scene the component belongs to.
  63623. */
  63624. scene: Scene;
  63625. private _engine;
  63626. /**
  63627. * Creates a new instance of the component for the given scene
  63628. * @param scene Defines the scene to register the component in
  63629. */
  63630. constructor(scene: Scene);
  63631. /**
  63632. * Registers the component in a given scene
  63633. */
  63634. register(): void;
  63635. /**
  63636. * Rebuilds the elements related to this component in case of
  63637. * context lost for instance.
  63638. */
  63639. rebuild(): void;
  63640. /**
  63641. * Disposes the component and the associated ressources.
  63642. */
  63643. dispose(): void;
  63644. private _draw;
  63645. private _drawCameraPredicate;
  63646. private _drawCameraBackground;
  63647. private _drawCameraForeground;
  63648. private _drawRenderTargetPredicate;
  63649. private _drawRenderTargetBackground;
  63650. private _drawRenderTargetForeground;
  63651. /**
  63652. * Adds all the elements from the container to the scene
  63653. * @param container the container holding the elements
  63654. */
  63655. addFromContainer(container: AbstractScene): void;
  63656. /**
  63657. * Removes all the elements in the container from the scene
  63658. * @param container contains the elements to remove
  63659. * @param dispose if the removed element should be disposed (default: false)
  63660. */
  63661. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  63662. }
  63663. }
  63664. declare module BABYLON {
  63665. /** @hidden */
  63666. export var layerPixelShader: {
  63667. name: string;
  63668. shader: string;
  63669. };
  63670. }
  63671. declare module BABYLON {
  63672. /** @hidden */
  63673. export var layerVertexShader: {
  63674. name: string;
  63675. shader: string;
  63676. };
  63677. }
  63678. declare module BABYLON {
  63679. /**
  63680. * This represents a full screen 2d layer.
  63681. * This can be useful to display a picture in the background of your scene for instance.
  63682. * @see https://www.babylonjs-playground.com/#08A2BS#1
  63683. */
  63684. export class Layer {
  63685. /**
  63686. * Define the name of the layer.
  63687. */
  63688. name: string;
  63689. /**
  63690. * Define the texture the layer should display.
  63691. */
  63692. texture: Nullable<Texture>;
  63693. /**
  63694. * Is the layer in background or foreground.
  63695. */
  63696. isBackground: boolean;
  63697. /**
  63698. * Define the color of the layer (instead of texture).
  63699. */
  63700. color: Color4;
  63701. /**
  63702. * Define the scale of the layer in order to zoom in out of the texture.
  63703. */
  63704. scale: Vector2;
  63705. /**
  63706. * Define an offset for the layer in order to shift the texture.
  63707. */
  63708. offset: Vector2;
  63709. /**
  63710. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  63711. */
  63712. alphaBlendingMode: number;
  63713. /**
  63714. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  63715. * Alpha test will not mix with the background color in case of transparency.
  63716. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  63717. */
  63718. alphaTest: boolean;
  63719. /**
  63720. * Define a mask to restrict the layer to only some of the scene cameras.
  63721. */
  63722. layerMask: number;
  63723. /**
  63724. * Define the list of render target the layer is visible into.
  63725. */
  63726. renderTargetTextures: RenderTargetTexture[];
  63727. /**
  63728. * Define if the layer is only used in renderTarget or if it also
  63729. * renders in the main frame buffer of the canvas.
  63730. */
  63731. renderOnlyInRenderTargetTextures: boolean;
  63732. private _scene;
  63733. private _vertexBuffers;
  63734. private _indexBuffer;
  63735. private _effect;
  63736. private _previousDefines;
  63737. /**
  63738. * An event triggered when the layer is disposed.
  63739. */
  63740. onDisposeObservable: Observable<Layer>;
  63741. private _onDisposeObserver;
  63742. /**
  63743. * Back compatibility with callback before the onDisposeObservable existed.
  63744. * The set callback will be triggered when the layer has been disposed.
  63745. */
  63746. set onDispose(callback: () => void);
  63747. /**
  63748. * An event triggered before rendering the scene
  63749. */
  63750. onBeforeRenderObservable: Observable<Layer>;
  63751. private _onBeforeRenderObserver;
  63752. /**
  63753. * Back compatibility with callback before the onBeforeRenderObservable existed.
  63754. * The set callback will be triggered just before rendering the layer.
  63755. */
  63756. set onBeforeRender(callback: () => void);
  63757. /**
  63758. * An event triggered after rendering the scene
  63759. */
  63760. onAfterRenderObservable: Observable<Layer>;
  63761. private _onAfterRenderObserver;
  63762. /**
  63763. * Back compatibility with callback before the onAfterRenderObservable existed.
  63764. * The set callback will be triggered just after rendering the layer.
  63765. */
  63766. set onAfterRender(callback: () => void);
  63767. /**
  63768. * Instantiates a new layer.
  63769. * This represents a full screen 2d layer.
  63770. * This can be useful to display a picture in the background of your scene for instance.
  63771. * @see https://www.babylonjs-playground.com/#08A2BS#1
  63772. * @param name Define the name of the layer in the scene
  63773. * @param imgUrl Define the url of the texture to display in the layer
  63774. * @param scene Define the scene the layer belongs to
  63775. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  63776. * @param color Defines a color for the layer
  63777. */
  63778. constructor(
  63779. /**
  63780. * Define the name of the layer.
  63781. */
  63782. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  63783. private _createIndexBuffer;
  63784. /** @hidden */
  63785. _rebuild(): void;
  63786. /**
  63787. * Renders the layer in the scene.
  63788. */
  63789. render(): void;
  63790. /**
  63791. * Disposes and releases the associated ressources.
  63792. */
  63793. dispose(): void;
  63794. }
  63795. }
  63796. declare module BABYLON {
  63797. /** @hidden */
  63798. export var lensFlarePixelShader: {
  63799. name: string;
  63800. shader: string;
  63801. };
  63802. }
  63803. declare module BABYLON {
  63804. /** @hidden */
  63805. export var lensFlareVertexShader: {
  63806. name: string;
  63807. shader: string;
  63808. };
  63809. }
  63810. declare module BABYLON {
  63811. /**
  63812. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  63813. * It is usually composed of several `lensFlare`.
  63814. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  63815. */
  63816. export class LensFlareSystem {
  63817. /**
  63818. * Define the name of the lens flare system
  63819. */
  63820. name: string;
  63821. /**
  63822. * List of lens flares used in this system.
  63823. */
  63824. lensFlares: LensFlare[];
  63825. /**
  63826. * Define a limit from the border the lens flare can be visible.
  63827. */
  63828. borderLimit: number;
  63829. /**
  63830. * Define a viewport border we do not want to see the lens flare in.
  63831. */
  63832. viewportBorder: number;
  63833. /**
  63834. * Define a predicate which could limit the list of meshes able to occlude the effect.
  63835. */
  63836. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  63837. /**
  63838. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  63839. */
  63840. layerMask: number;
  63841. /**
  63842. * Define the id of the lens flare system in the scene.
  63843. * (equal to name by default)
  63844. */
  63845. id: string;
  63846. private _scene;
  63847. private _emitter;
  63848. private _vertexBuffers;
  63849. private _indexBuffer;
  63850. private _effect;
  63851. private _positionX;
  63852. private _positionY;
  63853. private _isEnabled;
  63854. /** @hidden */
  63855. static _SceneComponentInitialization: (scene: Scene) => void;
  63856. /**
  63857. * Instantiates a lens flare system.
  63858. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  63859. * It is usually composed of several `lensFlare`.
  63860. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  63861. * @param name Define the name of the lens flare system in the scene
  63862. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  63863. * @param scene Define the scene the lens flare system belongs to
  63864. */
  63865. constructor(
  63866. /**
  63867. * Define the name of the lens flare system
  63868. */
  63869. name: string, emitter: any, scene: Scene);
  63870. /**
  63871. * Define if the lens flare system is enabled.
  63872. */
  63873. get isEnabled(): boolean;
  63874. set isEnabled(value: boolean);
  63875. /**
  63876. * Get the scene the effects belongs to.
  63877. * @returns the scene holding the lens flare system
  63878. */
  63879. getScene(): Scene;
  63880. /**
  63881. * Get the emitter of the lens flare system.
  63882. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  63883. * @returns the emitter of the lens flare system
  63884. */
  63885. getEmitter(): any;
  63886. /**
  63887. * Set the emitter of the lens flare system.
  63888. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  63889. * @param newEmitter Define the new emitter of the system
  63890. */
  63891. setEmitter(newEmitter: any): void;
  63892. /**
  63893. * Get the lens flare system emitter position.
  63894. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  63895. * @returns the position
  63896. */
  63897. getEmitterPosition(): Vector3;
  63898. /**
  63899. * @hidden
  63900. */
  63901. computeEffectivePosition(globalViewport: Viewport): boolean;
  63902. /** @hidden */
  63903. _isVisible(): boolean;
  63904. /**
  63905. * @hidden
  63906. */
  63907. render(): boolean;
  63908. /**
  63909. * Dispose and release the lens flare with its associated resources.
  63910. */
  63911. dispose(): void;
  63912. /**
  63913. * Parse a lens flare system from a JSON repressentation
  63914. * @param parsedLensFlareSystem Define the JSON to parse
  63915. * @param scene Define the scene the parsed system should be instantiated in
  63916. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  63917. * @returns the parsed system
  63918. */
  63919. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  63920. /**
  63921. * Serialize the current Lens Flare System into a JSON representation.
  63922. * @returns the serialized JSON
  63923. */
  63924. serialize(): any;
  63925. }
  63926. }
  63927. declare module BABYLON {
  63928. /**
  63929. * This represents one of the lens effect in a `lensFlareSystem`.
  63930. * It controls one of the indiviual texture used in the effect.
  63931. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  63932. */
  63933. export class LensFlare {
  63934. /**
  63935. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  63936. */
  63937. size: number;
  63938. /**
  63939. * 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.
  63940. */
  63941. position: number;
  63942. /**
  63943. * Define the lens color.
  63944. */
  63945. color: Color3;
  63946. /**
  63947. * Define the lens texture.
  63948. */
  63949. texture: Nullable<Texture>;
  63950. /**
  63951. * Define the alpha mode to render this particular lens.
  63952. */
  63953. alphaMode: number;
  63954. private _system;
  63955. /**
  63956. * Creates a new Lens Flare.
  63957. * This represents one of the lens effect in a `lensFlareSystem`.
  63958. * It controls one of the indiviual texture used in the effect.
  63959. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  63960. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  63961. * @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.
  63962. * @param color Define the lens color
  63963. * @param imgUrl Define the lens texture url
  63964. * @param system Define the `lensFlareSystem` this flare is part of
  63965. * @returns The newly created Lens Flare
  63966. */
  63967. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  63968. /**
  63969. * Instantiates a new Lens Flare.
  63970. * This represents one of the lens effect in a `lensFlareSystem`.
  63971. * It controls one of the indiviual texture used in the effect.
  63972. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  63973. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  63974. * @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.
  63975. * @param color Define the lens color
  63976. * @param imgUrl Define the lens texture url
  63977. * @param system Define the `lensFlareSystem` this flare is part of
  63978. */
  63979. constructor(
  63980. /**
  63981. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  63982. */
  63983. size: number,
  63984. /**
  63985. * 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.
  63986. */
  63987. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  63988. /**
  63989. * Dispose and release the lens flare with its associated resources.
  63990. */
  63991. dispose(): void;
  63992. }
  63993. }
  63994. declare module BABYLON {
  63995. interface AbstractScene {
  63996. /**
  63997. * The list of lens flare system added to the scene
  63998. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  63999. */
  64000. lensFlareSystems: Array<LensFlareSystem>;
  64001. /**
  64002. * Removes the given lens flare system from this scene.
  64003. * @param toRemove The lens flare system to remove
  64004. * @returns The index of the removed lens flare system
  64005. */
  64006. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  64007. /**
  64008. * Adds the given lens flare system to this scene
  64009. * @param newLensFlareSystem The lens flare system to add
  64010. */
  64011. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  64012. /**
  64013. * Gets a lens flare system using its name
  64014. * @param name defines the name to look for
  64015. * @returns the lens flare system or null if not found
  64016. */
  64017. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  64018. /**
  64019. * Gets a lens flare system using its id
  64020. * @param id defines the id to look for
  64021. * @returns the lens flare system or null if not found
  64022. */
  64023. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  64024. }
  64025. /**
  64026. * Defines the lens flare scene component responsible to manage any lens flares
  64027. * in a given scene.
  64028. */
  64029. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  64030. /**
  64031. * The component name helpfull to identify the component in the list of scene components.
  64032. */
  64033. readonly name: string;
  64034. /**
  64035. * The scene the component belongs to.
  64036. */
  64037. scene: Scene;
  64038. /**
  64039. * Creates a new instance of the component for the given scene
  64040. * @param scene Defines the scene to register the component in
  64041. */
  64042. constructor(scene: Scene);
  64043. /**
  64044. * Registers the component in a given scene
  64045. */
  64046. register(): void;
  64047. /**
  64048. * Rebuilds the elements related to this component in case of
  64049. * context lost for instance.
  64050. */
  64051. rebuild(): void;
  64052. /**
  64053. * Adds all the elements from the container to the scene
  64054. * @param container the container holding the elements
  64055. */
  64056. addFromContainer(container: AbstractScene): void;
  64057. /**
  64058. * Removes all the elements in the container from the scene
  64059. * @param container contains the elements to remove
  64060. * @param dispose if the removed element should be disposed (default: false)
  64061. */
  64062. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  64063. /**
  64064. * Serializes the component data to the specified json object
  64065. * @param serializationObject The object to serialize to
  64066. */
  64067. serialize(serializationObject: any): void;
  64068. /**
  64069. * Disposes the component and the associated ressources.
  64070. */
  64071. dispose(): void;
  64072. private _draw;
  64073. }
  64074. }
  64075. declare module BABYLON {
  64076. /** @hidden */
  64077. export var depthPixelShader: {
  64078. name: string;
  64079. shader: string;
  64080. };
  64081. }
  64082. declare module BABYLON {
  64083. /** @hidden */
  64084. export var depthVertexShader: {
  64085. name: string;
  64086. shader: string;
  64087. };
  64088. }
  64089. declare module BABYLON {
  64090. /**
  64091. * This represents a depth renderer in Babylon.
  64092. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  64093. */
  64094. export class DepthRenderer {
  64095. private _scene;
  64096. private _depthMap;
  64097. private _effect;
  64098. private readonly _storeNonLinearDepth;
  64099. private readonly _clearColor;
  64100. /** Get if the depth renderer is using packed depth or not */
  64101. readonly isPacked: boolean;
  64102. private _cachedDefines;
  64103. private _camera;
  64104. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  64105. enabled: boolean;
  64106. /**
  64107. * Specifiess that the depth renderer will only be used within
  64108. * the camera it is created for.
  64109. * This can help forcing its rendering during the camera processing.
  64110. */
  64111. useOnlyInActiveCamera: boolean;
  64112. /** @hidden */
  64113. static _SceneComponentInitialization: (scene: Scene) => void;
  64114. /**
  64115. * Instantiates a depth renderer
  64116. * @param scene The scene the renderer belongs to
  64117. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  64118. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  64119. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  64120. */
  64121. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  64122. /**
  64123. * Creates the depth rendering effect and checks if the effect is ready.
  64124. * @param subMesh The submesh to be used to render the depth map of
  64125. * @param useInstances If multiple world instances should be used
  64126. * @returns if the depth renderer is ready to render the depth map
  64127. */
  64128. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  64129. /**
  64130. * Gets the texture which the depth map will be written to.
  64131. * @returns The depth map texture
  64132. */
  64133. getDepthMap(): RenderTargetTexture;
  64134. /**
  64135. * Disposes of the depth renderer.
  64136. */
  64137. dispose(): void;
  64138. }
  64139. }
  64140. declare module BABYLON {
  64141. /** @hidden */
  64142. export var minmaxReduxPixelShader: {
  64143. name: string;
  64144. shader: string;
  64145. };
  64146. }
  64147. declare module BABYLON {
  64148. /**
  64149. * This class computes a min/max reduction from a texture: it means it computes the minimum
  64150. * and maximum values from all values of the texture.
  64151. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  64152. * The source values are read from the red channel of the texture.
  64153. */
  64154. export class MinMaxReducer {
  64155. /**
  64156. * Observable triggered when the computation has been performed
  64157. */
  64158. onAfterReductionPerformed: Observable<{
  64159. min: number;
  64160. max: number;
  64161. }>;
  64162. protected _camera: Camera;
  64163. protected _sourceTexture: Nullable<RenderTargetTexture>;
  64164. protected _reductionSteps: Nullable<Array<PostProcess>>;
  64165. protected _postProcessManager: PostProcessManager;
  64166. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  64167. protected _forceFullscreenViewport: boolean;
  64168. /**
  64169. * Creates a min/max reducer
  64170. * @param camera The camera to use for the post processes
  64171. */
  64172. constructor(camera: Camera);
  64173. /**
  64174. * Gets the texture used to read the values from.
  64175. */
  64176. get sourceTexture(): Nullable<RenderTargetTexture>;
  64177. /**
  64178. * Sets the source texture to read the values from.
  64179. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  64180. * because in such textures '1' value must not be taken into account to compute the maximum
  64181. * as this value is used to clear the texture.
  64182. * Note that the computation is not activated by calling this function, you must call activate() for that!
  64183. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  64184. * @param depthRedux Indicates if the texture is a depth texture or not
  64185. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  64186. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  64187. */
  64188. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  64189. /**
  64190. * Defines the refresh rate of the computation.
  64191. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  64192. */
  64193. get refreshRate(): number;
  64194. set refreshRate(value: number);
  64195. protected _activated: boolean;
  64196. /**
  64197. * Gets the activation status of the reducer
  64198. */
  64199. get activated(): boolean;
  64200. /**
  64201. * Activates the reduction computation.
  64202. * When activated, the observers registered in onAfterReductionPerformed are
  64203. * called after the compuation is performed
  64204. */
  64205. activate(): void;
  64206. /**
  64207. * Deactivates the reduction computation.
  64208. */
  64209. deactivate(): void;
  64210. /**
  64211. * Disposes the min/max reducer
  64212. * @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.
  64213. */
  64214. dispose(disposeAll?: boolean): void;
  64215. }
  64216. }
  64217. declare module BABYLON {
  64218. /**
  64219. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  64220. */
  64221. export class DepthReducer extends MinMaxReducer {
  64222. private _depthRenderer;
  64223. private _depthRendererId;
  64224. /**
  64225. * Gets the depth renderer used for the computation.
  64226. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  64227. */
  64228. get depthRenderer(): Nullable<DepthRenderer>;
  64229. /**
  64230. * Creates a depth reducer
  64231. * @param camera The camera used to render the depth texture
  64232. */
  64233. constructor(camera: Camera);
  64234. /**
  64235. * Sets the depth renderer to use to generate the depth map
  64236. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  64237. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  64238. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  64239. */
  64240. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  64241. /** @hidden */
  64242. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  64243. /**
  64244. * Activates the reduction computation.
  64245. * When activated, the observers registered in onAfterReductionPerformed are
  64246. * called after the compuation is performed
  64247. */
  64248. activate(): void;
  64249. /**
  64250. * Deactivates the reduction computation.
  64251. */
  64252. deactivate(): void;
  64253. /**
  64254. * Disposes the depth reducer
  64255. * @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.
  64256. */
  64257. dispose(disposeAll?: boolean): void;
  64258. }
  64259. }
  64260. declare module BABYLON {
  64261. /**
  64262. * A CSM implementation allowing casting shadows on large scenes.
  64263. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  64264. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  64265. */
  64266. export class CascadedShadowGenerator extends ShadowGenerator {
  64267. private static readonly frustumCornersNDCSpace;
  64268. /**
  64269. * Name of the CSM class
  64270. */
  64271. static CLASSNAME: string;
  64272. /**
  64273. * Defines the default number of cascades used by the CSM.
  64274. */
  64275. static readonly DEFAULT_CASCADES_COUNT: number;
  64276. /**
  64277. * Defines the minimum number of cascades used by the CSM.
  64278. */
  64279. static readonly MIN_CASCADES_COUNT: number;
  64280. /**
  64281. * Defines the maximum number of cascades used by the CSM.
  64282. */
  64283. static readonly MAX_CASCADES_COUNT: number;
  64284. protected _validateFilter(filter: number): number;
  64285. /**
  64286. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  64287. */
  64288. penumbraDarkness: number;
  64289. private _numCascades;
  64290. /**
  64291. * Gets or set the number of cascades used by the CSM.
  64292. */
  64293. get numCascades(): number;
  64294. set numCascades(value: number);
  64295. /**
  64296. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  64297. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  64298. */
  64299. stabilizeCascades: boolean;
  64300. private _freezeShadowCastersBoundingInfo;
  64301. private _freezeShadowCastersBoundingInfoObservable;
  64302. /**
  64303. * Enables or disables the shadow casters bounding info computation.
  64304. * If your shadow casters don't move, you can disable this feature.
  64305. * If it is enabled, the bounding box computation is done every frame.
  64306. */
  64307. get freezeShadowCastersBoundingInfo(): boolean;
  64308. set freezeShadowCastersBoundingInfo(freeze: boolean);
  64309. private _scbiMin;
  64310. private _scbiMax;
  64311. protected _computeShadowCastersBoundingInfo(): void;
  64312. protected _shadowCastersBoundingInfo: BoundingInfo;
  64313. /**
  64314. * Gets or sets the shadow casters bounding info.
  64315. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  64316. * so that the system won't overwrite the bounds you provide
  64317. */
  64318. get shadowCastersBoundingInfo(): BoundingInfo;
  64319. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  64320. protected _breaksAreDirty: boolean;
  64321. protected _minDistance: number;
  64322. protected _maxDistance: number;
  64323. /**
  64324. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  64325. *
  64326. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  64327. * If you don't know these values, simply leave them to their defaults and don't call this function.
  64328. * @param min minimal distance for the breaks (default to 0.)
  64329. * @param max maximal distance for the breaks (default to 1.)
  64330. */
  64331. setMinMaxDistance(min: number, max: number): void;
  64332. /** Gets the minimal distance used in the cascade break computation */
  64333. get minDistance(): number;
  64334. /** Gets the maximal distance used in the cascade break computation */
  64335. get maxDistance(): number;
  64336. /**
  64337. * Gets the class name of that object
  64338. * @returns "CascadedShadowGenerator"
  64339. */
  64340. getClassName(): string;
  64341. private _cascadeMinExtents;
  64342. private _cascadeMaxExtents;
  64343. /**
  64344. * Gets a cascade minimum extents
  64345. * @param cascadeIndex index of the cascade
  64346. * @returns the minimum cascade extents
  64347. */
  64348. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  64349. /**
  64350. * Gets a cascade maximum extents
  64351. * @param cascadeIndex index of the cascade
  64352. * @returns the maximum cascade extents
  64353. */
  64354. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  64355. private _cascades;
  64356. private _currentLayer;
  64357. private _viewSpaceFrustumsZ;
  64358. private _viewMatrices;
  64359. private _projectionMatrices;
  64360. private _transformMatrices;
  64361. private _transformMatricesAsArray;
  64362. private _frustumLengths;
  64363. private _lightSizeUVCorrection;
  64364. private _depthCorrection;
  64365. private _frustumCornersWorldSpace;
  64366. private _frustumCenter;
  64367. private _shadowCameraPos;
  64368. private _shadowMaxZ;
  64369. /**
  64370. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  64371. * It defaults to camera.maxZ
  64372. */
  64373. get shadowMaxZ(): number;
  64374. /**
  64375. * Sets the shadow max z distance.
  64376. */
  64377. set shadowMaxZ(value: number);
  64378. protected _debug: boolean;
  64379. /**
  64380. * Gets or sets the debug flag.
  64381. * When enabled, the cascades are materialized by different colors on the screen.
  64382. */
  64383. get debug(): boolean;
  64384. set debug(dbg: boolean);
  64385. private _depthClamp;
  64386. /**
  64387. * Gets or sets the depth clamping value.
  64388. *
  64389. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  64390. * to account for the shadow casters far away.
  64391. *
  64392. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  64393. */
  64394. get depthClamp(): boolean;
  64395. set depthClamp(value: boolean);
  64396. private _cascadeBlendPercentage;
  64397. /**
  64398. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  64399. * It defaults to 0.1 (10% blending).
  64400. */
  64401. get cascadeBlendPercentage(): number;
  64402. set cascadeBlendPercentage(value: number);
  64403. private _lambda;
  64404. /**
  64405. * Gets or set the lambda parameter.
  64406. * This parameter is used to split the camera frustum and create the cascades.
  64407. * 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.
  64408. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  64409. */
  64410. get lambda(): number;
  64411. set lambda(value: number);
  64412. /**
  64413. * Gets the view matrix corresponding to a given cascade
  64414. * @param cascadeNum cascade to retrieve the view matrix from
  64415. * @returns the cascade view matrix
  64416. */
  64417. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  64418. /**
  64419. * Gets the projection matrix corresponding to a given cascade
  64420. * @param cascadeNum cascade to retrieve the projection matrix from
  64421. * @returns the cascade projection matrix
  64422. */
  64423. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  64424. /**
  64425. * Gets the transformation matrix corresponding to a given cascade
  64426. * @param cascadeNum cascade to retrieve the transformation matrix from
  64427. * @returns the cascade transformation matrix
  64428. */
  64429. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  64430. private _depthRenderer;
  64431. /**
  64432. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  64433. *
  64434. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  64435. *
  64436. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  64437. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  64438. * @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
  64439. */
  64440. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  64441. private _depthReducer;
  64442. private _autoCalcDepthBounds;
  64443. /**
  64444. * Gets or sets the autoCalcDepthBounds property.
  64445. *
  64446. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  64447. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  64448. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  64449. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  64450. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  64451. */
  64452. get autoCalcDepthBounds(): boolean;
  64453. set autoCalcDepthBounds(value: boolean);
  64454. /**
  64455. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  64456. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  64457. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  64458. * for setting the refresh rate on the renderer yourself!
  64459. */
  64460. get autoCalcDepthBoundsRefreshRate(): number;
  64461. set autoCalcDepthBoundsRefreshRate(value: number);
  64462. /**
  64463. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  64464. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  64465. * you change the camera near/far planes!
  64466. */
  64467. splitFrustum(): void;
  64468. private _splitFrustum;
  64469. private _computeMatrices;
  64470. private _computeFrustumInWorldSpace;
  64471. private _computeCascadeFrustum;
  64472. /**
  64473. * Support test.
  64474. */
  64475. static get IsSupported(): boolean;
  64476. /** @hidden */
  64477. static _SceneComponentInitialization: (scene: Scene) => void;
  64478. /**
  64479. * Creates a Cascaded Shadow Generator object.
  64480. * A ShadowGenerator is the required tool to use the shadows.
  64481. * Each directional light casting shadows needs to use its own ShadowGenerator.
  64482. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  64483. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  64484. * @param light The directional light object generating the shadows.
  64485. * @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.
  64486. */
  64487. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  64488. protected _initializeGenerator(): void;
  64489. protected _createTargetRenderTexture(): void;
  64490. protected _initializeShadowMap(): void;
  64491. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  64492. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  64493. /**
  64494. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  64495. * @param defines Defines of the material we want to update
  64496. * @param lightIndex Index of the light in the enabled light list of the material
  64497. */
  64498. prepareDefines(defines: any, lightIndex: number): void;
  64499. /**
  64500. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  64501. * defined in the generator but impacting the effect).
  64502. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  64503. * @param effect The effect we are binfing the information for
  64504. */
  64505. bindShadowLight(lightIndex: string, effect: Effect): void;
  64506. /**
  64507. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  64508. * (eq to view projection * shadow projection matrices)
  64509. * @returns The transform matrix used to create the shadow map
  64510. */
  64511. getTransformMatrix(): Matrix;
  64512. /**
  64513. * Disposes the ShadowGenerator.
  64514. * Returns nothing.
  64515. */
  64516. dispose(): void;
  64517. /**
  64518. * Serializes the shadow generator setup to a json object.
  64519. * @returns The serialized JSON object
  64520. */
  64521. serialize(): any;
  64522. /**
  64523. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  64524. * @param parsedShadowGenerator The JSON object to parse
  64525. * @param scene The scene to create the shadow map for
  64526. * @returns The parsed shadow generator
  64527. */
  64528. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  64529. }
  64530. }
  64531. declare module BABYLON {
  64532. /**
  64533. * Defines the shadow generator component responsible to manage any shadow generators
  64534. * in a given scene.
  64535. */
  64536. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  64537. /**
  64538. * The component name helpfull to identify the component in the list of scene components.
  64539. */
  64540. readonly name: string;
  64541. /**
  64542. * The scene the component belongs to.
  64543. */
  64544. scene: Scene;
  64545. /**
  64546. * Creates a new instance of the component for the given scene
  64547. * @param scene Defines the scene to register the component in
  64548. */
  64549. constructor(scene: Scene);
  64550. /**
  64551. * Registers the component in a given scene
  64552. */
  64553. register(): void;
  64554. /**
  64555. * Rebuilds the elements related to this component in case of
  64556. * context lost for instance.
  64557. */
  64558. rebuild(): void;
  64559. /**
  64560. * Serializes the component data to the specified json object
  64561. * @param serializationObject The object to serialize to
  64562. */
  64563. serialize(serializationObject: any): void;
  64564. /**
  64565. * Adds all the elements from the container to the scene
  64566. * @param container the container holding the elements
  64567. */
  64568. addFromContainer(container: AbstractScene): void;
  64569. /**
  64570. * Removes all the elements in the container from the scene
  64571. * @param container contains the elements to remove
  64572. * @param dispose if the removed element should be disposed (default: false)
  64573. */
  64574. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  64575. /**
  64576. * Rebuilds the elements related to this component in case of
  64577. * context lost for instance.
  64578. */
  64579. dispose(): void;
  64580. private _gatherRenderTargets;
  64581. }
  64582. }
  64583. declare module BABYLON {
  64584. /**
  64585. * A point light is a light defined by an unique point in world space.
  64586. * The light is emitted in every direction from this point.
  64587. * A good example of a point light is a standard light bulb.
  64588. * Documentation: https://doc.babylonjs.com/babylon101/lights
  64589. */
  64590. export class PointLight extends ShadowLight {
  64591. private _shadowAngle;
  64592. /**
  64593. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  64594. * This specifies what angle the shadow will use to be created.
  64595. *
  64596. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  64597. */
  64598. get shadowAngle(): number;
  64599. /**
  64600. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  64601. * This specifies what angle the shadow will use to be created.
  64602. *
  64603. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  64604. */
  64605. set shadowAngle(value: number);
  64606. /**
  64607. * Gets the direction if it has been set.
  64608. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  64609. */
  64610. get direction(): Vector3;
  64611. /**
  64612. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  64613. */
  64614. set direction(value: Vector3);
  64615. /**
  64616. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  64617. * A PointLight emits the light in every direction.
  64618. * It can cast shadows.
  64619. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  64620. * ```javascript
  64621. * var pointLight = new PointLight("pl", camera.position, scene);
  64622. * ```
  64623. * Documentation : https://doc.babylonjs.com/babylon101/lights
  64624. * @param name The light friendly name
  64625. * @param position The position of the point light in the scene
  64626. * @param scene The scene the lights belongs to
  64627. */
  64628. constructor(name: string, position: Vector3, scene: Scene);
  64629. /**
  64630. * Returns the string "PointLight"
  64631. * @returns the class name
  64632. */
  64633. getClassName(): string;
  64634. /**
  64635. * Returns the integer 0.
  64636. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  64637. */
  64638. getTypeID(): number;
  64639. /**
  64640. * Specifies wether or not the shadowmap should be a cube texture.
  64641. * @returns true if the shadowmap needs to be a cube texture.
  64642. */
  64643. needCube(): boolean;
  64644. /**
  64645. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  64646. * @param faceIndex The index of the face we are computed the direction to generate shadow
  64647. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  64648. */
  64649. getShadowDirection(faceIndex?: number): Vector3;
  64650. /**
  64651. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  64652. * - fov = PI / 2
  64653. * - aspect ratio : 1.0
  64654. * - z-near and far equal to the active camera minZ and maxZ.
  64655. * Returns the PointLight.
  64656. */
  64657. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  64658. protected _buildUniformLayout(): void;
  64659. /**
  64660. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  64661. * @param effect The effect to update
  64662. * @param lightIndex The index of the light in the effect to update
  64663. * @returns The point light
  64664. */
  64665. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  64666. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  64667. /**
  64668. * Prepares the list of defines specific to the light type.
  64669. * @param defines the list of defines
  64670. * @param lightIndex defines the index of the light for the effect
  64671. */
  64672. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  64673. }
  64674. }
  64675. declare module BABYLON {
  64676. /**
  64677. * Header information of HDR texture files.
  64678. */
  64679. export interface HDRInfo {
  64680. /**
  64681. * The height of the texture in pixels.
  64682. */
  64683. height: number;
  64684. /**
  64685. * The width of the texture in pixels.
  64686. */
  64687. width: number;
  64688. /**
  64689. * The index of the beginning of the data in the binary file.
  64690. */
  64691. dataPosition: number;
  64692. }
  64693. /**
  64694. * This groups tools to convert HDR texture to native colors array.
  64695. */
  64696. export class HDRTools {
  64697. private static Ldexp;
  64698. private static Rgbe2float;
  64699. private static readStringLine;
  64700. /**
  64701. * Reads header information from an RGBE texture stored in a native array.
  64702. * More information on this format are available here:
  64703. * https://en.wikipedia.org/wiki/RGBE_image_format
  64704. *
  64705. * @param uint8array The binary file stored in native array.
  64706. * @return The header information.
  64707. */
  64708. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  64709. /**
  64710. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  64711. * This RGBE texture needs to store the information as a panorama.
  64712. *
  64713. * More information on this format are available here:
  64714. * https://en.wikipedia.org/wiki/RGBE_image_format
  64715. *
  64716. * @param buffer The binary file stored in an array buffer.
  64717. * @param size The expected size of the extracted cubemap.
  64718. * @return The Cube Map information.
  64719. */
  64720. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  64721. /**
  64722. * Returns the pixels data extracted from an RGBE texture.
  64723. * This pixels will be stored left to right up to down in the R G B order in one array.
  64724. *
  64725. * More information on this format are available here:
  64726. * https://en.wikipedia.org/wiki/RGBE_image_format
  64727. *
  64728. * @param uint8array The binary file stored in an array buffer.
  64729. * @param hdrInfo The header information of the file.
  64730. * @return The pixels data in RGB right to left up to down order.
  64731. */
  64732. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  64733. private static RGBE_ReadPixels_RLE;
  64734. private static RGBE_ReadPixels_NOT_RLE;
  64735. }
  64736. }
  64737. declare module BABYLON {
  64738. /**
  64739. * Effect Render Options
  64740. */
  64741. export interface IEffectRendererOptions {
  64742. /**
  64743. * Defines the vertices positions.
  64744. */
  64745. positions?: number[];
  64746. /**
  64747. * Defines the indices.
  64748. */
  64749. indices?: number[];
  64750. }
  64751. /**
  64752. * Helper class to render one or more effects.
  64753. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  64754. */
  64755. export class EffectRenderer {
  64756. private engine;
  64757. private static _DefaultOptions;
  64758. private _vertexBuffers;
  64759. private _indexBuffer;
  64760. private _fullscreenViewport;
  64761. /**
  64762. * Creates an effect renderer
  64763. * @param engine the engine to use for rendering
  64764. * @param options defines the options of the effect renderer
  64765. */
  64766. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  64767. /**
  64768. * Sets the current viewport in normalized coordinates 0-1
  64769. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  64770. */
  64771. setViewport(viewport?: Viewport): void;
  64772. /**
  64773. * Binds the embedded attributes buffer to the effect.
  64774. * @param effect Defines the effect to bind the attributes for
  64775. */
  64776. bindBuffers(effect: Effect): void;
  64777. /**
  64778. * Sets the current effect wrapper to use during draw.
  64779. * The effect needs to be ready before calling this api.
  64780. * This also sets the default full screen position attribute.
  64781. * @param effectWrapper Defines the effect to draw with
  64782. */
  64783. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  64784. /**
  64785. * Restores engine states
  64786. */
  64787. restoreStates(): void;
  64788. /**
  64789. * Draws a full screen quad.
  64790. */
  64791. draw(): void;
  64792. private isRenderTargetTexture;
  64793. /**
  64794. * renders one or more effects to a specified texture
  64795. * @param effectWrapper the effect to renderer
  64796. * @param outputTexture texture to draw to, if null it will render to the screen.
  64797. */
  64798. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  64799. /**
  64800. * Disposes of the effect renderer
  64801. */
  64802. dispose(): void;
  64803. }
  64804. /**
  64805. * Options to create an EffectWrapper
  64806. */
  64807. interface EffectWrapperCreationOptions {
  64808. /**
  64809. * Engine to use to create the effect
  64810. */
  64811. engine: ThinEngine;
  64812. /**
  64813. * Fragment shader for the effect
  64814. */
  64815. fragmentShader: string;
  64816. /**
  64817. * Use the shader store instead of direct source code
  64818. */
  64819. useShaderStore?: boolean;
  64820. /**
  64821. * Vertex shader for the effect
  64822. */
  64823. vertexShader?: string;
  64824. /**
  64825. * Attributes to use in the shader
  64826. */
  64827. attributeNames?: Array<string>;
  64828. /**
  64829. * Uniforms to use in the shader
  64830. */
  64831. uniformNames?: Array<string>;
  64832. /**
  64833. * Texture sampler names to use in the shader
  64834. */
  64835. samplerNames?: Array<string>;
  64836. /**
  64837. * Defines to use in the shader
  64838. */
  64839. defines?: Array<string>;
  64840. /**
  64841. * Callback when effect is compiled
  64842. */
  64843. onCompiled?: Nullable<(effect: Effect) => void>;
  64844. /**
  64845. * The friendly name of the effect displayed in Spector.
  64846. */
  64847. name?: string;
  64848. }
  64849. /**
  64850. * Wraps an effect to be used for rendering
  64851. */
  64852. export class EffectWrapper {
  64853. /**
  64854. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  64855. */
  64856. onApplyObservable: Observable<{}>;
  64857. /**
  64858. * The underlying effect
  64859. */
  64860. effect: Effect;
  64861. /**
  64862. * Creates an effect to be renderer
  64863. * @param creationOptions options to create the effect
  64864. */
  64865. constructor(creationOptions: EffectWrapperCreationOptions);
  64866. /**
  64867. * Disposes of the effect wrapper
  64868. */
  64869. dispose(): void;
  64870. }
  64871. }
  64872. declare module BABYLON {
  64873. /** @hidden */
  64874. export var hdrFilteringVertexShader: {
  64875. name: string;
  64876. shader: string;
  64877. };
  64878. }
  64879. declare module BABYLON {
  64880. /** @hidden */
  64881. export var hdrFilteringPixelShader: {
  64882. name: string;
  64883. shader: string;
  64884. };
  64885. }
  64886. declare module BABYLON {
  64887. /**
  64888. * Options for texture filtering
  64889. */
  64890. interface IHDRFilteringOptions {
  64891. /**
  64892. * Scales pixel intensity for the input HDR map.
  64893. */
  64894. hdrScale?: number;
  64895. /**
  64896. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  64897. */
  64898. quality?: number;
  64899. }
  64900. /**
  64901. * Filters HDR maps to get correct renderings of PBR reflections
  64902. */
  64903. export class HDRFiltering {
  64904. private _engine;
  64905. private _effectRenderer;
  64906. private _effectWrapper;
  64907. private _lodGenerationOffset;
  64908. private _lodGenerationScale;
  64909. /**
  64910. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  64911. * you care about baking speed.
  64912. */
  64913. quality: number;
  64914. /**
  64915. * Scales pixel intensity for the input HDR map.
  64916. */
  64917. hdrScale: number;
  64918. /**
  64919. * Instantiates HDR filter for reflection maps
  64920. *
  64921. * @param engine Thin engine
  64922. * @param options Options
  64923. */
  64924. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  64925. private _createRenderTarget;
  64926. private _prefilterInternal;
  64927. private _createEffect;
  64928. /**
  64929. * Get a value indicating if the filter is ready to be used
  64930. * @param texture Texture to filter
  64931. * @returns true if the filter is ready
  64932. */
  64933. isReady(texture: BaseTexture): boolean;
  64934. /**
  64935. * Prefilters a cube texture to have mipmap levels representing roughness values.
  64936. * Prefiltering will be invoked at the end of next rendering pass.
  64937. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  64938. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  64939. * @param texture Texture to filter
  64940. * @param onFinished Callback when filtering is done
  64941. * @return Promise called when prefiltering is done
  64942. */
  64943. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<void>;
  64944. }
  64945. }
  64946. declare module BABYLON {
  64947. /**
  64948. * This represents a texture coming from an HDR input.
  64949. *
  64950. * The only supported format is currently panorama picture stored in RGBE format.
  64951. * Example of such files can be found on HDRLib: http://hdrlib.com/
  64952. */
  64953. export class HDRCubeTexture extends BaseTexture {
  64954. private static _facesMapping;
  64955. private _generateHarmonics;
  64956. private _noMipmap;
  64957. private _prefilterOnLoad;
  64958. private _textureMatrix;
  64959. private _size;
  64960. private _onLoad;
  64961. private _onError;
  64962. /**
  64963. * The texture URL.
  64964. */
  64965. url: string;
  64966. protected _isBlocking: boolean;
  64967. /**
  64968. * Sets wether or not the texture is blocking during loading.
  64969. */
  64970. set isBlocking(value: boolean);
  64971. /**
  64972. * Gets wether or not the texture is blocking during loading.
  64973. */
  64974. get isBlocking(): boolean;
  64975. protected _rotationY: number;
  64976. /**
  64977. * Sets texture matrix rotation angle around Y axis in radians.
  64978. */
  64979. set rotationY(value: number);
  64980. /**
  64981. * Gets texture matrix rotation angle around Y axis radians.
  64982. */
  64983. get rotationY(): number;
  64984. /**
  64985. * Gets or sets the center of the bounding box associated with the cube texture
  64986. * It must define where the camera used to render the texture was set
  64987. */
  64988. boundingBoxPosition: Vector3;
  64989. private _boundingBoxSize;
  64990. /**
  64991. * Gets or sets the size of the bounding box associated with the cube texture
  64992. * When defined, the cubemap will switch to local mode
  64993. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  64994. * @example https://www.babylonjs-playground.com/#RNASML
  64995. */
  64996. set boundingBoxSize(value: Vector3);
  64997. get boundingBoxSize(): Vector3;
  64998. /**
  64999. * Instantiates an HDRTexture from the following parameters.
  65000. *
  65001. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  65002. * @param sceneOrEngine The scene or engine the texture will be used in
  65003. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  65004. * @param noMipmap Forces to not generate the mipmap if true
  65005. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  65006. * @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)
  65007. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  65008. */
  65009. 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>);
  65010. /**
  65011. * Get the current class name of the texture useful for serialization or dynamic coding.
  65012. * @returns "HDRCubeTexture"
  65013. */
  65014. getClassName(): string;
  65015. /**
  65016. * Occurs when the file is raw .hdr file.
  65017. */
  65018. private loadTexture;
  65019. clone(): HDRCubeTexture;
  65020. delayLoad(): void;
  65021. /**
  65022. * Get the texture reflection matrix used to rotate/transform the reflection.
  65023. * @returns the reflection matrix
  65024. */
  65025. getReflectionTextureMatrix(): Matrix;
  65026. /**
  65027. * Set the texture reflection matrix used to rotate/transform the reflection.
  65028. * @param value Define the reflection matrix to set
  65029. */
  65030. setReflectionTextureMatrix(value: Matrix): void;
  65031. /**
  65032. * Parses a JSON representation of an HDR Texture in order to create the texture
  65033. * @param parsedTexture Define the JSON representation
  65034. * @param scene Define the scene the texture should be created in
  65035. * @param rootUrl Define the root url in case we need to load relative dependencies
  65036. * @returns the newly created texture after parsing
  65037. */
  65038. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  65039. serialize(): any;
  65040. }
  65041. }
  65042. declare module BABYLON {
  65043. /**
  65044. * Class used to control physics engine
  65045. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  65046. */
  65047. export class PhysicsEngine implements IPhysicsEngine {
  65048. private _physicsPlugin;
  65049. /**
  65050. * Global value used to control the smallest number supported by the simulation
  65051. */
  65052. static Epsilon: number;
  65053. private _impostors;
  65054. private _joints;
  65055. private _subTimeStep;
  65056. /**
  65057. * Gets the gravity vector used by the simulation
  65058. */
  65059. gravity: Vector3;
  65060. /**
  65061. * Factory used to create the default physics plugin.
  65062. * @returns The default physics plugin
  65063. */
  65064. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  65065. /**
  65066. * Creates a new Physics Engine
  65067. * @param gravity defines the gravity vector used by the simulation
  65068. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  65069. */
  65070. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  65071. /**
  65072. * Sets the gravity vector used by the simulation
  65073. * @param gravity defines the gravity vector to use
  65074. */
  65075. setGravity(gravity: Vector3): void;
  65076. /**
  65077. * Set the time step of the physics engine.
  65078. * Default is 1/60.
  65079. * To slow it down, enter 1/600 for example.
  65080. * To speed it up, 1/30
  65081. * @param newTimeStep defines the new timestep to apply to this world.
  65082. */
  65083. setTimeStep(newTimeStep?: number): void;
  65084. /**
  65085. * Get the time step of the physics engine.
  65086. * @returns the current time step
  65087. */
  65088. getTimeStep(): number;
  65089. /**
  65090. * Set the sub time step of the physics engine.
  65091. * Default is 0 meaning there is no sub steps
  65092. * To increase physics resolution precision, set a small value (like 1 ms)
  65093. * @param subTimeStep defines the new sub timestep used for physics resolution.
  65094. */
  65095. setSubTimeStep(subTimeStep?: number): void;
  65096. /**
  65097. * Get the sub time step of the physics engine.
  65098. * @returns the current sub time step
  65099. */
  65100. getSubTimeStep(): number;
  65101. /**
  65102. * Release all resources
  65103. */
  65104. dispose(): void;
  65105. /**
  65106. * Gets the name of the current physics plugin
  65107. * @returns the name of the plugin
  65108. */
  65109. getPhysicsPluginName(): string;
  65110. /**
  65111. * Adding a new impostor for the impostor tracking.
  65112. * This will be done by the impostor itself.
  65113. * @param impostor the impostor to add
  65114. */
  65115. addImpostor(impostor: PhysicsImpostor): void;
  65116. /**
  65117. * Remove an impostor from the engine.
  65118. * This impostor and its mesh will not longer be updated by the physics engine.
  65119. * @param impostor the impostor to remove
  65120. */
  65121. removeImpostor(impostor: PhysicsImpostor): void;
  65122. /**
  65123. * Add a joint to the physics engine
  65124. * @param mainImpostor defines the main impostor to which the joint is added.
  65125. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  65126. * @param joint defines the joint that will connect both impostors.
  65127. */
  65128. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  65129. /**
  65130. * Removes a joint from the simulation
  65131. * @param mainImpostor defines the impostor used with the joint
  65132. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  65133. * @param joint defines the joint to remove
  65134. */
  65135. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  65136. /**
  65137. * Called by the scene. No need to call it.
  65138. * @param delta defines the timespam between frames
  65139. */
  65140. _step(delta: number): void;
  65141. /**
  65142. * Gets the current plugin used to run the simulation
  65143. * @returns current plugin
  65144. */
  65145. getPhysicsPlugin(): IPhysicsEnginePlugin;
  65146. /**
  65147. * Gets the list of physic impostors
  65148. * @returns an array of PhysicsImpostor
  65149. */
  65150. getImpostors(): Array<PhysicsImpostor>;
  65151. /**
  65152. * Gets the impostor for a physics enabled object
  65153. * @param object defines the object impersonated by the impostor
  65154. * @returns the PhysicsImpostor or null if not found
  65155. */
  65156. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  65157. /**
  65158. * Gets the impostor for a physics body object
  65159. * @param body defines physics body used by the impostor
  65160. * @returns the PhysicsImpostor or null if not found
  65161. */
  65162. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  65163. /**
  65164. * Does a raycast in the physics world
  65165. * @param from when should the ray start?
  65166. * @param to when should the ray end?
  65167. * @returns PhysicsRaycastResult
  65168. */
  65169. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  65170. }
  65171. }
  65172. declare module BABYLON {
  65173. /** @hidden */
  65174. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  65175. private _useDeltaForWorldStep;
  65176. world: any;
  65177. name: string;
  65178. private _physicsMaterials;
  65179. private _fixedTimeStep;
  65180. private _cannonRaycastResult;
  65181. private _raycastResult;
  65182. private _physicsBodysToRemoveAfterStep;
  65183. private _firstFrame;
  65184. BJSCANNON: any;
  65185. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  65186. setGravity(gravity: Vector3): void;
  65187. setTimeStep(timeStep: number): void;
  65188. getTimeStep(): number;
  65189. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  65190. private _removeMarkedPhysicsBodiesFromWorld;
  65191. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  65192. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  65193. generatePhysicsBody(impostor: PhysicsImpostor): void;
  65194. private _processChildMeshes;
  65195. removePhysicsBody(impostor: PhysicsImpostor): void;
  65196. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  65197. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  65198. private _addMaterial;
  65199. private _checkWithEpsilon;
  65200. private _createShape;
  65201. private _createHeightmap;
  65202. private _minus90X;
  65203. private _plus90X;
  65204. private _tmpPosition;
  65205. private _tmpDeltaPosition;
  65206. private _tmpUnityRotation;
  65207. private _updatePhysicsBodyTransformation;
  65208. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  65209. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  65210. isSupported(): boolean;
  65211. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  65212. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  65213. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  65214. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  65215. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  65216. getBodyMass(impostor: PhysicsImpostor): number;
  65217. getBodyFriction(impostor: PhysicsImpostor): number;
  65218. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  65219. getBodyRestitution(impostor: PhysicsImpostor): number;
  65220. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  65221. sleepBody(impostor: PhysicsImpostor): void;
  65222. wakeUpBody(impostor: PhysicsImpostor): void;
  65223. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  65224. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  65225. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  65226. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  65227. getRadius(impostor: PhysicsImpostor): number;
  65228. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  65229. dispose(): void;
  65230. private _extendNamespace;
  65231. /**
  65232. * Does a raycast in the physics world
  65233. * @param from when should the ray start?
  65234. * @param to when should the ray end?
  65235. * @returns PhysicsRaycastResult
  65236. */
  65237. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  65238. }
  65239. }
  65240. declare module BABYLON {
  65241. /** @hidden */
  65242. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  65243. private _useDeltaForWorldStep;
  65244. world: any;
  65245. name: string;
  65246. BJSOIMO: any;
  65247. private _raycastResult;
  65248. private _fixedTimeStep;
  65249. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  65250. setGravity(gravity: Vector3): void;
  65251. setTimeStep(timeStep: number): void;
  65252. getTimeStep(): number;
  65253. private _tmpImpostorsArray;
  65254. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  65255. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  65256. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  65257. generatePhysicsBody(impostor: PhysicsImpostor): void;
  65258. private _tmpPositionVector;
  65259. removePhysicsBody(impostor: PhysicsImpostor): void;
  65260. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  65261. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  65262. isSupported(): boolean;
  65263. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  65264. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  65265. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  65266. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  65267. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  65268. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  65269. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  65270. getBodyMass(impostor: PhysicsImpostor): number;
  65271. getBodyFriction(impostor: PhysicsImpostor): number;
  65272. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  65273. getBodyRestitution(impostor: PhysicsImpostor): number;
  65274. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  65275. sleepBody(impostor: PhysicsImpostor): void;
  65276. wakeUpBody(impostor: PhysicsImpostor): void;
  65277. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  65278. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  65279. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  65280. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  65281. getRadius(impostor: PhysicsImpostor): number;
  65282. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  65283. dispose(): void;
  65284. /**
  65285. * Does a raycast in the physics world
  65286. * @param from when should the ray start?
  65287. * @param to when should the ray end?
  65288. * @returns PhysicsRaycastResult
  65289. */
  65290. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  65291. }
  65292. }
  65293. declare module BABYLON {
  65294. /**
  65295. * AmmoJS Physics plugin
  65296. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  65297. * @see https://github.com/kripken/ammo.js/
  65298. */
  65299. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  65300. private _useDeltaForWorldStep;
  65301. /**
  65302. * Reference to the Ammo library
  65303. */
  65304. bjsAMMO: any;
  65305. /**
  65306. * Created ammoJS world which physics bodies are added to
  65307. */
  65308. world: any;
  65309. /**
  65310. * Name of the plugin
  65311. */
  65312. name: string;
  65313. private _timeStep;
  65314. private _fixedTimeStep;
  65315. private _maxSteps;
  65316. private _tmpQuaternion;
  65317. private _tmpAmmoTransform;
  65318. private _tmpAmmoQuaternion;
  65319. private _tmpAmmoConcreteContactResultCallback;
  65320. private _collisionConfiguration;
  65321. private _dispatcher;
  65322. private _overlappingPairCache;
  65323. private _solver;
  65324. private _softBodySolver;
  65325. private _tmpAmmoVectorA;
  65326. private _tmpAmmoVectorB;
  65327. private _tmpAmmoVectorC;
  65328. private _tmpAmmoVectorD;
  65329. private _tmpContactCallbackResult;
  65330. private _tmpAmmoVectorRCA;
  65331. private _tmpAmmoVectorRCB;
  65332. private _raycastResult;
  65333. private _tmpContactPoint;
  65334. private static readonly DISABLE_COLLISION_FLAG;
  65335. private static readonly KINEMATIC_FLAG;
  65336. private static readonly DISABLE_DEACTIVATION_FLAG;
  65337. /**
  65338. * Initializes the ammoJS plugin
  65339. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  65340. * @param ammoInjection can be used to inject your own ammo reference
  65341. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  65342. */
  65343. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  65344. /**
  65345. * Sets the gravity of the physics world (m/(s^2))
  65346. * @param gravity Gravity to set
  65347. */
  65348. setGravity(gravity: Vector3): void;
  65349. /**
  65350. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  65351. * @param timeStep timestep to use in seconds
  65352. */
  65353. setTimeStep(timeStep: number): void;
  65354. /**
  65355. * 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)
  65356. * @param fixedTimeStep fixedTimeStep to use in seconds
  65357. */
  65358. setFixedTimeStep(fixedTimeStep: number): void;
  65359. /**
  65360. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  65361. * @param maxSteps the maximum number of steps by the physics engine per frame
  65362. */
  65363. setMaxSteps(maxSteps: number): void;
  65364. /**
  65365. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  65366. * @returns the current timestep in seconds
  65367. */
  65368. getTimeStep(): number;
  65369. /**
  65370. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  65371. */
  65372. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  65373. private _isImpostorInContact;
  65374. private _isImpostorPairInContact;
  65375. private _stepSimulation;
  65376. /**
  65377. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  65378. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  65379. * After the step the babylon meshes are set to the position of the physics imposters
  65380. * @param delta amount of time to step forward
  65381. * @param impostors array of imposters to update before/after the step
  65382. */
  65383. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  65384. /**
  65385. * Update babylon mesh to match physics world object
  65386. * @param impostor imposter to match
  65387. */
  65388. private _afterSoftStep;
  65389. /**
  65390. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  65391. * @param impostor imposter to match
  65392. */
  65393. private _ropeStep;
  65394. /**
  65395. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  65396. * @param impostor imposter to match
  65397. */
  65398. private _softbodyOrClothStep;
  65399. private _tmpMatrix;
  65400. /**
  65401. * Applies an impulse on the imposter
  65402. * @param impostor imposter to apply impulse to
  65403. * @param force amount of force to be applied to the imposter
  65404. * @param contactPoint the location to apply the impulse on the imposter
  65405. */
  65406. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  65407. /**
  65408. * Applies a force on the imposter
  65409. * @param impostor imposter to apply force
  65410. * @param force amount of force to be applied to the imposter
  65411. * @param contactPoint the location to apply the force on the imposter
  65412. */
  65413. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  65414. /**
  65415. * Creates a physics body using the plugin
  65416. * @param impostor the imposter to create the physics body on
  65417. */
  65418. generatePhysicsBody(impostor: PhysicsImpostor): void;
  65419. /**
  65420. * Removes the physics body from the imposter and disposes of the body's memory
  65421. * @param impostor imposter to remove the physics body from
  65422. */
  65423. removePhysicsBody(impostor: PhysicsImpostor): void;
  65424. /**
  65425. * Generates a joint
  65426. * @param impostorJoint the imposter joint to create the joint with
  65427. */
  65428. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  65429. /**
  65430. * Removes a joint
  65431. * @param impostorJoint the imposter joint to remove the joint from
  65432. */
  65433. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  65434. private _addMeshVerts;
  65435. /**
  65436. * Initialise the soft body vertices to match its object's (mesh) vertices
  65437. * Softbody vertices (nodes) are in world space and to match this
  65438. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  65439. * @param impostor to create the softbody for
  65440. */
  65441. private _softVertexData;
  65442. /**
  65443. * Create an impostor's soft body
  65444. * @param impostor to create the softbody for
  65445. */
  65446. private _createSoftbody;
  65447. /**
  65448. * Create cloth for an impostor
  65449. * @param impostor to create the softbody for
  65450. */
  65451. private _createCloth;
  65452. /**
  65453. * Create rope for an impostor
  65454. * @param impostor to create the softbody for
  65455. */
  65456. private _createRope;
  65457. /**
  65458. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  65459. * @param impostor to create the custom physics shape for
  65460. */
  65461. private _createCustom;
  65462. private _addHullVerts;
  65463. private _createShape;
  65464. /**
  65465. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  65466. * @param impostor imposter containing the physics body and babylon object
  65467. */
  65468. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  65469. /**
  65470. * Sets the babylon object's position/rotation from the physics body's position/rotation
  65471. * @param impostor imposter containing the physics body and babylon object
  65472. * @param newPosition new position
  65473. * @param newRotation new rotation
  65474. */
  65475. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  65476. /**
  65477. * If this plugin is supported
  65478. * @returns true if its supported
  65479. */
  65480. isSupported(): boolean;
  65481. /**
  65482. * Sets the linear velocity of the physics body
  65483. * @param impostor imposter to set the velocity on
  65484. * @param velocity velocity to set
  65485. */
  65486. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  65487. /**
  65488. * Sets the angular velocity of the physics body
  65489. * @param impostor imposter to set the velocity on
  65490. * @param velocity velocity to set
  65491. */
  65492. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  65493. /**
  65494. * gets the linear velocity
  65495. * @param impostor imposter to get linear velocity from
  65496. * @returns linear velocity
  65497. */
  65498. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  65499. /**
  65500. * gets the angular velocity
  65501. * @param impostor imposter to get angular velocity from
  65502. * @returns angular velocity
  65503. */
  65504. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  65505. /**
  65506. * Sets the mass of physics body
  65507. * @param impostor imposter to set the mass on
  65508. * @param mass mass to set
  65509. */
  65510. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  65511. /**
  65512. * Gets the mass of the physics body
  65513. * @param impostor imposter to get the mass from
  65514. * @returns mass
  65515. */
  65516. getBodyMass(impostor: PhysicsImpostor): number;
  65517. /**
  65518. * Gets friction of the impostor
  65519. * @param impostor impostor to get friction from
  65520. * @returns friction value
  65521. */
  65522. getBodyFriction(impostor: PhysicsImpostor): number;
  65523. /**
  65524. * Sets friction of the impostor
  65525. * @param impostor impostor to set friction on
  65526. * @param friction friction value
  65527. */
  65528. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  65529. /**
  65530. * Gets restitution of the impostor
  65531. * @param impostor impostor to get restitution from
  65532. * @returns restitution value
  65533. */
  65534. getBodyRestitution(impostor: PhysicsImpostor): number;
  65535. /**
  65536. * Sets resitution of the impostor
  65537. * @param impostor impostor to set resitution on
  65538. * @param restitution resitution value
  65539. */
  65540. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  65541. /**
  65542. * Gets pressure inside the impostor
  65543. * @param impostor impostor to get pressure from
  65544. * @returns pressure value
  65545. */
  65546. getBodyPressure(impostor: PhysicsImpostor): number;
  65547. /**
  65548. * Sets pressure inside a soft body impostor
  65549. * Cloth and rope must remain 0 pressure
  65550. * @param impostor impostor to set pressure on
  65551. * @param pressure pressure value
  65552. */
  65553. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  65554. /**
  65555. * Gets stiffness of the impostor
  65556. * @param impostor impostor to get stiffness from
  65557. * @returns pressure value
  65558. */
  65559. getBodyStiffness(impostor: PhysicsImpostor): number;
  65560. /**
  65561. * Sets stiffness of the impostor
  65562. * @param impostor impostor to set stiffness on
  65563. * @param stiffness stiffness value from 0 to 1
  65564. */
  65565. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  65566. /**
  65567. * Gets velocityIterations of the impostor
  65568. * @param impostor impostor to get velocity iterations from
  65569. * @returns velocityIterations value
  65570. */
  65571. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  65572. /**
  65573. * Sets velocityIterations of the impostor
  65574. * @param impostor impostor to set velocity iterations on
  65575. * @param velocityIterations velocityIterations value
  65576. */
  65577. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  65578. /**
  65579. * Gets positionIterations of the impostor
  65580. * @param impostor impostor to get position iterations from
  65581. * @returns positionIterations value
  65582. */
  65583. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  65584. /**
  65585. * Sets positionIterations of the impostor
  65586. * @param impostor impostor to set position on
  65587. * @param positionIterations positionIterations value
  65588. */
  65589. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  65590. /**
  65591. * Append an anchor to a cloth object
  65592. * @param impostor is the cloth impostor to add anchor to
  65593. * @param otherImpostor is the rigid impostor to anchor to
  65594. * @param width ratio across width from 0 to 1
  65595. * @param height ratio up height from 0 to 1
  65596. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  65597. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  65598. */
  65599. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  65600. /**
  65601. * Append an hook to a rope object
  65602. * @param impostor is the rope impostor to add hook to
  65603. * @param otherImpostor is the rigid impostor to hook to
  65604. * @param length ratio along the rope from 0 to 1
  65605. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  65606. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  65607. */
  65608. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  65609. /**
  65610. * Sleeps the physics body and stops it from being active
  65611. * @param impostor impostor to sleep
  65612. */
  65613. sleepBody(impostor: PhysicsImpostor): void;
  65614. /**
  65615. * Activates the physics body
  65616. * @param impostor impostor to activate
  65617. */
  65618. wakeUpBody(impostor: PhysicsImpostor): void;
  65619. /**
  65620. * Updates the distance parameters of the joint
  65621. * @param joint joint to update
  65622. * @param maxDistance maximum distance of the joint
  65623. * @param minDistance minimum distance of the joint
  65624. */
  65625. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  65626. /**
  65627. * Sets a motor on the joint
  65628. * @param joint joint to set motor on
  65629. * @param speed speed of the motor
  65630. * @param maxForce maximum force of the motor
  65631. * @param motorIndex index of the motor
  65632. */
  65633. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  65634. /**
  65635. * Sets the motors limit
  65636. * @param joint joint to set limit on
  65637. * @param upperLimit upper limit
  65638. * @param lowerLimit lower limit
  65639. */
  65640. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  65641. /**
  65642. * Syncs the position and rotation of a mesh with the impostor
  65643. * @param mesh mesh to sync
  65644. * @param impostor impostor to update the mesh with
  65645. */
  65646. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  65647. /**
  65648. * Gets the radius of the impostor
  65649. * @param impostor impostor to get radius from
  65650. * @returns the radius
  65651. */
  65652. getRadius(impostor: PhysicsImpostor): number;
  65653. /**
  65654. * Gets the box size of the impostor
  65655. * @param impostor impostor to get box size from
  65656. * @param result the resulting box size
  65657. */
  65658. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  65659. /**
  65660. * Disposes of the impostor
  65661. */
  65662. dispose(): void;
  65663. /**
  65664. * Does a raycast in the physics world
  65665. * @param from when should the ray start?
  65666. * @param to when should the ray end?
  65667. * @returns PhysicsRaycastResult
  65668. */
  65669. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  65670. }
  65671. }
  65672. declare module BABYLON {
  65673. interface AbstractScene {
  65674. /**
  65675. * The list of reflection probes added to the scene
  65676. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  65677. */
  65678. reflectionProbes: Array<ReflectionProbe>;
  65679. /**
  65680. * Removes the given reflection probe from this scene.
  65681. * @param toRemove The reflection probe to remove
  65682. * @returns The index of the removed reflection probe
  65683. */
  65684. removeReflectionProbe(toRemove: ReflectionProbe): number;
  65685. /**
  65686. * Adds the given reflection probe to this scene.
  65687. * @param newReflectionProbe The reflection probe to add
  65688. */
  65689. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  65690. }
  65691. /**
  65692. * Class used to generate realtime reflection / refraction cube textures
  65693. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  65694. */
  65695. export class ReflectionProbe {
  65696. /** defines the name of the probe */
  65697. name: string;
  65698. private _scene;
  65699. private _renderTargetTexture;
  65700. private _projectionMatrix;
  65701. private _viewMatrix;
  65702. private _target;
  65703. private _add;
  65704. private _attachedMesh;
  65705. private _invertYAxis;
  65706. /** Gets or sets probe position (center of the cube map) */
  65707. position: Vector3;
  65708. /**
  65709. * Creates a new reflection probe
  65710. * @param name defines the name of the probe
  65711. * @param size defines the texture resolution (for each face)
  65712. * @param scene defines the hosting scene
  65713. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  65714. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  65715. */
  65716. constructor(
  65717. /** defines the name of the probe */
  65718. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  65719. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  65720. get samples(): number;
  65721. set samples(value: number);
  65722. /** Gets or sets the refresh rate to use (on every frame by default) */
  65723. get refreshRate(): number;
  65724. set refreshRate(value: number);
  65725. /**
  65726. * Gets the hosting scene
  65727. * @returns a Scene
  65728. */
  65729. getScene(): Scene;
  65730. /** Gets the internal CubeTexture used to render to */
  65731. get cubeTexture(): RenderTargetTexture;
  65732. /** Gets the list of meshes to render */
  65733. get renderList(): Nullable<AbstractMesh[]>;
  65734. /**
  65735. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  65736. * @param mesh defines the mesh to attach to
  65737. */
  65738. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  65739. /**
  65740. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  65741. * @param renderingGroupId The rendering group id corresponding to its index
  65742. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  65743. */
  65744. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  65745. /**
  65746. * Clean all associated resources
  65747. */
  65748. dispose(): void;
  65749. /**
  65750. * Converts the reflection probe information to a readable string for debug purpose.
  65751. * @param fullDetails Supports for multiple levels of logging within scene loading
  65752. * @returns the human readable reflection probe info
  65753. */
  65754. toString(fullDetails?: boolean): string;
  65755. /**
  65756. * Get the class name of the relfection probe.
  65757. * @returns "ReflectionProbe"
  65758. */
  65759. getClassName(): string;
  65760. /**
  65761. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  65762. * @returns The JSON representation of the texture
  65763. */
  65764. serialize(): any;
  65765. /**
  65766. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  65767. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  65768. * @param scene Define the scene the parsed reflection probe should be instantiated in
  65769. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  65770. * @returns The parsed reflection probe if successful
  65771. */
  65772. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  65773. }
  65774. }
  65775. declare module BABYLON {
  65776. /** @hidden */
  65777. export var _BabylonLoaderRegistered: boolean;
  65778. /**
  65779. * Helps setting up some configuration for the babylon file loader.
  65780. */
  65781. export class BabylonFileLoaderConfiguration {
  65782. /**
  65783. * The loader does not allow injecting custom physix engine into the plugins.
  65784. * Unfortunately in ES6, we need to manually inject them into the plugin.
  65785. * So you could set this variable to your engine import to make it work.
  65786. */
  65787. static LoaderInjectedPhysicsEngine: any;
  65788. }
  65789. }
  65790. declare module BABYLON {
  65791. /**
  65792. * A material to use for fast depth-only rendering.
  65793. */
  65794. export class OcclusionMaterial extends ShaderMaterial {
  65795. constructor(name: string, scene: Scene);
  65796. }
  65797. }
  65798. declare module BABYLON {
  65799. /**
  65800. * The Physically based simple base material of BJS.
  65801. *
  65802. * This enables better naming and convention enforcements on top of the pbrMaterial.
  65803. * It is used as the base class for both the specGloss and metalRough conventions.
  65804. */
  65805. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  65806. /**
  65807. * Number of Simultaneous lights allowed on the material.
  65808. */
  65809. maxSimultaneousLights: number;
  65810. /**
  65811. * If sets to true, disables all the lights affecting the material.
  65812. */
  65813. disableLighting: boolean;
  65814. /**
  65815. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  65816. */
  65817. environmentTexture: BaseTexture;
  65818. /**
  65819. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  65820. */
  65821. invertNormalMapX: boolean;
  65822. /**
  65823. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  65824. */
  65825. invertNormalMapY: boolean;
  65826. /**
  65827. * Normal map used in the model.
  65828. */
  65829. normalTexture: BaseTexture;
  65830. /**
  65831. * Emissivie color used to self-illuminate the model.
  65832. */
  65833. emissiveColor: Color3;
  65834. /**
  65835. * Emissivie texture used to self-illuminate the model.
  65836. */
  65837. emissiveTexture: BaseTexture;
  65838. /**
  65839. * Occlusion Channel Strenght.
  65840. */
  65841. occlusionStrength: number;
  65842. /**
  65843. * Occlusion Texture of the material (adding extra occlusion effects).
  65844. */
  65845. occlusionTexture: BaseTexture;
  65846. /**
  65847. * Defines the alpha limits in alpha test mode.
  65848. */
  65849. alphaCutOff: number;
  65850. /**
  65851. * Gets the current double sided mode.
  65852. */
  65853. get doubleSided(): boolean;
  65854. /**
  65855. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  65856. */
  65857. set doubleSided(value: boolean);
  65858. /**
  65859. * Stores the pre-calculated light information of a mesh in a texture.
  65860. */
  65861. lightmapTexture: BaseTexture;
  65862. /**
  65863. * If true, the light map contains occlusion information instead of lighting info.
  65864. */
  65865. useLightmapAsShadowmap: boolean;
  65866. /**
  65867. * Instantiates a new PBRMaterial instance.
  65868. *
  65869. * @param name The material name
  65870. * @param scene The scene the material will be use in.
  65871. */
  65872. constructor(name: string, scene: Scene);
  65873. getClassName(): string;
  65874. }
  65875. }
  65876. declare module BABYLON {
  65877. /**
  65878. * The PBR material of BJS following the metal roughness convention.
  65879. *
  65880. * This fits to the PBR convention in the GLTF definition:
  65881. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  65882. */
  65883. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  65884. /**
  65885. * The base color has two different interpretations depending on the value of metalness.
  65886. * When the material is a metal, the base color is the specific measured reflectance value
  65887. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  65888. * of the material.
  65889. */
  65890. baseColor: Color3;
  65891. /**
  65892. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  65893. * well as opacity information in the alpha channel.
  65894. */
  65895. baseTexture: BaseTexture;
  65896. /**
  65897. * Specifies the metallic scalar value of the material.
  65898. * Can also be used to scale the metalness values of the metallic texture.
  65899. */
  65900. metallic: number;
  65901. /**
  65902. * Specifies the roughness scalar value of the material.
  65903. * Can also be used to scale the roughness values of the metallic texture.
  65904. */
  65905. roughness: number;
  65906. /**
  65907. * Texture containing both the metallic value in the B channel and the
  65908. * roughness value in the G channel to keep better precision.
  65909. */
  65910. metallicRoughnessTexture: BaseTexture;
  65911. /**
  65912. * Instantiates a new PBRMetalRoughnessMaterial instance.
  65913. *
  65914. * @param name The material name
  65915. * @param scene The scene the material will be use in.
  65916. */
  65917. constructor(name: string, scene: Scene);
  65918. /**
  65919. * Return the currrent class name of the material.
  65920. */
  65921. getClassName(): string;
  65922. /**
  65923. * Makes a duplicate of the current material.
  65924. * @param name - name to use for the new material.
  65925. */
  65926. clone(name: string): PBRMetallicRoughnessMaterial;
  65927. /**
  65928. * Serialize the material to a parsable JSON object.
  65929. */
  65930. serialize(): any;
  65931. /**
  65932. * Parses a JSON object correponding to the serialize function.
  65933. */
  65934. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  65935. }
  65936. }
  65937. declare module BABYLON {
  65938. /**
  65939. * The PBR material of BJS following the specular glossiness convention.
  65940. *
  65941. * This fits to the PBR convention in the GLTF definition:
  65942. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  65943. */
  65944. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  65945. /**
  65946. * Specifies the diffuse color of the material.
  65947. */
  65948. diffuseColor: Color3;
  65949. /**
  65950. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  65951. * channel.
  65952. */
  65953. diffuseTexture: BaseTexture;
  65954. /**
  65955. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  65956. */
  65957. specularColor: Color3;
  65958. /**
  65959. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  65960. */
  65961. glossiness: number;
  65962. /**
  65963. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  65964. */
  65965. specularGlossinessTexture: BaseTexture;
  65966. /**
  65967. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  65968. */
  65969. get useMicroSurfaceFromReflectivityMapAlpha(): boolean;
  65970. /**
  65971. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  65972. *
  65973. * @param name The material name
  65974. * @param scene The scene the material will be use in.
  65975. */
  65976. constructor(name: string, scene: Scene);
  65977. /**
  65978. * Return the currrent class name of the material.
  65979. */
  65980. getClassName(): string;
  65981. /**
  65982. * Makes a duplicate of the current material.
  65983. * @param name - name to use for the new material.
  65984. */
  65985. clone(name: string): PBRSpecularGlossinessMaterial;
  65986. /**
  65987. * Serialize the material to a parsable JSON object.
  65988. */
  65989. serialize(): any;
  65990. /**
  65991. * Parses a JSON object correponding to the serialize function.
  65992. */
  65993. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  65994. }
  65995. }
  65996. declare module BABYLON {
  65997. /**
  65998. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  65999. * It can help converting any input color in a desired output one. This can then be used to create effects
  66000. * from sepia, black and white to sixties or futuristic rendering...
  66001. *
  66002. * The only supported format is currently 3dl.
  66003. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  66004. */
  66005. export class ColorGradingTexture extends BaseTexture {
  66006. /**
  66007. * The texture URL.
  66008. */
  66009. url: string;
  66010. /**
  66011. * Empty line regex stored for GC.
  66012. */
  66013. private static _noneEmptyLineRegex;
  66014. private _textureMatrix;
  66015. private _onLoad;
  66016. /**
  66017. * Instantiates a ColorGradingTexture from the following parameters.
  66018. *
  66019. * @param url The location of the color gradind data (currently only supporting 3dl)
  66020. * @param sceneOrEngine The scene or engine the texture will be used in
  66021. * @param onLoad defines a callback triggered when the texture has been loaded
  66022. */
  66023. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  66024. /**
  66025. * Fires the onload event from the constructor if requested.
  66026. */
  66027. private _triggerOnLoad;
  66028. /**
  66029. * Returns the texture matrix used in most of the material.
  66030. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  66031. */
  66032. getTextureMatrix(): Matrix;
  66033. /**
  66034. * Occurs when the file being loaded is a .3dl LUT file.
  66035. */
  66036. private load3dlTexture;
  66037. /**
  66038. * Starts the loading process of the texture.
  66039. */
  66040. private loadTexture;
  66041. /**
  66042. * Clones the color gradind texture.
  66043. */
  66044. clone(): ColorGradingTexture;
  66045. /**
  66046. * Called during delayed load for textures.
  66047. */
  66048. delayLoad(): void;
  66049. /**
  66050. * Parses a color grading texture serialized by Babylon.
  66051. * @param parsedTexture The texture information being parsedTexture
  66052. * @param scene The scene to load the texture in
  66053. * @param rootUrl The root url of the data assets to load
  66054. * @return A color gradind texture
  66055. */
  66056. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  66057. /**
  66058. * Serializes the LUT texture to json format.
  66059. */
  66060. serialize(): any;
  66061. }
  66062. }
  66063. declare module BABYLON {
  66064. /**
  66065. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  66066. */
  66067. export class EquiRectangularCubeTexture extends BaseTexture {
  66068. /** The six faces of the cube. */
  66069. private static _FacesMapping;
  66070. private _noMipmap;
  66071. private _onLoad;
  66072. private _onError;
  66073. /** The size of the cubemap. */
  66074. private _size;
  66075. /** The buffer of the image. */
  66076. private _buffer;
  66077. /** The width of the input image. */
  66078. private _width;
  66079. /** The height of the input image. */
  66080. private _height;
  66081. /** The URL to the image. */
  66082. url: string;
  66083. /**
  66084. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  66085. * @param url The location of the image
  66086. * @param scene The scene the texture will be used in
  66087. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  66088. * @param noMipmap Forces to not generate the mipmap if true
  66089. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  66090. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  66091. * @param onLoad — defines a callback called when texture is loaded
  66092. * @param onError — defines a callback called if there is an error
  66093. */
  66094. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  66095. /**
  66096. * Load the image data, by putting the image on a canvas and extracting its buffer.
  66097. */
  66098. private loadImage;
  66099. /**
  66100. * Convert the image buffer into a cubemap and create a CubeTexture.
  66101. */
  66102. private loadTexture;
  66103. /**
  66104. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  66105. * @param buffer The ArrayBuffer that should be converted.
  66106. * @returns The buffer as Float32Array.
  66107. */
  66108. private getFloat32ArrayFromArrayBuffer;
  66109. /**
  66110. * Get the current class name of the texture useful for serialization or dynamic coding.
  66111. * @returns "EquiRectangularCubeTexture"
  66112. */
  66113. getClassName(): string;
  66114. /**
  66115. * Create a clone of the current EquiRectangularCubeTexture and return it.
  66116. * @returns A clone of the current EquiRectangularCubeTexture.
  66117. */
  66118. clone(): EquiRectangularCubeTexture;
  66119. }
  66120. }
  66121. declare module BABYLON {
  66122. /**
  66123. * Defines the options related to the creation of an HtmlElementTexture
  66124. */
  66125. export interface IHtmlElementTextureOptions {
  66126. /**
  66127. * Defines wether mip maps should be created or not.
  66128. */
  66129. generateMipMaps?: boolean;
  66130. /**
  66131. * Defines the sampling mode of the texture.
  66132. */
  66133. samplingMode?: number;
  66134. /**
  66135. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  66136. */
  66137. engine: Nullable<ThinEngine>;
  66138. /**
  66139. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  66140. */
  66141. scene: Nullable<Scene>;
  66142. }
  66143. /**
  66144. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  66145. * To be as efficient as possible depending on your constraints nothing aside the first upload
  66146. * is automatically managed.
  66147. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  66148. * in your application.
  66149. *
  66150. * As the update is not automatic, you need to call them manually.
  66151. */
  66152. export class HtmlElementTexture extends BaseTexture {
  66153. /**
  66154. * The texture URL.
  66155. */
  66156. element: HTMLVideoElement | HTMLCanvasElement;
  66157. private static readonly DefaultOptions;
  66158. private _textureMatrix;
  66159. private _isVideo;
  66160. private _generateMipMaps;
  66161. private _samplingMode;
  66162. /**
  66163. * Instantiates a HtmlElementTexture from the following parameters.
  66164. *
  66165. * @param name Defines the name of the texture
  66166. * @param element Defines the video or canvas the texture is filled with
  66167. * @param options Defines the other none mandatory texture creation options
  66168. */
  66169. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  66170. private _createInternalTexture;
  66171. /**
  66172. * Returns the texture matrix used in most of the material.
  66173. */
  66174. getTextureMatrix(): Matrix;
  66175. /**
  66176. * Updates the content of the texture.
  66177. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  66178. */
  66179. update(invertY?: Nullable<boolean>): void;
  66180. }
  66181. }
  66182. declare module BABYLON {
  66183. /**
  66184. * Based on jsTGALoader - Javascript loader for TGA file
  66185. * By Vincent Thibault
  66186. * @see http://blog.robrowser.com/javascript-tga-loader.html
  66187. */
  66188. export class TGATools {
  66189. private static _TYPE_INDEXED;
  66190. private static _TYPE_RGB;
  66191. private static _TYPE_GREY;
  66192. private static _TYPE_RLE_INDEXED;
  66193. private static _TYPE_RLE_RGB;
  66194. private static _TYPE_RLE_GREY;
  66195. private static _ORIGIN_MASK;
  66196. private static _ORIGIN_SHIFT;
  66197. private static _ORIGIN_BL;
  66198. private static _ORIGIN_BR;
  66199. private static _ORIGIN_UL;
  66200. private static _ORIGIN_UR;
  66201. /**
  66202. * Gets the header of a TGA file
  66203. * @param data defines the TGA data
  66204. * @returns the header
  66205. */
  66206. static GetTGAHeader(data: Uint8Array): any;
  66207. /**
  66208. * Uploads TGA content to a Babylon Texture
  66209. * @hidden
  66210. */
  66211. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  66212. /** @hidden */
  66213. 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;
  66214. /** @hidden */
  66215. 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;
  66216. /** @hidden */
  66217. 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;
  66218. /** @hidden */
  66219. 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;
  66220. /** @hidden */
  66221. 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;
  66222. /** @hidden */
  66223. 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;
  66224. }
  66225. }
  66226. declare module BABYLON {
  66227. /**
  66228. * Implementation of the TGA Texture Loader.
  66229. * @hidden
  66230. */
  66231. export class _TGATextureLoader implements IInternalTextureLoader {
  66232. /**
  66233. * Defines wether the loader supports cascade loading the different faces.
  66234. */
  66235. readonly supportCascades: boolean;
  66236. /**
  66237. * This returns if the loader support the current file information.
  66238. * @param extension defines the file extension of the file being loaded
  66239. * @returns true if the loader can load the specified file
  66240. */
  66241. canLoad(extension: string): boolean;
  66242. /**
  66243. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  66244. * @param data contains the texture data
  66245. * @param texture defines the BabylonJS internal texture
  66246. * @param createPolynomials will be true if polynomials have been requested
  66247. * @param onLoad defines the callback to trigger once the texture is ready
  66248. * @param onError defines the callback to trigger in case of error
  66249. */
  66250. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  66251. /**
  66252. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  66253. * @param data contains the texture data
  66254. * @param texture defines the BabylonJS internal texture
  66255. * @param callback defines the method to call once ready to upload
  66256. */
  66257. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  66258. }
  66259. }
  66260. declare module BABYLON {
  66261. /**
  66262. * Implementation of the HDR Texture Loader.
  66263. * @hidden
  66264. */
  66265. export class _HDRTextureLoader implements IInternalTextureLoader {
  66266. /**
  66267. * Defines wether the loader supports cascade loading the different faces.
  66268. */
  66269. readonly supportCascades: boolean;
  66270. /**
  66271. * This returns if the loader support the current file information.
  66272. * @param extension defines the file extension of the file being loaded
  66273. * @returns true if the loader can load the specified file
  66274. */
  66275. canLoad(extension: string): boolean;
  66276. /**
  66277. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  66278. * @param data contains the texture data
  66279. * @param texture defines the BabylonJS internal texture
  66280. * @param createPolynomials will be true if polynomials have been requested
  66281. * @param onLoad defines the callback to trigger once the texture is ready
  66282. * @param onError defines the callback to trigger in case of error
  66283. */
  66284. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  66285. /**
  66286. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  66287. * @param data contains the texture data
  66288. * @param texture defines the BabylonJS internal texture
  66289. * @param callback defines the method to call once ready to upload
  66290. */
  66291. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  66292. }
  66293. }
  66294. declare module BABYLON {
  66295. /**
  66296. * Info about the .basis files
  66297. */
  66298. class BasisFileInfo {
  66299. /**
  66300. * If the file has alpha
  66301. */
  66302. hasAlpha: boolean;
  66303. /**
  66304. * Info about each image of the basis file
  66305. */
  66306. images: Array<{
  66307. levels: Array<{
  66308. width: number;
  66309. height: number;
  66310. transcodedPixels: ArrayBufferView;
  66311. }>;
  66312. }>;
  66313. }
  66314. /**
  66315. * Result of transcoding a basis file
  66316. */
  66317. class TranscodeResult {
  66318. /**
  66319. * Info about the .basis file
  66320. */
  66321. fileInfo: BasisFileInfo;
  66322. /**
  66323. * Format to use when loading the file
  66324. */
  66325. format: number;
  66326. }
  66327. /**
  66328. * Configuration options for the Basis transcoder
  66329. */
  66330. export class BasisTranscodeConfiguration {
  66331. /**
  66332. * Supported compression formats used to determine the supported output format of the transcoder
  66333. */
  66334. supportedCompressionFormats?: {
  66335. /**
  66336. * etc1 compression format
  66337. */
  66338. etc1?: boolean;
  66339. /**
  66340. * s3tc compression format
  66341. */
  66342. s3tc?: boolean;
  66343. /**
  66344. * pvrtc compression format
  66345. */
  66346. pvrtc?: boolean;
  66347. /**
  66348. * etc2 compression format
  66349. */
  66350. etc2?: boolean;
  66351. };
  66352. /**
  66353. * If mipmap levels should be loaded for transcoded images (Default: true)
  66354. */
  66355. loadMipmapLevels?: boolean;
  66356. /**
  66357. * Index of a single image to load (Default: all images)
  66358. */
  66359. loadSingleImage?: number;
  66360. }
  66361. /**
  66362. * Used to load .Basis files
  66363. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  66364. */
  66365. export class BasisTools {
  66366. private static _IgnoreSupportedFormats;
  66367. /**
  66368. * URL to use when loading the basis transcoder
  66369. */
  66370. static JSModuleURL: string;
  66371. /**
  66372. * URL to use when loading the wasm module for the transcoder
  66373. */
  66374. static WasmModuleURL: string;
  66375. /**
  66376. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  66377. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  66378. * @returns internal format corresponding to the Basis format
  66379. */
  66380. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  66381. private static _WorkerPromise;
  66382. private static _Worker;
  66383. private static _actionId;
  66384. private static _CreateWorkerAsync;
  66385. /**
  66386. * Transcodes a loaded image file to compressed pixel data
  66387. * @param data image data to transcode
  66388. * @param config configuration options for the transcoding
  66389. * @returns a promise resulting in the transcoded image
  66390. */
  66391. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  66392. /**
  66393. * Loads a texture from the transcode result
  66394. * @param texture texture load to
  66395. * @param transcodeResult the result of transcoding the basis file to load from
  66396. */
  66397. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  66398. }
  66399. }
  66400. declare module BABYLON {
  66401. /**
  66402. * Loader for .basis file format
  66403. */
  66404. export class _BasisTextureLoader implements IInternalTextureLoader {
  66405. /**
  66406. * Defines whether the loader supports cascade loading the different faces.
  66407. */
  66408. readonly supportCascades: boolean;
  66409. /**
  66410. * This returns if the loader support the current file information.
  66411. * @param extension defines the file extension of the file being loaded
  66412. * @returns true if the loader can load the specified file
  66413. */
  66414. canLoad(extension: string): boolean;
  66415. /**
  66416. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  66417. * @param data contains the texture data
  66418. * @param texture defines the BabylonJS internal texture
  66419. * @param createPolynomials will be true if polynomials have been requested
  66420. * @param onLoad defines the callback to trigger once the texture is ready
  66421. * @param onError defines the callback to trigger in case of error
  66422. */
  66423. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  66424. /**
  66425. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  66426. * @param data contains the texture data
  66427. * @param texture defines the BabylonJS internal texture
  66428. * @param callback defines the method to call once ready to upload
  66429. */
  66430. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  66431. }
  66432. }
  66433. declare module BABYLON {
  66434. /**
  66435. * Defines the basic options interface of a TexturePacker Frame
  66436. */
  66437. export interface ITexturePackerFrame {
  66438. /**
  66439. * The frame ID
  66440. */
  66441. id: number;
  66442. /**
  66443. * The frames Scale
  66444. */
  66445. scale: Vector2;
  66446. /**
  66447. * The Frames offset
  66448. */
  66449. offset: Vector2;
  66450. }
  66451. /**
  66452. * This is a support class for frame Data on texture packer sets.
  66453. */
  66454. export class TexturePackerFrame implements ITexturePackerFrame {
  66455. /**
  66456. * The frame ID
  66457. */
  66458. id: number;
  66459. /**
  66460. * The frames Scale
  66461. */
  66462. scale: Vector2;
  66463. /**
  66464. * The Frames offset
  66465. */
  66466. offset: Vector2;
  66467. /**
  66468. * Initializes a texture package frame.
  66469. * @param id The numerical frame identifier
  66470. * @param scale Scalar Vector2 for UV frame
  66471. * @param offset Vector2 for the frame position in UV units.
  66472. * @returns TexturePackerFrame
  66473. */
  66474. constructor(id: number, scale: Vector2, offset: Vector2);
  66475. }
  66476. }
  66477. declare module BABYLON {
  66478. /**
  66479. * Defines the basic options interface of a TexturePacker
  66480. */
  66481. export interface ITexturePackerOptions {
  66482. /**
  66483. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  66484. */
  66485. map?: string[];
  66486. /**
  66487. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  66488. */
  66489. uvsIn?: string;
  66490. /**
  66491. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  66492. */
  66493. uvsOut?: string;
  66494. /**
  66495. * number representing the layout style. Defaults to LAYOUT_STRIP
  66496. */
  66497. layout?: number;
  66498. /**
  66499. * number of columns if using custom column count layout(2). This defaults to 4.
  66500. */
  66501. colnum?: number;
  66502. /**
  66503. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  66504. */
  66505. updateInputMeshes?: boolean;
  66506. /**
  66507. * boolean flag to dispose all the source textures. Defaults to true.
  66508. */
  66509. disposeSources?: boolean;
  66510. /**
  66511. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  66512. */
  66513. fillBlanks?: boolean;
  66514. /**
  66515. * string value representing the context fill style color. Defaults to 'black'.
  66516. */
  66517. customFillColor?: string;
  66518. /**
  66519. * Width and Height Value of each Frame in the TexturePacker Sets
  66520. */
  66521. frameSize?: number;
  66522. /**
  66523. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  66524. */
  66525. paddingRatio?: number;
  66526. /**
  66527. * Number that declares the fill method for the padding gutter.
  66528. */
  66529. paddingMode?: number;
  66530. /**
  66531. * If in SUBUV_COLOR padding mode what color to use.
  66532. */
  66533. paddingColor?: Color3 | Color4;
  66534. }
  66535. /**
  66536. * Defines the basic interface of a TexturePacker JSON File
  66537. */
  66538. export interface ITexturePackerJSON {
  66539. /**
  66540. * The frame ID
  66541. */
  66542. name: string;
  66543. /**
  66544. * The base64 channel data
  66545. */
  66546. sets: any;
  66547. /**
  66548. * The options of the Packer
  66549. */
  66550. options: ITexturePackerOptions;
  66551. /**
  66552. * The frame data of the Packer
  66553. */
  66554. frames: Array<number>;
  66555. }
  66556. /**
  66557. * This is a support class that generates a series of packed texture sets.
  66558. * @see https://doc.babylonjs.com/babylon101/materials
  66559. */
  66560. export class TexturePacker {
  66561. /** Packer Layout Constant 0 */
  66562. static readonly LAYOUT_STRIP: number;
  66563. /** Packer Layout Constant 1 */
  66564. static readonly LAYOUT_POWER2: number;
  66565. /** Packer Layout Constant 2 */
  66566. static readonly LAYOUT_COLNUM: number;
  66567. /** Packer Layout Constant 0 */
  66568. static readonly SUBUV_WRAP: number;
  66569. /** Packer Layout Constant 1 */
  66570. static readonly SUBUV_EXTEND: number;
  66571. /** Packer Layout Constant 2 */
  66572. static readonly SUBUV_COLOR: number;
  66573. /** The Name of the Texture Package */
  66574. name: string;
  66575. /** The scene scope of the TexturePacker */
  66576. scene: Scene;
  66577. /** The Meshes to target */
  66578. meshes: AbstractMesh[];
  66579. /** Arguments passed with the Constructor */
  66580. options: ITexturePackerOptions;
  66581. /** The promise that is started upon initialization */
  66582. promise: Nullable<Promise<TexturePacker | string>>;
  66583. /** The Container object for the channel sets that are generated */
  66584. sets: object;
  66585. /** The Container array for the frames that are generated */
  66586. frames: TexturePackerFrame[];
  66587. /** The expected number of textures the system is parsing. */
  66588. private _expecting;
  66589. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  66590. private _paddingValue;
  66591. /**
  66592. * Initializes a texture package series from an array of meshes or a single mesh.
  66593. * @param name The name of the package
  66594. * @param meshes The target meshes to compose the package from
  66595. * @param options The arguments that texture packer should follow while building.
  66596. * @param scene The scene which the textures are scoped to.
  66597. * @returns TexturePacker
  66598. */
  66599. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  66600. /**
  66601. * Starts the package process
  66602. * @param resolve The promises resolution function
  66603. * @returns TexturePacker
  66604. */
  66605. private _createFrames;
  66606. /**
  66607. * Calculates the Size of the Channel Sets
  66608. * @returns Vector2
  66609. */
  66610. private _calculateSize;
  66611. /**
  66612. * Calculates the UV data for the frames.
  66613. * @param baseSize the base frameSize
  66614. * @param padding the base frame padding
  66615. * @param dtSize size of the Dynamic Texture for that channel
  66616. * @param dtUnits is 1/dtSize
  66617. * @param update flag to update the input meshes
  66618. */
  66619. private _calculateMeshUVFrames;
  66620. /**
  66621. * Calculates the frames Offset.
  66622. * @param index of the frame
  66623. * @returns Vector2
  66624. */
  66625. private _getFrameOffset;
  66626. /**
  66627. * Updates a Mesh to the frame data
  66628. * @param mesh that is the target
  66629. * @param frameID or the frame index
  66630. */
  66631. private _updateMeshUV;
  66632. /**
  66633. * Updates a Meshes materials to use the texture packer channels
  66634. * @param m is the mesh to target
  66635. * @param force all channels on the packer to be set.
  66636. */
  66637. private _updateTextureReferences;
  66638. /**
  66639. * Public method to set a Mesh to a frame
  66640. * @param m that is the target
  66641. * @param frameID or the frame index
  66642. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  66643. */
  66644. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  66645. /**
  66646. * Starts the async promise to compile the texture packer.
  66647. * @returns Promise<void>
  66648. */
  66649. processAsync(): Promise<void>;
  66650. /**
  66651. * Disposes all textures associated with this packer
  66652. */
  66653. dispose(): void;
  66654. /**
  66655. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  66656. * @param imageType is the image type to use.
  66657. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  66658. */
  66659. download(imageType?: string, quality?: number): void;
  66660. /**
  66661. * Public method to load a texturePacker JSON file.
  66662. * @param data of the JSON file in string format.
  66663. */
  66664. updateFromJSON(data: string): void;
  66665. }
  66666. }
  66667. declare module BABYLON {
  66668. /**
  66669. * 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.
  66670. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  66671. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  66672. */
  66673. export class CustomProceduralTexture extends ProceduralTexture {
  66674. private _animate;
  66675. private _time;
  66676. private _config;
  66677. private _texturePath;
  66678. /**
  66679. * Instantiates a new Custom Procedural Texture.
  66680. * 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.
  66681. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  66682. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  66683. * @param name Define the name of the texture
  66684. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  66685. * @param size Define the size of the texture to create
  66686. * @param scene Define the scene the texture belongs to
  66687. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  66688. * @param generateMipMaps Define if the texture should creates mip maps or not
  66689. */
  66690. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  66691. private _loadJson;
  66692. /**
  66693. * Is the texture ready to be used ? (rendered at least once)
  66694. * @returns true if ready, otherwise, false.
  66695. */
  66696. isReady(): boolean;
  66697. /**
  66698. * Render the texture to its associated render target.
  66699. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  66700. */
  66701. render(useCameraPostProcess?: boolean): void;
  66702. /**
  66703. * Update the list of dependant textures samplers in the shader.
  66704. */
  66705. updateTextures(): void;
  66706. /**
  66707. * Update the uniform values of the procedural texture in the shader.
  66708. */
  66709. updateShaderUniforms(): void;
  66710. /**
  66711. * Define if the texture animates or not.
  66712. */
  66713. get animate(): boolean;
  66714. set animate(value: boolean);
  66715. }
  66716. }
  66717. declare module BABYLON {
  66718. /** @hidden */
  66719. export var noisePixelShader: {
  66720. name: string;
  66721. shader: string;
  66722. };
  66723. }
  66724. declare module BABYLON {
  66725. /**
  66726. * Class used to generate noise procedural textures
  66727. */
  66728. export class NoiseProceduralTexture extends ProceduralTexture {
  66729. /** Gets or sets the start time (default is 0) */
  66730. time: number;
  66731. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  66732. brightness: number;
  66733. /** Defines the number of octaves to process */
  66734. octaves: number;
  66735. /** Defines the level of persistence (0.8 by default) */
  66736. persistence: number;
  66737. /** Gets or sets animation speed factor (default is 1) */
  66738. animationSpeedFactor: number;
  66739. /**
  66740. * Creates a new NoiseProceduralTexture
  66741. * @param name defines the name fo the texture
  66742. * @param size defines the size of the texture (default is 256)
  66743. * @param scene defines the hosting scene
  66744. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  66745. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  66746. */
  66747. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  66748. private _updateShaderUniforms;
  66749. protected _getDefines(): string;
  66750. /** Generate the current state of the procedural texture */
  66751. render(useCameraPostProcess?: boolean): void;
  66752. /**
  66753. * Serializes this noise procedural texture
  66754. * @returns a serialized noise procedural texture object
  66755. */
  66756. serialize(): any;
  66757. /**
  66758. * Clone the texture.
  66759. * @returns the cloned texture
  66760. */
  66761. clone(): NoiseProceduralTexture;
  66762. /**
  66763. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  66764. * @param parsedTexture defines parsed texture data
  66765. * @param scene defines the current scene
  66766. * @param rootUrl defines the root URL containing noise procedural texture information
  66767. * @returns a parsed NoiseProceduralTexture
  66768. */
  66769. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  66770. }
  66771. }
  66772. declare module BABYLON {
  66773. /**
  66774. * Raw cube texture where the raw buffers are passed in
  66775. */
  66776. export class RawCubeTexture extends CubeTexture {
  66777. /**
  66778. * Creates a cube texture where the raw buffers are passed in.
  66779. * @param scene defines the scene the texture is attached to
  66780. * @param data defines the array of data to use to create each face
  66781. * @param size defines the size of the textures
  66782. * @param format defines the format of the data
  66783. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  66784. * @param generateMipMaps defines if the engine should generate the mip levels
  66785. * @param invertY defines if data must be stored with Y axis inverted
  66786. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  66787. * @param compression defines the compression used (null by default)
  66788. */
  66789. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  66790. /**
  66791. * Updates the raw cube texture.
  66792. * @param data defines the data to store
  66793. * @param format defines the data format
  66794. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  66795. * @param invertY defines if data must be stored with Y axis inverted
  66796. * @param compression defines the compression used (null by default)
  66797. * @param level defines which level of the texture to update
  66798. */
  66799. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  66800. /**
  66801. * Updates a raw cube texture with RGBD encoded data.
  66802. * @param data defines the array of data [mipmap][face] to use to create each face
  66803. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  66804. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  66805. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  66806. * @returns a promsie that resolves when the operation is complete
  66807. */
  66808. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  66809. /**
  66810. * Clones the raw cube texture.
  66811. * @return a new cube texture
  66812. */
  66813. clone(): CubeTexture;
  66814. /** @hidden */
  66815. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  66816. }
  66817. }
  66818. declare module BABYLON {
  66819. /**
  66820. * Class used to store 2D array textures containing user data
  66821. */
  66822. export class RawTexture2DArray extends Texture {
  66823. /** Gets or sets the texture format to use */
  66824. format: number;
  66825. /**
  66826. * Create a new RawTexture2DArray
  66827. * @param data defines the data of the texture
  66828. * @param width defines the width of the texture
  66829. * @param height defines the height of the texture
  66830. * @param depth defines the number of layers of the texture
  66831. * @param format defines the texture format to use
  66832. * @param scene defines the hosting scene
  66833. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  66834. * @param invertY defines if texture must be stored with Y axis inverted
  66835. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  66836. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  66837. */
  66838. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  66839. /** Gets or sets the texture format to use */
  66840. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  66841. /**
  66842. * Update the texture with new data
  66843. * @param data defines the data to store in the texture
  66844. */
  66845. update(data: ArrayBufferView): void;
  66846. }
  66847. }
  66848. declare module BABYLON {
  66849. /**
  66850. * Class used to store 3D textures containing user data
  66851. */
  66852. export class RawTexture3D extends Texture {
  66853. /** Gets or sets the texture format to use */
  66854. format: number;
  66855. /**
  66856. * Create a new RawTexture3D
  66857. * @param data defines the data of the texture
  66858. * @param width defines the width of the texture
  66859. * @param height defines the height of the texture
  66860. * @param depth defines the depth of the texture
  66861. * @param format defines the texture format to use
  66862. * @param scene defines the hosting scene
  66863. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  66864. * @param invertY defines if texture must be stored with Y axis inverted
  66865. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  66866. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  66867. */
  66868. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  66869. /** Gets or sets the texture format to use */
  66870. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  66871. /**
  66872. * Update the texture with new data
  66873. * @param data defines the data to store in the texture
  66874. */
  66875. update(data: ArrayBufferView): void;
  66876. }
  66877. }
  66878. declare module BABYLON {
  66879. /**
  66880. * Creates a refraction texture used by refraction channel of the standard material.
  66881. * It is like a mirror but to see through a material.
  66882. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  66883. */
  66884. export class RefractionTexture extends RenderTargetTexture {
  66885. /**
  66886. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  66887. * 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.
  66888. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  66889. */
  66890. refractionPlane: Plane;
  66891. /**
  66892. * Define how deep under the surface we should see.
  66893. */
  66894. depth: number;
  66895. /**
  66896. * Creates a refraction texture used by refraction channel of the standard material.
  66897. * It is like a mirror but to see through a material.
  66898. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  66899. * @param name Define the texture name
  66900. * @param size Define the size of the underlying texture
  66901. * @param scene Define the scene the refraction belongs to
  66902. * @param generateMipMaps Define if we need to generate mips level for the refraction
  66903. */
  66904. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  66905. /**
  66906. * Clone the refraction texture.
  66907. * @returns the cloned texture
  66908. */
  66909. clone(): RefractionTexture;
  66910. /**
  66911. * Serialize the texture to a JSON representation you could use in Parse later on
  66912. * @returns the serialized JSON representation
  66913. */
  66914. serialize(): any;
  66915. }
  66916. }
  66917. declare module BABYLON {
  66918. /**
  66919. * Block used to add support for vertex skinning (bones)
  66920. */
  66921. export class BonesBlock extends NodeMaterialBlock {
  66922. /**
  66923. * Creates a new BonesBlock
  66924. * @param name defines the block name
  66925. */
  66926. constructor(name: string);
  66927. /**
  66928. * Initialize the block and prepare the context for build
  66929. * @param state defines the state that will be used for the build
  66930. */
  66931. initialize(state: NodeMaterialBuildState): void;
  66932. /**
  66933. * Gets the current class name
  66934. * @returns the class name
  66935. */
  66936. getClassName(): string;
  66937. /**
  66938. * Gets the matrix indices input component
  66939. */
  66940. get matricesIndices(): NodeMaterialConnectionPoint;
  66941. /**
  66942. * Gets the matrix weights input component
  66943. */
  66944. get matricesWeights(): NodeMaterialConnectionPoint;
  66945. /**
  66946. * Gets the extra matrix indices input component
  66947. */
  66948. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  66949. /**
  66950. * Gets the extra matrix weights input component
  66951. */
  66952. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  66953. /**
  66954. * Gets the world input component
  66955. */
  66956. get world(): NodeMaterialConnectionPoint;
  66957. /**
  66958. * Gets the output component
  66959. */
  66960. get output(): NodeMaterialConnectionPoint;
  66961. autoConfigure(material: NodeMaterial): void;
  66962. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  66963. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  66964. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66965. protected _buildBlock(state: NodeMaterialBuildState): this;
  66966. }
  66967. }
  66968. declare module BABYLON {
  66969. /**
  66970. * Block used to add support for instances
  66971. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  66972. */
  66973. export class InstancesBlock extends NodeMaterialBlock {
  66974. /**
  66975. * Creates a new InstancesBlock
  66976. * @param name defines the block name
  66977. */
  66978. constructor(name: string);
  66979. /**
  66980. * Gets the current class name
  66981. * @returns the class name
  66982. */
  66983. getClassName(): string;
  66984. /**
  66985. * Gets the first world row input component
  66986. */
  66987. get world0(): NodeMaterialConnectionPoint;
  66988. /**
  66989. * Gets the second world row input component
  66990. */
  66991. get world1(): NodeMaterialConnectionPoint;
  66992. /**
  66993. * Gets the third world row input component
  66994. */
  66995. get world2(): NodeMaterialConnectionPoint;
  66996. /**
  66997. * Gets the forth world row input component
  66998. */
  66999. get world3(): NodeMaterialConnectionPoint;
  67000. /**
  67001. * Gets the world input component
  67002. */
  67003. get world(): NodeMaterialConnectionPoint;
  67004. /**
  67005. * Gets the output component
  67006. */
  67007. get output(): NodeMaterialConnectionPoint;
  67008. /**
  67009. * Gets the isntanceID component
  67010. */
  67011. get instanceID(): NodeMaterialConnectionPoint;
  67012. autoConfigure(material: NodeMaterial): void;
  67013. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  67014. protected _buildBlock(state: NodeMaterialBuildState): this;
  67015. }
  67016. }
  67017. declare module BABYLON {
  67018. /**
  67019. * Block used to add morph targets support to vertex shader
  67020. */
  67021. export class MorphTargetsBlock extends NodeMaterialBlock {
  67022. private _repeatableContentAnchor;
  67023. /**
  67024. * Create a new MorphTargetsBlock
  67025. * @param name defines the block name
  67026. */
  67027. constructor(name: string);
  67028. /**
  67029. * Gets the current class name
  67030. * @returns the class name
  67031. */
  67032. getClassName(): string;
  67033. /**
  67034. * Gets the position input component
  67035. */
  67036. get position(): NodeMaterialConnectionPoint;
  67037. /**
  67038. * Gets the normal input component
  67039. */
  67040. get normal(): NodeMaterialConnectionPoint;
  67041. /**
  67042. * Gets the tangent input component
  67043. */
  67044. get tangent(): NodeMaterialConnectionPoint;
  67045. /**
  67046. * Gets the tangent input component
  67047. */
  67048. get uv(): NodeMaterialConnectionPoint;
  67049. /**
  67050. * Gets the position output component
  67051. */
  67052. get positionOutput(): NodeMaterialConnectionPoint;
  67053. /**
  67054. * Gets the normal output component
  67055. */
  67056. get normalOutput(): NodeMaterialConnectionPoint;
  67057. /**
  67058. * Gets the tangent output component
  67059. */
  67060. get tangentOutput(): NodeMaterialConnectionPoint;
  67061. /**
  67062. * Gets the tangent output component
  67063. */
  67064. get uvOutput(): NodeMaterialConnectionPoint;
  67065. initialize(state: NodeMaterialBuildState): void;
  67066. autoConfigure(material: NodeMaterial): void;
  67067. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67068. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  67069. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  67070. protected _buildBlock(state: NodeMaterialBuildState): this;
  67071. }
  67072. }
  67073. declare module BABYLON {
  67074. /**
  67075. * Block used to get data information from a light
  67076. */
  67077. export class LightInformationBlock extends NodeMaterialBlock {
  67078. private _lightDataUniformName;
  67079. private _lightColorUniformName;
  67080. private _lightTypeDefineName;
  67081. /**
  67082. * Gets or sets the light associated with this block
  67083. */
  67084. light: Nullable<Light>;
  67085. /**
  67086. * Creates a new LightInformationBlock
  67087. * @param name defines the block name
  67088. */
  67089. constructor(name: string);
  67090. /**
  67091. * Gets the current class name
  67092. * @returns the class name
  67093. */
  67094. getClassName(): string;
  67095. /**
  67096. * Gets the world position input component
  67097. */
  67098. get worldPosition(): NodeMaterialConnectionPoint;
  67099. /**
  67100. * Gets the direction output component
  67101. */
  67102. get direction(): NodeMaterialConnectionPoint;
  67103. /**
  67104. * Gets the direction output component
  67105. */
  67106. get color(): NodeMaterialConnectionPoint;
  67107. /**
  67108. * Gets the direction output component
  67109. */
  67110. get intensity(): NodeMaterialConnectionPoint;
  67111. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  67112. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67113. protected _buildBlock(state: NodeMaterialBuildState): this;
  67114. serialize(): any;
  67115. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67116. }
  67117. }
  67118. declare module BABYLON {
  67119. /**
  67120. * Block used to add image processing support to fragment shader
  67121. */
  67122. export class ImageProcessingBlock extends NodeMaterialBlock {
  67123. /**
  67124. * Create a new ImageProcessingBlock
  67125. * @param name defines the block name
  67126. */
  67127. constructor(name: string);
  67128. /**
  67129. * Gets the current class name
  67130. * @returns the class name
  67131. */
  67132. getClassName(): string;
  67133. /**
  67134. * Gets the color input component
  67135. */
  67136. get color(): NodeMaterialConnectionPoint;
  67137. /**
  67138. * Gets the output component
  67139. */
  67140. get output(): NodeMaterialConnectionPoint;
  67141. /**
  67142. * Initialize the block and prepare the context for build
  67143. * @param state defines the state that will be used for the build
  67144. */
  67145. initialize(state: NodeMaterialBuildState): void;
  67146. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  67147. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67148. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  67149. protected _buildBlock(state: NodeMaterialBuildState): this;
  67150. }
  67151. }
  67152. declare module BABYLON {
  67153. /**
  67154. * Block used to pertub normals based on a normal map
  67155. */
  67156. export class PerturbNormalBlock extends NodeMaterialBlock {
  67157. private _tangentSpaceParameterName;
  67158. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  67159. invertX: boolean;
  67160. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  67161. invertY: boolean;
  67162. /**
  67163. * Create a new PerturbNormalBlock
  67164. * @param name defines the block name
  67165. */
  67166. constructor(name: string);
  67167. /**
  67168. * Gets the current class name
  67169. * @returns the class name
  67170. */
  67171. getClassName(): string;
  67172. /**
  67173. * Gets the world position input component
  67174. */
  67175. get worldPosition(): NodeMaterialConnectionPoint;
  67176. /**
  67177. * Gets the world normal input component
  67178. */
  67179. get worldNormal(): NodeMaterialConnectionPoint;
  67180. /**
  67181. * Gets the world tangent input component
  67182. */
  67183. get worldTangent(): NodeMaterialConnectionPoint;
  67184. /**
  67185. * Gets the uv input component
  67186. */
  67187. get uv(): NodeMaterialConnectionPoint;
  67188. /**
  67189. * Gets the normal map color input component
  67190. */
  67191. get normalMapColor(): NodeMaterialConnectionPoint;
  67192. /**
  67193. * Gets the strength input component
  67194. */
  67195. get strength(): NodeMaterialConnectionPoint;
  67196. /**
  67197. * Gets the output component
  67198. */
  67199. get output(): NodeMaterialConnectionPoint;
  67200. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67201. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  67202. autoConfigure(material: NodeMaterial): void;
  67203. protected _buildBlock(state: NodeMaterialBuildState): this;
  67204. protected _dumpPropertiesCode(): string;
  67205. serialize(): any;
  67206. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67207. }
  67208. }
  67209. declare module BABYLON {
  67210. /**
  67211. * Block used to discard a pixel if a value is smaller than a cutoff
  67212. */
  67213. export class DiscardBlock extends NodeMaterialBlock {
  67214. /**
  67215. * Create a new DiscardBlock
  67216. * @param name defines the block name
  67217. */
  67218. constructor(name: string);
  67219. /**
  67220. * Gets the current class name
  67221. * @returns the class name
  67222. */
  67223. getClassName(): string;
  67224. /**
  67225. * Gets the color input component
  67226. */
  67227. get value(): NodeMaterialConnectionPoint;
  67228. /**
  67229. * Gets the cutoff input component
  67230. */
  67231. get cutoff(): NodeMaterialConnectionPoint;
  67232. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  67233. }
  67234. }
  67235. declare module BABYLON {
  67236. /**
  67237. * Block used to test if the fragment shader is front facing
  67238. */
  67239. export class FrontFacingBlock extends NodeMaterialBlock {
  67240. /**
  67241. * Creates a new FrontFacingBlock
  67242. * @param name defines the block name
  67243. */
  67244. constructor(name: string);
  67245. /**
  67246. * Gets the current class name
  67247. * @returns the class name
  67248. */
  67249. getClassName(): string;
  67250. /**
  67251. * Gets the output component
  67252. */
  67253. get output(): NodeMaterialConnectionPoint;
  67254. protected _buildBlock(state: NodeMaterialBuildState): this;
  67255. }
  67256. }
  67257. declare module BABYLON {
  67258. /**
  67259. * Block used to get the derivative value on x and y of a given input
  67260. */
  67261. export class DerivativeBlock extends NodeMaterialBlock {
  67262. /**
  67263. * Create a new DerivativeBlock
  67264. * @param name defines the block name
  67265. */
  67266. constructor(name: string);
  67267. /**
  67268. * Gets the current class name
  67269. * @returns the class name
  67270. */
  67271. getClassName(): string;
  67272. /**
  67273. * Gets the input component
  67274. */
  67275. get input(): NodeMaterialConnectionPoint;
  67276. /**
  67277. * Gets the derivative output on x
  67278. */
  67279. get dx(): NodeMaterialConnectionPoint;
  67280. /**
  67281. * Gets the derivative output on y
  67282. */
  67283. get dy(): NodeMaterialConnectionPoint;
  67284. protected _buildBlock(state: NodeMaterialBuildState): this;
  67285. }
  67286. }
  67287. declare module BABYLON {
  67288. /**
  67289. * Block used to make gl_FragCoord available
  67290. */
  67291. export class FragCoordBlock extends NodeMaterialBlock {
  67292. /**
  67293. * Creates a new FragCoordBlock
  67294. * @param name defines the block name
  67295. */
  67296. constructor(name: string);
  67297. /**
  67298. * Gets the current class name
  67299. * @returns the class name
  67300. */
  67301. getClassName(): string;
  67302. /**
  67303. * Gets the xy component
  67304. */
  67305. get xy(): NodeMaterialConnectionPoint;
  67306. /**
  67307. * Gets the xyz component
  67308. */
  67309. get xyz(): NodeMaterialConnectionPoint;
  67310. /**
  67311. * Gets the xyzw component
  67312. */
  67313. get xyzw(): NodeMaterialConnectionPoint;
  67314. /**
  67315. * Gets the x component
  67316. */
  67317. get x(): NodeMaterialConnectionPoint;
  67318. /**
  67319. * Gets the y component
  67320. */
  67321. get y(): NodeMaterialConnectionPoint;
  67322. /**
  67323. * Gets the z component
  67324. */
  67325. get z(): NodeMaterialConnectionPoint;
  67326. /**
  67327. * Gets the w component
  67328. */
  67329. get output(): NodeMaterialConnectionPoint;
  67330. protected writeOutputs(state: NodeMaterialBuildState): string;
  67331. protected _buildBlock(state: NodeMaterialBuildState): this;
  67332. }
  67333. }
  67334. declare module BABYLON {
  67335. /**
  67336. * Block used to get the screen sizes
  67337. */
  67338. export class ScreenSizeBlock extends NodeMaterialBlock {
  67339. private _varName;
  67340. private _scene;
  67341. /**
  67342. * Creates a new ScreenSizeBlock
  67343. * @param name defines the block name
  67344. */
  67345. constructor(name: string);
  67346. /**
  67347. * Gets the current class name
  67348. * @returns the class name
  67349. */
  67350. getClassName(): string;
  67351. /**
  67352. * Gets the xy component
  67353. */
  67354. get xy(): NodeMaterialConnectionPoint;
  67355. /**
  67356. * Gets the x component
  67357. */
  67358. get x(): NodeMaterialConnectionPoint;
  67359. /**
  67360. * Gets the y component
  67361. */
  67362. get y(): NodeMaterialConnectionPoint;
  67363. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  67364. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  67365. protected _buildBlock(state: NodeMaterialBuildState): this;
  67366. }
  67367. }
  67368. declare module BABYLON {
  67369. /**
  67370. * Block used to add support for scene fog
  67371. */
  67372. export class FogBlock extends NodeMaterialBlock {
  67373. private _fogDistanceName;
  67374. private _fogParameters;
  67375. /**
  67376. * Create a new FogBlock
  67377. * @param name defines the block name
  67378. */
  67379. constructor(name: string);
  67380. /**
  67381. * Gets the current class name
  67382. * @returns the class name
  67383. */
  67384. getClassName(): string;
  67385. /**
  67386. * Gets the world position input component
  67387. */
  67388. get worldPosition(): NodeMaterialConnectionPoint;
  67389. /**
  67390. * Gets the view input component
  67391. */
  67392. get view(): NodeMaterialConnectionPoint;
  67393. /**
  67394. * Gets the color input component
  67395. */
  67396. get input(): NodeMaterialConnectionPoint;
  67397. /**
  67398. * Gets the fog color input component
  67399. */
  67400. get fogColor(): NodeMaterialConnectionPoint;
  67401. /**
  67402. * Gets the output component
  67403. */
  67404. get output(): NodeMaterialConnectionPoint;
  67405. autoConfigure(material: NodeMaterial): void;
  67406. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67407. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  67408. protected _buildBlock(state: NodeMaterialBuildState): this;
  67409. }
  67410. }
  67411. declare module BABYLON {
  67412. /**
  67413. * Block used to add light in the fragment shader
  67414. */
  67415. export class LightBlock extends NodeMaterialBlock {
  67416. private _lightId;
  67417. /**
  67418. * Gets or sets the light associated with this block
  67419. */
  67420. light: Nullable<Light>;
  67421. /**
  67422. * Create a new LightBlock
  67423. * @param name defines the block name
  67424. */
  67425. constructor(name: string);
  67426. /**
  67427. * Gets the current class name
  67428. * @returns the class name
  67429. */
  67430. getClassName(): string;
  67431. /**
  67432. * Gets the world position input component
  67433. */
  67434. get worldPosition(): NodeMaterialConnectionPoint;
  67435. /**
  67436. * Gets the world normal input component
  67437. */
  67438. get worldNormal(): NodeMaterialConnectionPoint;
  67439. /**
  67440. * Gets the camera (or eye) position component
  67441. */
  67442. get cameraPosition(): NodeMaterialConnectionPoint;
  67443. /**
  67444. * Gets the glossiness component
  67445. */
  67446. get glossiness(): NodeMaterialConnectionPoint;
  67447. /**
  67448. * Gets the glossinness power component
  67449. */
  67450. get glossPower(): NodeMaterialConnectionPoint;
  67451. /**
  67452. * Gets the diffuse color component
  67453. */
  67454. get diffuseColor(): NodeMaterialConnectionPoint;
  67455. /**
  67456. * Gets the specular color component
  67457. */
  67458. get specularColor(): NodeMaterialConnectionPoint;
  67459. /**
  67460. * Gets the view matrix component
  67461. */
  67462. get view(): NodeMaterialConnectionPoint;
  67463. /**
  67464. * Gets the diffuse output component
  67465. */
  67466. get diffuseOutput(): NodeMaterialConnectionPoint;
  67467. /**
  67468. * Gets the specular output component
  67469. */
  67470. get specularOutput(): NodeMaterialConnectionPoint;
  67471. /**
  67472. * Gets the shadow output component
  67473. */
  67474. get shadow(): NodeMaterialConnectionPoint;
  67475. autoConfigure(material: NodeMaterial): void;
  67476. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67477. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  67478. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  67479. private _injectVertexCode;
  67480. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  67481. serialize(): any;
  67482. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67483. }
  67484. }
  67485. declare module BABYLON {
  67486. /**
  67487. * Block used to read a reflection texture from a sampler
  67488. */
  67489. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  67490. /**
  67491. * Create a new ReflectionTextureBlock
  67492. * @param name defines the block name
  67493. */
  67494. constructor(name: string);
  67495. /**
  67496. * Gets the current class name
  67497. * @returns the class name
  67498. */
  67499. getClassName(): string;
  67500. /**
  67501. * Gets the world position input component
  67502. */
  67503. get position(): NodeMaterialConnectionPoint;
  67504. /**
  67505. * Gets the world position input component
  67506. */
  67507. get worldPosition(): NodeMaterialConnectionPoint;
  67508. /**
  67509. * Gets the world normal input component
  67510. */
  67511. get worldNormal(): NodeMaterialConnectionPoint;
  67512. /**
  67513. * Gets the world input component
  67514. */
  67515. get world(): NodeMaterialConnectionPoint;
  67516. /**
  67517. * Gets the camera (or eye) position component
  67518. */
  67519. get cameraPosition(): NodeMaterialConnectionPoint;
  67520. /**
  67521. * Gets the view input component
  67522. */
  67523. get view(): NodeMaterialConnectionPoint;
  67524. /**
  67525. * Gets the rgb output component
  67526. */
  67527. get rgb(): NodeMaterialConnectionPoint;
  67528. /**
  67529. * Gets the rgba output component
  67530. */
  67531. get rgba(): NodeMaterialConnectionPoint;
  67532. /**
  67533. * Gets the r output component
  67534. */
  67535. get r(): NodeMaterialConnectionPoint;
  67536. /**
  67537. * Gets the g output component
  67538. */
  67539. get g(): NodeMaterialConnectionPoint;
  67540. /**
  67541. * Gets the b output component
  67542. */
  67543. get b(): NodeMaterialConnectionPoint;
  67544. /**
  67545. * Gets the a output component
  67546. */
  67547. get a(): NodeMaterialConnectionPoint;
  67548. autoConfigure(material: NodeMaterial): void;
  67549. protected _buildBlock(state: NodeMaterialBuildState): this;
  67550. }
  67551. }
  67552. declare module BABYLON {
  67553. /**
  67554. * Block used to add 2 vectors
  67555. */
  67556. export class AddBlock extends NodeMaterialBlock {
  67557. /**
  67558. * Creates a new AddBlock
  67559. * @param name defines the block name
  67560. */
  67561. constructor(name: string);
  67562. /**
  67563. * Gets the current class name
  67564. * @returns the class name
  67565. */
  67566. getClassName(): string;
  67567. /**
  67568. * Gets the left operand input component
  67569. */
  67570. get left(): NodeMaterialConnectionPoint;
  67571. /**
  67572. * Gets the right operand input component
  67573. */
  67574. get right(): NodeMaterialConnectionPoint;
  67575. /**
  67576. * Gets the output component
  67577. */
  67578. get output(): NodeMaterialConnectionPoint;
  67579. protected _buildBlock(state: NodeMaterialBuildState): this;
  67580. }
  67581. }
  67582. declare module BABYLON {
  67583. /**
  67584. * Block used to scale a vector by a float
  67585. */
  67586. export class ScaleBlock extends NodeMaterialBlock {
  67587. /**
  67588. * Creates a new ScaleBlock
  67589. * @param name defines the block name
  67590. */
  67591. constructor(name: string);
  67592. /**
  67593. * Gets the current class name
  67594. * @returns the class name
  67595. */
  67596. getClassName(): string;
  67597. /**
  67598. * Gets the input component
  67599. */
  67600. get input(): NodeMaterialConnectionPoint;
  67601. /**
  67602. * Gets the factor input component
  67603. */
  67604. get factor(): NodeMaterialConnectionPoint;
  67605. /**
  67606. * Gets the output component
  67607. */
  67608. get output(): NodeMaterialConnectionPoint;
  67609. protected _buildBlock(state: NodeMaterialBuildState): this;
  67610. }
  67611. }
  67612. declare module BABYLON {
  67613. /**
  67614. * Block used to clamp a float
  67615. */
  67616. export class ClampBlock extends NodeMaterialBlock {
  67617. /** Gets or sets the minimum range */
  67618. minimum: number;
  67619. /** Gets or sets the maximum range */
  67620. maximum: number;
  67621. /**
  67622. * Creates a new ClampBlock
  67623. * @param name defines the block name
  67624. */
  67625. constructor(name: string);
  67626. /**
  67627. * Gets the current class name
  67628. * @returns the class name
  67629. */
  67630. getClassName(): string;
  67631. /**
  67632. * Gets the value input component
  67633. */
  67634. get value(): NodeMaterialConnectionPoint;
  67635. /**
  67636. * Gets the output component
  67637. */
  67638. get output(): NodeMaterialConnectionPoint;
  67639. protected _buildBlock(state: NodeMaterialBuildState): this;
  67640. protected _dumpPropertiesCode(): string;
  67641. serialize(): any;
  67642. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67643. }
  67644. }
  67645. declare module BABYLON {
  67646. /**
  67647. * Block used to apply a cross product between 2 vectors
  67648. */
  67649. export class CrossBlock extends NodeMaterialBlock {
  67650. /**
  67651. * Creates a new CrossBlock
  67652. * @param name defines the block name
  67653. */
  67654. constructor(name: string);
  67655. /**
  67656. * Gets the current class name
  67657. * @returns the class name
  67658. */
  67659. getClassName(): string;
  67660. /**
  67661. * Gets the left operand input component
  67662. */
  67663. get left(): NodeMaterialConnectionPoint;
  67664. /**
  67665. * Gets the right operand input component
  67666. */
  67667. get right(): NodeMaterialConnectionPoint;
  67668. /**
  67669. * Gets the output component
  67670. */
  67671. get output(): NodeMaterialConnectionPoint;
  67672. protected _buildBlock(state: NodeMaterialBuildState): this;
  67673. }
  67674. }
  67675. declare module BABYLON {
  67676. /**
  67677. * Block used to apply a dot product between 2 vectors
  67678. */
  67679. export class DotBlock extends NodeMaterialBlock {
  67680. /**
  67681. * Creates a new DotBlock
  67682. * @param name defines the block name
  67683. */
  67684. constructor(name: string);
  67685. /**
  67686. * Gets the current class name
  67687. * @returns the class name
  67688. */
  67689. getClassName(): string;
  67690. /**
  67691. * Gets the left operand input component
  67692. */
  67693. get left(): NodeMaterialConnectionPoint;
  67694. /**
  67695. * Gets the right operand input component
  67696. */
  67697. get right(): NodeMaterialConnectionPoint;
  67698. /**
  67699. * Gets the output component
  67700. */
  67701. get output(): NodeMaterialConnectionPoint;
  67702. protected _buildBlock(state: NodeMaterialBuildState): this;
  67703. }
  67704. }
  67705. declare module BABYLON {
  67706. /**
  67707. * Block used to normalize a vector
  67708. */
  67709. export class NormalizeBlock extends NodeMaterialBlock {
  67710. /**
  67711. * Creates a new NormalizeBlock
  67712. * @param name defines the block name
  67713. */
  67714. constructor(name: string);
  67715. /**
  67716. * Gets the current class name
  67717. * @returns the class name
  67718. */
  67719. getClassName(): string;
  67720. /**
  67721. * Gets the input component
  67722. */
  67723. get input(): NodeMaterialConnectionPoint;
  67724. /**
  67725. * Gets the output component
  67726. */
  67727. get output(): NodeMaterialConnectionPoint;
  67728. protected _buildBlock(state: NodeMaterialBuildState): this;
  67729. }
  67730. }
  67731. declare module BABYLON {
  67732. /**
  67733. * Block used to create a Color3/4 out of individual inputs (one for each component)
  67734. */
  67735. export class ColorMergerBlock extends NodeMaterialBlock {
  67736. /**
  67737. * Create a new ColorMergerBlock
  67738. * @param name defines the block name
  67739. */
  67740. constructor(name: string);
  67741. /**
  67742. * Gets the current class name
  67743. * @returns the class name
  67744. */
  67745. getClassName(): string;
  67746. /**
  67747. * Gets the rgb component (input)
  67748. */
  67749. get rgbIn(): NodeMaterialConnectionPoint;
  67750. /**
  67751. * Gets the r component (input)
  67752. */
  67753. get r(): NodeMaterialConnectionPoint;
  67754. /**
  67755. * Gets the g component (input)
  67756. */
  67757. get g(): NodeMaterialConnectionPoint;
  67758. /**
  67759. * Gets the b component (input)
  67760. */
  67761. get b(): NodeMaterialConnectionPoint;
  67762. /**
  67763. * Gets the a component (input)
  67764. */
  67765. get a(): NodeMaterialConnectionPoint;
  67766. /**
  67767. * Gets the rgba component (output)
  67768. */
  67769. get rgba(): NodeMaterialConnectionPoint;
  67770. /**
  67771. * Gets the rgb component (output)
  67772. */
  67773. get rgbOut(): NodeMaterialConnectionPoint;
  67774. /**
  67775. * Gets the rgb component (output)
  67776. * @deprecated Please use rgbOut instead.
  67777. */
  67778. get rgb(): NodeMaterialConnectionPoint;
  67779. protected _buildBlock(state: NodeMaterialBuildState): this;
  67780. }
  67781. }
  67782. declare module BABYLON {
  67783. /**
  67784. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  67785. */
  67786. export class VectorSplitterBlock extends NodeMaterialBlock {
  67787. /**
  67788. * Create a new VectorSplitterBlock
  67789. * @param name defines the block name
  67790. */
  67791. constructor(name: string);
  67792. /**
  67793. * Gets the current class name
  67794. * @returns the class name
  67795. */
  67796. getClassName(): string;
  67797. /**
  67798. * Gets the xyzw component (input)
  67799. */
  67800. get xyzw(): NodeMaterialConnectionPoint;
  67801. /**
  67802. * Gets the xyz component (input)
  67803. */
  67804. get xyzIn(): NodeMaterialConnectionPoint;
  67805. /**
  67806. * Gets the xy component (input)
  67807. */
  67808. get xyIn(): NodeMaterialConnectionPoint;
  67809. /**
  67810. * Gets the xyz component (output)
  67811. */
  67812. get xyzOut(): NodeMaterialConnectionPoint;
  67813. /**
  67814. * Gets the xy component (output)
  67815. */
  67816. get xyOut(): NodeMaterialConnectionPoint;
  67817. /**
  67818. * Gets the x component (output)
  67819. */
  67820. get x(): NodeMaterialConnectionPoint;
  67821. /**
  67822. * Gets the y component (output)
  67823. */
  67824. get y(): NodeMaterialConnectionPoint;
  67825. /**
  67826. * Gets the z component (output)
  67827. */
  67828. get z(): NodeMaterialConnectionPoint;
  67829. /**
  67830. * Gets the w component (output)
  67831. */
  67832. get w(): NodeMaterialConnectionPoint;
  67833. protected _inputRename(name: string): string;
  67834. protected _outputRename(name: string): string;
  67835. protected _buildBlock(state: NodeMaterialBuildState): this;
  67836. }
  67837. }
  67838. declare module BABYLON {
  67839. /**
  67840. * Block used to lerp between 2 values
  67841. */
  67842. export class LerpBlock extends NodeMaterialBlock {
  67843. /**
  67844. * Creates a new LerpBlock
  67845. * @param name defines the block name
  67846. */
  67847. constructor(name: string);
  67848. /**
  67849. * Gets the current class name
  67850. * @returns the class name
  67851. */
  67852. getClassName(): string;
  67853. /**
  67854. * Gets the left operand input component
  67855. */
  67856. get left(): NodeMaterialConnectionPoint;
  67857. /**
  67858. * Gets the right operand input component
  67859. */
  67860. get right(): NodeMaterialConnectionPoint;
  67861. /**
  67862. * Gets the gradient operand input component
  67863. */
  67864. get gradient(): NodeMaterialConnectionPoint;
  67865. /**
  67866. * Gets the output component
  67867. */
  67868. get output(): NodeMaterialConnectionPoint;
  67869. protected _buildBlock(state: NodeMaterialBuildState): this;
  67870. }
  67871. }
  67872. declare module BABYLON {
  67873. /**
  67874. * Block used to divide 2 vectors
  67875. */
  67876. export class DivideBlock extends NodeMaterialBlock {
  67877. /**
  67878. * Creates a new DivideBlock
  67879. * @param name defines the block name
  67880. */
  67881. constructor(name: string);
  67882. /**
  67883. * Gets the current class name
  67884. * @returns the class name
  67885. */
  67886. getClassName(): string;
  67887. /**
  67888. * Gets the left operand input component
  67889. */
  67890. get left(): NodeMaterialConnectionPoint;
  67891. /**
  67892. * Gets the right operand input component
  67893. */
  67894. get right(): NodeMaterialConnectionPoint;
  67895. /**
  67896. * Gets the output component
  67897. */
  67898. get output(): NodeMaterialConnectionPoint;
  67899. protected _buildBlock(state: NodeMaterialBuildState): this;
  67900. }
  67901. }
  67902. declare module BABYLON {
  67903. /**
  67904. * Block used to subtract 2 vectors
  67905. */
  67906. export class SubtractBlock extends NodeMaterialBlock {
  67907. /**
  67908. * Creates a new SubtractBlock
  67909. * @param name defines the block name
  67910. */
  67911. constructor(name: string);
  67912. /**
  67913. * Gets the current class name
  67914. * @returns the class name
  67915. */
  67916. getClassName(): string;
  67917. /**
  67918. * Gets the left operand input component
  67919. */
  67920. get left(): NodeMaterialConnectionPoint;
  67921. /**
  67922. * Gets the right operand input component
  67923. */
  67924. get right(): NodeMaterialConnectionPoint;
  67925. /**
  67926. * Gets the output component
  67927. */
  67928. get output(): NodeMaterialConnectionPoint;
  67929. protected _buildBlock(state: NodeMaterialBuildState): this;
  67930. }
  67931. }
  67932. declare module BABYLON {
  67933. /**
  67934. * Block used to step a value
  67935. */
  67936. export class StepBlock extends NodeMaterialBlock {
  67937. /**
  67938. * Creates a new StepBlock
  67939. * @param name defines the block name
  67940. */
  67941. constructor(name: string);
  67942. /**
  67943. * Gets the current class name
  67944. * @returns the class name
  67945. */
  67946. getClassName(): string;
  67947. /**
  67948. * Gets the value operand input component
  67949. */
  67950. get value(): NodeMaterialConnectionPoint;
  67951. /**
  67952. * Gets the edge operand input component
  67953. */
  67954. get edge(): NodeMaterialConnectionPoint;
  67955. /**
  67956. * Gets the output component
  67957. */
  67958. get output(): NodeMaterialConnectionPoint;
  67959. protected _buildBlock(state: NodeMaterialBuildState): this;
  67960. }
  67961. }
  67962. declare module BABYLON {
  67963. /**
  67964. * Block used to get the opposite (1 - x) of a value
  67965. */
  67966. export class OneMinusBlock extends NodeMaterialBlock {
  67967. /**
  67968. * Creates a new OneMinusBlock
  67969. * @param name defines the block name
  67970. */
  67971. constructor(name: string);
  67972. /**
  67973. * Gets the current class name
  67974. * @returns the class name
  67975. */
  67976. getClassName(): string;
  67977. /**
  67978. * Gets the input component
  67979. */
  67980. get input(): NodeMaterialConnectionPoint;
  67981. /**
  67982. * Gets the output component
  67983. */
  67984. get output(): NodeMaterialConnectionPoint;
  67985. protected _buildBlock(state: NodeMaterialBuildState): this;
  67986. }
  67987. }
  67988. declare module BABYLON {
  67989. /**
  67990. * Block used to get the view direction
  67991. */
  67992. export class ViewDirectionBlock extends NodeMaterialBlock {
  67993. /**
  67994. * Creates a new ViewDirectionBlock
  67995. * @param name defines the block name
  67996. */
  67997. constructor(name: string);
  67998. /**
  67999. * Gets the current class name
  68000. * @returns the class name
  68001. */
  68002. getClassName(): string;
  68003. /**
  68004. * Gets the world position component
  68005. */
  68006. get worldPosition(): NodeMaterialConnectionPoint;
  68007. /**
  68008. * Gets the camera position component
  68009. */
  68010. get cameraPosition(): NodeMaterialConnectionPoint;
  68011. /**
  68012. * Gets the output component
  68013. */
  68014. get output(): NodeMaterialConnectionPoint;
  68015. autoConfigure(material: NodeMaterial): void;
  68016. protected _buildBlock(state: NodeMaterialBuildState): this;
  68017. }
  68018. }
  68019. declare module BABYLON {
  68020. /**
  68021. * Block used to compute fresnel value
  68022. */
  68023. export class FresnelBlock extends NodeMaterialBlock {
  68024. /**
  68025. * Create a new FresnelBlock
  68026. * @param name defines the block name
  68027. */
  68028. constructor(name: string);
  68029. /**
  68030. * Gets the current class name
  68031. * @returns the class name
  68032. */
  68033. getClassName(): string;
  68034. /**
  68035. * Gets the world normal input component
  68036. */
  68037. get worldNormal(): NodeMaterialConnectionPoint;
  68038. /**
  68039. * Gets the view direction input component
  68040. */
  68041. get viewDirection(): NodeMaterialConnectionPoint;
  68042. /**
  68043. * Gets the bias input component
  68044. */
  68045. get bias(): NodeMaterialConnectionPoint;
  68046. /**
  68047. * Gets the camera (or eye) position component
  68048. */
  68049. get power(): NodeMaterialConnectionPoint;
  68050. /**
  68051. * Gets the fresnel output component
  68052. */
  68053. get fresnel(): NodeMaterialConnectionPoint;
  68054. autoConfigure(material: NodeMaterial): void;
  68055. protected _buildBlock(state: NodeMaterialBuildState): this;
  68056. }
  68057. }
  68058. declare module BABYLON {
  68059. /**
  68060. * Block used to get the max of 2 values
  68061. */
  68062. export class MaxBlock extends NodeMaterialBlock {
  68063. /**
  68064. * Creates a new MaxBlock
  68065. * @param name defines the block name
  68066. */
  68067. constructor(name: string);
  68068. /**
  68069. * Gets the current class name
  68070. * @returns the class name
  68071. */
  68072. getClassName(): string;
  68073. /**
  68074. * Gets the left operand input component
  68075. */
  68076. get left(): NodeMaterialConnectionPoint;
  68077. /**
  68078. * Gets the right operand input component
  68079. */
  68080. get right(): NodeMaterialConnectionPoint;
  68081. /**
  68082. * Gets the output component
  68083. */
  68084. get output(): NodeMaterialConnectionPoint;
  68085. protected _buildBlock(state: NodeMaterialBuildState): this;
  68086. }
  68087. }
  68088. declare module BABYLON {
  68089. /**
  68090. * Block used to get the min of 2 values
  68091. */
  68092. export class MinBlock extends NodeMaterialBlock {
  68093. /**
  68094. * Creates a new MinBlock
  68095. * @param name defines the block name
  68096. */
  68097. constructor(name: string);
  68098. /**
  68099. * Gets the current class name
  68100. * @returns the class name
  68101. */
  68102. getClassName(): string;
  68103. /**
  68104. * Gets the left operand input component
  68105. */
  68106. get left(): NodeMaterialConnectionPoint;
  68107. /**
  68108. * Gets the right operand input component
  68109. */
  68110. get right(): NodeMaterialConnectionPoint;
  68111. /**
  68112. * Gets the output component
  68113. */
  68114. get output(): NodeMaterialConnectionPoint;
  68115. protected _buildBlock(state: NodeMaterialBuildState): this;
  68116. }
  68117. }
  68118. declare module BABYLON {
  68119. /**
  68120. * Block used to get the distance between 2 values
  68121. */
  68122. export class DistanceBlock extends NodeMaterialBlock {
  68123. /**
  68124. * Creates a new DistanceBlock
  68125. * @param name defines the block name
  68126. */
  68127. constructor(name: string);
  68128. /**
  68129. * Gets the current class name
  68130. * @returns the class name
  68131. */
  68132. getClassName(): string;
  68133. /**
  68134. * Gets the left operand input component
  68135. */
  68136. get left(): NodeMaterialConnectionPoint;
  68137. /**
  68138. * Gets the right operand input component
  68139. */
  68140. get right(): NodeMaterialConnectionPoint;
  68141. /**
  68142. * Gets the output component
  68143. */
  68144. get output(): NodeMaterialConnectionPoint;
  68145. protected _buildBlock(state: NodeMaterialBuildState): this;
  68146. }
  68147. }
  68148. declare module BABYLON {
  68149. /**
  68150. * Block used to get the length of a vector
  68151. */
  68152. export class LengthBlock extends NodeMaterialBlock {
  68153. /**
  68154. * Creates a new LengthBlock
  68155. * @param name defines the block name
  68156. */
  68157. constructor(name: string);
  68158. /**
  68159. * Gets the current class name
  68160. * @returns the class name
  68161. */
  68162. getClassName(): string;
  68163. /**
  68164. * Gets the value input component
  68165. */
  68166. get value(): NodeMaterialConnectionPoint;
  68167. /**
  68168. * Gets the output component
  68169. */
  68170. get output(): NodeMaterialConnectionPoint;
  68171. protected _buildBlock(state: NodeMaterialBuildState): this;
  68172. }
  68173. }
  68174. declare module BABYLON {
  68175. /**
  68176. * Block used to get negative version of a value (i.e. x * -1)
  68177. */
  68178. export class NegateBlock extends NodeMaterialBlock {
  68179. /**
  68180. * Creates a new NegateBlock
  68181. * @param name defines the block name
  68182. */
  68183. constructor(name: string);
  68184. /**
  68185. * Gets the current class name
  68186. * @returns the class name
  68187. */
  68188. getClassName(): string;
  68189. /**
  68190. * Gets the value input component
  68191. */
  68192. get value(): NodeMaterialConnectionPoint;
  68193. /**
  68194. * Gets the output component
  68195. */
  68196. get output(): NodeMaterialConnectionPoint;
  68197. protected _buildBlock(state: NodeMaterialBuildState): this;
  68198. }
  68199. }
  68200. declare module BABYLON {
  68201. /**
  68202. * Block used to get the value of the first parameter raised to the power of the second
  68203. */
  68204. export class PowBlock extends NodeMaterialBlock {
  68205. /**
  68206. * Creates a new PowBlock
  68207. * @param name defines the block name
  68208. */
  68209. constructor(name: string);
  68210. /**
  68211. * Gets the current class name
  68212. * @returns the class name
  68213. */
  68214. getClassName(): string;
  68215. /**
  68216. * Gets the value operand input component
  68217. */
  68218. get value(): NodeMaterialConnectionPoint;
  68219. /**
  68220. * Gets the power operand input component
  68221. */
  68222. get power(): NodeMaterialConnectionPoint;
  68223. /**
  68224. * Gets the output component
  68225. */
  68226. get output(): NodeMaterialConnectionPoint;
  68227. protected _buildBlock(state: NodeMaterialBuildState): this;
  68228. }
  68229. }
  68230. declare module BABYLON {
  68231. /**
  68232. * Block used to get a random number
  68233. */
  68234. export class RandomNumberBlock extends NodeMaterialBlock {
  68235. /**
  68236. * Creates a new RandomNumberBlock
  68237. * @param name defines the block name
  68238. */
  68239. constructor(name: string);
  68240. /**
  68241. * Gets the current class name
  68242. * @returns the class name
  68243. */
  68244. getClassName(): string;
  68245. /**
  68246. * Gets the seed input component
  68247. */
  68248. get seed(): NodeMaterialConnectionPoint;
  68249. /**
  68250. * Gets the output component
  68251. */
  68252. get output(): NodeMaterialConnectionPoint;
  68253. protected _buildBlock(state: NodeMaterialBuildState): this;
  68254. }
  68255. }
  68256. declare module BABYLON {
  68257. /**
  68258. * Block used to compute arc tangent of 2 values
  68259. */
  68260. export class ArcTan2Block extends NodeMaterialBlock {
  68261. /**
  68262. * Creates a new ArcTan2Block
  68263. * @param name defines the block name
  68264. */
  68265. constructor(name: string);
  68266. /**
  68267. * Gets the current class name
  68268. * @returns the class name
  68269. */
  68270. getClassName(): string;
  68271. /**
  68272. * Gets the x operand input component
  68273. */
  68274. get x(): NodeMaterialConnectionPoint;
  68275. /**
  68276. * Gets the y operand input component
  68277. */
  68278. get y(): NodeMaterialConnectionPoint;
  68279. /**
  68280. * Gets the output component
  68281. */
  68282. get output(): NodeMaterialConnectionPoint;
  68283. protected _buildBlock(state: NodeMaterialBuildState): this;
  68284. }
  68285. }
  68286. declare module BABYLON {
  68287. /**
  68288. * Block used to smooth step a value
  68289. */
  68290. export class SmoothStepBlock extends NodeMaterialBlock {
  68291. /**
  68292. * Creates a new SmoothStepBlock
  68293. * @param name defines the block name
  68294. */
  68295. constructor(name: string);
  68296. /**
  68297. * Gets the current class name
  68298. * @returns the class name
  68299. */
  68300. getClassName(): string;
  68301. /**
  68302. * Gets the value operand input component
  68303. */
  68304. get value(): NodeMaterialConnectionPoint;
  68305. /**
  68306. * Gets the first edge operand input component
  68307. */
  68308. get edge0(): NodeMaterialConnectionPoint;
  68309. /**
  68310. * Gets the second edge operand input component
  68311. */
  68312. get edge1(): NodeMaterialConnectionPoint;
  68313. /**
  68314. * Gets the output component
  68315. */
  68316. get output(): NodeMaterialConnectionPoint;
  68317. protected _buildBlock(state: NodeMaterialBuildState): this;
  68318. }
  68319. }
  68320. declare module BABYLON {
  68321. /**
  68322. * Block used to get the reciprocal (1 / x) of a value
  68323. */
  68324. export class ReciprocalBlock extends NodeMaterialBlock {
  68325. /**
  68326. * Creates a new ReciprocalBlock
  68327. * @param name defines the block name
  68328. */
  68329. constructor(name: string);
  68330. /**
  68331. * Gets the current class name
  68332. * @returns the class name
  68333. */
  68334. getClassName(): string;
  68335. /**
  68336. * Gets the input component
  68337. */
  68338. get input(): NodeMaterialConnectionPoint;
  68339. /**
  68340. * Gets the output component
  68341. */
  68342. get output(): NodeMaterialConnectionPoint;
  68343. protected _buildBlock(state: NodeMaterialBuildState): this;
  68344. }
  68345. }
  68346. declare module BABYLON {
  68347. /**
  68348. * Block used to replace a color by another one
  68349. */
  68350. export class ReplaceColorBlock extends NodeMaterialBlock {
  68351. /**
  68352. * Creates a new ReplaceColorBlock
  68353. * @param name defines the block name
  68354. */
  68355. constructor(name: string);
  68356. /**
  68357. * Gets the current class name
  68358. * @returns the class name
  68359. */
  68360. getClassName(): string;
  68361. /**
  68362. * Gets the value input component
  68363. */
  68364. get value(): NodeMaterialConnectionPoint;
  68365. /**
  68366. * Gets the reference input component
  68367. */
  68368. get reference(): NodeMaterialConnectionPoint;
  68369. /**
  68370. * Gets the distance input component
  68371. */
  68372. get distance(): NodeMaterialConnectionPoint;
  68373. /**
  68374. * Gets the replacement input component
  68375. */
  68376. get replacement(): NodeMaterialConnectionPoint;
  68377. /**
  68378. * Gets the output component
  68379. */
  68380. get output(): NodeMaterialConnectionPoint;
  68381. protected _buildBlock(state: NodeMaterialBuildState): this;
  68382. }
  68383. }
  68384. declare module BABYLON {
  68385. /**
  68386. * Block used to posterize a value
  68387. * @see https://en.wikipedia.org/wiki/Posterization
  68388. */
  68389. export class PosterizeBlock extends NodeMaterialBlock {
  68390. /**
  68391. * Creates a new PosterizeBlock
  68392. * @param name defines the block name
  68393. */
  68394. constructor(name: string);
  68395. /**
  68396. * Gets the current class name
  68397. * @returns the class name
  68398. */
  68399. getClassName(): string;
  68400. /**
  68401. * Gets the value input component
  68402. */
  68403. get value(): NodeMaterialConnectionPoint;
  68404. /**
  68405. * Gets the steps input component
  68406. */
  68407. get steps(): NodeMaterialConnectionPoint;
  68408. /**
  68409. * Gets the output component
  68410. */
  68411. get output(): NodeMaterialConnectionPoint;
  68412. protected _buildBlock(state: NodeMaterialBuildState): this;
  68413. }
  68414. }
  68415. declare module BABYLON {
  68416. /**
  68417. * Operations supported by the Wave block
  68418. */
  68419. export enum WaveBlockKind {
  68420. /** SawTooth */
  68421. SawTooth = 0,
  68422. /** Square */
  68423. Square = 1,
  68424. /** Triangle */
  68425. Triangle = 2
  68426. }
  68427. /**
  68428. * Block used to apply wave operation to floats
  68429. */
  68430. export class WaveBlock extends NodeMaterialBlock {
  68431. /**
  68432. * Gets or sets the kibnd of wave to be applied by the block
  68433. */
  68434. kind: WaveBlockKind;
  68435. /**
  68436. * Creates a new WaveBlock
  68437. * @param name defines the block name
  68438. */
  68439. constructor(name: string);
  68440. /**
  68441. * Gets the current class name
  68442. * @returns the class name
  68443. */
  68444. getClassName(): string;
  68445. /**
  68446. * Gets the input component
  68447. */
  68448. get input(): NodeMaterialConnectionPoint;
  68449. /**
  68450. * Gets the output component
  68451. */
  68452. get output(): NodeMaterialConnectionPoint;
  68453. protected _buildBlock(state: NodeMaterialBuildState): this;
  68454. serialize(): any;
  68455. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  68456. }
  68457. }
  68458. declare module BABYLON {
  68459. /**
  68460. * Class used to store a color step for the GradientBlock
  68461. */
  68462. export class GradientBlockColorStep {
  68463. private _step;
  68464. /**
  68465. * Gets value indicating which step this color is associated with (between 0 and 1)
  68466. */
  68467. get step(): number;
  68468. /**
  68469. * Sets a value indicating which step this color is associated with (between 0 and 1)
  68470. */
  68471. set step(val: number);
  68472. private _color;
  68473. /**
  68474. * Gets the color associated with this step
  68475. */
  68476. get color(): Color3;
  68477. /**
  68478. * Sets the color associated with this step
  68479. */
  68480. set color(val: Color3);
  68481. /**
  68482. * Creates a new GradientBlockColorStep
  68483. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  68484. * @param color defines the color associated with this step
  68485. */
  68486. constructor(step: number, color: Color3);
  68487. }
  68488. /**
  68489. * Block used to return a color from a gradient based on an input value between 0 and 1
  68490. */
  68491. export class GradientBlock extends NodeMaterialBlock {
  68492. /**
  68493. * Gets or sets the list of color steps
  68494. */
  68495. colorSteps: GradientBlockColorStep[];
  68496. /** Gets an observable raised when the value is changed */
  68497. onValueChangedObservable: Observable<GradientBlock>;
  68498. /** calls observable when the value is changed*/
  68499. colorStepsUpdated(): void;
  68500. /**
  68501. * Creates a new GradientBlock
  68502. * @param name defines the block name
  68503. */
  68504. constructor(name: string);
  68505. /**
  68506. * Gets the current class name
  68507. * @returns the class name
  68508. */
  68509. getClassName(): string;
  68510. /**
  68511. * Gets the gradient input component
  68512. */
  68513. get gradient(): NodeMaterialConnectionPoint;
  68514. /**
  68515. * Gets the output component
  68516. */
  68517. get output(): NodeMaterialConnectionPoint;
  68518. private _writeColorConstant;
  68519. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  68520. serialize(): any;
  68521. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  68522. protected _dumpPropertiesCode(): string;
  68523. }
  68524. }
  68525. declare module BABYLON {
  68526. /**
  68527. * Block used to normalize lerp between 2 values
  68528. */
  68529. export class NLerpBlock extends NodeMaterialBlock {
  68530. /**
  68531. * Creates a new NLerpBlock
  68532. * @param name defines the block name
  68533. */
  68534. constructor(name: string);
  68535. /**
  68536. * Gets the current class name
  68537. * @returns the class name
  68538. */
  68539. getClassName(): string;
  68540. /**
  68541. * Gets the left operand input component
  68542. */
  68543. get left(): NodeMaterialConnectionPoint;
  68544. /**
  68545. * Gets the right operand input component
  68546. */
  68547. get right(): NodeMaterialConnectionPoint;
  68548. /**
  68549. * Gets the gradient operand input component
  68550. */
  68551. get gradient(): NodeMaterialConnectionPoint;
  68552. /**
  68553. * Gets the output component
  68554. */
  68555. get output(): NodeMaterialConnectionPoint;
  68556. protected _buildBlock(state: NodeMaterialBuildState): this;
  68557. }
  68558. }
  68559. declare module BABYLON {
  68560. /**
  68561. * block used to Generate a Worley Noise 3D Noise Pattern
  68562. */
  68563. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  68564. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  68565. manhattanDistance: boolean;
  68566. /**
  68567. * Creates a new WorleyNoise3DBlock
  68568. * @param name defines the block name
  68569. */
  68570. constructor(name: string);
  68571. /**
  68572. * Gets the current class name
  68573. * @returns the class name
  68574. */
  68575. getClassName(): string;
  68576. /**
  68577. * Gets the seed input component
  68578. */
  68579. get seed(): NodeMaterialConnectionPoint;
  68580. /**
  68581. * Gets the jitter input component
  68582. */
  68583. get jitter(): NodeMaterialConnectionPoint;
  68584. /**
  68585. * Gets the output component
  68586. */
  68587. get output(): NodeMaterialConnectionPoint;
  68588. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  68589. /**
  68590. * Exposes the properties to the UI?
  68591. */
  68592. protected _dumpPropertiesCode(): string;
  68593. /**
  68594. * Exposes the properties to the Seralize?
  68595. */
  68596. serialize(): any;
  68597. /**
  68598. * Exposes the properties to the deseralize?
  68599. */
  68600. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  68601. }
  68602. }
  68603. declare module BABYLON {
  68604. /**
  68605. * block used to Generate a Simplex Perlin 3d Noise Pattern
  68606. */
  68607. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  68608. /**
  68609. * Creates a new SimplexPerlin3DBlock
  68610. * @param name defines the block name
  68611. */
  68612. constructor(name: string);
  68613. /**
  68614. * Gets the current class name
  68615. * @returns the class name
  68616. */
  68617. getClassName(): string;
  68618. /**
  68619. * Gets the seed operand input component
  68620. */
  68621. get seed(): NodeMaterialConnectionPoint;
  68622. /**
  68623. * Gets the output component
  68624. */
  68625. get output(): NodeMaterialConnectionPoint;
  68626. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  68627. }
  68628. }
  68629. declare module BABYLON {
  68630. /**
  68631. * Block used to blend normals
  68632. */
  68633. export class NormalBlendBlock extends NodeMaterialBlock {
  68634. /**
  68635. * Creates a new NormalBlendBlock
  68636. * @param name defines the block name
  68637. */
  68638. constructor(name: string);
  68639. /**
  68640. * Gets the current class name
  68641. * @returns the class name
  68642. */
  68643. getClassName(): string;
  68644. /**
  68645. * Gets the first input component
  68646. */
  68647. get normalMap0(): NodeMaterialConnectionPoint;
  68648. /**
  68649. * Gets the second input component
  68650. */
  68651. get normalMap1(): NodeMaterialConnectionPoint;
  68652. /**
  68653. * Gets the output component
  68654. */
  68655. get output(): NodeMaterialConnectionPoint;
  68656. protected _buildBlock(state: NodeMaterialBuildState): this;
  68657. }
  68658. }
  68659. declare module BABYLON {
  68660. /**
  68661. * Block used to rotate a 2d vector by a given angle
  68662. */
  68663. export class Rotate2dBlock extends NodeMaterialBlock {
  68664. /**
  68665. * Creates a new Rotate2dBlock
  68666. * @param name defines the block name
  68667. */
  68668. constructor(name: string);
  68669. /**
  68670. * Gets the current class name
  68671. * @returns the class name
  68672. */
  68673. getClassName(): string;
  68674. /**
  68675. * Gets the input vector
  68676. */
  68677. get input(): NodeMaterialConnectionPoint;
  68678. /**
  68679. * Gets the input angle
  68680. */
  68681. get angle(): NodeMaterialConnectionPoint;
  68682. /**
  68683. * Gets the output component
  68684. */
  68685. get output(): NodeMaterialConnectionPoint;
  68686. autoConfigure(material: NodeMaterial): void;
  68687. protected _buildBlock(state: NodeMaterialBuildState): this;
  68688. }
  68689. }
  68690. declare module BABYLON {
  68691. /**
  68692. * Block used to get the reflected vector from a direction and a normal
  68693. */
  68694. export class ReflectBlock extends NodeMaterialBlock {
  68695. /**
  68696. * Creates a new ReflectBlock
  68697. * @param name defines the block name
  68698. */
  68699. constructor(name: string);
  68700. /**
  68701. * Gets the current class name
  68702. * @returns the class name
  68703. */
  68704. getClassName(): string;
  68705. /**
  68706. * Gets the incident component
  68707. */
  68708. get incident(): NodeMaterialConnectionPoint;
  68709. /**
  68710. * Gets the normal component
  68711. */
  68712. get normal(): NodeMaterialConnectionPoint;
  68713. /**
  68714. * Gets the output component
  68715. */
  68716. get output(): NodeMaterialConnectionPoint;
  68717. protected _buildBlock(state: NodeMaterialBuildState): this;
  68718. }
  68719. }
  68720. declare module BABYLON {
  68721. /**
  68722. * Block used to get the refracted vector from a direction and a normal
  68723. */
  68724. export class RefractBlock extends NodeMaterialBlock {
  68725. /**
  68726. * Creates a new RefractBlock
  68727. * @param name defines the block name
  68728. */
  68729. constructor(name: string);
  68730. /**
  68731. * Gets the current class name
  68732. * @returns the class name
  68733. */
  68734. getClassName(): string;
  68735. /**
  68736. * Gets the incident component
  68737. */
  68738. get incident(): NodeMaterialConnectionPoint;
  68739. /**
  68740. * Gets the normal component
  68741. */
  68742. get normal(): NodeMaterialConnectionPoint;
  68743. /**
  68744. * Gets the index of refraction component
  68745. */
  68746. get ior(): NodeMaterialConnectionPoint;
  68747. /**
  68748. * Gets the output component
  68749. */
  68750. get output(): NodeMaterialConnectionPoint;
  68751. protected _buildBlock(state: NodeMaterialBuildState): this;
  68752. }
  68753. }
  68754. declare module BABYLON {
  68755. /**
  68756. * Block used to desaturate a color
  68757. */
  68758. export class DesaturateBlock extends NodeMaterialBlock {
  68759. /**
  68760. * Creates a new DesaturateBlock
  68761. * @param name defines the block name
  68762. */
  68763. constructor(name: string);
  68764. /**
  68765. * Gets the current class name
  68766. * @returns the class name
  68767. */
  68768. getClassName(): string;
  68769. /**
  68770. * Gets the color operand input component
  68771. */
  68772. get color(): NodeMaterialConnectionPoint;
  68773. /**
  68774. * Gets the level operand input component
  68775. */
  68776. get level(): NodeMaterialConnectionPoint;
  68777. /**
  68778. * Gets the output component
  68779. */
  68780. get output(): NodeMaterialConnectionPoint;
  68781. protected _buildBlock(state: NodeMaterialBuildState): this;
  68782. }
  68783. }
  68784. declare module BABYLON {
  68785. /**
  68786. * Block used to implement the reflection module of the PBR material
  68787. */
  68788. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  68789. /** @hidden */
  68790. _defineLODReflectionAlpha: string;
  68791. /** @hidden */
  68792. _defineLinearSpecularReflection: string;
  68793. private _vEnvironmentIrradianceName;
  68794. /** @hidden */
  68795. _vReflectionMicrosurfaceInfosName: string;
  68796. /** @hidden */
  68797. _vReflectionInfosName: string;
  68798. /** @hidden */
  68799. _vReflectionFilteringInfoName: string;
  68800. private _scene;
  68801. /**
  68802. * The properties below are set by the main PBR block prior to calling methods of this class.
  68803. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  68804. * It's less burden on the user side in the editor part.
  68805. */
  68806. /** @hidden */
  68807. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  68808. /** @hidden */
  68809. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  68810. /** @hidden */
  68811. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  68812. /** @hidden */
  68813. viewConnectionPoint: NodeMaterialConnectionPoint;
  68814. /**
  68815. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  68816. * diffuse part of the IBL.
  68817. */
  68818. useSphericalHarmonics: boolean;
  68819. /**
  68820. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  68821. */
  68822. forceIrradianceInFragment: boolean;
  68823. /**
  68824. * Create a new ReflectionBlock
  68825. * @param name defines the block name
  68826. */
  68827. constructor(name: string);
  68828. /**
  68829. * Gets the current class name
  68830. * @returns the class name
  68831. */
  68832. getClassName(): string;
  68833. /**
  68834. * Gets the position input component
  68835. */
  68836. get position(): NodeMaterialConnectionPoint;
  68837. /**
  68838. * Gets the world position input component
  68839. */
  68840. get worldPosition(): NodeMaterialConnectionPoint;
  68841. /**
  68842. * Gets the world normal input component
  68843. */
  68844. get worldNormal(): NodeMaterialConnectionPoint;
  68845. /**
  68846. * Gets the world input component
  68847. */
  68848. get world(): NodeMaterialConnectionPoint;
  68849. /**
  68850. * Gets the camera (or eye) position component
  68851. */
  68852. get cameraPosition(): NodeMaterialConnectionPoint;
  68853. /**
  68854. * Gets the view input component
  68855. */
  68856. get view(): NodeMaterialConnectionPoint;
  68857. /**
  68858. * Gets the color input component
  68859. */
  68860. get color(): NodeMaterialConnectionPoint;
  68861. /**
  68862. * Gets the reflection object output component
  68863. */
  68864. get reflection(): NodeMaterialConnectionPoint;
  68865. /**
  68866. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  68867. */
  68868. get hasTexture(): boolean;
  68869. /**
  68870. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  68871. */
  68872. get reflectionColor(): string;
  68873. protected _getTexture(): Nullable<BaseTexture>;
  68874. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  68875. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  68876. /**
  68877. * Gets the code to inject in the vertex shader
  68878. * @param state current state of the node material building
  68879. * @returns the shader code
  68880. */
  68881. handleVertexSide(state: NodeMaterialBuildState): string;
  68882. /**
  68883. * Gets the main code of the block (fragment side)
  68884. * @param state current state of the node material building
  68885. * @param normalVarName name of the existing variable corresponding to the normal
  68886. * @returns the shader code
  68887. */
  68888. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  68889. protected _buildBlock(state: NodeMaterialBuildState): this;
  68890. protected _dumpPropertiesCode(): string;
  68891. serialize(): any;
  68892. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  68893. }
  68894. }
  68895. declare module BABYLON {
  68896. /**
  68897. * Block used to implement the sheen module of the PBR material
  68898. */
  68899. export class SheenBlock extends NodeMaterialBlock {
  68900. /**
  68901. * Create a new SheenBlock
  68902. * @param name defines the block name
  68903. */
  68904. constructor(name: string);
  68905. /**
  68906. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  68907. * It allows the strength of the sheen effect to not depend on the base color of the material,
  68908. * making it easier to setup and tweak the effect
  68909. */
  68910. albedoScaling: boolean;
  68911. /**
  68912. * Defines if the sheen is linked to the sheen color.
  68913. */
  68914. linkSheenWithAlbedo: boolean;
  68915. /**
  68916. * Initialize the block and prepare the context for build
  68917. * @param state defines the state that will be used for the build
  68918. */
  68919. initialize(state: NodeMaterialBuildState): void;
  68920. /**
  68921. * Gets the current class name
  68922. * @returns the class name
  68923. */
  68924. getClassName(): string;
  68925. /**
  68926. * Gets the intensity input component
  68927. */
  68928. get intensity(): NodeMaterialConnectionPoint;
  68929. /**
  68930. * Gets the color input component
  68931. */
  68932. get color(): NodeMaterialConnectionPoint;
  68933. /**
  68934. * Gets the roughness input component
  68935. */
  68936. get roughness(): NodeMaterialConnectionPoint;
  68937. /**
  68938. * Gets the sheen object output component
  68939. */
  68940. get sheen(): NodeMaterialConnectionPoint;
  68941. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  68942. /**
  68943. * Gets the main code of the block (fragment side)
  68944. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  68945. * @returns the shader code
  68946. */
  68947. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  68948. protected _buildBlock(state: NodeMaterialBuildState): this;
  68949. protected _dumpPropertiesCode(): string;
  68950. serialize(): any;
  68951. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  68952. }
  68953. }
  68954. declare module BABYLON {
  68955. /**
  68956. * Block used to implement the anisotropy module of the PBR material
  68957. */
  68958. export class AnisotropyBlock extends NodeMaterialBlock {
  68959. /**
  68960. * The two properties below are set by the main PBR block prior to calling methods of this class.
  68961. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  68962. * It's less burden on the user side in the editor part.
  68963. */
  68964. /** @hidden */
  68965. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  68966. /** @hidden */
  68967. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  68968. /**
  68969. * Create a new AnisotropyBlock
  68970. * @param name defines the block name
  68971. */
  68972. constructor(name: string);
  68973. /**
  68974. * Initialize the block and prepare the context for build
  68975. * @param state defines the state that will be used for the build
  68976. */
  68977. initialize(state: NodeMaterialBuildState): void;
  68978. /**
  68979. * Gets the current class name
  68980. * @returns the class name
  68981. */
  68982. getClassName(): string;
  68983. /**
  68984. * Gets the intensity input component
  68985. */
  68986. get intensity(): NodeMaterialConnectionPoint;
  68987. /**
  68988. * Gets the direction input component
  68989. */
  68990. get direction(): NodeMaterialConnectionPoint;
  68991. /**
  68992. * Gets the uv input component
  68993. */
  68994. get uv(): NodeMaterialConnectionPoint;
  68995. /**
  68996. * Gets the worldTangent input component
  68997. */
  68998. get worldTangent(): NodeMaterialConnectionPoint;
  68999. /**
  69000. * Gets the anisotropy object output component
  69001. */
  69002. get anisotropy(): NodeMaterialConnectionPoint;
  69003. private _generateTBNSpace;
  69004. /**
  69005. * Gets the main code of the block (fragment side)
  69006. * @param state current state of the node material building
  69007. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  69008. * @returns the shader code
  69009. */
  69010. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  69011. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  69012. protected _buildBlock(state: NodeMaterialBuildState): this;
  69013. }
  69014. }
  69015. declare module BABYLON {
  69016. /**
  69017. * Block used to implement the clear coat module of the PBR material
  69018. */
  69019. export class ClearCoatBlock extends NodeMaterialBlock {
  69020. private _scene;
  69021. /**
  69022. * Create a new ClearCoatBlock
  69023. * @param name defines the block name
  69024. */
  69025. constructor(name: string);
  69026. /**
  69027. * Defines if the F0 value should be remapped to account for the interface change in the material.
  69028. */
  69029. remapF0OnInterfaceChange: boolean;
  69030. /**
  69031. * Initialize the block and prepare the context for build
  69032. * @param state defines the state that will be used for the build
  69033. */
  69034. initialize(state: NodeMaterialBuildState): void;
  69035. /**
  69036. * Gets the current class name
  69037. * @returns the class name
  69038. */
  69039. getClassName(): string;
  69040. /**
  69041. * Gets the intensity input component
  69042. */
  69043. get intensity(): NodeMaterialConnectionPoint;
  69044. /**
  69045. * Gets the roughness input component
  69046. */
  69047. get roughness(): NodeMaterialConnectionPoint;
  69048. /**
  69049. * Gets the ior input component
  69050. */
  69051. get indexOfRefraction(): NodeMaterialConnectionPoint;
  69052. /**
  69053. * Gets the bump texture input component
  69054. */
  69055. get normalMapColor(): NodeMaterialConnectionPoint;
  69056. /**
  69057. * Gets the uv input component
  69058. */
  69059. get uv(): NodeMaterialConnectionPoint;
  69060. /**
  69061. * Gets the tint color input component
  69062. */
  69063. get tintColor(): NodeMaterialConnectionPoint;
  69064. /**
  69065. * Gets the tint "at distance" input component
  69066. */
  69067. get tintAtDistance(): NodeMaterialConnectionPoint;
  69068. /**
  69069. * Gets the tint thickness input component
  69070. */
  69071. get tintThickness(): NodeMaterialConnectionPoint;
  69072. /**
  69073. * Gets the world tangent input component
  69074. */
  69075. get worldTangent(): NodeMaterialConnectionPoint;
  69076. /**
  69077. * Gets the clear coat object output component
  69078. */
  69079. get clearcoat(): NodeMaterialConnectionPoint;
  69080. autoConfigure(material: NodeMaterial): void;
  69081. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  69082. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  69083. private _generateTBNSpace;
  69084. /**
  69085. * Gets the main code of the block (fragment side)
  69086. * @param state current state of the node material building
  69087. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  69088. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  69089. * @param worldPosVarName name of the variable holding the world position
  69090. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  69091. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  69092. * @param worldNormalVarName name of the variable holding the world normal
  69093. * @returns the shader code
  69094. */
  69095. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  69096. protected _buildBlock(state: NodeMaterialBuildState): this;
  69097. protected _dumpPropertiesCode(): string;
  69098. serialize(): any;
  69099. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  69100. }
  69101. }
  69102. declare module BABYLON {
  69103. /**
  69104. * Block used to implement the sub surface module of the PBR material
  69105. */
  69106. export class SubSurfaceBlock extends NodeMaterialBlock {
  69107. /**
  69108. * Create a new SubSurfaceBlock
  69109. * @param name defines the block name
  69110. */
  69111. constructor(name: string);
  69112. /**
  69113. * Initialize the block and prepare the context for build
  69114. * @param state defines the state that will be used for the build
  69115. */
  69116. initialize(state: NodeMaterialBuildState): void;
  69117. /**
  69118. * Gets the current class name
  69119. * @returns the class name
  69120. */
  69121. getClassName(): string;
  69122. /**
  69123. * Gets the thickness component
  69124. */
  69125. get thickness(): NodeMaterialConnectionPoint;
  69126. /**
  69127. * Gets the tint color input component
  69128. */
  69129. get tintColor(): NodeMaterialConnectionPoint;
  69130. /**
  69131. * Gets the translucency intensity input component
  69132. */
  69133. get translucencyIntensity(): NodeMaterialConnectionPoint;
  69134. /**
  69135. * Gets the translucency diffusion distance input component
  69136. */
  69137. get translucencyDiffusionDist(): NodeMaterialConnectionPoint;
  69138. /**
  69139. * Gets the refraction object parameters
  69140. */
  69141. get refraction(): NodeMaterialConnectionPoint;
  69142. /**
  69143. * Gets the sub surface object output component
  69144. */
  69145. get subsurface(): NodeMaterialConnectionPoint;
  69146. autoConfigure(material: NodeMaterial): void;
  69147. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  69148. /**
  69149. * Gets the main code of the block (fragment side)
  69150. * @param state current state of the node material building
  69151. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  69152. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  69153. * @param worldPosVarName name of the variable holding the world position
  69154. * @returns the shader code
  69155. */
  69156. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  69157. protected _buildBlock(state: NodeMaterialBuildState): this;
  69158. }
  69159. }
  69160. declare module BABYLON {
  69161. /**
  69162. * Block used to implement the PBR metallic/roughness model
  69163. */
  69164. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  69165. /**
  69166. * Gets or sets the light associated with this block
  69167. */
  69168. light: Nullable<Light>;
  69169. private _lightId;
  69170. private _scene;
  69171. private _environmentBRDFTexture;
  69172. private _environmentBrdfSamplerName;
  69173. private _vNormalWName;
  69174. private _invertNormalName;
  69175. private _metallicReflectanceColor;
  69176. private _metallicF0Factor;
  69177. private _vMetallicReflectanceFactorsName;
  69178. /**
  69179. * Create a new ReflectionBlock
  69180. * @param name defines the block name
  69181. */
  69182. constructor(name: string);
  69183. /**
  69184. * Intensity of the direct lights e.g. the four lights available in your scene.
  69185. * This impacts both the direct diffuse and specular highlights.
  69186. */
  69187. directIntensity: number;
  69188. /**
  69189. * Intensity of the environment e.g. how much the environment will light the object
  69190. * either through harmonics for rough material or through the refelction for shiny ones.
  69191. */
  69192. environmentIntensity: number;
  69193. /**
  69194. * This is a special control allowing the reduction of the specular highlights coming from the
  69195. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  69196. */
  69197. specularIntensity: number;
  69198. /**
  69199. * Defines the falloff type used in this material.
  69200. * It by default is Physical.
  69201. */
  69202. lightFalloff: number;
  69203. /**
  69204. * Specifies that alpha test should be used
  69205. */
  69206. useAlphaTest: boolean;
  69207. /**
  69208. * Defines the alpha limits in alpha test mode.
  69209. */
  69210. alphaTestCutoff: number;
  69211. /**
  69212. * Specifies that alpha blending should be used
  69213. */
  69214. useAlphaBlending: boolean;
  69215. /**
  69216. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  69217. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  69218. */
  69219. useRadianceOverAlpha: boolean;
  69220. /**
  69221. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  69222. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  69223. */
  69224. useSpecularOverAlpha: boolean;
  69225. /**
  69226. * Enables specular anti aliasing in the PBR shader.
  69227. * It will both interacts on the Geometry for analytical and IBL lighting.
  69228. * It also prefilter the roughness map based on the bump values.
  69229. */
  69230. enableSpecularAntiAliasing: boolean;
  69231. /**
  69232. * Enables realtime filtering on the texture.
  69233. */
  69234. realTimeFiltering: boolean;
  69235. /**
  69236. * Quality switch for realtime filtering
  69237. */
  69238. realTimeFilteringQuality: number;
  69239. /**
  69240. * Defines if the material uses energy conservation.
  69241. */
  69242. useEnergyConservation: boolean;
  69243. /**
  69244. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  69245. * too much the area relying on ambient texture to define their ambient occlusion.
  69246. */
  69247. useRadianceOcclusion: boolean;
  69248. /**
  69249. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  69250. * makes the reflect vector face the model (under horizon).
  69251. */
  69252. useHorizonOcclusion: boolean;
  69253. /**
  69254. * If set to true, no lighting calculations will be applied.
  69255. */
  69256. unlit: boolean;
  69257. /**
  69258. * Force normal to face away from face.
  69259. */
  69260. forceNormalForward: boolean;
  69261. /**
  69262. * Defines the material debug mode.
  69263. * It helps seeing only some components of the material while troubleshooting.
  69264. */
  69265. debugMode: number;
  69266. /**
  69267. * Specify from where on screen the debug mode should start.
  69268. * The value goes from -1 (full screen) to 1 (not visible)
  69269. * It helps with side by side comparison against the final render
  69270. * This defaults to 0
  69271. */
  69272. debugLimit: number;
  69273. /**
  69274. * As the default viewing range might not be enough (if the ambient is really small for instance)
  69275. * You can use the factor to better multiply the final value.
  69276. */
  69277. debugFactor: number;
  69278. /**
  69279. * Initialize the block and prepare the context for build
  69280. * @param state defines the state that will be used for the build
  69281. */
  69282. initialize(state: NodeMaterialBuildState): void;
  69283. /**
  69284. * Gets the current class name
  69285. * @returns the class name
  69286. */
  69287. getClassName(): string;
  69288. /**
  69289. * Gets the world position input component
  69290. */
  69291. get worldPosition(): NodeMaterialConnectionPoint;
  69292. /**
  69293. * Gets the world normal input component
  69294. */
  69295. get worldNormal(): NodeMaterialConnectionPoint;
  69296. /**
  69297. * Gets the view matrix parameter
  69298. */
  69299. get view(): NodeMaterialConnectionPoint;
  69300. /**
  69301. * Gets the camera position input component
  69302. */
  69303. get cameraPosition(): NodeMaterialConnectionPoint;
  69304. /**
  69305. * Gets the perturbed normal input component
  69306. */
  69307. get perturbedNormal(): NodeMaterialConnectionPoint;
  69308. /**
  69309. * Gets the base color input component
  69310. */
  69311. get baseColor(): NodeMaterialConnectionPoint;
  69312. /**
  69313. * Gets the metallic input component
  69314. */
  69315. get metallic(): NodeMaterialConnectionPoint;
  69316. /**
  69317. * Gets the roughness input component
  69318. */
  69319. get roughness(): NodeMaterialConnectionPoint;
  69320. /**
  69321. * Gets the ambient occlusion input component
  69322. */
  69323. get ambientOcc(): NodeMaterialConnectionPoint;
  69324. /**
  69325. * Gets the opacity input component
  69326. */
  69327. get opacity(): NodeMaterialConnectionPoint;
  69328. /**
  69329. * Gets the index of refraction input component
  69330. */
  69331. get indexOfRefraction(): NodeMaterialConnectionPoint;
  69332. /**
  69333. * Gets the ambient color input component
  69334. */
  69335. get ambientColor(): NodeMaterialConnectionPoint;
  69336. /**
  69337. * Gets the reflection object parameters
  69338. */
  69339. get reflection(): NodeMaterialConnectionPoint;
  69340. /**
  69341. * Gets the clear coat object parameters
  69342. */
  69343. get clearcoat(): NodeMaterialConnectionPoint;
  69344. /**
  69345. * Gets the sheen object parameters
  69346. */
  69347. get sheen(): NodeMaterialConnectionPoint;
  69348. /**
  69349. * Gets the sub surface object parameters
  69350. */
  69351. get subsurface(): NodeMaterialConnectionPoint;
  69352. /**
  69353. * Gets the anisotropy object parameters
  69354. */
  69355. get anisotropy(): NodeMaterialConnectionPoint;
  69356. /**
  69357. * Gets the ambient output component
  69358. */
  69359. get ambientClr(): NodeMaterialConnectionPoint;
  69360. /**
  69361. * Gets the diffuse output component
  69362. */
  69363. get diffuseDir(): NodeMaterialConnectionPoint;
  69364. /**
  69365. * Gets the specular output component
  69366. */
  69367. get specularDir(): NodeMaterialConnectionPoint;
  69368. /**
  69369. * Gets the clear coat output component
  69370. */
  69371. get clearcoatDir(): NodeMaterialConnectionPoint;
  69372. /**
  69373. * Gets the sheen output component
  69374. */
  69375. get sheenDir(): NodeMaterialConnectionPoint;
  69376. /**
  69377. * Gets the indirect diffuse output component
  69378. */
  69379. get diffuseIndirect(): NodeMaterialConnectionPoint;
  69380. /**
  69381. * Gets the indirect specular output component
  69382. */
  69383. get specularIndirect(): NodeMaterialConnectionPoint;
  69384. /**
  69385. * Gets the indirect clear coat output component
  69386. */
  69387. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  69388. /**
  69389. * Gets the indirect sheen output component
  69390. */
  69391. get sheenIndirect(): NodeMaterialConnectionPoint;
  69392. /**
  69393. * Gets the refraction output component
  69394. */
  69395. get refraction(): NodeMaterialConnectionPoint;
  69396. /**
  69397. * Gets the global lighting output component
  69398. */
  69399. get lighting(): NodeMaterialConnectionPoint;
  69400. /**
  69401. * Gets the shadow output component
  69402. */
  69403. get shadow(): NodeMaterialConnectionPoint;
  69404. /**
  69405. * Gets the alpha output component
  69406. */
  69407. get alpha(): NodeMaterialConnectionPoint;
  69408. autoConfigure(material: NodeMaterial): void;
  69409. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  69410. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  69411. isReady(): boolean;
  69412. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  69413. private _injectVertexCode;
  69414. private _getAlbedoOpacityCode;
  69415. private _getAmbientOcclusionCode;
  69416. private _getReflectivityCode;
  69417. protected _buildBlock(state: NodeMaterialBuildState): this;
  69418. protected _dumpPropertiesCode(): string;
  69419. serialize(): any;
  69420. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  69421. }
  69422. }
  69423. declare module BABYLON {
  69424. /**
  69425. * Block used to compute value of one parameter modulo another
  69426. */
  69427. export class ModBlock extends NodeMaterialBlock {
  69428. /**
  69429. * Creates a new ModBlock
  69430. * @param name defines the block name
  69431. */
  69432. constructor(name: string);
  69433. /**
  69434. * Gets the current class name
  69435. * @returns the class name
  69436. */
  69437. getClassName(): string;
  69438. /**
  69439. * Gets the left operand input component
  69440. */
  69441. get left(): NodeMaterialConnectionPoint;
  69442. /**
  69443. * Gets the right operand input component
  69444. */
  69445. get right(): NodeMaterialConnectionPoint;
  69446. /**
  69447. * Gets the output component
  69448. */
  69449. get output(): NodeMaterialConnectionPoint;
  69450. protected _buildBlock(state: NodeMaterialBuildState): this;
  69451. }
  69452. }
  69453. declare module BABYLON {
  69454. /**
  69455. * Configuration for Draco compression
  69456. */
  69457. export interface IDracoCompressionConfiguration {
  69458. /**
  69459. * Configuration for the decoder.
  69460. */
  69461. decoder: {
  69462. /**
  69463. * The url to the WebAssembly module.
  69464. */
  69465. wasmUrl?: string;
  69466. /**
  69467. * The url to the WebAssembly binary.
  69468. */
  69469. wasmBinaryUrl?: string;
  69470. /**
  69471. * The url to the fallback JavaScript module.
  69472. */
  69473. fallbackUrl?: string;
  69474. };
  69475. }
  69476. /**
  69477. * Draco compression (https://google.github.io/draco/)
  69478. *
  69479. * This class wraps the Draco module.
  69480. *
  69481. * **Encoder**
  69482. *
  69483. * The encoder is not currently implemented.
  69484. *
  69485. * **Decoder**
  69486. *
  69487. * 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.
  69488. *
  69489. * To update the configuration, use the following code:
  69490. * ```javascript
  69491. * DracoCompression.Configuration = {
  69492. * decoder: {
  69493. * wasmUrl: "<url to the WebAssembly library>",
  69494. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  69495. * fallbackUrl: "<url to the fallback JavaScript library>",
  69496. * }
  69497. * };
  69498. * ```
  69499. *
  69500. * 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.
  69501. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  69502. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  69503. *
  69504. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  69505. * ```javascript
  69506. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  69507. * ```
  69508. *
  69509. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  69510. */
  69511. export class DracoCompression implements IDisposable {
  69512. private _workerPoolPromise?;
  69513. private _decoderModulePromise?;
  69514. /**
  69515. * The configuration. Defaults to the following urls:
  69516. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  69517. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  69518. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  69519. */
  69520. static Configuration: IDracoCompressionConfiguration;
  69521. /**
  69522. * Returns true if the decoder configuration is available.
  69523. */
  69524. static get DecoderAvailable(): boolean;
  69525. /**
  69526. * Default number of workers to create when creating the draco compression object.
  69527. */
  69528. static DefaultNumWorkers: number;
  69529. private static GetDefaultNumWorkers;
  69530. private static _Default;
  69531. /**
  69532. * Default instance for the draco compression object.
  69533. */
  69534. static get Default(): DracoCompression;
  69535. /**
  69536. * Constructor
  69537. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  69538. */
  69539. constructor(numWorkers?: number);
  69540. /**
  69541. * Stop all async operations and release resources.
  69542. */
  69543. dispose(): void;
  69544. /**
  69545. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  69546. * @returns a promise that resolves when ready
  69547. */
  69548. whenReadyAsync(): Promise<void>;
  69549. /**
  69550. * Decode Draco compressed mesh data to vertex data.
  69551. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  69552. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  69553. * @returns A promise that resolves with the decoded vertex data
  69554. */
  69555. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  69556. [kind: string]: number;
  69557. }): Promise<VertexData>;
  69558. }
  69559. }
  69560. declare module BABYLON {
  69561. /**
  69562. * Class for building Constructive Solid Geometry
  69563. */
  69564. export class CSG {
  69565. private polygons;
  69566. /**
  69567. * The world matrix
  69568. */
  69569. matrix: Matrix;
  69570. /**
  69571. * Stores the position
  69572. */
  69573. position: Vector3;
  69574. /**
  69575. * Stores the rotation
  69576. */
  69577. rotation: Vector3;
  69578. /**
  69579. * Stores the rotation quaternion
  69580. */
  69581. rotationQuaternion: Nullable<Quaternion>;
  69582. /**
  69583. * Stores the scaling vector
  69584. */
  69585. scaling: Vector3;
  69586. /**
  69587. * Convert the Mesh to CSG
  69588. * @param mesh The Mesh to convert to CSG
  69589. * @returns A new CSG from the Mesh
  69590. */
  69591. static FromMesh(mesh: Mesh): CSG;
  69592. /**
  69593. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  69594. * @param polygons Polygons used to construct a CSG solid
  69595. */
  69596. private static FromPolygons;
  69597. /**
  69598. * Clones, or makes a deep copy, of the CSG
  69599. * @returns A new CSG
  69600. */
  69601. clone(): CSG;
  69602. /**
  69603. * Unions this CSG with another CSG
  69604. * @param csg The CSG to union against this CSG
  69605. * @returns The unioned CSG
  69606. */
  69607. union(csg: CSG): CSG;
  69608. /**
  69609. * Unions this CSG with another CSG in place
  69610. * @param csg The CSG to union against this CSG
  69611. */
  69612. unionInPlace(csg: CSG): void;
  69613. /**
  69614. * Subtracts this CSG with another CSG
  69615. * @param csg The CSG to subtract against this CSG
  69616. * @returns A new CSG
  69617. */
  69618. subtract(csg: CSG): CSG;
  69619. /**
  69620. * Subtracts this CSG with another CSG in place
  69621. * @param csg The CSG to subtact against this CSG
  69622. */
  69623. subtractInPlace(csg: CSG): void;
  69624. /**
  69625. * Intersect this CSG with another CSG
  69626. * @param csg The CSG to intersect against this CSG
  69627. * @returns A new CSG
  69628. */
  69629. intersect(csg: CSG): CSG;
  69630. /**
  69631. * Intersects this CSG with another CSG in place
  69632. * @param csg The CSG to intersect against this CSG
  69633. */
  69634. intersectInPlace(csg: CSG): void;
  69635. /**
  69636. * Return a new CSG solid with solid and empty space switched. This solid is
  69637. * not modified.
  69638. * @returns A new CSG solid with solid and empty space switched
  69639. */
  69640. inverse(): CSG;
  69641. /**
  69642. * Inverses the CSG in place
  69643. */
  69644. inverseInPlace(): void;
  69645. /**
  69646. * This is used to keep meshes transformations so they can be restored
  69647. * when we build back a Babylon Mesh
  69648. * NB : All CSG operations are performed in world coordinates
  69649. * @param csg The CSG to copy the transform attributes from
  69650. * @returns This CSG
  69651. */
  69652. copyTransformAttributes(csg: CSG): CSG;
  69653. /**
  69654. * Build Raw mesh from CSG
  69655. * Coordinates here are in world space
  69656. * @param name The name of the mesh geometry
  69657. * @param scene The Scene
  69658. * @param keepSubMeshes Specifies if the submeshes should be kept
  69659. * @returns A new Mesh
  69660. */
  69661. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  69662. /**
  69663. * Build Mesh from CSG taking material and transforms into account
  69664. * @param name The name of the Mesh
  69665. * @param material The material of the Mesh
  69666. * @param scene The Scene
  69667. * @param keepSubMeshes Specifies if submeshes should be kept
  69668. * @returns The new Mesh
  69669. */
  69670. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  69671. }
  69672. }
  69673. declare module BABYLON {
  69674. /**
  69675. * Class used to create a trail following a mesh
  69676. */
  69677. export class TrailMesh extends Mesh {
  69678. private _generator;
  69679. private _autoStart;
  69680. private _running;
  69681. private _diameter;
  69682. private _length;
  69683. private _sectionPolygonPointsCount;
  69684. private _sectionVectors;
  69685. private _sectionNormalVectors;
  69686. private _beforeRenderObserver;
  69687. /**
  69688. * @constructor
  69689. * @param name The value used by scene.getMeshByName() to do a lookup.
  69690. * @param generator The mesh or transform node to generate a trail.
  69691. * @param scene The scene to add this mesh to.
  69692. * @param diameter Diameter of trailing mesh. Default is 1.
  69693. * @param length Length of trailing mesh. Default is 60.
  69694. * @param autoStart Automatically start trailing mesh. Default true.
  69695. */
  69696. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  69697. /**
  69698. * "TrailMesh"
  69699. * @returns "TrailMesh"
  69700. */
  69701. getClassName(): string;
  69702. private _createMesh;
  69703. /**
  69704. * Start trailing mesh.
  69705. */
  69706. start(): void;
  69707. /**
  69708. * Stop trailing mesh.
  69709. */
  69710. stop(): void;
  69711. /**
  69712. * Update trailing mesh geometry.
  69713. */
  69714. update(): void;
  69715. /**
  69716. * Returns a new TrailMesh object.
  69717. * @param name is a string, the name given to the new mesh
  69718. * @param newGenerator use new generator object for cloned trail mesh
  69719. * @returns a new mesh
  69720. */
  69721. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  69722. /**
  69723. * Serializes this trail mesh
  69724. * @param serializationObject object to write serialization to
  69725. */
  69726. serialize(serializationObject: any): void;
  69727. /**
  69728. * Parses a serialized trail mesh
  69729. * @param parsedMesh the serialized mesh
  69730. * @param scene the scene to create the trail mesh in
  69731. * @returns the created trail mesh
  69732. */
  69733. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  69734. }
  69735. }
  69736. declare module BABYLON {
  69737. /**
  69738. * Class containing static functions to help procedurally build meshes
  69739. */
  69740. export class TiledBoxBuilder {
  69741. /**
  69742. * Creates a box mesh
  69743. * 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)
  69744. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  69745. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69746. * * 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
  69747. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69748. * @param name defines the name of the mesh
  69749. * @param options defines the options used to create the mesh
  69750. * @param scene defines the hosting scene
  69751. * @returns the box mesh
  69752. */
  69753. static CreateTiledBox(name: string, options: {
  69754. pattern?: number;
  69755. width?: number;
  69756. height?: number;
  69757. depth?: number;
  69758. tileSize?: number;
  69759. tileWidth?: number;
  69760. tileHeight?: number;
  69761. alignHorizontal?: number;
  69762. alignVertical?: number;
  69763. faceUV?: Vector4[];
  69764. faceColors?: Color4[];
  69765. sideOrientation?: number;
  69766. updatable?: boolean;
  69767. }, scene?: Nullable<Scene>): Mesh;
  69768. }
  69769. }
  69770. declare module BABYLON {
  69771. /**
  69772. * Class containing static functions to help procedurally build meshes
  69773. */
  69774. export class TorusKnotBuilder {
  69775. /**
  69776. * Creates a torus knot mesh
  69777. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  69778. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  69779. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  69780. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  69781. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69782. * * 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
  69783. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  69784. * @param name defines the name of the mesh
  69785. * @param options defines the options used to create the mesh
  69786. * @param scene defines the hosting scene
  69787. * @returns the torus knot mesh
  69788. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  69789. */
  69790. static CreateTorusKnot(name: string, options: {
  69791. radius?: number;
  69792. tube?: number;
  69793. radialSegments?: number;
  69794. tubularSegments?: number;
  69795. p?: number;
  69796. q?: number;
  69797. updatable?: boolean;
  69798. sideOrientation?: number;
  69799. frontUVs?: Vector4;
  69800. backUVs?: Vector4;
  69801. }, scene: any): Mesh;
  69802. }
  69803. }
  69804. declare module BABYLON {
  69805. /**
  69806. * Polygon
  69807. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  69808. */
  69809. export class Polygon {
  69810. /**
  69811. * Creates a rectangle
  69812. * @param xmin bottom X coord
  69813. * @param ymin bottom Y coord
  69814. * @param xmax top X coord
  69815. * @param ymax top Y coord
  69816. * @returns points that make the resulting rectation
  69817. */
  69818. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  69819. /**
  69820. * Creates a circle
  69821. * @param radius radius of circle
  69822. * @param cx scale in x
  69823. * @param cy scale in y
  69824. * @param numberOfSides number of sides that make up the circle
  69825. * @returns points that make the resulting circle
  69826. */
  69827. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  69828. /**
  69829. * Creates a polygon from input string
  69830. * @param input Input polygon data
  69831. * @returns the parsed points
  69832. */
  69833. static Parse(input: string): Vector2[];
  69834. /**
  69835. * Starts building a polygon from x and y coordinates
  69836. * @param x x coordinate
  69837. * @param y y coordinate
  69838. * @returns the started path2
  69839. */
  69840. static StartingAt(x: number, y: number): Path2;
  69841. }
  69842. /**
  69843. * Builds a polygon
  69844. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  69845. */
  69846. export class PolygonMeshBuilder {
  69847. private _points;
  69848. private _outlinepoints;
  69849. private _holes;
  69850. private _name;
  69851. private _scene;
  69852. private _epoints;
  69853. private _eholes;
  69854. private _addToepoint;
  69855. /**
  69856. * Babylon reference to the earcut plugin.
  69857. */
  69858. bjsEarcut: any;
  69859. /**
  69860. * Creates a PolygonMeshBuilder
  69861. * @param name name of the builder
  69862. * @param contours Path of the polygon
  69863. * @param scene scene to add to when creating the mesh
  69864. * @param earcutInjection can be used to inject your own earcut reference
  69865. */
  69866. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  69867. /**
  69868. * Adds a hole within the polygon
  69869. * @param hole Array of points defining the hole
  69870. * @returns this
  69871. */
  69872. addHole(hole: Vector2[]): PolygonMeshBuilder;
  69873. /**
  69874. * Creates the polygon
  69875. * @param updatable If the mesh should be updatable
  69876. * @param depth The depth of the mesh created
  69877. * @param smoothingThreshold Dot product threshold for smoothed normals
  69878. * @returns the created mesh
  69879. */
  69880. build(updatable?: boolean, depth?: number, smoothingThreshold?: number): Mesh;
  69881. /**
  69882. * Creates the polygon
  69883. * @param depth The depth of the mesh created
  69884. * @param smoothingThreshold Dot product threshold for smoothed normals
  69885. * @returns the created VertexData
  69886. */
  69887. buildVertexData(depth?: number, smoothingThreshold?: number): VertexData;
  69888. /**
  69889. * Adds a side to the polygon
  69890. * @param positions points that make the polygon
  69891. * @param normals normals of the polygon
  69892. * @param uvs uvs of the polygon
  69893. * @param indices indices of the polygon
  69894. * @param bounds bounds of the polygon
  69895. * @param points points of the polygon
  69896. * @param depth depth of the polygon
  69897. * @param flip flip of the polygon
  69898. */
  69899. private addSide;
  69900. }
  69901. }
  69902. declare module BABYLON {
  69903. /**
  69904. * Class containing static functions to help procedurally build meshes
  69905. */
  69906. export class PolygonBuilder {
  69907. /**
  69908. * Creates a polygon mesh
  69909. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  69910. * * 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
  69911. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  69912. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69913. * * 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)
  69914. * * Remember you can only change the shape positions, not their number when updating a polygon
  69915. * @param name defines the name of the mesh
  69916. * @param options defines the options used to create the mesh
  69917. * @param scene defines the hosting scene
  69918. * @param earcutInjection can be used to inject your own earcut reference
  69919. * @returns the polygon mesh
  69920. */
  69921. static CreatePolygon(name: string, options: {
  69922. shape: Vector3[];
  69923. holes?: Vector3[][];
  69924. depth?: number;
  69925. smoothingThreshold?: number;
  69926. faceUV?: Vector4[];
  69927. faceColors?: Color4[];
  69928. updatable?: boolean;
  69929. sideOrientation?: number;
  69930. frontUVs?: Vector4;
  69931. backUVs?: Vector4;
  69932. wrap?: boolean;
  69933. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  69934. /**
  69935. * Creates an extruded polygon mesh, with depth in the Y direction.
  69936. * * 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)
  69937. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  69938. * @param name defines the name of the mesh
  69939. * @param options defines the options used to create the mesh
  69940. * @param scene defines the hosting scene
  69941. * @param earcutInjection can be used to inject your own earcut reference
  69942. * @returns the polygon mesh
  69943. */
  69944. static ExtrudePolygon(name: string, options: {
  69945. shape: Vector3[];
  69946. holes?: Vector3[][];
  69947. depth?: number;
  69948. faceUV?: Vector4[];
  69949. faceColors?: Color4[];
  69950. updatable?: boolean;
  69951. sideOrientation?: number;
  69952. frontUVs?: Vector4;
  69953. backUVs?: Vector4;
  69954. wrap?: boolean;
  69955. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  69956. }
  69957. }
  69958. declare module BABYLON {
  69959. /**
  69960. * Class containing static functions to help procedurally build meshes
  69961. */
  69962. export class LatheBuilder {
  69963. /**
  69964. * Creates lathe mesh.
  69965. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  69966. * * 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
  69967. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  69968. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  69969. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  69970. * * 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
  69971. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  69972. * * 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
  69973. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69974. * * 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
  69975. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  69976. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69977. * @param name defines the name of the mesh
  69978. * @param options defines the options used to create the mesh
  69979. * @param scene defines the hosting scene
  69980. * @returns the lathe mesh
  69981. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  69982. */
  69983. static CreateLathe(name: string, options: {
  69984. shape: Vector3[];
  69985. radius?: number;
  69986. tessellation?: number;
  69987. clip?: number;
  69988. arc?: number;
  69989. closed?: boolean;
  69990. updatable?: boolean;
  69991. sideOrientation?: number;
  69992. frontUVs?: Vector4;
  69993. backUVs?: Vector4;
  69994. cap?: number;
  69995. invertUV?: boolean;
  69996. }, scene?: Nullable<Scene>): Mesh;
  69997. }
  69998. }
  69999. declare module BABYLON {
  70000. /**
  70001. * Class containing static functions to help procedurally build meshes
  70002. */
  70003. export class TiledPlaneBuilder {
  70004. /**
  70005. * Creates a tiled plane mesh
  70006. * * The parameter `pattern` will, depending on value, do nothing or
  70007. * * * flip (reflect about central vertical) alternate tiles across and up
  70008. * * * flip every tile on alternate rows
  70009. * * * rotate (180 degs) alternate tiles across and up
  70010. * * * rotate every tile on alternate rows
  70011. * * * flip and rotate alternate tiles across and up
  70012. * * * flip and rotate every tile on alternate rows
  70013. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  70014. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  70015. * * 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
  70016. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  70017. * * 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)
  70018. * * 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)
  70019. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  70020. * @param name defines the name of the mesh
  70021. * @param options defines the options used to create the mesh
  70022. * @param scene defines the hosting scene
  70023. * @returns the box mesh
  70024. */
  70025. static CreateTiledPlane(name: string, options: {
  70026. pattern?: number;
  70027. tileSize?: number;
  70028. tileWidth?: number;
  70029. tileHeight?: number;
  70030. size?: number;
  70031. width?: number;
  70032. height?: number;
  70033. alignHorizontal?: number;
  70034. alignVertical?: number;
  70035. sideOrientation?: number;
  70036. frontUVs?: Vector4;
  70037. backUVs?: Vector4;
  70038. updatable?: boolean;
  70039. }, scene?: Nullable<Scene>): Mesh;
  70040. }
  70041. }
  70042. declare module BABYLON {
  70043. /**
  70044. * Class containing static functions to help procedurally build meshes
  70045. */
  70046. export class TubeBuilder {
  70047. /**
  70048. * Creates a tube mesh.
  70049. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  70050. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  70051. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  70052. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  70053. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  70054. * * 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)
  70055. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  70056. * * 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
  70057. * * 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
  70058. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70059. * * 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
  70060. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  70061. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70062. * @param name defines the name of the mesh
  70063. * @param options defines the options used to create the mesh
  70064. * @param scene defines the hosting scene
  70065. * @returns the tube mesh
  70066. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  70067. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  70068. */
  70069. static CreateTube(name: string, options: {
  70070. path: Vector3[];
  70071. radius?: number;
  70072. tessellation?: number;
  70073. radiusFunction?: {
  70074. (i: number, distance: number): number;
  70075. };
  70076. cap?: number;
  70077. arc?: number;
  70078. updatable?: boolean;
  70079. sideOrientation?: number;
  70080. frontUVs?: Vector4;
  70081. backUVs?: Vector4;
  70082. instance?: Mesh;
  70083. invertUV?: boolean;
  70084. }, scene?: Nullable<Scene>): Mesh;
  70085. }
  70086. }
  70087. declare module BABYLON {
  70088. /**
  70089. * Class containing static functions to help procedurally build meshes
  70090. */
  70091. export class IcoSphereBuilder {
  70092. /**
  70093. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  70094. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  70095. * * 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`)
  70096. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  70097. * * 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
  70098. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70099. * * 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
  70100. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70101. * @param name defines the name of the mesh
  70102. * @param options defines the options used to create the mesh
  70103. * @param scene defines the hosting scene
  70104. * @returns the icosahedron mesh
  70105. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  70106. */
  70107. static CreateIcoSphere(name: string, options: {
  70108. radius?: number;
  70109. radiusX?: number;
  70110. radiusY?: number;
  70111. radiusZ?: number;
  70112. flat?: boolean;
  70113. subdivisions?: number;
  70114. sideOrientation?: number;
  70115. frontUVs?: Vector4;
  70116. backUVs?: Vector4;
  70117. updatable?: boolean;
  70118. }, scene?: Nullable<Scene>): Mesh;
  70119. }
  70120. }
  70121. declare module BABYLON {
  70122. /**
  70123. * Class containing static functions to help procedurally build meshes
  70124. */
  70125. export class DecalBuilder {
  70126. /**
  70127. * Creates a decal mesh.
  70128. * 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
  70129. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  70130. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  70131. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  70132. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  70133. * @param name defines the name of the mesh
  70134. * @param sourceMesh defines the mesh where the decal must be applied
  70135. * @param options defines the options used to create the mesh
  70136. * @param scene defines the hosting scene
  70137. * @returns the decal mesh
  70138. * @see https://doc.babylonjs.com/how_to/decals
  70139. */
  70140. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  70141. position?: Vector3;
  70142. normal?: Vector3;
  70143. size?: Vector3;
  70144. angle?: number;
  70145. }): Mesh;
  70146. }
  70147. }
  70148. declare module BABYLON {
  70149. /**
  70150. * Class containing static functions to help procedurally build meshes
  70151. */
  70152. export class MeshBuilder {
  70153. /**
  70154. * Creates a box mesh
  70155. * * The parameter `size` sets the size (float) of each box side (default 1)
  70156. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  70157. * * 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)
  70158. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  70159. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70160. * * 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
  70161. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70162. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  70163. * @param name defines the name of the mesh
  70164. * @param options defines the options used to create the mesh
  70165. * @param scene defines the hosting scene
  70166. * @returns the box mesh
  70167. */
  70168. static CreateBox(name: string, options: {
  70169. size?: number;
  70170. width?: number;
  70171. height?: number;
  70172. depth?: number;
  70173. faceUV?: Vector4[];
  70174. faceColors?: Color4[];
  70175. sideOrientation?: number;
  70176. frontUVs?: Vector4;
  70177. backUVs?: Vector4;
  70178. wrap?: boolean;
  70179. topBaseAt?: number;
  70180. bottomBaseAt?: number;
  70181. updatable?: boolean;
  70182. }, scene?: Nullable<Scene>): Mesh;
  70183. /**
  70184. * Creates a tiled box mesh
  70185. * * faceTiles sets the pattern, tile size and number of tiles for a face
  70186. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70187. * @param name defines the name of the mesh
  70188. * @param options defines the options used to create the mesh
  70189. * @param scene defines the hosting scene
  70190. * @returns the tiled box mesh
  70191. */
  70192. static CreateTiledBox(name: string, options: {
  70193. pattern?: number;
  70194. size?: number;
  70195. width?: number;
  70196. height?: number;
  70197. depth: number;
  70198. tileSize?: number;
  70199. tileWidth?: number;
  70200. tileHeight?: number;
  70201. faceUV?: Vector4[];
  70202. faceColors?: Color4[];
  70203. alignHorizontal?: number;
  70204. alignVertical?: number;
  70205. sideOrientation?: number;
  70206. updatable?: boolean;
  70207. }, scene?: Nullable<Scene>): Mesh;
  70208. /**
  70209. * Creates a sphere mesh
  70210. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  70211. * * 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`)
  70212. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  70213. * * 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
  70214. * * 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)
  70215. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70216. * * 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
  70217. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70218. * @param name defines the name of the mesh
  70219. * @param options defines the options used to create the mesh
  70220. * @param scene defines the hosting scene
  70221. * @returns the sphere mesh
  70222. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  70223. */
  70224. static CreateSphere(name: string, options: {
  70225. segments?: number;
  70226. diameter?: number;
  70227. diameterX?: number;
  70228. diameterY?: number;
  70229. diameterZ?: number;
  70230. arc?: number;
  70231. slice?: number;
  70232. sideOrientation?: number;
  70233. frontUVs?: Vector4;
  70234. backUVs?: Vector4;
  70235. updatable?: boolean;
  70236. }, scene?: Nullable<Scene>): Mesh;
  70237. /**
  70238. * Creates a plane polygonal mesh. By default, this is a disc
  70239. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  70240. * * 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
  70241. * * 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
  70242. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70243. * * 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
  70244. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70245. * @param name defines the name of the mesh
  70246. * @param options defines the options used to create the mesh
  70247. * @param scene defines the hosting scene
  70248. * @returns the plane polygonal mesh
  70249. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  70250. */
  70251. static CreateDisc(name: string, options: {
  70252. radius?: number;
  70253. tessellation?: number;
  70254. arc?: number;
  70255. updatable?: boolean;
  70256. sideOrientation?: number;
  70257. frontUVs?: Vector4;
  70258. backUVs?: Vector4;
  70259. }, scene?: Nullable<Scene>): Mesh;
  70260. /**
  70261. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  70262. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  70263. * * 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`)
  70264. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  70265. * * 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
  70266. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70267. * * 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
  70268. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70269. * @param name defines the name of the mesh
  70270. * @param options defines the options used to create the mesh
  70271. * @param scene defines the hosting scene
  70272. * @returns the icosahedron mesh
  70273. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  70274. */
  70275. static CreateIcoSphere(name: string, options: {
  70276. radius?: number;
  70277. radiusX?: number;
  70278. radiusY?: number;
  70279. radiusZ?: number;
  70280. flat?: boolean;
  70281. subdivisions?: number;
  70282. sideOrientation?: number;
  70283. frontUVs?: Vector4;
  70284. backUVs?: Vector4;
  70285. updatable?: boolean;
  70286. }, scene?: Nullable<Scene>): Mesh;
  70287. /**
  70288. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  70289. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  70290. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  70291. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  70292. * * 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
  70293. * * 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
  70294. * * 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
  70295. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70296. * * 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
  70297. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  70298. * * 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
  70299. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  70300. * * 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
  70301. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  70302. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70303. * @param name defines the name of the mesh
  70304. * @param options defines the options used to create the mesh
  70305. * @param scene defines the hosting scene
  70306. * @returns the ribbon mesh
  70307. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  70308. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  70309. */
  70310. static CreateRibbon(name: string, options: {
  70311. pathArray: Vector3[][];
  70312. closeArray?: boolean;
  70313. closePath?: boolean;
  70314. offset?: number;
  70315. updatable?: boolean;
  70316. sideOrientation?: number;
  70317. frontUVs?: Vector4;
  70318. backUVs?: Vector4;
  70319. instance?: Mesh;
  70320. invertUV?: boolean;
  70321. uvs?: Vector2[];
  70322. colors?: Color4[];
  70323. }, scene?: Nullable<Scene>): Mesh;
  70324. /**
  70325. * Creates a cylinder or a cone mesh
  70326. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  70327. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  70328. * * 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.
  70329. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  70330. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  70331. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  70332. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  70333. * * 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).
  70334. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  70335. * * 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).
  70336. * * 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
  70337. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  70338. * * 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
  70339. * * 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.
  70340. * * If `enclose` is false, a ring surface is one element.
  70341. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  70342. * * 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
  70343. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70344. * * 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
  70345. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  70346. * @param name defines the name of the mesh
  70347. * @param options defines the options used to create the mesh
  70348. * @param scene defines the hosting scene
  70349. * @returns the cylinder mesh
  70350. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  70351. */
  70352. static CreateCylinder(name: string, options: {
  70353. height?: number;
  70354. diameterTop?: number;
  70355. diameterBottom?: number;
  70356. diameter?: number;
  70357. tessellation?: number;
  70358. subdivisions?: number;
  70359. arc?: number;
  70360. faceColors?: Color4[];
  70361. faceUV?: Vector4[];
  70362. updatable?: boolean;
  70363. hasRings?: boolean;
  70364. enclose?: boolean;
  70365. cap?: number;
  70366. sideOrientation?: number;
  70367. frontUVs?: Vector4;
  70368. backUVs?: Vector4;
  70369. }, scene?: Nullable<Scene>): Mesh;
  70370. /**
  70371. * Creates a torus mesh
  70372. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  70373. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  70374. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  70375. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70376. * * 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
  70377. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  70378. * @param name defines the name of the mesh
  70379. * @param options defines the options used to create the mesh
  70380. * @param scene defines the hosting scene
  70381. * @returns the torus mesh
  70382. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  70383. */
  70384. static CreateTorus(name: string, options: {
  70385. diameter?: number;
  70386. thickness?: number;
  70387. tessellation?: number;
  70388. updatable?: boolean;
  70389. sideOrientation?: number;
  70390. frontUVs?: Vector4;
  70391. backUVs?: Vector4;
  70392. }, scene?: Nullable<Scene>): Mesh;
  70393. /**
  70394. * Creates a torus knot mesh
  70395. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  70396. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  70397. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  70398. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  70399. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70400. * * 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
  70401. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  70402. * @param name defines the name of the mesh
  70403. * @param options defines the options used to create the mesh
  70404. * @param scene defines the hosting scene
  70405. * @returns the torus knot mesh
  70406. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  70407. */
  70408. static CreateTorusKnot(name: string, options: {
  70409. radius?: number;
  70410. tube?: number;
  70411. radialSegments?: number;
  70412. tubularSegments?: number;
  70413. p?: number;
  70414. q?: number;
  70415. updatable?: boolean;
  70416. sideOrientation?: number;
  70417. frontUVs?: Vector4;
  70418. backUVs?: Vector4;
  70419. }, scene?: Nullable<Scene>): Mesh;
  70420. /**
  70421. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  70422. * * 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
  70423. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  70424. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  70425. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  70426. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  70427. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  70428. * * 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
  70429. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  70430. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70431. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  70432. * @param name defines the name of the new line system
  70433. * @param options defines the options used to create the line system
  70434. * @param scene defines the hosting scene
  70435. * @returns a new line system mesh
  70436. */
  70437. static CreateLineSystem(name: string, options: {
  70438. lines: Vector3[][];
  70439. updatable?: boolean;
  70440. instance?: Nullable<LinesMesh>;
  70441. colors?: Nullable<Color4[][]>;
  70442. useVertexAlpha?: boolean;
  70443. }, scene: Nullable<Scene>): LinesMesh;
  70444. /**
  70445. * Creates a line mesh
  70446. * 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
  70447. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  70448. * * The parameter `points` is an array successive Vector3
  70449. * * 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
  70450. * * The optional parameter `colors` is an array of successive Color4, one per line point
  70451. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  70452. * * When updating an instance, remember that only point positions can change, not the number of points
  70453. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70454. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  70455. * @param name defines the name of the new line system
  70456. * @param options defines the options used to create the line system
  70457. * @param scene defines the hosting scene
  70458. * @returns a new line mesh
  70459. */
  70460. static CreateLines(name: string, options: {
  70461. points: Vector3[];
  70462. updatable?: boolean;
  70463. instance?: Nullable<LinesMesh>;
  70464. colors?: Color4[];
  70465. useVertexAlpha?: boolean;
  70466. }, scene?: Nullable<Scene>): LinesMesh;
  70467. /**
  70468. * Creates a dashed line mesh
  70469. * * 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
  70470. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  70471. * * The parameter `points` is an array successive Vector3
  70472. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  70473. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  70474. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  70475. * * 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
  70476. * * When updating an instance, remember that only point positions can change, not the number of points
  70477. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70478. * @param name defines the name of the mesh
  70479. * @param options defines the options used to create the mesh
  70480. * @param scene defines the hosting scene
  70481. * @returns the dashed line mesh
  70482. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  70483. */
  70484. static CreateDashedLines(name: string, options: {
  70485. points: Vector3[];
  70486. dashSize?: number;
  70487. gapSize?: number;
  70488. dashNb?: number;
  70489. updatable?: boolean;
  70490. instance?: LinesMesh;
  70491. }, scene?: Nullable<Scene>): LinesMesh;
  70492. /**
  70493. * 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.
  70494. * * 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.
  70495. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  70496. * * 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.
  70497. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  70498. * * 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
  70499. * * 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
  70500. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  70501. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70502. * * 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
  70503. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  70504. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  70505. * @param name defines the name of the mesh
  70506. * @param options defines the options used to create the mesh
  70507. * @param scene defines the hosting scene
  70508. * @returns the extruded shape mesh
  70509. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  70510. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  70511. */
  70512. static ExtrudeShape(name: string, options: {
  70513. shape: Vector3[];
  70514. path: Vector3[];
  70515. scale?: number;
  70516. rotation?: number;
  70517. cap?: number;
  70518. updatable?: boolean;
  70519. sideOrientation?: number;
  70520. frontUVs?: Vector4;
  70521. backUVs?: Vector4;
  70522. instance?: Mesh;
  70523. invertUV?: boolean;
  70524. }, scene?: Nullable<Scene>): Mesh;
  70525. /**
  70526. * Creates an custom extruded shape mesh.
  70527. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  70528. * * 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.
  70529. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  70530. * * 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
  70531. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  70532. * * 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
  70533. * * It must returns a float value that will be the scale value applied to the shape on each path point
  70534. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  70535. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  70536. * * 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
  70537. * * 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
  70538. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  70539. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70540. * * 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
  70541. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  70542. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70543. * @param name defines the name of the mesh
  70544. * @param options defines the options used to create the mesh
  70545. * @param scene defines the hosting scene
  70546. * @returns the custom extruded shape mesh
  70547. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  70548. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  70549. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  70550. */
  70551. static ExtrudeShapeCustom(name: string, options: {
  70552. shape: Vector3[];
  70553. path: Vector3[];
  70554. scaleFunction?: any;
  70555. rotationFunction?: any;
  70556. ribbonCloseArray?: boolean;
  70557. ribbonClosePath?: boolean;
  70558. cap?: number;
  70559. updatable?: boolean;
  70560. sideOrientation?: number;
  70561. frontUVs?: Vector4;
  70562. backUVs?: Vector4;
  70563. instance?: Mesh;
  70564. invertUV?: boolean;
  70565. }, scene?: Nullable<Scene>): Mesh;
  70566. /**
  70567. * Creates lathe mesh.
  70568. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  70569. * * 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
  70570. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  70571. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  70572. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  70573. * * 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
  70574. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  70575. * * 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
  70576. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70577. * * 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
  70578. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  70579. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70580. * @param name defines the name of the mesh
  70581. * @param options defines the options used to create the mesh
  70582. * @param scene defines the hosting scene
  70583. * @returns the lathe mesh
  70584. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  70585. */
  70586. static CreateLathe(name: string, options: {
  70587. shape: Vector3[];
  70588. radius?: number;
  70589. tessellation?: number;
  70590. clip?: number;
  70591. arc?: number;
  70592. closed?: boolean;
  70593. updatable?: boolean;
  70594. sideOrientation?: number;
  70595. frontUVs?: Vector4;
  70596. backUVs?: Vector4;
  70597. cap?: number;
  70598. invertUV?: boolean;
  70599. }, scene?: Nullable<Scene>): Mesh;
  70600. /**
  70601. * Creates a tiled plane mesh
  70602. * * You can set a limited pattern arrangement with the tiles
  70603. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70604. * * 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
  70605. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70606. * @param name defines the name of the mesh
  70607. * @param options defines the options used to create the mesh
  70608. * @param scene defines the hosting scene
  70609. * @returns the plane mesh
  70610. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  70611. */
  70612. static CreateTiledPlane(name: string, options: {
  70613. pattern?: number;
  70614. tileSize?: number;
  70615. tileWidth?: number;
  70616. tileHeight?: number;
  70617. size?: number;
  70618. width?: number;
  70619. height?: number;
  70620. alignHorizontal?: number;
  70621. alignVertical?: number;
  70622. sideOrientation?: number;
  70623. frontUVs?: Vector4;
  70624. backUVs?: Vector4;
  70625. updatable?: boolean;
  70626. }, scene?: Nullable<Scene>): Mesh;
  70627. /**
  70628. * Creates a plane mesh
  70629. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  70630. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  70631. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  70632. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70633. * * 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
  70634. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70635. * @param name defines the name of the mesh
  70636. * @param options defines the options used to create the mesh
  70637. * @param scene defines the hosting scene
  70638. * @returns the plane mesh
  70639. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  70640. */
  70641. static CreatePlane(name: string, options: {
  70642. size?: number;
  70643. width?: number;
  70644. height?: number;
  70645. sideOrientation?: number;
  70646. frontUVs?: Vector4;
  70647. backUVs?: Vector4;
  70648. updatable?: boolean;
  70649. sourcePlane?: Plane;
  70650. }, scene?: Nullable<Scene>): Mesh;
  70651. /**
  70652. * Creates a ground mesh
  70653. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  70654. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  70655. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70656. * @param name defines the name of the mesh
  70657. * @param options defines the options used to create the mesh
  70658. * @param scene defines the hosting scene
  70659. * @returns the ground mesh
  70660. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  70661. */
  70662. static CreateGround(name: string, options: {
  70663. width?: number;
  70664. height?: number;
  70665. subdivisions?: number;
  70666. subdivisionsX?: number;
  70667. subdivisionsY?: number;
  70668. updatable?: boolean;
  70669. }, scene?: Nullable<Scene>): Mesh;
  70670. /**
  70671. * Creates a tiled ground mesh
  70672. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  70673. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  70674. * * 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
  70675. * * 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
  70676. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  70677. * @param name defines the name of the mesh
  70678. * @param options defines the options used to create the mesh
  70679. * @param scene defines the hosting scene
  70680. * @returns the tiled ground mesh
  70681. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  70682. */
  70683. static CreateTiledGround(name: string, options: {
  70684. xmin: number;
  70685. zmin: number;
  70686. xmax: number;
  70687. zmax: number;
  70688. subdivisions?: {
  70689. w: number;
  70690. h: number;
  70691. };
  70692. precision?: {
  70693. w: number;
  70694. h: number;
  70695. };
  70696. updatable?: boolean;
  70697. }, scene?: Nullable<Scene>): Mesh;
  70698. /**
  70699. * Creates a ground mesh from a height map
  70700. * * The parameter `url` sets the URL of the height map image resource.
  70701. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  70702. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  70703. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  70704. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  70705. * * 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.
  70706. * * 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).
  70707. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  70708. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  70709. * @param name defines the name of the mesh
  70710. * @param url defines the url to the height map
  70711. * @param options defines the options used to create the mesh
  70712. * @param scene defines the hosting scene
  70713. * @returns the ground mesh
  70714. * @see https://doc.babylonjs.com/babylon101/height_map
  70715. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  70716. */
  70717. static CreateGroundFromHeightMap(name: string, url: string, options: {
  70718. width?: number;
  70719. height?: number;
  70720. subdivisions?: number;
  70721. minHeight?: number;
  70722. maxHeight?: number;
  70723. colorFilter?: Color3;
  70724. alphaFilter?: number;
  70725. updatable?: boolean;
  70726. onReady?: (mesh: GroundMesh) => void;
  70727. }, scene?: Nullable<Scene>): GroundMesh;
  70728. /**
  70729. * Creates a polygon mesh
  70730. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  70731. * * 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
  70732. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  70733. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70734. * * 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)
  70735. * * Remember you can only change the shape positions, not their number when updating a polygon
  70736. * @param name defines the name of the mesh
  70737. * @param options defines the options used to create the mesh
  70738. * @param scene defines the hosting scene
  70739. * @param earcutInjection can be used to inject your own earcut reference
  70740. * @returns the polygon mesh
  70741. */
  70742. static CreatePolygon(name: string, options: {
  70743. shape: Vector3[];
  70744. holes?: Vector3[][];
  70745. depth?: number;
  70746. faceUV?: Vector4[];
  70747. faceColors?: Color4[];
  70748. updatable?: boolean;
  70749. sideOrientation?: number;
  70750. frontUVs?: Vector4;
  70751. backUVs?: Vector4;
  70752. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  70753. /**
  70754. * Creates an extruded polygon mesh, with depth in the Y direction.
  70755. * * 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)
  70756. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  70757. * @param name defines the name of the mesh
  70758. * @param options defines the options used to create the mesh
  70759. * @param scene defines the hosting scene
  70760. * @param earcutInjection can be used to inject your own earcut reference
  70761. * @returns the polygon mesh
  70762. */
  70763. static ExtrudePolygon(name: string, options: {
  70764. shape: Vector3[];
  70765. holes?: Vector3[][];
  70766. depth?: number;
  70767. faceUV?: Vector4[];
  70768. faceColors?: Color4[];
  70769. updatable?: boolean;
  70770. sideOrientation?: number;
  70771. frontUVs?: Vector4;
  70772. backUVs?: Vector4;
  70773. wrap?: boolean;
  70774. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  70775. /**
  70776. * Creates a tube mesh.
  70777. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  70778. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  70779. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  70780. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  70781. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  70782. * * 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)
  70783. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  70784. * * 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
  70785. * * 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
  70786. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70787. * * 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
  70788. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  70789. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70790. * @param name defines the name of the mesh
  70791. * @param options defines the options used to create the mesh
  70792. * @param scene defines the hosting scene
  70793. * @returns the tube mesh
  70794. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  70795. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  70796. */
  70797. static CreateTube(name: string, options: {
  70798. path: Vector3[];
  70799. radius?: number;
  70800. tessellation?: number;
  70801. radiusFunction?: {
  70802. (i: number, distance: number): number;
  70803. };
  70804. cap?: number;
  70805. arc?: number;
  70806. updatable?: boolean;
  70807. sideOrientation?: number;
  70808. frontUVs?: Vector4;
  70809. backUVs?: Vector4;
  70810. instance?: Mesh;
  70811. invertUV?: boolean;
  70812. }, scene?: Nullable<Scene>): Mesh;
  70813. /**
  70814. * Creates a polyhedron mesh
  70815. * * 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
  70816. * * The parameter `size` (positive float, default 1) sets the polygon size
  70817. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  70818. * * 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`
  70819. * * 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
  70820. * * 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)`)
  70821. * * 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
  70822. * * 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
  70823. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70824. * * 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
  70825. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70826. * @param name defines the name of the mesh
  70827. * @param options defines the options used to create the mesh
  70828. * @param scene defines the hosting scene
  70829. * @returns the polyhedron mesh
  70830. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  70831. */
  70832. static CreatePolyhedron(name: string, options: {
  70833. type?: number;
  70834. size?: number;
  70835. sizeX?: number;
  70836. sizeY?: number;
  70837. sizeZ?: number;
  70838. custom?: any;
  70839. faceUV?: Vector4[];
  70840. faceColors?: Color4[];
  70841. flat?: boolean;
  70842. updatable?: boolean;
  70843. sideOrientation?: number;
  70844. frontUVs?: Vector4;
  70845. backUVs?: Vector4;
  70846. }, scene?: Nullable<Scene>): Mesh;
  70847. /**
  70848. * Creates a decal mesh.
  70849. * 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
  70850. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  70851. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  70852. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  70853. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  70854. * @param name defines the name of the mesh
  70855. * @param sourceMesh defines the mesh where the decal must be applied
  70856. * @param options defines the options used to create the mesh
  70857. * @param scene defines the hosting scene
  70858. * @returns the decal mesh
  70859. * @see https://doc.babylonjs.com/how_to/decals
  70860. */
  70861. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  70862. position?: Vector3;
  70863. normal?: Vector3;
  70864. size?: Vector3;
  70865. angle?: number;
  70866. }): Mesh;
  70867. /**
  70868. * Creates a Capsule Mesh
  70869. * @param name defines the name of the mesh.
  70870. * @param options the constructors options used to shape the mesh.
  70871. * @param scene defines the scene the mesh is scoped to.
  70872. * @returns the capsule mesh
  70873. * @see https://doc.babylonjs.com/how_to/capsule_shape
  70874. */
  70875. static CreateCapsule(name: string, options?: ICreateCapsuleOptions, scene?: Nullable<Scene>): Mesh;
  70876. }
  70877. }
  70878. declare module BABYLON {
  70879. /**
  70880. * A simplifier interface for future simplification implementations
  70881. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70882. */
  70883. export interface ISimplifier {
  70884. /**
  70885. * Simplification of a given mesh according to the given settings.
  70886. * Since this requires computation, it is assumed that the function runs async.
  70887. * @param settings The settings of the simplification, including quality and distance
  70888. * @param successCallback A callback that will be called after the mesh was simplified.
  70889. * @param errorCallback in case of an error, this callback will be called. optional.
  70890. */
  70891. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  70892. }
  70893. /**
  70894. * Expected simplification settings.
  70895. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  70896. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70897. */
  70898. export interface ISimplificationSettings {
  70899. /**
  70900. * Gets or sets the expected quality
  70901. */
  70902. quality: number;
  70903. /**
  70904. * Gets or sets the distance when this optimized version should be used
  70905. */
  70906. distance: number;
  70907. /**
  70908. * Gets an already optimized mesh
  70909. */
  70910. optimizeMesh?: boolean;
  70911. }
  70912. /**
  70913. * Class used to specify simplification options
  70914. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70915. */
  70916. export class SimplificationSettings implements ISimplificationSettings {
  70917. /** expected quality */
  70918. quality: number;
  70919. /** distance when this optimized version should be used */
  70920. distance: number;
  70921. /** already optimized mesh */
  70922. optimizeMesh?: boolean | undefined;
  70923. /**
  70924. * Creates a SimplificationSettings
  70925. * @param quality expected quality
  70926. * @param distance distance when this optimized version should be used
  70927. * @param optimizeMesh already optimized mesh
  70928. */
  70929. constructor(
  70930. /** expected quality */
  70931. quality: number,
  70932. /** distance when this optimized version should be used */
  70933. distance: number,
  70934. /** already optimized mesh */
  70935. optimizeMesh?: boolean | undefined);
  70936. }
  70937. /**
  70938. * Interface used to define a simplification task
  70939. */
  70940. export interface ISimplificationTask {
  70941. /**
  70942. * Array of settings
  70943. */
  70944. settings: Array<ISimplificationSettings>;
  70945. /**
  70946. * Simplification type
  70947. */
  70948. simplificationType: SimplificationType;
  70949. /**
  70950. * Mesh to simplify
  70951. */
  70952. mesh: Mesh;
  70953. /**
  70954. * Callback called on success
  70955. */
  70956. successCallback?: () => void;
  70957. /**
  70958. * Defines if parallel processing can be used
  70959. */
  70960. parallelProcessing: boolean;
  70961. }
  70962. /**
  70963. * Queue used to order the simplification tasks
  70964. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70965. */
  70966. export class SimplificationQueue {
  70967. private _simplificationArray;
  70968. /**
  70969. * Gets a boolean indicating that the process is still running
  70970. */
  70971. running: boolean;
  70972. /**
  70973. * Creates a new queue
  70974. */
  70975. constructor();
  70976. /**
  70977. * Adds a new simplification task
  70978. * @param task defines a task to add
  70979. */
  70980. addTask(task: ISimplificationTask): void;
  70981. /**
  70982. * Execute next task
  70983. */
  70984. executeNext(): void;
  70985. /**
  70986. * Execute a simplification task
  70987. * @param task defines the task to run
  70988. */
  70989. runSimplification(task: ISimplificationTask): void;
  70990. private getSimplifier;
  70991. }
  70992. /**
  70993. * The implemented types of simplification
  70994. * At the moment only Quadratic Error Decimation is implemented
  70995. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70996. */
  70997. export enum SimplificationType {
  70998. /** Quadratic error decimation */
  70999. QUADRATIC = 0
  71000. }
  71001. /**
  71002. * An implementation of the Quadratic Error simplification algorithm.
  71003. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  71004. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  71005. * @author RaananW
  71006. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  71007. */
  71008. export class QuadraticErrorSimplification implements ISimplifier {
  71009. private _mesh;
  71010. private triangles;
  71011. private vertices;
  71012. private references;
  71013. private _reconstructedMesh;
  71014. /** Gets or sets the number pf sync interations */
  71015. syncIterations: number;
  71016. /** Gets or sets the aggressiveness of the simplifier */
  71017. aggressiveness: number;
  71018. /** Gets or sets the number of allowed iterations for decimation */
  71019. decimationIterations: number;
  71020. /** Gets or sets the espilon to use for bounding box computation */
  71021. boundingBoxEpsilon: number;
  71022. /**
  71023. * Creates a new QuadraticErrorSimplification
  71024. * @param _mesh defines the target mesh
  71025. */
  71026. constructor(_mesh: Mesh);
  71027. /**
  71028. * Simplification of a given mesh according to the given settings.
  71029. * Since this requires computation, it is assumed that the function runs async.
  71030. * @param settings The settings of the simplification, including quality and distance
  71031. * @param successCallback A callback that will be called after the mesh was simplified.
  71032. */
  71033. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  71034. private runDecimation;
  71035. private initWithMesh;
  71036. private init;
  71037. private reconstructMesh;
  71038. private initDecimatedMesh;
  71039. private isFlipped;
  71040. private updateTriangles;
  71041. private identifyBorder;
  71042. private updateMesh;
  71043. private vertexError;
  71044. private calculateError;
  71045. }
  71046. }
  71047. declare module BABYLON {
  71048. interface Scene {
  71049. /** @hidden (Backing field) */
  71050. _simplificationQueue: SimplificationQueue;
  71051. /**
  71052. * Gets or sets the simplification queue attached to the scene
  71053. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  71054. */
  71055. simplificationQueue: SimplificationQueue;
  71056. }
  71057. interface Mesh {
  71058. /**
  71059. * Simplify the mesh according to the given array of settings.
  71060. * Function will return immediately and will simplify async
  71061. * @param settings a collection of simplification settings
  71062. * @param parallelProcessing should all levels calculate parallel or one after the other
  71063. * @param simplificationType the type of simplification to run
  71064. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  71065. * @returns the current mesh
  71066. */
  71067. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  71068. }
  71069. /**
  71070. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  71071. * created in a scene
  71072. */
  71073. export class SimplicationQueueSceneComponent implements ISceneComponent {
  71074. /**
  71075. * The component name helpfull to identify the component in the list of scene components.
  71076. */
  71077. readonly name: string;
  71078. /**
  71079. * The scene the component belongs to.
  71080. */
  71081. scene: Scene;
  71082. /**
  71083. * Creates a new instance of the component for the given scene
  71084. * @param scene Defines the scene to register the component in
  71085. */
  71086. constructor(scene: Scene);
  71087. /**
  71088. * Registers the component in a given scene
  71089. */
  71090. register(): void;
  71091. /**
  71092. * Rebuilds the elements related to this component in case of
  71093. * context lost for instance.
  71094. */
  71095. rebuild(): void;
  71096. /**
  71097. * Disposes the component and the associated ressources
  71098. */
  71099. dispose(): void;
  71100. private _beforeCameraUpdate;
  71101. }
  71102. }
  71103. declare module BABYLON {
  71104. interface Mesh {
  71105. /**
  71106. * Gets or sets a boolean defining if we want picking to pick thin instances as well
  71107. */
  71108. thinInstanceEnablePicking: boolean;
  71109. /**
  71110. * Creates a new thin instance
  71111. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  71112. * @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
  71113. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  71114. */
  71115. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  71116. /**
  71117. * Adds the transformation (matrix) of the current mesh as a thin instance
  71118. * @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
  71119. * @returns the thin instance index number
  71120. */
  71121. thinInstanceAddSelf(refresh: boolean): number;
  71122. /**
  71123. * Registers a custom attribute to be used with thin instances
  71124. * @param kind name of the attribute
  71125. * @param stride size in floats of the attribute
  71126. */
  71127. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  71128. /**
  71129. * Sets the matrix of a thin instance
  71130. * @param index index of the thin instance
  71131. * @param matrix matrix to set
  71132. * @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
  71133. */
  71134. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  71135. /**
  71136. * Sets the value of a custom attribute for a thin instance
  71137. * @param kind name of the attribute
  71138. * @param index index of the thin instance
  71139. * @param value value to set
  71140. * @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
  71141. */
  71142. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  71143. /**
  71144. * 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.
  71145. */
  71146. thinInstanceCount: number;
  71147. /**
  71148. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  71149. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  71150. * @param buffer buffer to set
  71151. * @param stride size in floats of each value of the buffer
  71152. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  71153. */
  71154. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  71155. /**
  71156. * Gets the list of world matrices
  71157. * @return an array containing all the world matrices from the thin instances
  71158. */
  71159. thinInstanceGetWorldMatrices(): Matrix[];
  71160. /**
  71161. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  71162. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  71163. */
  71164. thinInstanceBufferUpdated(kind: string): void;
  71165. /**
  71166. * Applies a partial update to a buffer directly on the GPU
  71167. * 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
  71168. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  71169. * @param data the data to set in the GPU buffer
  71170. * @param offset the offset in the GPU buffer where to update the data
  71171. */
  71172. thinInstancePartialBufferUpdate(kind: string, data: Float32Array, offset: number): void;
  71173. /**
  71174. * Refreshes the bounding info, taking into account all the thin instances defined
  71175. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  71176. */
  71177. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  71178. /** @hidden */
  71179. _thinInstanceInitializeUserStorage(): void;
  71180. /** @hidden */
  71181. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  71182. /** @hidden */
  71183. _userThinInstanceBuffersStorage: {
  71184. data: {
  71185. [key: string]: Float32Array;
  71186. };
  71187. sizes: {
  71188. [key: string]: number;
  71189. };
  71190. vertexBuffers: {
  71191. [key: string]: Nullable<VertexBuffer>;
  71192. };
  71193. strides: {
  71194. [key: string]: number;
  71195. };
  71196. };
  71197. }
  71198. }
  71199. declare module BABYLON {
  71200. /**
  71201. * Navigation plugin interface to add navigation constrained by a navigation mesh
  71202. */
  71203. export interface INavigationEnginePlugin {
  71204. /**
  71205. * plugin name
  71206. */
  71207. name: string;
  71208. /**
  71209. * Creates a navigation mesh
  71210. * @param meshes array of all the geometry used to compute the navigatio mesh
  71211. * @param parameters bunch of parameters used to filter geometry
  71212. */
  71213. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  71214. /**
  71215. * Create a navigation mesh debug mesh
  71216. * @param scene is where the mesh will be added
  71217. * @returns debug display mesh
  71218. */
  71219. createDebugNavMesh(scene: Scene): Mesh;
  71220. /**
  71221. * Get a navigation mesh constrained position, closest to the parameter position
  71222. * @param position world position
  71223. * @returns the closest point to position constrained by the navigation mesh
  71224. */
  71225. getClosestPoint(position: Vector3): Vector3;
  71226. /**
  71227. * Get a navigation mesh constrained position, closest to the parameter position
  71228. * @param position world position
  71229. * @param result output the closest point to position constrained by the navigation mesh
  71230. */
  71231. getClosestPointToRef(position: Vector3, result: Vector3): void;
  71232. /**
  71233. * Get a navigation mesh constrained position, within a particular radius
  71234. * @param position world position
  71235. * @param maxRadius the maximum distance to the constrained world position
  71236. * @returns the closest point to position constrained by the navigation mesh
  71237. */
  71238. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  71239. /**
  71240. * Get a navigation mesh constrained position, within a particular radius
  71241. * @param position world position
  71242. * @param maxRadius the maximum distance to the constrained world position
  71243. * @param result output the closest point to position constrained by the navigation mesh
  71244. */
  71245. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  71246. /**
  71247. * Compute the final position from a segment made of destination-position
  71248. * @param position world position
  71249. * @param destination world position
  71250. * @returns the resulting point along the navmesh
  71251. */
  71252. moveAlong(position: Vector3, destination: Vector3): Vector3;
  71253. /**
  71254. * Compute the final position from a segment made of destination-position
  71255. * @param position world position
  71256. * @param destination world position
  71257. * @param result output the resulting point along the navmesh
  71258. */
  71259. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  71260. /**
  71261. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  71262. * @param start world position
  71263. * @param end world position
  71264. * @returns array containing world position composing the path
  71265. */
  71266. computePath(start: Vector3, end: Vector3): Vector3[];
  71267. /**
  71268. * If this plugin is supported
  71269. * @returns true if plugin is supported
  71270. */
  71271. isSupported(): boolean;
  71272. /**
  71273. * Create a new Crowd so you can add agents
  71274. * @param maxAgents the maximum agent count in the crowd
  71275. * @param maxAgentRadius the maximum radius an agent can have
  71276. * @param scene to attach the crowd to
  71277. * @returns the crowd you can add agents to
  71278. */
  71279. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  71280. /**
  71281. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  71282. * The queries will try to find a solution within those bounds
  71283. * default is (1,1,1)
  71284. * @param extent x,y,z value that define the extent around the queries point of reference
  71285. */
  71286. setDefaultQueryExtent(extent: Vector3): void;
  71287. /**
  71288. * Get the Bounding box extent specified by setDefaultQueryExtent
  71289. * @returns the box extent values
  71290. */
  71291. getDefaultQueryExtent(): Vector3;
  71292. /**
  71293. * build the navmesh from a previously saved state using getNavmeshData
  71294. * @param data the Uint8Array returned by getNavmeshData
  71295. */
  71296. buildFromNavmeshData(data: Uint8Array): void;
  71297. /**
  71298. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  71299. * @returns data the Uint8Array that can be saved and reused
  71300. */
  71301. getNavmeshData(): Uint8Array;
  71302. /**
  71303. * Get the Bounding box extent result specified by setDefaultQueryExtent
  71304. * @param result output the box extent values
  71305. */
  71306. getDefaultQueryExtentToRef(result: Vector3): void;
  71307. /**
  71308. * Set the time step of the navigation tick update.
  71309. * Default is 1/60.
  71310. * A value of 0 will disable fixed time update
  71311. * @param newTimeStep the new timestep to apply to this world.
  71312. */
  71313. setTimeStep(newTimeStep: number): void;
  71314. /**
  71315. * Get the time step of the navigation tick update.
  71316. * @returns the current time step
  71317. */
  71318. getTimeStep(): number;
  71319. /**
  71320. * If delta time in navigation tick update is greater than the time step
  71321. * a number of sub iterations are done. If more iterations are need to reach deltatime
  71322. * they will be discarded.
  71323. * A value of 0 will set to no maximum and update will use as many substeps as needed
  71324. * @param newStepCount the maximum number of iterations
  71325. */
  71326. setMaximumSubStepCount(newStepCount: number): void;
  71327. /**
  71328. * Get the maximum number of iterations per navigation tick update
  71329. * @returns the maximum number of iterations
  71330. */
  71331. getMaximumSubStepCount(): number;
  71332. /**
  71333. * Release all resources
  71334. */
  71335. dispose(): void;
  71336. }
  71337. /**
  71338. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  71339. */
  71340. export interface ICrowd {
  71341. /**
  71342. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  71343. * You can attach anything to that node. The node position is updated in the scene update tick.
  71344. * @param pos world position that will be constrained by the navigation mesh
  71345. * @param parameters agent parameters
  71346. * @param transform hooked to the agent that will be update by the scene
  71347. * @returns agent index
  71348. */
  71349. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  71350. /**
  71351. * Returns the agent position in world space
  71352. * @param index agent index returned by addAgent
  71353. * @returns world space position
  71354. */
  71355. getAgentPosition(index: number): Vector3;
  71356. /**
  71357. * Gets the agent position result in world space
  71358. * @param index agent index returned by addAgent
  71359. * @param result output world space position
  71360. */
  71361. getAgentPositionToRef(index: number, result: Vector3): void;
  71362. /**
  71363. * Gets the agent velocity in world space
  71364. * @param index agent index returned by addAgent
  71365. * @returns world space velocity
  71366. */
  71367. getAgentVelocity(index: number): Vector3;
  71368. /**
  71369. * Gets the agent velocity result in world space
  71370. * @param index agent index returned by addAgent
  71371. * @param result output world space velocity
  71372. */
  71373. getAgentVelocityToRef(index: number, result: Vector3): void;
  71374. /**
  71375. * Gets the agent next target point on the path
  71376. * @param index agent index returned by addAgent
  71377. * @returns world space position
  71378. */
  71379. getAgentNextTargetPath(index: number): Vector3;
  71380. /**
  71381. * Gets the agent state
  71382. * @param index agent index returned by addAgent
  71383. * @returns agent state
  71384. */
  71385. getAgentState(index: number): number;
  71386. /**
  71387. * returns true if the agent in over an off mesh link connection
  71388. * @param index agent index returned by addAgent
  71389. * @returns true if over an off mesh link connection
  71390. */
  71391. overOffmeshConnection(index: number): boolean;
  71392. /**
  71393. * Gets the agent next target point on the path
  71394. * @param index agent index returned by addAgent
  71395. * @param result output world space position
  71396. */
  71397. getAgentNextTargetPathToRef(index: number, result: Vector3): void;
  71398. /**
  71399. * remove a particular agent previously created
  71400. * @param index agent index returned by addAgent
  71401. */
  71402. removeAgent(index: number): void;
  71403. /**
  71404. * get the list of all agents attached to this crowd
  71405. * @returns list of agent indices
  71406. */
  71407. getAgents(): number[];
  71408. /**
  71409. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  71410. * @param deltaTime in seconds
  71411. */
  71412. update(deltaTime: number): void;
  71413. /**
  71414. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  71415. * @param index agent index returned by addAgent
  71416. * @param destination targeted world position
  71417. */
  71418. agentGoto(index: number, destination: Vector3): void;
  71419. /**
  71420. * Teleport the agent to a new position
  71421. * @param index agent index returned by addAgent
  71422. * @param destination targeted world position
  71423. */
  71424. agentTeleport(index: number, destination: Vector3): void;
  71425. /**
  71426. * Update agent parameters
  71427. * @param index agent index returned by addAgent
  71428. * @param parameters agent parameters
  71429. */
  71430. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  71431. /**
  71432. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  71433. * The queries will try to find a solution within those bounds
  71434. * default is (1,1,1)
  71435. * @param extent x,y,z value that define the extent around the queries point of reference
  71436. */
  71437. setDefaultQueryExtent(extent: Vector3): void;
  71438. /**
  71439. * Get the Bounding box extent specified by setDefaultQueryExtent
  71440. * @returns the box extent values
  71441. */
  71442. getDefaultQueryExtent(): Vector3;
  71443. /**
  71444. * Get the Bounding box extent result specified by setDefaultQueryExtent
  71445. * @param result output the box extent values
  71446. */
  71447. getDefaultQueryExtentToRef(result: Vector3): void;
  71448. /**
  71449. * Release all resources
  71450. */
  71451. dispose(): void;
  71452. }
  71453. /**
  71454. * Configures an agent
  71455. */
  71456. export interface IAgentParameters {
  71457. /**
  71458. * Agent radius. [Limit: >= 0]
  71459. */
  71460. radius: number;
  71461. /**
  71462. * Agent height. [Limit: > 0]
  71463. */
  71464. height: number;
  71465. /**
  71466. * Maximum allowed acceleration. [Limit: >= 0]
  71467. */
  71468. maxAcceleration: number;
  71469. /**
  71470. * Maximum allowed speed. [Limit: >= 0]
  71471. */
  71472. maxSpeed: number;
  71473. /**
  71474. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  71475. */
  71476. collisionQueryRange: number;
  71477. /**
  71478. * The path visibility optimization range. [Limit: > 0]
  71479. */
  71480. pathOptimizationRange: number;
  71481. /**
  71482. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  71483. */
  71484. separationWeight: number;
  71485. }
  71486. /**
  71487. * Configures the navigation mesh creation
  71488. */
  71489. export interface INavMeshParameters {
  71490. /**
  71491. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  71492. */
  71493. cs: number;
  71494. /**
  71495. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  71496. */
  71497. ch: number;
  71498. /**
  71499. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  71500. */
  71501. walkableSlopeAngle: number;
  71502. /**
  71503. * Minimum floor to 'ceiling' height that will still allow the floor area to
  71504. * be considered walkable. [Limit: >= 3] [Units: vx]
  71505. */
  71506. walkableHeight: number;
  71507. /**
  71508. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  71509. */
  71510. walkableClimb: number;
  71511. /**
  71512. * The distance to erode/shrink the walkable area of the heightfield away from
  71513. * obstructions. [Limit: >=0] [Units: vx]
  71514. */
  71515. walkableRadius: number;
  71516. /**
  71517. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  71518. */
  71519. maxEdgeLen: number;
  71520. /**
  71521. * The maximum distance a simplfied contour's border edges should deviate
  71522. * the original raw contour. [Limit: >=0] [Units: vx]
  71523. */
  71524. maxSimplificationError: number;
  71525. /**
  71526. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  71527. */
  71528. minRegionArea: number;
  71529. /**
  71530. * Any regions with a span count smaller than this value will, if possible,
  71531. * be merged with larger regions. [Limit: >=0] [Units: vx]
  71532. */
  71533. mergeRegionArea: number;
  71534. /**
  71535. * The maximum number of vertices allowed for polygons generated during the
  71536. * contour to polygon conversion process. [Limit: >= 3]
  71537. */
  71538. maxVertsPerPoly: number;
  71539. /**
  71540. * Sets the sampling distance to use when generating the detail mesh.
  71541. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  71542. */
  71543. detailSampleDist: number;
  71544. /**
  71545. * The maximum distance the detail mesh surface should deviate from heightfield
  71546. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  71547. */
  71548. detailSampleMaxError: number;
  71549. }
  71550. }
  71551. declare module BABYLON {
  71552. /**
  71553. * RecastJS navigation plugin
  71554. */
  71555. export class RecastJSPlugin implements INavigationEnginePlugin {
  71556. /**
  71557. * Reference to the Recast library
  71558. */
  71559. bjsRECAST: any;
  71560. /**
  71561. * plugin name
  71562. */
  71563. name: string;
  71564. /**
  71565. * the first navmesh created. We might extend this to support multiple navmeshes
  71566. */
  71567. navMesh: any;
  71568. private _maximumSubStepCount;
  71569. private _timeStep;
  71570. /**
  71571. * Initializes the recastJS plugin
  71572. * @param recastInjection can be used to inject your own recast reference
  71573. */
  71574. constructor(recastInjection?: any);
  71575. /**
  71576. * Set the time step of the navigation tick update.
  71577. * Default is 1/60.
  71578. * A value of 0 will disable fixed time update
  71579. * @param newTimeStep the new timestep to apply to this world.
  71580. */
  71581. setTimeStep(newTimeStep?: number): void;
  71582. /**
  71583. * Get the time step of the navigation tick update.
  71584. * @returns the current time step
  71585. */
  71586. getTimeStep(): number;
  71587. /**
  71588. * If delta time in navigation tick update is greater than the time step
  71589. * a number of sub iterations are done. If more iterations are need to reach deltatime
  71590. * they will be discarded.
  71591. * A value of 0 will set to no maximum and update will use as many substeps as needed
  71592. * @param newStepCount the maximum number of iterations
  71593. */
  71594. setMaximumSubStepCount(newStepCount?: number): void;
  71595. /**
  71596. * Get the maximum number of iterations per navigation tick update
  71597. * @returns the maximum number of iterations
  71598. */
  71599. getMaximumSubStepCount(): number;
  71600. /**
  71601. * Creates a navigation mesh
  71602. * @param meshes array of all the geometry used to compute the navigatio mesh
  71603. * @param parameters bunch of parameters used to filter geometry
  71604. */
  71605. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  71606. /**
  71607. * Create a navigation mesh debug mesh
  71608. * @param scene is where the mesh will be added
  71609. * @returns debug display mesh
  71610. */
  71611. createDebugNavMesh(scene: Scene): Mesh;
  71612. /**
  71613. * Get a navigation mesh constrained position, closest to the parameter position
  71614. * @param position world position
  71615. * @returns the closest point to position constrained by the navigation mesh
  71616. */
  71617. getClosestPoint(position: Vector3): Vector3;
  71618. /**
  71619. * Get a navigation mesh constrained position, closest to the parameter position
  71620. * @param position world position
  71621. * @param result output the closest point to position constrained by the navigation mesh
  71622. */
  71623. getClosestPointToRef(position: Vector3, result: Vector3): void;
  71624. /**
  71625. * Get a navigation mesh constrained position, within a particular radius
  71626. * @param position world position
  71627. * @param maxRadius the maximum distance to the constrained world position
  71628. * @returns the closest point to position constrained by the navigation mesh
  71629. */
  71630. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  71631. /**
  71632. * Get a navigation mesh constrained position, within a particular radius
  71633. * @param position world position
  71634. * @param maxRadius the maximum distance to the constrained world position
  71635. * @param result output the closest point to position constrained by the navigation mesh
  71636. */
  71637. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  71638. /**
  71639. * Compute the final position from a segment made of destination-position
  71640. * @param position world position
  71641. * @param destination world position
  71642. * @returns the resulting point along the navmesh
  71643. */
  71644. moveAlong(position: Vector3, destination: Vector3): Vector3;
  71645. /**
  71646. * Compute the final position from a segment made of destination-position
  71647. * @param position world position
  71648. * @param destination world position
  71649. * @param result output the resulting point along the navmesh
  71650. */
  71651. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  71652. /**
  71653. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  71654. * @param start world position
  71655. * @param end world position
  71656. * @returns array containing world position composing the path
  71657. */
  71658. computePath(start: Vector3, end: Vector3): Vector3[];
  71659. /**
  71660. * Create a new Crowd so you can add agents
  71661. * @param maxAgents the maximum agent count in the crowd
  71662. * @param maxAgentRadius the maximum radius an agent can have
  71663. * @param scene to attach the crowd to
  71664. * @returns the crowd you can add agents to
  71665. */
  71666. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  71667. /**
  71668. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  71669. * The queries will try to find a solution within those bounds
  71670. * default is (1,1,1)
  71671. * @param extent x,y,z value that define the extent around the queries point of reference
  71672. */
  71673. setDefaultQueryExtent(extent: Vector3): void;
  71674. /**
  71675. * Get the Bounding box extent specified by setDefaultQueryExtent
  71676. * @returns the box extent values
  71677. */
  71678. getDefaultQueryExtent(): Vector3;
  71679. /**
  71680. * build the navmesh from a previously saved state using getNavmeshData
  71681. * @param data the Uint8Array returned by getNavmeshData
  71682. */
  71683. buildFromNavmeshData(data: Uint8Array): void;
  71684. /**
  71685. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  71686. * @returns data the Uint8Array that can be saved and reused
  71687. */
  71688. getNavmeshData(): Uint8Array;
  71689. /**
  71690. * Get the Bounding box extent result specified by setDefaultQueryExtent
  71691. * @param result output the box extent values
  71692. */
  71693. getDefaultQueryExtentToRef(result: Vector3): void;
  71694. /**
  71695. * Disposes
  71696. */
  71697. dispose(): void;
  71698. /**
  71699. * If this plugin is supported
  71700. * @returns true if plugin is supported
  71701. */
  71702. isSupported(): boolean;
  71703. }
  71704. /**
  71705. * Recast detour crowd implementation
  71706. */
  71707. export class RecastJSCrowd implements ICrowd {
  71708. /**
  71709. * Recast/detour plugin
  71710. */
  71711. bjsRECASTPlugin: RecastJSPlugin;
  71712. /**
  71713. * Link to the detour crowd
  71714. */
  71715. recastCrowd: any;
  71716. /**
  71717. * One transform per agent
  71718. */
  71719. transforms: TransformNode[];
  71720. /**
  71721. * All agents created
  71722. */
  71723. agents: number[];
  71724. /**
  71725. * Link to the scene is kept to unregister the crowd from the scene
  71726. */
  71727. private _scene;
  71728. /**
  71729. * Observer for crowd updates
  71730. */
  71731. private _onBeforeAnimationsObserver;
  71732. /**
  71733. * Constructor
  71734. * @param plugin recastJS plugin
  71735. * @param maxAgents the maximum agent count in the crowd
  71736. * @param maxAgentRadius the maximum radius an agent can have
  71737. * @param scene to attach the crowd to
  71738. * @returns the crowd you can add agents to
  71739. */
  71740. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  71741. /**
  71742. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  71743. * You can attach anything to that node. The node position is updated in the scene update tick.
  71744. * @param pos world position that will be constrained by the navigation mesh
  71745. * @param parameters agent parameters
  71746. * @param transform hooked to the agent that will be update by the scene
  71747. * @returns agent index
  71748. */
  71749. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  71750. /**
  71751. * Returns the agent position in world space
  71752. * @param index agent index returned by addAgent
  71753. * @returns world space position
  71754. */
  71755. getAgentPosition(index: number): Vector3;
  71756. /**
  71757. * Returns the agent position result in world space
  71758. * @param index agent index returned by addAgent
  71759. * @param result output world space position
  71760. */
  71761. getAgentPositionToRef(index: number, result: Vector3): void;
  71762. /**
  71763. * Returns the agent velocity in world space
  71764. * @param index agent index returned by addAgent
  71765. * @returns world space velocity
  71766. */
  71767. getAgentVelocity(index: number): Vector3;
  71768. /**
  71769. * Returns the agent velocity result in world space
  71770. * @param index agent index returned by addAgent
  71771. * @param result output world space velocity
  71772. */
  71773. getAgentVelocityToRef(index: number, result: Vector3): void;
  71774. /**
  71775. * Returns the agent next target point on the path
  71776. * @param index agent index returned by addAgent
  71777. * @returns world space position
  71778. */
  71779. getAgentNextTargetPath(index: number): Vector3;
  71780. /**
  71781. * Returns the agent next target point on the path
  71782. * @param index agent index returned by addAgent
  71783. * @param result output world space position
  71784. */
  71785. getAgentNextTargetPathToRef(index: number, result: Vector3): void;
  71786. /**
  71787. * Gets the agent state
  71788. * @param index agent index returned by addAgent
  71789. * @returns agent state
  71790. */
  71791. getAgentState(index: number): number;
  71792. /**
  71793. * returns true if the agent in over an off mesh link connection
  71794. * @param index agent index returned by addAgent
  71795. * @returns true if over an off mesh link connection
  71796. */
  71797. overOffmeshConnection(index: number): boolean;
  71798. /**
  71799. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  71800. * @param index agent index returned by addAgent
  71801. * @param destination targeted world position
  71802. */
  71803. agentGoto(index: number, destination: Vector3): void;
  71804. /**
  71805. * Teleport the agent to a new position
  71806. * @param index agent index returned by addAgent
  71807. * @param destination targeted world position
  71808. */
  71809. agentTeleport(index: number, destination: Vector3): void;
  71810. /**
  71811. * Update agent parameters
  71812. * @param index agent index returned by addAgent
  71813. * @param parameters agent parameters
  71814. */
  71815. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  71816. /**
  71817. * remove a particular agent previously created
  71818. * @param index agent index returned by addAgent
  71819. */
  71820. removeAgent(index: number): void;
  71821. /**
  71822. * get the list of all agents attached to this crowd
  71823. * @returns list of agent indices
  71824. */
  71825. getAgents(): number[];
  71826. /**
  71827. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  71828. * @param deltaTime in seconds
  71829. */
  71830. update(deltaTime: number): void;
  71831. /**
  71832. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  71833. * The queries will try to find a solution within those bounds
  71834. * default is (1,1,1)
  71835. * @param extent x,y,z value that define the extent around the queries point of reference
  71836. */
  71837. setDefaultQueryExtent(extent: Vector3): void;
  71838. /**
  71839. * Get the Bounding box extent specified by setDefaultQueryExtent
  71840. * @returns the box extent values
  71841. */
  71842. getDefaultQueryExtent(): Vector3;
  71843. /**
  71844. * Get the Bounding box extent result specified by setDefaultQueryExtent
  71845. * @param result output the box extent values
  71846. */
  71847. getDefaultQueryExtentToRef(result: Vector3): void;
  71848. /**
  71849. * Release all resources
  71850. */
  71851. dispose(): void;
  71852. }
  71853. }
  71854. declare module BABYLON {
  71855. /**
  71856. * Class used to enable access to IndexedDB
  71857. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  71858. */
  71859. export class Database implements IOfflineProvider {
  71860. private _callbackManifestChecked;
  71861. private _currentSceneUrl;
  71862. private _db;
  71863. private _enableSceneOffline;
  71864. private _enableTexturesOffline;
  71865. private _manifestVersionFound;
  71866. private _mustUpdateRessources;
  71867. private _hasReachedQuota;
  71868. private _isSupported;
  71869. private _idbFactory;
  71870. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  71871. private static IsUASupportingBlobStorage;
  71872. /**
  71873. * Gets a boolean indicating if Database storate is enabled (off by default)
  71874. */
  71875. static IDBStorageEnabled: boolean;
  71876. /**
  71877. * Gets a boolean indicating if scene must be saved in the database
  71878. */
  71879. get enableSceneOffline(): boolean;
  71880. /**
  71881. * Gets a boolean indicating if textures must be saved in the database
  71882. */
  71883. get enableTexturesOffline(): boolean;
  71884. /**
  71885. * Creates a new Database
  71886. * @param urlToScene defines the url to load the scene
  71887. * @param callbackManifestChecked defines the callback to use when manifest is checked
  71888. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  71889. */
  71890. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  71891. private static _ParseURL;
  71892. private static _ReturnFullUrlLocation;
  71893. private _checkManifestFile;
  71894. /**
  71895. * Open the database and make it available
  71896. * @param successCallback defines the callback to call on success
  71897. * @param errorCallback defines the callback to call on error
  71898. */
  71899. open(successCallback: () => void, errorCallback: () => void): void;
  71900. /**
  71901. * Loads an image from the database
  71902. * @param url defines the url to load from
  71903. * @param image defines the target DOM image
  71904. */
  71905. loadImage(url: string, image: HTMLImageElement): void;
  71906. private _loadImageFromDBAsync;
  71907. private _saveImageIntoDBAsync;
  71908. private _checkVersionFromDB;
  71909. private _loadVersionFromDBAsync;
  71910. private _saveVersionIntoDBAsync;
  71911. /**
  71912. * Loads a file from database
  71913. * @param url defines the URL to load from
  71914. * @param sceneLoaded defines a callback to call on success
  71915. * @param progressCallBack defines a callback to call when progress changed
  71916. * @param errorCallback defines a callback to call on error
  71917. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  71918. */
  71919. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  71920. private _loadFileAsync;
  71921. private _saveFileAsync;
  71922. /**
  71923. * Validates if xhr data is correct
  71924. * @param xhr defines the request to validate
  71925. * @param dataType defines the expected data type
  71926. * @returns true if data is correct
  71927. */
  71928. private static _ValidateXHRData;
  71929. }
  71930. }
  71931. declare module BABYLON {
  71932. /** @hidden */
  71933. export var gpuUpdateParticlesPixelShader: {
  71934. name: string;
  71935. shader: string;
  71936. };
  71937. }
  71938. declare module BABYLON {
  71939. /** @hidden */
  71940. export var gpuUpdateParticlesVertexShader: {
  71941. name: string;
  71942. shader: string;
  71943. };
  71944. }
  71945. declare module BABYLON {
  71946. /** @hidden */
  71947. export var clipPlaneFragmentDeclaration2: {
  71948. name: string;
  71949. shader: string;
  71950. };
  71951. }
  71952. declare module BABYLON {
  71953. /** @hidden */
  71954. export var gpuRenderParticlesPixelShader: {
  71955. name: string;
  71956. shader: string;
  71957. };
  71958. }
  71959. declare module BABYLON {
  71960. /** @hidden */
  71961. export var clipPlaneVertexDeclaration2: {
  71962. name: string;
  71963. shader: string;
  71964. };
  71965. }
  71966. declare module BABYLON {
  71967. /** @hidden */
  71968. export var gpuRenderParticlesVertexShader: {
  71969. name: string;
  71970. shader: string;
  71971. };
  71972. }
  71973. declare module BABYLON {
  71974. /**
  71975. * This represents a GPU particle system in Babylon
  71976. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  71977. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  71978. */
  71979. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  71980. /**
  71981. * The layer mask we are rendering the particles through.
  71982. */
  71983. layerMask: number;
  71984. private _capacity;
  71985. private _activeCount;
  71986. private _currentActiveCount;
  71987. private _accumulatedCount;
  71988. private _renderEffect;
  71989. private _updateEffect;
  71990. private _buffer0;
  71991. private _buffer1;
  71992. private _spriteBuffer;
  71993. private _updateVAO;
  71994. private _renderVAO;
  71995. private _targetIndex;
  71996. private _sourceBuffer;
  71997. private _targetBuffer;
  71998. private _currentRenderId;
  71999. private _started;
  72000. private _stopped;
  72001. private _timeDelta;
  72002. private _randomTexture;
  72003. private _randomTexture2;
  72004. private _attributesStrideSize;
  72005. private _updateEffectOptions;
  72006. private _randomTextureSize;
  72007. private _actualFrame;
  72008. private _customEffect;
  72009. private readonly _rawTextureWidth;
  72010. /**
  72011. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  72012. */
  72013. static get IsSupported(): boolean;
  72014. /**
  72015. * An event triggered when the system is disposed.
  72016. */
  72017. onDisposeObservable: Observable<IParticleSystem>;
  72018. /**
  72019. * An event triggered when the system is stopped
  72020. */
  72021. onStoppedObservable: Observable<IParticleSystem>;
  72022. /**
  72023. * Gets the maximum number of particles active at the same time.
  72024. * @returns The max number of active particles.
  72025. */
  72026. getCapacity(): number;
  72027. /**
  72028. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  72029. * to override the particles.
  72030. */
  72031. forceDepthWrite: boolean;
  72032. /**
  72033. * Gets or set the number of active particles
  72034. */
  72035. get activeParticleCount(): number;
  72036. set activeParticleCount(value: number);
  72037. private _preWarmDone;
  72038. /**
  72039. * Specifies if the particles are updated in emitter local space or world space.
  72040. */
  72041. isLocal: boolean;
  72042. /** Gets or sets a matrix to use to compute projection */
  72043. defaultProjectionMatrix: Matrix;
  72044. /**
  72045. * Is this system ready to be used/rendered
  72046. * @return true if the system is ready
  72047. */
  72048. isReady(): boolean;
  72049. /**
  72050. * Gets if the system has been started. (Note: this will still be true after stop is called)
  72051. * @returns True if it has been started, otherwise false.
  72052. */
  72053. isStarted(): boolean;
  72054. /**
  72055. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  72056. * @returns True if it has been stopped, otherwise false.
  72057. */
  72058. isStopped(): boolean;
  72059. /**
  72060. * Gets a boolean indicating that the system is stopping
  72061. * @returns true if the system is currently stopping
  72062. */
  72063. isStopping(): boolean;
  72064. /**
  72065. * Gets the number of particles active at the same time.
  72066. * @returns The number of active particles.
  72067. */
  72068. getActiveCount(): number;
  72069. /**
  72070. * Starts the particle system and begins to emit
  72071. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  72072. */
  72073. start(delay?: number): void;
  72074. /**
  72075. * Stops the particle system.
  72076. */
  72077. stop(): void;
  72078. /**
  72079. * Remove all active particles
  72080. */
  72081. reset(): void;
  72082. /**
  72083. * Returns the string "GPUParticleSystem"
  72084. * @returns a string containing the class name
  72085. */
  72086. getClassName(): string;
  72087. /**
  72088. * Gets the custom effect used to render the particles
  72089. * @param blendMode Blend mode for which the effect should be retrieved
  72090. * @returns The effect
  72091. */
  72092. getCustomEffect(blendMode?: number): Nullable<Effect>;
  72093. /**
  72094. * Sets the custom effect used to render the particles
  72095. * @param effect The effect to set
  72096. * @param blendMode Blend mode for which the effect should be set
  72097. */
  72098. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  72099. /** @hidden */
  72100. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  72101. /**
  72102. * Observable that will be called just before the particles are drawn
  72103. */
  72104. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  72105. /**
  72106. * Gets the name of the particle vertex shader
  72107. */
  72108. get vertexShaderName(): string;
  72109. private _colorGradientsTexture;
  72110. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  72111. /**
  72112. * Adds a new color gradient
  72113. * @param gradient defines the gradient to use (between 0 and 1)
  72114. * @param color1 defines the color to affect to the specified gradient
  72115. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  72116. * @returns the current particle system
  72117. */
  72118. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  72119. private _refreshColorGradient;
  72120. /** Force the system to rebuild all gradients that need to be resync */
  72121. forceRefreshGradients(): void;
  72122. /**
  72123. * Remove a specific color gradient
  72124. * @param gradient defines the gradient to remove
  72125. * @returns the current particle system
  72126. */
  72127. removeColorGradient(gradient: number): GPUParticleSystem;
  72128. private _angularSpeedGradientsTexture;
  72129. private _sizeGradientsTexture;
  72130. private _velocityGradientsTexture;
  72131. private _limitVelocityGradientsTexture;
  72132. private _dragGradientsTexture;
  72133. private _addFactorGradient;
  72134. /**
  72135. * Adds a new size gradient
  72136. * @param gradient defines the gradient to use (between 0 and 1)
  72137. * @param factor defines the size factor to affect to the specified gradient
  72138. * @returns the current particle system
  72139. */
  72140. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  72141. /**
  72142. * Remove a specific size gradient
  72143. * @param gradient defines the gradient to remove
  72144. * @returns the current particle system
  72145. */
  72146. removeSizeGradient(gradient: number): GPUParticleSystem;
  72147. private _refreshFactorGradient;
  72148. /**
  72149. * Adds a new angular speed gradient
  72150. * @param gradient defines the gradient to use (between 0 and 1)
  72151. * @param factor defines the angular speed to affect to the specified gradient
  72152. * @returns the current particle system
  72153. */
  72154. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  72155. /**
  72156. * Remove a specific angular speed gradient
  72157. * @param gradient defines the gradient to remove
  72158. * @returns the current particle system
  72159. */
  72160. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  72161. /**
  72162. * Adds a new velocity gradient
  72163. * @param gradient defines the gradient to use (between 0 and 1)
  72164. * @param factor defines the velocity to affect to the specified gradient
  72165. * @returns the current particle system
  72166. */
  72167. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  72168. /**
  72169. * Remove a specific velocity gradient
  72170. * @param gradient defines the gradient to remove
  72171. * @returns the current particle system
  72172. */
  72173. removeVelocityGradient(gradient: number): GPUParticleSystem;
  72174. /**
  72175. * Adds a new limit velocity gradient
  72176. * @param gradient defines the gradient to use (between 0 and 1)
  72177. * @param factor defines the limit velocity value to affect to the specified gradient
  72178. * @returns the current particle system
  72179. */
  72180. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  72181. /**
  72182. * Remove a specific limit velocity gradient
  72183. * @param gradient defines the gradient to remove
  72184. * @returns the current particle system
  72185. */
  72186. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  72187. /**
  72188. * Adds a new drag gradient
  72189. * @param gradient defines the gradient to use (between 0 and 1)
  72190. * @param factor defines the drag value to affect to the specified gradient
  72191. * @returns the current particle system
  72192. */
  72193. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  72194. /**
  72195. * Remove a specific drag gradient
  72196. * @param gradient defines the gradient to remove
  72197. * @returns the current particle system
  72198. */
  72199. removeDragGradient(gradient: number): GPUParticleSystem;
  72200. /**
  72201. * Not supported by GPUParticleSystem
  72202. * @param gradient defines the gradient to use (between 0 and 1)
  72203. * @param factor defines the emit rate value to affect to the specified gradient
  72204. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72205. * @returns the current particle system
  72206. */
  72207. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72208. /**
  72209. * Not supported by GPUParticleSystem
  72210. * @param gradient defines the gradient to remove
  72211. * @returns the current particle system
  72212. */
  72213. removeEmitRateGradient(gradient: number): IParticleSystem;
  72214. /**
  72215. * Not supported by GPUParticleSystem
  72216. * @param gradient defines the gradient to use (between 0 and 1)
  72217. * @param factor defines the start size value to affect to the specified gradient
  72218. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72219. * @returns the current particle system
  72220. */
  72221. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72222. /**
  72223. * Not supported by GPUParticleSystem
  72224. * @param gradient defines the gradient to remove
  72225. * @returns the current particle system
  72226. */
  72227. removeStartSizeGradient(gradient: number): IParticleSystem;
  72228. /**
  72229. * Not supported by GPUParticleSystem
  72230. * @param gradient defines the gradient to use (between 0 and 1)
  72231. * @param min defines the color remap minimal range
  72232. * @param max defines the color remap maximal range
  72233. * @returns the current particle system
  72234. */
  72235. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  72236. /**
  72237. * Not supported by GPUParticleSystem
  72238. * @param gradient defines the gradient to remove
  72239. * @returns the current particle system
  72240. */
  72241. removeColorRemapGradient(): IParticleSystem;
  72242. /**
  72243. * Not supported by GPUParticleSystem
  72244. * @param gradient defines the gradient to use (between 0 and 1)
  72245. * @param min defines the alpha remap minimal range
  72246. * @param max defines the alpha remap maximal range
  72247. * @returns the current particle system
  72248. */
  72249. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  72250. /**
  72251. * Not supported by GPUParticleSystem
  72252. * @param gradient defines the gradient to remove
  72253. * @returns the current particle system
  72254. */
  72255. removeAlphaRemapGradient(): IParticleSystem;
  72256. /**
  72257. * Not supported by GPUParticleSystem
  72258. * @param gradient defines the gradient to use (between 0 and 1)
  72259. * @param color defines the color to affect to the specified gradient
  72260. * @returns the current particle system
  72261. */
  72262. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  72263. /**
  72264. * Not supported by GPUParticleSystem
  72265. * @param gradient defines the gradient to remove
  72266. * @returns the current particle system
  72267. */
  72268. removeRampGradient(): IParticleSystem;
  72269. /**
  72270. * Not supported by GPUParticleSystem
  72271. * @returns the list of ramp gradients
  72272. */
  72273. getRampGradients(): Nullable<Array<Color3Gradient>>;
  72274. /**
  72275. * Not supported by GPUParticleSystem
  72276. * Gets or sets a boolean indicating that ramp gradients must be used
  72277. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  72278. */
  72279. get useRampGradients(): boolean;
  72280. set useRampGradients(value: boolean);
  72281. /**
  72282. * Not supported by GPUParticleSystem
  72283. * @param gradient defines the gradient to use (between 0 and 1)
  72284. * @param factor defines the life time factor to affect to the specified gradient
  72285. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72286. * @returns the current particle system
  72287. */
  72288. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72289. /**
  72290. * Not supported by GPUParticleSystem
  72291. * @param gradient defines the gradient to remove
  72292. * @returns the current particle system
  72293. */
  72294. removeLifeTimeGradient(gradient: number): IParticleSystem;
  72295. /**
  72296. * Instantiates a GPU particle system.
  72297. * 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.
  72298. * @param name The name of the particle system
  72299. * @param options The options used to create the system
  72300. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  72301. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  72302. * @param customEffect a custom effect used to change the way particles are rendered by default
  72303. */
  72304. constructor(name: string, options: Partial<{
  72305. capacity: number;
  72306. randomTextureSize: number;
  72307. }>, sceneOrEngine: Scene | ThinEngine, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  72308. protected _reset(): void;
  72309. private _createUpdateVAO;
  72310. private _createRenderVAO;
  72311. private _initialize;
  72312. /** @hidden */
  72313. _recreateUpdateEffect(): void;
  72314. private _getEffect;
  72315. /**
  72316. * Fill the defines array according to the current settings of the particle system
  72317. * @param defines Array to be updated
  72318. * @param blendMode blend mode to take into account when updating the array
  72319. */
  72320. fillDefines(defines: Array<string>, blendMode?: number): void;
  72321. /**
  72322. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  72323. * @param uniforms Uniforms array to fill
  72324. * @param attributes Attributes array to fill
  72325. * @param samplers Samplers array to fill
  72326. */
  72327. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  72328. /** @hidden */
  72329. _recreateRenderEffect(): Effect;
  72330. /**
  72331. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  72332. * @param preWarm defines if we are in the pre-warmimg phase
  72333. */
  72334. animate(preWarm?: boolean): void;
  72335. private _createFactorGradientTexture;
  72336. private _createSizeGradientTexture;
  72337. private _createAngularSpeedGradientTexture;
  72338. private _createVelocityGradientTexture;
  72339. private _createLimitVelocityGradientTexture;
  72340. private _createDragGradientTexture;
  72341. private _createColorGradientTexture;
  72342. /**
  72343. * Renders the particle system in its current state
  72344. * @param preWarm defines if the system should only update the particles but not render them
  72345. * @returns the current number of particles
  72346. */
  72347. render(preWarm?: boolean): number;
  72348. /**
  72349. * Rebuilds the particle system
  72350. */
  72351. rebuild(): void;
  72352. private _releaseBuffers;
  72353. private _releaseVAOs;
  72354. /**
  72355. * Disposes the particle system and free the associated resources
  72356. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  72357. */
  72358. dispose(disposeTexture?: boolean): void;
  72359. /**
  72360. * Clones the particle system.
  72361. * @param name The name of the cloned object
  72362. * @param newEmitter The new emitter to use
  72363. * @returns the cloned particle system
  72364. */
  72365. clone(name: string, newEmitter: any): GPUParticleSystem;
  72366. /**
  72367. * Serializes the particle system to a JSON object
  72368. * @param serializeTexture defines if the texture must be serialized as well
  72369. * @returns the JSON object
  72370. */
  72371. serialize(serializeTexture?: boolean): any;
  72372. /**
  72373. * Parses a JSON object to create a GPU particle system.
  72374. * @param parsedParticleSystem The JSON object to parse
  72375. * @param sceneOrEngine The scene or the engine to create the particle system in
  72376. * @param rootUrl The root url to use to load external dependencies like texture
  72377. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  72378. * @returns the parsed GPU particle system
  72379. */
  72380. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  72381. }
  72382. }
  72383. declare module BABYLON {
  72384. /**
  72385. * Represents a set of particle systems working together to create a specific effect
  72386. */
  72387. export class ParticleSystemSet implements IDisposable {
  72388. /**
  72389. * Gets or sets base Assets URL
  72390. */
  72391. static BaseAssetsUrl: string;
  72392. private _emitterCreationOptions;
  72393. private _emitterNode;
  72394. /**
  72395. * Gets the particle system list
  72396. */
  72397. systems: IParticleSystem[];
  72398. /**
  72399. * Gets the emitter node used with this set
  72400. */
  72401. get emitterNode(): Nullable<TransformNode>;
  72402. /**
  72403. * Creates a new emitter mesh as a sphere
  72404. * @param options defines the options used to create the sphere
  72405. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  72406. * @param scene defines the hosting scene
  72407. */
  72408. setEmitterAsSphere(options: {
  72409. diameter: number;
  72410. segments: number;
  72411. color: Color3;
  72412. }, renderingGroupId: number, scene: Scene): void;
  72413. /**
  72414. * Starts all particle systems of the set
  72415. * @param emitter defines an optional mesh to use as emitter for the particle systems
  72416. */
  72417. start(emitter?: AbstractMesh): void;
  72418. /**
  72419. * Release all associated resources
  72420. */
  72421. dispose(): void;
  72422. /**
  72423. * Serialize the set into a JSON compatible object
  72424. * @param serializeTexture defines if the texture must be serialized as well
  72425. * @returns a JSON compatible representation of the set
  72426. */
  72427. serialize(serializeTexture?: boolean): any;
  72428. /**
  72429. * Parse a new ParticleSystemSet from a serialized source
  72430. * @param data defines a JSON compatible representation of the set
  72431. * @param scene defines the hosting scene
  72432. * @param gpu defines if we want GPU particles or CPU particles
  72433. * @returns a new ParticleSystemSet
  72434. */
  72435. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  72436. }
  72437. }
  72438. declare module BABYLON {
  72439. /**
  72440. * This class is made for on one-liner static method to help creating particle system set.
  72441. */
  72442. export class ParticleHelper {
  72443. /**
  72444. * Gets or sets base Assets URL
  72445. */
  72446. static BaseAssetsUrl: string;
  72447. /** Define the Url to load snippets */
  72448. static SnippetUrl: string;
  72449. /**
  72450. * Create a default particle system that you can tweak
  72451. * @param emitter defines the emitter to use
  72452. * @param capacity defines the system capacity (default is 500 particles)
  72453. * @param scene defines the hosting scene
  72454. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  72455. * @returns the new Particle system
  72456. */
  72457. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  72458. /**
  72459. * This is the main static method (one-liner) of this helper to create different particle systems
  72460. * @param type This string represents the type to the particle system to create
  72461. * @param scene The scene where the particle system should live
  72462. * @param gpu If the system will use gpu
  72463. * @returns the ParticleSystemSet created
  72464. */
  72465. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  72466. /**
  72467. * Static function used to export a particle system to a ParticleSystemSet variable.
  72468. * Please note that the emitter shape is not exported
  72469. * @param systems defines the particle systems to export
  72470. * @returns the created particle system set
  72471. */
  72472. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  72473. /**
  72474. * Creates a particle system from a snippet saved in a remote file
  72475. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  72476. * @param url defines the url to load from
  72477. * @param scene defines the hosting scene
  72478. * @param gpu If the system will use gpu
  72479. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  72480. * @returns a promise that will resolve to the new particle system
  72481. */
  72482. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  72483. /**
  72484. * Creates a particle system from a snippet saved by the particle system editor
  72485. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  72486. * @param scene defines the hosting scene
  72487. * @param gpu If the system will use gpu
  72488. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  72489. * @returns a promise that will resolve to the new particle system
  72490. */
  72491. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  72492. }
  72493. }
  72494. declare module BABYLON {
  72495. interface Engine {
  72496. /**
  72497. * Create an effect to use with particle systems.
  72498. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  72499. * the particle system for which you want to create a custom effect in the last parameter
  72500. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  72501. * @param uniformsNames defines a list of attribute names
  72502. * @param samplers defines an array of string used to represent textures
  72503. * @param defines defines the string containing the defines to use to compile the shaders
  72504. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  72505. * @param onCompiled defines a function to call when the effect creation is successful
  72506. * @param onError defines a function to call when the effect creation has failed
  72507. * @param particleSystem the particle system you want to create the effect for
  72508. * @returns the new Effect
  72509. */
  72510. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  72511. }
  72512. interface Mesh {
  72513. /**
  72514. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  72515. * @returns an array of IParticleSystem
  72516. */
  72517. getEmittedParticleSystems(): IParticleSystem[];
  72518. /**
  72519. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  72520. * @returns an array of IParticleSystem
  72521. */
  72522. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  72523. }
  72524. }
  72525. declare module BABYLON {
  72526. /** Defines the 4 color options */
  72527. export enum PointColor {
  72528. /** color value */
  72529. Color = 2,
  72530. /** uv value */
  72531. UV = 1,
  72532. /** random value */
  72533. Random = 0,
  72534. /** stated value */
  72535. Stated = 3
  72536. }
  72537. /**
  72538. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  72539. * 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.
  72540. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  72541. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  72542. *
  72543. * Full documentation here : TO BE ENTERED
  72544. */
  72545. export class PointsCloudSystem implements IDisposable {
  72546. /**
  72547. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  72548. * Example : var p = SPS.particles[i];
  72549. */
  72550. particles: CloudPoint[];
  72551. /**
  72552. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  72553. */
  72554. nbParticles: number;
  72555. /**
  72556. * This a counter for your own usage. It's not set by any SPS functions.
  72557. */
  72558. counter: number;
  72559. /**
  72560. * The PCS name. This name is also given to the underlying mesh.
  72561. */
  72562. name: string;
  72563. /**
  72564. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  72565. */
  72566. mesh: Mesh;
  72567. /**
  72568. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  72569. * Please read :
  72570. */
  72571. vars: any;
  72572. /**
  72573. * @hidden
  72574. */
  72575. _size: number;
  72576. private _scene;
  72577. private _promises;
  72578. private _positions;
  72579. private _indices;
  72580. private _normals;
  72581. private _colors;
  72582. private _uvs;
  72583. private _indices32;
  72584. private _positions32;
  72585. private _colors32;
  72586. private _uvs32;
  72587. private _updatable;
  72588. private _isVisibilityBoxLocked;
  72589. private _alwaysVisible;
  72590. private _groups;
  72591. private _groupCounter;
  72592. private _computeParticleColor;
  72593. private _computeParticleTexture;
  72594. private _computeParticleRotation;
  72595. private _computeBoundingBox;
  72596. private _isReady;
  72597. /**
  72598. * Creates a PCS (Points Cloud System) object
  72599. * @param name (String) is the PCS name, this will be the underlying mesh name
  72600. * @param pointSize (number) is the size for each point
  72601. * @param scene (Scene) is the scene in which the PCS is added
  72602. * @param options defines the options of the PCS e.g.
  72603. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  72604. */
  72605. constructor(name: string, pointSize: number, scene: Scene, options?: {
  72606. updatable?: boolean;
  72607. });
  72608. /**
  72609. * Builds the PCS underlying mesh. Returns a standard Mesh.
  72610. * If no points were added to the PCS, the returned mesh is just a single point.
  72611. * @returns a promise for the created mesh
  72612. */
  72613. buildMeshAsync(): Promise<Mesh>;
  72614. /**
  72615. * @hidden
  72616. */
  72617. private _buildMesh;
  72618. private _addParticle;
  72619. private _randomUnitVector;
  72620. private _getColorIndicesForCoord;
  72621. private _setPointsColorOrUV;
  72622. private _colorFromTexture;
  72623. private _calculateDensity;
  72624. /**
  72625. * Adds points to the PCS in random positions within a unit sphere
  72626. * @param nb (positive integer) the number of particles to be created from this model
  72627. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  72628. * @returns the number of groups in the system
  72629. */
  72630. addPoints(nb: number, pointFunction?: any): number;
  72631. /**
  72632. * Adds points to the PCS from the surface of the model shape
  72633. * @param mesh is any Mesh object that will be used as a surface model for the points
  72634. * @param nb (positive integer) the number of particles to be created from this model
  72635. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  72636. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  72637. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  72638. * @returns the number of groups in the system
  72639. */
  72640. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  72641. /**
  72642. * Adds points to the PCS inside the model shape
  72643. * @param mesh is any Mesh object that will be used as a surface model for the points
  72644. * @param nb (positive integer) the number of particles to be created from this model
  72645. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  72646. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  72647. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  72648. * @returns the number of groups in the system
  72649. */
  72650. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  72651. /**
  72652. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  72653. * This method calls `updateParticle()` for each particle of the SPS.
  72654. * For an animated SPS, it is usually called within the render loop.
  72655. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  72656. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  72657. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  72658. * @returns the PCS.
  72659. */
  72660. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  72661. /**
  72662. * Disposes the PCS.
  72663. */
  72664. dispose(): void;
  72665. /**
  72666. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  72667. * doc :
  72668. * @returns the PCS.
  72669. */
  72670. refreshVisibleSize(): PointsCloudSystem;
  72671. /**
  72672. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  72673. * @param size the size (float) of the visibility box
  72674. * note : this doesn't lock the PCS mesh bounding box.
  72675. * doc :
  72676. */
  72677. setVisibilityBox(size: number): void;
  72678. /**
  72679. * Gets whether the PCS is always visible or not
  72680. * doc :
  72681. */
  72682. get isAlwaysVisible(): boolean;
  72683. /**
  72684. * Sets the PCS as always visible or not
  72685. * doc :
  72686. */
  72687. set isAlwaysVisible(val: boolean);
  72688. /**
  72689. * Tells to `setParticles()` to compute the particle rotations or not
  72690. * Default value : false. The PCS is faster when it's set to false
  72691. * Note : particle rotations are only applied to parent particles
  72692. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  72693. */
  72694. set computeParticleRotation(val: boolean);
  72695. /**
  72696. * Tells to `setParticles()` to compute the particle colors or not.
  72697. * Default value : true. The PCS is faster when it's set to false.
  72698. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  72699. */
  72700. set computeParticleColor(val: boolean);
  72701. set computeParticleTexture(val: boolean);
  72702. /**
  72703. * Gets if `setParticles()` computes the particle colors or not.
  72704. * Default value : false. The PCS is faster when it's set to false.
  72705. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  72706. */
  72707. get computeParticleColor(): boolean;
  72708. /**
  72709. * Gets if `setParticles()` computes the particle textures or not.
  72710. * Default value : false. The PCS is faster when it's set to false.
  72711. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  72712. */
  72713. get computeParticleTexture(): boolean;
  72714. /**
  72715. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  72716. */
  72717. set computeBoundingBox(val: boolean);
  72718. /**
  72719. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  72720. */
  72721. get computeBoundingBox(): boolean;
  72722. /**
  72723. * This function does nothing. It may be overwritten to set all the particle first values.
  72724. * The PCS doesn't call this function, you may have to call it by your own.
  72725. * doc :
  72726. */
  72727. initParticles(): void;
  72728. /**
  72729. * This function does nothing. It may be overwritten to recycle a particle
  72730. * The PCS doesn't call this function, you can to call it
  72731. * doc :
  72732. * @param particle The particle to recycle
  72733. * @returns the recycled particle
  72734. */
  72735. recycleParticle(particle: CloudPoint): CloudPoint;
  72736. /**
  72737. * Updates a particle : this function should be overwritten by the user.
  72738. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  72739. * doc :
  72740. * @example : just set a particle position or velocity and recycle conditions
  72741. * @param particle The particle to update
  72742. * @returns the updated particle
  72743. */
  72744. updateParticle(particle: CloudPoint): CloudPoint;
  72745. /**
  72746. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  72747. * This does nothing and may be overwritten by the user.
  72748. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  72749. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  72750. * @param update the boolean update value actually passed to setParticles()
  72751. */
  72752. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  72753. /**
  72754. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  72755. * This will be passed three parameters.
  72756. * This does nothing and may be overwritten by the user.
  72757. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  72758. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  72759. * @param update the boolean update value actually passed to setParticles()
  72760. */
  72761. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  72762. }
  72763. }
  72764. declare module BABYLON {
  72765. /**
  72766. * Represents one particle of a points cloud system.
  72767. */
  72768. export class CloudPoint {
  72769. /**
  72770. * particle global index
  72771. */
  72772. idx: number;
  72773. /**
  72774. * The color of the particle
  72775. */
  72776. color: Nullable<Color4>;
  72777. /**
  72778. * The world space position of the particle.
  72779. */
  72780. position: Vector3;
  72781. /**
  72782. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  72783. */
  72784. rotation: Vector3;
  72785. /**
  72786. * The world space rotation quaternion of the particle.
  72787. */
  72788. rotationQuaternion: Nullable<Quaternion>;
  72789. /**
  72790. * The uv of the particle.
  72791. */
  72792. uv: Nullable<Vector2>;
  72793. /**
  72794. * The current speed of the particle.
  72795. */
  72796. velocity: Vector3;
  72797. /**
  72798. * The pivot point in the particle local space.
  72799. */
  72800. pivot: Vector3;
  72801. /**
  72802. * Must the particle be translated from its pivot point in its local space ?
  72803. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  72804. * Default : false
  72805. */
  72806. translateFromPivot: boolean;
  72807. /**
  72808. * Index of this particle in the global "positions" array (Internal use)
  72809. * @hidden
  72810. */
  72811. _pos: number;
  72812. /**
  72813. * @hidden Index of this particle in the global "indices" array (Internal use)
  72814. */
  72815. _ind: number;
  72816. /**
  72817. * Group this particle belongs to
  72818. */
  72819. _group: PointsGroup;
  72820. /**
  72821. * Group id of this particle
  72822. */
  72823. groupId: number;
  72824. /**
  72825. * Index of the particle in its group id (Internal use)
  72826. */
  72827. idxInGroup: number;
  72828. /**
  72829. * @hidden Particle BoundingInfo object (Internal use)
  72830. */
  72831. _boundingInfo: BoundingInfo;
  72832. /**
  72833. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  72834. */
  72835. _pcs: PointsCloudSystem;
  72836. /**
  72837. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  72838. */
  72839. _stillInvisible: boolean;
  72840. /**
  72841. * @hidden Last computed particle rotation matrix
  72842. */
  72843. _rotationMatrix: number[];
  72844. /**
  72845. * Parent particle Id, if any.
  72846. * Default null.
  72847. */
  72848. parentId: Nullable<number>;
  72849. /**
  72850. * @hidden Internal global position in the PCS.
  72851. */
  72852. _globalPosition: Vector3;
  72853. /**
  72854. * Creates a Point Cloud object.
  72855. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  72856. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  72857. * @param group (PointsGroup) is the group the particle belongs to
  72858. * @param groupId (integer) is the group identifier in the PCS.
  72859. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  72860. * @param pcs defines the PCS it is associated to
  72861. */
  72862. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  72863. /**
  72864. * get point size
  72865. */
  72866. get size(): Vector3;
  72867. /**
  72868. * Set point size
  72869. */
  72870. set size(scale: Vector3);
  72871. /**
  72872. * Legacy support, changed quaternion to rotationQuaternion
  72873. */
  72874. get quaternion(): Nullable<Quaternion>;
  72875. /**
  72876. * Legacy support, changed quaternion to rotationQuaternion
  72877. */
  72878. set quaternion(q: Nullable<Quaternion>);
  72879. /**
  72880. * Returns a boolean. True if the particle intersects a mesh, else false
  72881. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  72882. * @param target is the object (point or mesh) what the intersection is computed against
  72883. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  72884. * @returns true if it intersects
  72885. */
  72886. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  72887. /**
  72888. * get the rotation matrix of the particle
  72889. * @hidden
  72890. */
  72891. getRotationMatrix(m: Matrix): void;
  72892. }
  72893. /**
  72894. * Represents a group of points in a points cloud system
  72895. * * PCS internal tool, don't use it manually.
  72896. */
  72897. export class PointsGroup {
  72898. /**
  72899. * The group id
  72900. * @hidden
  72901. */
  72902. groupID: number;
  72903. /**
  72904. * image data for group (internal use)
  72905. * @hidden
  72906. */
  72907. _groupImageData: Nullable<ArrayBufferView>;
  72908. /**
  72909. * Image Width (internal use)
  72910. * @hidden
  72911. */
  72912. _groupImgWidth: number;
  72913. /**
  72914. * Image Height (internal use)
  72915. * @hidden
  72916. */
  72917. _groupImgHeight: number;
  72918. /**
  72919. * Custom position function (internal use)
  72920. * @hidden
  72921. */
  72922. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  72923. /**
  72924. * density per facet for surface points
  72925. * @hidden
  72926. */
  72927. _groupDensity: number[];
  72928. /**
  72929. * Only when points are colored by texture carries pointer to texture list array
  72930. * @hidden
  72931. */
  72932. _textureNb: number;
  72933. /**
  72934. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  72935. * PCS internal tool, don't use it manually.
  72936. * @hidden
  72937. */
  72938. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  72939. }
  72940. }
  72941. declare module BABYLON {
  72942. interface Scene {
  72943. /** @hidden (Backing field) */
  72944. _physicsEngine: Nullable<IPhysicsEngine>;
  72945. /** @hidden */
  72946. _physicsTimeAccumulator: number;
  72947. /**
  72948. * Gets the current physics engine
  72949. * @returns a IPhysicsEngine or null if none attached
  72950. */
  72951. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  72952. /**
  72953. * Enables physics to the current scene
  72954. * @param gravity defines the scene's gravity for the physics engine
  72955. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  72956. * @return a boolean indicating if the physics engine was initialized
  72957. */
  72958. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  72959. /**
  72960. * Disables and disposes the physics engine associated with the scene
  72961. */
  72962. disablePhysicsEngine(): void;
  72963. /**
  72964. * Gets a boolean indicating if there is an active physics engine
  72965. * @returns a boolean indicating if there is an active physics engine
  72966. */
  72967. isPhysicsEnabled(): boolean;
  72968. /**
  72969. * Deletes a physics compound impostor
  72970. * @param compound defines the compound to delete
  72971. */
  72972. deleteCompoundImpostor(compound: any): void;
  72973. /**
  72974. * An event triggered when physic simulation is about to be run
  72975. */
  72976. onBeforePhysicsObservable: Observable<Scene>;
  72977. /**
  72978. * An event triggered when physic simulation has been done
  72979. */
  72980. onAfterPhysicsObservable: Observable<Scene>;
  72981. }
  72982. interface AbstractMesh {
  72983. /** @hidden */
  72984. _physicsImpostor: Nullable<PhysicsImpostor>;
  72985. /**
  72986. * Gets or sets impostor used for physic simulation
  72987. * @see https://doc.babylonjs.com/features/physics_engine
  72988. */
  72989. physicsImpostor: Nullable<PhysicsImpostor>;
  72990. /**
  72991. * Gets the current physics impostor
  72992. * @see https://doc.babylonjs.com/features/physics_engine
  72993. * @returns a physics impostor or null
  72994. */
  72995. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  72996. /** Apply a physic impulse to the mesh
  72997. * @param force defines the force to apply
  72998. * @param contactPoint defines where to apply the force
  72999. * @returns the current mesh
  73000. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  73001. */
  73002. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  73003. /**
  73004. * Creates a physic joint between two meshes
  73005. * @param otherMesh defines the other mesh to use
  73006. * @param pivot1 defines the pivot to use on this mesh
  73007. * @param pivot2 defines the pivot to use on the other mesh
  73008. * @param options defines additional options (can be plugin dependent)
  73009. * @returns the current mesh
  73010. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  73011. */
  73012. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  73013. /** @hidden */
  73014. _disposePhysicsObserver: Nullable<Observer<Node>>;
  73015. }
  73016. /**
  73017. * Defines the physics engine scene component responsible to manage a physics engine
  73018. */
  73019. export class PhysicsEngineSceneComponent implements ISceneComponent {
  73020. /**
  73021. * The component name helpful to identify the component in the list of scene components.
  73022. */
  73023. readonly name: string;
  73024. /**
  73025. * The scene the component belongs to.
  73026. */
  73027. scene: Scene;
  73028. /**
  73029. * Creates a new instance of the component for the given scene
  73030. * @param scene Defines the scene to register the component in
  73031. */
  73032. constructor(scene: Scene);
  73033. /**
  73034. * Registers the component in a given scene
  73035. */
  73036. register(): void;
  73037. /**
  73038. * Rebuilds the elements related to this component in case of
  73039. * context lost for instance.
  73040. */
  73041. rebuild(): void;
  73042. /**
  73043. * Disposes the component and the associated ressources
  73044. */
  73045. dispose(): void;
  73046. }
  73047. }
  73048. declare module BABYLON {
  73049. /**
  73050. * A helper for physics simulations
  73051. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73052. */
  73053. export class PhysicsHelper {
  73054. private _scene;
  73055. private _physicsEngine;
  73056. /**
  73057. * Initializes the Physics helper
  73058. * @param scene Babylon.js scene
  73059. */
  73060. constructor(scene: Scene);
  73061. /**
  73062. * Applies a radial explosion impulse
  73063. * @param origin the origin of the explosion
  73064. * @param radiusOrEventOptions the radius or the options of radial explosion
  73065. * @param strength the explosion strength
  73066. * @param falloff possible options: Constant & Linear. Defaults to Constant
  73067. * @returns A physics radial explosion event, or null
  73068. */
  73069. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  73070. /**
  73071. * Applies a radial explosion force
  73072. * @param origin the origin of the explosion
  73073. * @param radiusOrEventOptions the radius or the options of radial explosion
  73074. * @param strength the explosion strength
  73075. * @param falloff possible options: Constant & Linear. Defaults to Constant
  73076. * @returns A physics radial explosion event, or null
  73077. */
  73078. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  73079. /**
  73080. * Creates a gravitational field
  73081. * @param origin the origin of the explosion
  73082. * @param radiusOrEventOptions the radius or the options of radial explosion
  73083. * @param strength the explosion strength
  73084. * @param falloff possible options: Constant & Linear. Defaults to Constant
  73085. * @returns A physics gravitational field event, or null
  73086. */
  73087. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  73088. /**
  73089. * Creates a physics updraft event
  73090. * @param origin the origin of the updraft
  73091. * @param radiusOrEventOptions the radius or the options of the updraft
  73092. * @param strength the strength of the updraft
  73093. * @param height the height of the updraft
  73094. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  73095. * @returns A physics updraft event, or null
  73096. */
  73097. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  73098. /**
  73099. * Creates a physics vortex event
  73100. * @param origin the of the vortex
  73101. * @param radiusOrEventOptions the radius or the options of the vortex
  73102. * @param strength the strength of the vortex
  73103. * @param height the height of the vortex
  73104. * @returns a Physics vortex event, or null
  73105. * A physics vortex event or null
  73106. */
  73107. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  73108. }
  73109. /**
  73110. * Represents a physics radial explosion event
  73111. */
  73112. class PhysicsRadialExplosionEvent {
  73113. private _scene;
  73114. private _options;
  73115. private _sphere;
  73116. private _dataFetched;
  73117. /**
  73118. * Initializes a radial explosioin event
  73119. * @param _scene BabylonJS scene
  73120. * @param _options The options for the vortex event
  73121. */
  73122. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  73123. /**
  73124. * Returns the data related to the radial explosion event (sphere).
  73125. * @returns The radial explosion event data
  73126. */
  73127. getData(): PhysicsRadialExplosionEventData;
  73128. /**
  73129. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  73130. * @param impostor A physics imposter
  73131. * @param origin the origin of the explosion
  73132. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  73133. */
  73134. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  73135. /**
  73136. * Triggers affecterd impostors callbacks
  73137. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  73138. */
  73139. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  73140. /**
  73141. * Disposes the sphere.
  73142. * @param force Specifies if the sphere should be disposed by force
  73143. */
  73144. dispose(force?: boolean): void;
  73145. /*** Helpers ***/
  73146. private _prepareSphere;
  73147. private _intersectsWithSphere;
  73148. }
  73149. /**
  73150. * Represents a gravitational field event
  73151. */
  73152. class PhysicsGravitationalFieldEvent {
  73153. private _physicsHelper;
  73154. private _scene;
  73155. private _origin;
  73156. private _options;
  73157. private _tickCallback;
  73158. private _sphere;
  73159. private _dataFetched;
  73160. /**
  73161. * Initializes the physics gravitational field event
  73162. * @param _physicsHelper A physics helper
  73163. * @param _scene BabylonJS scene
  73164. * @param _origin The origin position of the gravitational field event
  73165. * @param _options The options for the vortex event
  73166. */
  73167. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  73168. /**
  73169. * Returns the data related to the gravitational field event (sphere).
  73170. * @returns A gravitational field event
  73171. */
  73172. getData(): PhysicsGravitationalFieldEventData;
  73173. /**
  73174. * Enables the gravitational field.
  73175. */
  73176. enable(): void;
  73177. /**
  73178. * Disables the gravitational field.
  73179. */
  73180. disable(): void;
  73181. /**
  73182. * Disposes the sphere.
  73183. * @param force The force to dispose from the gravitational field event
  73184. */
  73185. dispose(force?: boolean): void;
  73186. private _tick;
  73187. }
  73188. /**
  73189. * Represents a physics updraft event
  73190. */
  73191. class PhysicsUpdraftEvent {
  73192. private _scene;
  73193. private _origin;
  73194. private _options;
  73195. private _physicsEngine;
  73196. private _originTop;
  73197. private _originDirection;
  73198. private _tickCallback;
  73199. private _cylinder;
  73200. private _cylinderPosition;
  73201. private _dataFetched;
  73202. /**
  73203. * Initializes the physics updraft event
  73204. * @param _scene BabylonJS scene
  73205. * @param _origin The origin position of the updraft
  73206. * @param _options The options for the updraft event
  73207. */
  73208. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  73209. /**
  73210. * Returns the data related to the updraft event (cylinder).
  73211. * @returns A physics updraft event
  73212. */
  73213. getData(): PhysicsUpdraftEventData;
  73214. /**
  73215. * Enables the updraft.
  73216. */
  73217. enable(): void;
  73218. /**
  73219. * Disables the updraft.
  73220. */
  73221. disable(): void;
  73222. /**
  73223. * Disposes the cylinder.
  73224. * @param force Specifies if the updraft should be disposed by force
  73225. */
  73226. dispose(force?: boolean): void;
  73227. private getImpostorHitData;
  73228. private _tick;
  73229. /*** Helpers ***/
  73230. private _prepareCylinder;
  73231. private _intersectsWithCylinder;
  73232. }
  73233. /**
  73234. * Represents a physics vortex event
  73235. */
  73236. class PhysicsVortexEvent {
  73237. private _scene;
  73238. private _origin;
  73239. private _options;
  73240. private _physicsEngine;
  73241. private _originTop;
  73242. private _tickCallback;
  73243. private _cylinder;
  73244. private _cylinderPosition;
  73245. private _dataFetched;
  73246. /**
  73247. * Initializes the physics vortex event
  73248. * @param _scene The BabylonJS scene
  73249. * @param _origin The origin position of the vortex
  73250. * @param _options The options for the vortex event
  73251. */
  73252. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  73253. /**
  73254. * Returns the data related to the vortex event (cylinder).
  73255. * @returns The physics vortex event data
  73256. */
  73257. getData(): PhysicsVortexEventData;
  73258. /**
  73259. * Enables the vortex.
  73260. */
  73261. enable(): void;
  73262. /**
  73263. * Disables the cortex.
  73264. */
  73265. disable(): void;
  73266. /**
  73267. * Disposes the sphere.
  73268. * @param force
  73269. */
  73270. dispose(force?: boolean): void;
  73271. private getImpostorHitData;
  73272. private _tick;
  73273. /*** Helpers ***/
  73274. private _prepareCylinder;
  73275. private _intersectsWithCylinder;
  73276. }
  73277. /**
  73278. * Options fot the radial explosion event
  73279. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73280. */
  73281. export class PhysicsRadialExplosionEventOptions {
  73282. /**
  73283. * The radius of the sphere for the radial explosion.
  73284. */
  73285. radius: number;
  73286. /**
  73287. * The strenth of the explosion.
  73288. */
  73289. strength: number;
  73290. /**
  73291. * The strenght of the force in correspondence to the distance of the affected object
  73292. */
  73293. falloff: PhysicsRadialImpulseFalloff;
  73294. /**
  73295. * Sphere options for the radial explosion.
  73296. */
  73297. sphere: {
  73298. segments: number;
  73299. diameter: number;
  73300. };
  73301. /**
  73302. * Sphere options for the radial explosion.
  73303. */
  73304. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  73305. }
  73306. /**
  73307. * Options fot the updraft event
  73308. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73309. */
  73310. export class PhysicsUpdraftEventOptions {
  73311. /**
  73312. * The radius of the cylinder for the vortex
  73313. */
  73314. radius: number;
  73315. /**
  73316. * The strenth of the updraft.
  73317. */
  73318. strength: number;
  73319. /**
  73320. * The height of the cylinder for the updraft.
  73321. */
  73322. height: number;
  73323. /**
  73324. * The mode for the the updraft.
  73325. */
  73326. updraftMode: PhysicsUpdraftMode;
  73327. }
  73328. /**
  73329. * Options fot the vortex event
  73330. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73331. */
  73332. export class PhysicsVortexEventOptions {
  73333. /**
  73334. * The radius of the cylinder for the vortex
  73335. */
  73336. radius: number;
  73337. /**
  73338. * The strenth of the vortex.
  73339. */
  73340. strength: number;
  73341. /**
  73342. * The height of the cylinder for the vortex.
  73343. */
  73344. height: number;
  73345. /**
  73346. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  73347. */
  73348. centripetalForceThreshold: number;
  73349. /**
  73350. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  73351. */
  73352. centripetalForceMultiplier: number;
  73353. /**
  73354. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  73355. */
  73356. centrifugalForceMultiplier: number;
  73357. /**
  73358. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  73359. */
  73360. updraftForceMultiplier: number;
  73361. }
  73362. /**
  73363. * The strenght of the force in correspondence to the distance of the affected object
  73364. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73365. */
  73366. export enum PhysicsRadialImpulseFalloff {
  73367. /** Defines that impulse is constant in strength across it's whole radius */
  73368. Constant = 0,
  73369. /** Defines that impulse gets weaker if it's further from the origin */
  73370. Linear = 1
  73371. }
  73372. /**
  73373. * The strength of the force in correspondence to the distance of the affected object
  73374. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73375. */
  73376. export enum PhysicsUpdraftMode {
  73377. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  73378. Center = 0,
  73379. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  73380. Perpendicular = 1
  73381. }
  73382. /**
  73383. * Interface for a physics hit data
  73384. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73385. */
  73386. export interface PhysicsHitData {
  73387. /**
  73388. * The force applied at the contact point
  73389. */
  73390. force: Vector3;
  73391. /**
  73392. * The contact point
  73393. */
  73394. contactPoint: Vector3;
  73395. /**
  73396. * The distance from the origin to the contact point
  73397. */
  73398. distanceFromOrigin: number;
  73399. }
  73400. /**
  73401. * Interface for radial explosion event data
  73402. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73403. */
  73404. export interface PhysicsRadialExplosionEventData {
  73405. /**
  73406. * A sphere used for the radial explosion event
  73407. */
  73408. sphere: Mesh;
  73409. }
  73410. /**
  73411. * Interface for gravitational field event data
  73412. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73413. */
  73414. export interface PhysicsGravitationalFieldEventData {
  73415. /**
  73416. * A sphere mesh used for the gravitational field event
  73417. */
  73418. sphere: Mesh;
  73419. }
  73420. /**
  73421. * Interface for updraft event data
  73422. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73423. */
  73424. export interface PhysicsUpdraftEventData {
  73425. /**
  73426. * A cylinder used for the updraft event
  73427. */
  73428. cylinder: Mesh;
  73429. }
  73430. /**
  73431. * Interface for vortex event data
  73432. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73433. */
  73434. export interface PhysicsVortexEventData {
  73435. /**
  73436. * A cylinder used for the vortex event
  73437. */
  73438. cylinder: Mesh;
  73439. }
  73440. /**
  73441. * Interface for an affected physics impostor
  73442. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73443. */
  73444. export interface PhysicsAffectedImpostorWithData {
  73445. /**
  73446. * The impostor affected by the effect
  73447. */
  73448. impostor: PhysicsImpostor;
  73449. /**
  73450. * The data about the hit/horce from the explosion
  73451. */
  73452. hitData: PhysicsHitData;
  73453. }
  73454. }
  73455. declare module BABYLON {
  73456. /** @hidden */
  73457. export var blackAndWhitePixelShader: {
  73458. name: string;
  73459. shader: string;
  73460. };
  73461. }
  73462. declare module BABYLON {
  73463. /**
  73464. * Post process used to render in black and white
  73465. */
  73466. export class BlackAndWhitePostProcess extends PostProcess {
  73467. /**
  73468. * Linear about to convert he result to black and white (default: 1)
  73469. */
  73470. degree: number;
  73471. /**
  73472. * Gets a string identifying the name of the class
  73473. * @returns "BlackAndWhitePostProcess" string
  73474. */
  73475. getClassName(): string;
  73476. /**
  73477. * Creates a black and white post process
  73478. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  73479. * @param name The name of the effect.
  73480. * @param options The required width/height ratio to downsize to before computing the render pass.
  73481. * @param camera The camera to apply the render pass to.
  73482. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73483. * @param engine The engine which the post process will be applied. (default: current engine)
  73484. * @param reusable If the post process can be reused on the same frame. (default: false)
  73485. */
  73486. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  73487. /** @hidden */
  73488. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlackAndWhitePostProcess>;
  73489. }
  73490. }
  73491. declare module BABYLON {
  73492. /**
  73493. * This represents a set of one or more post processes in Babylon.
  73494. * A post process can be used to apply a shader to a texture after it is rendered.
  73495. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  73496. */
  73497. export class PostProcessRenderEffect {
  73498. private _postProcesses;
  73499. private _getPostProcesses;
  73500. private _singleInstance;
  73501. private _cameras;
  73502. private _indicesForCamera;
  73503. /**
  73504. * Name of the effect
  73505. * @hidden
  73506. */
  73507. _name: string;
  73508. /**
  73509. * Instantiates a post process render effect.
  73510. * A post process can be used to apply a shader to a texture after it is rendered.
  73511. * @param engine The engine the effect is tied to
  73512. * @param name The name of the effect
  73513. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  73514. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  73515. */
  73516. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  73517. /**
  73518. * Checks if all the post processes in the effect are supported.
  73519. */
  73520. get isSupported(): boolean;
  73521. /**
  73522. * Updates the current state of the effect
  73523. * @hidden
  73524. */
  73525. _update(): void;
  73526. /**
  73527. * Attaches the effect on cameras
  73528. * @param cameras The camera to attach to.
  73529. * @hidden
  73530. */
  73531. _attachCameras(cameras: Camera): void;
  73532. /**
  73533. * Attaches the effect on cameras
  73534. * @param cameras The camera to attach to.
  73535. * @hidden
  73536. */
  73537. _attachCameras(cameras: Camera[]): void;
  73538. /**
  73539. * Detaches the effect on cameras
  73540. * @param cameras The camera to detatch from.
  73541. * @hidden
  73542. */
  73543. _detachCameras(cameras: Camera): void;
  73544. /**
  73545. * Detatches the effect on cameras
  73546. * @param cameras The camera to detatch from.
  73547. * @hidden
  73548. */
  73549. _detachCameras(cameras: Camera[]): void;
  73550. /**
  73551. * Enables the effect on given cameras
  73552. * @param cameras The camera to enable.
  73553. * @hidden
  73554. */
  73555. _enable(cameras: Camera): void;
  73556. /**
  73557. * Enables the effect on given cameras
  73558. * @param cameras The camera to enable.
  73559. * @hidden
  73560. */
  73561. _enable(cameras: Nullable<Camera[]>): void;
  73562. /**
  73563. * Disables the effect on the given cameras
  73564. * @param cameras The camera to disable.
  73565. * @hidden
  73566. */
  73567. _disable(cameras: Camera): void;
  73568. /**
  73569. * Disables the effect on the given cameras
  73570. * @param cameras The camera to disable.
  73571. * @hidden
  73572. */
  73573. _disable(cameras: Nullable<Camera[]>): void;
  73574. /**
  73575. * Gets a list of the post processes contained in the effect.
  73576. * @param camera The camera to get the post processes on.
  73577. * @returns The list of the post processes in the effect.
  73578. */
  73579. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  73580. }
  73581. }
  73582. declare module BABYLON {
  73583. /** @hidden */
  73584. export var extractHighlightsPixelShader: {
  73585. name: string;
  73586. shader: string;
  73587. };
  73588. }
  73589. declare module BABYLON {
  73590. /**
  73591. * 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.
  73592. */
  73593. export class ExtractHighlightsPostProcess extends PostProcess {
  73594. /**
  73595. * The luminance threshold, pixels below this value will be set to black.
  73596. */
  73597. threshold: number;
  73598. /** @hidden */
  73599. _exposure: number;
  73600. /**
  73601. * Post process which has the input texture to be used when performing highlight extraction
  73602. * @hidden
  73603. */
  73604. _inputPostProcess: Nullable<PostProcess>;
  73605. /**
  73606. * Gets a string identifying the name of the class
  73607. * @returns "ExtractHighlightsPostProcess" string
  73608. */
  73609. getClassName(): string;
  73610. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73611. }
  73612. }
  73613. declare module BABYLON {
  73614. /** @hidden */
  73615. export var bloomMergePixelShader: {
  73616. name: string;
  73617. shader: string;
  73618. };
  73619. }
  73620. declare module BABYLON {
  73621. /**
  73622. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  73623. */
  73624. export class BloomMergePostProcess extends PostProcess {
  73625. /** Weight of the bloom to be added to the original input. */
  73626. weight: number;
  73627. /**
  73628. * Gets a string identifying the name of the class
  73629. * @returns "BloomMergePostProcess" string
  73630. */
  73631. getClassName(): string;
  73632. /**
  73633. * Creates a new instance of @see BloomMergePostProcess
  73634. * @param name The name of the effect.
  73635. * @param originalFromInput Post process which's input will be used for the merge.
  73636. * @param blurred Blurred highlights post process which's output will be used.
  73637. * @param weight Weight of the bloom to be added to the original input.
  73638. * @param options The required width/height ratio to downsize to before computing the render pass.
  73639. * @param camera The camera to apply the render pass to.
  73640. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73641. * @param engine The engine which the post process will be applied. (default: current engine)
  73642. * @param reusable If the post process can be reused on the same frame. (default: false)
  73643. * @param textureType Type of textures used when performing the post process. (default: 0)
  73644. * @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)
  73645. */
  73646. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  73647. /** Weight of the bloom to be added to the original input. */
  73648. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73649. }
  73650. }
  73651. declare module BABYLON {
  73652. /**
  73653. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  73654. */
  73655. export class BloomEffect extends PostProcessRenderEffect {
  73656. private bloomScale;
  73657. /**
  73658. * @hidden Internal
  73659. */
  73660. _effects: Array<PostProcess>;
  73661. /**
  73662. * @hidden Internal
  73663. */
  73664. _downscale: ExtractHighlightsPostProcess;
  73665. private _blurX;
  73666. private _blurY;
  73667. private _merge;
  73668. /**
  73669. * The luminance threshold to find bright areas of the image to bloom.
  73670. */
  73671. get threshold(): number;
  73672. set threshold(value: number);
  73673. /**
  73674. * The strength of the bloom.
  73675. */
  73676. get weight(): number;
  73677. set weight(value: number);
  73678. /**
  73679. * Specifies the size of the bloom blur kernel, relative to the final output size
  73680. */
  73681. get kernel(): number;
  73682. set kernel(value: number);
  73683. /**
  73684. * Creates a new instance of @see BloomEffect
  73685. * @param scene The scene the effect belongs to.
  73686. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  73687. * @param bloomKernel The size of the kernel to be used when applying the blur.
  73688. * @param bloomWeight The the strength of bloom.
  73689. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  73690. * @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)
  73691. */
  73692. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  73693. /**
  73694. * Disposes each of the internal effects for a given camera.
  73695. * @param camera The camera to dispose the effect on.
  73696. */
  73697. disposeEffects(camera: Camera): void;
  73698. /**
  73699. * @hidden Internal
  73700. */
  73701. _updateEffects(): void;
  73702. /**
  73703. * Internal
  73704. * @returns if all the contained post processes are ready.
  73705. * @hidden
  73706. */
  73707. _isReady(): boolean;
  73708. }
  73709. }
  73710. declare module BABYLON {
  73711. /** @hidden */
  73712. export var chromaticAberrationPixelShader: {
  73713. name: string;
  73714. shader: string;
  73715. };
  73716. }
  73717. declare module BABYLON {
  73718. /**
  73719. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  73720. */
  73721. export class ChromaticAberrationPostProcess extends PostProcess {
  73722. /**
  73723. * The amount of seperation of rgb channels (default: 30)
  73724. */
  73725. aberrationAmount: number;
  73726. /**
  73727. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  73728. */
  73729. radialIntensity: number;
  73730. /**
  73731. * 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))
  73732. */
  73733. direction: Vector2;
  73734. /**
  73735. * 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))
  73736. */
  73737. centerPosition: Vector2;
  73738. /** The width of the screen to apply the effect on */
  73739. screenWidth: number;
  73740. /** The height of the screen to apply the effect on */
  73741. screenHeight: number;
  73742. /**
  73743. * Gets a string identifying the name of the class
  73744. * @returns "ChromaticAberrationPostProcess" string
  73745. */
  73746. getClassName(): string;
  73747. /**
  73748. * Creates a new instance ChromaticAberrationPostProcess
  73749. * @param name The name of the effect.
  73750. * @param screenWidth The width of the screen to apply the effect on.
  73751. * @param screenHeight The height of the screen to apply the effect on.
  73752. * @param options The required width/height ratio to downsize to before computing the render pass.
  73753. * @param camera The camera to apply the render pass to.
  73754. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73755. * @param engine The engine which the post process will be applied. (default: current engine)
  73756. * @param reusable If the post process can be reused on the same frame. (default: false)
  73757. * @param textureType Type of textures used when performing the post process. (default: 0)
  73758. * @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)
  73759. */
  73760. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73761. /** @hidden */
  73762. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ChromaticAberrationPostProcess>;
  73763. }
  73764. }
  73765. declare module BABYLON {
  73766. /** @hidden */
  73767. export var circleOfConfusionPixelShader: {
  73768. name: string;
  73769. shader: string;
  73770. };
  73771. }
  73772. declare module BABYLON {
  73773. /**
  73774. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  73775. */
  73776. export class CircleOfConfusionPostProcess extends PostProcess {
  73777. /**
  73778. * 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.
  73779. */
  73780. lensSize: number;
  73781. /**
  73782. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  73783. */
  73784. fStop: number;
  73785. /**
  73786. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  73787. */
  73788. focusDistance: number;
  73789. /**
  73790. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  73791. */
  73792. focalLength: number;
  73793. /**
  73794. * Gets a string identifying the name of the class
  73795. * @returns "CircleOfConfusionPostProcess" string
  73796. */
  73797. getClassName(): string;
  73798. private _depthTexture;
  73799. /**
  73800. * Creates a new instance CircleOfConfusionPostProcess
  73801. * @param name The name of the effect.
  73802. * @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.
  73803. * @param options The required width/height ratio to downsize to before computing the render pass.
  73804. * @param camera The camera to apply the render pass to.
  73805. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73806. * @param engine The engine which the post process will be applied. (default: current engine)
  73807. * @param reusable If the post process can be reused on the same frame. (default: false)
  73808. * @param textureType Type of textures used when performing the post process. (default: 0)
  73809. * @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)
  73810. */
  73811. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73812. /**
  73813. * 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.
  73814. */
  73815. set depthTexture(value: RenderTargetTexture);
  73816. }
  73817. }
  73818. declare module BABYLON {
  73819. /** @hidden */
  73820. export var colorCorrectionPixelShader: {
  73821. name: string;
  73822. shader: string;
  73823. };
  73824. }
  73825. declare module BABYLON {
  73826. /**
  73827. *
  73828. * This post-process allows the modification of rendered colors by using
  73829. * a 'look-up table' (LUT). This effect is also called Color Grading.
  73830. *
  73831. * The object needs to be provided an url to a texture containing the color
  73832. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  73833. * Use an image editing software to tweak the LUT to match your needs.
  73834. *
  73835. * For an example of a color LUT, see here:
  73836. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  73837. * For explanations on color grading, see here:
  73838. * @see http://udn.epicgames.com/Three/ColorGrading.html
  73839. *
  73840. */
  73841. export class ColorCorrectionPostProcess extends PostProcess {
  73842. private _colorTableTexture;
  73843. /**
  73844. * Gets the color table url used to create the LUT texture
  73845. */
  73846. colorTableUrl: string;
  73847. /**
  73848. * Gets a string identifying the name of the class
  73849. * @returns "ColorCorrectionPostProcess" string
  73850. */
  73851. getClassName(): string;
  73852. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  73853. /** @hidden */
  73854. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ColorCorrectionPostProcess>;
  73855. }
  73856. }
  73857. declare module BABYLON {
  73858. /** @hidden */
  73859. export var convolutionPixelShader: {
  73860. name: string;
  73861. shader: string;
  73862. };
  73863. }
  73864. declare module BABYLON {
  73865. /**
  73866. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  73867. * input texture to perform effects such as edge detection or sharpening
  73868. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  73869. */
  73870. export class ConvolutionPostProcess extends PostProcess {
  73871. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  73872. kernel: number[];
  73873. /**
  73874. * Gets a string identifying the name of the class
  73875. * @returns "ConvolutionPostProcess" string
  73876. */
  73877. getClassName(): string;
  73878. /**
  73879. * Creates a new instance ConvolutionPostProcess
  73880. * @param name The name of the effect.
  73881. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  73882. * @param options The required width/height ratio to downsize to before computing the render pass.
  73883. * @param camera The camera to apply the render pass to.
  73884. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73885. * @param engine The engine which the post process will be applied. (default: current engine)
  73886. * @param reusable If the post process can be reused on the same frame. (default: false)
  73887. * @param textureType Type of textures used when performing the post process. (default: 0)
  73888. */
  73889. constructor(name: string, kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  73890. /** @hidden */
  73891. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ConvolutionPostProcess>;
  73892. /**
  73893. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  73894. */
  73895. static EdgeDetect0Kernel: number[];
  73896. /**
  73897. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  73898. */
  73899. static EdgeDetect1Kernel: number[];
  73900. /**
  73901. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  73902. */
  73903. static EdgeDetect2Kernel: number[];
  73904. /**
  73905. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  73906. */
  73907. static SharpenKernel: number[];
  73908. /**
  73909. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  73910. */
  73911. static EmbossKernel: number[];
  73912. /**
  73913. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  73914. */
  73915. static GaussianKernel: number[];
  73916. }
  73917. }
  73918. declare module BABYLON {
  73919. /**
  73920. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  73921. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  73922. * based on samples that have a large difference in distance than the center pixel.
  73923. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  73924. */
  73925. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  73926. /**
  73927. * The direction the blur should be applied
  73928. */
  73929. direction: Vector2;
  73930. /**
  73931. * Gets a string identifying the name of the class
  73932. * @returns "DepthOfFieldBlurPostProcess" string
  73933. */
  73934. getClassName(): string;
  73935. /**
  73936. * Creates a new instance CircleOfConfusionPostProcess
  73937. * @param name The name of the effect.
  73938. * @param scene The scene the effect belongs to.
  73939. * @param direction The direction the blur should be applied.
  73940. * @param kernel The size of the kernel used to blur.
  73941. * @param options The required width/height ratio to downsize to before computing the render pass.
  73942. * @param camera The camera to apply the render pass to.
  73943. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  73944. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  73945. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73946. * @param engine The engine which the post process will be applied. (default: current engine)
  73947. * @param reusable If the post process can be reused on the same frame. (default: false)
  73948. * @param textureType Type of textures used when performing the post process. (default: 0)
  73949. * @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)
  73950. */
  73951. 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);
  73952. }
  73953. }
  73954. declare module BABYLON {
  73955. /** @hidden */
  73956. export var depthOfFieldMergePixelShader: {
  73957. name: string;
  73958. shader: string;
  73959. };
  73960. }
  73961. declare module BABYLON {
  73962. /**
  73963. * Options to be set when merging outputs from the default pipeline.
  73964. */
  73965. export class DepthOfFieldMergePostProcessOptions {
  73966. /**
  73967. * The original image to merge on top of
  73968. */
  73969. originalFromInput: PostProcess;
  73970. /**
  73971. * Parameters to perform the merge of the depth of field effect
  73972. */
  73973. depthOfField?: {
  73974. circleOfConfusion: PostProcess;
  73975. blurSteps: Array<PostProcess>;
  73976. };
  73977. /**
  73978. * Parameters to perform the merge of bloom effect
  73979. */
  73980. bloom?: {
  73981. blurred: PostProcess;
  73982. weight: number;
  73983. };
  73984. }
  73985. /**
  73986. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  73987. */
  73988. export class DepthOfFieldMergePostProcess extends PostProcess {
  73989. private blurSteps;
  73990. /**
  73991. * Gets a string identifying the name of the class
  73992. * @returns "DepthOfFieldMergePostProcess" string
  73993. */
  73994. getClassName(): string;
  73995. /**
  73996. * Creates a new instance of DepthOfFieldMergePostProcess
  73997. * @param name The name of the effect.
  73998. * @param originalFromInput Post process which's input will be used for the merge.
  73999. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  74000. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  74001. * @param options The required width/height ratio to downsize to before computing the render pass.
  74002. * @param camera The camera to apply the render pass to.
  74003. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74004. * @param engine The engine which the post process will be applied. (default: current engine)
  74005. * @param reusable If the post process can be reused on the same frame. (default: false)
  74006. * @param textureType Type of textures used when performing the post process. (default: 0)
  74007. * @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)
  74008. */
  74009. 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);
  74010. /**
  74011. * Updates the effect with the current post process compile time values and recompiles the shader.
  74012. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  74013. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  74014. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  74015. * @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
  74016. * @param onCompiled Called when the shader has been compiled.
  74017. * @param onError Called if there is an error when compiling a shader.
  74018. */
  74019. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  74020. }
  74021. }
  74022. declare module BABYLON {
  74023. /**
  74024. * Specifies the level of max blur that should be applied when using the depth of field effect
  74025. */
  74026. export enum DepthOfFieldEffectBlurLevel {
  74027. /**
  74028. * Subtle blur
  74029. */
  74030. Low = 0,
  74031. /**
  74032. * Medium blur
  74033. */
  74034. Medium = 1,
  74035. /**
  74036. * Large blur
  74037. */
  74038. High = 2
  74039. }
  74040. /**
  74041. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  74042. */
  74043. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  74044. private _circleOfConfusion;
  74045. /**
  74046. * @hidden Internal, blurs from high to low
  74047. */
  74048. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  74049. private _depthOfFieldBlurY;
  74050. private _dofMerge;
  74051. /**
  74052. * @hidden Internal post processes in depth of field effect
  74053. */
  74054. _effects: Array<PostProcess>;
  74055. /**
  74056. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  74057. */
  74058. set focalLength(value: number);
  74059. get focalLength(): number;
  74060. /**
  74061. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  74062. */
  74063. set fStop(value: number);
  74064. get fStop(): number;
  74065. /**
  74066. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  74067. */
  74068. set focusDistance(value: number);
  74069. get focusDistance(): number;
  74070. /**
  74071. * 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.
  74072. */
  74073. set lensSize(value: number);
  74074. get lensSize(): number;
  74075. /**
  74076. * Creates a new instance DepthOfFieldEffect
  74077. * @param scene The scene the effect belongs to.
  74078. * @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.
  74079. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  74080. * @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)
  74081. */
  74082. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  74083. /**
  74084. * Get the current class name of the current effet
  74085. * @returns "DepthOfFieldEffect"
  74086. */
  74087. getClassName(): string;
  74088. /**
  74089. * 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.
  74090. */
  74091. set depthTexture(value: RenderTargetTexture);
  74092. /**
  74093. * Disposes each of the internal effects for a given camera.
  74094. * @param camera The camera to dispose the effect on.
  74095. */
  74096. disposeEffects(camera: Camera): void;
  74097. /**
  74098. * @hidden Internal
  74099. */
  74100. _updateEffects(): void;
  74101. /**
  74102. * Internal
  74103. * @returns if all the contained post processes are ready.
  74104. * @hidden
  74105. */
  74106. _isReady(): boolean;
  74107. }
  74108. }
  74109. declare module BABYLON {
  74110. /** @hidden */
  74111. export var displayPassPixelShader: {
  74112. name: string;
  74113. shader: string;
  74114. };
  74115. }
  74116. declare module BABYLON {
  74117. /**
  74118. * DisplayPassPostProcess which produces an output the same as it's input
  74119. */
  74120. export class DisplayPassPostProcess extends PostProcess {
  74121. /**
  74122. * Gets a string identifying the name of the class
  74123. * @returns "DisplayPassPostProcess" string
  74124. */
  74125. getClassName(): string;
  74126. /**
  74127. * Creates the DisplayPassPostProcess
  74128. * @param name The name of the effect.
  74129. * @param options The required width/height ratio to downsize to before computing the render pass.
  74130. * @param camera The camera to apply the render pass to.
  74131. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74132. * @param engine The engine which the post process will be applied. (default: current engine)
  74133. * @param reusable If the post process can be reused on the same frame. (default: false)
  74134. */
  74135. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  74136. /** @hidden */
  74137. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<DisplayPassPostProcess>;
  74138. }
  74139. }
  74140. declare module BABYLON {
  74141. /** @hidden */
  74142. export var filterPixelShader: {
  74143. name: string;
  74144. shader: string;
  74145. };
  74146. }
  74147. declare module BABYLON {
  74148. /**
  74149. * Applies a kernel filter to the image
  74150. */
  74151. export class FilterPostProcess extends PostProcess {
  74152. /** The matrix to be applied to the image */
  74153. kernelMatrix: Matrix;
  74154. /**
  74155. * Gets a string identifying the name of the class
  74156. * @returns "FilterPostProcess" string
  74157. */
  74158. getClassName(): string;
  74159. /**
  74160. *
  74161. * @param name The name of the effect.
  74162. * @param kernelMatrix The matrix to be applied to the image
  74163. * @param options The required width/height ratio to downsize to before computing the render pass.
  74164. * @param camera The camera to apply the render pass to.
  74165. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74166. * @param engine The engine which the post process will be applied. (default: current engine)
  74167. * @param reusable If the post process can be reused on the same frame. (default: false)
  74168. */
  74169. constructor(name: string, kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  74170. /** @hidden */
  74171. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<FilterPostProcess>;
  74172. }
  74173. }
  74174. declare module BABYLON {
  74175. /** @hidden */
  74176. export var fxaaPixelShader: {
  74177. name: string;
  74178. shader: string;
  74179. };
  74180. }
  74181. declare module BABYLON {
  74182. /** @hidden */
  74183. export var fxaaVertexShader: {
  74184. name: string;
  74185. shader: string;
  74186. };
  74187. }
  74188. declare module BABYLON {
  74189. /**
  74190. * Fxaa post process
  74191. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  74192. */
  74193. export class FxaaPostProcess extends PostProcess {
  74194. /**
  74195. * Gets a string identifying the name of the class
  74196. * @returns "FxaaPostProcess" string
  74197. */
  74198. getClassName(): string;
  74199. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  74200. private _getDefines;
  74201. /** @hidden */
  74202. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): FxaaPostProcess;
  74203. }
  74204. }
  74205. declare module BABYLON {
  74206. /** @hidden */
  74207. export var grainPixelShader: {
  74208. name: string;
  74209. shader: string;
  74210. };
  74211. }
  74212. declare module BABYLON {
  74213. /**
  74214. * The GrainPostProcess adds noise to the image at mid luminance levels
  74215. */
  74216. export class GrainPostProcess extends PostProcess {
  74217. /**
  74218. * The intensity of the grain added (default: 30)
  74219. */
  74220. intensity: number;
  74221. /**
  74222. * If the grain should be randomized on every frame
  74223. */
  74224. animated: boolean;
  74225. /**
  74226. * Gets a string identifying the name of the class
  74227. * @returns "GrainPostProcess" string
  74228. */
  74229. getClassName(): string;
  74230. /**
  74231. * Creates a new instance of @see GrainPostProcess
  74232. * @param name The name of the effect.
  74233. * @param options The required width/height ratio to downsize to before computing the render pass.
  74234. * @param camera The camera to apply the render pass to.
  74235. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74236. * @param engine The engine which the post process will be applied. (default: current engine)
  74237. * @param reusable If the post process can be reused on the same frame. (default: false)
  74238. * @param textureType Type of textures used when performing the post process. (default: 0)
  74239. * @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)
  74240. */
  74241. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  74242. /** @hidden */
  74243. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): GrainPostProcess;
  74244. }
  74245. }
  74246. declare module BABYLON {
  74247. /** @hidden */
  74248. export var highlightsPixelShader: {
  74249. name: string;
  74250. shader: string;
  74251. };
  74252. }
  74253. declare module BABYLON {
  74254. /**
  74255. * Extracts highlights from the image
  74256. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  74257. */
  74258. export class HighlightsPostProcess extends PostProcess {
  74259. /**
  74260. * Gets a string identifying the name of the class
  74261. * @returns "HighlightsPostProcess" string
  74262. */
  74263. getClassName(): string;
  74264. /**
  74265. * Extracts highlights from the image
  74266. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  74267. * @param name The name of the effect.
  74268. * @param options The required width/height ratio to downsize to before computing the render pass.
  74269. * @param camera The camera to apply the render pass to.
  74270. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74271. * @param engine The engine which the post process will be applied. (default: current engine)
  74272. * @param reusable If the post process can be reused on the same frame. (default: false)
  74273. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  74274. */
  74275. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  74276. }
  74277. }
  74278. declare module BABYLON {
  74279. /**
  74280. * Contains all parameters needed for the prepass to perform
  74281. * motion blur
  74282. */
  74283. export class MotionBlurConfiguration implements PrePassEffectConfiguration {
  74284. /**
  74285. * Is motion blur enabled
  74286. */
  74287. enabled: boolean;
  74288. /**
  74289. * Name of the configuration
  74290. */
  74291. name: string;
  74292. /**
  74293. * Textures that should be present in the MRT for this effect to work
  74294. */
  74295. readonly texturesRequired: number[];
  74296. }
  74297. }
  74298. declare module BABYLON {
  74299. interface Scene {
  74300. /** @hidden (Backing field) */
  74301. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  74302. /**
  74303. * Gets or Sets the current geometry buffer associated to the scene.
  74304. */
  74305. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  74306. /**
  74307. * Enables a GeometryBufferRender and associates it with the scene
  74308. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  74309. * @returns the GeometryBufferRenderer
  74310. */
  74311. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  74312. /**
  74313. * Disables the GeometryBufferRender associated with the scene
  74314. */
  74315. disableGeometryBufferRenderer(): void;
  74316. }
  74317. /**
  74318. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  74319. * in several rendering techniques.
  74320. */
  74321. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  74322. /**
  74323. * The component name helpful to identify the component in the list of scene components.
  74324. */
  74325. readonly name: string;
  74326. /**
  74327. * The scene the component belongs to.
  74328. */
  74329. scene: Scene;
  74330. /**
  74331. * Creates a new instance of the component for the given scene
  74332. * @param scene Defines the scene to register the component in
  74333. */
  74334. constructor(scene: Scene);
  74335. /**
  74336. * Registers the component in a given scene
  74337. */
  74338. register(): void;
  74339. /**
  74340. * Rebuilds the elements related to this component in case of
  74341. * context lost for instance.
  74342. */
  74343. rebuild(): void;
  74344. /**
  74345. * Disposes the component and the associated ressources
  74346. */
  74347. dispose(): void;
  74348. private _gatherRenderTargets;
  74349. }
  74350. }
  74351. declare module BABYLON {
  74352. /** @hidden */
  74353. export var motionBlurPixelShader: {
  74354. name: string;
  74355. shader: string;
  74356. };
  74357. }
  74358. declare module BABYLON {
  74359. /**
  74360. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  74361. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  74362. * As an example, all you have to do is to create the post-process:
  74363. * var mb = new BABYLON.MotionBlurPostProcess(
  74364. * 'mb', // The name of the effect.
  74365. * scene, // The scene containing the objects to blur according to their velocity.
  74366. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  74367. * camera // The camera to apply the render pass to.
  74368. * );
  74369. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  74370. */
  74371. export class MotionBlurPostProcess extends PostProcess {
  74372. /**
  74373. * Defines how much the image is blurred by the movement. Default value is equal to 1
  74374. */
  74375. motionStrength: number;
  74376. /**
  74377. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  74378. */
  74379. get motionBlurSamples(): number;
  74380. /**
  74381. * Sets the number of iterations to be used for motion blur quality
  74382. */
  74383. set motionBlurSamples(samples: number);
  74384. private _motionBlurSamples;
  74385. /**
  74386. * Gets wether or not the motion blur post-process is in object based mode.
  74387. */
  74388. get isObjectBased(): boolean;
  74389. /**
  74390. * Sets wether or not the motion blur post-process is in object based mode.
  74391. */
  74392. set isObjectBased(value: boolean);
  74393. private _isObjectBased;
  74394. private _forceGeometryBuffer;
  74395. private _geometryBufferRenderer;
  74396. private _prePassRenderer;
  74397. private _invViewProjection;
  74398. private _previousViewProjection;
  74399. /**
  74400. * Gets a string identifying the name of the class
  74401. * @returns "MotionBlurPostProcess" string
  74402. */
  74403. getClassName(): string;
  74404. /**
  74405. * Creates a new instance MotionBlurPostProcess
  74406. * @param name The name of the effect.
  74407. * @param scene The scene containing the objects to blur according to their velocity.
  74408. * @param options The required width/height ratio to downsize to before computing the render pass.
  74409. * @param camera The camera to apply the render pass to.
  74410. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74411. * @param engine The engine which the post process will be applied. (default: current engine)
  74412. * @param reusable If the post process can be reused on the same frame. (default: false)
  74413. * @param textureType Type of textures used when performing the post process. (default: 0)
  74414. * @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: true)
  74415. * @param forceGeometryBuffer If this post process should use geometry buffer instead of prepass (default: false)
  74416. */
  74417. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean, forceGeometryBuffer?: boolean);
  74418. /**
  74419. * Excludes the given skinned mesh from computing bones velocities.
  74420. * 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.
  74421. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  74422. */
  74423. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  74424. /**
  74425. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  74426. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  74427. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  74428. */
  74429. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  74430. /**
  74431. * Disposes the post process.
  74432. * @param camera The camera to dispose the post process on.
  74433. */
  74434. dispose(camera?: Camera): void;
  74435. /**
  74436. * Called on the mode changed (object based or screen based).
  74437. */
  74438. private _applyMode;
  74439. /**
  74440. * Called on the effect is applied when the motion blur post-process is in object based mode.
  74441. */
  74442. private _onApplyObjectBased;
  74443. /**
  74444. * Called on the effect is applied when the motion blur post-process is in screen based mode.
  74445. */
  74446. private _onApplyScreenBased;
  74447. /**
  74448. * Called on the effect must be updated (changed mode, samples count, etc.).
  74449. */
  74450. private _updateEffect;
  74451. /** @hidden */
  74452. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<MotionBlurPostProcess>;
  74453. }
  74454. }
  74455. declare module BABYLON {
  74456. /** @hidden */
  74457. export var refractionPixelShader: {
  74458. name: string;
  74459. shader: string;
  74460. };
  74461. }
  74462. declare module BABYLON {
  74463. /**
  74464. * Post process which applies a refractin texture
  74465. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  74466. */
  74467. export class RefractionPostProcess extends PostProcess {
  74468. private _refTexture;
  74469. private _ownRefractionTexture;
  74470. /** the base color of the refraction (used to taint the rendering) */
  74471. color: Color3;
  74472. /** simulated refraction depth */
  74473. depth: number;
  74474. /** the coefficient of the base color (0 to remove base color tainting) */
  74475. colorLevel: number;
  74476. /** Gets the url used to load the refraction texture */
  74477. refractionTextureUrl: string;
  74478. /**
  74479. * Gets or sets the refraction texture
  74480. * Please note that you are responsible for disposing the texture if you set it manually
  74481. */
  74482. get refractionTexture(): Texture;
  74483. set refractionTexture(value: Texture);
  74484. /**
  74485. * Gets a string identifying the name of the class
  74486. * @returns "RefractionPostProcess" string
  74487. */
  74488. getClassName(): string;
  74489. /**
  74490. * Initializes the RefractionPostProcess
  74491. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  74492. * @param name The name of the effect.
  74493. * @param refractionTextureUrl Url of the refraction texture to use
  74494. * @param color the base color of the refraction (used to taint the rendering)
  74495. * @param depth simulated refraction depth
  74496. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  74497. * @param camera The camera to apply the render pass to.
  74498. * @param options The required width/height ratio to downsize to before computing the render pass.
  74499. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74500. * @param engine The engine which the post process will be applied. (default: current engine)
  74501. * @param reusable If the post process can be reused on the same frame. (default: false)
  74502. */
  74503. constructor(name: string, refractionTextureUrl: string, color: Color3, depth: number, colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  74504. /**
  74505. * Disposes of the post process
  74506. * @param camera Camera to dispose post process on
  74507. */
  74508. dispose(camera: Camera): void;
  74509. /** @hidden */
  74510. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): RefractionPostProcess;
  74511. }
  74512. }
  74513. declare module BABYLON {
  74514. /** @hidden */
  74515. export var sharpenPixelShader: {
  74516. name: string;
  74517. shader: string;
  74518. };
  74519. }
  74520. declare module BABYLON {
  74521. /**
  74522. * The SharpenPostProcess applies a sharpen kernel to every pixel
  74523. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  74524. */
  74525. export class SharpenPostProcess extends PostProcess {
  74526. /**
  74527. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  74528. */
  74529. colorAmount: number;
  74530. /**
  74531. * How much sharpness should be applied (default: 0.3)
  74532. */
  74533. edgeAmount: number;
  74534. /**
  74535. * Gets a string identifying the name of the class
  74536. * @returns "SharpenPostProcess" string
  74537. */
  74538. getClassName(): string;
  74539. /**
  74540. * Creates a new instance ConvolutionPostProcess
  74541. * @param name The name of the effect.
  74542. * @param options The required width/height ratio to downsize to before computing the render pass.
  74543. * @param camera The camera to apply the render pass to.
  74544. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74545. * @param engine The engine which the post process will be applied. (default: current engine)
  74546. * @param reusable If the post process can be reused on the same frame. (default: false)
  74547. * @param textureType Type of textures used when performing the post process. (default: 0)
  74548. * @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)
  74549. */
  74550. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  74551. /** @hidden */
  74552. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): SharpenPostProcess;
  74553. }
  74554. }
  74555. declare module BABYLON {
  74556. /**
  74557. * PostProcessRenderPipeline
  74558. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  74559. */
  74560. export class PostProcessRenderPipeline {
  74561. private engine;
  74562. private _renderEffects;
  74563. private _renderEffectsForIsolatedPass;
  74564. /**
  74565. * List of inspectable custom properties (used by the Inspector)
  74566. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  74567. */
  74568. inspectableCustomProperties: IInspectable[];
  74569. /**
  74570. * @hidden
  74571. */
  74572. protected _cameras: Camera[];
  74573. /** @hidden */
  74574. _name: string;
  74575. /**
  74576. * Gets pipeline name
  74577. */
  74578. get name(): string;
  74579. /** Gets the list of attached cameras */
  74580. get cameras(): Camera[];
  74581. /**
  74582. * Initializes a PostProcessRenderPipeline
  74583. * @param engine engine to add the pipeline to
  74584. * @param name name of the pipeline
  74585. */
  74586. constructor(engine: Engine, name: string);
  74587. /**
  74588. * Gets the class name
  74589. * @returns "PostProcessRenderPipeline"
  74590. */
  74591. getClassName(): string;
  74592. /**
  74593. * If all the render effects in the pipeline are supported
  74594. */
  74595. get isSupported(): boolean;
  74596. /**
  74597. * Adds an effect to the pipeline
  74598. * @param renderEffect the effect to add
  74599. */
  74600. addEffect(renderEffect: PostProcessRenderEffect): void;
  74601. /** @hidden */
  74602. _rebuild(): void;
  74603. /** @hidden */
  74604. _enableEffect(renderEffectName: string, cameras: Camera): void;
  74605. /** @hidden */
  74606. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  74607. /** @hidden */
  74608. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  74609. /** @hidden */
  74610. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  74611. /** @hidden */
  74612. _attachCameras(cameras: Camera, unique: boolean): void;
  74613. /** @hidden */
  74614. _attachCameras(cameras: Camera[], unique: boolean): void;
  74615. /** @hidden */
  74616. _detachCameras(cameras: Camera): void;
  74617. /** @hidden */
  74618. _detachCameras(cameras: Nullable<Camera[]>): void;
  74619. /** @hidden */
  74620. _update(): void;
  74621. /** @hidden */
  74622. _reset(): void;
  74623. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  74624. /**
  74625. * Sets the required values to the prepass renderer.
  74626. * @param prePassRenderer defines the prepass renderer to setup.
  74627. * @returns true if the pre pass is needed.
  74628. */
  74629. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  74630. /**
  74631. * Disposes of the pipeline
  74632. */
  74633. dispose(): void;
  74634. }
  74635. }
  74636. declare module BABYLON {
  74637. /**
  74638. * PostProcessRenderPipelineManager class
  74639. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  74640. */
  74641. export class PostProcessRenderPipelineManager {
  74642. private _renderPipelines;
  74643. /**
  74644. * Initializes a PostProcessRenderPipelineManager
  74645. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  74646. */
  74647. constructor();
  74648. /**
  74649. * Gets the list of supported render pipelines
  74650. */
  74651. get supportedPipelines(): PostProcessRenderPipeline[];
  74652. /**
  74653. * Adds a pipeline to the manager
  74654. * @param renderPipeline The pipeline to add
  74655. */
  74656. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  74657. /**
  74658. * Attaches a camera to the pipeline
  74659. * @param renderPipelineName The name of the pipeline to attach to
  74660. * @param cameras the camera to attach
  74661. * @param unique if the camera can be attached multiple times to the pipeline
  74662. */
  74663. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  74664. /**
  74665. * Detaches a camera from the pipeline
  74666. * @param renderPipelineName The name of the pipeline to detach from
  74667. * @param cameras the camera to detach
  74668. */
  74669. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  74670. /**
  74671. * Enables an effect by name on a pipeline
  74672. * @param renderPipelineName the name of the pipeline to enable the effect in
  74673. * @param renderEffectName the name of the effect to enable
  74674. * @param cameras the cameras that the effect should be enabled on
  74675. */
  74676. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  74677. /**
  74678. * Disables an effect by name on a pipeline
  74679. * @param renderPipelineName the name of the pipeline to disable the effect in
  74680. * @param renderEffectName the name of the effect to disable
  74681. * @param cameras the cameras that the effect should be disabled on
  74682. */
  74683. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  74684. /**
  74685. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  74686. */
  74687. update(): void;
  74688. /** @hidden */
  74689. _rebuild(): void;
  74690. /**
  74691. * Disposes of the manager and pipelines
  74692. */
  74693. dispose(): void;
  74694. }
  74695. }
  74696. declare module BABYLON {
  74697. interface Scene {
  74698. /** @hidden (Backing field) */
  74699. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  74700. /**
  74701. * Gets the postprocess render pipeline manager
  74702. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  74703. * @see https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  74704. */
  74705. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  74706. }
  74707. /**
  74708. * Defines the Render Pipeline scene component responsible to rendering pipelines
  74709. */
  74710. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  74711. /**
  74712. * The component name helpfull to identify the component in the list of scene components.
  74713. */
  74714. readonly name: string;
  74715. /**
  74716. * The scene the component belongs to.
  74717. */
  74718. scene: Scene;
  74719. /**
  74720. * Creates a new instance of the component for the given scene
  74721. * @param scene Defines the scene to register the component in
  74722. */
  74723. constructor(scene: Scene);
  74724. /**
  74725. * Registers the component in a given scene
  74726. */
  74727. register(): void;
  74728. /**
  74729. * Rebuilds the elements related to this component in case of
  74730. * context lost for instance.
  74731. */
  74732. rebuild(): void;
  74733. /**
  74734. * Disposes the component and the associated ressources
  74735. */
  74736. dispose(): void;
  74737. private _gatherRenderTargets;
  74738. }
  74739. }
  74740. declare module BABYLON {
  74741. /**
  74742. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  74743. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  74744. */
  74745. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  74746. private _scene;
  74747. private _camerasToBeAttached;
  74748. /**
  74749. * ID of the sharpen post process,
  74750. */
  74751. private readonly SharpenPostProcessId;
  74752. /**
  74753. * @ignore
  74754. * ID of the image processing post process;
  74755. */
  74756. readonly ImageProcessingPostProcessId: string;
  74757. /**
  74758. * @ignore
  74759. * ID of the Fast Approximate Anti-Aliasing post process;
  74760. */
  74761. readonly FxaaPostProcessId: string;
  74762. /**
  74763. * ID of the chromatic aberration post process,
  74764. */
  74765. private readonly ChromaticAberrationPostProcessId;
  74766. /**
  74767. * ID of the grain post process
  74768. */
  74769. private readonly GrainPostProcessId;
  74770. /**
  74771. * Sharpen post process which will apply a sharpen convolution to enhance edges
  74772. */
  74773. sharpen: SharpenPostProcess;
  74774. private _sharpenEffect;
  74775. private bloom;
  74776. /**
  74777. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  74778. */
  74779. depthOfField: DepthOfFieldEffect;
  74780. /**
  74781. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  74782. */
  74783. fxaa: FxaaPostProcess;
  74784. /**
  74785. * Image post processing pass used to perform operations such as tone mapping or color grading.
  74786. */
  74787. imageProcessing: ImageProcessingPostProcess;
  74788. /**
  74789. * Chromatic aberration post process which will shift rgb colors in the image
  74790. */
  74791. chromaticAberration: ChromaticAberrationPostProcess;
  74792. private _chromaticAberrationEffect;
  74793. /**
  74794. * Grain post process which add noise to the image
  74795. */
  74796. grain: GrainPostProcess;
  74797. private _grainEffect;
  74798. /**
  74799. * Glow post process which adds a glow to emissive areas of the image
  74800. */
  74801. private _glowLayer;
  74802. /**
  74803. * Animations which can be used to tweak settings over a period of time
  74804. */
  74805. animations: Animation[];
  74806. private _imageProcessingConfigurationObserver;
  74807. private _sharpenEnabled;
  74808. private _bloomEnabled;
  74809. private _depthOfFieldEnabled;
  74810. private _depthOfFieldBlurLevel;
  74811. private _fxaaEnabled;
  74812. private _imageProcessingEnabled;
  74813. private _defaultPipelineTextureType;
  74814. private _bloomScale;
  74815. private _chromaticAberrationEnabled;
  74816. private _grainEnabled;
  74817. private _buildAllowed;
  74818. /**
  74819. * This is triggered each time the pipeline has been built.
  74820. */
  74821. onBuildObservable: Observable<DefaultRenderingPipeline>;
  74822. /**
  74823. * Gets active scene
  74824. */
  74825. get scene(): Scene;
  74826. /**
  74827. * Enable or disable the sharpen process from the pipeline
  74828. */
  74829. set sharpenEnabled(enabled: boolean);
  74830. get sharpenEnabled(): boolean;
  74831. private _resizeObserver;
  74832. private _hardwareScaleLevel;
  74833. private _bloomKernel;
  74834. /**
  74835. * Specifies the size of the bloom blur kernel, relative to the final output size
  74836. */
  74837. get bloomKernel(): number;
  74838. set bloomKernel(value: number);
  74839. /**
  74840. * Specifies the weight of the bloom in the final rendering
  74841. */
  74842. private _bloomWeight;
  74843. /**
  74844. * Specifies the luma threshold for the area that will be blurred by the bloom
  74845. */
  74846. private _bloomThreshold;
  74847. private _hdr;
  74848. /**
  74849. * The strength of the bloom.
  74850. */
  74851. set bloomWeight(value: number);
  74852. get bloomWeight(): number;
  74853. /**
  74854. * The strength of the bloom.
  74855. */
  74856. set bloomThreshold(value: number);
  74857. get bloomThreshold(): number;
  74858. /**
  74859. * The scale of the bloom, lower value will provide better performance.
  74860. */
  74861. set bloomScale(value: number);
  74862. get bloomScale(): number;
  74863. /**
  74864. * Enable or disable the bloom from the pipeline
  74865. */
  74866. set bloomEnabled(enabled: boolean);
  74867. get bloomEnabled(): boolean;
  74868. private _rebuildBloom;
  74869. /**
  74870. * If the depth of field is enabled.
  74871. */
  74872. get depthOfFieldEnabled(): boolean;
  74873. set depthOfFieldEnabled(enabled: boolean);
  74874. /**
  74875. * Blur level of the depth of field effect. (Higher blur will effect performance)
  74876. */
  74877. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  74878. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  74879. /**
  74880. * If the anti aliasing is enabled.
  74881. */
  74882. set fxaaEnabled(enabled: boolean);
  74883. get fxaaEnabled(): boolean;
  74884. private _samples;
  74885. /**
  74886. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  74887. */
  74888. set samples(sampleCount: number);
  74889. get samples(): number;
  74890. /**
  74891. * If image processing is enabled.
  74892. */
  74893. set imageProcessingEnabled(enabled: boolean);
  74894. get imageProcessingEnabled(): boolean;
  74895. /**
  74896. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  74897. */
  74898. set glowLayerEnabled(enabled: boolean);
  74899. get glowLayerEnabled(): boolean;
  74900. /**
  74901. * Gets the glow layer (or null if not defined)
  74902. */
  74903. get glowLayer(): Nullable<GlowLayer>;
  74904. /**
  74905. * Enable or disable the chromaticAberration process from the pipeline
  74906. */
  74907. set chromaticAberrationEnabled(enabled: boolean);
  74908. get chromaticAberrationEnabled(): boolean;
  74909. /**
  74910. * Enable or disable the grain process from the pipeline
  74911. */
  74912. set grainEnabled(enabled: boolean);
  74913. get grainEnabled(): boolean;
  74914. /**
  74915. * @constructor
  74916. * @param name - The rendering pipeline name (default: "")
  74917. * @param hdr - If high dynamic range textures should be used (default: true)
  74918. * @param scene - The scene linked to this pipeline (default: the last created scene)
  74919. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  74920. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  74921. */
  74922. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  74923. /**
  74924. * Get the class name
  74925. * @returns "DefaultRenderingPipeline"
  74926. */
  74927. getClassName(): string;
  74928. /**
  74929. * Force the compilation of the entire pipeline.
  74930. */
  74931. prepare(): void;
  74932. private _hasCleared;
  74933. private _prevPostProcess;
  74934. private _prevPrevPostProcess;
  74935. private _setAutoClearAndTextureSharing;
  74936. private _depthOfFieldSceneObserver;
  74937. private _buildPipeline;
  74938. private _disposePostProcesses;
  74939. /**
  74940. * Adds a camera to the pipeline
  74941. * @param camera the camera to be added
  74942. */
  74943. addCamera(camera: Camera): void;
  74944. /**
  74945. * Removes a camera from the pipeline
  74946. * @param camera the camera to remove
  74947. */
  74948. removeCamera(camera: Camera): void;
  74949. /**
  74950. * Dispose of the pipeline and stop all post processes
  74951. */
  74952. dispose(): void;
  74953. /**
  74954. * Serialize the rendering pipeline (Used when exporting)
  74955. * @returns the serialized object
  74956. */
  74957. serialize(): any;
  74958. /**
  74959. * Parse the serialized pipeline
  74960. * @param source Source pipeline.
  74961. * @param scene The scene to load the pipeline to.
  74962. * @param rootUrl The URL of the serialized pipeline.
  74963. * @returns An instantiated pipeline from the serialized object.
  74964. */
  74965. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  74966. }
  74967. }
  74968. declare module BABYLON {
  74969. /** @hidden */
  74970. export var lensHighlightsPixelShader: {
  74971. name: string;
  74972. shader: string;
  74973. };
  74974. }
  74975. declare module BABYLON {
  74976. /** @hidden */
  74977. export var depthOfFieldPixelShader: {
  74978. name: string;
  74979. shader: string;
  74980. };
  74981. }
  74982. declare module BABYLON {
  74983. /**
  74984. * BABYLON.JS Chromatic Aberration GLSL Shader
  74985. * Author: Olivier Guyot
  74986. * Separates very slightly R, G and B colors on the edges of the screen
  74987. * Inspired by Francois Tarlier & Martins Upitis
  74988. */
  74989. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  74990. /**
  74991. * @ignore
  74992. * The chromatic aberration PostProcess id in the pipeline
  74993. */
  74994. LensChromaticAberrationEffect: string;
  74995. /**
  74996. * @ignore
  74997. * The highlights enhancing PostProcess id in the pipeline
  74998. */
  74999. HighlightsEnhancingEffect: string;
  75000. /**
  75001. * @ignore
  75002. * The depth-of-field PostProcess id in the pipeline
  75003. */
  75004. LensDepthOfFieldEffect: string;
  75005. private _scene;
  75006. private _depthTexture;
  75007. private _grainTexture;
  75008. private _chromaticAberrationPostProcess;
  75009. private _highlightsPostProcess;
  75010. private _depthOfFieldPostProcess;
  75011. private _edgeBlur;
  75012. private _grainAmount;
  75013. private _chromaticAberration;
  75014. private _distortion;
  75015. private _highlightsGain;
  75016. private _highlightsThreshold;
  75017. private _dofDistance;
  75018. private _dofAperture;
  75019. private _dofDarken;
  75020. private _dofPentagon;
  75021. private _blurNoise;
  75022. /**
  75023. * @constructor
  75024. *
  75025. * Effect parameters are as follow:
  75026. * {
  75027. * chromatic_aberration: number; // from 0 to x (1 for realism)
  75028. * edge_blur: number; // from 0 to x (1 for realism)
  75029. * distortion: number; // from 0 to x (1 for realism)
  75030. * grain_amount: number; // from 0 to 1
  75031. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  75032. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  75033. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  75034. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  75035. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  75036. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  75037. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  75038. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  75039. * }
  75040. * Note: if an effect parameter is unset, effect is disabled
  75041. *
  75042. * @param name The rendering pipeline name
  75043. * @param parameters - An object containing all parameters (see above)
  75044. * @param scene The scene linked to this pipeline
  75045. * @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)
  75046. * @param cameras The array of cameras that the rendering pipeline will be attached to
  75047. */
  75048. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  75049. /**
  75050. * Get the class name
  75051. * @returns "LensRenderingPipeline"
  75052. */
  75053. getClassName(): string;
  75054. /**
  75055. * Gets associated scene
  75056. */
  75057. get scene(): Scene;
  75058. /**
  75059. * Gets or sets the edge blur
  75060. */
  75061. get edgeBlur(): number;
  75062. set edgeBlur(value: number);
  75063. /**
  75064. * Gets or sets the grain amount
  75065. */
  75066. get grainAmount(): number;
  75067. set grainAmount(value: number);
  75068. /**
  75069. * Gets or sets the chromatic aberration amount
  75070. */
  75071. get chromaticAberration(): number;
  75072. set chromaticAberration(value: number);
  75073. /**
  75074. * Gets or sets the depth of field aperture
  75075. */
  75076. get dofAperture(): number;
  75077. set dofAperture(value: number);
  75078. /**
  75079. * Gets or sets the edge distortion
  75080. */
  75081. get edgeDistortion(): number;
  75082. set edgeDistortion(value: number);
  75083. /**
  75084. * Gets or sets the depth of field distortion
  75085. */
  75086. get dofDistortion(): number;
  75087. set dofDistortion(value: number);
  75088. /**
  75089. * Gets or sets the darken out of focus amount
  75090. */
  75091. get darkenOutOfFocus(): number;
  75092. set darkenOutOfFocus(value: number);
  75093. /**
  75094. * Gets or sets a boolean indicating if blur noise is enabled
  75095. */
  75096. get blurNoise(): boolean;
  75097. set blurNoise(value: boolean);
  75098. /**
  75099. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  75100. */
  75101. get pentagonBokeh(): boolean;
  75102. set pentagonBokeh(value: boolean);
  75103. /**
  75104. * Gets or sets the highlight grain amount
  75105. */
  75106. get highlightsGain(): number;
  75107. set highlightsGain(value: number);
  75108. /**
  75109. * Gets or sets the highlight threshold
  75110. */
  75111. get highlightsThreshold(): number;
  75112. set highlightsThreshold(value: number);
  75113. /**
  75114. * Sets the amount of blur at the edges
  75115. * @param amount blur amount
  75116. */
  75117. setEdgeBlur(amount: number): void;
  75118. /**
  75119. * Sets edge blur to 0
  75120. */
  75121. disableEdgeBlur(): void;
  75122. /**
  75123. * Sets the amout of grain
  75124. * @param amount Amount of grain
  75125. */
  75126. setGrainAmount(amount: number): void;
  75127. /**
  75128. * Set grain amount to 0
  75129. */
  75130. disableGrain(): void;
  75131. /**
  75132. * Sets the chromatic aberration amount
  75133. * @param amount amount of chromatic aberration
  75134. */
  75135. setChromaticAberration(amount: number): void;
  75136. /**
  75137. * Sets chromatic aberration amount to 0
  75138. */
  75139. disableChromaticAberration(): void;
  75140. /**
  75141. * Sets the EdgeDistortion amount
  75142. * @param amount amount of EdgeDistortion
  75143. */
  75144. setEdgeDistortion(amount: number): void;
  75145. /**
  75146. * Sets edge distortion to 0
  75147. */
  75148. disableEdgeDistortion(): void;
  75149. /**
  75150. * Sets the FocusDistance amount
  75151. * @param amount amount of FocusDistance
  75152. */
  75153. setFocusDistance(amount: number): void;
  75154. /**
  75155. * Disables depth of field
  75156. */
  75157. disableDepthOfField(): void;
  75158. /**
  75159. * Sets the Aperture amount
  75160. * @param amount amount of Aperture
  75161. */
  75162. setAperture(amount: number): void;
  75163. /**
  75164. * Sets the DarkenOutOfFocus amount
  75165. * @param amount amount of DarkenOutOfFocus
  75166. */
  75167. setDarkenOutOfFocus(amount: number): void;
  75168. private _pentagonBokehIsEnabled;
  75169. /**
  75170. * Creates a pentagon bokeh effect
  75171. */
  75172. enablePentagonBokeh(): void;
  75173. /**
  75174. * Disables the pentagon bokeh effect
  75175. */
  75176. disablePentagonBokeh(): void;
  75177. /**
  75178. * Enables noise blur
  75179. */
  75180. enableNoiseBlur(): void;
  75181. /**
  75182. * Disables noise blur
  75183. */
  75184. disableNoiseBlur(): void;
  75185. /**
  75186. * Sets the HighlightsGain amount
  75187. * @param amount amount of HighlightsGain
  75188. */
  75189. setHighlightsGain(amount: number): void;
  75190. /**
  75191. * Sets the HighlightsThreshold amount
  75192. * @param amount amount of HighlightsThreshold
  75193. */
  75194. setHighlightsThreshold(amount: number): void;
  75195. /**
  75196. * Disables highlights
  75197. */
  75198. disableHighlights(): void;
  75199. /**
  75200. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  75201. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  75202. */
  75203. dispose(disableDepthRender?: boolean): void;
  75204. private _createChromaticAberrationPostProcess;
  75205. private _createHighlightsPostProcess;
  75206. private _createDepthOfFieldPostProcess;
  75207. private _createGrainTexture;
  75208. }
  75209. }
  75210. declare module BABYLON {
  75211. /**
  75212. * Contains all parameters needed for the prepass to perform
  75213. * screen space subsurface scattering
  75214. */
  75215. export class SSAO2Configuration implements PrePassEffectConfiguration {
  75216. /**
  75217. * Is subsurface enabled
  75218. */
  75219. enabled: boolean;
  75220. /**
  75221. * Name of the configuration
  75222. */
  75223. name: string;
  75224. /**
  75225. * Textures that should be present in the MRT for this effect to work
  75226. */
  75227. readonly texturesRequired: number[];
  75228. }
  75229. }
  75230. declare module BABYLON {
  75231. /** @hidden */
  75232. export var ssao2PixelShader: {
  75233. name: string;
  75234. shader: string;
  75235. };
  75236. }
  75237. declare module BABYLON {
  75238. /** @hidden */
  75239. export var ssaoCombinePixelShader: {
  75240. name: string;
  75241. shader: string;
  75242. };
  75243. }
  75244. declare module BABYLON {
  75245. /**
  75246. * Render pipeline to produce ssao effect
  75247. */
  75248. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  75249. /**
  75250. * @ignore
  75251. * The PassPostProcess id in the pipeline that contains the original scene color
  75252. */
  75253. SSAOOriginalSceneColorEffect: string;
  75254. /**
  75255. * @ignore
  75256. * The SSAO PostProcess id in the pipeline
  75257. */
  75258. SSAORenderEffect: string;
  75259. /**
  75260. * @ignore
  75261. * The horizontal blur PostProcess id in the pipeline
  75262. */
  75263. SSAOBlurHRenderEffect: string;
  75264. /**
  75265. * @ignore
  75266. * The vertical blur PostProcess id in the pipeline
  75267. */
  75268. SSAOBlurVRenderEffect: string;
  75269. /**
  75270. * @ignore
  75271. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  75272. */
  75273. SSAOCombineRenderEffect: string;
  75274. /**
  75275. * The output strength of the SSAO post-process. Default value is 1.0.
  75276. */
  75277. totalStrength: number;
  75278. /**
  75279. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  75280. */
  75281. maxZ: number;
  75282. /**
  75283. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  75284. */
  75285. minZAspect: number;
  75286. private _samples;
  75287. /**
  75288. * Number of samples used for the SSAO calculations. Default value is 8
  75289. */
  75290. set samples(n: number);
  75291. get samples(): number;
  75292. private _textureSamples;
  75293. /**
  75294. * Number of samples to use for antialiasing
  75295. */
  75296. set textureSamples(n: number);
  75297. get textureSamples(): number;
  75298. /**
  75299. * Force rendering the geometry through geometry buffer
  75300. */
  75301. private _forceGeometryBuffer;
  75302. /**
  75303. * Ratio object used for SSAO ratio and blur ratio
  75304. */
  75305. private _ratio;
  75306. /**
  75307. * Dynamically generated sphere sampler.
  75308. */
  75309. private _sampleSphere;
  75310. /**
  75311. * Blur filter offsets
  75312. */
  75313. private _samplerOffsets;
  75314. private _expensiveBlur;
  75315. /**
  75316. * If bilateral blur should be used
  75317. */
  75318. set expensiveBlur(b: boolean);
  75319. get expensiveBlur(): boolean;
  75320. /**
  75321. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  75322. */
  75323. radius: number;
  75324. /**
  75325. * The base color of the SSAO post-process
  75326. * The final result is "base + ssao" between [0, 1]
  75327. */
  75328. base: number;
  75329. /**
  75330. * Support test.
  75331. */
  75332. static get IsSupported(): boolean;
  75333. private _scene;
  75334. private _randomTexture;
  75335. private _originalColorPostProcess;
  75336. private _ssaoPostProcess;
  75337. private _blurHPostProcess;
  75338. private _blurVPostProcess;
  75339. private _ssaoCombinePostProcess;
  75340. private _prePassRenderer;
  75341. /**
  75342. * Gets active scene
  75343. */
  75344. get scene(): Scene;
  75345. /**
  75346. * @constructor
  75347. * @param name The rendering pipeline name
  75348. * @param scene The scene linked to this pipeline
  75349. * @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 }
  75350. * @param cameras The array of cameras that the rendering pipeline will be attached to
  75351. * @param forceGeometryBuffer Set to true if you want to use the legacy geometry buffer renderer
  75352. */
  75353. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[], forceGeometryBuffer?: boolean);
  75354. /**
  75355. * Get the class name
  75356. * @returns "SSAO2RenderingPipeline"
  75357. */
  75358. getClassName(): string;
  75359. /**
  75360. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  75361. */
  75362. dispose(disableGeometryBufferRenderer?: boolean): void;
  75363. private _createBlurPostProcess;
  75364. /** @hidden */
  75365. _rebuild(): void;
  75366. private _bits;
  75367. private _radicalInverse_VdC;
  75368. private _hammersley;
  75369. private _hemisphereSample_uniform;
  75370. private _generateHemisphere;
  75371. private _getDefinesForSSAO;
  75372. private static readonly ORTHO_DEPTH_PROJECTION;
  75373. private static readonly PERSPECTIVE_DEPTH_PROJECTION;
  75374. private _createSSAOPostProcess;
  75375. private _createSSAOCombinePostProcess;
  75376. private _createRandomTexture;
  75377. /**
  75378. * Serialize the rendering pipeline (Used when exporting)
  75379. * @returns the serialized object
  75380. */
  75381. serialize(): any;
  75382. /**
  75383. * Parse the serialized pipeline
  75384. * @param source Source pipeline.
  75385. * @param scene The scene to load the pipeline to.
  75386. * @param rootUrl The URL of the serialized pipeline.
  75387. * @returns An instantiated pipeline from the serialized object.
  75388. */
  75389. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  75390. }
  75391. }
  75392. declare module BABYLON {
  75393. /** @hidden */
  75394. export var ssaoPixelShader: {
  75395. name: string;
  75396. shader: string;
  75397. };
  75398. }
  75399. declare module BABYLON {
  75400. /**
  75401. * Render pipeline to produce ssao effect
  75402. */
  75403. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  75404. /**
  75405. * @ignore
  75406. * The PassPostProcess id in the pipeline that contains the original scene color
  75407. */
  75408. SSAOOriginalSceneColorEffect: string;
  75409. /**
  75410. * @ignore
  75411. * The SSAO PostProcess id in the pipeline
  75412. */
  75413. SSAORenderEffect: string;
  75414. /**
  75415. * @ignore
  75416. * The horizontal blur PostProcess id in the pipeline
  75417. */
  75418. SSAOBlurHRenderEffect: string;
  75419. /**
  75420. * @ignore
  75421. * The vertical blur PostProcess id in the pipeline
  75422. */
  75423. SSAOBlurVRenderEffect: string;
  75424. /**
  75425. * @ignore
  75426. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  75427. */
  75428. SSAOCombineRenderEffect: string;
  75429. /**
  75430. * The output strength of the SSAO post-process. Default value is 1.0.
  75431. */
  75432. totalStrength: number;
  75433. /**
  75434. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  75435. */
  75436. radius: number;
  75437. /**
  75438. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  75439. * Must not be equal to fallOff and superior to fallOff.
  75440. * Default value is 0.0075
  75441. */
  75442. area: number;
  75443. /**
  75444. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  75445. * Must not be equal to area and inferior to area.
  75446. * Default value is 0.000001
  75447. */
  75448. fallOff: number;
  75449. /**
  75450. * The base color of the SSAO post-process
  75451. * The final result is "base + ssao" between [0, 1]
  75452. */
  75453. base: number;
  75454. private _scene;
  75455. private _depthTexture;
  75456. private _randomTexture;
  75457. private _originalColorPostProcess;
  75458. private _ssaoPostProcess;
  75459. private _blurHPostProcess;
  75460. private _blurVPostProcess;
  75461. private _ssaoCombinePostProcess;
  75462. private _firstUpdate;
  75463. /**
  75464. * Gets active scene
  75465. */
  75466. get scene(): Scene;
  75467. /**
  75468. * @constructor
  75469. * @param name - The rendering pipeline name
  75470. * @param scene - The scene linked to this pipeline
  75471. * @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 }
  75472. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  75473. */
  75474. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  75475. /**
  75476. * Get the class name
  75477. * @returns "SSAORenderingPipeline"
  75478. */
  75479. getClassName(): string;
  75480. /**
  75481. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  75482. */
  75483. dispose(disableDepthRender?: boolean): void;
  75484. private _createBlurPostProcess;
  75485. /** @hidden */
  75486. _rebuild(): void;
  75487. private _createSSAOPostProcess;
  75488. private _createSSAOCombinePostProcess;
  75489. private _createRandomTexture;
  75490. }
  75491. }
  75492. declare module BABYLON {
  75493. /**
  75494. * Contains all parameters needed for the prepass to perform
  75495. * screen space reflections
  75496. */
  75497. export class ScreenSpaceReflectionsConfiguration implements PrePassEffectConfiguration {
  75498. /**
  75499. * Is ssr enabled
  75500. */
  75501. enabled: boolean;
  75502. /**
  75503. * Name of the configuration
  75504. */
  75505. name: string;
  75506. /**
  75507. * Textures that should be present in the MRT for this effect to work
  75508. */
  75509. readonly texturesRequired: number[];
  75510. }
  75511. }
  75512. declare module BABYLON {
  75513. /** @hidden */
  75514. export var screenSpaceReflectionPixelShader: {
  75515. name: string;
  75516. shader: string;
  75517. };
  75518. }
  75519. declare module BABYLON {
  75520. /**
  75521. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  75522. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  75523. */
  75524. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  75525. /**
  75526. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  75527. */
  75528. threshold: number;
  75529. /**
  75530. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  75531. */
  75532. strength: number;
  75533. /**
  75534. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  75535. */
  75536. reflectionSpecularFalloffExponent: number;
  75537. /**
  75538. * 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]
  75539. */
  75540. step: number;
  75541. /**
  75542. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  75543. */
  75544. roughnessFactor: number;
  75545. private _forceGeometryBuffer;
  75546. private _geometryBufferRenderer;
  75547. private _prePassRenderer;
  75548. private _enableSmoothReflections;
  75549. private _reflectionSamples;
  75550. private _smoothSteps;
  75551. /**
  75552. * Gets a string identifying the name of the class
  75553. * @returns "ScreenSpaceReflectionPostProcess" string
  75554. */
  75555. getClassName(): string;
  75556. /**
  75557. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  75558. * @param name The name of the effect.
  75559. * @param scene The scene containing the objects to calculate reflections.
  75560. * @param options The required width/height ratio to downsize to before computing the render pass.
  75561. * @param camera The camera to apply the render pass to.
  75562. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  75563. * @param engine The engine which the post process will be applied. (default: current engine)
  75564. * @param reusable If the post process can be reused on the same frame. (default: false)
  75565. * @param textureType Type of textures used when performing the post process. (default: 0)
  75566. * @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: true)
  75567. * @param forceGeometryBuffer If this post process should use geometry buffer instead of prepass (default: false)
  75568. */
  75569. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean, forceGeometryBuffer?: boolean);
  75570. /**
  75571. * Gets wether or not smoothing reflections is enabled.
  75572. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  75573. */
  75574. get enableSmoothReflections(): boolean;
  75575. /**
  75576. * Sets wether or not smoothing reflections is enabled.
  75577. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  75578. */
  75579. set enableSmoothReflections(enabled: boolean);
  75580. /**
  75581. * Gets the number of samples taken while computing reflections. More samples count is high,
  75582. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  75583. */
  75584. get reflectionSamples(): number;
  75585. /**
  75586. * Sets the number of samples taken while computing reflections. More samples count is high,
  75587. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  75588. */
  75589. set reflectionSamples(samples: number);
  75590. /**
  75591. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  75592. * more the post-process will require GPU power and can generate a drop in FPS.
  75593. * Default value (5.0) work pretty well in all cases but can be adjusted.
  75594. */
  75595. get smoothSteps(): number;
  75596. set smoothSteps(steps: number);
  75597. private _updateEffectDefines;
  75598. /** @hidden */
  75599. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceReflectionPostProcess;
  75600. }
  75601. }
  75602. declare module BABYLON {
  75603. /** @hidden */
  75604. export var standardPixelShader: {
  75605. name: string;
  75606. shader: string;
  75607. };
  75608. }
  75609. declare module BABYLON {
  75610. /**
  75611. * Standard rendering pipeline
  75612. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  75613. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  75614. */
  75615. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  75616. /**
  75617. * Public members
  75618. */
  75619. /**
  75620. * Post-process which contains the original scene color before the pipeline applies all the effects
  75621. */
  75622. originalPostProcess: Nullable<PostProcess>;
  75623. /**
  75624. * Post-process used to down scale an image x4
  75625. */
  75626. downSampleX4PostProcess: Nullable<PostProcess>;
  75627. /**
  75628. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  75629. */
  75630. brightPassPostProcess: Nullable<PostProcess>;
  75631. /**
  75632. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  75633. */
  75634. blurHPostProcesses: PostProcess[];
  75635. /**
  75636. * Post-process array storing all the vertical blur post-processes used by the pipeline
  75637. */
  75638. blurVPostProcesses: PostProcess[];
  75639. /**
  75640. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  75641. */
  75642. textureAdderPostProcess: Nullable<PostProcess>;
  75643. /**
  75644. * Post-process used to create volumetric lighting effect
  75645. */
  75646. volumetricLightPostProcess: Nullable<PostProcess>;
  75647. /**
  75648. * Post-process used to smooth the previous volumetric light post-process on the X axis
  75649. */
  75650. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  75651. /**
  75652. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  75653. */
  75654. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  75655. /**
  75656. * Post-process used to merge the volumetric light effect and the real scene color
  75657. */
  75658. volumetricLightMergePostProces: Nullable<PostProcess>;
  75659. /**
  75660. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  75661. */
  75662. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  75663. /**
  75664. * Base post-process used to calculate the average luminance of the final image for HDR
  75665. */
  75666. luminancePostProcess: Nullable<PostProcess>;
  75667. /**
  75668. * Post-processes used to create down sample post-processes in order to get
  75669. * the average luminance of the final image for HDR
  75670. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  75671. */
  75672. luminanceDownSamplePostProcesses: PostProcess[];
  75673. /**
  75674. * Post-process used to create a HDR effect (light adaptation)
  75675. */
  75676. hdrPostProcess: Nullable<PostProcess>;
  75677. /**
  75678. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  75679. */
  75680. textureAdderFinalPostProcess: Nullable<PostProcess>;
  75681. /**
  75682. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  75683. */
  75684. lensFlareFinalPostProcess: Nullable<PostProcess>;
  75685. /**
  75686. * Post-process used to merge the final HDR post-process and the real scene color
  75687. */
  75688. hdrFinalPostProcess: Nullable<PostProcess>;
  75689. /**
  75690. * Post-process used to create a lens flare effect
  75691. */
  75692. lensFlarePostProcess: Nullable<PostProcess>;
  75693. /**
  75694. * Post-process that merges the result of the lens flare post-process and the real scene color
  75695. */
  75696. lensFlareComposePostProcess: Nullable<PostProcess>;
  75697. /**
  75698. * Post-process used to create a motion blur effect
  75699. */
  75700. motionBlurPostProcess: Nullable<PostProcess>;
  75701. /**
  75702. * Post-process used to create a depth of field effect
  75703. */
  75704. depthOfFieldPostProcess: Nullable<PostProcess>;
  75705. /**
  75706. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  75707. */
  75708. fxaaPostProcess: Nullable<FxaaPostProcess>;
  75709. /**
  75710. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  75711. */
  75712. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  75713. /**
  75714. * Represents the brightness threshold in order to configure the illuminated surfaces
  75715. */
  75716. brightThreshold: number;
  75717. /**
  75718. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  75719. */
  75720. blurWidth: number;
  75721. /**
  75722. * Sets if the blur for highlighted surfaces must be only horizontal
  75723. */
  75724. horizontalBlur: boolean;
  75725. /**
  75726. * Gets the overall exposure used by the pipeline
  75727. */
  75728. get exposure(): number;
  75729. /**
  75730. * Sets the overall exposure used by the pipeline
  75731. */
  75732. set exposure(value: number);
  75733. /**
  75734. * Texture used typically to simulate "dirty" on camera lens
  75735. */
  75736. lensTexture: Nullable<Texture>;
  75737. /**
  75738. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  75739. */
  75740. volumetricLightCoefficient: number;
  75741. /**
  75742. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  75743. */
  75744. volumetricLightPower: number;
  75745. /**
  75746. * Used the set the blur intensity to smooth the volumetric lights
  75747. */
  75748. volumetricLightBlurScale: number;
  75749. /**
  75750. * Light (spot or directional) used to generate the volumetric lights rays
  75751. * The source light must have a shadow generate so the pipeline can get its
  75752. * depth map
  75753. */
  75754. sourceLight: Nullable<SpotLight | DirectionalLight>;
  75755. /**
  75756. * For eye adaptation, represents the minimum luminance the eye can see
  75757. */
  75758. hdrMinimumLuminance: number;
  75759. /**
  75760. * For eye adaptation, represents the decrease luminance speed
  75761. */
  75762. hdrDecreaseRate: number;
  75763. /**
  75764. * For eye adaptation, represents the increase luminance speed
  75765. */
  75766. hdrIncreaseRate: number;
  75767. /**
  75768. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  75769. */
  75770. get hdrAutoExposure(): boolean;
  75771. /**
  75772. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  75773. */
  75774. set hdrAutoExposure(value: boolean);
  75775. /**
  75776. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  75777. */
  75778. lensColorTexture: Nullable<Texture>;
  75779. /**
  75780. * The overall strengh for the lens flare effect
  75781. */
  75782. lensFlareStrength: number;
  75783. /**
  75784. * Dispersion coefficient for lens flare ghosts
  75785. */
  75786. lensFlareGhostDispersal: number;
  75787. /**
  75788. * Main lens flare halo width
  75789. */
  75790. lensFlareHaloWidth: number;
  75791. /**
  75792. * Based on the lens distortion effect, defines how much the lens flare result
  75793. * is distorted
  75794. */
  75795. lensFlareDistortionStrength: number;
  75796. /**
  75797. * Configures the blur intensity used for for lens flare (halo)
  75798. */
  75799. lensFlareBlurWidth: number;
  75800. /**
  75801. * Lens star texture must be used to simulate rays on the flares and is available
  75802. * in the documentation
  75803. */
  75804. lensStarTexture: Nullable<Texture>;
  75805. /**
  75806. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  75807. * flare effect by taking account of the dirt texture
  75808. */
  75809. lensFlareDirtTexture: Nullable<Texture>;
  75810. /**
  75811. * Represents the focal length for the depth of field effect
  75812. */
  75813. depthOfFieldDistance: number;
  75814. /**
  75815. * Represents the blur intensity for the blurred part of the depth of field effect
  75816. */
  75817. depthOfFieldBlurWidth: number;
  75818. /**
  75819. * Gets how much the image is blurred by the movement while using the motion blur post-process
  75820. */
  75821. get motionStrength(): number;
  75822. /**
  75823. * Sets how much the image is blurred by the movement while using the motion blur post-process
  75824. */
  75825. set motionStrength(strength: number);
  75826. /**
  75827. * Gets wether or not the motion blur post-process is object based or screen based.
  75828. */
  75829. get objectBasedMotionBlur(): boolean;
  75830. /**
  75831. * Sets wether or not the motion blur post-process should be object based or screen based
  75832. */
  75833. set objectBasedMotionBlur(value: boolean);
  75834. /**
  75835. * List of animations for the pipeline (IAnimatable implementation)
  75836. */
  75837. animations: Animation[];
  75838. /**
  75839. * Private members
  75840. */
  75841. private _scene;
  75842. private _currentDepthOfFieldSource;
  75843. private _basePostProcess;
  75844. private _fixedExposure;
  75845. private _currentExposure;
  75846. private _hdrAutoExposure;
  75847. private _hdrCurrentLuminance;
  75848. private _motionStrength;
  75849. private _isObjectBasedMotionBlur;
  75850. private _floatTextureType;
  75851. private _camerasToBeAttached;
  75852. private _ratio;
  75853. private _bloomEnabled;
  75854. private _depthOfFieldEnabled;
  75855. private _vlsEnabled;
  75856. private _lensFlareEnabled;
  75857. private _hdrEnabled;
  75858. private _motionBlurEnabled;
  75859. private _fxaaEnabled;
  75860. private _screenSpaceReflectionsEnabled;
  75861. private _motionBlurSamples;
  75862. private _volumetricLightStepsCount;
  75863. private _samples;
  75864. /**
  75865. * @ignore
  75866. * Specifies if the bloom pipeline is enabled
  75867. */
  75868. get BloomEnabled(): boolean;
  75869. set BloomEnabled(enabled: boolean);
  75870. /**
  75871. * @ignore
  75872. * Specifies if the depth of field pipeline is enabed
  75873. */
  75874. get DepthOfFieldEnabled(): boolean;
  75875. set DepthOfFieldEnabled(enabled: boolean);
  75876. /**
  75877. * @ignore
  75878. * Specifies if the lens flare pipeline is enabed
  75879. */
  75880. get LensFlareEnabled(): boolean;
  75881. set LensFlareEnabled(enabled: boolean);
  75882. /**
  75883. * @ignore
  75884. * Specifies if the HDR pipeline is enabled
  75885. */
  75886. get HDREnabled(): boolean;
  75887. set HDREnabled(enabled: boolean);
  75888. /**
  75889. * @ignore
  75890. * Specifies if the volumetric lights scattering effect is enabled
  75891. */
  75892. get VLSEnabled(): boolean;
  75893. set VLSEnabled(enabled: boolean);
  75894. /**
  75895. * @ignore
  75896. * Specifies if the motion blur effect is enabled
  75897. */
  75898. get MotionBlurEnabled(): boolean;
  75899. set MotionBlurEnabled(enabled: boolean);
  75900. /**
  75901. * Specifies if anti-aliasing is enabled
  75902. */
  75903. get fxaaEnabled(): boolean;
  75904. set fxaaEnabled(enabled: boolean);
  75905. /**
  75906. * Specifies if screen space reflections are enabled.
  75907. */
  75908. get screenSpaceReflectionsEnabled(): boolean;
  75909. set screenSpaceReflectionsEnabled(enabled: boolean);
  75910. /**
  75911. * Specifies the number of steps used to calculate the volumetric lights
  75912. * Typically in interval [50, 200]
  75913. */
  75914. get volumetricLightStepsCount(): number;
  75915. set volumetricLightStepsCount(count: number);
  75916. /**
  75917. * Specifies the number of samples used for the motion blur effect
  75918. * Typically in interval [16, 64]
  75919. */
  75920. get motionBlurSamples(): number;
  75921. set motionBlurSamples(samples: number);
  75922. /**
  75923. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  75924. */
  75925. get samples(): number;
  75926. set samples(sampleCount: number);
  75927. /**
  75928. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  75929. * @constructor
  75930. * @param name The rendering pipeline name
  75931. * @param scene The scene linked to this pipeline
  75932. * @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)
  75933. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  75934. * @param cameras The array of cameras that the rendering pipeline will be attached to
  75935. */
  75936. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  75937. private _buildPipeline;
  75938. private _createDownSampleX4PostProcess;
  75939. private _createBrightPassPostProcess;
  75940. private _createBlurPostProcesses;
  75941. private _createTextureAdderPostProcess;
  75942. private _createVolumetricLightPostProcess;
  75943. private _createLuminancePostProcesses;
  75944. private _createHdrPostProcess;
  75945. private _createLensFlarePostProcess;
  75946. private _createDepthOfFieldPostProcess;
  75947. private _createMotionBlurPostProcess;
  75948. private _getDepthTexture;
  75949. private _disposePostProcesses;
  75950. /**
  75951. * Dispose of the pipeline and stop all post processes
  75952. */
  75953. dispose(): void;
  75954. /**
  75955. * Serialize the rendering pipeline (Used when exporting)
  75956. * @returns the serialized object
  75957. */
  75958. serialize(): any;
  75959. /**
  75960. * Parse the serialized pipeline
  75961. * @param source Source pipeline.
  75962. * @param scene The scene to load the pipeline to.
  75963. * @param rootUrl The URL of the serialized pipeline.
  75964. * @returns An instantiated pipeline from the serialized object.
  75965. */
  75966. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  75967. /**
  75968. * Luminance steps
  75969. */
  75970. static LuminanceSteps: number;
  75971. }
  75972. }
  75973. declare module BABYLON {
  75974. /** @hidden */
  75975. export var tonemapPixelShader: {
  75976. name: string;
  75977. shader: string;
  75978. };
  75979. }
  75980. declare module BABYLON {
  75981. /** Defines operator used for tonemapping */
  75982. export enum TonemappingOperator {
  75983. /** Hable */
  75984. Hable = 0,
  75985. /** Reinhard */
  75986. Reinhard = 1,
  75987. /** HejiDawson */
  75988. HejiDawson = 2,
  75989. /** Photographic */
  75990. Photographic = 3
  75991. }
  75992. /**
  75993. * Defines a post process to apply tone mapping
  75994. */
  75995. export class TonemapPostProcess extends PostProcess {
  75996. private _operator;
  75997. /** Defines the required exposure adjustement */
  75998. exposureAdjustment: number;
  75999. /**
  76000. * Gets a string identifying the name of the class
  76001. * @returns "TonemapPostProcess" string
  76002. */
  76003. getClassName(): string;
  76004. /**
  76005. * Creates a new TonemapPostProcess
  76006. * @param name defines the name of the postprocess
  76007. * @param _operator defines the operator to use
  76008. * @param exposureAdjustment defines the required exposure adjustement
  76009. * @param camera defines the camera to use (can be null)
  76010. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  76011. * @param engine defines the hosting engine (can be ignore if camera is set)
  76012. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  76013. */
  76014. constructor(name: string, _operator: TonemappingOperator,
  76015. /** Defines the required exposure adjustement */
  76016. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  76017. }
  76018. }
  76019. declare module BABYLON {
  76020. /** @hidden */
  76021. export var volumetricLightScatteringPixelShader: {
  76022. name: string;
  76023. shader: string;
  76024. };
  76025. }
  76026. declare module BABYLON {
  76027. /** @hidden */
  76028. export var volumetricLightScatteringPassVertexShader: {
  76029. name: string;
  76030. shader: string;
  76031. };
  76032. }
  76033. declare module BABYLON {
  76034. /** @hidden */
  76035. export var volumetricLightScatteringPassPixelShader: {
  76036. name: string;
  76037. shader: string;
  76038. };
  76039. }
  76040. declare module BABYLON {
  76041. /**
  76042. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  76043. */
  76044. export class VolumetricLightScatteringPostProcess extends PostProcess {
  76045. private _volumetricLightScatteringPass;
  76046. private _volumetricLightScatteringRTT;
  76047. private _viewPort;
  76048. private _screenCoordinates;
  76049. private _cachedDefines;
  76050. /**
  76051. * If not undefined, the mesh position is computed from the attached node position
  76052. */
  76053. attachedNode: {
  76054. position: Vector3;
  76055. };
  76056. /**
  76057. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  76058. */
  76059. customMeshPosition: Vector3;
  76060. /**
  76061. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  76062. */
  76063. useCustomMeshPosition: boolean;
  76064. /**
  76065. * If the post-process should inverse the light scattering direction
  76066. */
  76067. invert: boolean;
  76068. /**
  76069. * The internal mesh used by the post-process
  76070. */
  76071. mesh: Mesh;
  76072. /**
  76073. * @hidden
  76074. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  76075. */
  76076. get useDiffuseColor(): boolean;
  76077. set useDiffuseColor(useDiffuseColor: boolean);
  76078. /**
  76079. * Array containing the excluded meshes not rendered in the internal pass
  76080. */
  76081. excludedMeshes: AbstractMesh[];
  76082. /**
  76083. * Controls the overall intensity of the post-process
  76084. */
  76085. exposure: number;
  76086. /**
  76087. * Dissipates each sample's contribution in range [0, 1]
  76088. */
  76089. decay: number;
  76090. /**
  76091. * Controls the overall intensity of each sample
  76092. */
  76093. weight: number;
  76094. /**
  76095. * Controls the density of each sample
  76096. */
  76097. density: number;
  76098. /**
  76099. * @constructor
  76100. * @param name The post-process name
  76101. * @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)
  76102. * @param camera The camera that the post-process will be attached to
  76103. * @param mesh The mesh used to create the light scattering
  76104. * @param samples The post-process quality, default 100
  76105. * @param samplingModeThe post-process filtering mode
  76106. * @param engine The babylon engine
  76107. * @param reusable If the post-process is reusable
  76108. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  76109. */
  76110. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  76111. /**
  76112. * Returns the string "VolumetricLightScatteringPostProcess"
  76113. * @returns "VolumetricLightScatteringPostProcess"
  76114. */
  76115. getClassName(): string;
  76116. private _isReady;
  76117. /**
  76118. * Sets the new light position for light scattering effect
  76119. * @param position The new custom light position
  76120. */
  76121. setCustomMeshPosition(position: Vector3): void;
  76122. /**
  76123. * Returns the light position for light scattering effect
  76124. * @return Vector3 The custom light position
  76125. */
  76126. getCustomMeshPosition(): Vector3;
  76127. /**
  76128. * Disposes the internal assets and detaches the post-process from the camera
  76129. */
  76130. dispose(camera: Camera): void;
  76131. /**
  76132. * Returns the render target texture used by the post-process
  76133. * @return the render target texture used by the post-process
  76134. */
  76135. getPass(): RenderTargetTexture;
  76136. private _meshExcluded;
  76137. private _createPass;
  76138. private _updateMeshScreenCoordinates;
  76139. /**
  76140. * Creates a default mesh for the Volumeric Light Scattering post-process
  76141. * @param name The mesh name
  76142. * @param scene The scene where to create the mesh
  76143. * @return the default mesh
  76144. */
  76145. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  76146. }
  76147. }
  76148. declare module BABYLON {
  76149. /** @hidden */
  76150. export var screenSpaceCurvaturePixelShader: {
  76151. name: string;
  76152. shader: string;
  76153. };
  76154. }
  76155. declare module BABYLON {
  76156. /**
  76157. * The Screen Space curvature effect can help highlighting ridge and valley of a model.
  76158. */
  76159. export class ScreenSpaceCurvaturePostProcess extends PostProcess {
  76160. /**
  76161. * Defines how much ridge the curvature effect displays.
  76162. */
  76163. ridge: number;
  76164. /**
  76165. * Defines how much valley the curvature effect displays.
  76166. */
  76167. valley: number;
  76168. private _geometryBufferRenderer;
  76169. /**
  76170. * Gets a string identifying the name of the class
  76171. * @returns "ScreenSpaceCurvaturePostProcess" string
  76172. */
  76173. getClassName(): string;
  76174. /**
  76175. * Creates a new instance ScreenSpaceCurvaturePostProcess
  76176. * @param name The name of the effect.
  76177. * @param scene The scene containing the objects to blur according to their velocity.
  76178. * @param options The required width/height ratio to downsize to before computing the render pass.
  76179. * @param camera The camera to apply the render pass to.
  76180. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  76181. * @param engine The engine which the post process will be applied. (default: current engine)
  76182. * @param reusable If the post process can be reused on the same frame. (default: false)
  76183. * @param textureType Type of textures used when performing the post process. (default: 0)
  76184. * @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)
  76185. */
  76186. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  76187. /**
  76188. * Support test.
  76189. */
  76190. static get IsSupported(): boolean;
  76191. /** @hidden */
  76192. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceCurvaturePostProcess;
  76193. }
  76194. }
  76195. declare module BABYLON {
  76196. interface Scene {
  76197. /** @hidden (Backing field) */
  76198. _boundingBoxRenderer: BoundingBoxRenderer;
  76199. /** @hidden (Backing field) */
  76200. _forceShowBoundingBoxes: boolean;
  76201. /**
  76202. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  76203. */
  76204. forceShowBoundingBoxes: boolean;
  76205. /**
  76206. * Gets the bounding box renderer associated with the scene
  76207. * @returns a BoundingBoxRenderer
  76208. */
  76209. getBoundingBoxRenderer(): BoundingBoxRenderer;
  76210. }
  76211. interface AbstractMesh {
  76212. /** @hidden (Backing field) */
  76213. _showBoundingBox: boolean;
  76214. /**
  76215. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  76216. */
  76217. showBoundingBox: boolean;
  76218. }
  76219. /**
  76220. * Component responsible of rendering the bounding box of the meshes in a scene.
  76221. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  76222. */
  76223. export class BoundingBoxRenderer implements ISceneComponent {
  76224. /**
  76225. * The component name helpfull to identify the component in the list of scene components.
  76226. */
  76227. readonly name: string;
  76228. /**
  76229. * The scene the component belongs to.
  76230. */
  76231. scene: Scene;
  76232. /**
  76233. * Color of the bounding box lines placed in front of an object
  76234. */
  76235. frontColor: Color3;
  76236. /**
  76237. * Color of the bounding box lines placed behind an object
  76238. */
  76239. backColor: Color3;
  76240. /**
  76241. * Defines if the renderer should show the back lines or not
  76242. */
  76243. showBackLines: boolean;
  76244. /**
  76245. * Observable raised before rendering a bounding box
  76246. */
  76247. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  76248. /**
  76249. * Observable raised after rendering a bounding box
  76250. */
  76251. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  76252. /**
  76253. * Observable raised after resources are created
  76254. */
  76255. onResourcesReadyObservable: Observable<BoundingBoxRenderer>;
  76256. /**
  76257. * When false, no bounding boxes will be rendered
  76258. */
  76259. enabled: boolean;
  76260. /**
  76261. * @hidden
  76262. */
  76263. renderList: SmartArray<BoundingBox>;
  76264. private _colorShader;
  76265. private _vertexBuffers;
  76266. private _indexBuffer;
  76267. private _fillIndexBuffer;
  76268. private _fillIndexData;
  76269. /**
  76270. * Instantiates a new bounding box renderer in a scene.
  76271. * @param scene the scene the renderer renders in
  76272. */
  76273. constructor(scene: Scene);
  76274. /**
  76275. * Registers the component in a given scene
  76276. */
  76277. register(): void;
  76278. private _evaluateSubMesh;
  76279. private _preActiveMesh;
  76280. private _prepareResources;
  76281. private _createIndexBuffer;
  76282. /**
  76283. * Rebuilds the elements related to this component in case of
  76284. * context lost for instance.
  76285. */
  76286. rebuild(): void;
  76287. /**
  76288. * @hidden
  76289. */
  76290. reset(): void;
  76291. /**
  76292. * Render the bounding boxes of a specific rendering group
  76293. * @param renderingGroupId defines the rendering group to render
  76294. */
  76295. render(renderingGroupId: number): void;
  76296. /**
  76297. * In case of occlusion queries, we can render the occlusion bounding box through this method
  76298. * @param mesh Define the mesh to render the occlusion bounding box for
  76299. */
  76300. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  76301. /**
  76302. * Dispose and release the resources attached to this renderer.
  76303. */
  76304. dispose(): void;
  76305. }
  76306. }
  76307. declare module BABYLON {
  76308. interface Scene {
  76309. /** @hidden (Backing field) */
  76310. _depthRenderer: {
  76311. [id: string]: DepthRenderer;
  76312. };
  76313. /**
  76314. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  76315. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  76316. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  76317. * @param force32bitsFloat Forces 32 bits float when supported (else 16 bits float is prioritized over 32 bits float if supported)
  76318. * @returns the created depth renderer
  76319. */
  76320. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean, force32bitsFloat?: boolean): DepthRenderer;
  76321. /**
  76322. * Disables a depth renderer for a given camera
  76323. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  76324. */
  76325. disableDepthRenderer(camera?: Nullable<Camera>): void;
  76326. }
  76327. /**
  76328. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  76329. * in several rendering techniques.
  76330. */
  76331. export class DepthRendererSceneComponent implements ISceneComponent {
  76332. /**
  76333. * The component name helpfull to identify the component in the list of scene components.
  76334. */
  76335. readonly name: string;
  76336. /**
  76337. * The scene the component belongs to.
  76338. */
  76339. scene: Scene;
  76340. /**
  76341. * Creates a new instance of the component for the given scene
  76342. * @param scene Defines the scene to register the component in
  76343. */
  76344. constructor(scene: Scene);
  76345. /**
  76346. * Registers the component in a given scene
  76347. */
  76348. register(): void;
  76349. /**
  76350. * Rebuilds the elements related to this component in case of
  76351. * context lost for instance.
  76352. */
  76353. rebuild(): void;
  76354. /**
  76355. * Disposes the component and the associated ressources
  76356. */
  76357. dispose(): void;
  76358. private _gatherRenderTargets;
  76359. private _gatherActiveCameraRenderTargets;
  76360. }
  76361. }
  76362. declare module BABYLON {
  76363. interface AbstractScene {
  76364. /** @hidden (Backing field) */
  76365. _prePassRenderer: Nullable<PrePassRenderer>;
  76366. /**
  76367. * Gets or Sets the current prepass renderer associated to the scene.
  76368. */
  76369. prePassRenderer: Nullable<PrePassRenderer>;
  76370. /**
  76371. * Enables the prepass and associates it with the scene
  76372. * @returns the PrePassRenderer
  76373. */
  76374. enablePrePassRenderer(): Nullable<PrePassRenderer>;
  76375. /**
  76376. * Disables the prepass associated with the scene
  76377. */
  76378. disablePrePassRenderer(): void;
  76379. }
  76380. /**
  76381. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  76382. * in several rendering techniques.
  76383. */
  76384. export class PrePassRendererSceneComponent implements ISceneComponent {
  76385. /**
  76386. * The component name helpful to identify the component in the list of scene components.
  76387. */
  76388. readonly name: string;
  76389. /**
  76390. * The scene the component belongs to.
  76391. */
  76392. scene: Scene;
  76393. /**
  76394. * Creates a new instance of the component for the given scene
  76395. * @param scene Defines the scene to register the component in
  76396. */
  76397. constructor(scene: Scene);
  76398. /**
  76399. * Registers the component in a given scene
  76400. */
  76401. register(): void;
  76402. private _beforeCameraDraw;
  76403. private _afterCameraDraw;
  76404. private _beforeClearStage;
  76405. private _beforeRenderingMeshStage;
  76406. private _afterRenderingMeshStage;
  76407. /**
  76408. * Rebuilds the elements related to this component in case of
  76409. * context lost for instance.
  76410. */
  76411. rebuild(): void;
  76412. /**
  76413. * Disposes the component and the associated ressources
  76414. */
  76415. dispose(): void;
  76416. }
  76417. }
  76418. declare module BABYLON {
  76419. /** @hidden */
  76420. export var fibonacci: {
  76421. name: string;
  76422. shader: string;
  76423. };
  76424. }
  76425. declare module BABYLON {
  76426. /** @hidden */
  76427. export var diffusionProfile: {
  76428. name: string;
  76429. shader: string;
  76430. };
  76431. }
  76432. declare module BABYLON {
  76433. /** @hidden */
  76434. export var subSurfaceScatteringPixelShader: {
  76435. name: string;
  76436. shader: string;
  76437. };
  76438. }
  76439. declare module BABYLON {
  76440. /**
  76441. * Sub surface scattering post process
  76442. */
  76443. export class SubSurfaceScatteringPostProcess extends PostProcess {
  76444. /**
  76445. * Gets a string identifying the name of the class
  76446. * @returns "SubSurfaceScatteringPostProcess" string
  76447. */
  76448. getClassName(): string;
  76449. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  76450. }
  76451. }
  76452. declare module BABYLON {
  76453. /**
  76454. * Contains all parameters needed for the prepass to perform
  76455. * screen space subsurface scattering
  76456. */
  76457. export class SubSurfaceConfiguration implements PrePassEffectConfiguration {
  76458. /** @hidden */
  76459. static _SceneComponentInitialization: (scene: Scene) => void;
  76460. private _ssDiffusionS;
  76461. private _ssFilterRadii;
  76462. private _ssDiffusionD;
  76463. /**
  76464. * Post process to attach for screen space subsurface scattering
  76465. */
  76466. postProcess: SubSurfaceScatteringPostProcess;
  76467. /**
  76468. * Diffusion profile color for subsurface scattering
  76469. */
  76470. get ssDiffusionS(): number[];
  76471. /**
  76472. * Diffusion profile max color channel value for subsurface scattering
  76473. */
  76474. get ssDiffusionD(): number[];
  76475. /**
  76476. * Diffusion profile filter radius for subsurface scattering
  76477. */
  76478. get ssFilterRadii(): number[];
  76479. /**
  76480. * Is subsurface enabled
  76481. */
  76482. enabled: boolean;
  76483. /**
  76484. * Name of the configuration
  76485. */
  76486. name: string;
  76487. /**
  76488. * Diffusion profile colors for subsurface scattering
  76489. * You can add one diffusion color using `addDiffusionProfile` on `scene.prePassRenderer`
  76490. * See ...
  76491. * Note that you can only store up to 5 of them
  76492. */
  76493. ssDiffusionProfileColors: Color3[];
  76494. /**
  76495. * Defines the ratio real world => scene units.
  76496. * Used for subsurface scattering
  76497. */
  76498. metersPerUnit: number;
  76499. /**
  76500. * Textures that should be present in the MRT for this effect to work
  76501. */
  76502. readonly texturesRequired: number[];
  76503. private _scene;
  76504. /**
  76505. * Builds a subsurface configuration object
  76506. * @param scene The scene
  76507. */
  76508. constructor(scene: Scene);
  76509. /**
  76510. * Adds a new diffusion profile.
  76511. * Useful for more realistic subsurface scattering on diverse materials.
  76512. * @param color The color of the diffusion profile. Should be the average color of the material.
  76513. * @return The index of the diffusion profile for the material subsurface configuration
  76514. */
  76515. addDiffusionProfile(color: Color3): number;
  76516. /**
  76517. * Creates the sss post process
  76518. * @return The created post process
  76519. */
  76520. createPostProcess(): SubSurfaceScatteringPostProcess;
  76521. /**
  76522. * Deletes all diffusion profiles.
  76523. * Note that in order to render subsurface scattering, you should have at least 1 diffusion profile.
  76524. */
  76525. clearAllDiffusionProfiles(): void;
  76526. /**
  76527. * Disposes this object
  76528. */
  76529. dispose(): void;
  76530. /**
  76531. * @hidden
  76532. * https://zero-radiance.github.io/post/sampling-diffusion/
  76533. *
  76534. * Importance sample the normalized diffuse reflectance profile for the computed value of 's'.
  76535. * ------------------------------------------------------------------------------------
  76536. * R[r, phi, s] = s * (Exp[-r * s] + Exp[-r * s / 3]) / (8 * Pi * r)
  76537. * PDF[r, phi, s] = r * R[r, phi, s]
  76538. * CDF[r, s] = 1 - 1/4 * Exp[-r * s] - 3/4 * Exp[-r * s / 3]
  76539. * ------------------------------------------------------------------------------------
  76540. * We importance sample the color channel with the widest scattering distance.
  76541. */
  76542. getDiffusionProfileParameters(color: Color3): number;
  76543. /**
  76544. * Performs sampling of a Normalized Burley diffusion profile in polar coordinates.
  76545. * 'u' is the random number (the value of the CDF): [0, 1).
  76546. * rcp(s) = 1 / ShapeParam = ScatteringDistance.
  76547. * Returns the sampled radial distance, s.t. (u = 0 -> r = 0) and (u = 1 -> r = Inf).
  76548. */
  76549. private _sampleBurleyDiffusionProfile;
  76550. }
  76551. }
  76552. declare module BABYLON {
  76553. interface AbstractScene {
  76554. /** @hidden (Backing field) */
  76555. _subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  76556. /**
  76557. * Gets or Sets the current prepass renderer associated to the scene.
  76558. */
  76559. subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  76560. /**
  76561. * Enables the subsurface effect for prepass
  76562. * @returns the SubSurfaceConfiguration
  76563. */
  76564. enableSubSurfaceForPrePass(): Nullable<SubSurfaceConfiguration>;
  76565. /**
  76566. * Disables the subsurface effect for prepass
  76567. */
  76568. disableSubSurfaceForPrePass(): void;
  76569. }
  76570. /**
  76571. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  76572. * in several rendering techniques.
  76573. */
  76574. export class SubSurfaceSceneComponent implements ISceneSerializableComponent {
  76575. /**
  76576. * The component name helpful to identify the component in the list of scene components.
  76577. */
  76578. readonly name: string;
  76579. /**
  76580. * The scene the component belongs to.
  76581. */
  76582. scene: Scene;
  76583. /**
  76584. * Creates a new instance of the component for the given scene
  76585. * @param scene Defines the scene to register the component in
  76586. */
  76587. constructor(scene: Scene);
  76588. /**
  76589. * Registers the component in a given scene
  76590. */
  76591. register(): void;
  76592. /**
  76593. * Serializes the component data to the specified json object
  76594. * @param serializationObject The object to serialize to
  76595. */
  76596. serialize(serializationObject: any): void;
  76597. /**
  76598. * Adds all the elements from the container to the scene
  76599. * @param container the container holding the elements
  76600. */
  76601. addFromContainer(container: AbstractScene): void;
  76602. /**
  76603. * Removes all the elements in the container from the scene
  76604. * @param container contains the elements to remove
  76605. * @param dispose if the removed element should be disposed (default: false)
  76606. */
  76607. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  76608. /**
  76609. * Rebuilds the elements related to this component in case of
  76610. * context lost for instance.
  76611. */
  76612. rebuild(): void;
  76613. /**
  76614. * Disposes the component and the associated ressources
  76615. */
  76616. dispose(): void;
  76617. }
  76618. }
  76619. declare module BABYLON {
  76620. /** @hidden */
  76621. export var outlinePixelShader: {
  76622. name: string;
  76623. shader: string;
  76624. };
  76625. }
  76626. declare module BABYLON {
  76627. /** @hidden */
  76628. export var outlineVertexShader: {
  76629. name: string;
  76630. shader: string;
  76631. };
  76632. }
  76633. declare module BABYLON {
  76634. interface Scene {
  76635. /** @hidden */
  76636. _outlineRenderer: OutlineRenderer;
  76637. /**
  76638. * Gets the outline renderer associated with the scene
  76639. * @returns a OutlineRenderer
  76640. */
  76641. getOutlineRenderer(): OutlineRenderer;
  76642. }
  76643. interface AbstractMesh {
  76644. /** @hidden (Backing field) */
  76645. _renderOutline: boolean;
  76646. /**
  76647. * Gets or sets a boolean indicating if the outline must be rendered as well
  76648. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  76649. */
  76650. renderOutline: boolean;
  76651. /** @hidden (Backing field) */
  76652. _renderOverlay: boolean;
  76653. /**
  76654. * Gets or sets a boolean indicating if the overlay must be rendered as well
  76655. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  76656. */
  76657. renderOverlay: boolean;
  76658. }
  76659. /**
  76660. * This class is responsible to draw bothe outline/overlay of meshes.
  76661. * It should not be used directly but through the available method on mesh.
  76662. */
  76663. export class OutlineRenderer implements ISceneComponent {
  76664. /**
  76665. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  76666. */
  76667. private static _StencilReference;
  76668. /**
  76669. * The name of the component. Each component must have a unique name.
  76670. */
  76671. name: string;
  76672. /**
  76673. * The scene the component belongs to.
  76674. */
  76675. scene: Scene;
  76676. /**
  76677. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  76678. */
  76679. zOffset: number;
  76680. private _engine;
  76681. private _effect;
  76682. private _cachedDefines;
  76683. private _savedDepthWrite;
  76684. /**
  76685. * Instantiates a new outline renderer. (There could be only one per scene).
  76686. * @param scene Defines the scene it belongs to
  76687. */
  76688. constructor(scene: Scene);
  76689. /**
  76690. * Register the component to one instance of a scene.
  76691. */
  76692. register(): void;
  76693. /**
  76694. * Rebuilds the elements related to this component in case of
  76695. * context lost for instance.
  76696. */
  76697. rebuild(): void;
  76698. /**
  76699. * Disposes the component and the associated ressources.
  76700. */
  76701. dispose(): void;
  76702. /**
  76703. * Renders the outline in the canvas.
  76704. * @param subMesh Defines the sumesh to render
  76705. * @param batch Defines the batch of meshes in case of instances
  76706. * @param useOverlay Defines if the rendering is for the overlay or the outline
  76707. */
  76708. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  76709. /**
  76710. * Returns whether or not the outline renderer is ready for a given submesh.
  76711. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  76712. * @param subMesh Defines the submesh to check readyness for
  76713. * @param useInstances Defines wheter wee are trying to render instances or not
  76714. * @returns true if ready otherwise false
  76715. */
  76716. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  76717. private _beforeRenderingMesh;
  76718. private _afterRenderingMesh;
  76719. }
  76720. }
  76721. declare module BABYLON {
  76722. /**
  76723. * Defines the basic options interface of a Sprite Frame Source Size.
  76724. */
  76725. export interface ISpriteJSONSpriteSourceSize {
  76726. /**
  76727. * number of the original width of the Frame
  76728. */
  76729. w: number;
  76730. /**
  76731. * number of the original height of the Frame
  76732. */
  76733. h: number;
  76734. }
  76735. /**
  76736. * Defines the basic options interface of a Sprite Frame Data.
  76737. */
  76738. export interface ISpriteJSONSpriteFrameData {
  76739. /**
  76740. * number of the x offset of the Frame
  76741. */
  76742. x: number;
  76743. /**
  76744. * number of the y offset of the Frame
  76745. */
  76746. y: number;
  76747. /**
  76748. * number of the width of the Frame
  76749. */
  76750. w: number;
  76751. /**
  76752. * number of the height of the Frame
  76753. */
  76754. h: number;
  76755. }
  76756. /**
  76757. * Defines the basic options interface of a JSON Sprite.
  76758. */
  76759. export interface ISpriteJSONSprite {
  76760. /**
  76761. * string name of the Frame
  76762. */
  76763. filename: string;
  76764. /**
  76765. * ISpriteJSONSpriteFrame basic object of the frame data
  76766. */
  76767. frame: ISpriteJSONSpriteFrameData;
  76768. /**
  76769. * boolean to flag is the frame was rotated.
  76770. */
  76771. rotated: boolean;
  76772. /**
  76773. * boolean to flag is the frame was trimmed.
  76774. */
  76775. trimmed: boolean;
  76776. /**
  76777. * ISpriteJSONSpriteFrame basic object of the source data
  76778. */
  76779. spriteSourceSize: ISpriteJSONSpriteFrameData;
  76780. /**
  76781. * ISpriteJSONSpriteFrame basic object of the source data
  76782. */
  76783. sourceSize: ISpriteJSONSpriteSourceSize;
  76784. }
  76785. /**
  76786. * Defines the basic options interface of a JSON atlas.
  76787. */
  76788. export interface ISpriteJSONAtlas {
  76789. /**
  76790. * Array of objects that contain the frame data.
  76791. */
  76792. frames: Array<ISpriteJSONSprite>;
  76793. /**
  76794. * object basic object containing the sprite meta data.
  76795. */
  76796. meta?: object;
  76797. }
  76798. }
  76799. declare module BABYLON {
  76800. /** @hidden */
  76801. export var spriteMapPixelShader: {
  76802. name: string;
  76803. shader: string;
  76804. };
  76805. }
  76806. declare module BABYLON {
  76807. /** @hidden */
  76808. export var spriteMapVertexShader: {
  76809. name: string;
  76810. shader: string;
  76811. };
  76812. }
  76813. declare module BABYLON {
  76814. /**
  76815. * Defines the basic options interface of a SpriteMap
  76816. */
  76817. export interface ISpriteMapOptions {
  76818. /**
  76819. * Vector2 of the number of cells in the grid.
  76820. */
  76821. stageSize?: Vector2;
  76822. /**
  76823. * Vector2 of the size of the output plane in World Units.
  76824. */
  76825. outputSize?: Vector2;
  76826. /**
  76827. * Vector3 of the position of the output plane in World Units.
  76828. */
  76829. outputPosition?: Vector3;
  76830. /**
  76831. * Vector3 of the rotation of the output plane.
  76832. */
  76833. outputRotation?: Vector3;
  76834. /**
  76835. * number of layers that the system will reserve in resources.
  76836. */
  76837. layerCount?: number;
  76838. /**
  76839. * number of max animation frames a single cell will reserve in resources.
  76840. */
  76841. maxAnimationFrames?: number;
  76842. /**
  76843. * number cell index of the base tile when the system compiles.
  76844. */
  76845. baseTile?: number;
  76846. /**
  76847. * boolean flip the sprite after its been repositioned by the framing data.
  76848. */
  76849. flipU?: boolean;
  76850. /**
  76851. * Vector3 scalar of the global RGB values of the SpriteMap.
  76852. */
  76853. colorMultiply?: Vector3;
  76854. }
  76855. /**
  76856. * Defines the IDisposable interface in order to be cleanable from resources.
  76857. */
  76858. export interface ISpriteMap extends IDisposable {
  76859. /**
  76860. * String name of the SpriteMap.
  76861. */
  76862. name: string;
  76863. /**
  76864. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  76865. */
  76866. atlasJSON: ISpriteJSONAtlas;
  76867. /**
  76868. * Texture of the SpriteMap.
  76869. */
  76870. spriteSheet: Texture;
  76871. /**
  76872. * The parameters to initialize the SpriteMap with.
  76873. */
  76874. options: ISpriteMapOptions;
  76875. }
  76876. /**
  76877. * Class used to manage a grid restricted sprite deployment on an Output plane.
  76878. */
  76879. export class SpriteMap implements ISpriteMap {
  76880. /** The Name of the spriteMap */
  76881. name: string;
  76882. /** The JSON file with the frame and meta data */
  76883. atlasJSON: ISpriteJSONAtlas;
  76884. /** The systems Sprite Sheet Texture */
  76885. spriteSheet: Texture;
  76886. /** Arguments passed with the Constructor */
  76887. options: ISpriteMapOptions;
  76888. /** Public Sprite Storage array, parsed from atlasJSON */
  76889. sprites: Array<ISpriteJSONSprite>;
  76890. /** Returns the Number of Sprites in the System */
  76891. get spriteCount(): number;
  76892. /** Returns the Position of Output Plane*/
  76893. get position(): Vector3;
  76894. /** Returns the Position of Output Plane*/
  76895. set position(v: Vector3);
  76896. /** Returns the Rotation of Output Plane*/
  76897. get rotation(): Vector3;
  76898. /** Returns the Rotation of Output Plane*/
  76899. set rotation(v: Vector3);
  76900. /** Sets the AnimationMap*/
  76901. get animationMap(): RawTexture;
  76902. /** Sets the AnimationMap*/
  76903. set animationMap(v: RawTexture);
  76904. /** Scene that the SpriteMap was created in */
  76905. private _scene;
  76906. /** Texture Buffer of Float32 that holds tile frame data*/
  76907. private _frameMap;
  76908. /** Texture Buffers of Float32 that holds tileMap data*/
  76909. private _tileMaps;
  76910. /** Texture Buffer of Float32 that holds Animation Data*/
  76911. private _animationMap;
  76912. /** Custom ShaderMaterial Central to the System*/
  76913. private _material;
  76914. /** Custom ShaderMaterial Central to the System*/
  76915. private _output;
  76916. /** Systems Time Ticker*/
  76917. private _time;
  76918. /**
  76919. * Creates a new SpriteMap
  76920. * @param name defines the SpriteMaps Name
  76921. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  76922. * @param spriteSheet is the Texture that the Sprites are on.
  76923. * @param options a basic deployment configuration
  76924. * @param scene The Scene that the map is deployed on
  76925. */
  76926. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  76927. /**
  76928. * Returns tileID location
  76929. * @returns Vector2 the cell position ID
  76930. */
  76931. getTileID(): Vector2;
  76932. /**
  76933. * Gets the UV location of the mouse over the SpriteMap.
  76934. * @returns Vector2 the UV position of the mouse interaction
  76935. */
  76936. getMousePosition(): Vector2;
  76937. /**
  76938. * Creates the "frame" texture Buffer
  76939. * -------------------------------------
  76940. * Structure of frames
  76941. * "filename": "Falling-Water-2.png",
  76942. * "frame": {"x":69,"y":103,"w":24,"h":32},
  76943. * "rotated": true,
  76944. * "trimmed": true,
  76945. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  76946. * "sourceSize": {"w":32,"h":32}
  76947. * @returns RawTexture of the frameMap
  76948. */
  76949. private _createFrameBuffer;
  76950. /**
  76951. * Creates the tileMap texture Buffer
  76952. * @param buffer normally and array of numbers, or a false to generate from scratch
  76953. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  76954. * @returns RawTexture of the tileMap
  76955. */
  76956. private _createTileBuffer;
  76957. /**
  76958. * Modifies the data of the tileMaps
  76959. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  76960. * @param pos is the iVector2 Coordinates of the Tile
  76961. * @param tile The SpriteIndex of the new Tile
  76962. */
  76963. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  76964. /**
  76965. * Creates the animationMap texture Buffer
  76966. * @param buffer normally and array of numbers, or a false to generate from scratch
  76967. * @returns RawTexture of the animationMap
  76968. */
  76969. private _createTileAnimationBuffer;
  76970. /**
  76971. * Modifies the data of the animationMap
  76972. * @param cellID is the Index of the Sprite
  76973. * @param _frame is the target Animation frame
  76974. * @param toCell is the Target Index of the next frame of the animation
  76975. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  76976. * @param speed is a global scalar of the time variable on the map.
  76977. */
  76978. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  76979. /**
  76980. * Exports the .tilemaps file
  76981. */
  76982. saveTileMaps(): void;
  76983. /**
  76984. * Imports the .tilemaps file
  76985. * @param url of the .tilemaps file
  76986. */
  76987. loadTileMaps(url: string): void;
  76988. /**
  76989. * Release associated resources
  76990. */
  76991. dispose(): void;
  76992. }
  76993. }
  76994. declare module BABYLON {
  76995. /**
  76996. * Class used to manage multiple sprites of different sizes on the same spritesheet
  76997. * @see https://doc.babylonjs.com/babylon101/sprites
  76998. */
  76999. export class SpritePackedManager extends SpriteManager {
  77000. /** defines the packed manager's name */
  77001. name: string;
  77002. /**
  77003. * Creates a new sprite manager from a packed sprite sheet
  77004. * @param name defines the manager's name
  77005. * @param imgUrl defines the sprite sheet url
  77006. * @param capacity defines the maximum allowed number of sprites
  77007. * @param scene defines the hosting scene
  77008. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  77009. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  77010. * @param samplingMode defines the smapling mode to use with spritesheet
  77011. * @param fromPacked set to true; do not alter
  77012. */
  77013. constructor(
  77014. /** defines the packed manager's name */
  77015. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  77016. }
  77017. }
  77018. declare module BABYLON {
  77019. /**
  77020. * Defines the list of states available for a task inside a AssetsManager
  77021. */
  77022. export enum AssetTaskState {
  77023. /**
  77024. * Initialization
  77025. */
  77026. INIT = 0,
  77027. /**
  77028. * Running
  77029. */
  77030. RUNNING = 1,
  77031. /**
  77032. * Done
  77033. */
  77034. DONE = 2,
  77035. /**
  77036. * Error
  77037. */
  77038. ERROR = 3
  77039. }
  77040. /**
  77041. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  77042. */
  77043. export abstract class AbstractAssetTask {
  77044. /**
  77045. * Task name
  77046. */ name: string;
  77047. /**
  77048. * Callback called when the task is successful
  77049. */
  77050. onSuccess: (task: any) => void;
  77051. /**
  77052. * Callback called when the task is not successful
  77053. */
  77054. onError: (task: any, message?: string, exception?: any) => void;
  77055. /**
  77056. * Creates a new AssetsManager
  77057. * @param name defines the name of the task
  77058. */
  77059. constructor(
  77060. /**
  77061. * Task name
  77062. */ name: string);
  77063. private _isCompleted;
  77064. private _taskState;
  77065. private _errorObject;
  77066. /**
  77067. * Get if the task is completed
  77068. */
  77069. get isCompleted(): boolean;
  77070. /**
  77071. * Gets the current state of the task
  77072. */
  77073. get taskState(): AssetTaskState;
  77074. /**
  77075. * Gets the current error object (if task is in error)
  77076. */
  77077. get errorObject(): {
  77078. message?: string;
  77079. exception?: any;
  77080. };
  77081. /**
  77082. * Internal only
  77083. * @hidden
  77084. */
  77085. _setErrorObject(message?: string, exception?: any): void;
  77086. /**
  77087. * Execute the current task
  77088. * @param scene defines the scene where you want your assets to be loaded
  77089. * @param onSuccess is a callback called when the task is successfully executed
  77090. * @param onError is a callback called if an error occurs
  77091. */
  77092. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77093. /**
  77094. * Execute the current task
  77095. * @param scene defines the scene where you want your assets to be loaded
  77096. * @param onSuccess is a callback called when the task is successfully executed
  77097. * @param onError is a callback called if an error occurs
  77098. */
  77099. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77100. /**
  77101. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  77102. * This can be used with failed tasks that have the reason for failure fixed.
  77103. */
  77104. reset(): void;
  77105. private onErrorCallback;
  77106. private onDoneCallback;
  77107. }
  77108. /**
  77109. * Define the interface used by progress events raised during assets loading
  77110. */
  77111. export interface IAssetsProgressEvent {
  77112. /**
  77113. * Defines the number of remaining tasks to process
  77114. */
  77115. remainingCount: number;
  77116. /**
  77117. * Defines the total number of tasks
  77118. */
  77119. totalCount: number;
  77120. /**
  77121. * Defines the task that was just processed
  77122. */
  77123. task: AbstractAssetTask;
  77124. }
  77125. /**
  77126. * Class used to share progress information about assets loading
  77127. */
  77128. export class AssetsProgressEvent implements IAssetsProgressEvent {
  77129. /**
  77130. * Defines the number of remaining tasks to process
  77131. */
  77132. remainingCount: number;
  77133. /**
  77134. * Defines the total number of tasks
  77135. */
  77136. totalCount: number;
  77137. /**
  77138. * Defines the task that was just processed
  77139. */
  77140. task: AbstractAssetTask;
  77141. /**
  77142. * Creates a AssetsProgressEvent
  77143. * @param remainingCount defines the number of remaining tasks to process
  77144. * @param totalCount defines the total number of tasks
  77145. * @param task defines the task that was just processed
  77146. */
  77147. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  77148. }
  77149. /**
  77150. * Define a task used by AssetsManager to load assets into a container
  77151. */
  77152. export class ContainerAssetTask extends AbstractAssetTask {
  77153. /**
  77154. * Defines the name of the task
  77155. */
  77156. name: string;
  77157. /**
  77158. * Defines the list of mesh's names you want to load
  77159. */
  77160. meshesNames: any;
  77161. /**
  77162. * Defines the root url to use as a base to load your meshes and associated resources
  77163. */
  77164. rootUrl: string;
  77165. /**
  77166. * Defines the filename or File of the scene to load from
  77167. */
  77168. sceneFilename: string | File;
  77169. /**
  77170. * Get the loaded asset container
  77171. */
  77172. loadedContainer: AssetContainer;
  77173. /**
  77174. * Gets the list of loaded meshes
  77175. */
  77176. loadedMeshes: Array<AbstractMesh>;
  77177. /**
  77178. * Gets the list of loaded particle systems
  77179. */
  77180. loadedParticleSystems: Array<IParticleSystem>;
  77181. /**
  77182. * Gets the list of loaded skeletons
  77183. */
  77184. loadedSkeletons: Array<Skeleton>;
  77185. /**
  77186. * Gets the list of loaded animation groups
  77187. */
  77188. loadedAnimationGroups: Array<AnimationGroup>;
  77189. /**
  77190. * Callback called when the task is successful
  77191. */
  77192. onSuccess: (task: ContainerAssetTask) => void;
  77193. /**
  77194. * Callback called when the task is successful
  77195. */
  77196. onError: (task: ContainerAssetTask, message?: string, exception?: any) => void;
  77197. /**
  77198. * Creates a new ContainerAssetTask
  77199. * @param name defines the name of the task
  77200. * @param meshesNames defines the list of mesh's names you want to load
  77201. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  77202. * @param sceneFilename defines the filename or File of the scene to load from
  77203. */
  77204. constructor(
  77205. /**
  77206. * Defines the name of the task
  77207. */
  77208. name: string,
  77209. /**
  77210. * Defines the list of mesh's names you want to load
  77211. */
  77212. meshesNames: any,
  77213. /**
  77214. * Defines the root url to use as a base to load your meshes and associated resources
  77215. */
  77216. rootUrl: string,
  77217. /**
  77218. * Defines the filename or File of the scene to load from
  77219. */
  77220. sceneFilename: string | File);
  77221. /**
  77222. * Execute the current task
  77223. * @param scene defines the scene where you want your assets to be loaded
  77224. * @param onSuccess is a callback called when the task is successfully executed
  77225. * @param onError is a callback called if an error occurs
  77226. */
  77227. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77228. }
  77229. /**
  77230. * Define a task used by AssetsManager to load meshes
  77231. */
  77232. export class MeshAssetTask extends AbstractAssetTask {
  77233. /**
  77234. * Defines the name of the task
  77235. */
  77236. name: string;
  77237. /**
  77238. * Defines the list of mesh's names you want to load
  77239. */
  77240. meshesNames: any;
  77241. /**
  77242. * Defines the root url to use as a base to load your meshes and associated resources
  77243. */
  77244. rootUrl: string;
  77245. /**
  77246. * Defines the filename or File of the scene to load from
  77247. */
  77248. sceneFilename: string | File;
  77249. /**
  77250. * Gets the list of loaded meshes
  77251. */
  77252. loadedMeshes: Array<AbstractMesh>;
  77253. /**
  77254. * Gets the list of loaded particle systems
  77255. */
  77256. loadedParticleSystems: Array<IParticleSystem>;
  77257. /**
  77258. * Gets the list of loaded skeletons
  77259. */
  77260. loadedSkeletons: Array<Skeleton>;
  77261. /**
  77262. * Gets the list of loaded animation groups
  77263. */
  77264. loadedAnimationGroups: Array<AnimationGroup>;
  77265. /**
  77266. * Callback called when the task is successful
  77267. */
  77268. onSuccess: (task: MeshAssetTask) => void;
  77269. /**
  77270. * Callback called when the task is successful
  77271. */
  77272. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  77273. /**
  77274. * Creates a new MeshAssetTask
  77275. * @param name defines the name of the task
  77276. * @param meshesNames defines the list of mesh's names you want to load
  77277. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  77278. * @param sceneFilename defines the filename or File of the scene to load from
  77279. */
  77280. constructor(
  77281. /**
  77282. * Defines the name of the task
  77283. */
  77284. name: string,
  77285. /**
  77286. * Defines the list of mesh's names you want to load
  77287. */
  77288. meshesNames: any,
  77289. /**
  77290. * Defines the root url to use as a base to load your meshes and associated resources
  77291. */
  77292. rootUrl: string,
  77293. /**
  77294. * Defines the filename or File of the scene to load from
  77295. */
  77296. sceneFilename: string | File);
  77297. /**
  77298. * Execute the current task
  77299. * @param scene defines the scene where you want your assets to be loaded
  77300. * @param onSuccess is a callback called when the task is successfully executed
  77301. * @param onError is a callback called if an error occurs
  77302. */
  77303. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77304. }
  77305. /**
  77306. * Define a task used by AssetsManager to load text content
  77307. */
  77308. export class TextFileAssetTask extends AbstractAssetTask {
  77309. /**
  77310. * Defines the name of the task
  77311. */
  77312. name: string;
  77313. /**
  77314. * Defines the location of the file to load
  77315. */
  77316. url: string;
  77317. /**
  77318. * Gets the loaded text string
  77319. */
  77320. text: string;
  77321. /**
  77322. * Callback called when the task is successful
  77323. */
  77324. onSuccess: (task: TextFileAssetTask) => void;
  77325. /**
  77326. * Callback called when the task is successful
  77327. */
  77328. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  77329. /**
  77330. * Creates a new TextFileAssetTask object
  77331. * @param name defines the name of the task
  77332. * @param url defines the location of the file to load
  77333. */
  77334. constructor(
  77335. /**
  77336. * Defines the name of the task
  77337. */
  77338. name: string,
  77339. /**
  77340. * Defines the location of the file to load
  77341. */
  77342. url: string);
  77343. /**
  77344. * Execute the current task
  77345. * @param scene defines the scene where you want your assets to be loaded
  77346. * @param onSuccess is a callback called when the task is successfully executed
  77347. * @param onError is a callback called if an error occurs
  77348. */
  77349. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77350. }
  77351. /**
  77352. * Define a task used by AssetsManager to load binary data
  77353. */
  77354. export class BinaryFileAssetTask extends AbstractAssetTask {
  77355. /**
  77356. * Defines the name of the task
  77357. */
  77358. name: string;
  77359. /**
  77360. * Defines the location of the file to load
  77361. */
  77362. url: string;
  77363. /**
  77364. * Gets the lodaded data (as an array buffer)
  77365. */
  77366. data: ArrayBuffer;
  77367. /**
  77368. * Callback called when the task is successful
  77369. */
  77370. onSuccess: (task: BinaryFileAssetTask) => void;
  77371. /**
  77372. * Callback called when the task is successful
  77373. */
  77374. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  77375. /**
  77376. * Creates a new BinaryFileAssetTask object
  77377. * @param name defines the name of the new task
  77378. * @param url defines the location of the file to load
  77379. */
  77380. constructor(
  77381. /**
  77382. * Defines the name of the task
  77383. */
  77384. name: string,
  77385. /**
  77386. * Defines the location of the file to load
  77387. */
  77388. url: string);
  77389. /**
  77390. * Execute the current task
  77391. * @param scene defines the scene where you want your assets to be loaded
  77392. * @param onSuccess is a callback called when the task is successfully executed
  77393. * @param onError is a callback called if an error occurs
  77394. */
  77395. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77396. }
  77397. /**
  77398. * Define a task used by AssetsManager to load images
  77399. */
  77400. export class ImageAssetTask extends AbstractAssetTask {
  77401. /**
  77402. * Defines the name of the task
  77403. */
  77404. name: string;
  77405. /**
  77406. * Defines the location of the image to load
  77407. */
  77408. url: string;
  77409. /**
  77410. * Gets the loaded images
  77411. */
  77412. image: HTMLImageElement;
  77413. /**
  77414. * Callback called when the task is successful
  77415. */
  77416. onSuccess: (task: ImageAssetTask) => void;
  77417. /**
  77418. * Callback called when the task is successful
  77419. */
  77420. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  77421. /**
  77422. * Creates a new ImageAssetTask
  77423. * @param name defines the name of the task
  77424. * @param url defines the location of the image to load
  77425. */
  77426. constructor(
  77427. /**
  77428. * Defines the name of the task
  77429. */
  77430. name: string,
  77431. /**
  77432. * Defines the location of the image to load
  77433. */
  77434. url: string);
  77435. /**
  77436. * Execute the current task
  77437. * @param scene defines the scene where you want your assets to be loaded
  77438. * @param onSuccess is a callback called when the task is successfully executed
  77439. * @param onError is a callback called if an error occurs
  77440. */
  77441. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77442. }
  77443. /**
  77444. * Defines the interface used by texture loading tasks
  77445. */
  77446. export interface ITextureAssetTask<TEX extends BaseTexture> {
  77447. /**
  77448. * Gets the loaded texture
  77449. */
  77450. texture: TEX;
  77451. }
  77452. /**
  77453. * Define a task used by AssetsManager to load 2D textures
  77454. */
  77455. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  77456. /**
  77457. * Defines the name of the task
  77458. */
  77459. name: string;
  77460. /**
  77461. * Defines the location of the file to load
  77462. */
  77463. url: string;
  77464. /**
  77465. * Defines if mipmap should not be generated (default is false)
  77466. */
  77467. noMipmap?: boolean | undefined;
  77468. /**
  77469. * Defines if texture must be inverted on Y axis (default is true)
  77470. */
  77471. invertY: boolean;
  77472. /**
  77473. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  77474. */
  77475. samplingMode: number;
  77476. /**
  77477. * Gets the loaded texture
  77478. */
  77479. texture: Texture;
  77480. /**
  77481. * Callback called when the task is successful
  77482. */
  77483. onSuccess: (task: TextureAssetTask) => void;
  77484. /**
  77485. * Callback called when the task is successful
  77486. */
  77487. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  77488. /**
  77489. * Creates a new TextureAssetTask object
  77490. * @param name defines the name of the task
  77491. * @param url defines the location of the file to load
  77492. * @param noMipmap defines if mipmap should not be generated (default is false)
  77493. * @param invertY defines if texture must be inverted on Y axis (default is true)
  77494. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  77495. */
  77496. constructor(
  77497. /**
  77498. * Defines the name of the task
  77499. */
  77500. name: string,
  77501. /**
  77502. * Defines the location of the file to load
  77503. */
  77504. url: string,
  77505. /**
  77506. * Defines if mipmap should not be generated (default is false)
  77507. */
  77508. noMipmap?: boolean | undefined,
  77509. /**
  77510. * Defines if texture must be inverted on Y axis (default is true)
  77511. */
  77512. invertY?: boolean,
  77513. /**
  77514. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  77515. */
  77516. samplingMode?: number);
  77517. /**
  77518. * Execute the current task
  77519. * @param scene defines the scene where you want your assets to be loaded
  77520. * @param onSuccess is a callback called when the task is successfully executed
  77521. * @param onError is a callback called if an error occurs
  77522. */
  77523. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77524. }
  77525. /**
  77526. * Define a task used by AssetsManager to load cube textures
  77527. */
  77528. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  77529. /**
  77530. * Defines the name of the task
  77531. */
  77532. name: string;
  77533. /**
  77534. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  77535. */
  77536. url: string;
  77537. /**
  77538. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  77539. */
  77540. extensions?: string[] | undefined;
  77541. /**
  77542. * Defines if mipmaps should not be generated (default is false)
  77543. */
  77544. noMipmap?: boolean | undefined;
  77545. /**
  77546. * Defines the explicit list of files (undefined by default)
  77547. */
  77548. files?: string[] | undefined;
  77549. /**
  77550. * Gets the loaded texture
  77551. */
  77552. texture: CubeTexture;
  77553. /**
  77554. * Callback called when the task is successful
  77555. */
  77556. onSuccess: (task: CubeTextureAssetTask) => void;
  77557. /**
  77558. * Callback called when the task is successful
  77559. */
  77560. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  77561. /**
  77562. * Creates a new CubeTextureAssetTask
  77563. * @param name defines the name of the task
  77564. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  77565. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  77566. * @param noMipmap defines if mipmaps should not be generated (default is false)
  77567. * @param files defines the explicit list of files (undefined by default)
  77568. */
  77569. constructor(
  77570. /**
  77571. * Defines the name of the task
  77572. */
  77573. name: string,
  77574. /**
  77575. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  77576. */
  77577. url: string,
  77578. /**
  77579. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  77580. */
  77581. extensions?: string[] | undefined,
  77582. /**
  77583. * Defines if mipmaps should not be generated (default is false)
  77584. */
  77585. noMipmap?: boolean | undefined,
  77586. /**
  77587. * Defines the explicit list of files (undefined by default)
  77588. */
  77589. files?: string[] | undefined);
  77590. /**
  77591. * Execute the current task
  77592. * @param scene defines the scene where you want your assets to be loaded
  77593. * @param onSuccess is a callback called when the task is successfully executed
  77594. * @param onError is a callback called if an error occurs
  77595. */
  77596. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77597. }
  77598. /**
  77599. * Define a task used by AssetsManager to load HDR cube textures
  77600. */
  77601. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  77602. /**
  77603. * Defines the name of the task
  77604. */
  77605. name: string;
  77606. /**
  77607. * Defines the location of the file to load
  77608. */
  77609. url: string;
  77610. /**
  77611. * Defines the desired size (the more it increases the longer the generation will be)
  77612. */
  77613. size: number;
  77614. /**
  77615. * Defines if mipmaps should not be generated (default is false)
  77616. */
  77617. noMipmap: boolean;
  77618. /**
  77619. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  77620. */
  77621. generateHarmonics: boolean;
  77622. /**
  77623. * 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)
  77624. */
  77625. gammaSpace: boolean;
  77626. /**
  77627. * Internal Use Only
  77628. */
  77629. reserved: boolean;
  77630. /**
  77631. * Gets the loaded texture
  77632. */
  77633. texture: HDRCubeTexture;
  77634. /**
  77635. * Callback called when the task is successful
  77636. */
  77637. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  77638. /**
  77639. * Callback called when the task is successful
  77640. */
  77641. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  77642. /**
  77643. * Creates a new HDRCubeTextureAssetTask object
  77644. * @param name defines the name of the task
  77645. * @param url defines the location of the file to load
  77646. * @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.
  77647. * @param noMipmap defines if mipmaps should not be generated (default is false)
  77648. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  77649. * @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)
  77650. * @param reserved Internal use only
  77651. */
  77652. constructor(
  77653. /**
  77654. * Defines the name of the task
  77655. */
  77656. name: string,
  77657. /**
  77658. * Defines the location of the file to load
  77659. */
  77660. url: string,
  77661. /**
  77662. * Defines the desired size (the more it increases the longer the generation will be)
  77663. */
  77664. size: number,
  77665. /**
  77666. * Defines if mipmaps should not be generated (default is false)
  77667. */
  77668. noMipmap?: boolean,
  77669. /**
  77670. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  77671. */
  77672. generateHarmonics?: boolean,
  77673. /**
  77674. * 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)
  77675. */
  77676. gammaSpace?: boolean,
  77677. /**
  77678. * Internal Use Only
  77679. */
  77680. reserved?: boolean);
  77681. /**
  77682. * Execute the current task
  77683. * @param scene defines the scene where you want your assets to be loaded
  77684. * @param onSuccess is a callback called when the task is successfully executed
  77685. * @param onError is a callback called if an error occurs
  77686. */
  77687. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77688. }
  77689. /**
  77690. * Define a task used by AssetsManager to load Equirectangular cube textures
  77691. */
  77692. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  77693. /**
  77694. * Defines the name of the task
  77695. */
  77696. name: string;
  77697. /**
  77698. * Defines the location of the file to load
  77699. */
  77700. url: string;
  77701. /**
  77702. * Defines the desired size (the more it increases the longer the generation will be)
  77703. */
  77704. size: number;
  77705. /**
  77706. * Defines if mipmaps should not be generated (default is false)
  77707. */
  77708. noMipmap: boolean;
  77709. /**
  77710. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  77711. * but the standard material would require them in Gamma space) (default is true)
  77712. */
  77713. gammaSpace: boolean;
  77714. /**
  77715. * Gets the loaded texture
  77716. */
  77717. texture: EquiRectangularCubeTexture;
  77718. /**
  77719. * Callback called when the task is successful
  77720. */
  77721. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  77722. /**
  77723. * Callback called when the task is successful
  77724. */
  77725. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  77726. /**
  77727. * Creates a new EquiRectangularCubeTextureAssetTask object
  77728. * @param name defines the name of the task
  77729. * @param url defines the location of the file to load
  77730. * @param size defines the desired size (the more it increases the longer the generation will be)
  77731. * If the size is omitted this implies you are using a preprocessed cubemap.
  77732. * @param noMipmap defines if mipmaps should not be generated (default is false)
  77733. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  77734. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  77735. * (default is true)
  77736. */
  77737. constructor(
  77738. /**
  77739. * Defines the name of the task
  77740. */
  77741. name: string,
  77742. /**
  77743. * Defines the location of the file to load
  77744. */
  77745. url: string,
  77746. /**
  77747. * Defines the desired size (the more it increases the longer the generation will be)
  77748. */
  77749. size: number,
  77750. /**
  77751. * Defines if mipmaps should not be generated (default is false)
  77752. */
  77753. noMipmap?: boolean,
  77754. /**
  77755. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  77756. * but the standard material would require them in Gamma space) (default is true)
  77757. */
  77758. gammaSpace?: boolean);
  77759. /**
  77760. * Execute the current task
  77761. * @param scene defines the scene where you want your assets to be loaded
  77762. * @param onSuccess is a callback called when the task is successfully executed
  77763. * @param onError is a callback called if an error occurs
  77764. */
  77765. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77766. }
  77767. /**
  77768. * This class can be used to easily import assets into a scene
  77769. * @see https://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  77770. */
  77771. export class AssetsManager {
  77772. private _scene;
  77773. private _isLoading;
  77774. protected _tasks: AbstractAssetTask[];
  77775. protected _waitingTasksCount: number;
  77776. protected _totalTasksCount: number;
  77777. /**
  77778. * Callback called when all tasks are processed
  77779. */
  77780. onFinish: (tasks: AbstractAssetTask[]) => void;
  77781. /**
  77782. * Callback called when a task is successful
  77783. */
  77784. onTaskSuccess: (task: AbstractAssetTask) => void;
  77785. /**
  77786. * Callback called when a task had an error
  77787. */
  77788. onTaskError: (task: AbstractAssetTask) => void;
  77789. /**
  77790. * Callback called when a task is done (whatever the result is)
  77791. */
  77792. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  77793. /**
  77794. * Observable called when all tasks are processed
  77795. */
  77796. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  77797. /**
  77798. * Observable called when a task had an error
  77799. */
  77800. onTaskErrorObservable: Observable<AbstractAssetTask>;
  77801. /**
  77802. * Observable called when all tasks were executed
  77803. */
  77804. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  77805. /**
  77806. * Observable called when a task is done (whatever the result is)
  77807. */
  77808. onProgressObservable: Observable<IAssetsProgressEvent>;
  77809. /**
  77810. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  77811. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  77812. */
  77813. useDefaultLoadingScreen: boolean;
  77814. /**
  77815. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  77816. * when all assets have been downloaded.
  77817. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  77818. */
  77819. autoHideLoadingUI: boolean;
  77820. /**
  77821. * Creates a new AssetsManager
  77822. * @param scene defines the scene to work on
  77823. */
  77824. constructor(scene: Scene);
  77825. /**
  77826. * Add a ContainerAssetTask to the list of active tasks
  77827. * @param taskName defines the name of the new task
  77828. * @param meshesNames defines the name of meshes to load
  77829. * @param rootUrl defines the root url to use to locate files
  77830. * @param sceneFilename defines the filename of the scene file
  77831. * @returns a new ContainerAssetTask object
  77832. */
  77833. addContainerTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): ContainerAssetTask;
  77834. /**
  77835. * Add a MeshAssetTask to the list of active tasks
  77836. * @param taskName defines the name of the new task
  77837. * @param meshesNames defines the name of meshes to load
  77838. * @param rootUrl defines the root url to use to locate files
  77839. * @param sceneFilename defines the filename of the scene file
  77840. * @returns a new MeshAssetTask object
  77841. */
  77842. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  77843. /**
  77844. * Add a TextFileAssetTask to the list of active tasks
  77845. * @param taskName defines the name of the new task
  77846. * @param url defines the url of the file to load
  77847. * @returns a new TextFileAssetTask object
  77848. */
  77849. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  77850. /**
  77851. * Add a BinaryFileAssetTask to the list of active tasks
  77852. * @param taskName defines the name of the new task
  77853. * @param url defines the url of the file to load
  77854. * @returns a new BinaryFileAssetTask object
  77855. */
  77856. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  77857. /**
  77858. * Add a ImageAssetTask to the list of active tasks
  77859. * @param taskName defines the name of the new task
  77860. * @param url defines the url of the file to load
  77861. * @returns a new ImageAssetTask object
  77862. */
  77863. addImageTask(taskName: string, url: string): ImageAssetTask;
  77864. /**
  77865. * Add a TextureAssetTask to the list of active tasks
  77866. * @param taskName defines the name of the new task
  77867. * @param url defines the url of the file to load
  77868. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  77869. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  77870. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  77871. * @returns a new TextureAssetTask object
  77872. */
  77873. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  77874. /**
  77875. * Add a CubeTextureAssetTask to the list of active tasks
  77876. * @param taskName defines the name of the new task
  77877. * @param url defines the url of the file to load
  77878. * @param extensions defines the extension to use to load the cube map (can be null)
  77879. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  77880. * @param files defines the list of files to load (can be null)
  77881. * @returns a new CubeTextureAssetTask object
  77882. */
  77883. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  77884. /**
  77885. *
  77886. * Add a HDRCubeTextureAssetTask to the list of active tasks
  77887. * @param taskName defines the name of the new task
  77888. * @param url defines the url of the file to load
  77889. * @param size defines the size you want for the cubemap (can be null)
  77890. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  77891. * @param generateHarmonics defines if you want to automatically generate (true by default)
  77892. * @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)
  77893. * @param reserved Internal use only
  77894. * @returns a new HDRCubeTextureAssetTask object
  77895. */
  77896. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  77897. /**
  77898. *
  77899. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  77900. * @param taskName defines the name of the new task
  77901. * @param url defines the url of the file to load
  77902. * @param size defines the size you want for the cubemap (can be null)
  77903. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  77904. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  77905. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  77906. * @returns a new EquiRectangularCubeTextureAssetTask object
  77907. */
  77908. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  77909. /**
  77910. * Remove a task from the assets manager.
  77911. * @param task the task to remove
  77912. */
  77913. removeTask(task: AbstractAssetTask): void;
  77914. private _decreaseWaitingTasksCount;
  77915. private _runTask;
  77916. /**
  77917. * Reset the AssetsManager and remove all tasks
  77918. * @return the current instance of the AssetsManager
  77919. */
  77920. reset(): AssetsManager;
  77921. /**
  77922. * Start the loading process
  77923. * @return the current instance of the AssetsManager
  77924. */
  77925. load(): AssetsManager;
  77926. /**
  77927. * Start the loading process as an async operation
  77928. * @return a promise returning the list of failed tasks
  77929. */
  77930. loadAsync(): Promise<void>;
  77931. }
  77932. }
  77933. declare module BABYLON {
  77934. /**
  77935. * Wrapper class for promise with external resolve and reject.
  77936. */
  77937. export class Deferred<T> {
  77938. /**
  77939. * The promise associated with this deferred object.
  77940. */
  77941. readonly promise: Promise<T>;
  77942. private _resolve;
  77943. private _reject;
  77944. /**
  77945. * The resolve method of the promise associated with this deferred object.
  77946. */
  77947. get resolve(): (value: T | PromiseLike<T>) => void;
  77948. /**
  77949. * The reject method of the promise associated with this deferred object.
  77950. */
  77951. get reject(): (reason?: any) => void;
  77952. /**
  77953. * Constructor for this deferred object.
  77954. */
  77955. constructor();
  77956. }
  77957. }
  77958. declare module BABYLON {
  77959. /**
  77960. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  77961. */
  77962. export class MeshExploder {
  77963. private _centerMesh;
  77964. private _meshes;
  77965. private _meshesOrigins;
  77966. private _toCenterVectors;
  77967. private _scaledDirection;
  77968. private _newPosition;
  77969. private _centerPosition;
  77970. /**
  77971. * Explodes meshes from a center mesh.
  77972. * @param meshes The meshes to explode.
  77973. * @param centerMesh The mesh to be center of explosion.
  77974. */
  77975. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  77976. private _setCenterMesh;
  77977. /**
  77978. * Get class name
  77979. * @returns "MeshExploder"
  77980. */
  77981. getClassName(): string;
  77982. /**
  77983. * "Exploded meshes"
  77984. * @returns Array of meshes with the centerMesh at index 0.
  77985. */
  77986. getMeshes(): Array<Mesh>;
  77987. /**
  77988. * Explodes meshes giving a specific direction
  77989. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  77990. */
  77991. explode(direction?: number): void;
  77992. }
  77993. }
  77994. declare module BABYLON {
  77995. /**
  77996. * Class used to help managing file picking and drag'n'drop
  77997. */
  77998. export class FilesInput {
  77999. /**
  78000. * List of files ready to be loaded
  78001. */
  78002. static get FilesToLoad(): {
  78003. [key: string]: File;
  78004. };
  78005. /**
  78006. * Callback called when a file is processed
  78007. */
  78008. onProcessFileCallback: (file: File, name: string, extension: string, setSceneFileToLoad: (sceneFile: File) => void) => boolean;
  78009. /**
  78010. * Function used when loading the scene file
  78011. */
  78012. loadAsync: (sceneFile: File, onProgress: Nullable<(event: ISceneLoaderProgressEvent) => void>) => Promise<Scene>;
  78013. private _engine;
  78014. private _currentScene;
  78015. private _sceneLoadedCallback;
  78016. private _progressCallback;
  78017. private _additionalRenderLoopLogicCallback;
  78018. private _textureLoadingCallback;
  78019. private _startingProcessingFilesCallback;
  78020. private _onReloadCallback;
  78021. private _errorCallback;
  78022. private _elementToMonitor;
  78023. private _sceneFileToLoad;
  78024. private _filesToLoad;
  78025. /**
  78026. * Creates a new FilesInput
  78027. * @param engine defines the rendering engine
  78028. * @param scene defines the hosting scene
  78029. * @param sceneLoadedCallback callback called when scene is loaded
  78030. * @param progressCallback callback called to track progress
  78031. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  78032. * @param textureLoadingCallback callback called when a texture is loading
  78033. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  78034. * @param onReloadCallback callback called when a reload is requested
  78035. * @param errorCallback callback call if an error occurs
  78036. */
  78037. 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>);
  78038. private _dragEnterHandler;
  78039. private _dragOverHandler;
  78040. private _dropHandler;
  78041. /**
  78042. * Calls this function to listen to drag'n'drop events on a specific DOM element
  78043. * @param elementToMonitor defines the DOM element to track
  78044. */
  78045. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  78046. /** Gets the current list of files to load */
  78047. get filesToLoad(): File[];
  78048. /**
  78049. * Release all associated resources
  78050. */
  78051. dispose(): void;
  78052. private renderFunction;
  78053. private drag;
  78054. private drop;
  78055. private _traverseFolder;
  78056. private _processFiles;
  78057. /**
  78058. * Load files from a drop event
  78059. * @param event defines the drop event to use as source
  78060. */
  78061. loadFiles(event: any): void;
  78062. private _processReload;
  78063. /**
  78064. * Reload the current scene from the loaded files
  78065. */
  78066. reload(): void;
  78067. }
  78068. }
  78069. declare module BABYLON {
  78070. /**
  78071. * Defines the root class used to create scene optimization to use with SceneOptimizer
  78072. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78073. */
  78074. export class SceneOptimization {
  78075. /**
  78076. * Defines the priority of this optimization (0 by default which means first in the list)
  78077. */
  78078. priority: number;
  78079. /**
  78080. * Gets a string describing the action executed by the current optimization
  78081. * @returns description string
  78082. */
  78083. getDescription(): string;
  78084. /**
  78085. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78086. * @param scene defines the current scene where to apply this optimization
  78087. * @param optimizer defines the current optimizer
  78088. * @returns true if everything that can be done was applied
  78089. */
  78090. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78091. /**
  78092. * Creates the SceneOptimization object
  78093. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  78094. * @param desc defines the description associated with the optimization
  78095. */
  78096. constructor(
  78097. /**
  78098. * Defines the priority of this optimization (0 by default which means first in the list)
  78099. */
  78100. priority?: number);
  78101. }
  78102. /**
  78103. * Defines an optimization used to reduce the size of render target textures
  78104. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78105. */
  78106. export class TextureOptimization extends SceneOptimization {
  78107. /**
  78108. * Defines the priority of this optimization (0 by default which means first in the list)
  78109. */
  78110. priority: number;
  78111. /**
  78112. * 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
  78113. */
  78114. maximumSize: number;
  78115. /**
  78116. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  78117. */
  78118. step: number;
  78119. /**
  78120. * Gets a string describing the action executed by the current optimization
  78121. * @returns description string
  78122. */
  78123. getDescription(): string;
  78124. /**
  78125. * Creates the TextureOptimization object
  78126. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  78127. * @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
  78128. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  78129. */
  78130. constructor(
  78131. /**
  78132. * Defines the priority of this optimization (0 by default which means first in the list)
  78133. */
  78134. priority?: number,
  78135. /**
  78136. * 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
  78137. */
  78138. maximumSize?: number,
  78139. /**
  78140. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  78141. */
  78142. step?: number);
  78143. /**
  78144. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78145. * @param scene defines the current scene where to apply this optimization
  78146. * @param optimizer defines the current optimizer
  78147. * @returns true if everything that can be done was applied
  78148. */
  78149. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78150. }
  78151. /**
  78152. * Defines an optimization used to increase or decrease the rendering resolution
  78153. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78154. */
  78155. export class HardwareScalingOptimization extends SceneOptimization {
  78156. /**
  78157. * Defines the priority of this optimization (0 by default which means first in the list)
  78158. */
  78159. priority: number;
  78160. /**
  78161. * Defines the maximum scale to use (2 by default)
  78162. */
  78163. maximumScale: number;
  78164. /**
  78165. * Defines the step to use between two passes (0.5 by default)
  78166. */
  78167. step: number;
  78168. private _currentScale;
  78169. private _directionOffset;
  78170. /**
  78171. * Gets a string describing the action executed by the current optimization
  78172. * @return description string
  78173. */
  78174. getDescription(): string;
  78175. /**
  78176. * Creates the HardwareScalingOptimization object
  78177. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  78178. * @param maximumScale defines the maximum scale to use (2 by default)
  78179. * @param step defines the step to use between two passes (0.5 by default)
  78180. */
  78181. constructor(
  78182. /**
  78183. * Defines the priority of this optimization (0 by default which means first in the list)
  78184. */
  78185. priority?: number,
  78186. /**
  78187. * Defines the maximum scale to use (2 by default)
  78188. */
  78189. maximumScale?: number,
  78190. /**
  78191. * Defines the step to use between two passes (0.5 by default)
  78192. */
  78193. step?: number);
  78194. /**
  78195. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78196. * @param scene defines the current scene where to apply this optimization
  78197. * @param optimizer defines the current optimizer
  78198. * @returns true if everything that can be done was applied
  78199. */
  78200. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78201. }
  78202. /**
  78203. * Defines an optimization used to remove shadows
  78204. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78205. */
  78206. export class ShadowsOptimization extends SceneOptimization {
  78207. /**
  78208. * Gets a string describing the action executed by the current optimization
  78209. * @return description string
  78210. */
  78211. getDescription(): string;
  78212. /**
  78213. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78214. * @param scene defines the current scene where to apply this optimization
  78215. * @param optimizer defines the current optimizer
  78216. * @returns true if everything that can be done was applied
  78217. */
  78218. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78219. }
  78220. /**
  78221. * Defines an optimization used to turn post-processes off
  78222. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78223. */
  78224. export class PostProcessesOptimization extends SceneOptimization {
  78225. /**
  78226. * Gets a string describing the action executed by the current optimization
  78227. * @return description string
  78228. */
  78229. getDescription(): string;
  78230. /**
  78231. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78232. * @param scene defines the current scene where to apply this optimization
  78233. * @param optimizer defines the current optimizer
  78234. * @returns true if everything that can be done was applied
  78235. */
  78236. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78237. }
  78238. /**
  78239. * Defines an optimization used to turn lens flares off
  78240. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78241. */
  78242. export class LensFlaresOptimization extends SceneOptimization {
  78243. /**
  78244. * Gets a string describing the action executed by the current optimization
  78245. * @return description string
  78246. */
  78247. getDescription(): string;
  78248. /**
  78249. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78250. * @param scene defines the current scene where to apply this optimization
  78251. * @param optimizer defines the current optimizer
  78252. * @returns true if everything that can be done was applied
  78253. */
  78254. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78255. }
  78256. /**
  78257. * Defines an optimization based on user defined callback.
  78258. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78259. */
  78260. export class CustomOptimization extends SceneOptimization {
  78261. /**
  78262. * Callback called to apply the custom optimization.
  78263. */
  78264. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  78265. /**
  78266. * Callback called to get custom description
  78267. */
  78268. onGetDescription: () => string;
  78269. /**
  78270. * Gets a string describing the action executed by the current optimization
  78271. * @returns description string
  78272. */
  78273. getDescription(): string;
  78274. /**
  78275. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78276. * @param scene defines the current scene where to apply this optimization
  78277. * @param optimizer defines the current optimizer
  78278. * @returns true if everything that can be done was applied
  78279. */
  78280. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78281. }
  78282. /**
  78283. * Defines an optimization used to turn particles off
  78284. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78285. */
  78286. export class ParticlesOptimization extends SceneOptimization {
  78287. /**
  78288. * Gets a string describing the action executed by the current optimization
  78289. * @return description string
  78290. */
  78291. getDescription(): string;
  78292. /**
  78293. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78294. * @param scene defines the current scene where to apply this optimization
  78295. * @param optimizer defines the current optimizer
  78296. * @returns true if everything that can be done was applied
  78297. */
  78298. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78299. }
  78300. /**
  78301. * Defines an optimization used to turn render targets off
  78302. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78303. */
  78304. export class RenderTargetsOptimization extends SceneOptimization {
  78305. /**
  78306. * Gets a string describing the action executed by the current optimization
  78307. * @return description string
  78308. */
  78309. getDescription(): string;
  78310. /**
  78311. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78312. * @param scene defines the current scene where to apply this optimization
  78313. * @param optimizer defines the current optimizer
  78314. * @returns true if everything that can be done was applied
  78315. */
  78316. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78317. }
  78318. /**
  78319. * Defines an optimization used to merge meshes with compatible materials
  78320. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78321. */
  78322. export class MergeMeshesOptimization extends SceneOptimization {
  78323. private static _UpdateSelectionTree;
  78324. /**
  78325. * Gets or sets a boolean which defines if optimization octree has to be updated
  78326. */
  78327. static get UpdateSelectionTree(): boolean;
  78328. /**
  78329. * Gets or sets a boolean which defines if optimization octree has to be updated
  78330. */
  78331. static set UpdateSelectionTree(value: boolean);
  78332. /**
  78333. * Gets a string describing the action executed by the current optimization
  78334. * @return description string
  78335. */
  78336. getDescription(): string;
  78337. private _canBeMerged;
  78338. /**
  78339. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78340. * @param scene defines the current scene where to apply this optimization
  78341. * @param optimizer defines the current optimizer
  78342. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  78343. * @returns true if everything that can be done was applied
  78344. */
  78345. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  78346. }
  78347. /**
  78348. * Defines a list of options used by SceneOptimizer
  78349. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78350. */
  78351. export class SceneOptimizerOptions {
  78352. /**
  78353. * Defines the target frame rate to reach (60 by default)
  78354. */
  78355. targetFrameRate: number;
  78356. /**
  78357. * Defines the interval between two checkes (2000ms by default)
  78358. */
  78359. trackerDuration: number;
  78360. /**
  78361. * Gets the list of optimizations to apply
  78362. */
  78363. optimizations: SceneOptimization[];
  78364. /**
  78365. * Creates a new list of options used by SceneOptimizer
  78366. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  78367. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  78368. */
  78369. constructor(
  78370. /**
  78371. * Defines the target frame rate to reach (60 by default)
  78372. */
  78373. targetFrameRate?: number,
  78374. /**
  78375. * Defines the interval between two checkes (2000ms by default)
  78376. */
  78377. trackerDuration?: number);
  78378. /**
  78379. * Add a new optimization
  78380. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  78381. * @returns the current SceneOptimizerOptions
  78382. */
  78383. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  78384. /**
  78385. * Add a new custom optimization
  78386. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  78387. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  78388. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  78389. * @returns the current SceneOptimizerOptions
  78390. */
  78391. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  78392. /**
  78393. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  78394. * @param targetFrameRate defines the target frame rate (60 by default)
  78395. * @returns a SceneOptimizerOptions object
  78396. */
  78397. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  78398. /**
  78399. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  78400. * @param targetFrameRate defines the target frame rate (60 by default)
  78401. * @returns a SceneOptimizerOptions object
  78402. */
  78403. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  78404. /**
  78405. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  78406. * @param targetFrameRate defines the target frame rate (60 by default)
  78407. * @returns a SceneOptimizerOptions object
  78408. */
  78409. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  78410. }
  78411. /**
  78412. * Class used to run optimizations in order to reach a target frame rate
  78413. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78414. */
  78415. export class SceneOptimizer implements IDisposable {
  78416. private _isRunning;
  78417. private _options;
  78418. private _scene;
  78419. private _currentPriorityLevel;
  78420. private _targetFrameRate;
  78421. private _trackerDuration;
  78422. private _currentFrameRate;
  78423. private _sceneDisposeObserver;
  78424. private _improvementMode;
  78425. /**
  78426. * Defines an observable called when the optimizer reaches the target frame rate
  78427. */
  78428. onSuccessObservable: Observable<SceneOptimizer>;
  78429. /**
  78430. * Defines an observable called when the optimizer enables an optimization
  78431. */
  78432. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  78433. /**
  78434. * Defines an observable called when the optimizer is not able to reach the target frame rate
  78435. */
  78436. onFailureObservable: Observable<SceneOptimizer>;
  78437. /**
  78438. * Gets a boolean indicating if the optimizer is in improvement mode
  78439. */
  78440. get isInImprovementMode(): boolean;
  78441. /**
  78442. * Gets the current priority level (0 at start)
  78443. */
  78444. get currentPriorityLevel(): number;
  78445. /**
  78446. * Gets the current frame rate checked by the SceneOptimizer
  78447. */
  78448. get currentFrameRate(): number;
  78449. /**
  78450. * Gets or sets the current target frame rate (60 by default)
  78451. */
  78452. get targetFrameRate(): number;
  78453. /**
  78454. * Gets or sets the current target frame rate (60 by default)
  78455. */
  78456. set targetFrameRate(value: number);
  78457. /**
  78458. * Gets or sets the current interval between two checks (every 2000ms by default)
  78459. */
  78460. get trackerDuration(): number;
  78461. /**
  78462. * Gets or sets the current interval between two checks (every 2000ms by default)
  78463. */
  78464. set trackerDuration(value: number);
  78465. /**
  78466. * Gets the list of active optimizations
  78467. */
  78468. get optimizations(): SceneOptimization[];
  78469. /**
  78470. * Creates a new SceneOptimizer
  78471. * @param scene defines the scene to work on
  78472. * @param options defines the options to use with the SceneOptimizer
  78473. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  78474. * @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)
  78475. */
  78476. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  78477. /**
  78478. * Stops the current optimizer
  78479. */
  78480. stop(): void;
  78481. /**
  78482. * Reset the optimizer to initial step (current priority level = 0)
  78483. */
  78484. reset(): void;
  78485. /**
  78486. * Start the optimizer. By default it will try to reach a specific framerate
  78487. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  78488. */
  78489. start(): void;
  78490. private _checkCurrentState;
  78491. /**
  78492. * Release all resources
  78493. */
  78494. dispose(): void;
  78495. /**
  78496. * Helper function to create a SceneOptimizer with one single line of code
  78497. * @param scene defines the scene to work on
  78498. * @param options defines the options to use with the SceneOptimizer
  78499. * @param onSuccess defines a callback to call on success
  78500. * @param onFailure defines a callback to call on failure
  78501. * @returns the new SceneOptimizer object
  78502. */
  78503. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  78504. }
  78505. }
  78506. declare module BABYLON {
  78507. /**
  78508. * Class used to serialize a scene into a string
  78509. */
  78510. export class SceneSerializer {
  78511. /**
  78512. * Clear cache used by a previous serialization
  78513. */
  78514. static ClearCache(): void;
  78515. /**
  78516. * Serialize a scene into a JSON compatible object
  78517. * Note that if the current engine does not support synchronous texture reading (like WebGPU), you should use SerializeAsync instead
  78518. * as else you may not retrieve the proper base64 encoded texture data (when using the Texture.ForceSerializeBuffers flag)
  78519. * @param scene defines the scene to serialize
  78520. * @returns a JSON compatible object
  78521. */
  78522. static Serialize(scene: Scene): any;
  78523. private static _Serialize;
  78524. /**
  78525. * Serialize a scene into a JSON compatible object
  78526. * @param scene defines the scene to serialize
  78527. * @returns a JSON promise compatible object
  78528. */
  78529. static SerializeAsync(scene: Scene): Promise<any>;
  78530. private static _CollectPromises;
  78531. /**
  78532. * Serialize a mesh into a JSON compatible object
  78533. * @param toSerialize defines the mesh to serialize
  78534. * @param withParents defines if parents must be serialized as well
  78535. * @param withChildren defines if children must be serialized as well
  78536. * @returns a JSON compatible object
  78537. */
  78538. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  78539. }
  78540. }
  78541. declare module BABYLON {
  78542. /**
  78543. * This represents the different options available for the video capture.
  78544. */
  78545. export interface VideoRecorderOptions {
  78546. /** Defines the mime type of the video. */
  78547. mimeType: string;
  78548. /** Defines the FPS the video should be recorded at. */
  78549. fps: number;
  78550. /** Defines the chunk size for the recording data. */
  78551. recordChunckSize: number;
  78552. /** The audio tracks to attach to the recording. */
  78553. audioTracks?: MediaStreamTrack[];
  78554. }
  78555. /**
  78556. * This can help with recording videos from BabylonJS.
  78557. * This is based on the available WebRTC functionalities of the browser.
  78558. *
  78559. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_video
  78560. */
  78561. export class VideoRecorder {
  78562. private static readonly _defaultOptions;
  78563. /**
  78564. * Returns whether or not the VideoRecorder is available in your browser.
  78565. * @param engine Defines the Babylon Engine.
  78566. * @returns true if supported otherwise false.
  78567. */
  78568. static IsSupported(engine: Engine): boolean;
  78569. private readonly _options;
  78570. private _canvas;
  78571. private _mediaRecorder;
  78572. private _recordedChunks;
  78573. private _fileName;
  78574. private _resolve;
  78575. private _reject;
  78576. /**
  78577. * True when a recording is already in progress.
  78578. */
  78579. get isRecording(): boolean;
  78580. /**
  78581. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  78582. * @param engine Defines the BabylonJS Engine you wish to record.
  78583. * @param options Defines options that can be used to customize the capture.
  78584. */
  78585. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  78586. /**
  78587. * Stops the current recording before the default capture timeout passed in the startRecording function.
  78588. */
  78589. stopRecording(): void;
  78590. /**
  78591. * Starts recording the canvas for a max duration specified in parameters.
  78592. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  78593. * If null no automatic download will start and you can rely on the promise to get the data back.
  78594. * @param maxDuration Defines the maximum recording time in seconds.
  78595. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  78596. * @return A promise callback at the end of the recording with the video data in Blob.
  78597. */
  78598. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  78599. /**
  78600. * Releases internal resources used during the recording.
  78601. */
  78602. dispose(): void;
  78603. private _handleDataAvailable;
  78604. private _handleError;
  78605. private _handleStop;
  78606. }
  78607. }
  78608. declare module BABYLON {
  78609. /**
  78610. * Class containing a set of static utilities functions for screenshots
  78611. */
  78612. export class ScreenshotTools {
  78613. /**
  78614. * Captures a screenshot of the current rendering
  78615. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  78616. * @param engine defines the rendering engine
  78617. * @param camera defines the source camera
  78618. * @param size This parameter can be set to a single number or to an object with the
  78619. * following (optional) properties: precision, width, height. If a single number is passed,
  78620. * it will be used for both width and height. If an object is passed, the screenshot size
  78621. * will be derived from the parameters. The precision property is a multiplier allowing
  78622. * rendering at a higher or lower resolution
  78623. * @param successCallback defines the callback receives a single parameter which contains the
  78624. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  78625. * src parameter of an <img> to display it
  78626. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  78627. * Check your browser for supported MIME types
  78628. * @param forceDownload force the system to download the image even if a successCallback is provided
  78629. */
  78630. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, forceDownload?: boolean): void;
  78631. /**
  78632. * Captures a screenshot of the current rendering
  78633. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  78634. * @param engine defines the rendering engine
  78635. * @param camera defines the source camera
  78636. * @param size This parameter can be set to a single number or to an object with the
  78637. * following (optional) properties: precision, width, height. If a single number is passed,
  78638. * it will be used for both width and height. If an object is passed, the screenshot size
  78639. * will be derived from the parameters. The precision property is a multiplier allowing
  78640. * rendering at a higher or lower resolution
  78641. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  78642. * Check your browser for supported MIME types
  78643. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  78644. * to the src parameter of an <img> to display it
  78645. */
  78646. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  78647. /**
  78648. * Captures a screenshot of the current rendering for a specific size. This will render the entire canvas but will generate a blink (due to canvas resize)
  78649. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  78650. * @param engine defines the rendering engine
  78651. * @param camera defines the source camera
  78652. * @param width defines the expected width
  78653. * @param height defines the expected height
  78654. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  78655. * Check your browser for supported MIME types
  78656. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  78657. * to the src parameter of an <img> to display it
  78658. */
  78659. static CreateScreenshotWithResizeAsync(engine: Engine, camera: Camera, width: number, height: number, mimeType?: string): Promise<void>;
  78660. /**
  78661. * Generates an image screenshot from the specified camera.
  78662. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  78663. * @param engine The engine to use for rendering
  78664. * @param camera The camera to use for rendering
  78665. * @param size This parameter can be set to a single number or to an object with the
  78666. * following (optional) properties: precision, width, height. If a single number is passed,
  78667. * it will be used for both width and height. If an object is passed, the screenshot size
  78668. * will be derived from the parameters. The precision property is a multiplier allowing
  78669. * rendering at a higher or lower resolution
  78670. * @param successCallback The callback receives a single parameter which contains the
  78671. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  78672. * src parameter of an <img> to display it
  78673. * @param mimeType The MIME type of the screenshot image (default: image/png).
  78674. * Check your browser for supported MIME types
  78675. * @param samples Texture samples (default: 1)
  78676. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  78677. * @param fileName A name for for the downloaded file.
  78678. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  78679. * @param enableStencilBuffer Whether the stencil buffer should be enabled or not (default: false)
  78680. */
  78681. 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;
  78682. /**
  78683. * Generates an image screenshot from the specified camera.
  78684. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  78685. * @param engine The engine to use for rendering
  78686. * @param camera The camera to use for rendering
  78687. * @param size This parameter can be set to a single number or to an object with the
  78688. * following (optional) properties: precision, width, height. If a single number is passed,
  78689. * it will be used for both width and height. If an object is passed, the screenshot size
  78690. * will be derived from the parameters. The precision property is a multiplier allowing
  78691. * rendering at a higher or lower resolution
  78692. * @param mimeType The MIME type of the screenshot image (default: image/png).
  78693. * Check your browser for supported MIME types
  78694. * @param samples Texture samples (default: 1)
  78695. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  78696. * @param fileName A name for for the downloaded file.
  78697. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  78698. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  78699. * to the src parameter of an <img> to display it
  78700. */
  78701. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  78702. /**
  78703. * Gets height and width for screenshot size
  78704. * @private
  78705. */
  78706. private static _getScreenshotSize;
  78707. }
  78708. }
  78709. declare module BABYLON {
  78710. /**
  78711. * Interface for a data buffer
  78712. */
  78713. export interface IDataBuffer {
  78714. /**
  78715. * Reads bytes from the data buffer.
  78716. * @param byteOffset The byte offset to read
  78717. * @param byteLength The byte length to read
  78718. * @returns A promise that resolves when the bytes are read
  78719. */
  78720. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  78721. /**
  78722. * The byte length of the buffer.
  78723. */
  78724. readonly byteLength: number;
  78725. }
  78726. /**
  78727. * Utility class for reading from a data buffer
  78728. */
  78729. export class DataReader {
  78730. /**
  78731. * The data buffer associated with this data reader.
  78732. */
  78733. readonly buffer: IDataBuffer;
  78734. /**
  78735. * The current byte offset from the beginning of the data buffer.
  78736. */
  78737. byteOffset: number;
  78738. private _dataView;
  78739. private _dataByteOffset;
  78740. /**
  78741. * Constructor
  78742. * @param buffer The buffer to read
  78743. */
  78744. constructor(buffer: IDataBuffer);
  78745. /**
  78746. * Loads the given byte length.
  78747. * @param byteLength The byte length to load
  78748. * @returns A promise that resolves when the load is complete
  78749. */
  78750. loadAsync(byteLength: number): Promise<void>;
  78751. /**
  78752. * Read a unsigned 32-bit integer from the currently loaded data range.
  78753. * @returns The 32-bit integer read
  78754. */
  78755. readUint32(): number;
  78756. /**
  78757. * Read a byte array from the currently loaded data range.
  78758. * @param byteLength The byte length to read
  78759. * @returns The byte array read
  78760. */
  78761. readUint8Array(byteLength: number): Uint8Array;
  78762. /**
  78763. * Read a string from the currently loaded data range.
  78764. * @param byteLength The byte length to read
  78765. * @returns The string read
  78766. */
  78767. readString(byteLength: number): string;
  78768. /**
  78769. * Skips the given byte length the currently loaded data range.
  78770. * @param byteLength The byte length to skip
  78771. */
  78772. skipBytes(byteLength: number): void;
  78773. }
  78774. }
  78775. declare module BABYLON {
  78776. /**
  78777. * Class for storing data to local storage if available or in-memory storage otherwise
  78778. */
  78779. export class DataStorage {
  78780. private static _Storage;
  78781. private static _GetStorage;
  78782. /**
  78783. * Reads a string from the data storage
  78784. * @param key The key to read
  78785. * @param defaultValue The value if the key doesn't exist
  78786. * @returns The string value
  78787. */
  78788. static ReadString(key: string, defaultValue: string): string;
  78789. /**
  78790. * Writes a string to the data storage
  78791. * @param key The key to write
  78792. * @param value The value to write
  78793. */
  78794. static WriteString(key: string, value: string): void;
  78795. /**
  78796. * Reads a boolean from the data storage
  78797. * @param key The key to read
  78798. * @param defaultValue The value if the key doesn't exist
  78799. * @returns The boolean value
  78800. */
  78801. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  78802. /**
  78803. * Writes a boolean to the data storage
  78804. * @param key The key to write
  78805. * @param value The value to write
  78806. */
  78807. static WriteBoolean(key: string, value: boolean): void;
  78808. /**
  78809. * Reads a number from the data storage
  78810. * @param key The key to read
  78811. * @param defaultValue The value if the key doesn't exist
  78812. * @returns The number value
  78813. */
  78814. static ReadNumber(key: string, defaultValue: number): number;
  78815. /**
  78816. * Writes a number to the data storage
  78817. * @param key The key to write
  78818. * @param value The value to write
  78819. */
  78820. static WriteNumber(key: string, value: number): void;
  78821. }
  78822. }
  78823. declare module BABYLON {
  78824. /**
  78825. * Class used to record delta files between 2 scene states
  78826. */
  78827. export class SceneRecorder {
  78828. private _trackedScene;
  78829. private _savedJSON;
  78830. /**
  78831. * Track a given scene. This means the current scene state will be considered the original state
  78832. * @param scene defines the scene to track
  78833. */
  78834. track(scene: Scene): void;
  78835. /**
  78836. * Get the delta between current state and original state
  78837. * @returns a any containing the delta
  78838. */
  78839. getDelta(): any;
  78840. private _compareArray;
  78841. private _compareObjects;
  78842. private _compareCollections;
  78843. private static GetShadowGeneratorById;
  78844. /**
  78845. * Apply a given delta to a given scene
  78846. * @param deltaJSON defines the JSON containing the delta
  78847. * @param scene defines the scene to apply the delta to
  78848. */
  78849. static ApplyDelta(deltaJSON: any | string, scene: Scene): void;
  78850. private static _ApplyPropertiesToEntity;
  78851. private static _ApplyDeltaForEntity;
  78852. }
  78853. }
  78854. declare module BABYLON {
  78855. /**
  78856. * A 3D trajectory consisting of an order list of vectors describing a
  78857. * path of motion through 3D space.
  78858. */
  78859. export class Trajectory {
  78860. private _points;
  78861. private readonly _segmentLength;
  78862. /**
  78863. * Serialize to JSON.
  78864. * @returns serialized JSON string
  78865. */
  78866. serialize(): string;
  78867. /**
  78868. * Deserialize from JSON.
  78869. * @param json serialized JSON string
  78870. * @returns deserialized Trajectory
  78871. */
  78872. static Deserialize(json: string): Trajectory;
  78873. /**
  78874. * Create a new empty Trajectory.
  78875. * @param segmentLength radius of discretization for Trajectory points
  78876. */
  78877. constructor(segmentLength?: number);
  78878. /**
  78879. * Get the length of the Trajectory.
  78880. * @returns length of the Trajectory
  78881. */
  78882. getLength(): number;
  78883. /**
  78884. * Append a new point to the Trajectory.
  78885. * NOTE: This implementation has many allocations.
  78886. * @param point point to append to the Trajectory
  78887. */
  78888. add(point: DeepImmutable<Vector3>): void;
  78889. /**
  78890. * Create a new Trajectory with a segment length chosen to make it
  78891. * probable that the new Trajectory will have a specified number of
  78892. * segments. This operation is imprecise.
  78893. * @param targetResolution number of segments desired
  78894. * @returns new Trajectory with approximately the requested number of segments
  78895. */
  78896. resampleAtTargetResolution(targetResolution: number): Trajectory;
  78897. /**
  78898. * Convert Trajectory segments into tokenized representation. This
  78899. * representation is an array of numbers where each nth number is the
  78900. * index of the token which is most similar to the nth segment of the
  78901. * Trajectory.
  78902. * @param tokens list of vectors which serve as discrete tokens
  78903. * @returns list of indices of most similar token per segment
  78904. */
  78905. tokenize(tokens: DeepImmutable<Vector3[]>): number[];
  78906. private static _forwardDir;
  78907. private static _inverseFromVec;
  78908. private static _upDir;
  78909. private static _fromToVec;
  78910. private static _lookMatrix;
  78911. /**
  78912. * Transform the rotation (i.e., direction) of a segment to isolate
  78913. * the relative transformation represented by the segment. This operation
  78914. * may or may not succeed due to singularities in the equations that define
  78915. * motion relativity in this context.
  78916. * @param priorVec the origin of the prior segment
  78917. * @param fromVec the origin of the current segment
  78918. * @param toVec the destination of the current segment
  78919. * @param result reference to output variable
  78920. * @returns whether or not transformation was successful
  78921. */
  78922. private static _transformSegmentDirToRef;
  78923. private static _bestMatch;
  78924. private static _score;
  78925. private static _bestScore;
  78926. /**
  78927. * Determine which token vector is most similar to the
  78928. * segment vector.
  78929. * @param segment segment vector
  78930. * @param tokens token vector list
  78931. * @returns index of the most similar token to the segment
  78932. */
  78933. private static _tokenizeSegment;
  78934. }
  78935. /**
  78936. * Class representing a set of known, named trajectories to which Trajectories can be
  78937. * added and using which Trajectories can be recognized.
  78938. */
  78939. export class TrajectoryClassifier {
  78940. private _maximumAllowableMatchCost;
  78941. private _vector3Alphabet;
  78942. private _levenshteinAlphabet;
  78943. private _nameToDescribedTrajectory;
  78944. /**
  78945. * Serialize to JSON.
  78946. * @returns JSON serialization
  78947. */
  78948. serialize(): string;
  78949. /**
  78950. * Deserialize from JSON.
  78951. * @param json JSON serialization
  78952. * @returns deserialized TrajectorySet
  78953. */
  78954. static Deserialize(json: string): TrajectoryClassifier;
  78955. /**
  78956. * Initialize a new empty TrajectorySet with auto-generated Alphabets.
  78957. * VERY naive, need to be generating these things from known
  78958. * sets. Better version later, probably eliminating this one.
  78959. * @returns auto-generated TrajectorySet
  78960. */
  78961. static Generate(): TrajectoryClassifier;
  78962. private constructor();
  78963. /**
  78964. * Add a new Trajectory to the set with a given name.
  78965. * @param trajectory new Trajectory to be added
  78966. * @param classification name to which to add the Trajectory
  78967. */
  78968. addTrajectoryToClassification(trajectory: Trajectory, classification: string): void;
  78969. /**
  78970. * Remove a known named trajectory and all Trajectories associated with it.
  78971. * @param classification name to remove
  78972. * @returns whether anything was removed
  78973. */
  78974. deleteClassification(classification: string): boolean;
  78975. /**
  78976. * Attempt to recognize a Trajectory from among all the classifications
  78977. * already known to the classifier.
  78978. * @param trajectory Trajectory to be recognized
  78979. * @returns classification of Trajectory if recognized, null otherwise
  78980. */
  78981. classifyTrajectory(trajectory: Trajectory): Nullable<string>;
  78982. }
  78983. }
  78984. declare module BABYLON {
  78985. /**
  78986. * An interface for all Hit test features
  78987. */
  78988. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  78989. /**
  78990. * Triggered when new babylon (transformed) hit test results are available
  78991. */
  78992. onHitTestResultObservable: Observable<T[]>;
  78993. }
  78994. /**
  78995. * Options used for hit testing
  78996. */
  78997. export interface IWebXRLegacyHitTestOptions {
  78998. /**
  78999. * Only test when user interacted with the scene. Default - hit test every frame
  79000. */
  79001. testOnPointerDownOnly?: boolean;
  79002. /**
  79003. * The node to use to transform the local results to world coordinates
  79004. */
  79005. worldParentNode?: TransformNode;
  79006. }
  79007. /**
  79008. * Interface defining the babylon result of raycasting/hit-test
  79009. */
  79010. export interface IWebXRLegacyHitResult {
  79011. /**
  79012. * Transformation matrix that can be applied to a node that will put it in the hit point location
  79013. */
  79014. transformationMatrix: Matrix;
  79015. /**
  79016. * The native hit test result
  79017. */
  79018. xrHitResult: XRHitResult | XRHitTestResult;
  79019. }
  79020. /**
  79021. * The currently-working hit-test module.
  79022. * Hit test (or Ray-casting) is used to interact with the real world.
  79023. * For further information read here - https://github.com/immersive-web/hit-test
  79024. */
  79025. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  79026. /**
  79027. * options to use when constructing this feature
  79028. */
  79029. readonly options: IWebXRLegacyHitTestOptions;
  79030. private _direction;
  79031. private _mat;
  79032. private _onSelectEnabled;
  79033. private _origin;
  79034. /**
  79035. * The module's name
  79036. */
  79037. static readonly Name: string;
  79038. /**
  79039. * The (Babylon) version of this module.
  79040. * This is an integer representing the implementation version.
  79041. * This number does not correspond to the WebXR specs version
  79042. */
  79043. static readonly Version: number;
  79044. /**
  79045. * Populated with the last native XR Hit Results
  79046. */
  79047. lastNativeXRHitResults: XRHitResult[];
  79048. /**
  79049. * Triggered when new babylon (transformed) hit test results are available
  79050. */
  79051. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  79052. /**
  79053. * Creates a new instance of the (legacy version) hit test feature
  79054. * @param _xrSessionManager an instance of WebXRSessionManager
  79055. * @param options options to use when constructing this feature
  79056. */
  79057. constructor(_xrSessionManager: WebXRSessionManager,
  79058. /**
  79059. * options to use when constructing this feature
  79060. */
  79061. options?: IWebXRLegacyHitTestOptions);
  79062. /**
  79063. * execute a hit test with an XR Ray
  79064. *
  79065. * @param xrSession a native xrSession that will execute this hit test
  79066. * @param xrRay the ray (position and direction) to use for ray-casting
  79067. * @param referenceSpace native XR reference space to use for the hit-test
  79068. * @param filter filter function that will filter the results
  79069. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  79070. */
  79071. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  79072. /**
  79073. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  79074. * @param event the (select) event to use to select with
  79075. * @param referenceSpace the reference space to use for this hit test
  79076. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  79077. */
  79078. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  79079. /**
  79080. * attach this feature
  79081. * Will usually be called by the features manager
  79082. *
  79083. * @returns true if successful.
  79084. */
  79085. attach(): boolean;
  79086. /**
  79087. * detach this feature.
  79088. * Will usually be called by the features manager
  79089. *
  79090. * @returns true if successful.
  79091. */
  79092. detach(): boolean;
  79093. /**
  79094. * Dispose this feature and all of the resources attached
  79095. */
  79096. dispose(): void;
  79097. protected _onXRFrame(frame: XRFrame): void;
  79098. private _onHitTestResults;
  79099. private _onSelect;
  79100. }
  79101. }
  79102. declare module BABYLON {
  79103. /**
  79104. * Options used for hit testing (version 2)
  79105. */
  79106. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  79107. /**
  79108. * Do not create a permanent hit test. Will usually be used when only
  79109. * transient inputs are needed.
  79110. */
  79111. disablePermanentHitTest?: boolean;
  79112. /**
  79113. * Enable transient (for example touch-based) hit test inspections
  79114. */
  79115. enableTransientHitTest?: boolean;
  79116. /**
  79117. * Offset ray for the permanent hit test
  79118. */
  79119. offsetRay?: Vector3;
  79120. /**
  79121. * Offset ray for the transient hit test
  79122. */
  79123. transientOffsetRay?: Vector3;
  79124. /**
  79125. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  79126. */
  79127. useReferenceSpace?: boolean;
  79128. /**
  79129. * Override the default entity type(s) of the hit-test result
  79130. */
  79131. entityTypes?: XRHitTestTrackableType[];
  79132. }
  79133. /**
  79134. * Interface defining the babylon result of hit-test
  79135. */
  79136. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  79137. /**
  79138. * The input source that generated this hit test (if transient)
  79139. */
  79140. inputSource?: XRInputSource;
  79141. /**
  79142. * Is this a transient hit test
  79143. */
  79144. isTransient?: boolean;
  79145. /**
  79146. * Position of the hit test result
  79147. */
  79148. position: Vector3;
  79149. /**
  79150. * Rotation of the hit test result
  79151. */
  79152. rotationQuaternion: Quaternion;
  79153. /**
  79154. * The native hit test result
  79155. */
  79156. xrHitResult: XRHitTestResult;
  79157. }
  79158. /**
  79159. * The currently-working hit-test module.
  79160. * Hit test (or Ray-casting) is used to interact with the real world.
  79161. * For further information read here - https://github.com/immersive-web/hit-test
  79162. *
  79163. * Tested on chrome (mobile) 80.
  79164. */
  79165. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  79166. /**
  79167. * options to use when constructing this feature
  79168. */
  79169. readonly options: IWebXRHitTestOptions;
  79170. private _tmpMat;
  79171. private _tmpPos;
  79172. private _tmpQuat;
  79173. private _transientXrHitTestSource;
  79174. private _xrHitTestSource;
  79175. private initHitTestSource;
  79176. /**
  79177. * The module's name
  79178. */
  79179. static readonly Name: string;
  79180. /**
  79181. * The (Babylon) version of this module.
  79182. * This is an integer representing the implementation version.
  79183. * This number does not correspond to the WebXR specs version
  79184. */
  79185. static readonly Version: number;
  79186. /**
  79187. * When set to true, each hit test will have its own position/rotation objects
  79188. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  79189. * the developers will clone them or copy them as they see fit.
  79190. */
  79191. autoCloneTransformation: boolean;
  79192. /**
  79193. * Triggered when new babylon (transformed) hit test results are available
  79194. * Note - this will be called when results come back from the device. It can be an empty array!!
  79195. */
  79196. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  79197. /**
  79198. * Use this to temporarily pause hit test checks.
  79199. */
  79200. paused: boolean;
  79201. /**
  79202. * Creates a new instance of the hit test feature
  79203. * @param _xrSessionManager an instance of WebXRSessionManager
  79204. * @param options options to use when constructing this feature
  79205. */
  79206. constructor(_xrSessionManager: WebXRSessionManager,
  79207. /**
  79208. * options to use when constructing this feature
  79209. */
  79210. options?: IWebXRHitTestOptions);
  79211. /**
  79212. * attach this feature
  79213. * Will usually be called by the features manager
  79214. *
  79215. * @returns true if successful.
  79216. */
  79217. attach(): boolean;
  79218. /**
  79219. * detach this feature.
  79220. * Will usually be called by the features manager
  79221. *
  79222. * @returns true if successful.
  79223. */
  79224. detach(): boolean;
  79225. /**
  79226. * Dispose this feature and all of the resources attached
  79227. */
  79228. dispose(): void;
  79229. protected _onXRFrame(frame: XRFrame): void;
  79230. private _processWebXRHitTestResult;
  79231. }
  79232. }
  79233. declare module BABYLON {
  79234. /**
  79235. * Configuration options of the anchor system
  79236. */
  79237. export interface IWebXRAnchorSystemOptions {
  79238. /**
  79239. * a node that will be used to convert local to world coordinates
  79240. */
  79241. worldParentNode?: TransformNode;
  79242. /**
  79243. * If set to true a reference of the created anchors will be kept until the next session starts
  79244. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  79245. */
  79246. doNotRemoveAnchorsOnSessionEnded?: boolean;
  79247. }
  79248. /**
  79249. * A babylon container for an XR Anchor
  79250. */
  79251. export interface IWebXRAnchor {
  79252. /**
  79253. * A babylon-assigned ID for this anchor
  79254. */
  79255. id: number;
  79256. /**
  79257. * Transformation matrix to apply to an object attached to this anchor
  79258. */
  79259. transformationMatrix: Matrix;
  79260. /**
  79261. * The native anchor object
  79262. */
  79263. xrAnchor: XRAnchor;
  79264. /**
  79265. * if defined, this object will be constantly updated by the anchor's position and rotation
  79266. */
  79267. attachedNode?: TransformNode;
  79268. /**
  79269. * Remove this anchor from the scene
  79270. */
  79271. remove(): void;
  79272. }
  79273. /**
  79274. * An implementation of the anchor system for WebXR.
  79275. * For further information see https://github.com/immersive-web/anchors/
  79276. */
  79277. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  79278. private _options;
  79279. private _lastFrameDetected;
  79280. private _trackedAnchors;
  79281. private _referenceSpaceForFrameAnchors;
  79282. private _futureAnchors;
  79283. /**
  79284. * The module's name
  79285. */
  79286. static readonly Name: string;
  79287. /**
  79288. * The (Babylon) version of this module.
  79289. * This is an integer representing the implementation version.
  79290. * This number does not correspond to the WebXR specs version
  79291. */
  79292. static readonly Version: number;
  79293. /**
  79294. * Observers registered here will be executed when a new anchor was added to the session
  79295. */
  79296. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  79297. /**
  79298. * Observers registered here will be executed when an anchor was removed from the session
  79299. */
  79300. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  79301. /**
  79302. * Observers registered here will be executed when an existing anchor updates
  79303. * This can execute N times every frame
  79304. */
  79305. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  79306. /**
  79307. * Set the reference space to use for anchor creation, when not using a hit test.
  79308. * Will default to the session's reference space if not defined
  79309. */
  79310. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  79311. /**
  79312. * constructs a new anchor system
  79313. * @param _xrSessionManager an instance of WebXRSessionManager
  79314. * @param _options configuration object for this feature
  79315. */
  79316. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  79317. private _tmpVector;
  79318. private _tmpQuaternion;
  79319. private _populateTmpTransformation;
  79320. /**
  79321. * Create a new anchor point using a hit test result at a specific point in the scene
  79322. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  79323. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  79324. *
  79325. * @param hitTestResult The hit test result to use for this anchor creation
  79326. * @param position an optional position offset for this anchor
  79327. * @param rotationQuaternion an optional rotation offset for this anchor
  79328. * @returns A promise that fulfills when babylon has created the corresponding WebXRAnchor object and tracking has begun
  79329. */
  79330. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<IWebXRAnchor>;
  79331. /**
  79332. * Add a new anchor at a specific position and rotation
  79333. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  79334. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  79335. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  79336. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  79337. *
  79338. * @param position the position in which to add an anchor
  79339. * @param rotationQuaternion an optional rotation for the anchor transformation
  79340. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  79341. * @returns A promise that fulfills when babylon has created the corresponding WebXRAnchor object and tracking has begun
  79342. */
  79343. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<IWebXRAnchor>;
  79344. /**
  79345. * Get the list of anchors currently being tracked by the system
  79346. */
  79347. get anchors(): IWebXRAnchor[];
  79348. /**
  79349. * detach this feature.
  79350. * Will usually be called by the features manager
  79351. *
  79352. * @returns true if successful.
  79353. */
  79354. detach(): boolean;
  79355. /**
  79356. * Dispose this feature and all of the resources attached
  79357. */
  79358. dispose(): void;
  79359. protected _onXRFrame(frame: XRFrame): void;
  79360. /**
  79361. * avoiding using Array.find for global support.
  79362. * @param xrAnchor the plane to find in the array
  79363. */
  79364. private _findIndexInAnchorArray;
  79365. private _updateAnchorWithXRFrame;
  79366. private _createAnchorAtTransformation;
  79367. }
  79368. }
  79369. declare module BABYLON {
  79370. /**
  79371. * Options used in the plane detector module
  79372. */
  79373. export interface IWebXRPlaneDetectorOptions {
  79374. /**
  79375. * The node to use to transform the local results to world coordinates
  79376. */
  79377. worldParentNode?: TransformNode;
  79378. /**
  79379. * If set to true a reference of the created planes will be kept until the next session starts
  79380. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  79381. */
  79382. doNotRemovePlanesOnSessionEnded?: boolean;
  79383. /**
  79384. * Preferred detector configuration, not all preferred options will be supported by all platforms.
  79385. */
  79386. preferredDetectorOptions?: XRGeometryDetectorOptions;
  79387. }
  79388. /**
  79389. * A babylon interface for a WebXR plane.
  79390. * A Plane is actually a polygon, built from N points in space
  79391. *
  79392. * Supported in chrome 79, not supported in canary 81 ATM
  79393. */
  79394. export interface IWebXRPlane {
  79395. /**
  79396. * a babylon-assigned ID for this polygon
  79397. */
  79398. id: number;
  79399. /**
  79400. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  79401. */
  79402. polygonDefinition: Array<Vector3>;
  79403. /**
  79404. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  79405. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  79406. */
  79407. transformationMatrix: Matrix;
  79408. /**
  79409. * the native xr-plane object
  79410. */
  79411. xrPlane: XRPlane;
  79412. }
  79413. /**
  79414. * The plane detector is used to detect planes in the real world when in AR
  79415. * For more information see https://github.com/immersive-web/real-world-geometry/
  79416. */
  79417. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  79418. private _options;
  79419. private _detectedPlanes;
  79420. private _enabled;
  79421. private _lastFrameDetected;
  79422. /**
  79423. * The module's name
  79424. */
  79425. static readonly Name: string;
  79426. /**
  79427. * The (Babylon) version of this module.
  79428. * This is an integer representing the implementation version.
  79429. * This number does not correspond to the WebXR specs version
  79430. */
  79431. static readonly Version: number;
  79432. /**
  79433. * Observers registered here will be executed when a new plane was added to the session
  79434. */
  79435. onPlaneAddedObservable: Observable<IWebXRPlane>;
  79436. /**
  79437. * Observers registered here will be executed when a plane is no longer detected in the session
  79438. */
  79439. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  79440. /**
  79441. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  79442. * This can execute N times every frame
  79443. */
  79444. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  79445. /**
  79446. * construct a new Plane Detector
  79447. * @param _xrSessionManager an instance of xr Session manager
  79448. * @param _options configuration to use when constructing this feature
  79449. */
  79450. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  79451. /**
  79452. * detach this feature.
  79453. * Will usually be called by the features manager
  79454. *
  79455. * @returns true if successful.
  79456. */
  79457. detach(): boolean;
  79458. /**
  79459. * Dispose this feature and all of the resources attached
  79460. */
  79461. dispose(): void;
  79462. /**
  79463. * Check if the needed objects are defined.
  79464. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  79465. */
  79466. isCompatible(): boolean;
  79467. protected _onXRFrame(frame: XRFrame): void;
  79468. private _init;
  79469. private _updatePlaneWithXRPlane;
  79470. /**
  79471. * avoiding using Array.find for global support.
  79472. * @param xrPlane the plane to find in the array
  79473. */
  79474. private _findIndexInPlaneArray;
  79475. }
  79476. }
  79477. declare module BABYLON {
  79478. /**
  79479. * Options interface for the background remover plugin
  79480. */
  79481. export interface IWebXRBackgroundRemoverOptions {
  79482. /**
  79483. * Further background meshes to disable when entering AR
  79484. */
  79485. backgroundMeshes?: AbstractMesh[];
  79486. /**
  79487. * flags to configure the removal of the environment helper.
  79488. * If not set, the entire background will be removed. If set, flags should be set as well.
  79489. */
  79490. environmentHelperRemovalFlags?: {
  79491. /**
  79492. * Should the skybox be removed (default false)
  79493. */
  79494. skyBox?: boolean;
  79495. /**
  79496. * Should the ground be removed (default false)
  79497. */
  79498. ground?: boolean;
  79499. };
  79500. /**
  79501. * don't disable the environment helper
  79502. */
  79503. ignoreEnvironmentHelper?: boolean;
  79504. }
  79505. /**
  79506. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  79507. */
  79508. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  79509. /**
  79510. * read-only options to be used in this module
  79511. */
  79512. readonly options: IWebXRBackgroundRemoverOptions;
  79513. /**
  79514. * The module's name
  79515. */
  79516. static readonly Name: string;
  79517. /**
  79518. * The (Babylon) version of this module.
  79519. * This is an integer representing the implementation version.
  79520. * This number does not correspond to the WebXR specs version
  79521. */
  79522. static readonly Version: number;
  79523. /**
  79524. * registered observers will be triggered when the background state changes
  79525. */
  79526. onBackgroundStateChangedObservable: Observable<boolean>;
  79527. /**
  79528. * constructs a new background remover module
  79529. * @param _xrSessionManager the session manager for this module
  79530. * @param options read-only options to be used in this module
  79531. */
  79532. constructor(_xrSessionManager: WebXRSessionManager,
  79533. /**
  79534. * read-only options to be used in this module
  79535. */
  79536. options?: IWebXRBackgroundRemoverOptions);
  79537. /**
  79538. * attach this feature
  79539. * Will usually be called by the features manager
  79540. *
  79541. * @returns true if successful.
  79542. */
  79543. attach(): boolean;
  79544. /**
  79545. * detach this feature.
  79546. * Will usually be called by the features manager
  79547. *
  79548. * @returns true if successful.
  79549. */
  79550. detach(): boolean;
  79551. /**
  79552. * Dispose this feature and all of the resources attached
  79553. */
  79554. dispose(): void;
  79555. protected _onXRFrame(_xrFrame: XRFrame): void;
  79556. private _setBackgroundState;
  79557. }
  79558. }
  79559. declare module BABYLON {
  79560. /**
  79561. * Options for the controller physics feature
  79562. */
  79563. export class IWebXRControllerPhysicsOptions {
  79564. /**
  79565. * Should the headset get its own impostor
  79566. */
  79567. enableHeadsetImpostor?: boolean;
  79568. /**
  79569. * Optional parameters for the headset impostor
  79570. */
  79571. headsetImpostorParams?: {
  79572. /**
  79573. * The type of impostor to create. Default is sphere
  79574. */
  79575. impostorType: number;
  79576. /**
  79577. * the size of the impostor. Defaults to 10cm
  79578. */
  79579. impostorSize?: number | {
  79580. width: number;
  79581. height: number;
  79582. depth: number;
  79583. };
  79584. /**
  79585. * Friction definitions
  79586. */
  79587. friction?: number;
  79588. /**
  79589. * Restitution
  79590. */
  79591. restitution?: number;
  79592. };
  79593. /**
  79594. * The physics properties of the future impostors
  79595. */
  79596. physicsProperties?: {
  79597. /**
  79598. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  79599. * Note that this requires a physics engine that supports mesh impostors!
  79600. */
  79601. useControllerMesh?: boolean;
  79602. /**
  79603. * The type of impostor to create. Default is sphere
  79604. */
  79605. impostorType?: number;
  79606. /**
  79607. * the size of the impostor. Defaults to 10cm
  79608. */
  79609. impostorSize?: number | {
  79610. width: number;
  79611. height: number;
  79612. depth: number;
  79613. };
  79614. /**
  79615. * Friction definitions
  79616. */
  79617. friction?: number;
  79618. /**
  79619. * Restitution
  79620. */
  79621. restitution?: number;
  79622. };
  79623. /**
  79624. * the xr input to use with this pointer selection
  79625. */
  79626. xrInput: WebXRInput;
  79627. }
  79628. /**
  79629. * Add physics impostor to your webxr controllers,
  79630. * including naive calculation of their linear and angular velocity
  79631. */
  79632. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  79633. private readonly _options;
  79634. private _attachController;
  79635. private _controllers;
  79636. private _debugMode;
  79637. private _delta;
  79638. private _headsetImpostor?;
  79639. private _headsetMesh?;
  79640. private _lastTimestamp;
  79641. private _tmpQuaternion;
  79642. private _tmpVector;
  79643. /**
  79644. * The module's name
  79645. */
  79646. static readonly Name: string;
  79647. /**
  79648. * The (Babylon) version of this module.
  79649. * This is an integer representing the implementation version.
  79650. * This number does not correspond to the webxr specs version
  79651. */
  79652. static readonly Version: number;
  79653. /**
  79654. * Construct a new Controller Physics Feature
  79655. * @param _xrSessionManager the corresponding xr session manager
  79656. * @param _options options to create this feature with
  79657. */
  79658. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  79659. /**
  79660. * @hidden
  79661. * enable debugging - will show console outputs and the impostor mesh
  79662. */
  79663. _enablePhysicsDebug(): void;
  79664. /**
  79665. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  79666. * @param xrController the controller to add
  79667. */
  79668. addController(xrController: WebXRInputSource): void;
  79669. /**
  79670. * attach this feature
  79671. * Will usually be called by the features manager
  79672. *
  79673. * @returns true if successful.
  79674. */
  79675. attach(): boolean;
  79676. /**
  79677. * detach this feature.
  79678. * Will usually be called by the features manager
  79679. *
  79680. * @returns true if successful.
  79681. */
  79682. detach(): boolean;
  79683. /**
  79684. * Get the headset impostor, if enabled
  79685. * @returns the impostor
  79686. */
  79687. getHeadsetImpostor(): PhysicsImpostor | undefined;
  79688. /**
  79689. * Get the physics impostor of a specific controller.
  79690. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  79691. * @param controller the controller or the controller id of which to get the impostor
  79692. * @returns the impostor or null
  79693. */
  79694. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  79695. /**
  79696. * Update the physics properties provided in the constructor
  79697. * @param newProperties the new properties object
  79698. */
  79699. setPhysicsProperties(newProperties: {
  79700. impostorType?: number;
  79701. impostorSize?: number | {
  79702. width: number;
  79703. height: number;
  79704. depth: number;
  79705. };
  79706. friction?: number;
  79707. restitution?: number;
  79708. }): void;
  79709. protected _onXRFrame(_xrFrame: any): void;
  79710. private _detachController;
  79711. }
  79712. }
  79713. declare module BABYLON {
  79714. /**
  79715. * A babylon interface for a "WebXR" feature point.
  79716. * Represents the position and confidence value of a given feature point.
  79717. */
  79718. export interface IWebXRFeaturePoint {
  79719. /**
  79720. * Represents the position of the feature point in world space.
  79721. */
  79722. position: Vector3;
  79723. /**
  79724. * Represents the confidence value of the feature point in world space. 0 being least confident, and 1 being most confident.
  79725. */
  79726. confidenceValue: number;
  79727. }
  79728. /**
  79729. * The feature point system is used to detect feature points from real world geometry.
  79730. * This feature is currently experimental and only supported on BabylonNative, and should not be used in the browser.
  79731. * The newly introduced API can be seen in webxr.nativeextensions.d.ts and described in FeaturePoints.md.
  79732. */
  79733. export class WebXRFeaturePointSystem extends WebXRAbstractFeature {
  79734. private _enabled;
  79735. private _featurePointCloud;
  79736. /**
  79737. * The module's name
  79738. */
  79739. static readonly Name: string;
  79740. /**
  79741. * The (Babylon) version of this module.
  79742. * This is an integer representing the implementation version.
  79743. * This number does not correspond to the WebXR specs version
  79744. */
  79745. static readonly Version: number;
  79746. /**
  79747. * Observers registered here will be executed whenever new feature points are added (on XRFrame while the session is tracking).
  79748. * Will notify the observers about which feature points have been added.
  79749. */
  79750. readonly onFeaturePointsAddedObservable: Observable<number[]>;
  79751. /**
  79752. * Observers registered here will be executed whenever a feature point has been updated (on XRFrame while the session is tracking).
  79753. * Will notify the observers about which feature points have been updated.
  79754. */
  79755. readonly onFeaturePointsUpdatedObservable: Observable<number[]>;
  79756. /**
  79757. * The current feature point cloud maintained across frames.
  79758. */
  79759. get featurePointCloud(): Array<IWebXRFeaturePoint>;
  79760. /**
  79761. * construct the feature point system
  79762. * @param _xrSessionManager an instance of xr Session manager
  79763. */
  79764. constructor(_xrSessionManager: WebXRSessionManager);
  79765. /**
  79766. * Detach this feature.
  79767. * Will usually be called by the features manager
  79768. *
  79769. * @returns true if successful.
  79770. */
  79771. detach(): boolean;
  79772. /**
  79773. * Dispose this feature and all of the resources attached
  79774. */
  79775. dispose(): void;
  79776. /**
  79777. * On receiving a new XR frame if this feature is attached notify observers new feature point data is available.
  79778. */
  79779. protected _onXRFrame(frame: XRFrame): void;
  79780. /**
  79781. * Initializes the feature. If the feature point feature is not available for this environment do not mark the feature as enabled.
  79782. */
  79783. private _init;
  79784. }
  79785. }
  79786. declare module BABYLON {
  79787. /**
  79788. * Configuration interface for the hand tracking feature
  79789. */
  79790. export interface IWebXRHandTrackingOptions {
  79791. /**
  79792. * The xrInput that will be used as source for new hands
  79793. */
  79794. xrInput: WebXRInput;
  79795. /**
  79796. * Configuration object for the joint meshes
  79797. */
  79798. jointMeshes?: {
  79799. /**
  79800. * Should the meshes created be invisible (defaults to false)
  79801. */
  79802. invisible?: boolean;
  79803. /**
  79804. * A source mesh to be used to create instances. Defaults to a sphere.
  79805. * This mesh will be the source for all other (25) meshes.
  79806. * It should have the general size of a single unit, as the instances will be scaled according to the provided radius
  79807. */
  79808. sourceMesh?: Mesh;
  79809. /**
  79810. * This function will be called after a mesh was created for a specific joint.
  79811. * Using this function you can either manipulate the instance or return a new mesh.
  79812. * When returning a new mesh the instance created before will be disposed
  79813. */
  79814. onHandJointMeshGenerated?: (meshInstance: InstancedMesh, jointId: number, controllerId: string) => Mesh | undefined;
  79815. /**
  79816. * Should the source mesh stay visible. Defaults to false
  79817. */
  79818. keepOriginalVisible?: boolean;
  79819. /**
  79820. * Scale factor for all instances (defaults to 2)
  79821. */
  79822. scaleFactor?: number;
  79823. /**
  79824. * Should each instance have its own physics impostor
  79825. */
  79826. enablePhysics?: boolean;
  79827. /**
  79828. * If enabled, override default physics properties
  79829. */
  79830. physicsProps?: {
  79831. friction?: number;
  79832. restitution?: number;
  79833. impostorType?: number;
  79834. };
  79835. /**
  79836. * Should the default hand mesh be disabled. In this case, the spheres will be visible (unless set invisible).
  79837. */
  79838. disableDefaultHandMesh?: boolean;
  79839. /**
  79840. * a rigged hand-mesh that will be updated according to the XRHand data provided. This will override the default hand mesh
  79841. */
  79842. handMeshes?: {
  79843. right: AbstractMesh;
  79844. left: AbstractMesh;
  79845. };
  79846. /**
  79847. * If a hand mesh was provided, this array will define what axis will update which node. This will override the default hand mesh
  79848. */
  79849. rigMapping?: {
  79850. right: string[];
  79851. left: string[];
  79852. };
  79853. };
  79854. }
  79855. /**
  79856. * Parts of the hands divided to writs and finger names
  79857. */
  79858. export const enum HandPart {
  79859. /**
  79860. * HandPart - Wrist
  79861. */
  79862. WRIST = "wrist",
  79863. /**
  79864. * HandPart - The THumb
  79865. */
  79866. THUMB = "thumb",
  79867. /**
  79868. * HandPart - Index finger
  79869. */
  79870. INDEX = "index",
  79871. /**
  79872. * HandPart - Middle finger
  79873. */
  79874. MIDDLE = "middle",
  79875. /**
  79876. * HandPart - Ring finger
  79877. */
  79878. RING = "ring",
  79879. /**
  79880. * HandPart - Little finger
  79881. */
  79882. LITTLE = "little"
  79883. }
  79884. /**
  79885. * Representing a single hand (with its corresponding native XRHand object)
  79886. */
  79887. export class WebXRHand implements IDisposable {
  79888. /** the controller to which the hand correlates */
  79889. readonly xrController: WebXRInputSource;
  79890. /** the meshes to be used to track the hand joints */
  79891. readonly trackedMeshes: AbstractMesh[];
  79892. private _handMesh?;
  79893. private _rigMapping?;
  79894. private _scene;
  79895. private _defaultHandMesh;
  79896. private _transformNodeMapping;
  79897. /**
  79898. * Hand-parts definition (key is HandPart)
  79899. */
  79900. handPartsDefinition: {
  79901. [key: string]: number[];
  79902. };
  79903. /**
  79904. * Observers will be triggered when the mesh for this hand was initialized.
  79905. */
  79906. onHandMeshReadyObservable: Observable<WebXRHand>;
  79907. /**
  79908. * Populate the HandPartsDefinition object.
  79909. * This is called as a side effect since certain browsers don't have XRHand defined.
  79910. */
  79911. private generateHandPartsDefinition;
  79912. /**
  79913. * Construct a new hand object
  79914. * @param xrController the controller to which the hand correlates
  79915. * @param trackedMeshes the meshes to be used to track the hand joints
  79916. * @param _handMesh an optional hand mesh. if not provided, ours will be used
  79917. * @param _rigMapping an optional rig mapping for the hand mesh. if not provided, ours will be used
  79918. * @param disableDefaultHandMesh should the default mesh creation be disabled
  79919. */
  79920. constructor(
  79921. /** the controller to which the hand correlates */
  79922. xrController: WebXRInputSource,
  79923. /** the meshes to be used to track the hand joints */
  79924. trackedMeshes: AbstractMesh[], _handMesh?: AbstractMesh | undefined, _rigMapping?: string[] | undefined, disableDefaultHandMesh?: boolean);
  79925. /**
  79926. * Get the hand mesh. It is possible that the hand mesh is not yet ready!
  79927. */
  79928. get handMesh(): AbstractMesh | undefined;
  79929. /**
  79930. * Update this hand from the latest xr frame
  79931. * @param xrFrame xrFrame to update from
  79932. * @param referenceSpace The current viewer reference space
  79933. * @param scaleFactor optional scale factor for the meshes
  79934. */
  79935. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace, scaleFactor?: number): void;
  79936. /**
  79937. * Get meshes of part of the hand
  79938. * @param part the part of hand to get
  79939. * @returns An array of meshes that correlate to the hand part requested
  79940. */
  79941. getHandPartMeshes(part: HandPart): AbstractMesh[];
  79942. /**
  79943. * Dispose this Hand object
  79944. */
  79945. dispose(): void;
  79946. private _generateDefaultHandMesh;
  79947. }
  79948. /**
  79949. * WebXR Hand Joint tracking feature, available for selected browsers and devices
  79950. */
  79951. export class WebXRHandTracking extends WebXRAbstractFeature {
  79952. /**
  79953. * options to use when constructing this feature
  79954. */
  79955. readonly options: IWebXRHandTrackingOptions;
  79956. private static _idCounter;
  79957. /**
  79958. * The module's name
  79959. */
  79960. static readonly Name: string;
  79961. /**
  79962. * The (Babylon) version of this module.
  79963. * This is an integer representing the implementation version.
  79964. * This number does not correspond to the WebXR specs version
  79965. */
  79966. static readonly Version: number;
  79967. /**
  79968. * This observable will notify registered observers when a new hand object was added and initialized
  79969. */
  79970. onHandAddedObservable: Observable<WebXRHand>;
  79971. /**
  79972. * This observable will notify its observers right before the hand object is disposed
  79973. */
  79974. onHandRemovedObservable: Observable<WebXRHand>;
  79975. private _hands;
  79976. /**
  79977. * Creates a new instance of the hit test feature
  79978. * @param _xrSessionManager an instance of WebXRSessionManager
  79979. * @param options options to use when constructing this feature
  79980. */
  79981. constructor(_xrSessionManager: WebXRSessionManager,
  79982. /**
  79983. * options to use when constructing this feature
  79984. */
  79985. options: IWebXRHandTrackingOptions);
  79986. /**
  79987. * Check if the needed objects are defined.
  79988. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  79989. */
  79990. isCompatible(): boolean;
  79991. /**
  79992. * attach this feature
  79993. * Will usually be called by the features manager
  79994. *
  79995. * @returns true if successful.
  79996. */
  79997. attach(): boolean;
  79998. /**
  79999. * detach this feature.
  80000. * Will usually be called by the features manager
  80001. *
  80002. * @returns true if successful.
  80003. */
  80004. detach(): boolean;
  80005. /**
  80006. * Dispose this feature and all of the resources attached
  80007. */
  80008. dispose(): void;
  80009. /**
  80010. * Get the hand object according to the controller id
  80011. * @param controllerId the controller id to which we want to get the hand
  80012. * @returns null if not found or the WebXRHand object if found
  80013. */
  80014. getHandByControllerId(controllerId: string): Nullable<WebXRHand>;
  80015. /**
  80016. * Get a hand object according to the requested handedness
  80017. * @param handedness the handedness to request
  80018. * @returns null if not found or the WebXRHand object if found
  80019. */
  80020. getHandByHandedness(handedness: XRHandedness): Nullable<WebXRHand>;
  80021. protected _onXRFrame(_xrFrame: XRFrame): void;
  80022. private _attachHand;
  80023. private _detachHand;
  80024. }
  80025. }
  80026. declare module BABYLON {
  80027. /**
  80028. * Options used in the mesh detector module
  80029. */
  80030. export interface IWebXRMeshDetectorOptions {
  80031. /**
  80032. * The node to use to transform the local results to world coordinates
  80033. */
  80034. worldParentNode?: TransformNode;
  80035. /**
  80036. * If set to true a reference of the created meshes will be kept until the next session starts
  80037. * If not defined, meshes will be removed from the array when the feature is detached or the session ended.
  80038. */
  80039. doNotRemoveMeshesOnSessionEnded?: boolean;
  80040. /**
  80041. * Preferred detector configuration, not all preferred options will be supported by all platforms.
  80042. */
  80043. preferredDetectorOptions?: XRGeometryDetectorOptions;
  80044. /**
  80045. * If set to true, WebXRMeshDetector will convert coordinate systems for meshes.
  80046. * If not defined, mesh conversions from right handed to left handed coordinate systems won't be conducted.
  80047. * Right handed mesh data will be available through IWebXRVertexData.xrMesh.
  80048. */
  80049. convertCoordinateSystems?: boolean;
  80050. }
  80051. /**
  80052. * A babylon interface for a XR mesh's vertex data.
  80053. *
  80054. * Currently not supported by WebXR, available only with BabylonNative
  80055. */
  80056. export interface IWebXRVertexData {
  80057. /**
  80058. * A babylon-assigned ID for this mesh
  80059. */
  80060. id: number;
  80061. /**
  80062. * Data required for constructing a mesh in Babylon.js.
  80063. */
  80064. xrMesh: XRMesh;
  80065. /**
  80066. * The node to use to transform the local results to world coordinates.
  80067. * WorldParentNode will only exist if it was declared in the IWebXRMeshDetectorOptions.
  80068. */
  80069. worldParentNode?: TransformNode;
  80070. /**
  80071. * An array of vertex positions in babylon space. right/left hand system is taken into account.
  80072. * Positions will only be calculated if convertCoordinateSystems is set to true in the IWebXRMeshDetectorOptions.
  80073. */
  80074. positions?: Float32Array;
  80075. /**
  80076. * An array of indices in babylon space. Indices have a counterclockwise winding order.
  80077. * Indices will only be populated if convertCoordinateSystems is set to true in the IWebXRMeshDetectorOptions.
  80078. */
  80079. indices?: Uint32Array;
  80080. /**
  80081. * An array of vertex normals in babylon space. right/left hand system is taken into account.
  80082. * Normals will not be calculated if convertCoordinateSystems is undefined in the IWebXRMeshDetectorOptions.
  80083. * Different platforms may or may not support mesh normals when convertCoordinateSystems is set to true.
  80084. */
  80085. normals?: Float32Array;
  80086. /**
  80087. * A transformation matrix to apply on the mesh that will be built using the meshDefinition.
  80088. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module.
  80089. * TransformationMatrix will only be calculated if convertCoordinateSystems is set to true in the IWebXRMeshDetectorOptions.
  80090. */
  80091. transformationMatrix?: Matrix;
  80092. }
  80093. /**
  80094. * The mesh detector is used to detect meshes in the real world when in AR
  80095. */
  80096. export class WebXRMeshDetector extends WebXRAbstractFeature {
  80097. private _options;
  80098. private _detectedMeshes;
  80099. /**
  80100. * The module's name
  80101. */
  80102. static readonly Name: string;
  80103. /**
  80104. * The (Babylon) version of this module.
  80105. * This is an integer representing the implementation version.
  80106. * This number does not correspond to the WebXR specs version
  80107. */
  80108. static readonly Version: number;
  80109. /**
  80110. * Observers registered here will be executed when a new mesh was added to the session
  80111. */
  80112. onMeshAddedObservable: Observable<IWebXRVertexData>;
  80113. /**
  80114. * Observers registered here will be executed when a mesh is no longer detected in the session
  80115. */
  80116. onMeshRemovedObservable: Observable<IWebXRVertexData>;
  80117. /**
  80118. * Observers registered here will be executed when an existing mesh updates
  80119. */
  80120. onMeshUpdatedObservable: Observable<IWebXRVertexData>;
  80121. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRMeshDetectorOptions);
  80122. detach(): boolean;
  80123. dispose(): void;
  80124. protected _onXRFrame(frame: XRFrame): void;
  80125. private _init;
  80126. private _updateVertexDataWithXRMesh;
  80127. }
  80128. }
  80129. declare module BABYLON {
  80130. /**
  80131. * Options interface for the background remover plugin
  80132. */
  80133. export interface IWebXRImageTrackingOptions {
  80134. /**
  80135. * A required array with images to track
  80136. */
  80137. images: {
  80138. /**
  80139. * The source of the image. can be a URL or an image bitmap
  80140. */
  80141. src: string | ImageBitmap;
  80142. /**
  80143. * The estimated width in the real world (in meters)
  80144. */
  80145. estimatedRealWorldWidth: number;
  80146. }[];
  80147. }
  80148. /**
  80149. * An object representing an image tracked by the system
  80150. */
  80151. export interface IWebXRTrackedImage {
  80152. /**
  80153. * The ID of this image (which is the same as the position in the array that was used to initialize the feature)
  80154. */
  80155. id: number;
  80156. /**
  80157. * Is the transformation provided emulated. If it is, the system "guesses" its real position. Otherwise it can be considered as exact position.
  80158. */
  80159. emulated?: boolean;
  80160. /**
  80161. * Just in case it is needed - the image bitmap that is being tracked
  80162. */
  80163. originalBitmap: ImageBitmap;
  80164. /**
  80165. * The native XR result image tracking result, untouched
  80166. */
  80167. xrTrackingResult?: XRImageTrackingResult;
  80168. /**
  80169. * Width in real world (meters)
  80170. */
  80171. realWorldWidth?: number;
  80172. /**
  80173. * A transformation matrix of this current image in the current reference space.
  80174. */
  80175. transformationMatrix: Matrix;
  80176. /**
  80177. * The width/height ratio of this image. can be used to calculate the size of the detected object/image
  80178. */
  80179. ratio?: number;
  80180. }
  80181. /**
  80182. * Image tracking for immersive AR sessions.
  80183. * Providing a list of images and their estimated widths will enable tracking those images in the real world.
  80184. */
  80185. export class WebXRImageTracking extends WebXRAbstractFeature {
  80186. /**
  80187. * read-only options to be used in this module
  80188. */
  80189. readonly options: IWebXRImageTrackingOptions;
  80190. /**
  80191. * The module's name
  80192. */
  80193. static readonly Name: string;
  80194. /**
  80195. * The (Babylon) version of this module.
  80196. * This is an integer representing the implementation version.
  80197. * This number does not correspond to the WebXR specs version
  80198. */
  80199. static readonly Version: number;
  80200. /**
  80201. * This will be triggered if the underlying system deems an image untrackable.
  80202. * The index is the index of the image from the array used to initialize the feature.
  80203. */
  80204. onUntrackableImageFoundObservable: Observable<number>;
  80205. /**
  80206. * An image was deemed trackable, and the system will start tracking it.
  80207. */
  80208. onTrackableImageFoundObservable: Observable<IWebXRTrackedImage>;
  80209. /**
  80210. * The image was found and its state was updated.
  80211. */
  80212. onTrackedImageUpdatedObservable: Observable<IWebXRTrackedImage>;
  80213. private _trackedImages;
  80214. private _originalTrackingRequest;
  80215. /**
  80216. * constructs the image tracking feature
  80217. * @param _xrSessionManager the session manager for this module
  80218. * @param options read-only options to be used in this module
  80219. */
  80220. constructor(_xrSessionManager: WebXRSessionManager,
  80221. /**
  80222. * read-only options to be used in this module
  80223. */
  80224. options: IWebXRImageTrackingOptions);
  80225. /**
  80226. * attach this feature
  80227. * Will usually be called by the features manager
  80228. *
  80229. * @returns true if successful.
  80230. */
  80231. attach(): boolean;
  80232. /**
  80233. * detach this feature.
  80234. * Will usually be called by the features manager
  80235. *
  80236. * @returns true if successful.
  80237. */
  80238. detach(): boolean;
  80239. /**
  80240. * Check if the needed objects are defined.
  80241. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  80242. */
  80243. isCompatible(): boolean;
  80244. /**
  80245. * Get a tracked image by its ID.
  80246. *
  80247. * @param id the id of the image to load (position in the init array)
  80248. * @returns a trackable image, if exists in this location
  80249. */
  80250. getTrackedImageById(id: number): Nullable<IWebXRTrackedImage>;
  80251. /**
  80252. * Dispose this feature and all of the resources attached
  80253. */
  80254. dispose(): void;
  80255. /**
  80256. * Extends the session init object if needed
  80257. * @returns augmentation object fo the xr session init object.
  80258. */
  80259. getXRSessionInitExtension(): Promise<Partial<XRSessionInit>>;
  80260. protected _onXRFrame(_xrFrame: XRFrame): void;
  80261. private _init;
  80262. }
  80263. }
  80264. declare module BABYLON {
  80265. /**
  80266. * The motion controller class for all microsoft mixed reality controllers
  80267. */
  80268. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  80269. protected readonly _mapping: {
  80270. defaultButton: {
  80271. valueNodeName: string;
  80272. unpressedNodeName: string;
  80273. pressedNodeName: string;
  80274. };
  80275. defaultAxis: {
  80276. valueNodeName: string;
  80277. minNodeName: string;
  80278. maxNodeName: string;
  80279. };
  80280. buttons: {
  80281. "xr-standard-trigger": {
  80282. rootNodeName: string;
  80283. componentProperty: string;
  80284. states: string[];
  80285. };
  80286. "xr-standard-squeeze": {
  80287. rootNodeName: string;
  80288. componentProperty: string;
  80289. states: string[];
  80290. };
  80291. "xr-standard-touchpad": {
  80292. rootNodeName: string;
  80293. labelAnchorNodeName: string;
  80294. touchPointNodeName: string;
  80295. };
  80296. "xr-standard-thumbstick": {
  80297. rootNodeName: string;
  80298. componentProperty: string;
  80299. states: string[];
  80300. };
  80301. };
  80302. axes: {
  80303. "xr-standard-touchpad": {
  80304. "x-axis": {
  80305. rootNodeName: string;
  80306. };
  80307. "y-axis": {
  80308. rootNodeName: string;
  80309. };
  80310. };
  80311. "xr-standard-thumbstick": {
  80312. "x-axis": {
  80313. rootNodeName: string;
  80314. };
  80315. "y-axis": {
  80316. rootNodeName: string;
  80317. };
  80318. };
  80319. };
  80320. };
  80321. /**
  80322. * The base url used to load the left and right controller models
  80323. */
  80324. static MODEL_BASE_URL: string;
  80325. /**
  80326. * The name of the left controller model file
  80327. */
  80328. static MODEL_LEFT_FILENAME: string;
  80329. /**
  80330. * The name of the right controller model file
  80331. */
  80332. static MODEL_RIGHT_FILENAME: string;
  80333. profileId: string;
  80334. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  80335. protected _getFilenameAndPath(): {
  80336. filename: string;
  80337. path: string;
  80338. };
  80339. protected _getModelLoadingConstraints(): boolean;
  80340. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  80341. protected _setRootMesh(meshes: AbstractMesh[]): void;
  80342. protected _updateModel(): void;
  80343. }
  80344. }
  80345. declare module BABYLON {
  80346. /**
  80347. * The motion controller class for oculus touch (quest, rift).
  80348. * This class supports legacy mapping as well the standard xr mapping
  80349. */
  80350. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  80351. private _forceLegacyControllers;
  80352. private _modelRootNode;
  80353. /**
  80354. * The base url used to load the left and right controller models
  80355. */
  80356. static MODEL_BASE_URL: string;
  80357. /**
  80358. * The name of the left controller model file
  80359. */
  80360. static MODEL_LEFT_FILENAME: string;
  80361. /**
  80362. * The name of the right controller model file
  80363. */
  80364. static MODEL_RIGHT_FILENAME: string;
  80365. /**
  80366. * Base Url for the Quest controller model.
  80367. */
  80368. static QUEST_MODEL_BASE_URL: string;
  80369. profileId: string;
  80370. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  80371. protected _getFilenameAndPath(): {
  80372. filename: string;
  80373. path: string;
  80374. };
  80375. protected _getModelLoadingConstraints(): boolean;
  80376. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  80377. protected _setRootMesh(meshes: AbstractMesh[]): void;
  80378. protected _updateModel(): void;
  80379. /**
  80380. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  80381. * between the touch and touch 2.
  80382. */
  80383. private _isQuest;
  80384. }
  80385. }
  80386. declare module BABYLON {
  80387. /**
  80388. * The motion controller class for the standard HTC-Vive controllers
  80389. */
  80390. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  80391. private _modelRootNode;
  80392. /**
  80393. * The base url used to load the left and right controller models
  80394. */
  80395. static MODEL_BASE_URL: string;
  80396. /**
  80397. * File name for the controller model.
  80398. */
  80399. static MODEL_FILENAME: string;
  80400. profileId: string;
  80401. /**
  80402. * Create a new Vive motion controller object
  80403. * @param scene the scene to use to create this controller
  80404. * @param gamepadObject the corresponding gamepad object
  80405. * @param handedness the handedness of the controller
  80406. */
  80407. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  80408. protected _getFilenameAndPath(): {
  80409. filename: string;
  80410. path: string;
  80411. };
  80412. protected _getModelLoadingConstraints(): boolean;
  80413. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  80414. protected _setRootMesh(meshes: AbstractMesh[]): void;
  80415. protected _updateModel(): void;
  80416. }
  80417. }
  80418. declare module BABYLON {
  80419. /**
  80420. * A cursor which tracks a point on a path
  80421. */
  80422. export class PathCursor {
  80423. private path;
  80424. /**
  80425. * Stores path cursor callbacks for when an onchange event is triggered
  80426. */
  80427. private _onchange;
  80428. /**
  80429. * The value of the path cursor
  80430. */
  80431. value: number;
  80432. /**
  80433. * The animation array of the path cursor
  80434. */
  80435. animations: Animation[];
  80436. /**
  80437. * Initializes the path cursor
  80438. * @param path The path to track
  80439. */
  80440. constructor(path: Path2);
  80441. /**
  80442. * Gets the cursor point on the path
  80443. * @returns A point on the path cursor at the cursor location
  80444. */
  80445. getPoint(): Vector3;
  80446. /**
  80447. * Moves the cursor ahead by the step amount
  80448. * @param step The amount to move the cursor forward
  80449. * @returns This path cursor
  80450. */
  80451. moveAhead(step?: number): PathCursor;
  80452. /**
  80453. * Moves the cursor behind by the step amount
  80454. * @param step The amount to move the cursor back
  80455. * @returns This path cursor
  80456. */
  80457. moveBack(step?: number): PathCursor;
  80458. /**
  80459. * Moves the cursor by the step amount
  80460. * If the step amount is greater than one, an exception is thrown
  80461. * @param step The amount to move the cursor
  80462. * @returns This path cursor
  80463. */
  80464. move(step: number): PathCursor;
  80465. /**
  80466. * Ensures that the value is limited between zero and one
  80467. * @returns This path cursor
  80468. */
  80469. private ensureLimits;
  80470. /**
  80471. * Runs onchange callbacks on change (used by the animation engine)
  80472. * @returns This path cursor
  80473. */
  80474. private raiseOnChange;
  80475. /**
  80476. * Executes a function on change
  80477. * @param f A path cursor onchange callback
  80478. * @returns This path cursor
  80479. */
  80480. onchange(f: (cursor: PathCursor) => void): PathCursor;
  80481. }
  80482. }
  80483. declare module BABYLON {
  80484. /** @hidden */
  80485. export var blurPixelShader: {
  80486. name: string;
  80487. shader: string;
  80488. };
  80489. }
  80490. declare module BABYLON {
  80491. /** @hidden */
  80492. export var pointCloudVertexDeclaration: {
  80493. name: string;
  80494. shader: string;
  80495. };
  80496. }
  80497. // Mixins
  80498. interface Window {
  80499. mozIndexedDB: IDBFactory;
  80500. webkitIndexedDB: IDBFactory;
  80501. msIndexedDB: IDBFactory;
  80502. webkitURL: typeof URL;
  80503. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  80504. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  80505. WebGLRenderingContext: WebGLRenderingContext;
  80506. MSGesture: MSGesture;
  80507. CANNON: any;
  80508. AudioContext: AudioContext;
  80509. webkitAudioContext: AudioContext;
  80510. PointerEvent: any;
  80511. Math: Math;
  80512. Uint8Array: Uint8ArrayConstructor;
  80513. Float32Array: Float32ArrayConstructor;
  80514. mozURL: typeof URL;
  80515. msURL: typeof URL;
  80516. VRFrameData: any; // WebVR, from specs 1.1
  80517. DracoDecoderModule: any;
  80518. setImmediate(handler: (...args: any[]) => void): number;
  80519. }
  80520. interface HTMLCanvasElement {
  80521. requestPointerLock(): void;
  80522. msRequestPointerLock?(): void;
  80523. mozRequestPointerLock?(): void;
  80524. webkitRequestPointerLock?(): void;
  80525. /** Track wether a record is in progress */
  80526. isRecording: boolean;
  80527. /** Capture Stream method defined by some browsers */
  80528. captureStream(fps?: number): MediaStream;
  80529. }
  80530. interface CanvasRenderingContext2D {
  80531. msImageSmoothingEnabled: boolean;
  80532. }
  80533. interface MouseEvent {
  80534. mozMovementX: number;
  80535. mozMovementY: number;
  80536. webkitMovementX: number;
  80537. webkitMovementY: number;
  80538. msMovementX: number;
  80539. msMovementY: number;
  80540. }
  80541. interface Navigator {
  80542. mozGetVRDevices: (any: any) => any;
  80543. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  80544. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  80545. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  80546. webkitGetGamepads(): Gamepad[];
  80547. msGetGamepads(): Gamepad[];
  80548. webkitGamepads(): Gamepad[];
  80549. }
  80550. interface HTMLVideoElement {
  80551. mozSrcObject: any;
  80552. }
  80553. interface Math {
  80554. fround(x: number): number;
  80555. imul(a: number, b: number): number;
  80556. log2(x: number): number;
  80557. }
  80558. interface WebGLRenderingContext {
  80559. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  80560. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  80561. vertexAttribDivisor(index: number, divisor: number): void;
  80562. createVertexArray(): any;
  80563. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  80564. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  80565. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  80566. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  80567. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  80568. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  80569. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  80570. // Queries
  80571. createQuery(): WebGLQuery;
  80572. deleteQuery(query: WebGLQuery): void;
  80573. beginQuery(target: number, query: WebGLQuery): void;
  80574. endQuery(target: number): void;
  80575. getQueryParameter(query: WebGLQuery, pname: number): any;
  80576. getQuery(target: number, pname: number): any;
  80577. MAX_SAMPLES: number;
  80578. RGBA8: number;
  80579. READ_FRAMEBUFFER: number;
  80580. DRAW_FRAMEBUFFER: number;
  80581. UNIFORM_BUFFER: number;
  80582. HALF_FLOAT_OES: number;
  80583. RGBA16F: number;
  80584. RGBA32F: number;
  80585. R32F: number;
  80586. RG32F: number;
  80587. RGB32F: number;
  80588. R16F: number;
  80589. RG16F: number;
  80590. RGB16F: number;
  80591. RED: number;
  80592. RG: number;
  80593. R8: number;
  80594. RG8: number;
  80595. UNSIGNED_INT_24_8: number;
  80596. DEPTH24_STENCIL8: number;
  80597. MIN: number;
  80598. MAX: number;
  80599. /* Multiple Render Targets */
  80600. drawBuffers(buffers: number[]): void;
  80601. readBuffer(src: number): void;
  80602. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  80603. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  80604. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  80605. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  80606. // Occlusion Query
  80607. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  80608. ANY_SAMPLES_PASSED: number;
  80609. QUERY_RESULT_AVAILABLE: number;
  80610. QUERY_RESULT: number;
  80611. }
  80612. interface WebGLProgram {
  80613. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  80614. }
  80615. interface EXT_disjoint_timer_query {
  80616. QUERY_COUNTER_BITS_EXT: number;
  80617. TIME_ELAPSED_EXT: number;
  80618. TIMESTAMP_EXT: number;
  80619. GPU_DISJOINT_EXT: number;
  80620. QUERY_RESULT_EXT: number;
  80621. QUERY_RESULT_AVAILABLE_EXT: number;
  80622. queryCounterEXT(query: WebGLQuery, target: number): void;
  80623. createQueryEXT(): WebGLQuery;
  80624. beginQueryEXT(target: number, query: WebGLQuery): void;
  80625. endQueryEXT(target: number): void;
  80626. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  80627. deleteQueryEXT(query: WebGLQuery): void;
  80628. }
  80629. interface WebGLUniformLocation {
  80630. _currentState: any;
  80631. }
  80632. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  80633. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  80634. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  80635. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  80636. interface WebGLRenderingContext {
  80637. readonly RASTERIZER_DISCARD: number;
  80638. readonly DEPTH_COMPONENT24: number;
  80639. readonly TEXTURE_3D: number;
  80640. readonly TEXTURE_2D_ARRAY: number;
  80641. readonly TEXTURE_COMPARE_FUNC: number;
  80642. readonly TEXTURE_COMPARE_MODE: number;
  80643. readonly COMPARE_REF_TO_TEXTURE: number;
  80644. readonly TEXTURE_WRAP_R: number;
  80645. readonly HALF_FLOAT: number;
  80646. readonly RGB8: number;
  80647. readonly RED_INTEGER: number;
  80648. readonly RG_INTEGER: number;
  80649. readonly RGB_INTEGER: number;
  80650. readonly RGBA_INTEGER: number;
  80651. readonly R8_SNORM: number;
  80652. readonly RG8_SNORM: number;
  80653. readonly RGB8_SNORM: number;
  80654. readonly RGBA8_SNORM: number;
  80655. readonly R8I: number;
  80656. readonly RG8I: number;
  80657. readonly RGB8I: number;
  80658. readonly RGBA8I: number;
  80659. readonly R8UI: number;
  80660. readonly RG8UI: number;
  80661. readonly RGB8UI: number;
  80662. readonly RGBA8UI: number;
  80663. readonly R16I: number;
  80664. readonly RG16I: number;
  80665. readonly RGB16I: number;
  80666. readonly RGBA16I: number;
  80667. readonly R16UI: number;
  80668. readonly RG16UI: number;
  80669. readonly RGB16UI: number;
  80670. readonly RGBA16UI: number;
  80671. readonly R32I: number;
  80672. readonly RG32I: number;
  80673. readonly RGB32I: number;
  80674. readonly RGBA32I: number;
  80675. readonly R32UI: number;
  80676. readonly RG32UI: number;
  80677. readonly RGB32UI: number;
  80678. readonly RGBA32UI: number;
  80679. readonly RGB10_A2UI: number;
  80680. readonly R11F_G11F_B10F: number;
  80681. readonly RGB9_E5: number;
  80682. readonly RGB10_A2: number;
  80683. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  80684. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  80685. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  80686. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  80687. readonly DEPTH_COMPONENT32F: number;
  80688. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  80689. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  80690. 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;
  80691. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  80692. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  80693. readonly TRANSFORM_FEEDBACK: number;
  80694. readonly INTERLEAVED_ATTRIBS: number;
  80695. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  80696. createTransformFeedback(): WebGLTransformFeedback;
  80697. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  80698. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  80699. beginTransformFeedback(primitiveMode: number): void;
  80700. endTransformFeedback(): void;
  80701. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  80702. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  80703. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  80704. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  80705. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  80706. }
  80707. interface ImageBitmap {
  80708. readonly width: number;
  80709. readonly height: number;
  80710. close(): void;
  80711. }
  80712. interface WebGLQuery extends WebGLObject {
  80713. }
  80714. declare var WebGLQuery: {
  80715. prototype: WebGLQuery;
  80716. new(): WebGLQuery;
  80717. };
  80718. interface WebGLSampler extends WebGLObject {
  80719. }
  80720. declare var WebGLSampler: {
  80721. prototype: WebGLSampler;
  80722. new(): WebGLSampler;
  80723. };
  80724. interface WebGLSync extends WebGLObject {
  80725. }
  80726. declare var WebGLSync: {
  80727. prototype: WebGLSync;
  80728. new(): WebGLSync;
  80729. };
  80730. interface WebGLTransformFeedback extends WebGLObject {
  80731. }
  80732. declare var WebGLTransformFeedback: {
  80733. prototype: WebGLTransformFeedback;
  80734. new(): WebGLTransformFeedback;
  80735. };
  80736. interface WebGLVertexArrayObject extends WebGLObject {
  80737. }
  80738. declare var WebGLVertexArrayObject: {
  80739. prototype: WebGLVertexArrayObject;
  80740. new(): WebGLVertexArrayObject;
  80741. };
  80742. interface Navigator {
  80743. readonly gpu: GPU | undefined;
  80744. }
  80745. interface GPUColorDict {
  80746. a: number;
  80747. b: number;
  80748. g: number;
  80749. r: number;
  80750. }
  80751. type GPUColor = [number, number, number, number] | GPUColorDict;
  80752. interface GPUOrigin2DDict {
  80753. x?: number;
  80754. y?: number;
  80755. }
  80756. type GPUOrigin2D = [number, number] | GPUOrigin2DDict;
  80757. interface GPUOrigin3DDict {
  80758. x?: number;
  80759. y?: number;
  80760. z?: number;
  80761. }
  80762. type GPUOrigin3D = [number, number, number] | GPUOrigin3DDict;
  80763. interface GPUExtent3DDict {
  80764. width: number;
  80765. height: number;
  80766. depth: number;
  80767. }
  80768. type GPUExtent3D = [number, number, number] | GPUExtent3DDict;
  80769. type GPUBindingResource =
  80770. | GPUSampler
  80771. | GPUTextureView
  80772. | GPUBufferBinding;
  80773. type GPUExtensionName =
  80774. | "texture-compression-bc"
  80775. | "timestamp-query"
  80776. | "pipeline-statistics-query"
  80777. | "depth-clamping"
  80778. | "depth24unorm-stencil8"
  80779. | "depth32float-stencil8";
  80780. type GPUAddressMode = "clamp-to-edge" | "repeat" | "mirror-repeat";
  80781. type GPUBindingType =
  80782. | "uniform-buffer"
  80783. | "storage-buffer"
  80784. | "readonly-storage-buffer"
  80785. | "sampler"
  80786. | "comparison-sampler"
  80787. | "sampled-texture"
  80788. | "readonly-storage-texture"
  80789. | "writeonly-storage-texture";
  80790. type GPUBlendFactor =
  80791. | "zero"
  80792. | "one"
  80793. | "src-color"
  80794. | "one-minus-src-color"
  80795. | "src-alpha"
  80796. | "one-minus-src-alpha"
  80797. | "dst-color"
  80798. | "one-minus-dst-color"
  80799. | "dst-alpha"
  80800. | "one-minus-dst-alpha"
  80801. | "src-alpha-saturated"
  80802. | "blend-color"
  80803. | "one-minus-blend-color";
  80804. type GPUBlendOperation =
  80805. | "add"
  80806. | "subtract"
  80807. | "reverse-subtract"
  80808. | "min"
  80809. | "max";
  80810. type GPUCompareFunction =
  80811. | "never"
  80812. | "less"
  80813. | "equal"
  80814. | "less-equal"
  80815. | "greater"
  80816. | "not-equal"
  80817. | "greater-equal"
  80818. | "always";
  80819. type GPUCullMode = "none" | "front" | "back";
  80820. type GPUFilterMode = "nearest" | "linear";
  80821. type GPUFrontFace = "ccw" | "cw";
  80822. type GPUIndexFormat = "uint16" | "uint32";
  80823. type GPUInputStepMode = "vertex" | "instance";
  80824. type GPULoadOp = "load";
  80825. type GPUPrimitiveTopology =
  80826. | "point-list"
  80827. | "line-list"
  80828. | "line-strip"
  80829. | "triangle-list"
  80830. | "triangle-strip";
  80831. type GPUStencilOperation =
  80832. | "keep"
  80833. | "zero"
  80834. | "replace"
  80835. | "invert"
  80836. | "increment-clamp"
  80837. | "decrement-clamp"
  80838. | "increment-wrap"
  80839. | "decrement-wrap";
  80840. type GPUStoreOp = "store" | "clear";
  80841. type GPUTextureDimension = "1d" | "2d" | "3d";
  80842. type GPUTextureFormat =
  80843. | "r8unorm"
  80844. | "r8snorm"
  80845. | "r8uint"
  80846. | "r8sint"
  80847. | "r16uint"
  80848. | "r16sint"
  80849. | "r16float"
  80850. | "rg8unorm"
  80851. | "rg8snorm"
  80852. | "rg8uint"
  80853. | "rg8sint"
  80854. | "r32uint"
  80855. | "r32sint"
  80856. | "r32float"
  80857. | "rg16uint"
  80858. | "rg16sint"
  80859. | "rg16float"
  80860. | "rgba8unorm"
  80861. | "rgba8unorm-srgb"
  80862. | "rgba8snorm"
  80863. | "rgba8uint"
  80864. | "rgba8sint"
  80865. | "bgra8unorm"
  80866. | "bgra8unorm-srgb"
  80867. | "rgb9e5ufloat"
  80868. | "rgb10a2unorm"
  80869. | "rg11b10ufloat"
  80870. | "rg32uint"
  80871. | "rg32sint"
  80872. | "rg32float"
  80873. | "rgba16uint"
  80874. | "rgba16sint"
  80875. | "rgba16float"
  80876. | "rgba32uint"
  80877. | "rgba32sint"
  80878. | "rgba32float"
  80879. | "stencil8"
  80880. | "depth16unorm"
  80881. | "depth24plus"
  80882. | "depth24plus-stencil8"
  80883. | "depth32float"
  80884. | "bc1-rgba-unorm"
  80885. | "bc1-rgba-unorm-srgb"
  80886. | "bc2-rgba-unorm"
  80887. | "bc2-rgba-unorm-srgb"
  80888. | "bc3-rgba-unorm"
  80889. | "bc3-rgba-unorm-srgb"
  80890. | "bc4-r-unorm"
  80891. | "bc4-r-snorm"
  80892. | "bc5-rg-unorm"
  80893. | "bc5-rg-snorm"
  80894. | "bc6h-rgb-ufloat"
  80895. | "bc6h-rgb-float"
  80896. | "bc7-rgba-unorm"
  80897. | "bc7-rgba-unorm-srgb"
  80898. | "depth24unorm-stencil8"
  80899. | "depth32float-stencil8";
  80900. type GPUTextureComponentType = "float" | "sint" | "uint" | "depth-comparison";
  80901. type GPUTextureViewDimension =
  80902. | "1d"
  80903. | "2d"
  80904. | "2d-array"
  80905. | "cube"
  80906. | "cube-array"
  80907. | "3d";
  80908. type GPUVertexFormat =
  80909. | "uchar2"
  80910. | "uchar4"
  80911. | "char2"
  80912. | "char4"
  80913. | "uchar2norm"
  80914. | "uchar4norm"
  80915. | "char2norm"
  80916. | "char4norm"
  80917. | "ushort2"
  80918. | "ushort4"
  80919. | "short2"
  80920. | "short4"
  80921. | "ushort2norm"
  80922. | "ushort4norm"
  80923. | "short2norm"
  80924. | "short4norm"
  80925. | "half2"
  80926. | "half4"
  80927. | "float"
  80928. | "float2"
  80929. | "float3"
  80930. | "float4"
  80931. | "uint"
  80932. | "uint2"
  80933. | "uint3"
  80934. | "uint4"
  80935. | "int"
  80936. | "int2"
  80937. | "int3"
  80938. | "int4";
  80939. type GPUTextureAspect = "all" | "stencil-only" | "depth-only";
  80940. type GPUBufferUsageFlags = number;
  80941. type GPUColorWriteFlags = number;
  80942. type GPUShaderStageFlags = number;
  80943. type GPUTextureUsageFlags = number;
  80944. type GPUMapModeFlags = number;
  80945. interface GPUBindGroupEntry {
  80946. binding: number;
  80947. resource: GPUBindingResource;
  80948. }
  80949. interface GPUBindGroupDescriptor extends GPUObjectDescriptorBase {
  80950. layout: GPUBindGroupLayout;
  80951. entries: Iterable<GPUBindGroupEntry>;
  80952. }
  80953. interface GPUBindGroupLayoutEntry {
  80954. binding: number;
  80955. visibility: GPUShaderStageFlags;
  80956. type: GPUBindingType;
  80957. hasDynamicOffset?: boolean;
  80958. minBufferBindingSize?: number;
  80959. viewDimension?: GPUTextureViewDimension;
  80960. textureComponentType?: GPUTextureComponentType;
  80961. storageTextureFormat?: GPUTextureFormat;
  80962. }
  80963. interface GPUBindGroupLayoutDescriptor
  80964. extends GPUObjectDescriptorBase {
  80965. entries: Iterable<GPUBindGroupLayoutEntry>;
  80966. }
  80967. interface GPUBlendDescriptor {
  80968. dstFactor?: GPUBlendFactor;
  80969. operation?: GPUBlendOperation;
  80970. srcFactor?: GPUBlendFactor;
  80971. }
  80972. interface GPUColorStateDescriptor {
  80973. format: GPUTextureFormat;
  80974. alphaBlend?: GPUBlendDescriptor;
  80975. colorBlend?: GPUBlendDescriptor;
  80976. writeMask?: GPUColorWriteFlags;
  80977. }
  80978. interface GPUBufferBinding {
  80979. buffer: GPUBuffer;
  80980. offset?: number;
  80981. size?: number;
  80982. }
  80983. interface GPUTextureDataLayout {
  80984. offset?: number;
  80985. bytesPerRow: number;
  80986. rowsPerImage?: number;
  80987. }
  80988. interface GPUBufferCopyView extends GPUTextureDataLayout {
  80989. buffer: GPUBuffer;
  80990. }
  80991. interface GPUTextureCopyView {
  80992. texture: GPUTexture;
  80993. mipLevel?: number;
  80994. origin?: GPUOrigin3D;
  80995. }
  80996. interface GPUImageBitmapCopyView {
  80997. imageBitmap: ImageBitmap;
  80998. origin?: GPUOrigin2D;
  80999. }
  81000. interface GPUBufferDescriptor extends GPUObjectDescriptorBase {
  81001. size: number;
  81002. usage: GPUBufferUsageFlags;
  81003. mappedAtCreation?: boolean;
  81004. }
  81005. interface GPUCommandEncoderDescriptor extends GPUObjectDescriptorBase {
  81006. label?: string;
  81007. measureExecutionTime?: boolean;
  81008. }
  81009. interface GPUComputePipelineDescriptor
  81010. extends GPUPipelineDescriptorBase {
  81011. computeStage: GPUProgrammableStageDescriptor;
  81012. }
  81013. interface GPUDepthStencilStateDescriptor {
  81014. format: GPUTextureFormat;
  81015. depthWriteEnabled?: boolean;
  81016. depthCompare?: GPUCompareFunction;
  81017. stencilFront?: GPUStencilStateFaceDescriptor;
  81018. stencilBack?: GPUStencilStateFaceDescriptor;
  81019. stencilReadMask?: number;
  81020. stencilWriteMask?: number;
  81021. }
  81022. interface GPUDeviceDescriptor extends GPUObjectDescriptorBase {
  81023. extensions?: Iterable<GPUExtensionName>;
  81024. limits?: GPULimits;
  81025. }
  81026. interface GPUFenceDescriptor extends GPUObjectDescriptorBase {
  81027. initialValue?: number;
  81028. label?: string;
  81029. signalQueue?: GPUQueue;
  81030. }
  81031. interface GPUVertexAttributeDescriptor {
  81032. format: GPUVertexFormat;
  81033. offset: number;
  81034. shaderLocation: number;
  81035. }
  81036. interface GPUVertexBufferLayoutDescriptor {
  81037. arrayStride: number;
  81038. stepMode?: GPUInputStepMode;
  81039. attributes: Iterable<GPUVertexAttributeDescriptor>;
  81040. }
  81041. interface GPUVertexStateDescriptor {
  81042. indexFormat?: GPUIndexFormat;
  81043. vertexBuffers?: Iterable<GPUVertexBufferLayoutDescriptor>;
  81044. }
  81045. interface GPULimits {
  81046. maxBindGroups?: number;
  81047. maxDynamicUniformBuffersPerPipelineLayout?: number;
  81048. maxDynamicStorageBuffersPerPipelineLayout?: number;
  81049. maxSampledTexturesPerShaderStage?: number;
  81050. maxSamplersPerShaderStage?: number;
  81051. maxStorageBuffersPerShaderStage?: number;
  81052. maxStorageTexturesPerShaderStage?: number;
  81053. maxUniformBuffersPerShaderStage?: number;
  81054. maxUniformBufferBindingSize?: number;
  81055. }
  81056. interface GPUPipelineDescriptorBase {
  81057. label?: string;
  81058. layout?: GPUPipelineLayout;
  81059. }
  81060. interface GPUPipelineLayoutDescriptor extends GPUObjectDescriptorBase {
  81061. bindGroupLayouts: Iterable<GPUBindGroupLayout>;
  81062. }
  81063. interface GPUProgrammableStageDescriptor {
  81064. module: GPUShaderModule;
  81065. entryPoint: string;
  81066. }
  81067. interface GPURasterizationStateDescriptor {
  81068. frontFace?: GPUFrontFace;
  81069. cullMode?: GPUCullMode;
  81070. clampDepth?: boolean;
  81071. depthBias?: number;
  81072. depthBiasSlopeScale?: number;
  81073. depthBiasClamp?: number;
  81074. }
  81075. interface GPURenderPassColorAttachmentDescriptor {
  81076. attachment: GPUTextureView;
  81077. resolveTarget?: GPUTextureView;
  81078. loadValue: GPULoadOp | GPUColor;
  81079. storeOp?: GPUStoreOp;
  81080. }
  81081. interface GPURenderPassDepthStencilAttachmentDescriptor {
  81082. attachment: GPUTextureView;
  81083. depthLoadValue: GPULoadOp | number;
  81084. depthStoreOp: GPUStoreOp;
  81085. depthReadOnly?: boolean;
  81086. stencilLoadValue: GPULoadOp | number;
  81087. stencilStoreOp: GPUStoreOp;
  81088. stencilReadOnly?: boolean;
  81089. }
  81090. interface GPURenderPassDescriptor extends GPUObjectDescriptorBase {
  81091. colorAttachments: Iterable<GPURenderPassColorAttachmentDescriptor>;
  81092. depthStencilAttachment?: GPURenderPassDepthStencilAttachmentDescriptor;
  81093. }
  81094. interface GPURenderPipelineDescriptor
  81095. extends GPUPipelineDescriptorBase {
  81096. vertexStage: GPUProgrammableStageDescriptor;
  81097. fragmentStage?: GPUProgrammableStageDescriptor;
  81098. primitiveTopology: GPUPrimitiveTopology;
  81099. rasterizationState?: GPURasterizationStateDescriptor;
  81100. colorStates: Iterable<GPUColorStateDescriptor>;
  81101. depthStencilState?: GPUDepthStencilStateDescriptor;
  81102. vertexState?: GPUVertexStateDescriptor;
  81103. sampleCount?: number;
  81104. sampleMask?: number;
  81105. alphaToCoverageEnabled?: boolean;
  81106. }
  81107. interface GPUSamplerDescriptor extends GPUObjectDescriptorBase {
  81108. addressModeU?: GPUAddressMode;
  81109. addressModeV?: GPUAddressMode;
  81110. addressModeW?: GPUAddressMode;
  81111. magFilter?: GPUFilterMode;
  81112. minFilter?: GPUFilterMode;
  81113. mipmapFilter?: GPUFilterMode;
  81114. lodMinClamp?: number;
  81115. lodMaxClamp?: number;
  81116. compare?: GPUCompareFunction;
  81117. maxAnisotropy?: number;
  81118. }
  81119. interface GPUShaderModuleDescriptor extends GPUObjectDescriptorBase {
  81120. code: Uint32Array | string;
  81121. label?: string;
  81122. sourceMap?: object;
  81123. }
  81124. interface GPUStencilStateFaceDescriptor {
  81125. compare?: GPUCompareFunction;
  81126. depthFailOp?: GPUStencilOperation;
  81127. passOp?: GPUStencilOperation;
  81128. failOp?: GPUStencilOperation;
  81129. }
  81130. interface GPUSwapChainDescriptor extends GPUObjectDescriptorBase {
  81131. device: GPUDevice;
  81132. format: GPUTextureFormat;
  81133. usage?: GPUTextureUsageFlags;
  81134. }
  81135. interface GPUTextureDescriptor extends GPUObjectDescriptorBase {
  81136. size: GPUExtent3D;
  81137. mipLevelCount?: number;
  81138. sampleCount?: number;
  81139. dimension?: GPUTextureDimension;
  81140. format: GPUTextureFormat;
  81141. usage: GPUTextureUsageFlags;
  81142. }
  81143. interface GPUTextureViewDescriptor extends GPUObjectDescriptorBase {
  81144. format?: GPUTextureFormat;
  81145. dimension?: GPUTextureViewDimension;
  81146. aspect?: GPUTextureAspect;
  81147. baseArrayLayer?: number;
  81148. baseMipLevel?: number;
  81149. arrayLayerCount?: number;
  81150. mipLevelCount?: number;
  81151. }
  81152. declare class GPUAdapter {
  81153. // https://michalzalecki.com/nominal-typing-in-typescript/#approach-1-class-with-a-private-property
  81154. private __brand: void;
  81155. readonly name: string;
  81156. readonly extensions: GPUExtensionName[];
  81157. readonly limits: Required<GPULimits>;
  81158. requestDevice(descriptor?: GPUDeviceDescriptor): Promise<GPUDevice | null>;
  81159. }
  81160. declare class GPUBindGroup implements GPUObjectBase {
  81161. private __brand: void;
  81162. label: string | undefined;
  81163. }
  81164. declare class GPUBindGroupLayout implements GPUObjectBase {
  81165. private __brand: void;
  81166. label: string | undefined;
  81167. }
  81168. declare class GPUBuffer implements GPUObjectBase {
  81169. private __brand: void;
  81170. label: string | undefined;
  81171. destroy(): void;
  81172. unmap(): void;
  81173. mapAsync(mode: GPUMapModeFlags, offset?: number, size?: number): Promise<void>;
  81174. getMappedRange(offset?: number, size?: number): ArrayBuffer;
  81175. }
  81176. declare class GPUCommandBuffer implements GPUObjectBase {
  81177. private __brand: void;
  81178. label: string | undefined;
  81179. readonly executionTime: Promise<number>;
  81180. }
  81181. interface GPUCommandBufferDescriptor extends GPUObjectDescriptorBase { }
  81182. declare class GPUCommandEncoder implements GPUObjectBase {
  81183. private __brand: void;
  81184. label: string | undefined;
  81185. beginComputePass(
  81186. descriptor?: GPUComputePassDescriptor
  81187. ): GPUComputePassEncoder;
  81188. beginRenderPass(descriptor: GPURenderPassDescriptor): GPURenderPassEncoder;
  81189. copyBufferToBuffer(
  81190. source: GPUBuffer,
  81191. sourceOffset: number,
  81192. destination: GPUBuffer,
  81193. destinationOffset: number,
  81194. size: number
  81195. ): void;
  81196. copyBufferToTexture(
  81197. source: GPUBufferCopyView,
  81198. destination: GPUTextureCopyView,
  81199. copySize: GPUExtent3D
  81200. ): void;
  81201. copyTextureToBuffer(
  81202. source: GPUTextureCopyView,
  81203. destination: GPUBufferCopyView,
  81204. copySize: GPUExtent3D
  81205. ): void;
  81206. copyTextureToTexture(
  81207. source: GPUTextureCopyView,
  81208. destination: GPUTextureCopyView,
  81209. copySize: GPUExtent3D
  81210. ): void;
  81211. finish(descriptor?: GPUCommandBufferDescriptor): GPUCommandBuffer;
  81212. writeTimestamp(querySet: GPUQuerySet, queryIndex: number): void;
  81213. popDebugGroup(): void;
  81214. pushDebugGroup(groupLabel: string): void;
  81215. insertDebugMarker(markerLabel: string): void;
  81216. }
  81217. interface GPUComputePassDescriptor extends GPUObjectDescriptorBase { }
  81218. declare class GPUComputePassEncoder implements GPUObjectBase, GPUProgrammablePassEncoder {
  81219. private __brand: void;
  81220. label: string | undefined;
  81221. setBindGroup(
  81222. index: number,
  81223. bindGroup: GPUBindGroup,
  81224. dynamicOffsets?: Iterable<number>
  81225. ): void;
  81226. popDebugGroup(): void;
  81227. pushDebugGroup(groupLabel: string): void;
  81228. insertDebugMarker(markerLabel: string): void;
  81229. setPipeline(pipeline: GPUComputePipeline): void;
  81230. dispatch(x: number, y?: number, z?: number): void;
  81231. dispatchIndirect(indirectBuffer: GPUBuffer, indirectOffset: number): void;
  81232. writeTimestamp(querySet: GPUQuerySet, queryIndex: number): void;
  81233. beginPipelineStatisticsQuery(querySet: GPUQuerySet, queryIndex: number): void;
  81234. endPipelineStatisticsQuery(querySet: GPUQuerySet, queryIndex: number): void;
  81235. endPass(): void;
  81236. }
  81237. declare class GPUComputePipeline implements GPUPipelineBase {
  81238. private __brand: void;
  81239. label: string | undefined;
  81240. getBindGroupLayout(index: number): GPUBindGroupLayout;
  81241. }
  81242. interface GPUObjectBase {
  81243. label: string | undefined;
  81244. }
  81245. interface GPUObjectDescriptorBase {
  81246. label?: string;
  81247. }
  81248. // SwapChain / CanvasContext
  81249. declare class GPUCanvasContext {
  81250. private __brand: void;
  81251. configureSwapChain(descriptor: GPUSwapChainDescriptor): GPUSwapChain;
  81252. getSwapChainPreferredFormat(device: GPUDevice): Promise<GPUTextureFormat>;
  81253. }
  81254. declare class GPUDevice extends EventTarget implements GPUObjectBase {
  81255. private __brand: void;
  81256. label: string | undefined;
  81257. readonly adapter: GPUAdapter;
  81258. readonly extensions: GPUExtensionName[];
  81259. readonly limits: Required<GPULimits>;
  81260. createBindGroup(descriptor: GPUBindGroupDescriptor): GPUBindGroup;
  81261. createBindGroupLayout(
  81262. descriptor: GPUBindGroupLayoutDescriptor
  81263. ): GPUBindGroupLayout;
  81264. createBuffer(descriptor: GPUBufferDescriptor): GPUBuffer;
  81265. createPipelineLayout(
  81266. descriptor: GPUPipelineLayoutDescriptor
  81267. ): GPUPipelineLayout;
  81268. createSampler(descriptor?: GPUSamplerDescriptor): GPUSampler;
  81269. createShaderModule(descriptor: GPUShaderModuleDescriptor): GPUShaderModule;
  81270. createTexture(descriptor: GPUTextureDescriptor): GPUTexture;
  81271. createComputePipeline(
  81272. descriptor: GPUComputePipelineDescriptor
  81273. ): GPUComputePipeline;
  81274. createRenderPipeline(
  81275. descriptor: GPURenderPipelineDescriptor
  81276. ): GPURenderPipeline;
  81277. createReadyComputePipeline(
  81278. descriptor: GPUComputePipelineDescriptor
  81279. ): Promise<GPUComputePipeline>;
  81280. createReadyRenderPipeline(
  81281. descriptor: GPURenderPipelineDescriptor
  81282. ): Promise<GPURenderPipeline>;
  81283. createCommandEncoder(
  81284. descriptor?: GPUCommandEncoderDescriptor
  81285. ): GPUCommandEncoder;
  81286. createRenderBundleEncoder(
  81287. descriptor: GPURenderBundleEncoderDescriptor
  81288. ): GPURenderBundleEncoder;
  81289. createQuerySet(descriptor: GPUQuerySetDescriptor): GPUQuerySet;
  81290. defaultQueue: GPUQueue;
  81291. pushErrorScope(filter: GPUErrorFilter): void;
  81292. popErrorScope(): Promise<GPUError | null>;
  81293. onuncapturederror: Event | undefined;
  81294. readonly lost: Promise<GPUDeviceLostInfo>;
  81295. }
  81296. declare class GPUFence implements GPUObjectBase {
  81297. private __brand: void;
  81298. label: string | undefined;
  81299. getCompletedValue(): number;
  81300. onCompletion(completionValue: number): Promise<void>;
  81301. }
  81302. interface GPUPipelineBase extends GPUObjectBase {
  81303. getBindGroupLayout(index: number): GPUBindGroupLayout;
  81304. }
  81305. declare class GPUPipelineLayout implements GPUObjectBase {
  81306. private __brand: void;
  81307. label: string | undefined;
  81308. }
  81309. interface GPUProgrammablePassEncoder {
  81310. setBindGroup(
  81311. index: number,
  81312. bindGroup: GPUBindGroup,
  81313. dynamicOffsets?: Iterable<number>
  81314. ): void;
  81315. popDebugGroup(): void;
  81316. pushDebugGroup(groupLabel: string): void;
  81317. insertDebugMarker(markerLabel: string): void;
  81318. }
  81319. declare class GPUQueue implements GPUObjectBase {
  81320. private __brand: void;
  81321. label: string | undefined;
  81322. signal(fence: GPUFence, signalValue: number): void;
  81323. submit(commandBuffers: Iterable<GPUCommandBuffer>): void;
  81324. createFence(descriptor?: GPUFenceDescriptor): GPUFence;
  81325. writeBuffer(buffer: GPUBuffer,
  81326. bufferOffset: number,
  81327. data: BufferSource | ArrayBuffer,
  81328. dataOffset?: number,
  81329. size?: number): void;
  81330. writeTexture(destination: GPUTextureCopyView,
  81331. data: BufferSource | ArrayBuffer,
  81332. dataLayout: GPUTextureDataLayout,
  81333. size: GPUExtent3D): void;
  81334. copyImageBitmapToTexture(
  81335. source: GPUImageBitmapCopyView,
  81336. destination: GPUTextureCopyView,
  81337. copySize: GPUExtent3D
  81338. ): void;
  81339. }
  81340. type GPUQueryType =
  81341. | "occlusion"
  81342. | "timestamp"
  81343. | "pipeline-statistics";
  81344. type GPUPipelineStatisticName =
  81345. | "vertex-shader-invocations"
  81346. | "clipper-invocations"
  81347. | "clipper-primitives-out"
  81348. | "fragment-shader-invocations"
  81349. | "compute-shader-invocations";
  81350. interface GPUQuerySetDescriptor extends GPUObjectDescriptorBase {
  81351. type: GPUQueryType;
  81352. count: number;
  81353. pipelineStatistics?: Iterable<GPUPipelineStatisticName>;
  81354. }
  81355. declare class GPUQuerySet implements GPUObjectBase {
  81356. private __brand: void;
  81357. label: string | undefined;
  81358. destroy(): void;
  81359. }
  81360. interface GPURenderEncoderBase {
  81361. setPipeline(pipeline: GPURenderPipeline): void;
  81362. setIndexBuffer(buffer: GPUBuffer, offset?: number, size?: number): void;
  81363. setIndexBuffer(buffer: GPUBuffer, indexFormat: GPUIndexFormat, offset?: number, size?: number): void;
  81364. setVertexBuffer(slot: number, buffer: GPUBuffer, offset?: number, size?: number): void;
  81365. draw(
  81366. vertexCount: number,
  81367. instanceCount?: number,
  81368. firstVertex?: number,
  81369. firstInstance?: number
  81370. ): void;
  81371. drawIndexed(
  81372. indexCount: number,
  81373. instanceCount?: number,
  81374. firstIndex?: number,
  81375. baseVertex?: number,
  81376. firstInstance?: number
  81377. ): void;
  81378. drawIndirect(indirectBuffer: GPUBuffer, indirectOffset: number): void;
  81379. drawIndexedIndirect(
  81380. indirectBuffer: GPUBuffer,
  81381. indirectOffset: number
  81382. ): void;
  81383. }
  81384. declare class GPURenderPassEncoder implements GPUObjectBase, GPUProgrammablePassEncoder, GPURenderEncoderBase {
  81385. private __brand: void;
  81386. label: string | undefined;
  81387. setBindGroup(
  81388. index: number,
  81389. bindGroup: GPUBindGroup,
  81390. dynamicOffsets?: Iterable<number>
  81391. ): void;
  81392. popDebugGroup(): void;
  81393. pushDebugGroup(groupLabel: string): void;
  81394. insertDebugMarker(markerLabel: string): void;
  81395. setPipeline(pipeline: GPURenderPipeline): void;
  81396. setIndexBuffer(buffer: GPUBuffer, offset?: number): void;
  81397. setIndexBuffer(buffer: GPUBuffer, indexFormat: GPUIndexFormat, offset?: number, size?: number): void;
  81398. setVertexBuffer(slot: number, buffer: GPUBuffer, offset?: number): void;
  81399. draw(
  81400. vertexCount: number,
  81401. instanceCount?: number,
  81402. firstVertex?: number,
  81403. firstInstance?: number
  81404. ): void;
  81405. drawIndexed(
  81406. indexCount: number,
  81407. instanceCount?: number,
  81408. firstIndex?: number,
  81409. baseVertex?: number,
  81410. firstInstance?: number
  81411. ): void;
  81412. drawIndirect(indirectBuffer: GPUBuffer, indirectOffset: number): void;
  81413. drawIndexedIndirect(
  81414. indirectBuffer: GPUBuffer,
  81415. indirectOffset: number
  81416. ): void;
  81417. setViewport(
  81418. x: number,
  81419. y: number,
  81420. width: number,
  81421. height: number,
  81422. minDepth: number,
  81423. maxDepth: number
  81424. ): void;
  81425. setScissorRect(x: number, y: number, width: number, height: number): void;
  81426. setBlendColor(color: GPUColor): void;
  81427. setStencilReference(reference: number): void;
  81428. writeTimestamp(querySet: GPUQuerySet, queryIndex: number): void;
  81429. beginOcclusionQuery(queryIndex: number): void;
  81430. endOcclusionQuery(): void;
  81431. beginPipelineStatisticsQuery(querySet: GPUQuerySet, queryIndex: number): void;
  81432. endPipelineStatisticsQuery(querySet: GPUQuerySet, queryIndex: number): void;
  81433. executeBundles(bundles: Iterable<GPURenderBundle>): void;
  81434. endPass(): void;
  81435. }
  81436. interface GPURenderBundleDescriptor extends GPUObjectDescriptorBase { }
  81437. declare class GPURenderBundle implements GPUObjectBase {
  81438. private __brand: void;
  81439. label: string | undefined;
  81440. }
  81441. declare class GPURenderBundleEncoder implements GPURenderEncoderBase {
  81442. private __brand: void;
  81443. label: string | undefined;
  81444. setBindGroup(
  81445. index: number,
  81446. bindGroup: GPUBindGroup,
  81447. dynamicOffsets?: Iterable<number>
  81448. ): void;
  81449. popDebugGroup(): void;
  81450. pushDebugGroup(groupLabel: string): void;
  81451. insertDebugMarker(markerLabel: string): void;
  81452. setPipeline(pipeline: GPURenderPipeline): void;
  81453. setIndexBuffer(buffer: GPUBuffer, offset?: number): void;
  81454. setIndexBuffer(buffer: GPUBuffer, indexFormat: GPUIndexFormat, offset?: number, size?: number): void;
  81455. setVertexBuffer(slot: number, buffer: GPUBuffer, offset?: number): void;
  81456. draw(
  81457. vertexCount: number,
  81458. instanceCount?: number,
  81459. firstVertex?: number,
  81460. firstInstance?: number
  81461. ): void;
  81462. drawIndexed(
  81463. indexCount: number,
  81464. instanceCount?: number,
  81465. firstIndex?: number,
  81466. baseVertex?: number,
  81467. firstInstance?: number
  81468. ): void;
  81469. drawIndirect(indirectBuffer: GPUBuffer, indirectOffset: number): void;
  81470. drawIndexedIndirect(
  81471. indirectBuffer: GPUBuffer,
  81472. indirectOffset: number
  81473. ): void;
  81474. finish(descriptor?: GPURenderBundleDescriptor): GPURenderBundle;
  81475. }
  81476. interface GPURenderBundleEncoderDescriptor
  81477. extends GPUObjectDescriptorBase {
  81478. colorFormats: Iterable<GPUTextureFormat>;
  81479. depthStencilFormat?: GPUTextureFormat;
  81480. sampleCount?: number;
  81481. }
  81482. declare class GPURenderPipeline implements GPUPipelineBase {
  81483. private __brand: void;
  81484. label: string | undefined;
  81485. getBindGroupLayout(index: number): GPUBindGroupLayout;
  81486. }
  81487. declare class GPUSampler implements GPUObjectBase {
  81488. private __brand: void;
  81489. label: string | undefined;
  81490. }
  81491. type GPUCompilationMessageType =
  81492. | "error"
  81493. | "warning"
  81494. | "info";
  81495. interface GPUCompilationMessage {
  81496. readonly message: string;
  81497. readonly type: GPUCompilationMessageType;
  81498. readonly lineNum: number;
  81499. readonly linePos: number;
  81500. }
  81501. interface GPUCompilationInfo {
  81502. readonly messages: readonly GPUCompilationMessage[];
  81503. }
  81504. declare class GPUShaderModule implements GPUObjectBase {
  81505. private __brand: void;
  81506. label: string | undefined;
  81507. compilationInfo(): Promise<GPUCompilationInfo>;
  81508. }
  81509. declare class GPUSwapChain implements GPUObjectBase {
  81510. private __brand: void;
  81511. label: string | undefined;
  81512. getCurrentTexture(): GPUTexture;
  81513. }
  81514. declare class GPUTexture implements GPUObjectBase {
  81515. private __brand: void;
  81516. label: string | undefined;
  81517. createView(descriptor?: GPUTextureViewDescriptor): GPUTextureView;
  81518. destroy(): void;
  81519. }
  81520. declare class GPUTextureView implements GPUObjectBase {
  81521. private __brand: void;
  81522. label: string | undefined;
  81523. }
  81524. type GPUPowerPreference = "low-power" | "high-performance";
  81525. interface GPURequestAdapterOptions {
  81526. powerPreference?: GPUPowerPreference;
  81527. }
  81528. declare class GPU {
  81529. private __brand: void;
  81530. requestAdapter(options?: GPURequestAdapterOptions): Promise<GPUAdapter | null>;
  81531. }
  81532. // ****************************************************************************
  81533. // ERROR SCOPES
  81534. // ****************************************************************************
  81535. type GPUErrorFilter = "out-of-memory" | "validation";
  81536. declare class GPUOutOfMemoryError {
  81537. private __brand: void;
  81538. constructor();
  81539. }
  81540. declare class GPUValidationError {
  81541. private __brand: void;
  81542. constructor(message: string);
  81543. readonly message: string;
  81544. }
  81545. type GPUError = GPUOutOfMemoryError | GPUValidationError;
  81546. // ****************************************************************************
  81547. // TELEMETRY
  81548. // ****************************************************************************
  81549. declare class GPUUncapturedErrorEvent extends Event {
  81550. private __brand: void;
  81551. constructor(
  81552. type: string,
  81553. gpuUncapturedErrorEventInitDict: GPUUncapturedErrorEventInit
  81554. );
  81555. readonly error: GPUError;
  81556. }
  81557. interface GPUUncapturedErrorEventInit extends EventInit {
  81558. error: GPUError;
  81559. }
  81560. declare class GPUDeviceLostInfo {
  81561. private __brand: void;
  81562. readonly message: string;
  81563. }
  81564. // Type definitions for WebVR API
  81565. // Project: https://w3c.github.io/webvr/
  81566. // Definitions by: six a <https://github.com/lostfictions>
  81567. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  81568. interface VRDisplay extends EventTarget {
  81569. /**
  81570. * Dictionary of capabilities describing the VRDisplay.
  81571. */
  81572. readonly capabilities: VRDisplayCapabilities;
  81573. /**
  81574. * z-depth defining the far plane of the eye view frustum
  81575. * enables mapping of values in the render target depth
  81576. * attachment to scene coordinates. Initially set to 10000.0.
  81577. */
  81578. depthFar: number;
  81579. /**
  81580. * z-depth defining the near plane of the eye view frustum
  81581. * enables mapping of values in the render target depth
  81582. * attachment to scene coordinates. Initially set to 0.01.
  81583. */
  81584. depthNear: number;
  81585. /**
  81586. * An identifier for this distinct VRDisplay. Used as an
  81587. * association point in the Gamepad API.
  81588. */
  81589. readonly displayId: number;
  81590. /**
  81591. * A display name, a user-readable name identifying it.
  81592. */
  81593. readonly displayName: string;
  81594. readonly isConnected: boolean;
  81595. readonly isPresenting: boolean;
  81596. /**
  81597. * If this VRDisplay supports room-scale experiences, the optional
  81598. * stage attribute contains details on the room-scale parameters.
  81599. */
  81600. readonly stageParameters: VRStageParameters | null;
  81601. /**
  81602. * Passing the value returned by `requestAnimationFrame` to
  81603. * `cancelAnimationFrame` will unregister the callback.
  81604. * @param handle Define the hanle of the request to cancel
  81605. */
  81606. cancelAnimationFrame(handle: number): void;
  81607. /**
  81608. * Stops presenting to the VRDisplay.
  81609. * @returns a promise to know when it stopped
  81610. */
  81611. exitPresent(): Promise<void>;
  81612. /**
  81613. * Return the current VREyeParameters for the given eye.
  81614. * @param whichEye Define the eye we want the parameter for
  81615. * @returns the eye parameters
  81616. */
  81617. getEyeParameters(whichEye: string): VREyeParameters;
  81618. /**
  81619. * Populates the passed VRFrameData with the information required to render
  81620. * the current frame.
  81621. * @param frameData Define the data structure to populate
  81622. * @returns true if ok otherwise false
  81623. */
  81624. getFrameData(frameData: VRFrameData): boolean;
  81625. /**
  81626. * Get the layers currently being presented.
  81627. * @returns the list of VR layers
  81628. */
  81629. getLayers(): VRLayer[];
  81630. /**
  81631. * Return a VRPose containing the future predicted pose of the VRDisplay
  81632. * when the current frame will be presented. The value returned will not
  81633. * change until JavaScript has returned control to the browser.
  81634. *
  81635. * The VRPose will contain the position, orientation, velocity,
  81636. * and acceleration of each of these properties.
  81637. * @returns the pose object
  81638. */
  81639. getPose(): VRPose;
  81640. /**
  81641. * Return the current instantaneous pose of the VRDisplay, with no
  81642. * prediction applied.
  81643. * @returns the current instantaneous pose
  81644. */
  81645. getImmediatePose(): VRPose;
  81646. /**
  81647. * The callback passed to `requestAnimationFrame` will be called
  81648. * any time a new frame should be rendered. When the VRDisplay is
  81649. * presenting the callback will be called at the native refresh
  81650. * rate of the HMD. When not presenting this function acts
  81651. * identically to how window.requestAnimationFrame acts. Content should
  81652. * make no assumptions of frame rate or vsync behavior as the HMD runs
  81653. * asynchronously from other displays and at differing refresh rates.
  81654. * @param callback Define the eaction to run next frame
  81655. * @returns the request handle it
  81656. */
  81657. requestAnimationFrame(callback: FrameRequestCallback): number;
  81658. /**
  81659. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  81660. * Repeat calls while already presenting will update the VRLayers being displayed.
  81661. * @param layers Define the list of layer to present
  81662. * @returns a promise to know when the request has been fulfilled
  81663. */
  81664. requestPresent(layers: VRLayer[]): Promise<void>;
  81665. /**
  81666. * Reset the pose for this display, treating its current position and
  81667. * orientation as the "origin/zero" values. VRPose.position,
  81668. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  81669. * updated when calling resetPose(). This should be called in only
  81670. * sitting-space experiences.
  81671. */
  81672. resetPose(): void;
  81673. /**
  81674. * The VRLayer provided to the VRDisplay will be captured and presented
  81675. * in the HMD. Calling this function has the same effect on the source
  81676. * canvas as any other operation that uses its source image, and canvases
  81677. * created without preserveDrawingBuffer set to true will be cleared.
  81678. * @param pose Define the pose to submit
  81679. */
  81680. submitFrame(pose?: VRPose): void;
  81681. }
  81682. declare var VRDisplay: {
  81683. prototype: VRDisplay;
  81684. new(): VRDisplay;
  81685. };
  81686. interface VRLayer {
  81687. leftBounds?: number[] | Float32Array | null;
  81688. rightBounds?: number[] | Float32Array | null;
  81689. source?: HTMLCanvasElement | null;
  81690. }
  81691. interface VRDisplayCapabilities {
  81692. readonly canPresent: boolean;
  81693. readonly hasExternalDisplay: boolean;
  81694. readonly hasOrientation: boolean;
  81695. readonly hasPosition: boolean;
  81696. readonly maxLayers: number;
  81697. }
  81698. interface VREyeParameters {
  81699. /** @deprecated */
  81700. readonly fieldOfView: VRFieldOfView;
  81701. readonly offset: Float32Array;
  81702. readonly renderHeight: number;
  81703. readonly renderWidth: number;
  81704. }
  81705. interface VRFieldOfView {
  81706. readonly downDegrees: number;
  81707. readonly leftDegrees: number;
  81708. readonly rightDegrees: number;
  81709. readonly upDegrees: number;
  81710. }
  81711. interface VRFrameData {
  81712. readonly leftProjectionMatrix: Float32Array;
  81713. readonly leftViewMatrix: Float32Array;
  81714. readonly pose: VRPose;
  81715. readonly rightProjectionMatrix: Float32Array;
  81716. readonly rightViewMatrix: Float32Array;
  81717. readonly timestamp: number;
  81718. }
  81719. interface VRPose {
  81720. readonly angularAcceleration: Float32Array | null;
  81721. readonly angularVelocity: Float32Array | null;
  81722. readonly linearAcceleration: Float32Array | null;
  81723. readonly linearVelocity: Float32Array | null;
  81724. readonly orientation: Float32Array | null;
  81725. readonly position: Float32Array | null;
  81726. readonly timestamp: number;
  81727. }
  81728. interface VRStageParameters {
  81729. sittingToStandingTransform?: Float32Array;
  81730. sizeX?: number;
  81731. sizeY?: number;
  81732. }
  81733. interface Navigator {
  81734. getVRDisplays(): Promise<VRDisplay[]>;
  81735. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  81736. }
  81737. interface Window {
  81738. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  81739. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  81740. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  81741. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  81742. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  81743. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  81744. }
  81745. interface Gamepad {
  81746. readonly displayId: number;
  81747. }
  81748. /**
  81749. * Available session modes
  81750. */
  81751. type XRSessionMode = "inline" | "immersive-vr" | "immersive-ar";
  81752. /**
  81753. * Reference space types
  81754. */
  81755. type XRReferenceSpaceType = "viewer" | "local" | "local-floor" | "bounded-floor" | "unbounded";
  81756. type XREnvironmentBlendMode = "opaque" | "additive" | "alpha-blend";
  81757. type XRVisibilityState = "visible" | "visible-blurred" | "hidden";
  81758. /**
  81759. * Handedness types
  81760. */
  81761. type XRHandedness = "none" | "left" | "right";
  81762. /**
  81763. * InputSource target ray modes
  81764. */
  81765. type XRTargetRayMode = "gaze" | "tracked-pointer" | "screen";
  81766. /**
  81767. * Eye types
  81768. */
  81769. type XREye = "none" | "left" | "right";
  81770. /**
  81771. * Type of XR events available
  81772. */
  81773. type XREventType = "devicechange" | "visibilitychange" | "end" | "inputsourceschange" | "select" | "selectstart" | "selectend" | "squeeze" | "squeezestart" | "squeezeend" | "reset";
  81774. type XRFrameRequestCallback = (time: DOMHighResTimeStamp, frame: XRFrame) => void;
  81775. type XRPlaneSet = Set<XRPlane>;
  81776. type XRAnchorSet = Set<XRAnchor>;
  81777. type XREventHandler = (callback: any) => void;
  81778. interface XRLayer extends EventTarget {}
  81779. interface XRSessionInit {
  81780. optionalFeatures?: string[];
  81781. requiredFeatures?: string[];
  81782. trackedImages?: XRTrackedImageInit[];
  81783. }
  81784. interface XRSessionEvent extends Event {
  81785. readonly session: XRSession;
  81786. }
  81787. interface XRSystem {
  81788. isSessionSupported: (sessionMode: XRSessionMode) => Promise<boolean>;
  81789. requestSession: (sessionMode: XRSessionMode, sessionInit?: any) => Promise<XRSession>;
  81790. }
  81791. interface XRViewport {
  81792. readonly x: number;
  81793. readonly y: number;
  81794. readonly width: number;
  81795. readonly height: number;
  81796. }
  81797. interface XRWebGLLayerInit {
  81798. antialias?: boolean;
  81799. depth?: boolean;
  81800. stencil?: boolean;
  81801. alpha?: boolean;
  81802. multiview?: boolean;
  81803. framebufferScaleFactor?: number;
  81804. }
  81805. declare class XRWebGLLayer {
  81806. static getNativeFramebufferScaleFactor(session: XRSession): number;
  81807. constructor(session: XRSession, context: WebGLRenderingContext | WebGL2RenderingContext, layerInit?: XRWebGLLayerInit);
  81808. readonly antialias: boolean;
  81809. readonly framebuffer: WebGLFramebuffer;
  81810. readonly framebufferWidth: number;
  81811. readonly framebufferHeight: number;
  81812. readonly ignoreDepthValues: boolean;
  81813. getViewport: (view: XRView) => XRViewport;
  81814. }
  81815. // tslint:disable-next-line no-empty-interface
  81816. interface XRSpace extends EventTarget {}
  81817. interface XRRenderState {
  81818. readonly baseLayer?: XRWebGLLayer;
  81819. readonly depthFar: number;
  81820. readonly depthNear: number;
  81821. readonly inlineVerticalFieldOfView?: number;
  81822. }
  81823. interface XRRenderStateInit extends XRRenderState {
  81824. baseLayer: XRWebGLLayer;
  81825. depthFar: number;
  81826. depthNear: number;
  81827. inlineVerticalFieldOfView?: number;
  81828. layers?: XRLayer[];
  81829. }
  81830. interface XRReferenceSpace extends XRSpace {
  81831. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  81832. onreset: XREventHandler;
  81833. }
  81834. interface XRBoundedReferenceSpace extends XRSpace {
  81835. readonly boundsGeometry: DOMPointReadOnly[];
  81836. }
  81837. interface XRInputSource {
  81838. readonly handedness: XRHandedness;
  81839. readonly targetRayMode: XRTargetRayMode;
  81840. readonly targetRaySpace: XRSpace;
  81841. readonly gripSpace?: XRSpace;
  81842. readonly gamepad?: Gamepad;
  81843. readonly profiles: Array<string>;
  81844. readonly hand?: XRHand;
  81845. }
  81846. interface XRPose {
  81847. readonly transform: XRRigidTransform;
  81848. readonly emulatedPosition: boolean;
  81849. }
  81850. interface XRWorldInformation {
  81851. detectedPlanes?: XRPlaneSet;
  81852. }
  81853. interface XRFrame {
  81854. readonly session: XRSession;
  81855. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  81856. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  81857. // AR
  81858. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult>;
  81859. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  81860. // Anchors
  81861. trackedAnchors?: XRAnchorSet;
  81862. createAnchor?(pose: XRRigidTransform, space: XRSpace): Promise<XRAnchor>;
  81863. // World geometries
  81864. worldInformation?: XRWorldInformation;
  81865. // Hand tracking
  81866. getJointPose?(joint: XRJointSpace, baseSpace: XRSpace): XRJointPose;
  81867. // Image tracking
  81868. getImageTrackingResults?(): Array<XRImageTrackingResult>;
  81869. }
  81870. interface XRInputSourceEvent extends Event {
  81871. readonly frame: XRFrame;
  81872. readonly inputSource: XRInputSource;
  81873. }
  81874. type XRInputSourceArray = XRInputSource[];
  81875. interface XRSession {
  81876. addEventListener(type: XREventType, listener: XREventHandler, options?: boolean | AddEventListenerOptions): void;
  81877. removeEventListener(type: XREventType, listener: XREventHandler, options?: boolean | EventListenerOptions): void;
  81878. /**
  81879. * Returns a list of this session's XRInputSources, each representing an input device
  81880. * used to control the camera and/or scene.
  81881. */
  81882. readonly inputSources: Array<XRInputSource>;
  81883. /**
  81884. * object which contains options affecting how the imagery is rendered.
  81885. * This includes things such as the near and far clipping planes
  81886. */
  81887. readonly renderState: XRRenderState;
  81888. readonly visibilityState: XRVisibilityState;
  81889. /**
  81890. * Removes a callback from the animation frame painting callback from
  81891. * XRSession's set of animation frame rendering callbacks, given the
  81892. * identifying handle returned by a previous call to requestAnimationFrame().
  81893. */
  81894. cancelAnimationFrame: (handle: number) => void;
  81895. /**
  81896. * Ends the WebXR session. Returns a promise which resolves when the
  81897. * session has been shut down.
  81898. */
  81899. end(): Promise<void>;
  81900. /**
  81901. * Schedules the specified method to be called the next time the user agent
  81902. * is working on rendering an animation frame for the WebXR device. Returns an
  81903. * integer value which can be used to identify the request for the purposes of
  81904. * canceling the callback using cancelAnimationFrame(). This method is comparable
  81905. * to the Window.requestAnimationFrame() method.
  81906. */
  81907. requestAnimationFrame: XRFrameRequestCallback;
  81908. /**
  81909. * Requests that a new XRReferenceSpace of the specified type be created.
  81910. * Returns a promise which resolves with the XRReferenceSpace or
  81911. * XRBoundedReferenceSpace which was requested, or throws a NotSupportedError if
  81912. * the requested space type isn't supported by the device.
  81913. */
  81914. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace | XRBoundedReferenceSpace>;
  81915. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  81916. onend: XREventHandler;
  81917. oninputsourceschange: XREventHandler;
  81918. onselect: XREventHandler;
  81919. onselectstart: XREventHandler;
  81920. onselectend: XREventHandler;
  81921. onsqueeze: XREventHandler;
  81922. onsqueezestart: XREventHandler;
  81923. onsqueezeend: XREventHandler;
  81924. onvisibilitychange: XREventHandler;
  81925. // hit test
  81926. requestHitTestSource?(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  81927. requestHitTestSourceForTransientInput?(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  81928. // legacy AR hit test
  81929. requestHitTest?(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  81930. // legacy plane detection
  81931. updateWorldTrackingState?(options: { planeDetectionState?: { enabled: boolean } }): void;
  81932. // image tracking
  81933. getTrackedImageScores?(): XRImageTrackingScore[];
  81934. }
  81935. interface XRViewerPose extends XRPose {
  81936. readonly views: Array<XRView>;
  81937. }
  81938. declare class XRRigidTransform {
  81939. constructor(position?: DOMPointInit, direction?: DOMPointInit);
  81940. position: DOMPointReadOnly;
  81941. orientation: DOMPointReadOnly;
  81942. matrix: Float32Array;
  81943. inverse: XRRigidTransform;
  81944. }
  81945. interface XRView {
  81946. readonly eye: XREye;
  81947. readonly projectionMatrix: Float32Array;
  81948. readonly transform: XRRigidTransform;
  81949. readonly recommendedViewportScale?: number;
  81950. requestViewportScale(scale: number): void;
  81951. }
  81952. interface XRInputSourceChangeEvent extends Event {
  81953. session: XRSession;
  81954. removed: Array<XRInputSource>;
  81955. added: Array<XRInputSource>;
  81956. }
  81957. // Experimental/Draft features
  81958. declare class XRRay {
  81959. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  81960. origin: DOMPointReadOnly;
  81961. direction: DOMPointReadOnly;
  81962. matrix: Float32Array;
  81963. }
  81964. declare enum XRHitTestTrackableType {
  81965. "point",
  81966. "plane",
  81967. "mesh",
  81968. }
  81969. interface XRHitResult {
  81970. hitMatrix: Float32Array;
  81971. }
  81972. interface XRTransientInputHitTestResult {
  81973. readonly inputSource: XRInputSource;
  81974. readonly results: Array<XRHitTestResult>;
  81975. }
  81976. interface XRHitTestResult {
  81977. getPose(baseSpace: XRSpace): XRPose | undefined;
  81978. // When anchor system is enabled
  81979. createAnchor?(pose: XRRigidTransform): Promise<XRAnchor>;
  81980. }
  81981. interface XRHitTestSource {
  81982. cancel(): void;
  81983. }
  81984. interface XRTransientInputHitTestSource {
  81985. cancel(): void;
  81986. }
  81987. interface XRHitTestOptionsInit {
  81988. space: XRSpace;
  81989. entityTypes?: Array<XRHitTestTrackableType>;
  81990. offsetRay?: XRRay;
  81991. }
  81992. interface XRTransientInputHitTestOptionsInit {
  81993. profile: string;
  81994. entityTypes?: Array<XRHitTestTrackableType>;
  81995. offsetRay?: XRRay;
  81996. }
  81997. interface XRAnchor {
  81998. anchorSpace: XRSpace;
  81999. delete(): void;
  82000. }
  82001. interface XRPlane {
  82002. orientation: "Horizontal" | "Vertical";
  82003. planeSpace: XRSpace;
  82004. polygon: Array<DOMPointReadOnly>;
  82005. lastChangedTime: number;
  82006. }
  82007. interface XRJointSpace extends XRSpace {}
  82008. interface XRJointPose extends XRPose {
  82009. radius: number | undefined;
  82010. }
  82011. interface XRHand extends Iterable<XRJointSpace> {
  82012. readonly length: number;
  82013. [index: number]: XRJointSpace;
  82014. readonly WRIST: number;
  82015. readonly THUMB_METACARPAL: number;
  82016. readonly THUMB_PHALANX_PROXIMAL: number;
  82017. readonly THUMB_PHALANX_DISTAL: number;
  82018. readonly THUMB_PHALANX_TIP: number;
  82019. readonly INDEX_METACARPAL: number;
  82020. readonly INDEX_PHALANX_PROXIMAL: number;
  82021. readonly INDEX_PHALANX_INTERMEDIATE: number;
  82022. readonly INDEX_PHALANX_DISTAL: number;
  82023. readonly INDEX_PHALANX_TIP: number;
  82024. readonly MIDDLE_METACARPAL: number;
  82025. readonly MIDDLE_PHALANX_PROXIMAL: number;
  82026. readonly MIDDLE_PHALANX_INTERMEDIATE: number;
  82027. readonly MIDDLE_PHALANX_DISTAL: number;
  82028. readonly MIDDLE_PHALANX_TIP: number;
  82029. readonly RING_METACARPAL: number;
  82030. readonly RING_PHALANX_PROXIMAL: number;
  82031. readonly RING_PHALANX_INTERMEDIATE: number;
  82032. readonly RING_PHALANX_DISTAL: number;
  82033. readonly RING_PHALANX_TIP: number;
  82034. readonly LITTLE_METACARPAL: number;
  82035. readonly LITTLE_PHALANX_PROXIMAL: number;
  82036. readonly LITTLE_PHALANX_INTERMEDIATE: number;
  82037. readonly LITTLE_PHALANX_DISTAL: number;
  82038. readonly LITTLE_PHALANX_TIP: number;
  82039. }
  82040. type XRImageTrackingState = "tracked" | "emulated";
  82041. type XRImageTrackingScore = "untrackable" | "trackable";
  82042. interface XRTrackedImageInit {
  82043. image: ImageBitmap;
  82044. widthInMeters: number;
  82045. }
  82046. interface XRImageTrackingResult {
  82047. readonly imageSpace: XRSpace;
  82048. readonly index: number;
  82049. readonly trackingState: XRImageTrackingState;
  82050. readonly measuredWidthInMeters: number;
  82051. }
  82052. // This file contains native only extensions for WebXR. These APIs are not supported in the browser yet.
  82053. // They are intended for use with either Babylon Native https://github.com/BabylonJS/BabylonNative or
  82054. // Babylon React Native: https://github.com/BabylonJS/BabylonReactNative
  82055. type XRSceneObjectType = "unknown" | "background" | "wall" | "floor" | "ceiling" | "platform";
  82056. interface XRSceneObject {
  82057. type: XRSceneObjectType;
  82058. }
  82059. interface XRFieldOfView {
  82060. angleLeft: number;
  82061. angleRight: number;
  82062. angleUp: number;
  82063. angleDown: number;
  82064. }
  82065. interface XRFrustum {
  82066. position: DOMPointReadOnly;
  82067. orientation: DOMPointReadOnly;
  82068. fieldOfView: XRFieldOfView;
  82069. farDistance: number;
  82070. }
  82071. interface XRPlane {
  82072. parentSceneObject?: XRSceneObject;
  82073. }
  82074. interface XRMesh {
  82075. meshSpace: XRSpace;
  82076. positions: Float32Array;
  82077. indices: Uint32Array;
  82078. normals?: Float32Array;
  82079. lastChangedTime: number;
  82080. parentSceneObject?: XRSceneObject;
  82081. }
  82082. interface XRFrustumDetectionBoundary {
  82083. type: "frustum";
  82084. frustum: XRFrustum;
  82085. }
  82086. interface XRSphereDetectionBoundary {
  82087. type: "sphere";
  82088. radius: number;
  82089. }
  82090. interface XRBoxDetectionBoundary {
  82091. type: "box";
  82092. extent: DOMPointReadOnly;
  82093. }
  82094. type XRDetectionBoundary = XRFrustumDetectionBoundary | XRSphereDetectionBoundary | XRBoxDetectionBoundary;
  82095. interface XRGeometryDetectorOptions {
  82096. detectionBoundary?: XRDetectionBoundary;
  82097. updateInterval?: number;
  82098. }
  82099. interface XRSession {
  82100. trySetFeaturePointCloudEnabled(enabled: boolean): boolean;
  82101. trySetPreferredPlaneDetectorOptions(preferredOptions: XRGeometryDetectorOptions): boolean;
  82102. trySetMeshDetectorEnabled(enabled: boolean): boolean;
  82103. trySetPreferredMeshDetectorOptions(preferredOptions: XRGeometryDetectorOptions): boolean;
  82104. }
  82105. interface XRFrame {
  82106. featurePointCloud?: Array<number>;
  82107. }
  82108. type XRMeshSet = Set<XRMesh>;
  82109. interface XRWorldInformation {
  82110. detectedMeshes?: XRMeshSet;
  82111. }
  82112. /**
  82113. * @ignore
  82114. */
  82115. declare module BABYLON.GLTF2.Exporter {
  82116. }
  82117. /**
  82118. * @ignore
  82119. */
  82120. declare module BABYLON.GLTF1 {
  82121. }
  82122. declare module BABYLON.GUI {
  82123. /**
  82124. * Interface used to define a control that can receive focus
  82125. */
  82126. export interface IFocusableControl {
  82127. /**
  82128. * Function called when the control receives the focus
  82129. */
  82130. onFocus(): void;
  82131. /**
  82132. * Function called when the control loses the focus
  82133. */
  82134. onBlur(): void;
  82135. /**
  82136. * Function called to let the control handle keyboard events
  82137. * @param evt defines the current keyboard event
  82138. */
  82139. processKeyboard(evt: KeyboardEvent): void;
  82140. /**
  82141. * Function called to get the list of controls that should not steal the focus from this control
  82142. * @returns an array of controls
  82143. */
  82144. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  82145. /**
  82146. * Function to focus the control programmatically
  82147. */
  82148. focus(): void;
  82149. /**
  82150. * Function to unfocus the control programmatically
  82151. */
  82152. blur(): void;
  82153. }
  82154. }
  82155. declare module BABYLON.GUI {
  82156. /**
  82157. * Class used to specific a value and its associated unit
  82158. */
  82159. export class ValueAndUnit {
  82160. /** defines the unit to store */
  82161. unit: number;
  82162. /** defines a boolean indicating if the value can be negative */
  82163. negativeValueAllowed: boolean;
  82164. private _value;
  82165. private _originalUnit;
  82166. /**
  82167. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  82168. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  82169. */
  82170. ignoreAdaptiveScaling: boolean;
  82171. /**
  82172. * Creates a new ValueAndUnit
  82173. * @param value defines the value to store
  82174. * @param unit defines the unit to store
  82175. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  82176. */
  82177. constructor(value: number,
  82178. /** defines the unit to store */
  82179. unit?: number,
  82180. /** defines a boolean indicating if the value can be negative */
  82181. negativeValueAllowed?: boolean);
  82182. /** Gets a boolean indicating if the value is a percentage */
  82183. get isPercentage(): boolean;
  82184. /** Gets a boolean indicating if the value is store as pixel */
  82185. get isPixel(): boolean;
  82186. /** Gets direct internal value */
  82187. get internalValue(): number;
  82188. /**
  82189. * Gets value as pixel
  82190. * @param host defines the root host
  82191. * @param refValue defines the reference value for percentages
  82192. * @returns the value as pixel
  82193. */
  82194. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  82195. /**
  82196. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  82197. * @param value defines the value to store
  82198. * @param unit defines the unit to store
  82199. * @returns the current ValueAndUnit
  82200. */
  82201. updateInPlace(value: number, unit?: number): ValueAndUnit;
  82202. /**
  82203. * Gets the value accordingly to its unit
  82204. * @param host defines the root host
  82205. * @returns the value
  82206. */
  82207. getValue(host: AdvancedDynamicTexture): number;
  82208. /**
  82209. * Gets a string representation of the value
  82210. * @param host defines the root host
  82211. * @param decimals defines an optional number of decimals to display
  82212. * @returns a string
  82213. */
  82214. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  82215. /**
  82216. * Store a value parsed from a string
  82217. * @param source defines the source string
  82218. * @returns true if the value was successfully parsed
  82219. */
  82220. fromString(source: string | number): boolean;
  82221. private static _Regex;
  82222. private static _UNITMODE_PERCENTAGE;
  82223. private static _UNITMODE_PIXEL;
  82224. /** UNITMODE_PERCENTAGE */
  82225. static get UNITMODE_PERCENTAGE(): number;
  82226. /** UNITMODE_PIXEL */
  82227. static get UNITMODE_PIXEL(): number;
  82228. }
  82229. }
  82230. declare module BABYLON.GUI {
  82231. /**
  82232. * Define a style used by control to automatically setup properties based on a template.
  82233. * Only support font related properties so far
  82234. */
  82235. export class Style implements BABYLON.IDisposable {
  82236. private _fontFamily;
  82237. private _fontStyle;
  82238. private _fontWeight;
  82239. /** @hidden */
  82240. _host: AdvancedDynamicTexture;
  82241. /** @hidden */
  82242. _fontSize: ValueAndUnit;
  82243. /**
  82244. * BABYLON.Observable raised when the style values are changed
  82245. */
  82246. onChangedObservable: BABYLON.Observable<Style>;
  82247. /**
  82248. * Creates a new style object
  82249. * @param host defines the AdvancedDynamicTexture which hosts this style
  82250. */
  82251. constructor(host: AdvancedDynamicTexture);
  82252. /**
  82253. * Gets or sets the font size
  82254. */
  82255. get fontSize(): string | number;
  82256. set fontSize(value: string | number);
  82257. /**
  82258. * Gets or sets the font family
  82259. */
  82260. get fontFamily(): string;
  82261. set fontFamily(value: string);
  82262. /**
  82263. * Gets or sets the font style
  82264. */
  82265. get fontStyle(): string;
  82266. set fontStyle(value: string);
  82267. /** Gets or sets font weight */
  82268. get fontWeight(): string;
  82269. set fontWeight(value: string);
  82270. /** Dispose all associated resources */
  82271. dispose(): void;
  82272. }
  82273. }
  82274. declare module BABYLON.GUI {
  82275. /**
  82276. * Class used to transport BABYLON.Vector2 information for pointer events
  82277. */
  82278. export class Vector2WithInfo extends BABYLON.Vector2 {
  82279. /** defines the current mouse button index */
  82280. buttonIndex: number;
  82281. /**
  82282. * Creates a new Vector2WithInfo
  82283. * @param source defines the vector2 data to transport
  82284. * @param buttonIndex defines the current mouse button index
  82285. */
  82286. constructor(source: BABYLON.Vector2,
  82287. /** defines the current mouse button index */
  82288. buttonIndex?: number);
  82289. }
  82290. /** Class used to provide 2D matrix features */
  82291. export class Matrix2D {
  82292. /** Gets the internal array of 6 floats used to store matrix data */
  82293. m: Float32Array;
  82294. /**
  82295. * Creates a new matrix
  82296. * @param m00 defines value for (0, 0)
  82297. * @param m01 defines value for (0, 1)
  82298. * @param m10 defines value for (1, 0)
  82299. * @param m11 defines value for (1, 1)
  82300. * @param m20 defines value for (2, 0)
  82301. * @param m21 defines value for (2, 1)
  82302. */
  82303. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  82304. /**
  82305. * Fills the matrix from direct values
  82306. * @param m00 defines value for (0, 0)
  82307. * @param m01 defines value for (0, 1)
  82308. * @param m10 defines value for (1, 0)
  82309. * @param m11 defines value for (1, 1)
  82310. * @param m20 defines value for (2, 0)
  82311. * @param m21 defines value for (2, 1)
  82312. * @returns the current modified matrix
  82313. */
  82314. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  82315. /**
  82316. * Gets matrix determinant
  82317. * @returns the determinant
  82318. */
  82319. determinant(): number;
  82320. /**
  82321. * Inverses the matrix and stores it in a target matrix
  82322. * @param result defines the target matrix
  82323. * @returns the current matrix
  82324. */
  82325. invertToRef(result: Matrix2D): Matrix2D;
  82326. /**
  82327. * Multiplies the current matrix with another one
  82328. * @param other defines the second operand
  82329. * @param result defines the target matrix
  82330. * @returns the current matrix
  82331. */
  82332. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  82333. /**
  82334. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  82335. * @param x defines the x coordinate to transform
  82336. * @param y defines the x coordinate to transform
  82337. * @param result defines the target vector2
  82338. * @returns the current matrix
  82339. */
  82340. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  82341. /**
  82342. * Creates an identity matrix
  82343. * @returns a new matrix
  82344. */
  82345. static Identity(): Matrix2D;
  82346. /**
  82347. * Creates a translation matrix and stores it in a target matrix
  82348. * @param x defines the x coordinate of the translation
  82349. * @param y defines the y coordinate of the translation
  82350. * @param result defines the target matrix
  82351. */
  82352. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  82353. /**
  82354. * Creates a scaling matrix and stores it in a target matrix
  82355. * @param x defines the x coordinate of the scaling
  82356. * @param y defines the y coordinate of the scaling
  82357. * @param result defines the target matrix
  82358. */
  82359. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  82360. /**
  82361. * Creates a rotation matrix and stores it in a target matrix
  82362. * @param angle defines the rotation angle
  82363. * @param result defines the target matrix
  82364. */
  82365. static RotationToRef(angle: number, result: Matrix2D): void;
  82366. private static _TempPreTranslationMatrix;
  82367. private static _TempPostTranslationMatrix;
  82368. private static _TempRotationMatrix;
  82369. private static _TempScalingMatrix;
  82370. private static _TempCompose0;
  82371. private static _TempCompose1;
  82372. private static _TempCompose2;
  82373. /**
  82374. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  82375. * @param tx defines the x coordinate of the translation
  82376. * @param ty defines the y coordinate of the translation
  82377. * @param angle defines the rotation angle
  82378. * @param scaleX defines the x coordinate of the scaling
  82379. * @param scaleY defines the y coordinate of the scaling
  82380. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  82381. * @param result defines the target matrix
  82382. */
  82383. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  82384. }
  82385. }
  82386. declare module BABYLON.GUI {
  82387. /**
  82388. * Class used to store 2D control sizes
  82389. */
  82390. export class Measure {
  82391. /** defines left coordinate */
  82392. left: number;
  82393. /** defines top coordinate */
  82394. top: number;
  82395. /** defines width dimension */
  82396. width: number;
  82397. /** defines height dimension */
  82398. height: number;
  82399. /**
  82400. * Creates a new measure
  82401. * @param left defines left coordinate
  82402. * @param top defines top coordinate
  82403. * @param width defines width dimension
  82404. * @param height defines height dimension
  82405. */
  82406. constructor(
  82407. /** defines left coordinate */
  82408. left: number,
  82409. /** defines top coordinate */
  82410. top: number,
  82411. /** defines width dimension */
  82412. width: number,
  82413. /** defines height dimension */
  82414. height: number);
  82415. /**
  82416. * Copy from another measure
  82417. * @param other defines the other measure to copy from
  82418. */
  82419. copyFrom(other: Measure): void;
  82420. /**
  82421. * Copy from a group of 4 floats
  82422. * @param left defines left coordinate
  82423. * @param top defines top coordinate
  82424. * @param width defines width dimension
  82425. * @param height defines height dimension
  82426. */
  82427. copyFromFloats(left: number, top: number, width: number, height: number): void;
  82428. /**
  82429. * Computes the axis aligned bounding box measure for two given measures
  82430. * @param a Input measure
  82431. * @param b Input measure
  82432. * @param result the resulting bounding measure
  82433. */
  82434. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  82435. /**
  82436. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  82437. * @param transform the matrix to transform the measure before computing the AABB
  82438. * @param addX number to add to left
  82439. * @param addY number to add to top
  82440. * @param addWidth number to add to width
  82441. * @param addHeight number to add to height
  82442. * @param result the resulting AABB
  82443. */
  82444. addAndTransformToRef(transform: Matrix2D, addX: number, addY: number, addWidth: number, addHeight: number, result: Measure): void;
  82445. /**
  82446. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  82447. * @param transform the matrix to transform the measure before computing the AABB
  82448. * @param result the resulting AABB
  82449. */
  82450. transformToRef(transform: Matrix2D, result: Measure): void;
  82451. /**
  82452. * Check equality between this measure and another one
  82453. * @param other defines the other measures
  82454. * @returns true if both measures are equals
  82455. */
  82456. isEqualsTo(other: Measure): boolean;
  82457. /**
  82458. * Creates an empty measure
  82459. * @returns a new measure
  82460. */
  82461. static Empty(): Measure;
  82462. }
  82463. }
  82464. declare module BABYLON.GUI {
  82465. /**
  82466. * Class used to create texture to support 2D GUI elements
  82467. * @see https://doc.babylonjs.com/how_to/gui
  82468. */
  82469. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  82470. /** Define the Uurl to load snippets */
  82471. static SnippetUrl: string;
  82472. /** Snippet ID if the content was created from the snippet server */
  82473. snippetId: string;
  82474. private _isDirty;
  82475. private _renderObserver;
  82476. private _resizeObserver;
  82477. private _preKeyboardObserver;
  82478. private _pointerMoveObserver;
  82479. private _pointerObserver;
  82480. private _canvasPointerOutObserver;
  82481. private _canvasBlurObserver;
  82482. private _background;
  82483. /** @hidden */
  82484. _rootContainer: Container;
  82485. /** @hidden */
  82486. _lastPickedControl: Control;
  82487. /** @hidden */
  82488. _lastControlOver: {
  82489. [pointerId: number]: Control;
  82490. };
  82491. /** @hidden */
  82492. _lastControlDown: {
  82493. [pointerId: number]: Control;
  82494. };
  82495. /** @hidden */
  82496. _capturingControl: {
  82497. [pointerId: number]: Control;
  82498. };
  82499. /** @hidden */
  82500. _shouldBlockPointer: boolean;
  82501. /** @hidden */
  82502. _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  82503. /** @hidden */
  82504. _linkedControls: Control[];
  82505. private _isFullscreen;
  82506. private _fullscreenViewport;
  82507. private _idealWidth;
  82508. private _idealHeight;
  82509. private _useSmallestIdeal;
  82510. private _renderAtIdealSize;
  82511. private _focusedControl;
  82512. private _blockNextFocusCheck;
  82513. private _renderScale;
  82514. private _rootElement;
  82515. private _cursorChanged;
  82516. private _defaultMousePointerId;
  82517. /** @hidden */
  82518. _numLayoutCalls: number;
  82519. /** Gets the number of layout calls made the last time the ADT has been rendered */
  82520. get numLayoutCalls(): number;
  82521. /** @hidden */
  82522. _numRenderCalls: number;
  82523. /** Gets the number of render calls made the last time the ADT has been rendered */
  82524. get numRenderCalls(): number;
  82525. /**
  82526. * Define type to string to ensure compatibility across browsers
  82527. * Safari doesn't support DataTransfer constructor
  82528. */
  82529. private _clipboardData;
  82530. /**
  82531. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  82532. */
  82533. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  82534. /**
  82535. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  82536. */
  82537. onControlPickedObservable: BABYLON.Observable<Control>;
  82538. /**
  82539. * BABYLON.Observable event triggered before layout is evaluated
  82540. */
  82541. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  82542. /**
  82543. * BABYLON.Observable event triggered after the layout was evaluated
  82544. */
  82545. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  82546. /**
  82547. * BABYLON.Observable event triggered before the texture is rendered
  82548. */
  82549. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  82550. /**
  82551. * BABYLON.Observable event triggered after the texture was rendered
  82552. */
  82553. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  82554. /**
  82555. * Gets or sets a boolean defining if alpha is stored as premultiplied
  82556. */
  82557. premulAlpha: boolean;
  82558. /**
  82559. * Gets or sets a boolean indicating that the canvas must be reverted on Y when updating the texture
  82560. */
  82561. applyYInversionOnUpdate: boolean;
  82562. /**
  82563. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  82564. * Useful when you want more antialiasing
  82565. */
  82566. get renderScale(): number;
  82567. set renderScale(value: number);
  82568. /** Gets or sets the background color */
  82569. get background(): string;
  82570. set background(value: string);
  82571. /**
  82572. * Gets or sets the ideal width used to design controls.
  82573. * The GUI will then rescale everything accordingly
  82574. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  82575. */
  82576. get idealWidth(): number;
  82577. set idealWidth(value: number);
  82578. /**
  82579. * Gets or sets the ideal height used to design controls.
  82580. * The GUI will then rescale everything accordingly
  82581. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  82582. */
  82583. get idealHeight(): number;
  82584. set idealHeight(value: number);
  82585. /**
  82586. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  82587. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  82588. */
  82589. get useSmallestIdeal(): boolean;
  82590. set useSmallestIdeal(value: boolean);
  82591. /**
  82592. * Gets or sets a boolean indicating if adaptive scaling must be used
  82593. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  82594. */
  82595. get renderAtIdealSize(): boolean;
  82596. set renderAtIdealSize(value: boolean);
  82597. /**
  82598. * Gets the ratio used when in "ideal mode"
  82599. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  82600. * */
  82601. get idealRatio(): number;
  82602. /**
  82603. * Gets the underlying layer used to render the texture when in fullscreen mode
  82604. */
  82605. get layer(): BABYLON.Nullable<BABYLON.Layer>;
  82606. /**
  82607. * Gets the root container control
  82608. */
  82609. get rootContainer(): Container;
  82610. /**
  82611. * Returns an array containing the root container.
  82612. * This is mostly used to let the Inspector introspects the ADT
  82613. * @returns an array containing the rootContainer
  82614. */
  82615. getChildren(): Array<Container>;
  82616. /**
  82617. * Will return all controls that are inside this texture
  82618. * @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
  82619. * @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
  82620. * @return all child controls
  82621. */
  82622. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  82623. /**
  82624. * Gets or sets the current focused control
  82625. */
  82626. get focusedControl(): BABYLON.Nullable<IFocusableControl>;
  82627. set focusedControl(control: BABYLON.Nullable<IFocusableControl>);
  82628. /**
  82629. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  82630. */
  82631. get isForeground(): boolean;
  82632. set isForeground(value: boolean);
  82633. /**
  82634. * Gets or set information about clipboardData
  82635. */
  82636. get clipboardData(): string;
  82637. set clipboardData(value: string);
  82638. /**
  82639. * Creates a new AdvancedDynamicTexture
  82640. * @param name defines the name of the texture
  82641. * @param width defines the width of the texture
  82642. * @param height defines the height of the texture
  82643. * @param scene defines the hosting scene
  82644. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  82645. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  82646. * @param invertY defines if the texture needs to be inverted on the y axis during loading (true by default)
  82647. */
  82648. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number, invertY?: boolean);
  82649. /**
  82650. * Get the current class name of the texture useful for serialization or dynamic coding.
  82651. * @returns "AdvancedDynamicTexture"
  82652. */
  82653. getClassName(): string;
  82654. /**
  82655. * Function used to execute a function on all controls
  82656. * @param func defines the function to execute
  82657. * @param container defines the container where controls belong. If null the root container will be used
  82658. */
  82659. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  82660. private _useInvalidateRectOptimization;
  82661. /**
  82662. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  82663. */
  82664. get useInvalidateRectOptimization(): boolean;
  82665. set useInvalidateRectOptimization(value: boolean);
  82666. private _invalidatedRectangle;
  82667. /**
  82668. * Invalidates a rectangle area on the gui texture
  82669. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  82670. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  82671. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  82672. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  82673. */
  82674. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  82675. /**
  82676. * Marks the texture as dirty forcing a complete update
  82677. */
  82678. markAsDirty(): void;
  82679. /**
  82680. * Helper function used to create a new style
  82681. * @returns a new style
  82682. * @see https://doc.babylonjs.com/how_to/gui#styles
  82683. */
  82684. createStyle(): Style;
  82685. /**
  82686. * Adds a new control to the root container
  82687. * @param control defines the control to add
  82688. * @returns the current texture
  82689. */
  82690. addControl(control: Control): AdvancedDynamicTexture;
  82691. /**
  82692. * Removes a control from the root container
  82693. * @param control defines the control to remove
  82694. * @returns the current texture
  82695. */
  82696. removeControl(control: Control): AdvancedDynamicTexture;
  82697. /**
  82698. * Release all resources
  82699. */
  82700. dispose(): void;
  82701. private _onResize;
  82702. /** @hidden */
  82703. _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  82704. /**
  82705. * Get screen coordinates for a vector3
  82706. * @param position defines the position to project
  82707. * @param worldMatrix defines the world matrix to use
  82708. * @returns the projected position
  82709. */
  82710. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  82711. /**
  82712. * Get screen coordinates for a vector3
  82713. * @param position defines the position to project
  82714. * @param worldMatrix defines the world matrix to use
  82715. * @returns the projected position with Z
  82716. */
  82717. getProjectedPositionWithZ(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector3;
  82718. private _checkUpdate;
  82719. private _clearMeasure;
  82720. private _render;
  82721. /** @hidden */
  82722. _changeCursor(cursor: string): void;
  82723. /** @hidden */
  82724. _registerLastControlDown(control: Control, pointerId: number): void;
  82725. private _doPicking;
  82726. /** @hidden */
  82727. _cleanControlAfterRemovalFromList(list: {
  82728. [pointerId: number]: Control;
  82729. }, control: Control): void;
  82730. /** @hidden */
  82731. _cleanControlAfterRemoval(control: Control): void;
  82732. /** Attach to all scene events required to support pointer events */
  82733. attach(): void;
  82734. /** @hidden */
  82735. private onClipboardCopy;
  82736. /** @hidden */
  82737. private onClipboardCut;
  82738. /** @hidden */
  82739. private onClipboardPaste;
  82740. /**
  82741. * Register the clipboard Events onto the canvas
  82742. */
  82743. registerClipboardEvents(): void;
  82744. /**
  82745. * Unregister the clipboard Events from the canvas
  82746. */
  82747. unRegisterClipboardEvents(): void;
  82748. /**
  82749. * Connect the texture to a hosting mesh to enable interactions
  82750. * @param mesh defines the mesh to attach to
  82751. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  82752. */
  82753. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  82754. /**
  82755. * Move the focus to a specific control
  82756. * @param control defines the control which will receive the focus
  82757. */
  82758. moveFocusToControl(control: IFocusableControl): void;
  82759. private _manageFocus;
  82760. private _attachToOnPointerOut;
  82761. private _attachToOnBlur;
  82762. /**
  82763. * Serializes the entire GUI system
  82764. * @returns an object with the JSON serialized data
  82765. */
  82766. serializeContent(): any;
  82767. /**
  82768. * Recreate the content of the ADT from a JSON object
  82769. * @param serializedObject define the JSON serialized object to restore from
  82770. */
  82771. parseContent(serializedObject: any): void;
  82772. /**
  82773. * Recreate the content of the ADT from a snippet saved by the GUI editor
  82774. * @param snippetId defines the snippet to load
  82775. * @returns a promise that will resolve on success
  82776. */
  82777. parseFromSnippetAsync(snippetId: string): Promise<void>;
  82778. /**
  82779. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  82780. * @param mesh defines the mesh which will receive the texture
  82781. * @param width defines the texture width (1024 by default)
  82782. * @param height defines the texture height (1024 by default)
  82783. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  82784. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  82785. * @param invertY defines if the texture needs to be inverted on the y axis during loading (true by default)
  82786. * @returns a new AdvancedDynamicTexture
  82787. */
  82788. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean, invertY?: boolean): AdvancedDynamicTexture;
  82789. /**
  82790. * 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
  82791. * @param mesh defines the mesh which will receive the texture
  82792. * @param width defines the texture width (1024 by default)
  82793. * @param height defines the texture height (1024 by default)
  82794. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  82795. * @param invertY defines if the texture needs to be inverted on the y axis during loading (true by default)
  82796. * @returns a new AdvancedDynamicTexture
  82797. */
  82798. static CreateForMeshTexture(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, invertY?: boolean): AdvancedDynamicTexture;
  82799. /**
  82800. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  82801. * In this mode the texture will rely on a layer for its rendering.
  82802. * This allows it to be treated like any other layer.
  82803. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  82804. * LayerMask is set through advancedTexture.layer.layerMask
  82805. * @param name defines name for the texture
  82806. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  82807. * @param scene defines the hsoting scene
  82808. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  82809. * @returns a new AdvancedDynamicTexture
  82810. */
  82811. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  82812. }
  82813. }
  82814. declare module BABYLON.GUI {
  82815. /**
  82816. * Root class used for all 2D controls
  82817. * @see https://doc.babylonjs.com/how_to/gui#controls
  82818. */
  82819. export class Control {
  82820. /** defines the name of the control */
  82821. name?: string | undefined;
  82822. /**
  82823. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  82824. */
  82825. static AllowAlphaInheritance: boolean;
  82826. private _alpha;
  82827. private _alphaSet;
  82828. private _zIndex;
  82829. /** @hidden */
  82830. _host: AdvancedDynamicTexture;
  82831. /** Gets or sets the control parent */
  82832. parent: BABYLON.Nullable<Container>;
  82833. /** @hidden */
  82834. _currentMeasure: Measure;
  82835. private _fontFamily;
  82836. private _fontStyle;
  82837. private _fontWeight;
  82838. private _fontSize;
  82839. private _font;
  82840. /** @hidden */
  82841. _width: ValueAndUnit;
  82842. /** @hidden */
  82843. _height: ValueAndUnit;
  82844. /** @hidden */
  82845. protected _fontOffset: {
  82846. ascent: number;
  82847. height: number;
  82848. descent: number;
  82849. };
  82850. private _color;
  82851. private _style;
  82852. private _styleObserver;
  82853. /** @hidden */
  82854. protected _horizontalAlignment: number;
  82855. /** @hidden */
  82856. protected _verticalAlignment: number;
  82857. /** @hidden */
  82858. protected _isDirty: boolean;
  82859. /** @hidden */
  82860. protected _wasDirty: boolean;
  82861. /** @hidden */
  82862. _tempParentMeasure: Measure;
  82863. /** @hidden */
  82864. _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  82865. /** @hidden */
  82866. protected _cachedParentMeasure: Measure;
  82867. private _paddingLeft;
  82868. private _paddingRight;
  82869. private _paddingTop;
  82870. private _paddingBottom;
  82871. /** @hidden */
  82872. _left: ValueAndUnit;
  82873. /** @hidden */
  82874. _top: ValueAndUnit;
  82875. private _scaleX;
  82876. private _scaleY;
  82877. private _rotation;
  82878. private _transformCenterX;
  82879. private _transformCenterY;
  82880. /** @hidden */
  82881. _transformMatrix: Matrix2D;
  82882. /** @hidden */
  82883. protected _invertTransformMatrix: Matrix2D;
  82884. /** @hidden */
  82885. protected _transformedPosition: BABYLON.Vector2;
  82886. private _isMatrixDirty;
  82887. private _cachedOffsetX;
  82888. private _cachedOffsetY;
  82889. private _isVisible;
  82890. private _isHighlighted;
  82891. /** @hidden */
  82892. _linkedMesh: BABYLON.Nullable<BABYLON.TransformNode>;
  82893. private _fontSet;
  82894. private _dummyVector2;
  82895. private _downCount;
  82896. private _enterCount;
  82897. private _doNotRender;
  82898. private _downPointerIds;
  82899. protected _isEnabled: boolean;
  82900. protected _disabledColor: string;
  82901. protected _disabledColorItem: string;
  82902. /** @hidden */
  82903. protected _rebuildLayout: boolean;
  82904. /** @hidden */
  82905. _customData: any;
  82906. /** @hidden */
  82907. _isClipped: boolean;
  82908. /** @hidden */
  82909. _automaticSize: boolean;
  82910. /** @hidden */
  82911. _tag: any;
  82912. /**
  82913. * 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
  82914. */
  82915. uniqueId: number;
  82916. /**
  82917. * Gets or sets an object used to store user defined information for the node
  82918. */
  82919. metadata: any;
  82920. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  82921. isHitTestVisible: boolean;
  82922. /** Gets or sets a boolean indicating if the control can block pointer events */
  82923. isPointerBlocker: boolean;
  82924. /** Gets or sets a boolean indicating if the control can be focusable */
  82925. isFocusInvisible: boolean;
  82926. /**
  82927. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  82928. * 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
  82929. */
  82930. clipChildren: boolean;
  82931. /**
  82932. * Gets or sets a boolean indicating that control content must be clipped
  82933. * 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
  82934. */
  82935. clipContent: boolean;
  82936. /**
  82937. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  82938. */
  82939. useBitmapCache: boolean;
  82940. private _cacheData;
  82941. private _shadowOffsetX;
  82942. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  82943. get shadowOffsetX(): number;
  82944. set shadowOffsetX(value: number);
  82945. private _shadowOffsetY;
  82946. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  82947. get shadowOffsetY(): number;
  82948. set shadowOffsetY(value: number);
  82949. private _shadowBlur;
  82950. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  82951. get shadowBlur(): number;
  82952. set shadowBlur(value: number);
  82953. private _shadowColor;
  82954. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  82955. get shadowColor(): string;
  82956. set shadowColor(value: string);
  82957. /** Gets or sets the cursor to use when the control is hovered */
  82958. hoverCursor: string;
  82959. /** @hidden */
  82960. protected _linkOffsetX: ValueAndUnit;
  82961. /** @hidden */
  82962. protected _linkOffsetY: ValueAndUnit;
  82963. /** Gets the control type name */
  82964. get typeName(): string;
  82965. /**
  82966. * Get the current class name of the control.
  82967. * @returns current class name
  82968. */
  82969. getClassName(): string;
  82970. /**
  82971. * An event triggered when pointer wheel is scrolled
  82972. */
  82973. onWheelObservable: BABYLON.Observable<BABYLON.Vector2>;
  82974. /**
  82975. * An event triggered when the pointer move over the control.
  82976. */
  82977. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  82978. /**
  82979. * An event triggered when the pointer move out of the control.
  82980. */
  82981. onPointerOutObservable: BABYLON.Observable<Control>;
  82982. /**
  82983. * An event triggered when the pointer taps the control
  82984. */
  82985. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  82986. /**
  82987. * An event triggered when pointer up
  82988. */
  82989. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  82990. /**
  82991. * An event triggered when a control is clicked on
  82992. */
  82993. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  82994. /**
  82995. * An event triggered when pointer enters the control
  82996. */
  82997. onPointerEnterObservable: BABYLON.Observable<Control>;
  82998. /**
  82999. * An event triggered when the control is marked as dirty
  83000. */
  83001. onDirtyObservable: BABYLON.Observable<Control>;
  83002. /**
  83003. * An event triggered before drawing the control
  83004. */
  83005. onBeforeDrawObservable: BABYLON.Observable<Control>;
  83006. /**
  83007. * An event triggered after the control was drawn
  83008. */
  83009. onAfterDrawObservable: BABYLON.Observable<Control>;
  83010. /**
  83011. * An event triggered when the control has been disposed
  83012. */
  83013. onDisposeObservable: BABYLON.Observable<Control>;
  83014. /**
  83015. * Get the hosting AdvancedDynamicTexture
  83016. */
  83017. get host(): AdvancedDynamicTexture;
  83018. /** Gets or set information about font offsets (used to render and align text) */
  83019. get fontOffset(): {
  83020. ascent: number;
  83021. height: number;
  83022. descent: number;
  83023. };
  83024. set fontOffset(offset: {
  83025. ascent: number;
  83026. height: number;
  83027. descent: number;
  83028. });
  83029. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  83030. get alpha(): number;
  83031. set alpha(value: number);
  83032. /**
  83033. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  83034. */
  83035. get isHighlighted(): boolean;
  83036. set isHighlighted(value: boolean);
  83037. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  83038. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  83039. */
  83040. get scaleX(): number;
  83041. set scaleX(value: number);
  83042. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  83043. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  83044. */
  83045. get scaleY(): number;
  83046. set scaleY(value: number);
  83047. /** Gets or sets the rotation angle (0 by default)
  83048. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  83049. */
  83050. get rotation(): number;
  83051. set rotation(value: number);
  83052. /** Gets or sets the transformation center on Y axis (0 by default)
  83053. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  83054. */
  83055. get transformCenterY(): number;
  83056. set transformCenterY(value: number);
  83057. /** Gets or sets the transformation center on X axis (0 by default)
  83058. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  83059. */
  83060. get transformCenterX(): number;
  83061. set transformCenterX(value: number);
  83062. /**
  83063. * Gets or sets the horizontal alignment
  83064. * @see https://doc.babylonjs.com/how_to/gui#alignments
  83065. */
  83066. get horizontalAlignment(): number;
  83067. set horizontalAlignment(value: number);
  83068. /**
  83069. * Gets or sets the vertical alignment
  83070. * @see https://doc.babylonjs.com/how_to/gui#alignments
  83071. */
  83072. get verticalAlignment(): number;
  83073. set verticalAlignment(value: number);
  83074. /**
  83075. * Gets or sets a fixed ratio for this control.
  83076. * When different from 0, the ratio is used to compute the "second" dimension.
  83077. * The first dimension used in the computation is the last one set (by setting width / widthInPixels or height / heightInPixels), and the
  83078. * second dimension is computed as first dimension * fixedRatio
  83079. */
  83080. fixedRatio: number;
  83081. private _fixedRatioMasterIsWidth;
  83082. /**
  83083. * Gets or sets control width
  83084. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83085. */
  83086. get width(): string | number;
  83087. set width(value: string | number);
  83088. /**
  83089. * Gets or sets the control width in pixel
  83090. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83091. */
  83092. get widthInPixels(): number;
  83093. set widthInPixels(value: number);
  83094. /**
  83095. * Gets or sets control height
  83096. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83097. */
  83098. get height(): string | number;
  83099. set height(value: string | number);
  83100. /**
  83101. * Gets or sets control height in pixel
  83102. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83103. */
  83104. get heightInPixels(): number;
  83105. set heightInPixels(value: number);
  83106. /** Gets or set font family */
  83107. get fontFamily(): string;
  83108. set fontFamily(value: string);
  83109. /** Gets or sets font style */
  83110. get fontStyle(): string;
  83111. set fontStyle(value: string);
  83112. /** Gets or sets font weight */
  83113. get fontWeight(): string;
  83114. set fontWeight(value: string);
  83115. /**
  83116. * Gets or sets style
  83117. * @see https://doc.babylonjs.com/how_to/gui#styles
  83118. */
  83119. get style(): BABYLON.Nullable<Style>;
  83120. set style(value: BABYLON.Nullable<Style>);
  83121. /** @hidden */
  83122. get _isFontSizeInPercentage(): boolean;
  83123. /** Gets or sets font size in pixels */
  83124. get fontSizeInPixels(): number;
  83125. set fontSizeInPixels(value: number);
  83126. /** Gets or sets font size */
  83127. get fontSize(): string | number;
  83128. set fontSize(value: string | number);
  83129. /** Gets or sets foreground color */
  83130. get color(): string;
  83131. set color(value: string);
  83132. /** Gets or sets z index which is used to reorder controls on the z axis */
  83133. get zIndex(): number;
  83134. set zIndex(value: number);
  83135. /** Gets or sets a boolean indicating if the control can be rendered */
  83136. get notRenderable(): boolean;
  83137. set notRenderable(value: boolean);
  83138. /** Gets or sets a boolean indicating if the control is visible */
  83139. get isVisible(): boolean;
  83140. set isVisible(value: boolean);
  83141. /** Gets a boolean indicating that the control needs to update its rendering */
  83142. get isDirty(): boolean;
  83143. /**
  83144. * Gets the current linked mesh (or null if none)
  83145. */
  83146. get linkedMesh(): BABYLON.Nullable<BABYLON.TransformNode>;
  83147. /**
  83148. * Gets or sets a value indicating the padding to use on the left of the control
  83149. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83150. */
  83151. get paddingLeft(): string | number;
  83152. set paddingLeft(value: string | number);
  83153. /**
  83154. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  83155. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83156. */
  83157. get paddingLeftInPixels(): number;
  83158. set paddingLeftInPixels(value: number);
  83159. /**
  83160. * Gets or sets a value indicating the padding to use on the right of the control
  83161. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83162. */
  83163. get paddingRight(): string | number;
  83164. set paddingRight(value: string | number);
  83165. /**
  83166. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  83167. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83168. */
  83169. get paddingRightInPixels(): number;
  83170. set paddingRightInPixels(value: number);
  83171. /**
  83172. * Gets or sets a value indicating the padding to use on the top of the control
  83173. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83174. */
  83175. get paddingTop(): string | number;
  83176. set paddingTop(value: string | number);
  83177. /**
  83178. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  83179. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83180. */
  83181. get paddingTopInPixels(): number;
  83182. set paddingTopInPixels(value: number);
  83183. /**
  83184. * Gets or sets a value indicating the padding to use on the bottom of the control
  83185. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83186. */
  83187. get paddingBottom(): string | number;
  83188. set paddingBottom(value: string | number);
  83189. /**
  83190. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  83191. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83192. */
  83193. get paddingBottomInPixels(): number;
  83194. set paddingBottomInPixels(value: number);
  83195. /**
  83196. * Gets or sets a value indicating the left coordinate of the control
  83197. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83198. */
  83199. get left(): string | number;
  83200. set left(value: string | number);
  83201. /**
  83202. * Gets or sets a value indicating the left coordinate in pixels of the control
  83203. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83204. */
  83205. get leftInPixels(): number;
  83206. set leftInPixels(value: number);
  83207. /**
  83208. * Gets or sets a value indicating the top coordinate of the control
  83209. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83210. */
  83211. get top(): string | number;
  83212. set top(value: string | number);
  83213. /**
  83214. * Gets or sets a value indicating the top coordinate in pixels of the control
  83215. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83216. */
  83217. get topInPixels(): number;
  83218. set topInPixels(value: number);
  83219. /**
  83220. * Gets or sets a value indicating the offset on X axis to the linked mesh
  83221. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  83222. */
  83223. get linkOffsetX(): string | number;
  83224. set linkOffsetX(value: string | number);
  83225. /**
  83226. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  83227. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  83228. */
  83229. get linkOffsetXInPixels(): number;
  83230. set linkOffsetXInPixels(value: number);
  83231. /**
  83232. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  83233. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  83234. */
  83235. get linkOffsetY(): string | number;
  83236. set linkOffsetY(value: string | number);
  83237. /**
  83238. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  83239. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  83240. */
  83241. get linkOffsetYInPixels(): number;
  83242. set linkOffsetYInPixels(value: number);
  83243. /** Gets the center coordinate on X axis */
  83244. get centerX(): number;
  83245. /** Gets the center coordinate on Y axis */
  83246. get centerY(): number;
  83247. /** Gets or sets if control is Enabled */
  83248. get isEnabled(): boolean;
  83249. set isEnabled(value: boolean);
  83250. /** Gets or sets background color of control if it's disabled */
  83251. get disabledColor(): string;
  83252. set disabledColor(value: string);
  83253. /** Gets or sets front color of control if it's disabled */
  83254. get disabledColorItem(): string;
  83255. set disabledColorItem(value: string);
  83256. /**
  83257. * Creates a new control
  83258. * @param name defines the name of the control
  83259. */
  83260. constructor(
  83261. /** defines the name of the control */
  83262. name?: string | undefined);
  83263. /** @hidden */
  83264. protected _getTypeName(): string;
  83265. /**
  83266. * Gets the first ascendant in the hierarchy of the given type
  83267. * @param className defines the required type
  83268. * @returns the ascendant or null if not found
  83269. */
  83270. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  83271. /** @hidden */
  83272. _resetFontCache(): void;
  83273. /**
  83274. * Determines if a container is an ascendant of the current control
  83275. * @param container defines the container to look for
  83276. * @returns true if the container is one of the ascendant of the control
  83277. */
  83278. isAscendant(container: Control): boolean;
  83279. /**
  83280. * Gets coordinates in local control space
  83281. * @param globalCoordinates defines the coordinates to transform
  83282. * @returns the new coordinates in local space
  83283. */
  83284. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  83285. /**
  83286. * Gets coordinates in local control space
  83287. * @param globalCoordinates defines the coordinates to transform
  83288. * @param result defines the target vector2 where to store the result
  83289. * @returns the current control
  83290. */
  83291. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  83292. /**
  83293. * Gets coordinates in parent local control space
  83294. * @param globalCoordinates defines the coordinates to transform
  83295. * @returns the new coordinates in parent local space
  83296. */
  83297. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  83298. /**
  83299. * Move the current control to a vector3 position projected onto the screen.
  83300. * @param position defines the target position
  83301. * @param scene defines the hosting scene
  83302. */
  83303. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  83304. /**
  83305. * Will store all controls that have this control as ascendant in a given array
  83306. * @param results defines the array where to store the descendants
  83307. * @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
  83308. * @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
  83309. */
  83310. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  83311. /**
  83312. * Will return all controls that have this control as ascendant
  83313. * @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
  83314. * @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
  83315. * @return all child controls
  83316. */
  83317. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  83318. /**
  83319. * Link current control with a target mesh
  83320. * @param mesh defines the mesh to link with
  83321. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  83322. */
  83323. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.TransformNode>): void;
  83324. /**
  83325. * Shorthand funtion to set the top, right, bottom, and left padding values on the control.
  83326. * @param { string | number} paddingTop - The value of the top padding.
  83327. * @param { string | number} paddingRight - The value of the right padding. If omitted, top is used.
  83328. * @param { string | number} paddingBottom - The value of the bottom padding. If omitted, top is used.
  83329. * @param { string | number} paddingLeft - The value of the left padding. If omitted, right is used.
  83330. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83331. */
  83332. setPadding(paddingTop: string | number, paddingRight?: string | number, paddingBottom?: string | number, paddingLeft?: string | number): void;
  83333. /**
  83334. * Shorthand funtion to set the top, right, bottom, and left padding values in pixels on the control.
  83335. * @param { number} paddingTop - The value in pixels of the top padding.
  83336. * @param { number} paddingRight - The value in pixels of the right padding. If omitted, top is used.
  83337. * @param { number} paddingBottom - The value in pixels of the bottom padding. If omitted, top is used.
  83338. * @param { number} paddingLeft - The value in pixels of the left padding. If omitted, right is used.
  83339. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83340. */
  83341. setPaddingInPixels(paddingTop: number, paddingRight?: number, paddingBottom?: number, paddingLeft?: number): void;
  83342. /** @hidden */
  83343. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  83344. /** @hidden */
  83345. _offsetLeft(offset: number): void;
  83346. /** @hidden */
  83347. _offsetTop(offset: number): void;
  83348. /** @hidden */
  83349. _markMatrixAsDirty(): void;
  83350. /** @hidden */
  83351. _flagDescendantsAsMatrixDirty(): void;
  83352. /** @hidden */
  83353. _intersectsRect(rect: Measure): boolean;
  83354. /** @hidden */
  83355. protected invalidateRect(): void;
  83356. /** @hidden */
  83357. _markAsDirty(force?: boolean): void;
  83358. /** @hidden */
  83359. _markAllAsDirty(): void;
  83360. /** @hidden */
  83361. _link(host: AdvancedDynamicTexture): void;
  83362. /** @hidden */
  83363. protected _transform(context?: CanvasRenderingContext2D): void;
  83364. /** @hidden */
  83365. _renderHighlight(context: CanvasRenderingContext2D): void;
  83366. /** @hidden */
  83367. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  83368. /** @hidden */
  83369. protected _applyStates(context: CanvasRenderingContext2D): void;
  83370. /** @hidden */
  83371. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  83372. /** @hidden */
  83373. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  83374. protected _evaluateClippingState(parentMeasure: Measure): void;
  83375. /** @hidden */
  83376. _measure(): void;
  83377. /** @hidden */
  83378. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  83379. /** @hidden */
  83380. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  83381. /** @hidden */
  83382. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  83383. /** @hidden */
  83384. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  83385. private static _ClipMeasure;
  83386. private _tmpMeasureA;
  83387. private _clip;
  83388. /** @hidden */
  83389. _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  83390. /** @hidden */
  83391. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  83392. /**
  83393. * Tests if a given coordinates belong to the current control
  83394. * @param x defines x coordinate to test
  83395. * @param y defines y coordinate to test
  83396. * @returns true if the coordinates are inside the control
  83397. */
  83398. contains(x: number, y: number): boolean;
  83399. /** @hidden */
  83400. _processPicking(x: number, y: number, pi: BABYLON.PointerInfoBase, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  83401. /** @hidden */
  83402. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number, pi: BABYLON.PointerInfoBase): void;
  83403. /** @hidden */
  83404. _onPointerEnter(target: Control, pi: BABYLON.PointerInfoBase): boolean;
  83405. /** @hidden */
  83406. _onPointerOut(target: Control, pi: BABYLON.Nullable<BABYLON.PointerInfoBase>, force?: boolean): void;
  83407. /** @hidden */
  83408. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  83409. /** @hidden */
  83410. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean, pi?: BABYLON.PointerInfoBase): void;
  83411. /** @hidden */
  83412. _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  83413. /** @hidden */
  83414. _onWheelScroll(deltaX?: number, deltaY?: number): void;
  83415. /** @hidden */
  83416. _onCanvasBlur(): void;
  83417. /** @hidden */
  83418. _processObservables(type: number, x: number, y: number, pi: BABYLON.PointerInfoBase, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  83419. private _prepareFont;
  83420. /**
  83421. * Serializes the current control
  83422. * @param serializationObject defined the JSON serialized object
  83423. */
  83424. serialize(serializationObject: any): void;
  83425. /** @hidden */
  83426. _parseFromContent(serializedObject: any, host: AdvancedDynamicTexture): void;
  83427. /** Releases associated resources */
  83428. dispose(): void;
  83429. private static _HORIZONTAL_ALIGNMENT_LEFT;
  83430. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  83431. private static _HORIZONTAL_ALIGNMENT_CENTER;
  83432. private static _VERTICAL_ALIGNMENT_TOP;
  83433. private static _VERTICAL_ALIGNMENT_BOTTOM;
  83434. private static _VERTICAL_ALIGNMENT_CENTER;
  83435. /** HORIZONTAL_ALIGNMENT_LEFT */
  83436. static get HORIZONTAL_ALIGNMENT_LEFT(): number;
  83437. /** HORIZONTAL_ALIGNMENT_RIGHT */
  83438. static get HORIZONTAL_ALIGNMENT_RIGHT(): number;
  83439. /** HORIZONTAL_ALIGNMENT_CENTER */
  83440. static get HORIZONTAL_ALIGNMENT_CENTER(): number;
  83441. /** VERTICAL_ALIGNMENT_TOP */
  83442. static get VERTICAL_ALIGNMENT_TOP(): number;
  83443. /** VERTICAL_ALIGNMENT_BOTTOM */
  83444. static get VERTICAL_ALIGNMENT_BOTTOM(): number;
  83445. /** VERTICAL_ALIGNMENT_CENTER */
  83446. static get VERTICAL_ALIGNMENT_CENTER(): number;
  83447. private static _FontHeightSizes;
  83448. /** @hidden */
  83449. static _GetFontOffset(font: string): {
  83450. ascent: number;
  83451. height: number;
  83452. descent: number;
  83453. };
  83454. /**
  83455. * Creates a Control from parsed data
  83456. * @param serializedObject defines parsed data
  83457. * @param host defines the hosting AdvancedDynamicTexture
  83458. * @returns a new Control
  83459. */
  83460. static Parse(serializedObject: any, host: AdvancedDynamicTexture): Control;
  83461. /**
  83462. * Creates a stack panel that can be used to render headers
  83463. * @param control defines the control to associate with the header
  83464. * @param text defines the text of the header
  83465. * @param size defines the size of the header
  83466. * @param options defines options used to configure the header
  83467. * @returns a new StackPanel
  83468. * @ignore
  83469. * @hidden
  83470. */
  83471. static AddHeader: (control: Control, text: string, size: string | number, options: {
  83472. isHorizontal: boolean;
  83473. controlFirst: boolean;
  83474. }) => any;
  83475. /** @hidden */
  83476. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  83477. }
  83478. }
  83479. declare module BABYLON.GUI {
  83480. /**
  83481. * Root class for 2D containers
  83482. * @see https://doc.babylonjs.com/how_to/gui#containers
  83483. */
  83484. export class Container extends Control {
  83485. name?: string | undefined;
  83486. /** @hidden */
  83487. _children: Control[];
  83488. /** @hidden */
  83489. protected _measureForChildren: Measure;
  83490. /** @hidden */
  83491. protected _background: string;
  83492. /** @hidden */
  83493. protected _adaptWidthToChildren: boolean;
  83494. /** @hidden */
  83495. protected _adaptHeightToChildren: boolean;
  83496. /**
  83497. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  83498. */
  83499. logLayoutCycleErrors: boolean;
  83500. /**
  83501. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  83502. */
  83503. maxLayoutCycle: number;
  83504. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  83505. get adaptHeightToChildren(): boolean;
  83506. set adaptHeightToChildren(value: boolean);
  83507. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  83508. get adaptWidthToChildren(): boolean;
  83509. set adaptWidthToChildren(value: boolean);
  83510. /** Gets or sets background color */
  83511. get background(): string;
  83512. set background(value: string);
  83513. /** Gets the list of children */
  83514. get children(): Control[];
  83515. /**
  83516. * Creates a new Container
  83517. * @param name defines the name of the container
  83518. */
  83519. constructor(name?: string | undefined);
  83520. protected _getTypeName(): string;
  83521. _flagDescendantsAsMatrixDirty(): void;
  83522. /**
  83523. * Gets a child using its name
  83524. * @param name defines the child name to look for
  83525. * @returns the child control if found
  83526. */
  83527. getChildByName(name: string): BABYLON.Nullable<Control>;
  83528. /**
  83529. * Gets a child using its type and its name
  83530. * @param name defines the child name to look for
  83531. * @param type defines the child type to look for
  83532. * @returns the child control if found
  83533. */
  83534. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  83535. /**
  83536. * Search for a specific control in children
  83537. * @param control defines the control to look for
  83538. * @returns true if the control is in child list
  83539. */
  83540. containsControl(control: Control): boolean;
  83541. /**
  83542. * Adds a new control to the current container
  83543. * @param control defines the control to add
  83544. * @returns the current container
  83545. */
  83546. addControl(control: BABYLON.Nullable<Control>): Container;
  83547. /**
  83548. * Removes all controls from the current container
  83549. * @returns the current container
  83550. */
  83551. clearControls(): Container;
  83552. /**
  83553. * Removes a control from the current container
  83554. * @param control defines the control to remove
  83555. * @returns the current container
  83556. */
  83557. removeControl(control: Control): Container;
  83558. /** @hidden */
  83559. _reOrderControl(control: Control): void;
  83560. /** @hidden */
  83561. _offsetLeft(offset: number): void;
  83562. /** @hidden */
  83563. _offsetTop(offset: number): void;
  83564. /** @hidden */
  83565. _markAllAsDirty(): void;
  83566. /** @hidden */
  83567. protected _localDraw(context: CanvasRenderingContext2D): void;
  83568. /** @hidden */
  83569. _link(host: AdvancedDynamicTexture): void;
  83570. /** @hidden */
  83571. protected _beforeLayout(): void;
  83572. /** @hidden */
  83573. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  83574. /** @hidden */
  83575. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  83576. protected _postMeasure(): void;
  83577. /** @hidden */
  83578. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  83579. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  83580. /** @hidden */
  83581. _processPicking(x: number, y: number, pi: BABYLON.PointerInfoBase, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  83582. /** @hidden */
  83583. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  83584. /**
  83585. * Serializes the current control
  83586. * @param serializationObject defined the JSON serialized object
  83587. */
  83588. serialize(serializationObject: any): void;
  83589. /** Releases associated resources */
  83590. dispose(): void;
  83591. /** @hidden */
  83592. _parseFromContent(serializedObject: any, host: AdvancedDynamicTexture): void;
  83593. }
  83594. }
  83595. declare module BABYLON.GUI {
  83596. /** Class used to create rectangle container */
  83597. export class Rectangle extends Container {
  83598. name?: string | undefined;
  83599. private _thickness;
  83600. private _cornerRadius;
  83601. /** Gets or sets border thickness */
  83602. get thickness(): number;
  83603. set thickness(value: number);
  83604. /** Gets or sets the corner radius angle */
  83605. get cornerRadius(): number;
  83606. set cornerRadius(value: number);
  83607. /**
  83608. * Creates a new Rectangle
  83609. * @param name defines the control name
  83610. */
  83611. constructor(name?: string | undefined);
  83612. protected _getTypeName(): string;
  83613. protected _localDraw(context: CanvasRenderingContext2D): void;
  83614. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  83615. private _drawRoundedRect;
  83616. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  83617. }
  83618. }
  83619. declare module BABYLON.GUI {
  83620. /**
  83621. * Enum that determines the text-wrapping mode to use.
  83622. */
  83623. export enum TextWrapping {
  83624. /**
  83625. * Clip the text when it's larger than Control.width; this is the default mode.
  83626. */
  83627. Clip = 0,
  83628. /**
  83629. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  83630. */
  83631. WordWrap = 1,
  83632. /**
  83633. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  83634. */
  83635. Ellipsis = 2
  83636. }
  83637. /**
  83638. * Class used to create text block control
  83639. */
  83640. export class TextBlock extends Control {
  83641. /**
  83642. * Defines the name of the control
  83643. */
  83644. name?: string | undefined;
  83645. private _text;
  83646. private _textWrapping;
  83647. private _textHorizontalAlignment;
  83648. private _textVerticalAlignment;
  83649. private _lines;
  83650. private _resizeToFit;
  83651. private _lineSpacing;
  83652. private _outlineWidth;
  83653. private _outlineColor;
  83654. private _underline;
  83655. private _lineThrough;
  83656. /**
  83657. * An event triggered after the text is changed
  83658. */
  83659. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  83660. /**
  83661. * An event triggered after the text was broken up into lines
  83662. */
  83663. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  83664. /**
  83665. * Function used to split a string into words. By default, a string is split at each space character found
  83666. */
  83667. wordSplittingFunction: BABYLON.Nullable<(line: string) => string[]>;
  83668. /**
  83669. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  83670. */
  83671. get lines(): any[];
  83672. /**
  83673. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  83674. */
  83675. get resizeToFit(): boolean;
  83676. /**
  83677. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  83678. */
  83679. set resizeToFit(value: boolean);
  83680. /**
  83681. * Gets or sets a boolean indicating if text must be wrapped
  83682. */
  83683. get textWrapping(): TextWrapping | boolean;
  83684. /**
  83685. * Gets or sets a boolean indicating if text must be wrapped
  83686. */
  83687. set textWrapping(value: TextWrapping | boolean);
  83688. /**
  83689. * Gets or sets text to display
  83690. */
  83691. get text(): string;
  83692. /**
  83693. * Gets or sets text to display
  83694. */
  83695. set text(value: string);
  83696. /**
  83697. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  83698. */
  83699. get textHorizontalAlignment(): number;
  83700. /**
  83701. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  83702. */
  83703. set textHorizontalAlignment(value: number);
  83704. /**
  83705. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  83706. */
  83707. get textVerticalAlignment(): number;
  83708. /**
  83709. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  83710. */
  83711. set textVerticalAlignment(value: number);
  83712. /**
  83713. * Gets or sets line spacing value
  83714. */
  83715. set lineSpacing(value: string | number);
  83716. /**
  83717. * Gets or sets line spacing value
  83718. */
  83719. get lineSpacing(): string | number;
  83720. /**
  83721. * Gets or sets outlineWidth of the text to display
  83722. */
  83723. get outlineWidth(): number;
  83724. /**
  83725. * Gets or sets outlineWidth of the text to display
  83726. */
  83727. set outlineWidth(value: number);
  83728. /**
  83729. * Gets or sets a boolean indicating that text must have underline
  83730. */
  83731. get underline(): boolean;
  83732. /**
  83733. * Gets or sets a boolean indicating that text must have underline
  83734. */
  83735. set underline(value: boolean);
  83736. /**
  83737. * Gets or sets an boolean indicating that text must be crossed out
  83738. */
  83739. get lineThrough(): boolean;
  83740. /**
  83741. * Gets or sets an boolean indicating that text must be crossed out
  83742. */
  83743. set lineThrough(value: boolean);
  83744. /**
  83745. * Gets or sets outlineColor of the text to display
  83746. */
  83747. get outlineColor(): string;
  83748. /**
  83749. * Gets or sets outlineColor of the text to display
  83750. */
  83751. set outlineColor(value: string);
  83752. /**
  83753. * Creates a new TextBlock object
  83754. * @param name defines the name of the control
  83755. * @param text defines the text to display (emptry string by default)
  83756. */
  83757. constructor(
  83758. /**
  83759. * Defines the name of the control
  83760. */
  83761. name?: string | undefined, text?: string);
  83762. protected _getTypeName(): string;
  83763. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  83764. private _drawText;
  83765. /** @hidden */
  83766. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  83767. protected _applyStates(context: CanvasRenderingContext2D): void;
  83768. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  83769. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  83770. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  83771. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  83772. protected _renderLines(context: CanvasRenderingContext2D): void;
  83773. /**
  83774. * Given a width constraint applied on the text block, find the expected height
  83775. * @returns expected height
  83776. */
  83777. computeExpectedHeight(): number;
  83778. dispose(): void;
  83779. }
  83780. }
  83781. declare module BABYLON.GUI {
  83782. /**
  83783. * Class used to create 2D images
  83784. */
  83785. export class Image extends Control {
  83786. name?: string | undefined;
  83787. private _workingCanvas;
  83788. private _domImage;
  83789. private _imageWidth;
  83790. private _imageHeight;
  83791. private _loaded;
  83792. private _stretch;
  83793. private _source;
  83794. private _autoScale;
  83795. private _sourceLeft;
  83796. private _sourceTop;
  83797. private _sourceWidth;
  83798. private _sourceHeight;
  83799. private _svgAttributesComputationCompleted;
  83800. private _isSVG;
  83801. private _cellWidth;
  83802. private _cellHeight;
  83803. private _cellId;
  83804. private _populateNinePatchSlicesFromImage;
  83805. private _sliceLeft;
  83806. private _sliceRight;
  83807. private _sliceTop;
  83808. private _sliceBottom;
  83809. private _detectPointerOnOpaqueOnly;
  83810. private _imageDataCache;
  83811. /**
  83812. * BABYLON.Observable notified when the content is loaded
  83813. */
  83814. onImageLoadedObservable: BABYLON.Observable<Image>;
  83815. /**
  83816. * BABYLON.Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  83817. */
  83818. onSVGAttributesComputedObservable: BABYLON.Observable<Image>;
  83819. /**
  83820. * Gets a boolean indicating that the content is loaded
  83821. */
  83822. get isLoaded(): boolean;
  83823. /**
  83824. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  83825. */
  83826. get populateNinePatchSlicesFromImage(): boolean;
  83827. set populateNinePatchSlicesFromImage(value: boolean);
  83828. /**
  83829. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  83830. * Beware using this as this will comsume more memory as the image has to be stored twice
  83831. */
  83832. get detectPointerOnOpaqueOnly(): boolean;
  83833. set detectPointerOnOpaqueOnly(value: boolean);
  83834. /**
  83835. * Gets or sets the left value for slicing (9-patch)
  83836. */
  83837. get sliceLeft(): number;
  83838. set sliceLeft(value: number);
  83839. /**
  83840. * Gets or sets the right value for slicing (9-patch)
  83841. */
  83842. get sliceRight(): number;
  83843. set sliceRight(value: number);
  83844. /**
  83845. * Gets or sets the top value for slicing (9-patch)
  83846. */
  83847. get sliceTop(): number;
  83848. set sliceTop(value: number);
  83849. /**
  83850. * Gets or sets the bottom value for slicing (9-patch)
  83851. */
  83852. get sliceBottom(): number;
  83853. set sliceBottom(value: number);
  83854. /**
  83855. * Gets or sets the left coordinate in the source image
  83856. */
  83857. get sourceLeft(): number;
  83858. set sourceLeft(value: number);
  83859. /**
  83860. * Gets or sets the top coordinate in the source image
  83861. */
  83862. get sourceTop(): number;
  83863. set sourceTop(value: number);
  83864. /**
  83865. * Gets or sets the width to capture in the source image
  83866. */
  83867. get sourceWidth(): number;
  83868. set sourceWidth(value: number);
  83869. /**
  83870. * Gets or sets the height to capture in the source image
  83871. */
  83872. get sourceHeight(): number;
  83873. set sourceHeight(value: number);
  83874. /** Indicates if the format of the image is SVG */
  83875. get isSVG(): boolean;
  83876. /** Gets the status of the SVG attributes computation (sourceLeft, sourceTop, sourceWidth, sourceHeight) */
  83877. get svgAttributesComputationCompleted(): boolean;
  83878. /**
  83879. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  83880. * @see https://doc.babylonjs.com/how_to/gui#image
  83881. */
  83882. get autoScale(): boolean;
  83883. set autoScale(value: boolean);
  83884. /** Gets or sets the streching mode used by the image */
  83885. get stretch(): number;
  83886. set stretch(value: number);
  83887. /** @hidden */
  83888. _rotate90(n: number, preserveProperties?: boolean): Image;
  83889. private _handleRotationForSVGImage;
  83890. private _rotate90SourceProperties;
  83891. /**
  83892. * Gets or sets the internal DOM image used to render the control
  83893. */
  83894. set domImage(value: HTMLImageElement);
  83895. get domImage(): HTMLImageElement;
  83896. private _onImageLoaded;
  83897. private _extractNinePatchSliceDataFromImage;
  83898. /**
  83899. * Gets the image source url
  83900. */
  83901. get source(): BABYLON.Nullable<string>;
  83902. /**
  83903. * Gets or sets image source url
  83904. */
  83905. set source(value: BABYLON.Nullable<string>);
  83906. /**
  83907. * Checks for svg document with icon id present
  83908. */
  83909. private _svgCheck;
  83910. /**
  83911. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  83912. * given external svg file and icon id
  83913. */
  83914. private _getSVGAttribs;
  83915. /**
  83916. * Gets or sets the cell width to use when animation sheet is enabled
  83917. * @see https://doc.babylonjs.com/how_to/gui#image
  83918. */
  83919. get cellWidth(): number;
  83920. set cellWidth(value: number);
  83921. /**
  83922. * Gets or sets the cell height to use when animation sheet is enabled
  83923. * @see https://doc.babylonjs.com/how_to/gui#image
  83924. */
  83925. get cellHeight(): number;
  83926. set cellHeight(value: number);
  83927. /**
  83928. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  83929. * @see https://doc.babylonjs.com/how_to/gui#image
  83930. */
  83931. get cellId(): number;
  83932. set cellId(value: number);
  83933. /**
  83934. * Creates a new Image
  83935. * @param name defines the control name
  83936. * @param url defines the image url
  83937. */
  83938. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  83939. /**
  83940. * Tests if a given coordinates belong to the current control
  83941. * @param x defines x coordinate to test
  83942. * @param y defines y coordinate to test
  83943. * @returns true if the coordinates are inside the control
  83944. */
  83945. contains(x: number, y: number): boolean;
  83946. protected _getTypeName(): string;
  83947. /** Force the control to synchronize with its content */
  83948. synchronizeSizeWithContent(): void;
  83949. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  83950. private _prepareWorkingCanvasForOpaqueDetection;
  83951. private _drawImage;
  83952. _draw(context: CanvasRenderingContext2D): void;
  83953. private _renderCornerPatch;
  83954. private _renderNinePatch;
  83955. dispose(): void;
  83956. /** STRETCH_NONE */
  83957. static readonly STRETCH_NONE: number;
  83958. /** STRETCH_FILL */
  83959. static readonly STRETCH_FILL: number;
  83960. /** STRETCH_UNIFORM */
  83961. static readonly STRETCH_UNIFORM: number;
  83962. /** STRETCH_EXTEND */
  83963. static readonly STRETCH_EXTEND: number;
  83964. /** NINE_PATCH */
  83965. static readonly STRETCH_NINE_PATCH: number;
  83966. }
  83967. }
  83968. declare module BABYLON.GUI {
  83969. /**
  83970. * Class used to create 2D buttons
  83971. */
  83972. export class Button extends Rectangle {
  83973. name?: string | undefined;
  83974. /**
  83975. * Function called to generate a pointer enter animation
  83976. */
  83977. pointerEnterAnimation: () => void;
  83978. /**
  83979. * Function called to generate a pointer out animation
  83980. */
  83981. pointerOutAnimation: () => void;
  83982. /**
  83983. * Function called to generate a pointer down animation
  83984. */
  83985. pointerDownAnimation: () => void;
  83986. /**
  83987. * Function called to generate a pointer up animation
  83988. */
  83989. pointerUpAnimation: () => void;
  83990. /**
  83991. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  83992. */
  83993. delegatePickingToChildren: boolean;
  83994. private _image;
  83995. /**
  83996. * Returns the image part of the button (if any)
  83997. */
  83998. get image(): BABYLON.Nullable<Image>;
  83999. private _textBlock;
  84000. /**
  84001. * Returns the image part of the button (if any)
  84002. */
  84003. get textBlock(): BABYLON.Nullable<TextBlock>;
  84004. /**
  84005. * Creates a new Button
  84006. * @param name defines the name of the button
  84007. */
  84008. constructor(name?: string | undefined);
  84009. protected _getTypeName(): string;
  84010. /** @hidden */
  84011. _processPicking(x: number, y: number, pi: BABYLON.PointerInfoBase, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  84012. /** @hidden */
  84013. _onPointerEnter(target: Control, pi: BABYLON.PointerInfoBase): boolean;
  84014. /** @hidden */
  84015. _onPointerOut(target: Control, pi: BABYLON.PointerInfoBase, force?: boolean): void;
  84016. /** @hidden */
  84017. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  84018. /** @hidden */
  84019. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean, pi: BABYLON.PointerInfoBase): void;
  84020. /**
  84021. * Creates a new button made with an image and a text
  84022. * @param name defines the name of the button
  84023. * @param text defines the text of the button
  84024. * @param imageUrl defines the url of the image
  84025. * @returns a new Button
  84026. */
  84027. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  84028. /**
  84029. * Creates a new button made with an image
  84030. * @param name defines the name of the button
  84031. * @param imageUrl defines the url of the image
  84032. * @returns a new Button
  84033. */
  84034. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  84035. /**
  84036. * Creates a new button made with a text
  84037. * @param name defines the name of the button
  84038. * @param text defines the text of the button
  84039. * @returns a new Button
  84040. */
  84041. static CreateSimpleButton(name: string, text: string): Button;
  84042. /**
  84043. * Creates a new button made with an image and a centered text
  84044. * @param name defines the name of the button
  84045. * @param text defines the text of the button
  84046. * @param imageUrl defines the url of the image
  84047. * @returns a new Button
  84048. */
  84049. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  84050. }
  84051. }
  84052. declare module BABYLON.GUI {
  84053. /**
  84054. * Class used to create a 2D stack panel container
  84055. */
  84056. export class StackPanel extends Container {
  84057. name?: string | undefined;
  84058. private _isVertical;
  84059. private _manualWidth;
  84060. private _manualHeight;
  84061. private _doNotTrackManualChanges;
  84062. /**
  84063. * Gets or sets a boolean indicating that layou warnings should be ignored
  84064. */
  84065. ignoreLayoutWarnings: boolean;
  84066. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  84067. get isVertical(): boolean;
  84068. set isVertical(value: boolean);
  84069. /**
  84070. * Gets or sets panel width.
  84071. * This value should not be set when in horizontal mode as it will be computed automatically
  84072. */
  84073. set width(value: string | number);
  84074. get width(): string | number;
  84075. /**
  84076. * Gets or sets panel height.
  84077. * This value should not be set when in vertical mode as it will be computed automatically
  84078. */
  84079. set height(value: string | number);
  84080. get height(): string | number;
  84081. /**
  84082. * Creates a new StackPanel
  84083. * @param name defines control name
  84084. */
  84085. constructor(name?: string | undefined);
  84086. protected _getTypeName(): string;
  84087. /** @hidden */
  84088. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  84089. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  84090. protected _postMeasure(): void;
  84091. /**
  84092. * Serializes the current control
  84093. * @param serializationObject defined the JSON serialized object
  84094. */
  84095. serialize(serializationObject: any): void;
  84096. /** @hidden */
  84097. _parseFromContent(serializedObject: any, host: AdvancedDynamicTexture): void;
  84098. }
  84099. }
  84100. declare module BABYLON.GUI {
  84101. /**
  84102. * Class used to represent a 2D checkbox
  84103. */
  84104. export class Checkbox extends Control {
  84105. name?: string | undefined;
  84106. private _isChecked;
  84107. private _background;
  84108. private _checkSizeRatio;
  84109. private _thickness;
  84110. /** Gets or sets border thickness */
  84111. get thickness(): number;
  84112. set thickness(value: number);
  84113. /**
  84114. * BABYLON.Observable raised when isChecked property changes
  84115. */
  84116. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  84117. /** Gets or sets a value indicating the ratio between overall size and check size */
  84118. get checkSizeRatio(): number;
  84119. set checkSizeRatio(value: number);
  84120. /** Gets or sets background color */
  84121. get background(): string;
  84122. set background(value: string);
  84123. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  84124. get isChecked(): boolean;
  84125. set isChecked(value: boolean);
  84126. /**
  84127. * Creates a new CheckBox
  84128. * @param name defines the control name
  84129. */
  84130. constructor(name?: string | undefined);
  84131. protected _getTypeName(): string;
  84132. /** @hidden */
  84133. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  84134. /** @hidden */
  84135. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  84136. /**
  84137. * Utility function to easily create a checkbox with a header
  84138. * @param title defines the label to use for the header
  84139. * @param onValueChanged defines the callback to call when value changes
  84140. * @returns a StackPanel containing the checkbox and a textBlock
  84141. */
  84142. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  84143. }
  84144. }
  84145. declare module BABYLON.GUI {
  84146. /**
  84147. * Class used to store key control properties
  84148. */
  84149. export class KeyPropertySet {
  84150. /** Width */
  84151. width?: string;
  84152. /** Height */
  84153. height?: string;
  84154. /** Left padding */
  84155. paddingLeft?: string;
  84156. /** Right padding */
  84157. paddingRight?: string;
  84158. /** Top padding */
  84159. paddingTop?: string;
  84160. /** Bottom padding */
  84161. paddingBottom?: string;
  84162. /** Foreground color */
  84163. color?: string;
  84164. /** Background color */
  84165. background?: string;
  84166. }
  84167. /**
  84168. * Class used to create virtual keyboard
  84169. */
  84170. export class VirtualKeyboard extends StackPanel {
  84171. /** BABYLON.Observable raised when a key is pressed */
  84172. onKeyPressObservable: BABYLON.Observable<string>;
  84173. /** Gets or sets default key button width */
  84174. defaultButtonWidth: string;
  84175. /** Gets or sets default key button height */
  84176. defaultButtonHeight: string;
  84177. /** Gets or sets default key button left padding */
  84178. defaultButtonPaddingLeft: string;
  84179. /** Gets or sets default key button right padding */
  84180. defaultButtonPaddingRight: string;
  84181. /** Gets or sets default key button top padding */
  84182. defaultButtonPaddingTop: string;
  84183. /** Gets or sets default key button bottom padding */
  84184. defaultButtonPaddingBottom: string;
  84185. /** Gets or sets default key button foreground color */
  84186. defaultButtonColor: string;
  84187. /** Gets or sets default key button background color */
  84188. defaultButtonBackground: string;
  84189. /** Gets or sets shift button foreground color */
  84190. shiftButtonColor: string;
  84191. /** Gets or sets shift button thickness*/
  84192. selectedShiftThickness: number;
  84193. /** Gets shift key state */
  84194. shiftState: number;
  84195. protected _getTypeName(): string;
  84196. private _createKey;
  84197. /**
  84198. * Adds a new row of keys
  84199. * @param keys defines the list of keys to add
  84200. * @param propertySets defines the associated property sets
  84201. */
  84202. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  84203. /**
  84204. * Set the shift key to a specific state
  84205. * @param shiftState defines the new shift state
  84206. */
  84207. applyShiftState(shiftState: number): void;
  84208. private _currentlyConnectedInputText;
  84209. private _connectedInputTexts;
  84210. private _onKeyPressObserver;
  84211. /** Gets the input text control currently attached to the keyboard */
  84212. get connectedInputText(): BABYLON.Nullable<InputText>;
  84213. /**
  84214. * Connects the keyboard with an input text control
  84215. *
  84216. * @param input defines the target control
  84217. */
  84218. connect(input: InputText): void;
  84219. /**
  84220. * Disconnects the keyboard from connected InputText controls
  84221. *
  84222. * @param input optionally defines a target control, otherwise all are disconnected
  84223. */
  84224. disconnect(input?: InputText): void;
  84225. private _removeConnectedInputObservables;
  84226. /**
  84227. * Release all resources
  84228. */
  84229. dispose(): void;
  84230. /**
  84231. * Creates a new keyboard using a default layout
  84232. *
  84233. * @param name defines control name
  84234. * @returns a new VirtualKeyboard
  84235. */
  84236. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  84237. }
  84238. }
  84239. declare module BABYLON.GUI {
  84240. /** @hidden */
  84241. export class TextWrapper {
  84242. private _text;
  84243. private _characters;
  84244. get text(): string;
  84245. set text(txt: string);
  84246. get length(): number;
  84247. removePart(idxStart: number, idxEnd: number, insertTxt?: string): void;
  84248. charAt(idx: number): string;
  84249. substr(from: number, length?: number): string;
  84250. substring(from: number, to?: number): string;
  84251. isWord(index: number): boolean;
  84252. }
  84253. }
  84254. declare module BABYLON.GUI {
  84255. /**
  84256. * Class used to create input text control
  84257. */
  84258. export class InputText extends Control implements IFocusableControl {
  84259. name?: string | undefined;
  84260. private _textWrapper;
  84261. private _placeholderText;
  84262. private _background;
  84263. private _focusedBackground;
  84264. private _focusedColor;
  84265. private _placeholderColor;
  84266. private _thickness;
  84267. private _margin;
  84268. private _autoStretchWidth;
  84269. private _maxWidth;
  84270. private _isFocused;
  84271. private _blinkTimeout;
  84272. private _blinkIsEven;
  84273. private _cursorOffset;
  84274. private _scrollLeft;
  84275. private _textWidth;
  84276. private _clickedCoordinate;
  84277. private _deadKey;
  84278. private _addKey;
  84279. private _currentKey;
  84280. private _isTextHighlightOn;
  84281. private _textHighlightColor;
  84282. private _highligherOpacity;
  84283. private _highlightedText;
  84284. private _startHighlightIndex;
  84285. private _endHighlightIndex;
  84286. private _cursorIndex;
  84287. private _onFocusSelectAll;
  84288. private _isPointerDown;
  84289. private _onClipboardObserver;
  84290. private _onPointerDblTapObserver;
  84291. /** @hidden */
  84292. _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  84293. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  84294. promptMessage: string;
  84295. /** Force disable prompt on mobile device */
  84296. disableMobilePrompt: boolean;
  84297. /** BABYLON.Observable raised when the text changes */
  84298. onTextChangedObservable: BABYLON.Observable<InputText>;
  84299. /** BABYLON.Observable raised just before an entered character is to be added */
  84300. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  84301. /** BABYLON.Observable raised when the control gets the focus */
  84302. onFocusObservable: BABYLON.Observable<InputText>;
  84303. /** BABYLON.Observable raised when the control loses the focus */
  84304. onBlurObservable: BABYLON.Observable<InputText>;
  84305. /**Observable raised when the text is highlighted */
  84306. onTextHighlightObservable: BABYLON.Observable<InputText>;
  84307. /**Observable raised when copy event is triggered */
  84308. onTextCopyObservable: BABYLON.Observable<InputText>;
  84309. /** BABYLON.Observable raised when cut event is triggered */
  84310. onTextCutObservable: BABYLON.Observable<InputText>;
  84311. /** BABYLON.Observable raised when paste event is triggered */
  84312. onTextPasteObservable: BABYLON.Observable<InputText>;
  84313. /** BABYLON.Observable raised when a key event was processed */
  84314. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  84315. /** Gets or sets the maximum width allowed by the control */
  84316. get maxWidth(): string | number;
  84317. /** Gets the maximum width allowed by the control in pixels */
  84318. get maxWidthInPixels(): number;
  84319. set maxWidth(value: string | number);
  84320. /** Gets or sets the text highlighter transparency; default: 0.4 */
  84321. get highligherOpacity(): number;
  84322. set highligherOpacity(value: number);
  84323. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  84324. get onFocusSelectAll(): boolean;
  84325. set onFocusSelectAll(value: boolean);
  84326. /** Gets or sets the text hightlight color */
  84327. get textHighlightColor(): string;
  84328. set textHighlightColor(value: string);
  84329. /** Gets or sets control margin */
  84330. get margin(): string;
  84331. /** Gets control margin in pixels */
  84332. get marginInPixels(): number;
  84333. set margin(value: string);
  84334. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  84335. get autoStretchWidth(): boolean;
  84336. set autoStretchWidth(value: boolean);
  84337. /** Gets or sets border thickness */
  84338. get thickness(): number;
  84339. set thickness(value: number);
  84340. /** Gets or sets the background color when focused */
  84341. get focusedBackground(): string;
  84342. set focusedBackground(value: string);
  84343. /** Gets or sets the background color when focused */
  84344. get focusedColor(): string;
  84345. set focusedColor(value: string);
  84346. /** Gets or sets the background color */
  84347. get background(): string;
  84348. set background(value: string);
  84349. /** Gets or sets the placeholder color */
  84350. get placeholderColor(): string;
  84351. set placeholderColor(value: string);
  84352. /** Gets or sets the text displayed when the control is empty */
  84353. get placeholderText(): string;
  84354. set placeholderText(value: string);
  84355. /** Gets or sets the dead key flag */
  84356. get deadKey(): boolean;
  84357. set deadKey(flag: boolean);
  84358. /** Gets or sets the highlight text */
  84359. get highlightedText(): string;
  84360. set highlightedText(text: string);
  84361. /** Gets or sets if the current key should be added */
  84362. get addKey(): boolean;
  84363. set addKey(flag: boolean);
  84364. /** Gets or sets the value of the current key being entered */
  84365. get currentKey(): string;
  84366. set currentKey(key: string);
  84367. /** Gets or sets the text displayed in the control */
  84368. get text(): string;
  84369. set text(value: string);
  84370. private _textHasChanged;
  84371. /** Gets or sets control width */
  84372. get width(): string | number;
  84373. set width(value: string | number);
  84374. /**
  84375. * Creates a new InputText
  84376. * @param name defines the control name
  84377. * @param text defines the text of the control
  84378. */
  84379. constructor(name?: string | undefined, text?: string);
  84380. /** @hidden */
  84381. onBlur(): void;
  84382. /** @hidden */
  84383. onFocus(): void;
  84384. /**
  84385. * Function to focus an inputText programmatically
  84386. */
  84387. focus(): void;
  84388. /**
  84389. * Function to unfocus an inputText programmatically
  84390. */
  84391. blur(): void;
  84392. protected _getTypeName(): string;
  84393. /**
  84394. * Function called to get the list of controls that should not steal the focus from this control
  84395. * @returns an array of controls
  84396. */
  84397. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  84398. /** @hidden */
  84399. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  84400. /** @hidden */
  84401. private _updateValueFromCursorIndex;
  84402. /** @hidden */
  84403. private _processDblClick;
  84404. /** @hidden */
  84405. private _selectAllText;
  84406. /**
  84407. * Handles the keyboard event
  84408. * @param evt Defines the KeyboardEvent
  84409. */
  84410. processKeyboard(evt: KeyboardEvent): void;
  84411. /** @hidden */
  84412. private _onCopyText;
  84413. /** @hidden */
  84414. private _onCutText;
  84415. /** @hidden */
  84416. private _onPasteText;
  84417. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  84418. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  84419. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number, pi: BABYLON.PointerInfoBase): void;
  84420. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  84421. protected _beforeRenderText(textWrapper: TextWrapper): TextWrapper;
  84422. dispose(): void;
  84423. }
  84424. }
  84425. declare module BABYLON.GUI {
  84426. /**
  84427. * Class used to create a 2D grid container
  84428. */
  84429. export class Grid extends Container {
  84430. name?: string | undefined;
  84431. private _rowDefinitions;
  84432. private _columnDefinitions;
  84433. private _cells;
  84434. private _childControls;
  84435. /**
  84436. * Gets the number of columns
  84437. */
  84438. get columnCount(): number;
  84439. /**
  84440. * Gets the number of rows
  84441. */
  84442. get rowCount(): number;
  84443. /** Gets the list of children */
  84444. get children(): Control[];
  84445. /** Gets the list of cells (e.g. the containers) */
  84446. get cells(): {
  84447. [key: string]: Container;
  84448. };
  84449. /**
  84450. * Gets the definition of a specific row
  84451. * @param index defines the index of the row
  84452. * @returns the row definition
  84453. */
  84454. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  84455. /**
  84456. * Gets the definition of a specific column
  84457. * @param index defines the index of the column
  84458. * @returns the column definition
  84459. */
  84460. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  84461. /**
  84462. * Adds a new row to the grid
  84463. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  84464. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  84465. * @returns the current grid
  84466. */
  84467. addRowDefinition(height: number, isPixel?: boolean): Grid;
  84468. /**
  84469. * Adds a new column to the grid
  84470. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  84471. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  84472. * @returns the current grid
  84473. */
  84474. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  84475. /**
  84476. * Update a row definition
  84477. * @param index defines the index of the row to update
  84478. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  84479. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  84480. * @returns the current grid
  84481. */
  84482. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  84483. /**
  84484. * Update a column definition
  84485. * @param index defines the index of the column to update
  84486. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  84487. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  84488. * @returns the current grid
  84489. */
  84490. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  84491. /**
  84492. * Gets the list of children stored in a specific cell
  84493. * @param row defines the row to check
  84494. * @param column defines the column to check
  84495. * @returns the list of controls
  84496. */
  84497. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  84498. /**
  84499. * Gets a string representing the child cell info (row x column)
  84500. * @param child defines the control to get info from
  84501. * @returns a string containing the child cell info (row x column)
  84502. */
  84503. getChildCellInfo(child: Control): string;
  84504. private _removeCell;
  84505. private _offsetCell;
  84506. /**
  84507. * Remove a column definition at specified index
  84508. * @param index defines the index of the column to remove
  84509. * @returns the current grid
  84510. */
  84511. removeColumnDefinition(index: number): Grid;
  84512. /**
  84513. * Remove a row definition at specified index
  84514. * @param index defines the index of the row to remove
  84515. * @returns the current grid
  84516. */
  84517. removeRowDefinition(index: number): Grid;
  84518. /**
  84519. * Adds a new control to the current grid
  84520. * @param control defines the control to add
  84521. * @param row defines the row where to add the control (0 by default)
  84522. * @param column defines the column where to add the control (0 by default)
  84523. * @returns the current grid
  84524. */
  84525. addControl(control: Control, row?: number, column?: number): Grid;
  84526. /**
  84527. * Removes a control from the current container
  84528. * @param control defines the control to remove
  84529. * @returns the current container
  84530. */
  84531. removeControl(control: Control): Container;
  84532. /**
  84533. * Creates a new Grid
  84534. * @param name defines control name
  84535. */
  84536. constructor(name?: string | undefined);
  84537. protected _getTypeName(): string;
  84538. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  84539. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  84540. _flagDescendantsAsMatrixDirty(): void;
  84541. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  84542. /** Releases associated resources */
  84543. dispose(): void;
  84544. }
  84545. }
  84546. declare module BABYLON.GUI {
  84547. /** Class used to create color pickers */
  84548. export class ColorPicker extends Control {
  84549. name?: string | undefined;
  84550. private static _Epsilon;
  84551. private _colorWheelCanvas;
  84552. private _value;
  84553. private _tmpColor;
  84554. private _pointerStartedOnSquare;
  84555. private _pointerStartedOnWheel;
  84556. private _squareLeft;
  84557. private _squareTop;
  84558. private _squareSize;
  84559. private _h;
  84560. private _s;
  84561. private _v;
  84562. private _lastPointerDownID;
  84563. /**
  84564. * BABYLON.Observable raised when the value changes
  84565. */
  84566. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  84567. /** Gets or sets the color of the color picker */
  84568. get value(): BABYLON.Color3;
  84569. set value(value: BABYLON.Color3);
  84570. /**
  84571. * Gets or sets control width
  84572. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  84573. */
  84574. get width(): string | number;
  84575. set width(value: string | number);
  84576. /**
  84577. * Gets or sets control height
  84578. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  84579. */
  84580. get height(): string | number;
  84581. /** Gets or sets control height */
  84582. set height(value: string | number);
  84583. /** Gets or sets control size */
  84584. get size(): string | number;
  84585. set size(value: string | number);
  84586. /**
  84587. * Creates a new ColorPicker
  84588. * @param name defines the control name
  84589. */
  84590. constructor(name?: string | undefined);
  84591. protected _getTypeName(): string;
  84592. /** @hidden */
  84593. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  84594. private _updateSquareProps;
  84595. private _drawGradientSquare;
  84596. private _drawCircle;
  84597. private _createColorWheelCanvas;
  84598. /** @hidden */
  84599. _draw(context: CanvasRenderingContext2D): void;
  84600. private _pointerIsDown;
  84601. private _updateValueFromPointer;
  84602. private _isPointOnSquare;
  84603. private _isPointOnWheel;
  84604. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  84605. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number, pi: BABYLON.PointerInfoBase): void;
  84606. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean, pi: BABYLON.PointerInfoBase): void;
  84607. _onCanvasBlur(): void;
  84608. /**
  84609. * This function expands the color picker by creating a color picker dialog with manual
  84610. * color value input and the ability to save colors into an array to be used later in
  84611. * subsequent launches of the dialogue.
  84612. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  84613. * @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.
  84614. * @returns picked color as a hex string and the saved colors array as hex strings.
  84615. */
  84616. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  84617. pickerWidth?: string;
  84618. pickerHeight?: string;
  84619. headerHeight?: string;
  84620. lastColor?: string;
  84621. swatchLimit?: number;
  84622. numSwatchesPerLine?: number;
  84623. savedColors?: Array<string>;
  84624. }): Promise<{
  84625. savedColors?: string[];
  84626. pickedColor: string;
  84627. }>;
  84628. }
  84629. }
  84630. declare module BABYLON.GUI {
  84631. /** Class used to create 2D ellipse containers */
  84632. export class Ellipse extends Container {
  84633. name?: string | undefined;
  84634. private _thickness;
  84635. /** Gets or sets border thickness */
  84636. get thickness(): number;
  84637. set thickness(value: number);
  84638. /**
  84639. * Creates a new Ellipse
  84640. * @param name defines the control name
  84641. */
  84642. constructor(name?: string | undefined);
  84643. protected _getTypeName(): string;
  84644. protected _localDraw(context: CanvasRenderingContext2D): void;
  84645. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  84646. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  84647. }
  84648. }
  84649. declare module BABYLON.GUI {
  84650. /**
  84651. * Class used to create a focusable button that can easily handle keyboard events
  84652. */
  84653. export class FocusableButton extends Button implements IFocusableControl {
  84654. name?: string | undefined;
  84655. /** Highlight color when button is focused */
  84656. focusedColor: BABYLON.Nullable<string>;
  84657. private _isFocused;
  84658. private _unfocusedColor;
  84659. /** BABYLON.Observable raised when the control gets the focus */
  84660. onFocusObservable: BABYLON.Observable<Button>;
  84661. /** BABYLON.Observable raised when the control loses the focus */
  84662. onBlurObservable: BABYLON.Observable<Button>;
  84663. /** BABYLON.Observable raised when a key event was processed */
  84664. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  84665. constructor(name?: string | undefined);
  84666. /** @hidden */
  84667. onBlur(): void;
  84668. /** @hidden */
  84669. onFocus(): void;
  84670. /**
  84671. * Function called to get the list of controls that should not steal the focus from this control
  84672. * @returns an array of controls
  84673. */
  84674. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  84675. /**
  84676. * Function to focus a button programmatically
  84677. */
  84678. focus(): void;
  84679. /**
  84680. * Function to unfocus a button programmatically
  84681. */
  84682. blur(): void;
  84683. /**
  84684. * Handles the keyboard event
  84685. * @param evt Defines the KeyboardEvent
  84686. */
  84687. processKeyboard(evt: KeyboardEvent): void;
  84688. /** @hidden */
  84689. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  84690. /** @hidden */
  84691. displose(): void;
  84692. }
  84693. }
  84694. declare module BABYLON.GUI {
  84695. /**
  84696. * Class used to create a password control
  84697. */
  84698. export class InputPassword extends InputText {
  84699. protected _beforeRenderText(textWrapper: TextWrapper): TextWrapper;
  84700. }
  84701. }
  84702. declare module BABYLON.GUI {
  84703. /** Class used to render 2D lines */
  84704. export class Line extends Control {
  84705. name?: string | undefined;
  84706. private _lineWidth;
  84707. private _x1;
  84708. private _y1;
  84709. private _x2;
  84710. private _y2;
  84711. private _dash;
  84712. private _connectedControl;
  84713. private _connectedControlDirtyObserver;
  84714. /** Gets or sets the dash pattern */
  84715. get dash(): Array<number>;
  84716. set dash(value: Array<number>);
  84717. /** Gets or sets the control connected with the line end */
  84718. get connectedControl(): Control;
  84719. set connectedControl(value: Control);
  84720. /** Gets or sets start coordinates on X axis */
  84721. get x1(): string | number;
  84722. set x1(value: string | number);
  84723. /** Gets or sets start coordinates on Y axis */
  84724. get y1(): string | number;
  84725. set y1(value: string | number);
  84726. /** Gets or sets end coordinates on X axis */
  84727. get x2(): string | number;
  84728. set x2(value: string | number);
  84729. /** Gets or sets end coordinates on Y axis */
  84730. get y2(): string | number;
  84731. set y2(value: string | number);
  84732. /** Gets or sets line width */
  84733. get lineWidth(): number;
  84734. set lineWidth(value: number);
  84735. /** Gets or sets horizontal alignment */
  84736. set horizontalAlignment(value: number);
  84737. /** Gets or sets vertical alignment */
  84738. set verticalAlignment(value: number);
  84739. private get _effectiveX2();
  84740. private get _effectiveY2();
  84741. /**
  84742. * Creates a new Line
  84743. * @param name defines the control name
  84744. */
  84745. constructor(name?: string | undefined);
  84746. protected _getTypeName(): string;
  84747. _draw(context: CanvasRenderingContext2D): void;
  84748. _measure(): void;
  84749. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  84750. /**
  84751. * Move one end of the line given 3D cartesian coordinates.
  84752. * @param position Targeted world position
  84753. * @param scene BABYLON.Scene
  84754. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  84755. */
  84756. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  84757. /**
  84758. * Move one end of the line to a position in screen absolute space.
  84759. * @param projectedPosition Position in screen absolute space (X, Y)
  84760. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  84761. */
  84762. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  84763. }
  84764. }
  84765. declare module BABYLON.GUI {
  84766. /**
  84767. * Class used to store a point for a MultiLine object.
  84768. * The point can be pure 2D coordinates, a mesh or a control
  84769. */
  84770. export class MultiLinePoint {
  84771. private _multiLine;
  84772. private _x;
  84773. private _y;
  84774. private _control;
  84775. private _mesh;
  84776. private _controlObserver;
  84777. private _meshObserver;
  84778. /** @hidden */
  84779. _point: BABYLON.Vector3;
  84780. /**
  84781. * Creates a new MultiLinePoint
  84782. * @param multiLine defines the source MultiLine object
  84783. */
  84784. constructor(multiLine: MultiLine);
  84785. /** Gets or sets x coordinate */
  84786. get x(): string | number;
  84787. set x(value: string | number);
  84788. /** Gets or sets y coordinate */
  84789. get y(): string | number;
  84790. set y(value: string | number);
  84791. /** Gets or sets the control associated with this point */
  84792. get control(): BABYLON.Nullable<Control>;
  84793. set control(value: BABYLON.Nullable<Control>);
  84794. /** Gets or sets the mesh associated with this point */
  84795. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  84796. set mesh(value: BABYLON.Nullable<BABYLON.AbstractMesh>);
  84797. /** Resets links */
  84798. resetLinks(): void;
  84799. /**
  84800. * Gets a translation vector with Z component
  84801. * @returns the translation vector
  84802. */
  84803. translate(): BABYLON.Vector3;
  84804. private _translatePoint;
  84805. /** Release associated resources */
  84806. dispose(): void;
  84807. }
  84808. }
  84809. declare module BABYLON.GUI {
  84810. /**
  84811. * Class used to create multi line control
  84812. */
  84813. export class MultiLine extends Control {
  84814. name?: string | undefined;
  84815. private _lineWidth;
  84816. private _dash;
  84817. private _points;
  84818. private _minX;
  84819. private _minY;
  84820. private _maxX;
  84821. private _maxY;
  84822. /**
  84823. * Creates a new MultiLine
  84824. * @param name defines the control name
  84825. */
  84826. constructor(name?: string | undefined);
  84827. /** Gets or sets dash pattern */
  84828. get dash(): Array<number>;
  84829. set dash(value: Array<number>);
  84830. /**
  84831. * Gets point stored at specified index
  84832. * @param index defines the index to look for
  84833. * @returns the requested point if found
  84834. */
  84835. getAt(index: number): MultiLinePoint;
  84836. /** Function called when a point is updated */
  84837. onPointUpdate: () => void;
  84838. /**
  84839. * Adds new points to the point collection
  84840. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  84841. * @returns the list of created MultiLinePoint
  84842. */
  84843. add(...items: (AbstractMesh | Control | {
  84844. x: string | number;
  84845. y: string | number;
  84846. })[]): MultiLinePoint[];
  84847. /**
  84848. * Adds a new point to the point collection
  84849. * @param item defines the item (mesh, control or 2d coordiantes) to add
  84850. * @returns the created MultiLinePoint
  84851. */
  84852. push(item?: (AbstractMesh | Control | {
  84853. x: string | number;
  84854. y: string | number;
  84855. })): MultiLinePoint;
  84856. /**
  84857. * Remove a specific value or point from the active point collection
  84858. * @param value defines the value or point to remove
  84859. */
  84860. remove(value: number | MultiLinePoint): void;
  84861. /**
  84862. * Resets this object to initial state (no point)
  84863. */
  84864. reset(): void;
  84865. /**
  84866. * Resets all links
  84867. */
  84868. resetLinks(): void;
  84869. /** Gets or sets line width */
  84870. get lineWidth(): number;
  84871. set lineWidth(value: number);
  84872. set horizontalAlignment(value: number);
  84873. set verticalAlignment(value: number);
  84874. protected _getTypeName(): string;
  84875. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  84876. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  84877. _measure(): void;
  84878. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  84879. dispose(): void;
  84880. }
  84881. }
  84882. declare module BABYLON.GUI {
  84883. /**
  84884. * Class used to create radio button controls
  84885. */
  84886. export class RadioButton extends Control {
  84887. name?: string | undefined;
  84888. private _isChecked;
  84889. private _background;
  84890. private _checkSizeRatio;
  84891. private _thickness;
  84892. /** Gets or sets border thickness */
  84893. get thickness(): number;
  84894. set thickness(value: number);
  84895. /** Gets or sets group name */
  84896. group: string;
  84897. /** BABYLON.Observable raised when isChecked is changed */
  84898. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  84899. /** Gets or sets a value indicating the ratio between overall size and check size */
  84900. get checkSizeRatio(): number;
  84901. set checkSizeRatio(value: number);
  84902. /** Gets or sets background color */
  84903. get background(): string;
  84904. set background(value: string);
  84905. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  84906. get isChecked(): boolean;
  84907. set isChecked(value: boolean);
  84908. /**
  84909. * Creates a new RadioButton
  84910. * @param name defines the control name
  84911. */
  84912. constructor(name?: string | undefined);
  84913. protected _getTypeName(): string;
  84914. _draw(context: CanvasRenderingContext2D): void;
  84915. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  84916. /**
  84917. * Utility function to easily create a radio button with a header
  84918. * @param title defines the label to use for the header
  84919. * @param group defines the group to use for the radio button
  84920. * @param isChecked defines the initial state of the radio button
  84921. * @param onValueChanged defines the callback to call when value changes
  84922. * @returns a StackPanel containing the radio button and a textBlock
  84923. */
  84924. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  84925. }
  84926. }
  84927. declare module BABYLON.GUI {
  84928. /**
  84929. * Class used to create slider controls
  84930. */
  84931. export class BaseSlider extends Control {
  84932. name?: string | undefined;
  84933. protected _thumbWidth: ValueAndUnit;
  84934. private _minimum;
  84935. private _maximum;
  84936. private _value;
  84937. private _isVertical;
  84938. protected _barOffset: ValueAndUnit;
  84939. private _isThumbClamped;
  84940. protected _displayThumb: boolean;
  84941. private _step;
  84942. private _lastPointerDownID;
  84943. protected _effectiveBarOffset: number;
  84944. protected _renderLeft: number;
  84945. protected _renderTop: number;
  84946. protected _renderWidth: number;
  84947. protected _renderHeight: number;
  84948. protected _backgroundBoxLength: number;
  84949. protected _backgroundBoxThickness: number;
  84950. protected _effectiveThumbThickness: number;
  84951. /** BABYLON.Observable raised when the sldier value changes */
  84952. onValueChangedObservable: BABYLON.Observable<number>;
  84953. /** Gets or sets a boolean indicating if the thumb must be rendered */
  84954. get displayThumb(): boolean;
  84955. set displayThumb(value: boolean);
  84956. /** Gets or sets a step to apply to values (0 by default) */
  84957. get step(): number;
  84958. set step(value: number);
  84959. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  84960. get barOffset(): string | number;
  84961. /** Gets main bar offset in pixels*/
  84962. get barOffsetInPixels(): number;
  84963. set barOffset(value: string | number);
  84964. /** Gets or sets thumb width */
  84965. get thumbWidth(): string | number;
  84966. /** Gets thumb width in pixels */
  84967. get thumbWidthInPixels(): number;
  84968. set thumbWidth(value: string | number);
  84969. /** Gets or sets minimum value */
  84970. get minimum(): number;
  84971. set minimum(value: number);
  84972. /** Gets or sets maximum value */
  84973. get maximum(): number;
  84974. set maximum(value: number);
  84975. /** Gets or sets current value */
  84976. get value(): number;
  84977. set value(value: number);
  84978. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  84979. get isVertical(): boolean;
  84980. set isVertical(value: boolean);
  84981. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  84982. get isThumbClamped(): boolean;
  84983. set isThumbClamped(value: boolean);
  84984. /**
  84985. * Creates a new BaseSlider
  84986. * @param name defines the control name
  84987. */
  84988. constructor(name?: string | undefined);
  84989. protected _getTypeName(): string;
  84990. protected _getThumbPosition(): number;
  84991. protected _getThumbThickness(type: string): number;
  84992. protected _prepareRenderingData(type: string): void;
  84993. private _pointerIsDown;
  84994. /** @hidden */
  84995. protected _updateValueFromPointer(x: number, y: number): void;
  84996. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  84997. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number, pi: BABYLON.PointerInfoBase): void;
  84998. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  84999. _onCanvasBlur(): void;
  85000. }
  85001. }
  85002. declare module BABYLON.GUI {
  85003. /**
  85004. * Class used to create slider controls
  85005. */
  85006. export class Slider extends BaseSlider {
  85007. name?: string | undefined;
  85008. private _background;
  85009. private _borderColor;
  85010. private _thumbColor;
  85011. private _isThumbCircle;
  85012. protected _displayValueBar: boolean;
  85013. /** Gets or sets a boolean indicating if the value bar must be rendered */
  85014. get displayValueBar(): boolean;
  85015. set displayValueBar(value: boolean);
  85016. /** Gets or sets border color */
  85017. get borderColor(): string;
  85018. set borderColor(value: string);
  85019. /** Gets or sets background color */
  85020. get background(): string;
  85021. set background(value: string);
  85022. /** Gets or sets thumb's color */
  85023. get thumbColor(): string;
  85024. set thumbColor(value: string);
  85025. /** Gets or sets a boolean indicating if the thumb should be round or square */
  85026. get isThumbCircle(): boolean;
  85027. set isThumbCircle(value: boolean);
  85028. /**
  85029. * Creates a new Slider
  85030. * @param name defines the control name
  85031. */
  85032. constructor(name?: string | undefined);
  85033. protected _getTypeName(): string;
  85034. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  85035. }
  85036. }
  85037. declare module BABYLON.GUI {
  85038. /** Class used to create a RadioGroup
  85039. * which contains groups of radio buttons
  85040. */
  85041. export class SelectorGroup {
  85042. /** name of SelectorGroup */
  85043. name: string;
  85044. private _groupPanel;
  85045. private _selectors;
  85046. private _groupHeader;
  85047. /**
  85048. * Creates a new SelectorGroup
  85049. * @param name of group, used as a group heading
  85050. */
  85051. constructor(
  85052. /** name of SelectorGroup */
  85053. name: string);
  85054. /** Gets the groupPanel of the SelectorGroup */
  85055. get groupPanel(): StackPanel;
  85056. /** Gets the selectors array */
  85057. get selectors(): StackPanel[];
  85058. /** Gets and sets the group header */
  85059. get header(): string;
  85060. set header(label: string);
  85061. /** @hidden */
  85062. private _addGroupHeader;
  85063. /** @hidden*/
  85064. _getSelector(selectorNb: number): StackPanel | undefined;
  85065. /** Removes the selector at the given position
  85066. * @param selectorNb the position of the selector within the group
  85067. */
  85068. removeSelector(selectorNb: number): void;
  85069. }
  85070. /** Class used to create a CheckboxGroup
  85071. * which contains groups of checkbox buttons
  85072. */
  85073. export class CheckboxGroup extends SelectorGroup {
  85074. /** Adds a checkbox as a control
  85075. * @param text is the label for the selector
  85076. * @param func is the function called when the Selector is checked
  85077. * @param checked is true when Selector is checked
  85078. */
  85079. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  85080. /** @hidden */
  85081. _setSelectorLabel(selectorNb: number, label: string): void;
  85082. /** @hidden */
  85083. _setSelectorLabelColor(selectorNb: number, color: string): void;
  85084. /** @hidden */
  85085. _setSelectorButtonColor(selectorNb: number, color: string): void;
  85086. /** @hidden */
  85087. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  85088. }
  85089. /** Class used to create a RadioGroup
  85090. * which contains groups of radio buttons
  85091. */
  85092. export class RadioGroup extends SelectorGroup {
  85093. private _selectNb;
  85094. /** Adds a radio button as a control
  85095. * @param label is the label for the selector
  85096. * @param func is the function called when the Selector is checked
  85097. * @param checked is true when Selector is checked
  85098. */
  85099. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  85100. /** @hidden */
  85101. _setSelectorLabel(selectorNb: number, label: string): void;
  85102. /** @hidden */
  85103. _setSelectorLabelColor(selectorNb: number, color: string): void;
  85104. /** @hidden */
  85105. _setSelectorButtonColor(selectorNb: number, color: string): void;
  85106. /** @hidden */
  85107. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  85108. }
  85109. /** Class used to create a SliderGroup
  85110. * which contains groups of slider buttons
  85111. */
  85112. export class SliderGroup extends SelectorGroup {
  85113. /**
  85114. * Adds a slider to the SelectorGroup
  85115. * @param label is the label for the SliderBar
  85116. * @param func is the function called when the Slider moves
  85117. * @param unit is a string describing the units used, eg degrees or metres
  85118. * @param min is the minimum value for the Slider
  85119. * @param max is the maximum value for the Slider
  85120. * @param value is the start value for the Slider between min and max
  85121. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  85122. */
  85123. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  85124. /** @hidden */
  85125. _setSelectorLabel(selectorNb: number, label: string): void;
  85126. /** @hidden */
  85127. _setSelectorLabelColor(selectorNb: number, color: string): void;
  85128. /** @hidden */
  85129. _setSelectorButtonColor(selectorNb: number, color: string): void;
  85130. /** @hidden */
  85131. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  85132. }
  85133. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  85134. * @see https://doc.babylonjs.com/how_to/selector
  85135. */
  85136. export class SelectionPanel extends Rectangle {
  85137. /** name of SelectionPanel */
  85138. name: string;
  85139. /** an array of SelectionGroups */
  85140. groups: SelectorGroup[];
  85141. private _panel;
  85142. private _buttonColor;
  85143. private _buttonBackground;
  85144. private _headerColor;
  85145. private _barColor;
  85146. private _barHeight;
  85147. private _spacerHeight;
  85148. private _labelColor;
  85149. private _groups;
  85150. private _bars;
  85151. /**
  85152. * Creates a new SelectionPanel
  85153. * @param name of SelectionPanel
  85154. * @param groups is an array of SelectionGroups
  85155. */
  85156. constructor(
  85157. /** name of SelectionPanel */
  85158. name: string,
  85159. /** an array of SelectionGroups */
  85160. groups?: SelectorGroup[]);
  85161. protected _getTypeName(): string;
  85162. /** Gets the (stack) panel of the SelectionPanel */
  85163. get panel(): StackPanel;
  85164. /** Gets or sets the headerColor */
  85165. get headerColor(): string;
  85166. set headerColor(color: string);
  85167. private _setHeaderColor;
  85168. /** Gets or sets the button color */
  85169. get buttonColor(): string;
  85170. set buttonColor(color: string);
  85171. private _setbuttonColor;
  85172. /** Gets or sets the label color */
  85173. get labelColor(): string;
  85174. set labelColor(color: string);
  85175. private _setLabelColor;
  85176. /** Gets or sets the button background */
  85177. get buttonBackground(): string;
  85178. set buttonBackground(color: string);
  85179. private _setButtonBackground;
  85180. /** Gets or sets the color of separator bar */
  85181. get barColor(): string;
  85182. set barColor(color: string);
  85183. private _setBarColor;
  85184. /** Gets or sets the height of separator bar */
  85185. get barHeight(): string;
  85186. set barHeight(value: string);
  85187. private _setBarHeight;
  85188. /** Gets or sets the height of spacers*/
  85189. get spacerHeight(): string;
  85190. set spacerHeight(value: string);
  85191. private _setSpacerHeight;
  85192. /** Adds a bar between groups */
  85193. private _addSpacer;
  85194. /** Add a group to the selection panel
  85195. * @param group is the selector group to add
  85196. */
  85197. addGroup(group: SelectorGroup): void;
  85198. /** Remove the group from the given position
  85199. * @param groupNb is the position of the group in the list
  85200. */
  85201. removeGroup(groupNb: number): void;
  85202. /** Change a group header label
  85203. * @param label is the new group header label
  85204. * @param groupNb is the number of the group to relabel
  85205. * */
  85206. setHeaderName(label: string, groupNb: number): void;
  85207. /** Change selector label to the one given
  85208. * @param label is the new selector label
  85209. * @param groupNb is the number of the groupcontaining the selector
  85210. * @param selectorNb is the number of the selector within a group to relabel
  85211. * */
  85212. relabel(label: string, groupNb: number, selectorNb: number): void;
  85213. /** For a given group position remove the selector at the given position
  85214. * @param groupNb is the number of the group to remove the selector from
  85215. * @param selectorNb is the number of the selector within the group
  85216. */
  85217. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  85218. /** For a given group position of correct type add a checkbox button
  85219. * @param groupNb is the number of the group to remove the selector from
  85220. * @param label is the label for the selector
  85221. * @param func is the function called when the Selector is checked
  85222. * @param checked is true when Selector is checked
  85223. */
  85224. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  85225. /** For a given group position of correct type add a radio button
  85226. * @param groupNb is the number of the group to remove the selector from
  85227. * @param label is the label for the selector
  85228. * @param func is the function called when the Selector is checked
  85229. * @param checked is true when Selector is checked
  85230. */
  85231. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  85232. /**
  85233. * For a given slider group add a slider
  85234. * @param groupNb is the number of the group to add the slider to
  85235. * @param label is the label for the Slider
  85236. * @param func is the function called when the Slider moves
  85237. * @param unit is a string describing the units used, eg degrees or metres
  85238. * @param min is the minimum value for the Slider
  85239. * @param max is the maximum value for the Slider
  85240. * @param value is the start value for the Slider between min and max
  85241. * @param onVal is the function used to format the value displayed, eg radians to degrees
  85242. */
  85243. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  85244. }
  85245. }
  85246. declare module BABYLON.GUI {
  85247. /**
  85248. * Class used to hold a the container for ScrollViewer
  85249. * @hidden
  85250. */
  85251. export class _ScrollViewerWindow extends Container {
  85252. parentClientWidth: number;
  85253. parentClientHeight: number;
  85254. private _freezeControls;
  85255. private _parentMeasure;
  85256. private _oldLeft;
  85257. private _oldTop;
  85258. get freezeControls(): boolean;
  85259. set freezeControls(value: boolean);
  85260. private _bucketWidth;
  85261. private _bucketHeight;
  85262. private _buckets;
  85263. private _bucketLen;
  85264. get bucketWidth(): number;
  85265. get bucketHeight(): number;
  85266. setBucketSizes(width: number, height: number): void;
  85267. private _useBuckets;
  85268. private _makeBuckets;
  85269. private _dispatchInBuckets;
  85270. private _updateMeasures;
  85271. private _updateChildrenMeasures;
  85272. private _restoreMeasures;
  85273. /**
  85274. * Creates a new ScrollViewerWindow
  85275. * @param name of ScrollViewerWindow
  85276. */
  85277. constructor(name?: string);
  85278. protected _getTypeName(): string;
  85279. /** @hidden */
  85280. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  85281. /** @hidden */
  85282. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  85283. private _scrollChildren;
  85284. private _scrollChildrenWithBuckets;
  85285. /** @hidden */
  85286. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  85287. protected _postMeasure(): void;
  85288. }
  85289. }
  85290. declare module BABYLON.GUI {
  85291. /**
  85292. * Class used to create slider controls
  85293. */
  85294. export class ScrollBar extends BaseSlider {
  85295. name?: string | undefined;
  85296. private _background;
  85297. private _borderColor;
  85298. private _tempMeasure;
  85299. /** Gets or sets border color */
  85300. get borderColor(): string;
  85301. set borderColor(value: string);
  85302. /** Gets or sets background color */
  85303. get background(): string;
  85304. set background(value: string);
  85305. /**
  85306. * Creates a new Slider
  85307. * @param name defines the control name
  85308. */
  85309. constructor(name?: string | undefined);
  85310. protected _getTypeName(): string;
  85311. protected _getThumbThickness(): number;
  85312. _draw(context: CanvasRenderingContext2D): void;
  85313. private _first;
  85314. private _originX;
  85315. private _originY;
  85316. /** @hidden */
  85317. protected _updateValueFromPointer(x: number, y: number): void;
  85318. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  85319. }
  85320. }
  85321. declare module BABYLON.GUI {
  85322. /**
  85323. * Class used to create slider controls
  85324. */
  85325. export class ImageScrollBar extends BaseSlider {
  85326. name?: string | undefined;
  85327. private _backgroundBaseImage;
  85328. private _backgroundImage;
  85329. private _thumbImage;
  85330. private _thumbBaseImage;
  85331. private _thumbLength;
  85332. private _thumbHeight;
  85333. private _barImageHeight;
  85334. private _tempMeasure;
  85335. /** Number of 90° rotation to apply on the images when in vertical mode */
  85336. num90RotationInVerticalMode: number;
  85337. /**
  85338. * Gets or sets the image used to render the background for horizontal bar
  85339. */
  85340. get backgroundImage(): Image;
  85341. set backgroundImage(value: Image);
  85342. /**
  85343. * Gets or sets the image used to render the thumb
  85344. */
  85345. get thumbImage(): Image;
  85346. set thumbImage(value: Image);
  85347. /**
  85348. * Gets or sets the length of the thumb
  85349. */
  85350. get thumbLength(): number;
  85351. set thumbLength(value: number);
  85352. /**
  85353. * Gets or sets the height of the thumb
  85354. */
  85355. get thumbHeight(): number;
  85356. set thumbHeight(value: number);
  85357. /**
  85358. * Gets or sets the height of the bar image
  85359. */
  85360. get barImageHeight(): number;
  85361. set barImageHeight(value: number);
  85362. /**
  85363. * Creates a new ImageScrollBar
  85364. * @param name defines the control name
  85365. */
  85366. constructor(name?: string | undefined);
  85367. protected _getTypeName(): string;
  85368. protected _getThumbThickness(): number;
  85369. _draw(context: CanvasRenderingContext2D): void;
  85370. private _first;
  85371. private _originX;
  85372. private _originY;
  85373. /** @hidden */
  85374. protected _updateValueFromPointer(x: number, y: number): void;
  85375. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  85376. }
  85377. }
  85378. declare module BABYLON.GUI {
  85379. /**
  85380. * Class used to hold a viewer window and sliders in a grid
  85381. */
  85382. export class ScrollViewer extends Rectangle {
  85383. private _grid;
  85384. private _horizontalBarSpace;
  85385. private _verticalBarSpace;
  85386. private _dragSpace;
  85387. private _horizontalBar;
  85388. private _verticalBar;
  85389. private _barColor;
  85390. private _barBackground;
  85391. private _barImage;
  85392. private _horizontalBarImage;
  85393. private _verticalBarImage;
  85394. private _barBackgroundImage;
  85395. private _horizontalBarBackgroundImage;
  85396. private _verticalBarBackgroundImage;
  85397. private _barSize;
  85398. private _window;
  85399. private _pointerIsOver;
  85400. private _wheelPrecision;
  85401. private _onWheelObserver;
  85402. private _clientWidth;
  85403. private _clientHeight;
  85404. private _useImageBar;
  85405. private _thumbLength;
  85406. private _thumbHeight;
  85407. private _barImageHeight;
  85408. private _horizontalBarImageHeight;
  85409. private _verticalBarImageHeight;
  85410. private _oldWindowContentsWidth;
  85411. private _oldWindowContentsHeight;
  85412. /**
  85413. * Gets the horizontal scrollbar
  85414. */
  85415. get horizontalBar(): ScrollBar | ImageScrollBar;
  85416. /**
  85417. * Gets the vertical scrollbar
  85418. */
  85419. get verticalBar(): ScrollBar | ImageScrollBar;
  85420. /**
  85421. * Adds a new control to the current container
  85422. * @param control defines the control to add
  85423. * @returns the current container
  85424. */
  85425. addControl(control: BABYLON.Nullable<Control>): Container;
  85426. /**
  85427. * Removes a control from the current container
  85428. * @param control defines the control to remove
  85429. * @returns the current container
  85430. */
  85431. removeControl(control: Control): Container;
  85432. /** Gets the list of children */
  85433. get children(): Control[];
  85434. _flagDescendantsAsMatrixDirty(): void;
  85435. /**
  85436. * Freezes or unfreezes the controls in the window.
  85437. * When controls are frozen, the scroll viewer can render a lot more quickly but updates to positions/sizes of controls
  85438. * are not taken into account. If you want to change positions/sizes, unfreeze, perform the changes then freeze again
  85439. */
  85440. get freezeControls(): boolean;
  85441. set freezeControls(value: boolean);
  85442. /** Gets the bucket width */
  85443. get bucketWidth(): number;
  85444. /** Gets the bucket height */
  85445. get bucketHeight(): number;
  85446. /**
  85447. * Sets the bucket sizes.
  85448. * When freezeControls is true, setting a non-zero bucket size will improve performances by updating only
  85449. * controls that are visible. The bucket sizes is used to subdivide (internally) the window area to smaller areas into which
  85450. * controls are dispatched. So, the size should be roughly equals to the mean size of all the controls of
  85451. * the window. To disable the usage of buckets, sets either width or height (or both) to 0.
  85452. * Please note that using this option will raise the memory usage (the higher the bucket sizes, the less memory
  85453. * used), that's why it is not enabled by default.
  85454. * @param width width of the bucket
  85455. * @param height height of the bucket
  85456. */
  85457. setBucketSizes(width: number, height: number): void;
  85458. private _forceHorizontalBar;
  85459. private _forceVerticalBar;
  85460. /**
  85461. * Forces the horizontal scroll bar to be displayed
  85462. */
  85463. get forceHorizontalBar(): boolean;
  85464. set forceHorizontalBar(value: boolean);
  85465. /**
  85466. * Forces the vertical scroll bar to be displayed
  85467. */
  85468. get forceVerticalBar(): boolean;
  85469. set forceVerticalBar(value: boolean);
  85470. /**
  85471. * Creates a new ScrollViewer
  85472. * @param name of ScrollViewer
  85473. */
  85474. constructor(name?: string, isImageBased?: boolean);
  85475. /** Reset the scroll viewer window to initial size */
  85476. resetWindow(): void;
  85477. protected _getTypeName(): string;
  85478. private _buildClientSizes;
  85479. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  85480. protected _postMeasure(): void;
  85481. /**
  85482. * Gets or sets the mouse wheel precision
  85483. * from 0 to 1 with a default value of 0.05
  85484. * */
  85485. get wheelPrecision(): number;
  85486. set wheelPrecision(value: number);
  85487. /** Gets or sets the scroll bar container background color */
  85488. get scrollBackground(): string;
  85489. set scrollBackground(color: string);
  85490. /** Gets or sets the bar color */
  85491. get barColor(): string;
  85492. set barColor(color: string);
  85493. /** Gets or sets the bar image */
  85494. get thumbImage(): Image;
  85495. set thumbImage(value: Image);
  85496. /** Gets or sets the horizontal bar image */
  85497. get horizontalThumbImage(): Image;
  85498. set horizontalThumbImage(value: Image);
  85499. /** Gets or sets the vertical bar image */
  85500. get verticalThumbImage(): Image;
  85501. set verticalThumbImage(value: Image);
  85502. /** Gets or sets the size of the bar */
  85503. get barSize(): number;
  85504. set barSize(value: number);
  85505. /** Gets or sets the length of the thumb */
  85506. get thumbLength(): number;
  85507. set thumbLength(value: number);
  85508. /** Gets or sets the height of the thumb */
  85509. get thumbHeight(): number;
  85510. set thumbHeight(value: number);
  85511. /** Gets or sets the height of the bar image */
  85512. get barImageHeight(): number;
  85513. set barImageHeight(value: number);
  85514. /** Gets or sets the height of the horizontal bar image */
  85515. get horizontalBarImageHeight(): number;
  85516. set horizontalBarImageHeight(value: number);
  85517. /** Gets or sets the height of the vertical bar image */
  85518. get verticalBarImageHeight(): number;
  85519. set verticalBarImageHeight(value: number);
  85520. /** Gets or sets the bar background */
  85521. get barBackground(): string;
  85522. set barBackground(color: string);
  85523. /** Gets or sets the bar background image */
  85524. get barImage(): Image;
  85525. set barImage(value: Image);
  85526. /** Gets or sets the horizontal bar background image */
  85527. get horizontalBarImage(): Image;
  85528. set horizontalBarImage(value: Image);
  85529. /** Gets or sets the vertical bar background image */
  85530. get verticalBarImage(): Image;
  85531. set verticalBarImage(value: Image);
  85532. private _setWindowPosition;
  85533. /** @hidden */
  85534. private _updateScroller;
  85535. _link(host: AdvancedDynamicTexture): void;
  85536. /** @hidden */
  85537. private _addBar;
  85538. /** @hidden */
  85539. private _attachWheel;
  85540. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  85541. /** Releases associated resources */
  85542. dispose(): void;
  85543. }
  85544. }
  85545. declare module BABYLON.GUI {
  85546. /**
  85547. * Class used to create toggle buttons
  85548. */
  85549. export class ToggleButton extends Rectangle {
  85550. name?: string | undefined;
  85551. /**
  85552. * Function called to generate the toActive animation
  85553. */
  85554. toActiveAnimation: () => void;
  85555. /**
  85556. * Function called to generate the toInactive animation
  85557. */
  85558. toInactiveAnimation: () => void;
  85559. /**
  85560. * Function called to generate a pointer enter animation when the toggle button is active.
  85561. */
  85562. pointerEnterActiveAnimation: () => void;
  85563. /**
  85564. * Function called to generate a pointer out animation when the toggle button is active.
  85565. */
  85566. pointerOutActiveAnimation: () => void;
  85567. /**
  85568. * Function called to generate a pointer down animation when the toggle button is active.
  85569. */
  85570. pointerDownActiveAnimation: () => void;
  85571. /**
  85572. * Function called to generate a pointer up animation when the toggle button is active.
  85573. */
  85574. pointerUpActiveAnimation: () => void;
  85575. /**
  85576. * Function called to generate a pointer enter animation when the toggle button is inactive.
  85577. */
  85578. pointerEnterInactiveAnimation: () => void;
  85579. /**
  85580. * Function called to generate a pointer out animation when the toggle button is inactive.
  85581. */
  85582. pointerOutInactiveAnimation: () => void;
  85583. /**
  85584. * Function called to generate a pointer down animation when the toggle button is inactive.
  85585. */
  85586. pointerDownInactiveAnimation: () => void;
  85587. /**
  85588. * Function called to generate a pointer up animation when the toggle button is inactive.
  85589. */
  85590. pointerUpInactiveAnimation: () => void;
  85591. /** BABYLON.Observable raised when isActive is changed */
  85592. onIsActiveChangedObservable: BABYLON.Observable<boolean>;
  85593. /**
  85594. * Gets or sets a boolean indicating that the toggle button will let internal controls handle picking instead of doing it directly using its bounding info
  85595. */
  85596. delegatePickingToChildren: boolean;
  85597. private _image;
  85598. /**
  85599. * Returns the ToggleButton's image control if it exists
  85600. */
  85601. get image(): BABYLON.Nullable<Image>;
  85602. private _textBlock;
  85603. /**
  85604. * Returns the ToggleButton's child TextBlock control if it exists
  85605. */
  85606. get textBlock(): BABYLON.Nullable<TextBlock>;
  85607. private _group;
  85608. /** Gets or sets group name this toggle button belongs to */
  85609. get group(): string;
  85610. set group(value: string);
  85611. private _isActive;
  85612. /** Gets or sets a boolean indicating if the toogle button is active or not */
  85613. get isActive(): boolean;
  85614. set isActive(value: boolean);
  85615. /**
  85616. * Creates a new ToggleButton
  85617. * @param name defines the control name
  85618. * @param group defines the toggle group this toggle belongs to
  85619. */
  85620. constructor(name?: string | undefined, group?: string);
  85621. protected _getTypeName(): string;
  85622. /** @hidden */
  85623. _processPicking(x: number, y: number, pi: BABYLON.PointerInfoBase, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  85624. /** @hidden */
  85625. _onPointerEnter(target: Control, pi: BABYLON.PointerInfoBase): boolean;
  85626. /** @hidden */
  85627. _onPointerOut(target: Control, pi: BABYLON.PointerInfoBase, force?: boolean): void;
  85628. /** @hidden */
  85629. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  85630. /** @hidden */
  85631. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean, pi: BABYLON.PointerInfoBase): void;
  85632. }
  85633. }
  85634. declare module BABYLON.GUI {
  85635. /** Class used to render a grid */
  85636. export class DisplayGrid extends Control {
  85637. name?: string | undefined;
  85638. private _cellWidth;
  85639. private _cellHeight;
  85640. private _minorLineTickness;
  85641. private _minorLineColor;
  85642. private _majorLineTickness;
  85643. private _majorLineColor;
  85644. private _majorLineFrequency;
  85645. private _background;
  85646. private _displayMajorLines;
  85647. private _displayMinorLines;
  85648. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  85649. get displayMinorLines(): boolean;
  85650. set displayMinorLines(value: boolean);
  85651. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  85652. get displayMajorLines(): boolean;
  85653. set displayMajorLines(value: boolean);
  85654. /** Gets or sets background color (Black by default) */
  85655. get background(): string;
  85656. set background(value: string);
  85657. /** Gets or sets the width of each cell (20 by default) */
  85658. get cellWidth(): number;
  85659. set cellWidth(value: number);
  85660. /** Gets or sets the height of each cell (20 by default) */
  85661. get cellHeight(): number;
  85662. set cellHeight(value: number);
  85663. /** Gets or sets the tickness of minor lines (1 by default) */
  85664. get minorLineTickness(): number;
  85665. set minorLineTickness(value: number);
  85666. /** Gets or sets the color of minor lines (DarkGray by default) */
  85667. get minorLineColor(): string;
  85668. set minorLineColor(value: string);
  85669. /** Gets or sets the tickness of major lines (2 by default) */
  85670. get majorLineTickness(): number;
  85671. set majorLineTickness(value: number);
  85672. /** Gets or sets the color of major lines (White by default) */
  85673. get majorLineColor(): string;
  85674. set majorLineColor(value: string);
  85675. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  85676. get majorLineFrequency(): number;
  85677. set majorLineFrequency(value: number);
  85678. /**
  85679. * Creates a new GridDisplayRectangle
  85680. * @param name defines the control name
  85681. */
  85682. constructor(name?: string | undefined);
  85683. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  85684. protected _getTypeName(): string;
  85685. }
  85686. }
  85687. declare module BABYLON.GUI {
  85688. /**
  85689. * Class used to create slider controls based on images
  85690. */
  85691. export class ImageBasedSlider extends BaseSlider {
  85692. name?: string | undefined;
  85693. private _backgroundImage;
  85694. private _thumbImage;
  85695. private _valueBarImage;
  85696. private _tempMeasure;
  85697. get displayThumb(): boolean;
  85698. set displayThumb(value: boolean);
  85699. /**
  85700. * Gets or sets the image used to render the background
  85701. */
  85702. get backgroundImage(): Image;
  85703. set backgroundImage(value: Image);
  85704. /**
  85705. * Gets or sets the image used to render the value bar
  85706. */
  85707. get valueBarImage(): Image;
  85708. set valueBarImage(value: Image);
  85709. /**
  85710. * Gets or sets the image used to render the thumb
  85711. */
  85712. get thumbImage(): Image;
  85713. set thumbImage(value: Image);
  85714. /**
  85715. * Creates a new ImageBasedSlider
  85716. * @param name defines the control name
  85717. */
  85718. constructor(name?: string | undefined);
  85719. protected _getTypeName(): string;
  85720. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  85721. }
  85722. }
  85723. declare module BABYLON.GUI {
  85724. /**
  85725. * Forcing an export so that this code will execute
  85726. * @hidden
  85727. */
  85728. const name = "Statics";
  85729. }
  85730. declare module BABYLON.GUI {
  85731. /**
  85732. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  85733. */
  85734. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  85735. /**
  85736. * Define the instrumented AdvancedDynamicTexture.
  85737. */
  85738. texture: AdvancedDynamicTexture;
  85739. private _captureRenderTime;
  85740. private _renderTime;
  85741. private _captureLayoutTime;
  85742. private _layoutTime;
  85743. private _onBeginRenderObserver;
  85744. private _onEndRenderObserver;
  85745. private _onBeginLayoutObserver;
  85746. private _onEndLayoutObserver;
  85747. /**
  85748. * Gets the perf counter used to capture render time
  85749. */
  85750. get renderTimeCounter(): BABYLON.PerfCounter;
  85751. /**
  85752. * Gets the perf counter used to capture layout time
  85753. */
  85754. get layoutTimeCounter(): BABYLON.PerfCounter;
  85755. /**
  85756. * Enable or disable the render time capture
  85757. */
  85758. get captureRenderTime(): boolean;
  85759. set captureRenderTime(value: boolean);
  85760. /**
  85761. * Enable or disable the layout time capture
  85762. */
  85763. get captureLayoutTime(): boolean;
  85764. set captureLayoutTime(value: boolean);
  85765. /**
  85766. * Instantiates a new advanced dynamic texture instrumentation.
  85767. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  85768. * @param texture Defines the AdvancedDynamicTexture to instrument
  85769. */
  85770. constructor(
  85771. /**
  85772. * Define the instrumented AdvancedDynamicTexture.
  85773. */
  85774. texture: AdvancedDynamicTexture);
  85775. /**
  85776. * Dispose and release associated resources.
  85777. */
  85778. dispose(): void;
  85779. }
  85780. }
  85781. declare module BABYLON.GUI {
  85782. /**
  85783. * Class used to load GUI via XML.
  85784. */
  85785. export class XmlLoader {
  85786. private _nodes;
  85787. private _nodeTypes;
  85788. private _isLoaded;
  85789. private _objectAttributes;
  85790. private _parentClass;
  85791. /**
  85792. * Create a new xml loader
  85793. * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context
  85794. */
  85795. constructor(parentClass?: null);
  85796. private _getChainElement;
  85797. private _getClassAttribute;
  85798. private _createGuiElement;
  85799. private _parseGrid;
  85800. private _parseElement;
  85801. private _prepareSourceElement;
  85802. private _parseElementsFromSource;
  85803. private _parseXml;
  85804. /**
  85805. * Gets if the loading has finished.
  85806. * @returns whether the loading has finished or not
  85807. */
  85808. isLoaded(): boolean;
  85809. /**
  85810. * Gets a loaded node / control by id.
  85811. * @param id the Controls id set in the xml
  85812. * @returns element of type Control
  85813. */
  85814. getNodeById(id: string): any;
  85815. /**
  85816. * Gets all loaded nodes / controls
  85817. * @returns Array of controls
  85818. */
  85819. getNodes(): any;
  85820. /**
  85821. * Initiates the xml layout loading
  85822. * @param xmlFile defines the xml layout to load
  85823. * @param rootNode defines the node / control to use as a parent for the loaded layout controls.
  85824. * @param callback defines the callback called on layout load.
  85825. */
  85826. loadLayout(xmlFile: any, rootNode: any, callback: any): void;
  85827. }
  85828. }
  85829. declare module BABYLON.GUI {
  85830. /**
  85831. * Class used to create containers for controls
  85832. */
  85833. export class Container3D extends Control3D {
  85834. private _blockLayout;
  85835. /**
  85836. * Gets the list of child controls
  85837. */
  85838. protected _children: Control3D[];
  85839. /**
  85840. * Gets the list of child controls
  85841. */
  85842. get children(): Array<Control3D>;
  85843. /**
  85844. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  85845. * This is helpful to optimize layout operation when adding multiple children in a row
  85846. */
  85847. get blockLayout(): boolean;
  85848. set blockLayout(value: boolean);
  85849. /**
  85850. * Creates a new container
  85851. * @param name defines the container name
  85852. */
  85853. constructor(name?: string);
  85854. /**
  85855. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  85856. * @returns the current container
  85857. */
  85858. updateLayout(): Container3D;
  85859. /**
  85860. * Gets a boolean indicating if the given control is in the children of this control
  85861. * @param control defines the control to check
  85862. * @returns true if the control is in the child list
  85863. */
  85864. containsControl(control: Control3D): boolean;
  85865. /**
  85866. * Adds a control to the children of this control
  85867. * @param control defines the control to add
  85868. * @returns the current container
  85869. */
  85870. addControl(control: Control3D): Container3D;
  85871. /**
  85872. * This function will be called everytime a new control is added
  85873. */
  85874. protected _arrangeChildren(): void;
  85875. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  85876. /**
  85877. * Removes a control from the children of this control
  85878. * @param control defines the control to remove
  85879. * @returns the current container
  85880. */
  85881. removeControl(control: Control3D): Container3D;
  85882. protected _getTypeName(): string;
  85883. /**
  85884. * Releases all associated resources
  85885. */
  85886. dispose(): void;
  85887. /** Control rotation will remain unchanged */
  85888. static readonly UNSET_ORIENTATION: number;
  85889. /** Control will rotate to make it look at sphere central axis */
  85890. static readonly FACEORIGIN_ORIENTATION: number;
  85891. /** Control will rotate to make it look back at sphere central axis */
  85892. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  85893. /** Control will rotate to look at z axis (0, 0, 1) */
  85894. static readonly FACEFORWARD_ORIENTATION: number;
  85895. /** Control will rotate to look at negative z axis (0, 0, -1) */
  85896. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  85897. }
  85898. }
  85899. declare module BABYLON.GUI {
  85900. /**
  85901. * Class used to manage 3D user interface
  85902. * @see https://doc.babylonjs.com/how_to/gui3d
  85903. */
  85904. export class GUI3DManager implements BABYLON.IDisposable {
  85905. private _scene;
  85906. private _sceneDisposeObserver;
  85907. private _utilityLayer;
  85908. private _rootContainer;
  85909. private _pointerObserver;
  85910. private _pointerOutObserver;
  85911. /** @hidden */
  85912. _lastPickedControl: Control3D;
  85913. /** @hidden */
  85914. _lastControlOver: {
  85915. [pointerId: number]: Control3D;
  85916. };
  85917. /** @hidden */
  85918. _lastControlDown: {
  85919. [pointerId: number]: Control3D;
  85920. };
  85921. /**
  85922. * BABYLON.Observable raised when the point picked by the pointer events changed
  85923. */
  85924. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  85925. /** @hidden */
  85926. _sharedMaterials: {
  85927. [key: string]: BABYLON.Material;
  85928. };
  85929. /** Gets the hosting scene */
  85930. get scene(): BABYLON.Scene;
  85931. /** Gets associated utility layer */
  85932. get utilityLayer(): BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  85933. /**
  85934. * Creates a new GUI3DManager
  85935. * @param scene
  85936. */
  85937. constructor(scene?: BABYLON.Scene);
  85938. private _handlePointerOut;
  85939. private _doPicking;
  85940. /**
  85941. * Gets the root container
  85942. */
  85943. get rootContainer(): Container3D;
  85944. /**
  85945. * Gets a boolean indicating if the given control is in the root child list
  85946. * @param control defines the control to check
  85947. * @returns true if the control is in the root child list
  85948. */
  85949. containsControl(control: Control3D): boolean;
  85950. /**
  85951. * Adds a control to the root child list
  85952. * @param control defines the control to add
  85953. * @returns the current manager
  85954. */
  85955. addControl(control: Control3D): GUI3DManager;
  85956. /**
  85957. * Removes a control from the root child list
  85958. * @param control defines the control to remove
  85959. * @returns the current container
  85960. */
  85961. removeControl(control: Control3D): GUI3DManager;
  85962. /**
  85963. * Releases all associated resources
  85964. */
  85965. dispose(): void;
  85966. }
  85967. }
  85968. declare module BABYLON.GUI {
  85969. /**
  85970. * Class used to transport BABYLON.Vector3 information for pointer events
  85971. */
  85972. export class Vector3WithInfo extends BABYLON.Vector3 {
  85973. /** defines the current mouse button index */
  85974. buttonIndex: number;
  85975. /**
  85976. * Creates a new Vector3WithInfo
  85977. * @param source defines the vector3 data to transport
  85978. * @param buttonIndex defines the current mouse button index
  85979. */
  85980. constructor(source: BABYLON.Vector3,
  85981. /** defines the current mouse button index */
  85982. buttonIndex?: number);
  85983. }
  85984. }
  85985. declare module BABYLON.GUI {
  85986. /**
  85987. * Class used as base class for controls
  85988. */
  85989. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  85990. /** Defines the control name */
  85991. name?: string | undefined;
  85992. /** @hidden */
  85993. _host: GUI3DManager;
  85994. private _node;
  85995. private _downCount;
  85996. private _enterCount;
  85997. private _downPointerIds;
  85998. private _isVisible;
  85999. /** Gets or sets the control position in world space */
  86000. get position(): BABYLON.Vector3;
  86001. set position(value: BABYLON.Vector3);
  86002. /** Gets or sets the control scaling in world space */
  86003. get scaling(): BABYLON.Vector3;
  86004. set scaling(value: BABYLON.Vector3);
  86005. /** Callback used to start pointer enter animation */
  86006. pointerEnterAnimation: () => void;
  86007. /** Callback used to start pointer out animation */
  86008. pointerOutAnimation: () => void;
  86009. /** Callback used to start pointer down animation */
  86010. pointerDownAnimation: () => void;
  86011. /** Callback used to start pointer up animation */
  86012. pointerUpAnimation: () => void;
  86013. /**
  86014. * An event triggered when the pointer move over the control
  86015. */
  86016. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  86017. /**
  86018. * An event triggered when the pointer move out of the control
  86019. */
  86020. onPointerOutObservable: BABYLON.Observable<Control3D>;
  86021. /**
  86022. * An event triggered when the pointer taps the control
  86023. */
  86024. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  86025. /**
  86026. * An event triggered when pointer is up
  86027. */
  86028. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  86029. /**
  86030. * An event triggered when a control is clicked on (with a mouse)
  86031. */
  86032. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  86033. /**
  86034. * An event triggered when pointer enters the control
  86035. */
  86036. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  86037. /**
  86038. * Gets or sets the parent container
  86039. */
  86040. parent: BABYLON.Nullable<Container3D>;
  86041. private _behaviors;
  86042. /**
  86043. * Gets the list of attached behaviors
  86044. * @see https://doc.babylonjs.com/features/behaviour
  86045. */
  86046. get behaviors(): BABYLON.Behavior<Control3D>[];
  86047. /**
  86048. * Attach a behavior to the control
  86049. * @see https://doc.babylonjs.com/features/behaviour
  86050. * @param behavior defines the behavior to attach
  86051. * @returns the current control
  86052. */
  86053. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  86054. /**
  86055. * Remove an attached behavior
  86056. * @see https://doc.babylonjs.com/features/behaviour
  86057. * @param behavior defines the behavior to attach
  86058. * @returns the current control
  86059. */
  86060. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  86061. /**
  86062. * Gets an attached behavior by name
  86063. * @param name defines the name of the behavior to look for
  86064. * @see https://doc.babylonjs.com/features/behaviour
  86065. * @returns null if behavior was not found else the requested behavior
  86066. */
  86067. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  86068. /** Gets or sets a boolean indicating if the control is visible */
  86069. get isVisible(): boolean;
  86070. set isVisible(value: boolean);
  86071. /**
  86072. * Creates a new control
  86073. * @param name defines the control name
  86074. */
  86075. constructor(
  86076. /** Defines the control name */
  86077. name?: string | undefined);
  86078. /**
  86079. * Gets a string representing the class name
  86080. */
  86081. get typeName(): string;
  86082. /**
  86083. * Get the current class name of the control.
  86084. * @returns current class name
  86085. */
  86086. getClassName(): string;
  86087. protected _getTypeName(): string;
  86088. /**
  86089. * Gets the transform node used by this control
  86090. */
  86091. get node(): BABYLON.Nullable<BABYLON.TransformNode>;
  86092. /**
  86093. * Gets the mesh used to render this control
  86094. */
  86095. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  86096. /**
  86097. * Link the control as child of the given node
  86098. * @param node defines the node to link to. Use null to unlink the control
  86099. * @returns the current control
  86100. */
  86101. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  86102. /** @hidden **/
  86103. _prepareNode(scene: BABYLON.Scene): void;
  86104. protected _injectGUI3DMetadata(node: BABYLON.TransformNode): any;
  86105. /**
  86106. * Node creation.
  86107. * Can be overriden by children
  86108. * @param scene defines the scene where the node must be attached
  86109. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  86110. */
  86111. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  86112. /**
  86113. * Affect a material to the given mesh
  86114. * @param mesh defines the mesh which will represent the control
  86115. */
  86116. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  86117. /** @hidden */
  86118. _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  86119. /** @hidden */
  86120. _onPointerEnter(target: Control3D): boolean;
  86121. /** @hidden */
  86122. _onPointerOut(target: Control3D): void;
  86123. /** @hidden */
  86124. _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  86125. /** @hidden */
  86126. _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  86127. /** @hidden */
  86128. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  86129. /** @hidden */
  86130. _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  86131. /** @hidden */
  86132. _disposeNode(): void;
  86133. /**
  86134. * Releases all associated resources
  86135. */
  86136. dispose(): void;
  86137. }
  86138. }
  86139. declare module BABYLON.GUI {
  86140. /**
  86141. * Class used as a root to all buttons
  86142. */
  86143. export class AbstractButton3D extends Control3D {
  86144. /**
  86145. * Creates a new button
  86146. * @param name defines the control name
  86147. */
  86148. constructor(name?: string);
  86149. protected _getTypeName(): string;
  86150. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  86151. }
  86152. }
  86153. declare module BABYLON.GUI {
  86154. /**
  86155. * Class used to create a button in 3D
  86156. */
  86157. export class Button3D extends AbstractButton3D {
  86158. /** @hidden */
  86159. protected _currentMaterial: BABYLON.Material;
  86160. private _facadeTexture;
  86161. private _content;
  86162. private _contentResolution;
  86163. private _contentScaleRatio;
  86164. /**
  86165. * Gets or sets the texture resolution used to render content (512 by default)
  86166. */
  86167. get contentResolution(): BABYLON.int;
  86168. set contentResolution(value: BABYLON.int);
  86169. /**
  86170. * Gets or sets the texture scale ratio used to render content (2 by default)
  86171. */
  86172. get contentScaleRatio(): number;
  86173. set contentScaleRatio(value: number);
  86174. protected _disposeFacadeTexture(): void;
  86175. protected _resetContent(): void;
  86176. /**
  86177. * Creates a new button
  86178. * @param name defines the control name
  86179. */
  86180. constructor(name?: string);
  86181. /**
  86182. * Gets or sets the GUI 2D content used to display the button's facade
  86183. */
  86184. get content(): Control;
  86185. set content(value: Control);
  86186. /**
  86187. * Apply the facade texture (created from the content property).
  86188. * This function can be overloaded by child classes
  86189. * @param facadeTexture defines the AdvancedDynamicTexture to use
  86190. */
  86191. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  86192. protected _getTypeName(): string;
  86193. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  86194. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  86195. /**
  86196. * Releases all associated resources
  86197. */
  86198. dispose(): void;
  86199. }
  86200. }
  86201. declare module BABYLON.GUI {
  86202. /**
  86203. * Abstract class used to create a container panel deployed on the surface of a volume
  86204. */
  86205. export abstract class VolumeBasedPanel extends Container3D {
  86206. private _columns;
  86207. private _rows;
  86208. private _rowThenColum;
  86209. private _orientation;
  86210. protected _cellWidth: number;
  86211. protected _cellHeight: number;
  86212. /**
  86213. * Gets or sets the distance between elements
  86214. */
  86215. margin: number;
  86216. /**
  86217. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  86218. * | Value | Type | Description |
  86219. * | ----- | ----------------------------------- | ----------- |
  86220. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  86221. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  86222. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  86223. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  86224. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  86225. */
  86226. get orientation(): number;
  86227. set orientation(value: number);
  86228. /**
  86229. * Gets or sets the number of columns requested (10 by default).
  86230. * The panel will automatically compute the number of rows based on number of child controls.
  86231. */
  86232. get columns(): BABYLON.int;
  86233. set columns(value: BABYLON.int);
  86234. /**
  86235. * Gets or sets a the number of rows requested.
  86236. * The panel will automatically compute the number of columns based on number of child controls.
  86237. */
  86238. get rows(): BABYLON.int;
  86239. set rows(value: BABYLON.int);
  86240. /**
  86241. * Creates new VolumeBasedPanel
  86242. */
  86243. constructor();
  86244. protected _arrangeChildren(): void;
  86245. /** Child classes must implement this function to provide correct control positioning */
  86246. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  86247. /** Child classes can implement this function to provide additional processing */
  86248. protected _finalProcessing(): void;
  86249. }
  86250. }
  86251. declare module BABYLON.GUI {
  86252. /**
  86253. * Class used to create a container panel deployed on the surface of a cylinder
  86254. */
  86255. export class CylinderPanel extends VolumeBasedPanel {
  86256. private _radius;
  86257. /**
  86258. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  86259. */
  86260. get radius(): BABYLON.float;
  86261. set radius(value: BABYLON.float);
  86262. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  86263. private _cylindricalMapping;
  86264. }
  86265. }
  86266. declare module BABYLON.GUI {
  86267. /** @hidden */
  86268. export var fluentVertexShader: {
  86269. name: string;
  86270. shader: string;
  86271. };
  86272. }
  86273. declare module BABYLON.GUI {
  86274. /** @hidden */
  86275. export var fluentPixelShader: {
  86276. name: string;
  86277. shader: string;
  86278. };
  86279. }
  86280. declare module BABYLON.GUI {
  86281. /** @hidden */
  86282. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  86283. INNERGLOW: boolean;
  86284. BORDER: boolean;
  86285. HOVERLIGHT: boolean;
  86286. TEXTURE: boolean;
  86287. constructor();
  86288. }
  86289. /**
  86290. * Class used to render controls with fluent desgin
  86291. */
  86292. export class FluentMaterial extends BABYLON.PushMaterial {
  86293. /**
  86294. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  86295. */
  86296. innerGlowColorIntensity: number;
  86297. /**
  86298. * Gets or sets the inner glow color (white by default)
  86299. */
  86300. innerGlowColor: BABYLON.Color3;
  86301. /**
  86302. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  86303. */
  86304. albedoColor: BABYLON.Color3;
  86305. /**
  86306. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  86307. */
  86308. renderBorders: boolean;
  86309. /**
  86310. * Gets or sets border width (default is 0.5)
  86311. */
  86312. borderWidth: number;
  86313. /**
  86314. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  86315. */
  86316. edgeSmoothingValue: number;
  86317. /**
  86318. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  86319. */
  86320. borderMinValue: number;
  86321. /**
  86322. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  86323. */
  86324. renderHoverLight: boolean;
  86325. /**
  86326. * Gets or sets the radius used to render the hover light (default is 1.0)
  86327. */
  86328. hoverRadius: number;
  86329. /**
  86330. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  86331. */
  86332. hoverColor: BABYLON.Color4;
  86333. /**
  86334. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  86335. */
  86336. hoverPosition: BABYLON.Vector3;
  86337. private _albedoTexture;
  86338. /** Gets or sets the texture to use for albedo color */
  86339. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  86340. /**
  86341. * Creates a new Fluent material
  86342. * @param name defines the name of the material
  86343. * @param scene defines the hosting scene
  86344. */
  86345. constructor(name: string, scene: BABYLON.Scene);
  86346. needAlphaBlending(): boolean;
  86347. needAlphaTesting(): boolean;
  86348. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  86349. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86350. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86351. getActiveTextures(): BABYLON.BaseTexture[];
  86352. hasTexture(texture: BABYLON.BaseTexture): boolean;
  86353. dispose(forceDisposeEffect?: boolean): void;
  86354. clone(name: string): FluentMaterial;
  86355. serialize(): any;
  86356. getClassName(): string;
  86357. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  86358. }
  86359. }
  86360. declare module BABYLON.GUI {
  86361. /**
  86362. * Class used to create a holographic button in 3D
  86363. */
  86364. export class HolographicButton extends Button3D {
  86365. private _backPlate;
  86366. private _textPlate;
  86367. private _frontPlate;
  86368. private _text;
  86369. private _imageUrl;
  86370. private _shareMaterials;
  86371. private _frontMaterial;
  86372. private _backMaterial;
  86373. private _plateMaterial;
  86374. private _pickedPointObserver;
  86375. private _tooltipFade;
  86376. private _tooltipTextBlock;
  86377. private _tooltipTexture;
  86378. private _tooltipMesh;
  86379. private _tooltipHoverObserver;
  86380. private _tooltipOutObserver;
  86381. private _disposeTooltip;
  86382. /**
  86383. * Rendering ground id of all the mesh in the button
  86384. */
  86385. set renderingGroupId(id: number);
  86386. get renderingGroupId(): number;
  86387. /**
  86388. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  86389. */
  86390. set tooltipText(text: BABYLON.Nullable<string>);
  86391. get tooltipText(): BABYLON.Nullable<string>;
  86392. /**
  86393. * Gets or sets text for the button
  86394. */
  86395. get text(): string;
  86396. set text(value: string);
  86397. /**
  86398. * Gets or sets the image url for the button
  86399. */
  86400. get imageUrl(): string;
  86401. set imageUrl(value: string);
  86402. /**
  86403. * Gets the back material used by this button
  86404. */
  86405. get backMaterial(): FluentMaterial;
  86406. /**
  86407. * Gets the front material used by this button
  86408. */
  86409. get frontMaterial(): FluentMaterial;
  86410. /**
  86411. * Gets the plate material used by this button
  86412. */
  86413. get plateMaterial(): BABYLON.StandardMaterial;
  86414. /**
  86415. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  86416. */
  86417. get shareMaterials(): boolean;
  86418. /**
  86419. * Creates a new button
  86420. * @param name defines the control name
  86421. */
  86422. constructor(name?: string, shareMaterials?: boolean);
  86423. protected _getTypeName(): string;
  86424. private _rebuildContent;
  86425. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  86426. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  86427. private _createBackMaterial;
  86428. private _createFrontMaterial;
  86429. private _createPlateMaterial;
  86430. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  86431. /**
  86432. * Releases all associated resources
  86433. */
  86434. dispose(): void;
  86435. }
  86436. }
  86437. declare module BABYLON.GUI {
  86438. /**
  86439. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  86440. */
  86441. export class MeshButton3D extends Button3D {
  86442. /** @hidden */
  86443. protected _currentMesh: BABYLON.Mesh;
  86444. /**
  86445. * Creates a new 3D button based on a mesh
  86446. * @param mesh mesh to become a 3D button
  86447. * @param name defines the control name
  86448. */
  86449. constructor(mesh: BABYLON.Mesh, name?: string);
  86450. protected _getTypeName(): string;
  86451. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  86452. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  86453. }
  86454. }
  86455. declare module BABYLON.GUI {
  86456. /**
  86457. * Class used to create a container panel deployed on the surface of a plane
  86458. */
  86459. export class PlanePanel extends VolumeBasedPanel {
  86460. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  86461. }
  86462. }
  86463. declare module BABYLON.GUI {
  86464. /**
  86465. * Class used to create a container panel where items get randomized planar mapping
  86466. */
  86467. export class ScatterPanel extends VolumeBasedPanel {
  86468. private _iteration;
  86469. /**
  86470. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  86471. */
  86472. get iteration(): BABYLON.float;
  86473. set iteration(value: BABYLON.float);
  86474. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  86475. private _scatterMapping;
  86476. protected _finalProcessing(): void;
  86477. }
  86478. }
  86479. declare module BABYLON.GUI {
  86480. /**
  86481. * Class used to create a container panel deployed on the surface of a sphere
  86482. */
  86483. export class SpherePanel extends VolumeBasedPanel {
  86484. private _radius;
  86485. /**
  86486. * Gets or sets the radius of the sphere where to project controls (5 by default)
  86487. */
  86488. get radius(): BABYLON.float;
  86489. set radius(value: BABYLON.float);
  86490. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  86491. private _sphericalMapping;
  86492. }
  86493. }
  86494. declare module BABYLON.GUI {
  86495. /**
  86496. * Class used to create a stack panel in 3D on XY plane
  86497. */
  86498. export class StackPanel3D extends Container3D {
  86499. private _isVertical;
  86500. /**
  86501. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  86502. */
  86503. get isVertical(): boolean;
  86504. set isVertical(value: boolean);
  86505. /**
  86506. * Gets or sets the distance between elements
  86507. */
  86508. margin: number;
  86509. /**
  86510. * Creates new StackPanel
  86511. * @param isVertical
  86512. */
  86513. constructor(isVertical?: boolean);
  86514. protected _arrangeChildren(): void;
  86515. }
  86516. }
  86517. declare module BABYLON {
  86518. /**
  86519. * Configuration for glTF validation
  86520. */
  86521. export interface IGLTFValidationConfiguration {
  86522. /**
  86523. * The url of the glTF validator.
  86524. */
  86525. url: string;
  86526. }
  86527. /**
  86528. * glTF validation
  86529. */
  86530. export class GLTFValidation {
  86531. /**
  86532. * The configuration. Defaults to `{ url: "https://preview.babylonjs.com/gltf_validator.js" }`.
  86533. */
  86534. static Configuration: IGLTFValidationConfiguration;
  86535. private static _LoadScriptPromise;
  86536. /**
  86537. * Validate a glTF asset using the glTF-Validator.
  86538. * @param data The JSON of a glTF or the array buffer of a binary glTF
  86539. * @param rootUrl The root url for the glTF
  86540. * @param fileName The file name for the glTF
  86541. * @param getExternalResource The callback to get external resources for the glTF validator
  86542. * @returns A promise that resolves with the glTF validation results once complete
  86543. */
  86544. static ValidateAsync(data: string | ArrayBuffer, rootUrl: string, fileName: string, getExternalResource: (uri: string) => Promise<ArrayBuffer>): Promise<BABYLON.GLTF2.IGLTFValidationResults>;
  86545. }
  86546. }
  86547. declare module BABYLON {
  86548. /**
  86549. * Mode that determines the coordinate system to use.
  86550. */
  86551. export enum GLTFLoaderCoordinateSystemMode {
  86552. /**
  86553. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  86554. */
  86555. AUTO = 0,
  86556. /**
  86557. * Sets the useRightHandedSystem flag on the scene.
  86558. */
  86559. FORCE_RIGHT_HANDED = 1
  86560. }
  86561. /**
  86562. * Mode that determines what animations will start.
  86563. */
  86564. export enum GLTFLoaderAnimationStartMode {
  86565. /**
  86566. * No animation will start.
  86567. */
  86568. NONE = 0,
  86569. /**
  86570. * The first animation will start.
  86571. */
  86572. FIRST = 1,
  86573. /**
  86574. * All animations will start.
  86575. */
  86576. ALL = 2
  86577. }
  86578. /**
  86579. * Interface that contains the data for the glTF asset.
  86580. */
  86581. export interface IGLTFLoaderData {
  86582. /**
  86583. * The object that represents the glTF JSON.
  86584. */
  86585. json: Object;
  86586. /**
  86587. * The BIN chunk of a binary glTF.
  86588. */
  86589. bin: Nullable<IDataBuffer>;
  86590. }
  86591. /**
  86592. * Interface for extending the loader.
  86593. */
  86594. export interface IGLTFLoaderExtension {
  86595. /**
  86596. * The name of this extension.
  86597. */
  86598. readonly name: string;
  86599. /**
  86600. * Defines whether this extension is enabled.
  86601. */
  86602. enabled: boolean;
  86603. /**
  86604. * Defines the order of this extension.
  86605. * The loader sorts the extensions using these values when loading.
  86606. */
  86607. order?: number;
  86608. }
  86609. /**
  86610. * Loader state.
  86611. */
  86612. export enum GLTFLoaderState {
  86613. /**
  86614. * The asset is loading.
  86615. */
  86616. LOADING = 0,
  86617. /**
  86618. * The asset is ready for rendering.
  86619. */
  86620. READY = 1,
  86621. /**
  86622. * The asset is completely loaded.
  86623. */
  86624. COMPLETE = 2
  86625. }
  86626. /** @hidden */
  86627. export interface IGLTFLoader extends IDisposable {
  86628. readonly state: Nullable<GLTFLoaderState>;
  86629. importMeshAsync: (meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string) => Promise<ISceneLoaderAsyncResult>;
  86630. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  86631. }
  86632. /**
  86633. * File loader for loading glTF files into a scene.
  86634. */
  86635. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  86636. /** @hidden */
  86637. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  86638. /** @hidden */
  86639. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  86640. /**
  86641. * Raised when the asset has been parsed
  86642. */
  86643. onParsedObservable: Observable<IGLTFLoaderData>;
  86644. private _onParsedObserver;
  86645. /**
  86646. * Raised when the asset has been parsed
  86647. */
  86648. set onParsed(callback: (loaderData: IGLTFLoaderData) => void);
  86649. /**
  86650. * 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.
  86651. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  86652. * Defaults to true.
  86653. * @hidden
  86654. */
  86655. static IncrementalLoading: boolean;
  86656. /**
  86657. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  86658. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  86659. * @hidden
  86660. */
  86661. static HomogeneousCoordinates: boolean;
  86662. /**
  86663. * The coordinate system mode. Defaults to AUTO.
  86664. */
  86665. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  86666. /**
  86667. * The animation start mode. Defaults to FIRST.
  86668. */
  86669. animationStartMode: GLTFLoaderAnimationStartMode;
  86670. /**
  86671. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  86672. */
  86673. compileMaterials: boolean;
  86674. /**
  86675. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  86676. */
  86677. useClipPlane: boolean;
  86678. /**
  86679. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  86680. */
  86681. compileShadowGenerators: boolean;
  86682. /**
  86683. * Defines if the Alpha blended materials are only applied as coverage.
  86684. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  86685. * If true, no extra effects are applied to transparent pixels.
  86686. */
  86687. transparencyAsCoverage: boolean;
  86688. /**
  86689. * Defines if the loader should use range requests when load binary glTF files from HTTP.
  86690. * Enabling will disable offline support and glTF validator.
  86691. * Defaults to false.
  86692. */
  86693. useRangeRequests: boolean;
  86694. /**
  86695. * Defines if the loader should create instances when multiple glTF nodes point to the same glTF mesh. Defaults to true.
  86696. */
  86697. createInstances: boolean;
  86698. /**
  86699. * 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.
  86700. */
  86701. alwaysComputeBoundingBox: boolean;
  86702. /**
  86703. * If true, load all materials defined in the file, even if not used by any mesh. Defaults to false.
  86704. */
  86705. loadAllMaterials: boolean;
  86706. /**
  86707. * Function called before loading a url referenced by the asset.
  86708. */
  86709. preprocessUrlAsync: (url: string) => Promise<string>;
  86710. /**
  86711. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  86712. * 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, ...)
  86713. */
  86714. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  86715. private _onMeshLoadedObserver;
  86716. /**
  86717. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  86718. * 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, ...)
  86719. */
  86720. set onMeshLoaded(callback: (mesh: AbstractMesh) => void);
  86721. /**
  86722. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  86723. */
  86724. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  86725. private _onTextureLoadedObserver;
  86726. /**
  86727. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  86728. */
  86729. set onTextureLoaded(callback: (texture: BaseTexture) => void);
  86730. /**
  86731. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  86732. */
  86733. readonly onMaterialLoadedObservable: Observable<Material>;
  86734. private _onMaterialLoadedObserver;
  86735. /**
  86736. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  86737. */
  86738. set onMaterialLoaded(callback: (material: Material) => void);
  86739. /**
  86740. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  86741. */
  86742. readonly onCameraLoadedObservable: Observable<Camera>;
  86743. private _onCameraLoadedObserver;
  86744. /**
  86745. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  86746. */
  86747. set onCameraLoaded(callback: (camera: Camera) => void);
  86748. /**
  86749. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  86750. * For assets with LODs, raised when all of the LODs are complete.
  86751. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  86752. */
  86753. readonly onCompleteObservable: Observable<void>;
  86754. private _onCompleteObserver;
  86755. /**
  86756. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  86757. * For assets with LODs, raised when all of the LODs are complete.
  86758. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  86759. */
  86760. set onComplete(callback: () => void);
  86761. /**
  86762. * Observable raised when an error occurs.
  86763. */
  86764. readonly onErrorObservable: Observable<any>;
  86765. private _onErrorObserver;
  86766. /**
  86767. * Callback raised when an error occurs.
  86768. */
  86769. set onError(callback: (reason: any) => void);
  86770. /**
  86771. * Observable raised after the loader is disposed.
  86772. */
  86773. readonly onDisposeObservable: Observable<void>;
  86774. private _onDisposeObserver;
  86775. /**
  86776. * Callback raised after the loader is disposed.
  86777. */
  86778. set onDispose(callback: () => void);
  86779. /**
  86780. * Observable raised after a loader extension is created.
  86781. * Set additional options for a loader extension in this event.
  86782. */
  86783. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  86784. private _onExtensionLoadedObserver;
  86785. /**
  86786. * Callback raised after a loader extension is created.
  86787. */
  86788. set onExtensionLoaded(callback: (extension: IGLTFLoaderExtension) => void);
  86789. /**
  86790. * Defines if the loader logging is enabled.
  86791. */
  86792. get loggingEnabled(): boolean;
  86793. set loggingEnabled(value: boolean);
  86794. /**
  86795. * Defines if the loader should capture performance counters.
  86796. */
  86797. get capturePerformanceCounters(): boolean;
  86798. set capturePerformanceCounters(value: boolean);
  86799. /**
  86800. * Defines if the loader should validate the asset.
  86801. */
  86802. validate: boolean;
  86803. /**
  86804. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  86805. */
  86806. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  86807. private _onValidatedObserver;
  86808. /**
  86809. * Callback raised after a loader extension is created.
  86810. */
  86811. set onValidated(callback: (results: BABYLON.GLTF2.IGLTFValidationResults) => void);
  86812. private _loader;
  86813. private _progressCallback?;
  86814. private _requests;
  86815. private static magicBase64Encoded;
  86816. /**
  86817. * Name of the loader ("gltf")
  86818. */
  86819. name: string;
  86820. /** @hidden */
  86821. extensions: ISceneLoaderPluginExtensions;
  86822. /**
  86823. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  86824. */
  86825. dispose(): void;
  86826. /** @hidden */
  86827. requestFile(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  86828. /** @hidden */
  86829. readFile(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  86830. /** @hidden */
  86831. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<ISceneLoaderAsyncResult>;
  86832. /** @hidden */
  86833. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  86834. /** @hidden */
  86835. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  86836. /** @hidden */
  86837. canDirectLoad(data: string): boolean;
  86838. /** @hidden */
  86839. directLoad(scene: Scene, data: string): Promise<any>;
  86840. /**
  86841. * The callback that allows custom handling of the root url based on the response url.
  86842. * @param rootUrl the original root url
  86843. * @param responseURL the response url if available
  86844. * @returns the new root url
  86845. */
  86846. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  86847. /** @hidden */
  86848. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  86849. /**
  86850. * The loader state or null if the loader is not active.
  86851. */
  86852. get loaderState(): Nullable<GLTFLoaderState>;
  86853. /**
  86854. * Returns a promise that resolves when the asset is completely loaded.
  86855. * @returns a promise that resolves when the asset is completely loaded.
  86856. */
  86857. whenCompleteAsync(): Promise<void>;
  86858. /** @hidden */
  86859. _loadFile(url: string, scene: Scene, onSuccess: (data: string | ArrayBuffer) => void, useArrayBuffer?: boolean, onError?: (request?: WebRequest) => void): IFileRequest;
  86860. /** @hidden */
  86861. _requestFile(url: string, scene: Scene, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  86862. private _onProgress;
  86863. private _validate;
  86864. private _getLoader;
  86865. private _parseJson;
  86866. private _unpackBinaryAsync;
  86867. private _unpackBinaryV1Async;
  86868. private _unpackBinaryV2Async;
  86869. private static _parseVersion;
  86870. private static _compareVersion;
  86871. private static readonly _logSpaces;
  86872. private _logIndentLevel;
  86873. private _loggingEnabled;
  86874. /** @hidden */
  86875. _log: (message: string) => void;
  86876. /** @hidden */
  86877. _logOpen(message: string): void;
  86878. /** @hidden */
  86879. _logClose(): void;
  86880. private _logEnabled;
  86881. private _logDisabled;
  86882. private _capturePerformanceCounters;
  86883. /** @hidden */
  86884. _startPerformanceCounter: (counterName: string) => void;
  86885. /** @hidden */
  86886. _endPerformanceCounter: (counterName: string) => void;
  86887. private _startPerformanceCounterEnabled;
  86888. private _startPerformanceCounterDisabled;
  86889. private _endPerformanceCounterEnabled;
  86890. private _endPerformanceCounterDisabled;
  86891. }
  86892. }
  86893. declare module BABYLON.GLTF1 {
  86894. /**
  86895. * Enums
  86896. * @hidden
  86897. */
  86898. export enum EComponentType {
  86899. BYTE = 5120,
  86900. UNSIGNED_BYTE = 5121,
  86901. SHORT = 5122,
  86902. UNSIGNED_SHORT = 5123,
  86903. FLOAT = 5126
  86904. }
  86905. /** @hidden */
  86906. export enum EShaderType {
  86907. FRAGMENT = 35632,
  86908. VERTEX = 35633
  86909. }
  86910. /** @hidden */
  86911. export enum EParameterType {
  86912. BYTE = 5120,
  86913. UNSIGNED_BYTE = 5121,
  86914. SHORT = 5122,
  86915. UNSIGNED_SHORT = 5123,
  86916. INT = 5124,
  86917. UNSIGNED_INT = 5125,
  86918. FLOAT = 5126,
  86919. FLOAT_VEC2 = 35664,
  86920. FLOAT_VEC3 = 35665,
  86921. FLOAT_VEC4 = 35666,
  86922. INT_VEC2 = 35667,
  86923. INT_VEC3 = 35668,
  86924. INT_VEC4 = 35669,
  86925. BOOL = 35670,
  86926. BOOL_VEC2 = 35671,
  86927. BOOL_VEC3 = 35672,
  86928. BOOL_VEC4 = 35673,
  86929. FLOAT_MAT2 = 35674,
  86930. FLOAT_MAT3 = 35675,
  86931. FLOAT_MAT4 = 35676,
  86932. SAMPLER_2D = 35678
  86933. }
  86934. /** @hidden */
  86935. export enum ETextureWrapMode {
  86936. CLAMP_TO_EDGE = 33071,
  86937. MIRRORED_REPEAT = 33648,
  86938. REPEAT = 10497
  86939. }
  86940. /** @hidden */
  86941. export enum ETextureFilterType {
  86942. NEAREST = 9728,
  86943. LINEAR = 9728,
  86944. NEAREST_MIPMAP_NEAREST = 9984,
  86945. LINEAR_MIPMAP_NEAREST = 9985,
  86946. NEAREST_MIPMAP_LINEAR = 9986,
  86947. LINEAR_MIPMAP_LINEAR = 9987
  86948. }
  86949. /** @hidden */
  86950. export enum ETextureFormat {
  86951. ALPHA = 6406,
  86952. RGB = 6407,
  86953. RGBA = 6408,
  86954. LUMINANCE = 6409,
  86955. LUMINANCE_ALPHA = 6410
  86956. }
  86957. /** @hidden */
  86958. export enum ECullingType {
  86959. FRONT = 1028,
  86960. BACK = 1029,
  86961. FRONT_AND_BACK = 1032
  86962. }
  86963. /** @hidden */
  86964. export enum EBlendingFunction {
  86965. ZERO = 0,
  86966. ONE = 1,
  86967. SRC_COLOR = 768,
  86968. ONE_MINUS_SRC_COLOR = 769,
  86969. DST_COLOR = 774,
  86970. ONE_MINUS_DST_COLOR = 775,
  86971. SRC_ALPHA = 770,
  86972. ONE_MINUS_SRC_ALPHA = 771,
  86973. DST_ALPHA = 772,
  86974. ONE_MINUS_DST_ALPHA = 773,
  86975. CONSTANT_COLOR = 32769,
  86976. ONE_MINUS_CONSTANT_COLOR = 32770,
  86977. CONSTANT_ALPHA = 32771,
  86978. ONE_MINUS_CONSTANT_ALPHA = 32772,
  86979. SRC_ALPHA_SATURATE = 776
  86980. }
  86981. /** @hidden */
  86982. export interface IGLTFProperty {
  86983. extensions?: {
  86984. [key: string]: any;
  86985. };
  86986. extras?: Object;
  86987. }
  86988. /** @hidden */
  86989. export interface IGLTFChildRootProperty extends IGLTFProperty {
  86990. name?: string;
  86991. }
  86992. /** @hidden */
  86993. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  86994. bufferView: string;
  86995. byteOffset: number;
  86996. byteStride: number;
  86997. count: number;
  86998. type: string;
  86999. componentType: EComponentType;
  87000. max?: number[];
  87001. min?: number[];
  87002. name?: string;
  87003. }
  87004. /** @hidden */
  87005. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  87006. buffer: string;
  87007. byteOffset: number;
  87008. byteLength: number;
  87009. byteStride: number;
  87010. target?: number;
  87011. }
  87012. /** @hidden */
  87013. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  87014. uri: string;
  87015. byteLength?: number;
  87016. type?: string;
  87017. }
  87018. /** @hidden */
  87019. export interface IGLTFShader extends IGLTFChildRootProperty {
  87020. uri: string;
  87021. type: EShaderType;
  87022. }
  87023. /** @hidden */
  87024. export interface IGLTFProgram extends IGLTFChildRootProperty {
  87025. attributes: string[];
  87026. fragmentShader: string;
  87027. vertexShader: string;
  87028. }
  87029. /** @hidden */
  87030. export interface IGLTFTechniqueParameter {
  87031. type: number;
  87032. count?: number;
  87033. semantic?: string;
  87034. node?: string;
  87035. value?: number | boolean | string | Array<any>;
  87036. source?: string;
  87037. babylonValue?: any;
  87038. }
  87039. /** @hidden */
  87040. export interface IGLTFTechniqueCommonProfile {
  87041. lightingModel: string;
  87042. texcoordBindings: Object;
  87043. parameters?: Array<any>;
  87044. }
  87045. /** @hidden */
  87046. export interface IGLTFTechniqueStatesFunctions {
  87047. blendColor?: number[];
  87048. blendEquationSeparate?: number[];
  87049. blendFuncSeparate?: number[];
  87050. colorMask: boolean[];
  87051. cullFace: number[];
  87052. }
  87053. /** @hidden */
  87054. export interface IGLTFTechniqueStates {
  87055. enable: number[];
  87056. functions: IGLTFTechniqueStatesFunctions;
  87057. }
  87058. /** @hidden */
  87059. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  87060. parameters: {
  87061. [key: string]: IGLTFTechniqueParameter;
  87062. };
  87063. program: string;
  87064. attributes: {
  87065. [key: string]: string;
  87066. };
  87067. uniforms: {
  87068. [key: string]: string;
  87069. };
  87070. states: IGLTFTechniqueStates;
  87071. }
  87072. /** @hidden */
  87073. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  87074. technique?: string;
  87075. values: string[];
  87076. }
  87077. /** @hidden */
  87078. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  87079. attributes: {
  87080. [key: string]: string;
  87081. };
  87082. indices: string;
  87083. material: string;
  87084. mode?: number;
  87085. }
  87086. /** @hidden */
  87087. export interface IGLTFMesh extends IGLTFChildRootProperty {
  87088. primitives: IGLTFMeshPrimitive[];
  87089. }
  87090. /** @hidden */
  87091. export interface IGLTFImage extends IGLTFChildRootProperty {
  87092. uri: string;
  87093. }
  87094. /** @hidden */
  87095. export interface IGLTFSampler extends IGLTFChildRootProperty {
  87096. magFilter?: number;
  87097. minFilter?: number;
  87098. wrapS?: number;
  87099. wrapT?: number;
  87100. }
  87101. /** @hidden */
  87102. export interface IGLTFTexture extends IGLTFChildRootProperty {
  87103. sampler: string;
  87104. source: string;
  87105. format?: ETextureFormat;
  87106. internalFormat?: ETextureFormat;
  87107. target?: number;
  87108. type?: number;
  87109. babylonTexture?: Texture;
  87110. }
  87111. /** @hidden */
  87112. export interface IGLTFAmbienLight {
  87113. color?: number[];
  87114. }
  87115. /** @hidden */
  87116. export interface IGLTFDirectionalLight {
  87117. color?: number[];
  87118. }
  87119. /** @hidden */
  87120. export interface IGLTFPointLight {
  87121. color?: number[];
  87122. constantAttenuation?: number;
  87123. linearAttenuation?: number;
  87124. quadraticAttenuation?: number;
  87125. }
  87126. /** @hidden */
  87127. export interface IGLTFSpotLight {
  87128. color?: number[];
  87129. constantAttenuation?: number;
  87130. fallOfAngle?: number;
  87131. fallOffExponent?: number;
  87132. linearAttenuation?: number;
  87133. quadraticAttenuation?: number;
  87134. }
  87135. /** @hidden */
  87136. export interface IGLTFLight extends IGLTFChildRootProperty {
  87137. type: string;
  87138. }
  87139. /** @hidden */
  87140. export interface IGLTFCameraOrthographic {
  87141. xmag: number;
  87142. ymag: number;
  87143. zfar: number;
  87144. znear: number;
  87145. }
  87146. /** @hidden */
  87147. export interface IGLTFCameraPerspective {
  87148. aspectRatio: number;
  87149. yfov: number;
  87150. zfar: number;
  87151. znear: number;
  87152. }
  87153. /** @hidden */
  87154. export interface IGLTFCamera extends IGLTFChildRootProperty {
  87155. type: string;
  87156. }
  87157. /** @hidden */
  87158. export interface IGLTFAnimationChannelTarget {
  87159. id: string;
  87160. path: string;
  87161. }
  87162. /** @hidden */
  87163. export interface IGLTFAnimationChannel {
  87164. sampler: string;
  87165. target: IGLTFAnimationChannelTarget;
  87166. }
  87167. /** @hidden */
  87168. export interface IGLTFAnimationSampler {
  87169. input: string;
  87170. output: string;
  87171. interpolation?: string;
  87172. }
  87173. /** @hidden */
  87174. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  87175. channels?: IGLTFAnimationChannel[];
  87176. parameters?: {
  87177. [key: string]: string;
  87178. };
  87179. samplers?: {
  87180. [key: string]: IGLTFAnimationSampler;
  87181. };
  87182. }
  87183. /** @hidden */
  87184. export interface IGLTFNodeInstanceSkin {
  87185. skeletons: string[];
  87186. skin: string;
  87187. meshes: string[];
  87188. }
  87189. /** @hidden */
  87190. export interface IGLTFSkins extends IGLTFChildRootProperty {
  87191. bindShapeMatrix: number[];
  87192. inverseBindMatrices: string;
  87193. jointNames: string[];
  87194. babylonSkeleton?: Skeleton;
  87195. }
  87196. /** @hidden */
  87197. export interface IGLTFNode extends IGLTFChildRootProperty {
  87198. camera?: string;
  87199. children: string[];
  87200. skin?: string;
  87201. jointName?: string;
  87202. light?: string;
  87203. matrix: number[];
  87204. mesh?: string;
  87205. meshes?: string[];
  87206. rotation?: number[];
  87207. scale?: number[];
  87208. translation?: number[];
  87209. babylonNode?: Node;
  87210. }
  87211. /** @hidden */
  87212. export interface IGLTFScene extends IGLTFChildRootProperty {
  87213. nodes: string[];
  87214. }
  87215. /** @hidden */
  87216. export interface IGLTFRuntime {
  87217. extensions: {
  87218. [key: string]: any;
  87219. };
  87220. accessors: {
  87221. [key: string]: IGLTFAccessor;
  87222. };
  87223. buffers: {
  87224. [key: string]: IGLTFBuffer;
  87225. };
  87226. bufferViews: {
  87227. [key: string]: IGLTFBufferView;
  87228. };
  87229. meshes: {
  87230. [key: string]: IGLTFMesh;
  87231. };
  87232. lights: {
  87233. [key: string]: IGLTFLight;
  87234. };
  87235. cameras: {
  87236. [key: string]: IGLTFCamera;
  87237. };
  87238. nodes: {
  87239. [key: string]: IGLTFNode;
  87240. };
  87241. images: {
  87242. [key: string]: IGLTFImage;
  87243. };
  87244. textures: {
  87245. [key: string]: IGLTFTexture;
  87246. };
  87247. shaders: {
  87248. [key: string]: IGLTFShader;
  87249. };
  87250. programs: {
  87251. [key: string]: IGLTFProgram;
  87252. };
  87253. samplers: {
  87254. [key: string]: IGLTFSampler;
  87255. };
  87256. techniques: {
  87257. [key: string]: IGLTFTechnique;
  87258. };
  87259. materials: {
  87260. [key: string]: IGLTFMaterial;
  87261. };
  87262. animations: {
  87263. [key: string]: IGLTFAnimation;
  87264. };
  87265. skins: {
  87266. [key: string]: IGLTFSkins;
  87267. };
  87268. currentScene?: Object;
  87269. scenes: {
  87270. [key: string]: IGLTFScene;
  87271. };
  87272. extensionsUsed: string[];
  87273. extensionsRequired?: string[];
  87274. buffersCount: number;
  87275. shaderscount: number;
  87276. scene: Scene;
  87277. rootUrl: string;
  87278. loadedBufferCount: number;
  87279. loadedBufferViews: {
  87280. [name: string]: ArrayBufferView;
  87281. };
  87282. loadedShaderCount: number;
  87283. importOnlyMeshes: boolean;
  87284. importMeshesNames?: string[];
  87285. dummyNodes: Node[];
  87286. forAssetContainer: boolean;
  87287. }
  87288. /** @hidden */
  87289. export interface INodeToRoot {
  87290. bone: Bone;
  87291. node: IGLTFNode;
  87292. id: string;
  87293. }
  87294. /** @hidden */
  87295. export interface IJointNode {
  87296. node: IGLTFNode;
  87297. id: string;
  87298. }
  87299. }
  87300. declare module BABYLON.GLTF1 {
  87301. /**
  87302. * Utils functions for GLTF
  87303. * @hidden
  87304. */
  87305. export class GLTFUtils {
  87306. /**
  87307. * Sets the given "parameter" matrix
  87308. * @param scene: the Scene object
  87309. * @param source: the source node where to pick the matrix
  87310. * @param parameter: the GLTF technique parameter
  87311. * @param uniformName: the name of the shader's uniform
  87312. * @param shaderMaterial: the shader material
  87313. */
  87314. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  87315. /**
  87316. * Sets the given "parameter" matrix
  87317. * @param shaderMaterial: the shader material
  87318. * @param uniform: the name of the shader's uniform
  87319. * @param value: the value of the uniform
  87320. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  87321. */
  87322. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  87323. /**
  87324. * Returns the wrap mode of the texture
  87325. * @param mode: the mode value
  87326. */
  87327. static GetWrapMode(mode: number): number;
  87328. /**
  87329. * Returns the byte stride giving an accessor
  87330. * @param accessor: the GLTF accessor objet
  87331. */
  87332. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  87333. /**
  87334. * Returns the texture filter mode giving a mode value
  87335. * @param mode: the filter mode value
  87336. */
  87337. static GetTextureFilterMode(mode: number): ETextureFilterType;
  87338. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  87339. /**
  87340. * Returns a buffer from its accessor
  87341. * @param gltfRuntime: the GLTF runtime
  87342. * @param accessor: the GLTF accessor
  87343. */
  87344. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  87345. /**
  87346. * Decodes a buffer view into a string
  87347. * @param view: the buffer view
  87348. */
  87349. static DecodeBufferToText(view: ArrayBufferView): string;
  87350. /**
  87351. * Returns the default material of gltf. Related to
  87352. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  87353. * @param scene: the Babylon.js scene
  87354. */
  87355. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  87356. private static _DefaultMaterial;
  87357. }
  87358. }
  87359. declare module BABYLON.GLTF1 {
  87360. /**
  87361. * Implementation of the base glTF spec
  87362. * @hidden
  87363. */
  87364. export class GLTFLoaderBase {
  87365. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  87366. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  87367. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  87368. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  87369. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  87370. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  87371. }
  87372. /**
  87373. * glTF V1 Loader
  87374. * @hidden
  87375. */
  87376. export class GLTFLoader implements IGLTFLoader {
  87377. static Extensions: {
  87378. [name: string]: GLTFLoaderExtension;
  87379. };
  87380. static RegisterExtension(extension: GLTFLoaderExtension): void;
  87381. state: Nullable<GLTFLoaderState>;
  87382. dispose(): void;
  87383. private _importMeshAsync;
  87384. /**
  87385. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  87386. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  87387. * @param scene the scene the meshes should be added to
  87388. * @param forAssetContainer defines if the entities must be stored in the scene
  87389. * @param data gltf data containing information of the meshes in a loaded file
  87390. * @param rootUrl root url to load from
  87391. * @param onProgress event that fires when loading progress has occured
  87392. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  87393. */
  87394. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void): Promise<ISceneLoaderAsyncResult>;
  87395. private _loadAsync;
  87396. /**
  87397. * Imports all objects from a loaded gltf file and adds them to the scene
  87398. * @param scene the scene the objects should be added to
  87399. * @param data gltf data containing information of the meshes in a loaded file
  87400. * @param rootUrl root url to load from
  87401. * @param onProgress event that fires when loading progress has occured
  87402. * @returns a promise which completes when objects have been loaded to the scene
  87403. */
  87404. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void): Promise<void>;
  87405. private _loadShadersAsync;
  87406. private _loadBuffersAsync;
  87407. private _createNodes;
  87408. }
  87409. /** @hidden */
  87410. export abstract class GLTFLoaderExtension {
  87411. private _name;
  87412. constructor(name: string);
  87413. get name(): string;
  87414. /**
  87415. * Defines an override for loading the runtime
  87416. * Return true to stop further extensions from loading the runtime
  87417. */
  87418. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  87419. /**
  87420. * Defines an onverride for creating gltf runtime
  87421. * Return true to stop further extensions from creating the runtime
  87422. */
  87423. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  87424. /**
  87425. * Defines an override for loading buffers
  87426. * Return true to stop further extensions from loading this buffer
  87427. */
  87428. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  87429. /**
  87430. * Defines an override for loading texture buffers
  87431. * Return true to stop further extensions from loading this texture data
  87432. */
  87433. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  87434. /**
  87435. * Defines an override for creating textures
  87436. * Return true to stop further extensions from loading this texture
  87437. */
  87438. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  87439. /**
  87440. * Defines an override for loading shader strings
  87441. * Return true to stop further extensions from loading this shader data
  87442. */
  87443. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  87444. /**
  87445. * Defines an override for loading materials
  87446. * Return true to stop further extensions from loading this material
  87447. */
  87448. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  87449. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  87450. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  87451. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  87452. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  87453. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  87454. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  87455. private static LoadTextureBufferAsync;
  87456. private static CreateTextureAsync;
  87457. private static ApplyExtensions;
  87458. }
  87459. }
  87460. declare module BABYLON.GLTF1 {
  87461. /** @hidden */
  87462. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  87463. private _bin;
  87464. constructor();
  87465. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  87466. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  87467. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  87468. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  87469. }
  87470. }
  87471. declare module BABYLON.GLTF1 {
  87472. /** @hidden */
  87473. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  87474. constructor();
  87475. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  87476. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  87477. private _loadTexture;
  87478. }
  87479. }
  87480. declare module BABYLON.GLTF2.Loader {
  87481. /**
  87482. * Loader interface with an index field.
  87483. */
  87484. export interface IArrayItem {
  87485. /**
  87486. * The index of this item in the array.
  87487. */
  87488. index: number;
  87489. }
  87490. /**
  87491. * Loader interface with additional members.
  87492. */
  87493. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  87494. /** @hidden */
  87495. _data?: Promise<ArrayBufferView>;
  87496. /** @hidden */
  87497. _babylonVertexBuffer?: Promise<VertexBuffer>;
  87498. }
  87499. /**
  87500. * Loader interface with additional members.
  87501. */
  87502. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  87503. }
  87504. /** @hidden */
  87505. export interface _IAnimationSamplerData {
  87506. input: Float32Array;
  87507. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  87508. output: Float32Array;
  87509. }
  87510. /**
  87511. * Loader interface with additional members.
  87512. */
  87513. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  87514. /** @hidden */
  87515. _data?: Promise<_IAnimationSamplerData>;
  87516. }
  87517. /**
  87518. * Loader interface with additional members.
  87519. */
  87520. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  87521. channels: IAnimationChannel[];
  87522. samplers: IAnimationSampler[];
  87523. /** @hidden */
  87524. _babylonAnimationGroup?: AnimationGroup;
  87525. }
  87526. /**
  87527. * Loader interface with additional members.
  87528. */
  87529. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  87530. /** @hidden */
  87531. _data?: Promise<ArrayBufferView>;
  87532. }
  87533. /**
  87534. * Loader interface with additional members.
  87535. */
  87536. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  87537. /** @hidden */
  87538. _data?: Promise<ArrayBufferView>;
  87539. /** @hidden */
  87540. _babylonBuffer?: Promise<Buffer>;
  87541. }
  87542. /**
  87543. * Loader interface with additional members.
  87544. */
  87545. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  87546. }
  87547. /**
  87548. * Loader interface with additional members.
  87549. */
  87550. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  87551. /** @hidden */
  87552. _data?: Promise<ArrayBufferView>;
  87553. }
  87554. /**
  87555. * Loader interface with additional members.
  87556. */
  87557. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  87558. }
  87559. /**
  87560. * Loader interface with additional members.
  87561. */
  87562. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  87563. }
  87564. /**
  87565. * Loader interface with additional members.
  87566. */
  87567. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  87568. baseColorTexture?: ITextureInfo;
  87569. metallicRoughnessTexture?: ITextureInfo;
  87570. }
  87571. /**
  87572. * Loader interface with additional members.
  87573. */
  87574. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  87575. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  87576. normalTexture?: IMaterialNormalTextureInfo;
  87577. occlusionTexture?: IMaterialOcclusionTextureInfo;
  87578. emissiveTexture?: ITextureInfo;
  87579. /** @hidden */
  87580. _data?: {
  87581. [babylonDrawMode: number]: {
  87582. babylonMaterial: Material;
  87583. babylonMeshes: AbstractMesh[];
  87584. promise: Promise<void>;
  87585. };
  87586. };
  87587. }
  87588. /**
  87589. * Loader interface with additional members.
  87590. */
  87591. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  87592. primitives: IMeshPrimitive[];
  87593. }
  87594. /**
  87595. * Loader interface with additional members.
  87596. */
  87597. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  87598. /** @hidden */
  87599. _instanceData?: {
  87600. babylonSourceMesh: Mesh;
  87601. promise: Promise<any>;
  87602. };
  87603. }
  87604. /**
  87605. * Loader interface with additional members.
  87606. */
  87607. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  87608. /**
  87609. * The parent glTF node.
  87610. */
  87611. parent?: INode;
  87612. /** @hidden */
  87613. _babylonTransformNode?: TransformNode;
  87614. /** @hidden */
  87615. _primitiveBabylonMeshes?: AbstractMesh[];
  87616. /** @hidden */
  87617. _babylonBones?: Bone[];
  87618. /** @hidden */
  87619. _numMorphTargets?: number;
  87620. }
  87621. /** @hidden */
  87622. export interface _ISamplerData {
  87623. noMipMaps: boolean;
  87624. samplingMode: number;
  87625. wrapU: number;
  87626. wrapV: number;
  87627. }
  87628. /**
  87629. * Loader interface with additional members.
  87630. */
  87631. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  87632. /** @hidden */
  87633. _data?: _ISamplerData;
  87634. }
  87635. /**
  87636. * Loader interface with additional members.
  87637. */
  87638. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  87639. }
  87640. /**
  87641. * Loader interface with additional members.
  87642. */
  87643. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  87644. /** @hidden */
  87645. _data?: {
  87646. babylonSkeleton: Skeleton;
  87647. promise: Promise<void>;
  87648. };
  87649. }
  87650. /**
  87651. * Loader interface with additional members.
  87652. */
  87653. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  87654. /** @hidden */
  87655. _textureInfo: ITextureInfo;
  87656. }
  87657. /**
  87658. * Loader interface with additional members.
  87659. */
  87660. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  87661. /** false or undefined if the texture holds color data (true if data are roughness, normal, ...) */
  87662. nonColorData?: boolean;
  87663. }
  87664. /**
  87665. * Loader interface with additional members.
  87666. */
  87667. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  87668. accessors?: IAccessor[];
  87669. animations?: IAnimation[];
  87670. buffers?: IBuffer[];
  87671. bufferViews?: IBufferView[];
  87672. cameras?: ICamera[];
  87673. images?: IImage[];
  87674. materials?: IMaterial[];
  87675. meshes?: IMesh[];
  87676. nodes?: INode[];
  87677. samplers?: ISampler[];
  87678. scenes?: IScene[];
  87679. skins?: ISkin[];
  87680. textures?: ITexture[];
  87681. }
  87682. }
  87683. declare module BABYLON.GLTF2 {
  87684. /**
  87685. * Interface for a glTF loader extension.
  87686. */
  87687. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  87688. /**
  87689. * Called after the loader state changes to LOADING.
  87690. */
  87691. onLoading?(): void;
  87692. /**
  87693. * Called after the loader state changes to READY.
  87694. */
  87695. onReady?(): void;
  87696. /**
  87697. * Define this method to modify the default behavior when loading scenes.
  87698. * @param context The context when loading the asset
  87699. * @param scene The glTF scene property
  87700. * @returns A promise that resolves when the load is complete or null if not handled
  87701. */
  87702. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  87703. /**
  87704. * Define this method to modify the default behavior when loading nodes.
  87705. * @param context The context when loading the asset
  87706. * @param node The glTF node property
  87707. * @param assign A function called synchronously after parsing the glTF properties
  87708. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  87709. */
  87710. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  87711. /**
  87712. * Define this method to modify the default behavior when loading cameras.
  87713. * @param context The context when loading the asset
  87714. * @param camera The glTF camera property
  87715. * @param assign A function called synchronously after parsing the glTF properties
  87716. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  87717. */
  87718. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  87719. /**
  87720. * @hidden
  87721. * Define this method to modify the default behavior when loading vertex data for mesh primitives.
  87722. * @param context The context when loading the asset
  87723. * @param primitive The glTF mesh primitive property
  87724. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  87725. */
  87726. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  87727. /**
  87728. * @hidden
  87729. * Define this method to modify the default behavior when loading data for mesh primitives.
  87730. * @param context The context when loading the asset
  87731. * @param name The mesh name when loading the asset
  87732. * @param node The glTF node when loading the asset
  87733. * @param mesh The glTF mesh when loading the asset
  87734. * @param primitive The glTF mesh primitive property
  87735. * @param assign A function called synchronously after parsing the glTF properties
  87736. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  87737. */
  87738. _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Nullable<Promise<AbstractMesh>>;
  87739. /**
  87740. * @hidden
  87741. * Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  87742. * @param context The context when loading the asset
  87743. * @param material The glTF material property
  87744. * @param assign A function called synchronously after parsing the glTF properties
  87745. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  87746. */
  87747. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Nullable<Mesh>, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  87748. /**
  87749. * Define this method to modify the default behavior when creating materials.
  87750. * @param context The context when loading the asset
  87751. * @param material The glTF material property
  87752. * @param babylonDrawMode The draw mode for the Babylon material
  87753. * @returns The Babylon material or null if not handled
  87754. */
  87755. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  87756. /**
  87757. * Define this method to modify the default behavior when loading material properties.
  87758. * @param context The context when loading the asset
  87759. * @param material The glTF material property
  87760. * @param babylonMaterial The Babylon material
  87761. * @returns A promise that resolves when the load is complete or null if not handled
  87762. */
  87763. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  87764. /**
  87765. * Define this method to modify the default behavior when loading texture infos.
  87766. * @param context The context when loading the asset
  87767. * @param textureInfo The glTF texture info property
  87768. * @param assign A function called synchronously after parsing the glTF properties
  87769. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  87770. */
  87771. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  87772. /**
  87773. * @hidden
  87774. * Define this method to modify the default behavior when loading textures.
  87775. * @param context The context when loading the asset
  87776. * @param texture The glTF texture property
  87777. * @param assign A function called synchronously after parsing the glTF properties
  87778. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  87779. */
  87780. _loadTextureAsync?(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  87781. /**
  87782. * Define this method to modify the default behavior when loading animations.
  87783. * @param context The context when loading the asset
  87784. * @param animation The glTF animation property
  87785. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  87786. */
  87787. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  87788. /**
  87789. * @hidden
  87790. * Define this method to modify the default behavior when loading skins.
  87791. * @param context The context when loading the asset
  87792. * @param node The glTF node property
  87793. * @param skin The glTF skin property
  87794. * @returns A promise that resolves when the load is complete or null if not handled
  87795. */
  87796. _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  87797. /**
  87798. * @hidden
  87799. * Define this method to modify the default behavior when loading uris.
  87800. * @param context The context when loading the asset
  87801. * @param property The glTF property associated with the uri
  87802. * @param uri The uri to load
  87803. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  87804. */
  87805. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  87806. /**
  87807. * Define this method to modify the default behavior when loading buffer views.
  87808. * @param context The context when loading the asset
  87809. * @param bufferView The glTF buffer view property
  87810. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  87811. */
  87812. loadBufferViewAsync?(context: string, bufferView: IBufferView): Nullable<Promise<ArrayBufferView>>;
  87813. /**
  87814. * Define this method to modify the default behavior when loading buffers.
  87815. * @param context The context when loading the asset
  87816. * @param buffer The glTF buffer property
  87817. * @param byteOffset The byte offset to load
  87818. * @param byteLength The byte length to load
  87819. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  87820. */
  87821. loadBufferAsync?(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  87822. }
  87823. }
  87824. declare module BABYLON.GLTF2 {
  87825. /**
  87826. * Helper class for working with arrays when loading the glTF asset
  87827. */
  87828. export class ArrayItem {
  87829. /**
  87830. * Gets an item from the given array.
  87831. * @param context The context when loading the asset
  87832. * @param array The array to get the item from
  87833. * @param index The index to the array
  87834. * @returns The array item
  87835. */
  87836. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  87837. /**
  87838. * Assign an `index` field to each item of the given array.
  87839. * @param array The array of items
  87840. */
  87841. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  87842. }
  87843. /**
  87844. * The glTF 2.0 loader
  87845. */
  87846. export class GLTFLoader implements IGLTFLoader {
  87847. /** @hidden */
  87848. _completePromises: Promise<any>[];
  87849. /** @hidden */
  87850. _forAssetContainer: boolean;
  87851. /** Storage */
  87852. _babylonLights: Light[];
  87853. /** @hidden */
  87854. _disableInstancedMesh: number;
  87855. private _disposed;
  87856. private _parent;
  87857. private _state;
  87858. private _extensions;
  87859. private _rootUrl;
  87860. private _fileName;
  87861. private _uniqueRootUrl;
  87862. private _gltf;
  87863. private _bin;
  87864. private _babylonScene;
  87865. private _rootBabylonMesh;
  87866. private _defaultBabylonMaterialData;
  87867. private static _RegisteredExtensions;
  87868. /**
  87869. * The default glTF sampler.
  87870. */
  87871. static readonly DefaultSampler: ISampler;
  87872. /**
  87873. * Registers a loader extension.
  87874. * @param name The name of the loader extension.
  87875. * @param factory The factory function that creates the loader extension.
  87876. */
  87877. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  87878. /**
  87879. * Unregisters a loader extension.
  87880. * @param name The name of the loader extension.
  87881. * @returns A boolean indicating whether the extension has been unregistered
  87882. */
  87883. static UnregisterExtension(name: string): boolean;
  87884. /**
  87885. * The loader state.
  87886. */
  87887. get state(): Nullable<GLTFLoaderState>;
  87888. /**
  87889. * The object that represents the glTF JSON.
  87890. */
  87891. get gltf(): IGLTF;
  87892. /**
  87893. * The BIN chunk of a binary glTF.
  87894. */
  87895. get bin(): Nullable<IDataBuffer>;
  87896. /**
  87897. * The parent file loader.
  87898. */
  87899. get parent(): GLTFFileLoader;
  87900. /**
  87901. * The Babylon scene when loading the asset.
  87902. */
  87903. get babylonScene(): Scene;
  87904. /**
  87905. * The root Babylon mesh when loading the asset.
  87906. */
  87907. get rootBabylonMesh(): Mesh;
  87908. /** @hidden */
  87909. constructor(parent: GLTFFileLoader);
  87910. /** @hidden */
  87911. dispose(): void;
  87912. /** @hidden */
  87913. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<ISceneLoaderAsyncResult>;
  87914. /** @hidden */
  87915. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  87916. private _loadAsync;
  87917. private _loadData;
  87918. private _setupData;
  87919. private _loadExtensions;
  87920. private _checkExtensions;
  87921. private _setState;
  87922. private _createRootNode;
  87923. /**
  87924. * Loads a glTF scene.
  87925. * @param context The context when loading the asset
  87926. * @param scene The glTF scene property
  87927. * @returns A promise that resolves when the load is complete
  87928. */
  87929. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  87930. private _forEachPrimitive;
  87931. private _getGeometries;
  87932. private _getMeshes;
  87933. private _getTransformNodes;
  87934. private _getSkeletons;
  87935. private _getAnimationGroups;
  87936. private _startAnimations;
  87937. /**
  87938. * Loads a glTF node.
  87939. * @param context The context when loading the asset
  87940. * @param node The glTF node property
  87941. * @param assign A function called synchronously after parsing the glTF properties
  87942. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  87943. */
  87944. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  87945. private _loadMeshAsync;
  87946. /**
  87947. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  87948. * @param context The context when loading the asset
  87949. * @param name The mesh name when loading the asset
  87950. * @param node The glTF node when loading the asset
  87951. * @param mesh The glTF mesh when loading the asset
  87952. * @param primitive The glTF mesh primitive property
  87953. * @param assign A function called synchronously after parsing the glTF properties
  87954. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  87955. */
  87956. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  87957. private _loadVertexDataAsync;
  87958. private _createMorphTargets;
  87959. private _loadMorphTargetsAsync;
  87960. private _loadMorphTargetVertexDataAsync;
  87961. private static _LoadTransform;
  87962. private _loadSkinAsync;
  87963. private _loadBones;
  87964. private _loadBone;
  87965. private _loadSkinInverseBindMatricesDataAsync;
  87966. private _updateBoneMatrices;
  87967. private _getNodeMatrix;
  87968. /**
  87969. * Loads a glTF camera.
  87970. * @param context The context when loading the asset
  87971. * @param camera The glTF camera property
  87972. * @param assign A function called synchronously after parsing the glTF properties
  87973. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  87974. */
  87975. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  87976. private _loadAnimationsAsync;
  87977. /**
  87978. * Loads a glTF animation.
  87979. * @param context The context when loading the asset
  87980. * @param animation The glTF animation property
  87981. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  87982. */
  87983. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  87984. /**
  87985. * @hidden Loads a glTF animation channel.
  87986. * @param context The context when loading the asset
  87987. * @param animationContext The context of the animation when loading the asset
  87988. * @param animation The glTF animation property
  87989. * @param channel The glTF animation channel property
  87990. * @param babylonAnimationGroup The babylon animation group property
  87991. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  87992. * @returns A void promise when the channel load is complete
  87993. */
  87994. _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  87995. private _loadAnimationSamplerAsync;
  87996. /**
  87997. * Loads a glTF buffer.
  87998. * @param context The context when loading the asset
  87999. * @param buffer The glTF buffer property
  88000. * @param byteOffset The byte offset to use
  88001. * @param byteLength The byte length to use
  88002. * @returns A promise that resolves with the loaded data when the load is complete
  88003. */
  88004. loadBufferAsync(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  88005. /**
  88006. * Loads a glTF buffer view.
  88007. * @param context The context when loading the asset
  88008. * @param bufferView The glTF buffer view property
  88009. * @returns A promise that resolves with the loaded data when the load is complete
  88010. */
  88011. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  88012. private _loadAccessorAsync;
  88013. /** @hidden */
  88014. _loadFloatAccessorAsync(context: string, accessor: IAccessor): Promise<Float32Array>;
  88015. private _loadIndicesAccessorAsync;
  88016. private _loadVertexBufferViewAsync;
  88017. private _loadVertexAccessorAsync;
  88018. private _loadMaterialMetallicRoughnessPropertiesAsync;
  88019. /** @hidden */
  88020. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Nullable<Mesh>, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  88021. private _createDefaultMaterial;
  88022. /**
  88023. * Creates a Babylon material from a glTF material.
  88024. * @param context The context when loading the asset
  88025. * @param material The glTF material property
  88026. * @param babylonDrawMode The draw mode for the Babylon material
  88027. * @returns The Babylon material
  88028. */
  88029. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  88030. /**
  88031. * Loads properties from a glTF material into a Babylon material.
  88032. * @param context The context when loading the asset
  88033. * @param material The glTF material property
  88034. * @param babylonMaterial The Babylon material
  88035. * @returns A promise that resolves when the load is complete
  88036. */
  88037. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  88038. /**
  88039. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  88040. * @param context The context when loading the asset
  88041. * @param material The glTF material property
  88042. * @param babylonMaterial The Babylon material
  88043. * @returns A promise that resolves when the load is complete
  88044. */
  88045. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  88046. /**
  88047. * Loads the alpha properties from a glTF material into a Babylon material.
  88048. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  88049. * @param context The context when loading the asset
  88050. * @param material The glTF material property
  88051. * @param babylonMaterial The Babylon material
  88052. */
  88053. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  88054. /**
  88055. * Loads a glTF texture info.
  88056. * @param context The context when loading the asset
  88057. * @param textureInfo The glTF texture info property
  88058. * @param assign A function called synchronously after parsing the glTF properties
  88059. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  88060. */
  88061. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  88062. /** @hidden */
  88063. _loadTextureAsync(context: string, texture: ITexture, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  88064. /** @hidden */
  88065. _createTextureAsync(context: string, sampler: ISampler, image: IImage, assign?: (babylonTexture: BaseTexture) => void, textureLoaderOptions?: any): Promise<BaseTexture>;
  88066. private _loadSampler;
  88067. /**
  88068. * Loads a glTF image.
  88069. * @param context The context when loading the asset
  88070. * @param image The glTF image property
  88071. * @returns A promise that resolves with the loaded data when the load is complete
  88072. */
  88073. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  88074. /**
  88075. * Loads a glTF uri.
  88076. * @param context The context when loading the asset
  88077. * @param property The glTF property associated with the uri
  88078. * @param uri The base64 or relative uri
  88079. * @returns A promise that resolves with the loaded data when the load is complete
  88080. */
  88081. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  88082. /**
  88083. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  88084. * @param babylonObject the Babylon object with metadata
  88085. * @param pointer the JSON pointer
  88086. */
  88087. static AddPointerMetadata(babylonObject: {
  88088. metadata: any;
  88089. }, pointer: string): void;
  88090. private static _GetTextureWrapMode;
  88091. private static _GetTextureSamplingMode;
  88092. private static _GetTypedArrayConstructor;
  88093. private static _GetTypedArray;
  88094. private static _GetNumComponents;
  88095. private static _ValidateUri;
  88096. /** @hidden */
  88097. static _GetDrawMode(context: string, mode: number | undefined): number;
  88098. private _compileMaterialsAsync;
  88099. private _compileShadowGeneratorsAsync;
  88100. private _forEachExtensions;
  88101. private _applyExtensions;
  88102. private _extensionsOnLoading;
  88103. private _extensionsOnReady;
  88104. private _extensionsLoadSceneAsync;
  88105. private _extensionsLoadNodeAsync;
  88106. private _extensionsLoadCameraAsync;
  88107. private _extensionsLoadVertexDataAsync;
  88108. private _extensionsLoadMeshPrimitiveAsync;
  88109. private _extensionsLoadMaterialAsync;
  88110. private _extensionsCreateMaterial;
  88111. private _extensionsLoadMaterialPropertiesAsync;
  88112. private _extensionsLoadTextureInfoAsync;
  88113. private _extensionsLoadTextureAsync;
  88114. private _extensionsLoadAnimationAsync;
  88115. private _extensionsLoadSkinAsync;
  88116. private _extensionsLoadUriAsync;
  88117. private _extensionsLoadBufferViewAsync;
  88118. private _extensionsLoadBufferAsync;
  88119. /**
  88120. * Helper method called by a loader extension to load an glTF extension.
  88121. * @param context The context when loading the asset
  88122. * @param property The glTF property to load the extension from
  88123. * @param extensionName The name of the extension to load
  88124. * @param actionAsync The action to run
  88125. * @returns The promise returned by actionAsync or null if the extension does not exist
  88126. */
  88127. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  88128. /**
  88129. * Helper method called by a loader extension to load a glTF extra.
  88130. * @param context The context when loading the asset
  88131. * @param property The glTF property to load the extra from
  88132. * @param extensionName The name of the extension to load
  88133. * @param actionAsync The action to run
  88134. * @returns The promise returned by actionAsync or null if the extra does not exist
  88135. */
  88136. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  88137. /**
  88138. * Checks for presence of an extension.
  88139. * @param name The name of the extension to check
  88140. * @returns A boolean indicating the presence of the given extension name in `extensionsUsed`
  88141. */
  88142. isExtensionUsed(name: string): boolean;
  88143. /**
  88144. * Increments the indentation level and logs a message.
  88145. * @param message The message to log
  88146. */
  88147. logOpen(message: string): void;
  88148. /**
  88149. * Decrements the indentation level.
  88150. */
  88151. logClose(): void;
  88152. /**
  88153. * Logs a message
  88154. * @param message The message to log
  88155. */
  88156. log(message: string): void;
  88157. /**
  88158. * Starts a performance counter.
  88159. * @param counterName The name of the performance counter
  88160. */
  88161. startPerformanceCounter(counterName: string): void;
  88162. /**
  88163. * Ends a performance counter.
  88164. * @param counterName The name of the performance counter
  88165. */
  88166. endPerformanceCounter(counterName: string): void;
  88167. }
  88168. }
  88169. declare module BABYLON.GLTF2.Loader.Extensions {
  88170. /** @hidden */
  88171. interface IEXTLightsImageBased_LightImageBased {
  88172. _babylonTexture?: BaseTexture;
  88173. _loaded?: Promise<void>;
  88174. }
  88175. /**
  88176. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_lights_image_based/README.md)
  88177. */
  88178. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  88179. /**
  88180. * The name of this extension.
  88181. */
  88182. readonly name: string;
  88183. /**
  88184. * Defines whether this extension is enabled.
  88185. */
  88186. enabled: boolean;
  88187. private _loader;
  88188. private _lights?;
  88189. /** @hidden */
  88190. constructor(loader: GLTFLoader);
  88191. /** @hidden */
  88192. dispose(): void;
  88193. /** @hidden */
  88194. onLoading(): void;
  88195. /** @hidden */
  88196. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  88197. private _loadLightAsync;
  88198. }
  88199. }
  88200. declare module BABYLON.GLTF2.Loader.Extensions {
  88201. /**
  88202. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1691)
  88203. * [Playground Sample](https://playground.babylonjs.com/#QFIGLW#9)
  88204. * !!! Experimental Extension Subject to Changes !!!
  88205. */
  88206. export class EXT_mesh_gpu_instancing implements IGLTFLoaderExtension {
  88207. /**
  88208. * The name of this extension.
  88209. */
  88210. readonly name: string;
  88211. /**
  88212. * Defines whether this extension is enabled.
  88213. */
  88214. enabled: boolean;
  88215. private _loader;
  88216. /** @hidden */
  88217. constructor(loader: GLTFLoader);
  88218. /** @hidden */
  88219. dispose(): void;
  88220. /** @hidden */
  88221. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  88222. }
  88223. }
  88224. declare module BABYLON.GLTF2.Loader.Extensions {
  88225. /**
  88226. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/EXT_meshopt_compression)
  88227. *
  88228. * This extension uses a WebAssembly decoder module from https://github.com/zeux/meshoptimizer/tree/master/js
  88229. */
  88230. export class EXT_meshopt_compression implements IGLTFLoaderExtension {
  88231. /**
  88232. * The name of this extension.
  88233. */
  88234. readonly name: string;
  88235. /**
  88236. * Defines whether this extension is enabled.
  88237. */
  88238. enabled: boolean;
  88239. /**
  88240. * Path to decoder module; defaults to https://preview.babylonjs.com/meshopt_decoder.js
  88241. */
  88242. static DecoderPath: string;
  88243. private _loader;
  88244. private _decoderPromise?;
  88245. /** @hidden */
  88246. constructor(loader: GLTFLoader);
  88247. /** @hidden */
  88248. dispose(): void;
  88249. /** @hidden */
  88250. loadBufferViewAsync(context: string, bufferView: IBufferView): Nullable<Promise<ArrayBufferView>>;
  88251. }
  88252. }
  88253. declare module BABYLON.GLTF2.Loader.Extensions {
  88254. /**
  88255. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_texture_webp/)
  88256. */
  88257. export class EXT_texture_webp implements IGLTFLoaderExtension {
  88258. /** The name of this extension. */
  88259. readonly name: string;
  88260. /** Defines whether this extension is enabled. */
  88261. enabled: boolean;
  88262. private _loader;
  88263. /** @hidden */
  88264. constructor(loader: GLTFLoader);
  88265. /** @hidden */
  88266. dispose(): void;
  88267. /** @hidden */
  88268. _loadTextureAsync(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  88269. }
  88270. }
  88271. declare module BABYLON.GLTF2.Loader.Extensions {
  88272. /**
  88273. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  88274. */
  88275. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  88276. /**
  88277. * The name of this extension.
  88278. */
  88279. readonly name: string;
  88280. /**
  88281. * The draco compression used to decode vertex data or DracoCompression.Default if not defined
  88282. */
  88283. dracoCompression?: DracoCompression;
  88284. /**
  88285. * Defines whether this extension is enabled.
  88286. */
  88287. enabled: boolean;
  88288. private _loader;
  88289. /** @hidden */
  88290. constructor(loader: GLTFLoader);
  88291. /** @hidden */
  88292. dispose(): void;
  88293. /** @hidden */
  88294. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  88295. }
  88296. }
  88297. declare module BABYLON.GLTF2.Loader.Extensions {
  88298. /**
  88299. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual)
  88300. */
  88301. export class KHR_lights implements IGLTFLoaderExtension {
  88302. /**
  88303. * The name of this extension.
  88304. */
  88305. readonly name: string;
  88306. /**
  88307. * Defines whether this extension is enabled.
  88308. */
  88309. enabled: boolean;
  88310. private _loader;
  88311. private _lights?;
  88312. /** @hidden */
  88313. constructor(loader: GLTFLoader);
  88314. /** @hidden */
  88315. dispose(): void;
  88316. /** @hidden */
  88317. onLoading(): void;
  88318. /** @hidden */
  88319. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  88320. }
  88321. }
  88322. declare module BABYLON.GLTF2.Loader.Extensions {
  88323. /**
  88324. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  88325. */
  88326. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  88327. /**
  88328. * The name of this extension.
  88329. */
  88330. readonly name: string;
  88331. /**
  88332. * Defines whether this extension is enabled.
  88333. */
  88334. enabled: boolean;
  88335. /**
  88336. * Defines a number that determines the order the extensions are applied.
  88337. */
  88338. order: number;
  88339. private _loader;
  88340. /** @hidden */
  88341. constructor(loader: GLTFLoader);
  88342. /** @hidden */
  88343. dispose(): void;
  88344. /** @hidden */
  88345. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  88346. private _loadSpecularGlossinessPropertiesAsync;
  88347. }
  88348. }
  88349. declare module BABYLON.GLTF2.Loader.Extensions {
  88350. /**
  88351. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  88352. */
  88353. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  88354. /**
  88355. * The name of this extension.
  88356. */
  88357. readonly name: string;
  88358. /**
  88359. * Defines whether this extension is enabled.
  88360. */
  88361. enabled: boolean;
  88362. /**
  88363. * Defines a number that determines the order the extensions are applied.
  88364. */
  88365. order: number;
  88366. private _loader;
  88367. /** @hidden */
  88368. constructor(loader: GLTFLoader);
  88369. /** @hidden */
  88370. dispose(): void;
  88371. /** @hidden */
  88372. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  88373. private _loadUnlitPropertiesAsync;
  88374. }
  88375. }
  88376. declare module BABYLON.GLTF2.Loader.Extensions {
  88377. /**
  88378. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_clearcoat/README.md)
  88379. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#7F7PN6#8)
  88380. */
  88381. export class KHR_materials_clearcoat implements IGLTFLoaderExtension {
  88382. /**
  88383. * The name of this extension.
  88384. */
  88385. readonly name: string;
  88386. /**
  88387. * Defines whether this extension is enabled.
  88388. */
  88389. enabled: boolean;
  88390. /**
  88391. * Defines a number that determines the order the extensions are applied.
  88392. */
  88393. order: number;
  88394. private _loader;
  88395. /** @hidden */
  88396. constructor(loader: GLTFLoader);
  88397. /** @hidden */
  88398. dispose(): void;
  88399. /** @hidden */
  88400. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  88401. private _loadClearCoatPropertiesAsync;
  88402. }
  88403. }
  88404. declare module BABYLON.GLTF2.Loader.Extensions {
  88405. /**
  88406. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_sheen/README.md)
  88407. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  88408. * !!! Experimental Extension Subject to Changes !!!
  88409. */
  88410. export class KHR_materials_sheen implements IGLTFLoaderExtension {
  88411. /**
  88412. * The name of this extension.
  88413. */
  88414. readonly name: string;
  88415. /**
  88416. * Defines whether this extension is enabled.
  88417. */
  88418. enabled: boolean;
  88419. /**
  88420. * Defines a number that determines the order the extensions are applied.
  88421. */
  88422. order: number;
  88423. private _loader;
  88424. /** @hidden */
  88425. constructor(loader: GLTFLoader);
  88426. /** @hidden */
  88427. dispose(): void;
  88428. /** @hidden */
  88429. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  88430. private _loadSheenPropertiesAsync;
  88431. }
  88432. }
  88433. declare module BABYLON.GLTF2.Loader.Extensions {
  88434. /**
  88435. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1719)
  88436. * !!! Experimental Extension Subject to Changes !!!
  88437. */
  88438. export class KHR_materials_specular implements IGLTFLoaderExtension {
  88439. /**
  88440. * The name of this extension.
  88441. */
  88442. readonly name: string;
  88443. /**
  88444. * Defines whether this extension is enabled.
  88445. */
  88446. enabled: boolean;
  88447. /**
  88448. * Defines a number that determines the order the extensions are applied.
  88449. */
  88450. order: number;
  88451. private _loader;
  88452. /** @hidden */
  88453. constructor(loader: GLTFLoader);
  88454. /** @hidden */
  88455. dispose(): void;
  88456. /** @hidden */
  88457. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  88458. private _loadSpecularPropertiesAsync;
  88459. }
  88460. }
  88461. declare module BABYLON.GLTF2.Loader.Extensions {
  88462. /**
  88463. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1718)
  88464. * !!! Experimental Extension Subject to Changes !!!
  88465. */
  88466. export class KHR_materials_ior implements IGLTFLoaderExtension {
  88467. /**
  88468. * Default ior Value from the spec.
  88469. */
  88470. private static readonly _DEFAULT_IOR;
  88471. /**
  88472. * The name of this extension.
  88473. */
  88474. readonly name: string;
  88475. /**
  88476. * Defines whether this extension is enabled.
  88477. */
  88478. enabled: boolean;
  88479. /**
  88480. * Defines a number that determines the order the extensions are applied.
  88481. */
  88482. order: number;
  88483. private _loader;
  88484. /** @hidden */
  88485. constructor(loader: GLTFLoader);
  88486. /** @hidden */
  88487. dispose(): void;
  88488. /** @hidden */
  88489. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  88490. private _loadIorPropertiesAsync;
  88491. }
  88492. }
  88493. declare module BABYLON.GLTF2.Loader.Extensions {
  88494. /**
  88495. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_variants/README.md)
  88496. */
  88497. export class KHR_materials_variants implements IGLTFLoaderExtension {
  88498. /**
  88499. * The name of this extension.
  88500. */
  88501. readonly name: string;
  88502. /**
  88503. * Defines whether this extension is enabled.
  88504. */
  88505. enabled: boolean;
  88506. private _loader;
  88507. private _variants?;
  88508. /** @hidden */
  88509. constructor(loader: GLTFLoader);
  88510. /** @hidden */
  88511. dispose(): void;
  88512. /**
  88513. * Gets the list of available variant names for this asset.
  88514. * @param rootMesh The glTF root mesh
  88515. * @returns the list of all the variant names for this model
  88516. */
  88517. static GetAvailableVariants(rootMesh: Mesh): string[];
  88518. /**
  88519. * Gets the list of available variant names for this asset.
  88520. * @param rootMesh The glTF root mesh
  88521. * @returns the list of all the variant names for this model
  88522. */
  88523. getAvailableVariants(rootMesh: Mesh): string[];
  88524. /**
  88525. * Select a variant given a variant name or a list of variant names.
  88526. * @param rootMesh The glTF root mesh
  88527. * @param variantName The variant name(s) to select.
  88528. */
  88529. static SelectVariant(rootMesh: Mesh, variantName: string | string[]): void;
  88530. /**
  88531. * Select a variant given a variant name or a list of variant names.
  88532. * @param rootMesh The glTF root mesh
  88533. * @param variantName The variant name(s) to select.
  88534. */
  88535. selectVariant(rootMesh: Mesh, variantName: string | string[]): void;
  88536. /**
  88537. * Reset back to the original before selecting a variant.
  88538. * @param rootMesh The glTF root mesh
  88539. */
  88540. static Reset(rootMesh: Mesh): void;
  88541. /**
  88542. * Reset back to the original before selecting a variant.
  88543. * @param rootMesh The glTF root mesh
  88544. */
  88545. reset(rootMesh: Mesh): void;
  88546. /**
  88547. * Gets the last selected variant name(s) or null if original.
  88548. * @param rootMesh The glTF root mesh
  88549. * @returns The selected variant name(s).
  88550. */
  88551. static GetLastSelectedVariant(rootMesh: Mesh): Nullable<string | string[]>;
  88552. /**
  88553. * Gets the last selected variant name(s) or null if original.
  88554. * @param rootMesh The glTF root mesh
  88555. * @returns The selected variant name(s).
  88556. */
  88557. getLastSelectedVariant(rootMesh: Mesh): Nullable<string | string[]>;
  88558. private static _GetExtensionMetadata;
  88559. /** @hidden */
  88560. onLoading(): void;
  88561. /** @hidden */
  88562. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Nullable<Promise<AbstractMesh>>;
  88563. }
  88564. }
  88565. declare module BABYLON.GLTF2.Loader.Extensions {
  88566. /**
  88567. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_transmission/README.md)
  88568. */
  88569. export class KHR_materials_transmission implements IGLTFLoaderExtension {
  88570. /**
  88571. * The name of this extension.
  88572. */
  88573. readonly name: string;
  88574. /**
  88575. * Defines whether this extension is enabled.
  88576. */
  88577. enabled: boolean;
  88578. /**
  88579. * Defines a number that determines the order the extensions are applied.
  88580. */
  88581. order: number;
  88582. private _loader;
  88583. /** @hidden */
  88584. constructor(loader: GLTFLoader);
  88585. /** @hidden */
  88586. dispose(): void;
  88587. /** @hidden */
  88588. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  88589. private _loadTransparentPropertiesAsync;
  88590. }
  88591. }
  88592. declare module BABYLON.GLTF2.Loader.Extensions {
  88593. /**
  88594. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1825)
  88595. * !!! Experimental Extension Subject to Changes !!!
  88596. */
  88597. export class KHR_materials_translucency implements IGLTFLoaderExtension {
  88598. /**
  88599. * The name of this extension.
  88600. */
  88601. readonly name: string;
  88602. /**
  88603. * Defines whether this extension is enabled.
  88604. */
  88605. enabled: boolean;
  88606. /**
  88607. * Defines a number that determines the order the extensions are applied.
  88608. */
  88609. order: number;
  88610. private _loader;
  88611. /** @hidden */
  88612. constructor(loader: GLTFLoader);
  88613. /** @hidden */
  88614. dispose(): void;
  88615. /** @hidden */
  88616. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  88617. private _loadTranslucentPropertiesAsync;
  88618. }
  88619. }
  88620. declare module BABYLON.GLTF2.Loader.Extensions {
  88621. /**
  88622. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_mesh_quantization)
  88623. */
  88624. export class KHR_mesh_quantization implements IGLTFLoaderExtension {
  88625. /**
  88626. * The name of this extension.
  88627. */
  88628. readonly name: string;
  88629. /**
  88630. * Defines whether this extension is enabled.
  88631. */
  88632. enabled: boolean;
  88633. /** @hidden */
  88634. constructor(loader: GLTFLoader);
  88635. /** @hidden */
  88636. dispose(): void;
  88637. }
  88638. }
  88639. declare module BABYLON.GLTF2.Loader.Extensions {
  88640. /**
  88641. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1751)
  88642. * !!! Experimental Extension Subject to Changes !!!
  88643. */
  88644. export class KHR_texture_basisu implements IGLTFLoaderExtension {
  88645. /** The name of this extension. */
  88646. readonly name: string;
  88647. /** Defines whether this extension is enabled. */
  88648. enabled: boolean;
  88649. private _loader;
  88650. /** @hidden */
  88651. constructor(loader: GLTFLoader);
  88652. /** @hidden */
  88653. dispose(): void;
  88654. /** @hidden */
  88655. _loadTextureAsync(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  88656. }
  88657. }
  88658. declare module BABYLON.GLTF2.Loader.Extensions {
  88659. /**
  88660. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform)
  88661. */
  88662. export class KHR_texture_transform implements IGLTFLoaderExtension {
  88663. /**
  88664. * The name of this extension.
  88665. */
  88666. readonly name: string;
  88667. /**
  88668. * Defines whether this extension is enabled.
  88669. */
  88670. enabled: boolean;
  88671. private _loader;
  88672. /** @hidden */
  88673. constructor(loader: GLTFLoader);
  88674. /** @hidden */
  88675. dispose(): void;
  88676. /** @hidden */
  88677. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  88678. }
  88679. }
  88680. declare module BABYLON.GLTF2.Loader.Extensions {
  88681. /**
  88682. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1893)
  88683. * !!! Experimental Extension Subject to Changes !!!
  88684. */
  88685. export class KHR_xmp_json_ld implements IGLTFLoaderExtension {
  88686. /**
  88687. * The name of this extension.
  88688. */
  88689. readonly name: string;
  88690. /**
  88691. * Defines whether this extension is enabled.
  88692. */
  88693. enabled: boolean;
  88694. /**
  88695. * Defines a number that determines the order the extensions are applied.
  88696. */
  88697. order: number;
  88698. private _loader;
  88699. /** @hidden */
  88700. constructor(loader: GLTFLoader);
  88701. /** @hidden */
  88702. dispose(): void;
  88703. /**
  88704. * Called after the loader state changes to LOADING.
  88705. */
  88706. onLoading(): void;
  88707. }
  88708. }
  88709. declare module BABYLON.GLTF2.Loader.Extensions {
  88710. /**
  88711. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  88712. */
  88713. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  88714. /**
  88715. * The name of this extension.
  88716. */
  88717. readonly name: string;
  88718. /**
  88719. * Defines whether this extension is enabled.
  88720. */
  88721. enabled: boolean;
  88722. private _loader;
  88723. private _clips;
  88724. private _emitters;
  88725. /** @hidden */
  88726. constructor(loader: GLTFLoader);
  88727. /** @hidden */
  88728. dispose(): void;
  88729. /** @hidden */
  88730. onLoading(): void;
  88731. /** @hidden */
  88732. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  88733. /** @hidden */
  88734. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  88735. /** @hidden */
  88736. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  88737. private _loadClipAsync;
  88738. private _loadEmitterAsync;
  88739. private _getEventAction;
  88740. private _loadAnimationEventAsync;
  88741. }
  88742. }
  88743. declare module BABYLON.GLTF2.Loader.Extensions {
  88744. /**
  88745. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  88746. */
  88747. export class MSFT_lod implements IGLTFLoaderExtension {
  88748. /**
  88749. * The name of this extension.
  88750. */
  88751. readonly name: string;
  88752. /**
  88753. * Defines whether this extension is enabled.
  88754. */
  88755. enabled: boolean;
  88756. /**
  88757. * Defines a number that determines the order the extensions are applied.
  88758. */
  88759. order: number;
  88760. /**
  88761. * Maximum number of LODs to load, starting from the lowest LOD.
  88762. */
  88763. maxLODsToLoad: number;
  88764. /**
  88765. * Observable raised when all node LODs of one level are loaded.
  88766. * The event data is the index of the loaded LOD starting from zero.
  88767. * Dispose the loader to cancel the loading of the next level of LODs.
  88768. */
  88769. onNodeLODsLoadedObservable: Observable<number>;
  88770. /**
  88771. * Observable raised when all material LODs of one level are loaded.
  88772. * The event data is the index of the loaded LOD starting from zero.
  88773. * Dispose the loader to cancel the loading of the next level of LODs.
  88774. */
  88775. onMaterialLODsLoadedObservable: Observable<number>;
  88776. private _loader;
  88777. private _bufferLODs;
  88778. private _nodeIndexLOD;
  88779. private _nodeSignalLODs;
  88780. private _nodePromiseLODs;
  88781. private _nodeBufferLODs;
  88782. private _materialIndexLOD;
  88783. private _materialSignalLODs;
  88784. private _materialPromiseLODs;
  88785. private _materialBufferLODs;
  88786. /** @hidden */
  88787. constructor(loader: GLTFLoader);
  88788. /** @hidden */
  88789. dispose(): void;
  88790. /** @hidden */
  88791. onReady(): void;
  88792. /** @hidden */
  88793. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  88794. /** @hidden */
  88795. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  88796. /** @hidden */
  88797. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Nullable<Mesh>, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  88798. /** @hidden */
  88799. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  88800. /** @hidden */
  88801. loadBufferAsync(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  88802. private _loadBufferLOD;
  88803. /**
  88804. * Gets an array of LOD properties from lowest to highest.
  88805. */
  88806. private _getLODs;
  88807. private _disposeTransformNode;
  88808. private _disposeMaterials;
  88809. }
  88810. }
  88811. declare module BABYLON.GLTF2.Loader.Extensions {
  88812. /** @hidden */
  88813. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  88814. readonly name: string;
  88815. enabled: boolean;
  88816. private _loader;
  88817. constructor(loader: GLTFLoader);
  88818. dispose(): void;
  88819. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  88820. }
  88821. }
  88822. declare module BABYLON.GLTF2.Loader.Extensions {
  88823. /** @hidden */
  88824. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  88825. readonly name: string;
  88826. enabled: boolean;
  88827. private _loader;
  88828. constructor(loader: GLTFLoader);
  88829. dispose(): void;
  88830. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  88831. }
  88832. }
  88833. declare module BABYLON.GLTF2.Loader.Extensions {
  88834. /**
  88835. * Store glTF extras (if present) in BJS objects' metadata
  88836. */
  88837. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  88838. /**
  88839. * The name of this extension.
  88840. */
  88841. readonly name: string;
  88842. /**
  88843. * Defines whether this extension is enabled.
  88844. */
  88845. enabled: boolean;
  88846. private _loader;
  88847. private _assignExtras;
  88848. /** @hidden */
  88849. constructor(loader: GLTFLoader);
  88850. /** @hidden */
  88851. dispose(): void;
  88852. /** @hidden */
  88853. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  88854. /** @hidden */
  88855. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  88856. /** @hidden */
  88857. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  88858. }
  88859. }
  88860. declare module BABYLON {
  88861. /**
  88862. * Class reading and parsing the MTL file bundled with the obj file.
  88863. */
  88864. export class MTLFileLoader {
  88865. /**
  88866. * Invert Y-Axis of referenced textures on load
  88867. */
  88868. static INVERT_TEXTURE_Y: boolean;
  88869. /**
  88870. * All material loaded from the mtl will be set here
  88871. */
  88872. materials: StandardMaterial[];
  88873. /**
  88874. * This function will read the mtl file and create each material described inside
  88875. * This function could be improve by adding :
  88876. * -some component missing (Ni, Tf...)
  88877. * -including the specific options available
  88878. *
  88879. * @param scene defines the scene the material will be created in
  88880. * @param data defines the mtl data to parse
  88881. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  88882. * @param forAssetContainer defines if the material should be registered in the scene
  88883. */
  88884. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string, forAssetContainer: boolean): void;
  88885. /**
  88886. * Gets the texture for the material.
  88887. *
  88888. * If the material is imported from input file,
  88889. * We sanitize the url to ensure it takes the textre from aside the material.
  88890. *
  88891. * @param rootUrl The root url to load from
  88892. * @param value The value stored in the mtl
  88893. * @return The Texture
  88894. */
  88895. private static _getTexture;
  88896. }
  88897. }
  88898. declare module BABYLON {
  88899. /**
  88900. * Options for loading OBJ/MTL files
  88901. */
  88902. type MeshLoadOptions = {
  88903. /**
  88904. * Defines if UVs are optimized by default during load.
  88905. */
  88906. OptimizeWithUV: boolean;
  88907. /**
  88908. * Defines custom scaling of UV coordinates of loaded meshes.
  88909. */
  88910. UVScaling: Vector2;
  88911. /**
  88912. * Invert model on y-axis (does a model scaling inversion)
  88913. */
  88914. InvertY: boolean;
  88915. /**
  88916. * Invert Y-Axis of referenced textures on load
  88917. */
  88918. InvertTextureY: boolean;
  88919. /**
  88920. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  88921. */
  88922. ImportVertexColors: boolean;
  88923. /**
  88924. * Compute the normals for the model, even if normals are present in the file.
  88925. */
  88926. ComputeNormals: boolean;
  88927. /**
  88928. * Optimize the normals for the model. Lighting can be uneven if you use OptimizeWithUV = true because new vertices can be created for the same location if they pertain to different faces.
  88929. * Using OptimizehNormals = true will help smoothing the lighting by averaging the normals of those vertices.
  88930. */
  88931. OptimizeNormals: boolean;
  88932. /**
  88933. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  88934. */
  88935. SkipMaterials: boolean;
  88936. /**
  88937. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  88938. */
  88939. MaterialLoadingFailsSilently: boolean;
  88940. };
  88941. /**
  88942. * OBJ file type loader.
  88943. * This is a babylon scene loader plugin.
  88944. */
  88945. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  88946. /**
  88947. * Defines if UVs are optimized by default during load.
  88948. */
  88949. static OPTIMIZE_WITH_UV: boolean;
  88950. /**
  88951. * Invert model on y-axis (does a model scaling inversion)
  88952. */
  88953. static INVERT_Y: boolean;
  88954. /**
  88955. * Invert Y-Axis of referenced textures on load
  88956. */
  88957. static get INVERT_TEXTURE_Y(): boolean;
  88958. static set INVERT_TEXTURE_Y(value: boolean);
  88959. /**
  88960. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  88961. */
  88962. static IMPORT_VERTEX_COLORS: boolean;
  88963. /**
  88964. * Compute the normals for the model, even if normals are present in the file.
  88965. */
  88966. static COMPUTE_NORMALS: boolean;
  88967. /**
  88968. * Optimize the normals for the model. Lighting can be uneven if you use OptimizeWithUV = true because new vertices can be created for the same location if they pertain to different faces.
  88969. * Using OptimizehNormals = true will help smoothing the lighting by averaging the normals of those vertices.
  88970. */
  88971. static OPTIMIZE_NORMALS: boolean;
  88972. /**
  88973. * Defines custom scaling of UV coordinates of loaded meshes.
  88974. */
  88975. static UV_SCALING: Vector2;
  88976. /**
  88977. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  88978. */
  88979. static SKIP_MATERIALS: boolean;
  88980. /**
  88981. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  88982. *
  88983. * Defaults to true for backwards compatibility.
  88984. */
  88985. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  88986. /**
  88987. * Defines the name of the plugin.
  88988. */
  88989. name: string;
  88990. /**
  88991. * Defines the extension the plugin is able to load.
  88992. */
  88993. extensions: string;
  88994. /** @hidden */
  88995. obj: RegExp;
  88996. /** @hidden */
  88997. group: RegExp;
  88998. /** @hidden */
  88999. mtllib: RegExp;
  89000. /** @hidden */
  89001. usemtl: RegExp;
  89002. /** @hidden */
  89003. smooth: RegExp;
  89004. /** @hidden */
  89005. vertexPattern: RegExp;
  89006. /** @hidden */
  89007. normalPattern: RegExp;
  89008. /** @hidden */
  89009. uvPattern: RegExp;
  89010. /** @hidden */
  89011. facePattern1: RegExp;
  89012. /** @hidden */
  89013. facePattern2: RegExp;
  89014. /** @hidden */
  89015. facePattern3: RegExp;
  89016. /** @hidden */
  89017. facePattern4: RegExp;
  89018. /** @hidden */
  89019. facePattern5: RegExp;
  89020. private _forAssetContainer;
  89021. private _meshLoadOptions;
  89022. /**
  89023. * Creates loader for .OBJ files
  89024. *
  89025. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  89026. */
  89027. constructor(meshLoadOptions?: MeshLoadOptions);
  89028. private static get currentMeshLoadOptions();
  89029. /**
  89030. * Calls synchronously the MTL file attached to this obj.
  89031. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  89032. * Without this function materials are not displayed in the first frame (but displayed after).
  89033. * In consequence it is impossible to get material information in your HTML file
  89034. *
  89035. * @param url The URL of the MTL file
  89036. * @param rootUrl
  89037. * @param onSuccess Callback function to be called when the MTL file is loaded
  89038. * @private
  89039. */
  89040. private _loadMTL;
  89041. /**
  89042. * Instantiates a OBJ file loader plugin.
  89043. * @returns the created plugin
  89044. */
  89045. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  89046. /**
  89047. * If the data string can be loaded directly.
  89048. *
  89049. * @param data string containing the file data
  89050. * @returns if the data can be loaded directly
  89051. */
  89052. canDirectLoad(data: string): boolean;
  89053. /**
  89054. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  89055. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  89056. * @param scene the scene the meshes should be added to
  89057. * @param data the OBJ data to load
  89058. * @param rootUrl root url to load from
  89059. * @param onProgress event that fires when loading progress has occured
  89060. * @param fileName Defines the name of the file to load
  89061. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  89062. */
  89063. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<ISceneLoaderAsyncResult>;
  89064. /**
  89065. * Imports all objects from the loaded OBJ data and adds them to the scene
  89066. * @param scene the scene the objects should be added to
  89067. * @param data the OBJ data to load
  89068. * @param rootUrl root url to load from
  89069. * @param onProgress event that fires when loading progress has occured
  89070. * @param fileName Defines the name of the file to load
  89071. * @returns a promise which completes when objects have been loaded to the scene
  89072. */
  89073. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  89074. /**
  89075. * Load into an asset container.
  89076. * @param scene The scene to load into
  89077. * @param data The data to import
  89078. * @param rootUrl The root url for scene and resources
  89079. * @param onProgress The callback when the load progresses
  89080. * @param fileName Defines the name of the file to load
  89081. * @returns The loaded asset container
  89082. */
  89083. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  89084. private _optimizeNormals;
  89085. /**
  89086. * Read the OBJ file and create an Array of meshes.
  89087. * Each mesh contains all information given by the OBJ and the MTL file.
  89088. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  89089. *
  89090. * @param meshesNames
  89091. * @param scene Scene The scene where are displayed the data
  89092. * @param data String The content of the obj file
  89093. * @param rootUrl String The path to the folder
  89094. * @returns Array<AbstractMesh>
  89095. * @private
  89096. */
  89097. private _parseSolid;
  89098. }
  89099. }
  89100. declare module BABYLON {
  89101. /**
  89102. * STL file type loader.
  89103. * This is a babylon scene loader plugin.
  89104. */
  89105. export class STLFileLoader implements ISceneLoaderPlugin {
  89106. /** @hidden */
  89107. solidPattern: RegExp;
  89108. /** @hidden */
  89109. facetsPattern: RegExp;
  89110. /** @hidden */
  89111. normalPattern: RegExp;
  89112. /** @hidden */
  89113. vertexPattern: RegExp;
  89114. /**
  89115. * Defines the name of the plugin.
  89116. */
  89117. name: string;
  89118. /**
  89119. * Defines the extensions the stl loader is able to load.
  89120. * force data to come in as an ArrayBuffer
  89121. * we'll convert to string if it looks like it's an ASCII .stl
  89122. */
  89123. extensions: ISceneLoaderPluginExtensions;
  89124. /**
  89125. * Import meshes into a scene.
  89126. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  89127. * @param scene The scene to import into
  89128. * @param data The data to import
  89129. * @param rootUrl The root url for scene and resources
  89130. * @param meshes The meshes array to import into
  89131. * @param particleSystems The particle systems array to import into
  89132. * @param skeletons The skeletons array to import into
  89133. * @param onError The callback when import fails
  89134. * @returns True if successful or false otherwise
  89135. */
  89136. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  89137. /**
  89138. * Load into a scene.
  89139. * @param scene The scene to load into
  89140. * @param data The data to import
  89141. * @param rootUrl The root url for scene and resources
  89142. * @param onError The callback when import fails
  89143. * @returns true if successful or false otherwise
  89144. */
  89145. load(scene: Scene, data: any, rootUrl: string): boolean;
  89146. /**
  89147. * Load into an asset container.
  89148. * @param scene The scene to load into
  89149. * @param data The data to import
  89150. * @param rootUrl The root url for scene and resources
  89151. * @param onError The callback when import fails
  89152. * @returns The loaded asset container
  89153. */
  89154. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  89155. private _isBinary;
  89156. private _parseBinary;
  89157. private _parseASCII;
  89158. }
  89159. }
  89160. declare module BABYLON {
  89161. /**
  89162. * Class for generating OBJ data from a Babylon scene.
  89163. */
  89164. export class OBJExport {
  89165. /**
  89166. * Exports the geometry of a Mesh array in .OBJ file format (text)
  89167. * @param mesh defines the list of meshes to serialize
  89168. * @param materials defines if materials should be exported
  89169. * @param matlibname defines the name of the associated mtl file
  89170. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  89171. * @returns the OBJ content
  89172. */
  89173. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  89174. /**
  89175. * Exports the material(s) of a mesh in .MTL file format (text)
  89176. * @param mesh defines the mesh to extract the material from
  89177. * @returns the mtl content
  89178. */
  89179. static MTL(mesh: Mesh): string;
  89180. }
  89181. }
  89182. declare module BABYLON {
  89183. /** @hidden */
  89184. export var __IGLTFExporterExtension: number;
  89185. /**
  89186. * Interface for extending the exporter
  89187. * @hidden
  89188. */
  89189. export interface IGLTFExporterExtension {
  89190. /**
  89191. * The name of this extension
  89192. */
  89193. readonly name: string;
  89194. /**
  89195. * Defines whether this extension is enabled
  89196. */
  89197. enabled: boolean;
  89198. /**
  89199. * Defines whether this extension is required
  89200. */
  89201. required: boolean;
  89202. }
  89203. }
  89204. declare module BABYLON.GLTF2.Exporter {
  89205. /** @hidden */
  89206. export var __IGLTFExporterExtensionV2: number;
  89207. /**
  89208. * Interface for a glTF exporter extension
  89209. * @hidden
  89210. */
  89211. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  89212. /**
  89213. * Define this method to modify the default behavior before exporting a texture
  89214. * @param context The context when loading the asset
  89215. * @param babylonTexture The Babylon.js texture
  89216. * @param mimeType The mime-type of the generated image
  89217. * @returns A promise that resolves with the exported texture
  89218. */
  89219. preExportTextureAsync?(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Texture>;
  89220. /**
  89221. * Define this method to get notified when a texture info is created
  89222. * @param context The context when loading the asset
  89223. * @param textureInfo The glTF texture info
  89224. * @param babylonTexture The Babylon.js texture
  89225. */
  89226. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  89227. /**
  89228. * Define this method to modify the default behavior when exporting texture info
  89229. * @param context The context when loading the asset
  89230. * @param meshPrimitive glTF mesh primitive
  89231. * @param babylonSubMesh Babylon submesh
  89232. * @param binaryWriter glTF serializer binary writer instance
  89233. * @returns nullable IMeshPrimitive promise
  89234. */
  89235. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: Nullable<IMeshPrimitive>, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<IMeshPrimitive>;
  89236. /**
  89237. * Define this method to modify the default behavior when exporting a node
  89238. * @param context The context when exporting the node
  89239. * @param node glTF node
  89240. * @param babylonNode BabylonJS node
  89241. * @returns nullable INode promise
  89242. */
  89243. postExportNodeAsync?(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  89244. [key: number]: number;
  89245. }): Promise<Nullable<INode>>;
  89246. /**
  89247. * Define this method to modify the default behavior when exporting a material
  89248. * @param material glTF material
  89249. * @param babylonMaterial BabylonJS material
  89250. * @returns nullable IMaterial promise
  89251. */
  89252. postExportMaterialAsync?(context: string, node: Nullable<IMaterial>, babylonMaterial: Material): Promise<IMaterial>;
  89253. /**
  89254. * Define this method to return additional textures to export from a material
  89255. * @param material glTF material
  89256. * @param babylonMaterial BabylonJS material
  89257. * @returns List of textures
  89258. */
  89259. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  89260. /** Gets a boolean indicating that this extension was used */
  89261. wasUsed: boolean;
  89262. /** Gets a boolean indicating that this extension is required for the file to work */
  89263. required: boolean;
  89264. /**
  89265. * Called after the exporter state changes to EXPORTING
  89266. */
  89267. onExporting?(): void;
  89268. }
  89269. }
  89270. declare module BABYLON.GLTF2.Exporter {
  89271. /**
  89272. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  89273. * @hidden
  89274. */
  89275. export class _GLTFMaterialExporter {
  89276. /**
  89277. * Represents the dielectric specular values for R, G and B
  89278. */
  89279. private static readonly _DielectricSpecular;
  89280. /**
  89281. * Allows the maximum specular power to be defined for material calculations
  89282. */
  89283. private static readonly _MaxSpecularPower;
  89284. /**
  89285. * Mapping to store textures
  89286. */
  89287. private _textureMap;
  89288. /**
  89289. * Numeric tolerance value
  89290. */
  89291. private static readonly _Epsilon;
  89292. /**
  89293. * Reference to the glTF Exporter
  89294. */
  89295. private _exporter;
  89296. constructor(exporter: _Exporter);
  89297. /**
  89298. * Specifies if two colors are approximately equal in value
  89299. * @param color1 first color to compare to
  89300. * @param color2 second color to compare to
  89301. * @param epsilon threshold value
  89302. */
  89303. private static FuzzyEquals;
  89304. /**
  89305. * Gets the materials from a Babylon scene and converts them to glTF materials
  89306. * @param scene babylonjs scene
  89307. * @param mimeType texture mime type
  89308. * @param images array of images
  89309. * @param textures array of textures
  89310. * @param materials array of materials
  89311. * @param imageData mapping of texture names to base64 textures
  89312. * @param hasTextureCoords specifies if texture coordinates are present on the material
  89313. */
  89314. _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  89315. /**
  89316. * Makes a copy of the glTF material without the texture parameters
  89317. * @param originalMaterial original glTF material
  89318. * @returns glTF material without texture parameters
  89319. */
  89320. _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  89321. /**
  89322. * Specifies if the material has any texture parameters present
  89323. * @param material glTF Material
  89324. * @returns boolean specifying if texture parameters are present
  89325. */
  89326. _hasTexturesPresent(material: IMaterial): boolean;
  89327. /**
  89328. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  89329. * @param babylonStandardMaterial
  89330. * @returns glTF Metallic Roughness Material representation
  89331. */
  89332. _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  89333. /**
  89334. * Computes the metallic factor
  89335. * @param diffuse diffused value
  89336. * @param specular specular value
  89337. * @param oneMinusSpecularStrength one minus the specular strength
  89338. * @returns metallic value
  89339. */
  89340. static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  89341. /**
  89342. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  89343. * @param glTFMaterial glTF material
  89344. * @param babylonMaterial Babylon material
  89345. */
  89346. private static _SetAlphaMode;
  89347. /**
  89348. * Converts a Babylon Standard Material to a glTF Material
  89349. * @param babylonStandardMaterial BJS Standard Material
  89350. * @param mimeType mime type to use for the textures
  89351. * @param images array of glTF image interfaces
  89352. * @param textures array of glTF texture interfaces
  89353. * @param materials array of glTF material interfaces
  89354. * @param imageData map of image file name to data
  89355. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  89356. */
  89357. _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  89358. private _finishMaterial;
  89359. /**
  89360. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  89361. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  89362. * @param mimeType mime type to use for the textures
  89363. * @param images array of glTF image interfaces
  89364. * @param textures array of glTF texture interfaces
  89365. * @param materials array of glTF material interfaces
  89366. * @param imageData map of image file name to data
  89367. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  89368. */
  89369. _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  89370. /**
  89371. * Converts an image typed array buffer to a base64 image
  89372. * @param buffer typed array buffer
  89373. * @param width width of the image
  89374. * @param height height of the image
  89375. * @param mimeType mimetype of the image
  89376. * @returns base64 image string
  89377. */
  89378. private _createBase64FromCanvasAsync;
  89379. /**
  89380. * Generates a white texture based on the specified width and height
  89381. * @param width width of the texture in pixels
  89382. * @param height height of the texture in pixels
  89383. * @param scene babylonjs scene
  89384. * @returns white texture
  89385. */
  89386. private _createWhiteTexture;
  89387. /**
  89388. * 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
  89389. * @param texture1 first texture to resize
  89390. * @param texture2 second texture to resize
  89391. * @param scene babylonjs scene
  89392. * @returns resized textures or null
  89393. */
  89394. private _resizeTexturesToSameDimensions;
  89395. /**
  89396. * Converts an array of pixels to a Float32Array
  89397. * Throws an error if the pixel format is not supported
  89398. * @param pixels - array buffer containing pixel values
  89399. * @returns Float32 of pixels
  89400. */
  89401. private _convertPixelArrayToFloat32;
  89402. /**
  89403. * Convert Specular Glossiness Textures to Metallic Roughness
  89404. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  89405. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  89406. * @param diffuseTexture texture used to store diffuse information
  89407. * @param specularGlossinessTexture texture used to store specular and glossiness information
  89408. * @param factors specular glossiness material factors
  89409. * @param mimeType the mime type to use for the texture
  89410. * @returns pbr metallic roughness interface or null
  89411. */
  89412. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  89413. /**
  89414. * Converts specular glossiness material properties to metallic roughness
  89415. * @param specularGlossiness interface with specular glossiness material properties
  89416. * @returns interface with metallic roughness material properties
  89417. */
  89418. private _convertSpecularGlossinessToMetallicRoughness;
  89419. /**
  89420. * Calculates the surface reflectance, independent of lighting conditions
  89421. * @param color Color source to calculate brightness from
  89422. * @returns number representing the perceived brightness, or zero if color is undefined
  89423. */
  89424. private _getPerceivedBrightness;
  89425. /**
  89426. * Returns the maximum color component value
  89427. * @param color
  89428. * @returns maximum color component value, or zero if color is null or undefined
  89429. */
  89430. private _getMaxComponent;
  89431. /**
  89432. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  89433. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  89434. * @param mimeType mime type to use for the textures
  89435. * @param images array of glTF image interfaces
  89436. * @param textures array of glTF texture interfaces
  89437. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  89438. * @param imageData map of image file name to data
  89439. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  89440. * @returns glTF PBR Metallic Roughness factors
  89441. */
  89442. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  89443. private _getGLTFTextureSampler;
  89444. private _getGLTFTextureWrapMode;
  89445. private _getGLTFTextureWrapModesSampler;
  89446. /**
  89447. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  89448. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  89449. * @param mimeType mime type to use for the textures
  89450. * @param images array of glTF image interfaces
  89451. * @param textures array of glTF texture interfaces
  89452. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  89453. * @param imageData map of image file name to data
  89454. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  89455. * @returns glTF PBR Metallic Roughness factors
  89456. */
  89457. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  89458. /**
  89459. * Converts a Babylon PBR Base Material to a glTF Material
  89460. * @param babylonPBRMaterial BJS PBR Base Material
  89461. * @param mimeType mime type to use for the textures
  89462. * @param images array of glTF image interfaces
  89463. * @param textures array of glTF texture interfaces
  89464. * @param materials array of glTF material interfaces
  89465. * @param imageData map of image file name to data
  89466. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  89467. */
  89468. _convertPBRMaterialAsync(babylonPBRMaterial: PBRBaseMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  89469. private setMetallicRoughnessPbrMaterial;
  89470. private getPixelsFromTexture;
  89471. /**
  89472. * Extracts a texture from a Babylon texture into file data and glTF data
  89473. * @param babylonTexture Babylon texture to extract
  89474. * @param mimeType Mime Type of the babylonTexture
  89475. * @return glTF texture info, or null if the texture format is not supported
  89476. */
  89477. _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  89478. _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  89479. /**
  89480. * Builds a texture from base64 string
  89481. * @param base64Texture base64 texture string
  89482. * @param baseTextureName Name to use for the texture
  89483. * @param mimeType image mime type for the texture
  89484. * @param images array of images
  89485. * @param textures array of textures
  89486. * @param imageData map of image data
  89487. * @returns glTF texture info, or null if the texture format is not supported
  89488. */
  89489. private _getTextureInfoFromBase64;
  89490. }
  89491. }
  89492. declare module BABYLON {
  89493. /**
  89494. * Class for holding and downloading glTF file data
  89495. */
  89496. export class GLTFData {
  89497. /**
  89498. * Object which contains the file name as the key and its data as the value
  89499. */
  89500. glTFFiles: {
  89501. [fileName: string]: string | Blob;
  89502. };
  89503. /**
  89504. * Initializes the glTF file object
  89505. */
  89506. constructor();
  89507. /**
  89508. * Downloads the glTF data as files based on their names and data
  89509. */
  89510. downloadFiles(): void;
  89511. }
  89512. }
  89513. declare module BABYLON {
  89514. /**
  89515. * Holds a collection of exporter options and parameters
  89516. */
  89517. export interface IExportOptions {
  89518. /**
  89519. * Function which indicates whether a babylon node should be exported or not
  89520. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  89521. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  89522. */
  89523. shouldExportNode?(node: Node): boolean;
  89524. /**
  89525. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  89526. * @param metadata source metadata to read from
  89527. * @returns the data to store to glTF node extras
  89528. */
  89529. metadataSelector?(metadata: any): any;
  89530. /**
  89531. * The sample rate to bake animation curves
  89532. */
  89533. animationSampleRate?: number;
  89534. /**
  89535. * Begin serialization without waiting for the scene to be ready
  89536. */
  89537. exportWithoutWaitingForScene?: boolean;
  89538. /**
  89539. * Indicates if coordinate system swapping root nodes should be included in export
  89540. */
  89541. includeCoordinateSystemConversionNodes?: boolean;
  89542. }
  89543. /**
  89544. * Class for generating glTF data from a Babylon scene.
  89545. */
  89546. export class GLTF2Export {
  89547. /**
  89548. * Exports the geometry of the scene to .gltf file format asynchronously
  89549. * @param scene Babylon scene with scene hierarchy information
  89550. * @param filePrefix File prefix to use when generating the glTF file
  89551. * @param options Exporter options
  89552. * @returns Returns an object with a .gltf file and associates texture names
  89553. * as keys and their data and paths as values
  89554. */
  89555. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  89556. private static _PreExportAsync;
  89557. private static _PostExportAsync;
  89558. /**
  89559. * Exports the geometry of the scene to .glb file format asychronously
  89560. * @param scene Babylon scene with scene hierarchy information
  89561. * @param filePrefix File prefix to use when generating glb file
  89562. * @param options Exporter options
  89563. * @returns Returns an object with a .glb filename as key and data as value
  89564. */
  89565. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  89566. }
  89567. }
  89568. declare module BABYLON.GLTF2.Exporter {
  89569. /**
  89570. * @hidden
  89571. */
  89572. export class _GLTFUtilities {
  89573. /**
  89574. * Creates a buffer view based on the supplied arguments
  89575. * @param bufferIndex index value of the specified buffer
  89576. * @param byteOffset byte offset value
  89577. * @param byteLength byte length of the bufferView
  89578. * @param byteStride byte distance between conequential elements
  89579. * @param name name of the buffer view
  89580. * @returns bufferView for glTF
  89581. */
  89582. static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  89583. /**
  89584. * Creates an accessor based on the supplied arguments
  89585. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  89586. * @param name The name of the accessor
  89587. * @param type The type of the accessor
  89588. * @param componentType The datatype of components in the attribute
  89589. * @param count The number of attributes referenced by this accessor
  89590. * @param byteOffset The offset relative to the start of the bufferView in bytes
  89591. * @param min Minimum value of each component in this attribute
  89592. * @param max Maximum value of each component in this attribute
  89593. * @returns accessor for glTF
  89594. */
  89595. static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  89596. /**
  89597. * Calculates the minimum and maximum values of an array of position floats
  89598. * @param positions Positions array of a mesh
  89599. * @param vertexStart Starting vertex offset to calculate min and max values
  89600. * @param vertexCount Number of vertices to check for min and max values
  89601. * @returns min number array and max number array
  89602. */
  89603. static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  89604. min: number[];
  89605. max: number[];
  89606. };
  89607. /**
  89608. * Converts a new right-handed Vector3
  89609. * @param vector vector3 array
  89610. * @returns right-handed Vector3
  89611. */
  89612. static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  89613. /**
  89614. * Converts a Vector3 to right-handed
  89615. * @param vector Vector3 to convert to right-handed
  89616. */
  89617. static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  89618. /**
  89619. * Converts a three element number array to right-handed
  89620. * @param vector number array to convert to right-handed
  89621. */
  89622. static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  89623. /**
  89624. * Converts a new right-handed Vector3
  89625. * @param vector vector3 array
  89626. * @returns right-handed Vector3
  89627. */
  89628. static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  89629. /**
  89630. * Converts a Vector3 to right-handed
  89631. * @param vector Vector3 to convert to right-handed
  89632. */
  89633. static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  89634. /**
  89635. * Converts a three element number array to right-handed
  89636. * @param vector number array to convert to right-handed
  89637. */
  89638. static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  89639. /**
  89640. * Converts a Vector4 to right-handed
  89641. * @param vector Vector4 to convert to right-handed
  89642. */
  89643. static _GetRightHandedVector4FromRef(vector: Vector4): void;
  89644. /**
  89645. * Converts a Vector4 to right-handed
  89646. * @param vector Vector4 to convert to right-handed
  89647. */
  89648. static _GetRightHandedArray4FromRef(vector: number[]): void;
  89649. /**
  89650. * Converts a Quaternion to right-handed
  89651. * @param quaternion Source quaternion to convert to right-handed
  89652. */
  89653. static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  89654. /**
  89655. * Converts a Quaternion to right-handed
  89656. * @param quaternion Source quaternion to convert to right-handed
  89657. */
  89658. static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  89659. static _NormalizeTangentFromRef(tangent: Vector4): void;
  89660. static _GetRightHandedMatrixFromRef(matrix: Matrix): void;
  89661. static _GetDataAccessorElementCount(accessorType: AccessorType): 1 | 3 | 2 | 4 | 9 | 16;
  89662. }
  89663. }
  89664. declare module BABYLON.GLTF2.Exporter {
  89665. /**
  89666. * Converts Babylon Scene into glTF 2.0.
  89667. * @hidden
  89668. */
  89669. export class _Exporter {
  89670. /**
  89671. * Stores the glTF to export
  89672. */
  89673. _glTF: IGLTF;
  89674. /**
  89675. * Stores all generated buffer views, which represents views into the main glTF buffer data
  89676. */
  89677. _bufferViews: IBufferView[];
  89678. /**
  89679. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  89680. */
  89681. _accessors: IAccessor[];
  89682. /**
  89683. * Stores all the generated nodes, which contains transform and/or mesh information per node
  89684. */
  89685. _nodes: INode[];
  89686. /**
  89687. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  89688. */
  89689. private _scenes;
  89690. /**
  89691. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  89692. */
  89693. private _meshes;
  89694. /**
  89695. * Stores all the generated material information, which represents the appearance of each primitive
  89696. */
  89697. _materials: IMaterial[];
  89698. _materialMap: {
  89699. [materialID: number]: number;
  89700. };
  89701. /**
  89702. * Stores all the generated texture information, which is referenced by glTF materials
  89703. */
  89704. _textures: ITexture[];
  89705. /**
  89706. * Stores all the generated image information, which is referenced by glTF textures
  89707. */
  89708. _images: IImage[];
  89709. /**
  89710. * Stores all the texture samplers
  89711. */
  89712. _samplers: ISampler[];
  89713. /**
  89714. * Stores all the generated glTF skins
  89715. */
  89716. _skins: ISkin[];
  89717. /**
  89718. * Stores all the generated animation samplers, which is referenced by glTF animations
  89719. */
  89720. /**
  89721. * Stores the animations for glTF models
  89722. */
  89723. private _animations;
  89724. /**
  89725. * Stores the total amount of bytes stored in the glTF buffer
  89726. */
  89727. private _totalByteLength;
  89728. /**
  89729. * Stores a reference to the Babylon scene containing the source geometry and material information
  89730. */
  89731. _babylonScene: Scene;
  89732. /**
  89733. * Stores a map of the image data, where the key is the file name and the value
  89734. * is the image data
  89735. */
  89736. _imageData: {
  89737. [fileName: string]: {
  89738. data: Uint8Array;
  89739. mimeType: ImageMimeType;
  89740. };
  89741. };
  89742. protected _orderedImageData: Array<{
  89743. data: Uint8Array;
  89744. mimeType: ImageMimeType;
  89745. }>;
  89746. /**
  89747. * Stores a map of the unique id of a node to its index in the node array
  89748. */
  89749. _nodeMap: {
  89750. [key: number]: number;
  89751. };
  89752. /**
  89753. * Specifies if the source Babylon scene was left handed, and needed conversion.
  89754. */
  89755. _convertToRightHandedSystem: boolean;
  89756. /**
  89757. * Specifies if a Babylon node should be converted to right-handed on export
  89758. */
  89759. _convertToRightHandedSystemMap: {
  89760. [nodeId: number]: boolean;
  89761. };
  89762. _includeCoordinateSystemConversionNodes: boolean;
  89763. /**
  89764. * Baked animation sample rate
  89765. */
  89766. private _animationSampleRate;
  89767. private _options;
  89768. private _localEngine;
  89769. _glTFMaterialExporter: _GLTFMaterialExporter;
  89770. private _extensions;
  89771. private static _ExtensionNames;
  89772. private static _ExtensionFactories;
  89773. private _applyExtension;
  89774. private _applyExtensions;
  89775. _extensionsPreExportTextureAsync(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Nullable<BaseTexture>>;
  89776. _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<Nullable<IMeshPrimitive>>;
  89777. _extensionsPostExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  89778. [key: number]: number;
  89779. }): Promise<Nullable<INode>>;
  89780. _extensionsPostExportMaterialAsync(context: string, material: Nullable<IMaterial>, babylonMaterial: Material): Promise<Nullable<IMaterial>>;
  89781. _extensionsPostExportMaterialAdditionalTextures(context: string, material: IMaterial, babylonMaterial: Material): BaseTexture[];
  89782. _extensionsPostExportTextures(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  89783. private _forEachExtensions;
  89784. private _extensionsOnExporting;
  89785. /**
  89786. * Load glTF serializer extensions
  89787. */
  89788. private _loadExtensions;
  89789. /**
  89790. * Creates a glTF Exporter instance, which can accept optional exporter options
  89791. * @param babylonScene Babylon scene object
  89792. * @param options Options to modify the behavior of the exporter
  89793. */
  89794. constructor(babylonScene: Scene, options?: IExportOptions);
  89795. dispose(): void;
  89796. /**
  89797. * Registers a glTF exporter extension
  89798. * @param name Name of the extension to export
  89799. * @param factory The factory function that creates the exporter extension
  89800. */
  89801. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  89802. /**
  89803. * Un-registers an exporter extension
  89804. * @param name The name fo the exporter extension
  89805. * @returns A boolean indicating whether the extension has been un-registered
  89806. */
  89807. static UnregisterExtension(name: string): boolean;
  89808. private reorderIndicesBasedOnPrimitiveMode;
  89809. /**
  89810. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  89811. * clock-wise during export to glTF
  89812. * @param submesh BabylonJS submesh
  89813. * @param primitiveMode Primitive mode of the mesh
  89814. * @param sideOrientation the winding order of the submesh
  89815. * @param vertexBufferKind The type of vertex attribute
  89816. * @param meshAttributeArray The vertex attribute data
  89817. * @param byteOffset The offset to the binary data
  89818. * @param binaryWriter The binary data for the glTF file
  89819. * @param convertToRightHandedSystem Converts the values to right-handed
  89820. */
  89821. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  89822. /**
  89823. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  89824. * clock-wise during export to glTF
  89825. * @param submesh BabylonJS submesh
  89826. * @param primitiveMode Primitive mode of the mesh
  89827. * @param sideOrientation the winding order of the submesh
  89828. * @param vertexBufferKind The type of vertex attribute
  89829. * @param meshAttributeArray The vertex attribute data
  89830. * @param byteOffset The offset to the binary data
  89831. * @param binaryWriter The binary data for the glTF file
  89832. * @param convertToRightHandedSystem Converts the values to right-handed
  89833. */
  89834. private reorderTriangleFillMode;
  89835. /**
  89836. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  89837. * clock-wise during export to glTF
  89838. * @param submesh BabylonJS submesh
  89839. * @param primitiveMode Primitive mode of the mesh
  89840. * @param sideOrientation the winding order of the submesh
  89841. * @param vertexBufferKind The type of vertex attribute
  89842. * @param meshAttributeArray The vertex attribute data
  89843. * @param byteOffset The offset to the binary data
  89844. * @param binaryWriter The binary data for the glTF file
  89845. * @param convertToRightHandedSystem Converts the values to right-handed
  89846. */
  89847. private reorderTriangleStripDrawMode;
  89848. /**
  89849. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  89850. * clock-wise during export to glTF
  89851. * @param submesh BabylonJS submesh
  89852. * @param primitiveMode Primitive mode of the mesh
  89853. * @param sideOrientation the winding order of the submesh
  89854. * @param vertexBufferKind The type of vertex attribute
  89855. * @param meshAttributeArray The vertex attribute data
  89856. * @param byteOffset The offset to the binary data
  89857. * @param binaryWriter The binary data for the glTF file
  89858. * @param convertToRightHandedSystem Converts the values to right-handed
  89859. */
  89860. private reorderTriangleFanMode;
  89861. /**
  89862. * Writes the vertex attribute data to binary
  89863. * @param vertices The vertices to write to the binary writer
  89864. * @param byteOffset The offset into the binary writer to overwrite binary data
  89865. * @param vertexAttributeKind The vertex attribute type
  89866. * @param meshAttributeArray The vertex attribute data
  89867. * @param binaryWriter The writer containing the binary data
  89868. * @param convertToRightHandedSystem Converts the values to right-handed
  89869. */
  89870. private writeVertexAttributeData;
  89871. /**
  89872. * Writes mesh attribute data to a data buffer
  89873. * Returns the bytelength of the data
  89874. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  89875. * @param meshAttributeArray Array containing the attribute data
  89876. * @param byteStride Specifies the space between data
  89877. * @param binaryWriter The buffer to write the binary data to
  89878. * @param convertToRightHandedSystem Converts the values to right-handed
  89879. */
  89880. writeAttributeData(vertexBufferKind: string, attributeComponentKind: AccessorComponentType, meshAttributeArray: FloatArray, stride: number, binaryWriter: _BinaryWriter, convertToRightHandedSystem: boolean, babylonTransformNode: TransformNode): void;
  89881. /**
  89882. * Writes mesh attribute data to a data buffer
  89883. * Returns the bytelength of the data
  89884. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  89885. * @param meshAttributeArray Array containing the attribute data
  89886. * @param byteStride Specifies the space between data
  89887. * @param binaryWriter The buffer to write the binary data to
  89888. * @param convertToRightHandedSystem Converts the values to right-handed
  89889. */
  89890. writeMorphTargetAttributeData(vertexBufferKind: string, attributeComponentKind: AccessorComponentType, meshPrimitive: SubMesh, morphTarget: MorphTarget, meshAttributeArray: FloatArray, morphTargetAttributeArray: FloatArray, stride: number, binaryWriter: _BinaryWriter, convertToRightHandedSystem: boolean, minMax?: any): void;
  89891. /**
  89892. * Generates glTF json data
  89893. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  89894. * @param glTFPrefix Text to use when prefixing a glTF file
  89895. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  89896. * @returns json data as string
  89897. */
  89898. private generateJSON;
  89899. /**
  89900. * Generates data for .gltf and .bin files based on the glTF prefix string
  89901. * @param glTFPrefix Text to use when prefixing a glTF file
  89902. * @param dispose Dispose the exporter
  89903. * @returns GLTFData with glTF file data
  89904. */
  89905. _generateGLTFAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  89906. /**
  89907. * Creates a binary buffer for glTF
  89908. * @returns array buffer for binary data
  89909. */
  89910. private _generateBinaryAsync;
  89911. /**
  89912. * Pads the number to a multiple of 4
  89913. * @param num number to pad
  89914. * @returns padded number
  89915. */
  89916. private _getPadding;
  89917. /**
  89918. * @hidden
  89919. */
  89920. _generateGLBAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  89921. /**
  89922. * Sets the TRS for each node
  89923. * @param node glTF Node for storing the transformation data
  89924. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  89925. * @param convertToRightHandedSystem Converts the values to right-handed
  89926. */
  89927. private setNodeTransformation;
  89928. private getVertexBufferFromMesh;
  89929. /**
  89930. * Creates a bufferview based on the vertices type for the Babylon mesh
  89931. * @param kind Indicates the type of vertices data
  89932. * @param componentType Indicates the numerical type used to store the data
  89933. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  89934. * @param binaryWriter The buffer to write the bufferview data to
  89935. * @param convertToRightHandedSystem Converts the values to right-handed
  89936. */
  89937. private createBufferViewKind;
  89938. /**
  89939. * Creates a bufferview based on the vertices type for the Babylon mesh
  89940. * @param babylonSubMesh The Babylon submesh that the morph target is applied to
  89941. * @param babylonMorphTarget the morph target to be exported
  89942. * @param binaryWriter The buffer to write the bufferview data to
  89943. * @param convertToRightHandedSystem Converts the values to right-handed
  89944. */
  89945. private setMorphTargetAttributes;
  89946. /**
  89947. * The primitive mode of the Babylon mesh
  89948. * @param babylonMesh The BabylonJS mesh
  89949. */
  89950. private getMeshPrimitiveMode;
  89951. /**
  89952. * Sets the primitive mode of the glTF mesh primitive
  89953. * @param meshPrimitive glTF mesh primitive
  89954. * @param primitiveMode The primitive mode
  89955. */
  89956. private setPrimitiveMode;
  89957. /**
  89958. * Sets the vertex attribute accessor based of the glTF mesh primitive
  89959. * @param meshPrimitive glTF mesh primitive
  89960. * @param attributeKind vertex attribute
  89961. * @returns boolean specifying if uv coordinates are present
  89962. */
  89963. private setAttributeKind;
  89964. /**
  89965. * Sets data for the primitive attributes of each submesh
  89966. * @param mesh glTF Mesh object to store the primitive attribute information
  89967. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  89968. * @param binaryWriter Buffer to write the attribute data to
  89969. * @param convertToRightHandedSystem Converts the values to right-handed
  89970. */
  89971. private setPrimitiveAttributesAsync;
  89972. /**
  89973. * Check if the node is used to convert its descendants from a right handed coordinate system to the Babylon scene's coordinate system.
  89974. * @param node The node to check
  89975. * @returns True if the node is used to convert its descendants from right-handed to left-handed. False otherwise
  89976. */
  89977. private isBabylonCoordinateSystemConvertingNode;
  89978. /**
  89979. * Creates a glTF scene based on the array of meshes
  89980. * Returns the the total byte offset
  89981. * @param babylonScene Babylon scene to get the mesh data from
  89982. * @param binaryWriter Buffer to write binary data to
  89983. */
  89984. private createSceneAsync;
  89985. /**
  89986. * Creates a mapping of Node unique id to node index and handles animations
  89987. * @param babylonScene Babylon Scene
  89988. * @param nodes Babylon transform nodes
  89989. * @param binaryWriter Buffer to write binary data to
  89990. * @returns Node mapping of unique id to index
  89991. */
  89992. private createNodeMapAndAnimationsAsync;
  89993. /**
  89994. * Creates a glTF node from a Babylon mesh
  89995. * @param babylonMesh Source Babylon mesh
  89996. * @param binaryWriter Buffer for storing geometry data
  89997. * @param convertToRightHandedSystem Converts the values to right-handed
  89998. * @param nodeMap Node mapping of unique id to glTF node index
  89999. * @returns glTF node
  90000. */
  90001. private createNodeAsync;
  90002. /**
  90003. * Creates a glTF skin from a Babylon skeleton
  90004. * @param babylonScene Babylon Scene
  90005. * @param nodes Babylon transform nodes
  90006. * @param binaryWriter Buffer to write binary data to
  90007. * @returns Node mapping of unique id to index
  90008. */
  90009. private createSkinsAsync;
  90010. }
  90011. /**
  90012. * @hidden
  90013. *
  90014. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  90015. */
  90016. export class _BinaryWriter {
  90017. /**
  90018. * Array buffer which stores all binary data
  90019. */
  90020. private _arrayBuffer;
  90021. /**
  90022. * View of the array buffer
  90023. */
  90024. private _dataView;
  90025. /**
  90026. * byte offset of data in array buffer
  90027. */
  90028. private _byteOffset;
  90029. /**
  90030. * Initialize binary writer with an initial byte length
  90031. * @param byteLength Initial byte length of the array buffer
  90032. */
  90033. constructor(byteLength: number);
  90034. /**
  90035. * Resize the array buffer to the specified byte length
  90036. * @param byteLength
  90037. */
  90038. private resizeBuffer;
  90039. /**
  90040. * Get an array buffer with the length of the byte offset
  90041. * @returns ArrayBuffer resized to the byte offset
  90042. */
  90043. getArrayBuffer(): ArrayBuffer;
  90044. /**
  90045. * Get the byte offset of the array buffer
  90046. * @returns byte offset
  90047. */
  90048. getByteOffset(): number;
  90049. /**
  90050. * Stores an UInt8 in the array buffer
  90051. * @param entry
  90052. * @param byteOffset If defined, specifies where to set the value as an offset.
  90053. */
  90054. setUInt8(entry: number, byteOffset?: number): void;
  90055. /**
  90056. * Stores an UInt16 in the array buffer
  90057. * @param entry
  90058. * @param byteOffset If defined, specifies where to set the value as an offset.
  90059. */
  90060. setUInt16(entry: number, byteOffset?: number): void;
  90061. /**
  90062. * Gets an UInt32 in the array buffer
  90063. * @param entry
  90064. * @param byteOffset If defined, specifies where to set the value as an offset.
  90065. */
  90066. getUInt32(byteOffset: number): number;
  90067. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  90068. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  90069. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  90070. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  90071. /**
  90072. * Stores a Float32 in the array buffer
  90073. * @param entry
  90074. */
  90075. setFloat32(entry: number, byteOffset?: number): void;
  90076. /**
  90077. * Stores an UInt32 in the array buffer
  90078. * @param entry
  90079. * @param byteOffset If defined, specifies where to set the value as an offset.
  90080. */
  90081. setUInt32(entry: number, byteOffset?: number): void;
  90082. }
  90083. }
  90084. declare module BABYLON.GLTF2.Exporter {
  90085. /**
  90086. * @hidden
  90087. * Interface to store animation data.
  90088. */
  90089. export interface _IAnimationData {
  90090. /**
  90091. * Keyframe data.
  90092. */
  90093. inputs: number[];
  90094. /**
  90095. * Value data.
  90096. */
  90097. outputs: number[][];
  90098. /**
  90099. * Animation interpolation data.
  90100. */
  90101. samplerInterpolation: AnimationSamplerInterpolation;
  90102. /**
  90103. * Minimum keyframe value.
  90104. */
  90105. inputsMin: number;
  90106. /**
  90107. * Maximum keyframe value.
  90108. */
  90109. inputsMax: number;
  90110. }
  90111. /**
  90112. * @hidden
  90113. */
  90114. export interface _IAnimationInfo {
  90115. /**
  90116. * The target channel for the animation
  90117. */
  90118. animationChannelTargetPath: AnimationChannelTargetPath;
  90119. /**
  90120. * The glTF accessor type for the data.
  90121. */
  90122. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4 | AccessorType.SCALAR;
  90123. /**
  90124. * Specifies if quaternions should be used.
  90125. */
  90126. useQuaternion: boolean;
  90127. }
  90128. /**
  90129. * @hidden
  90130. * Utility class for generating glTF animation data from BabylonJS.
  90131. */
  90132. export class _GLTFAnimation {
  90133. /**
  90134. * @ignore
  90135. *
  90136. * Creates glTF channel animation from BabylonJS animation.
  90137. * @param babylonTransformNode - BabylonJS mesh.
  90138. * @param animation - animation.
  90139. * @param animationChannelTargetPath - The target animation channel.
  90140. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  90141. * @param useQuaternion - Specifies if quaternions are used.
  90142. * @returns nullable IAnimationData
  90143. */
  90144. static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  90145. private static _DeduceAnimationInfo;
  90146. /**
  90147. * @ignore
  90148. * Create node animations from the transform node animations
  90149. * @param babylonNode
  90150. * @param runtimeGLTFAnimation
  90151. * @param idleGLTFAnimations
  90152. * @param nodeMap
  90153. * @param nodes
  90154. * @param binaryWriter
  90155. * @param bufferViews
  90156. * @param accessors
  90157. * @param convertToRightHandedSystem
  90158. * @param animationSampleRate
  90159. */
  90160. static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  90161. [key: number]: number;
  90162. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  90163. /**
  90164. * @ignore
  90165. * Create individual morph animations from the mesh's morph target animation tracks
  90166. * @param babylonNode
  90167. * @param runtimeGLTFAnimation
  90168. * @param idleGLTFAnimations
  90169. * @param nodeMap
  90170. * @param nodes
  90171. * @param binaryWriter
  90172. * @param bufferViews
  90173. * @param accessors
  90174. * @param convertToRightHandedSystem
  90175. * @param animationSampleRate
  90176. */
  90177. static _CreateMorphTargetAnimationFromMorphTargetAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  90178. [key: number]: number;
  90179. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  90180. /**
  90181. * @ignore
  90182. * Create node and morph animations from the animation groups
  90183. * @param babylonScene
  90184. * @param glTFAnimations
  90185. * @param nodeMap
  90186. * @param nodes
  90187. * @param binaryWriter
  90188. * @param bufferViews
  90189. * @param accessors
  90190. * @param convertToRightHandedSystemMap
  90191. * @param animationSampleRate
  90192. */
  90193. static _CreateNodeAndMorphAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  90194. [key: number]: number;
  90195. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystemMap: {
  90196. [nodeId: number]: boolean;
  90197. }, animationSampleRate: number): void;
  90198. private static AddAnimation;
  90199. /**
  90200. * Create a baked animation
  90201. * @param babylonTransformNode BabylonJS mesh
  90202. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  90203. * @param animationChannelTargetPath animation target channel
  90204. * @param minFrame minimum animation frame
  90205. * @param maxFrame maximum animation frame
  90206. * @param fps frames per second of the animation
  90207. * @param inputs input key frames of the animation
  90208. * @param outputs output key frame data of the animation
  90209. * @param convertToRightHandedSystem converts the values to right-handed
  90210. * @param useQuaternion specifies if quaternions should be used
  90211. */
  90212. private static _CreateBakedAnimation;
  90213. private static _ConvertFactorToVector3OrQuaternion;
  90214. private static _SetInterpolatedValue;
  90215. /**
  90216. * Creates linear animation from the animation key frames
  90217. * @param babylonTransformNode BabylonJS mesh
  90218. * @param animation BabylonJS animation
  90219. * @param animationChannelTargetPath The target animation channel
  90220. * @param frameDelta The difference between the last and first frame of the animation
  90221. * @param inputs Array to store the key frame times
  90222. * @param outputs Array to store the key frame data
  90223. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  90224. * @param useQuaternion Specifies if quaternions are used in the animation
  90225. */
  90226. private static _CreateLinearOrStepAnimation;
  90227. /**
  90228. * Creates cubic spline animation from the animation key frames
  90229. * @param babylonTransformNode BabylonJS mesh
  90230. * @param animation BabylonJS animation
  90231. * @param animationChannelTargetPath The target animation channel
  90232. * @param frameDelta The difference between the last and first frame of the animation
  90233. * @param inputs Array to store the key frame times
  90234. * @param outputs Array to store the key frame data
  90235. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  90236. * @param useQuaternion Specifies if quaternions are used in the animation
  90237. */
  90238. private static _CreateCubicSplineAnimation;
  90239. private static _GetBasePositionRotationOrScale;
  90240. /**
  90241. * Adds a key frame value
  90242. * @param keyFrame
  90243. * @param animation
  90244. * @param outputs
  90245. * @param animationChannelTargetPath
  90246. * @param basePositionRotationOrScale
  90247. * @param convertToRightHandedSystem
  90248. * @param useQuaternion
  90249. */
  90250. private static _AddKeyframeValue;
  90251. /**
  90252. * Determine the interpolation based on the key frames
  90253. * @param keyFrames
  90254. * @param animationChannelTargetPath
  90255. * @param useQuaternion
  90256. */
  90257. private static _DeduceInterpolation;
  90258. /**
  90259. * Adds an input tangent or output tangent to the output data
  90260. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  90261. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  90262. * @param outputs The animation data by keyframe
  90263. * @param animationChannelTargetPath The target animation channel
  90264. * @param interpolation The interpolation type
  90265. * @param keyFrame The key frame with the animation data
  90266. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  90267. * @param useQuaternion Specifies if quaternions are used
  90268. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  90269. */
  90270. private static AddSplineTangent;
  90271. /**
  90272. * Get the minimum and maximum key frames' frame values
  90273. * @param keyFrames animation key frames
  90274. * @returns the minimum and maximum key frame value
  90275. */
  90276. private static calculateMinMaxKeyFrames;
  90277. }
  90278. }
  90279. declare module BABYLON.GLTF2.Exporter {
  90280. /** @hidden */
  90281. export var textureTransformPixelShader: {
  90282. name: string;
  90283. shader: string;
  90284. };
  90285. }
  90286. declare module BABYLON.GLTF2.Exporter.Extensions {
  90287. /**
  90288. * @hidden
  90289. */
  90290. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  90291. private _recordedTextures;
  90292. /** Name of this extension */
  90293. readonly name: string;
  90294. /** Defines whether this extension is enabled */
  90295. enabled: boolean;
  90296. /** Defines whether this extension is required */
  90297. required: boolean;
  90298. /** Reference to the glTF exporter */
  90299. private _wasUsed;
  90300. constructor(exporter: _Exporter);
  90301. dispose(): void;
  90302. /** @hidden */
  90303. get wasUsed(): boolean;
  90304. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  90305. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Texture>;
  90306. /**
  90307. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  90308. * @param babylonTexture
  90309. * @param offset
  90310. * @param rotation
  90311. * @param scale
  90312. * @param scene
  90313. */
  90314. private _textureTransformTextureAsync;
  90315. }
  90316. }
  90317. declare module BABYLON.GLTF2.Exporter.Extensions {
  90318. /**
  90319. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  90320. */
  90321. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  90322. /** The name of this extension. */
  90323. readonly name: string;
  90324. /** Defines whether this extension is enabled. */
  90325. enabled: boolean;
  90326. /** Defines whether this extension is required */
  90327. required: boolean;
  90328. /** Reference to the glTF exporter */
  90329. private _exporter;
  90330. private _lights;
  90331. /** @hidden */
  90332. constructor(exporter: _Exporter);
  90333. /** @hidden */
  90334. dispose(): void;
  90335. /** @hidden */
  90336. get wasUsed(): boolean;
  90337. /** @hidden */
  90338. onExporting(): void;
  90339. /**
  90340. * Define this method to modify the default behavior when exporting a node
  90341. * @param context The context when exporting the node
  90342. * @param node glTF node
  90343. * @param babylonNode BabylonJS node
  90344. * @param nodeMap Node mapping of unique id to glTF node index
  90345. * @returns nullable INode promise
  90346. */
  90347. postExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  90348. [key: number]: number;
  90349. }): Promise<Nullable<INode>>;
  90350. }
  90351. }
  90352. declare module BABYLON.GLTF2.Exporter.Extensions {
  90353. /**
  90354. * @hidden
  90355. */
  90356. export class KHR_materials_sheen implements IGLTFExporterExtensionV2 {
  90357. /** Name of this extension */
  90358. readonly name: string;
  90359. /** Defines whether this extension is enabled */
  90360. enabled: boolean;
  90361. /** Defines whether this extension is required */
  90362. required: boolean;
  90363. /** Reference to the glTF exporter */
  90364. private _textureInfos;
  90365. private _exportedTextures;
  90366. private _wasUsed;
  90367. constructor(exporter: _Exporter);
  90368. dispose(): void;
  90369. /** @hidden */
  90370. get wasUsed(): boolean;
  90371. private _getTextureIndex;
  90372. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  90373. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  90374. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  90375. }
  90376. }
  90377. declare module BABYLON.GLTF2.Exporter.Extensions {
  90378. /**
  90379. * @hidden
  90380. */
  90381. export class KHR_materials_unlit implements IGLTFExporterExtensionV2 {
  90382. /** Name of this extension */
  90383. readonly name: string;
  90384. /** Defines whether this extension is enabled */
  90385. enabled: boolean;
  90386. /** Defines whether this extension is required */
  90387. required: boolean;
  90388. private _wasUsed;
  90389. constructor(exporter: _Exporter);
  90390. /** @hidden */
  90391. get wasUsed(): boolean;
  90392. dispose(): void;
  90393. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  90394. }
  90395. }
  90396. declare module BABYLON {
  90397. /**
  90398. * Class for generating STL data from a Babylon scene.
  90399. */
  90400. export class STLExport {
  90401. /**
  90402. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  90403. * @param meshes list defines the mesh to serialize
  90404. * @param download triggers the automatic download of the file.
  90405. * @param fileName changes the downloads fileName.
  90406. * @param binary changes the STL to a binary type.
  90407. * @param isLittleEndian toggle for binary type exporter.
  90408. * @param doNotBakeTransform toggle if meshes transforms should be baked or not.
  90409. * @returns the STL as UTF8 string
  90410. */
  90411. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean, doNotBakeTransform?: boolean): any;
  90412. }
  90413. }
  90414. declare module "babylonjs-gltf2interface" {
  90415. export = BABYLON.GLTF2;
  90416. }
  90417. /**
  90418. * Module for glTF 2.0 Interface
  90419. */
  90420. declare module BABYLON.GLTF2 {
  90421. /**
  90422. * The datatype of the components in the attribute
  90423. */
  90424. const enum AccessorComponentType {
  90425. /**
  90426. * Byte
  90427. */
  90428. BYTE = 5120,
  90429. /**
  90430. * Unsigned Byte
  90431. */
  90432. UNSIGNED_BYTE = 5121,
  90433. /**
  90434. * Short
  90435. */
  90436. SHORT = 5122,
  90437. /**
  90438. * Unsigned Short
  90439. */
  90440. UNSIGNED_SHORT = 5123,
  90441. /**
  90442. * Unsigned Int
  90443. */
  90444. UNSIGNED_INT = 5125,
  90445. /**
  90446. * Float
  90447. */
  90448. FLOAT = 5126,
  90449. }
  90450. /**
  90451. * Specifies if the attirbute is a scalar, vector, or matrix
  90452. */
  90453. const enum AccessorType {
  90454. /**
  90455. * Scalar
  90456. */
  90457. SCALAR = "SCALAR",
  90458. /**
  90459. * Vector2
  90460. */
  90461. VEC2 = "VEC2",
  90462. /**
  90463. * Vector3
  90464. */
  90465. VEC3 = "VEC3",
  90466. /**
  90467. * Vector4
  90468. */
  90469. VEC4 = "VEC4",
  90470. /**
  90471. * Matrix2x2
  90472. */
  90473. MAT2 = "MAT2",
  90474. /**
  90475. * Matrix3x3
  90476. */
  90477. MAT3 = "MAT3",
  90478. /**
  90479. * Matrix4x4
  90480. */
  90481. MAT4 = "MAT4",
  90482. }
  90483. /**
  90484. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  90485. */
  90486. const enum AnimationChannelTargetPath {
  90487. /**
  90488. * Translation
  90489. */
  90490. TRANSLATION = "translation",
  90491. /**
  90492. * Rotation
  90493. */
  90494. ROTATION = "rotation",
  90495. /**
  90496. * Scale
  90497. */
  90498. SCALE = "scale",
  90499. /**
  90500. * Weights
  90501. */
  90502. WEIGHTS = "weights",
  90503. }
  90504. /**
  90505. * Interpolation algorithm
  90506. */
  90507. const enum AnimationSamplerInterpolation {
  90508. /**
  90509. * The animated values are linearly interpolated between keyframes
  90510. */
  90511. LINEAR = "LINEAR",
  90512. /**
  90513. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  90514. */
  90515. STEP = "STEP",
  90516. /**
  90517. * The animation's interpolation is computed using a cubic spline with specified tangents
  90518. */
  90519. CUBICSPLINE = "CUBICSPLINE",
  90520. }
  90521. /**
  90522. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  90523. */
  90524. const enum CameraType {
  90525. /**
  90526. * A perspective camera containing properties to create a perspective projection matrix
  90527. */
  90528. PERSPECTIVE = "perspective",
  90529. /**
  90530. * An orthographic camera containing properties to create an orthographic projection matrix
  90531. */
  90532. ORTHOGRAPHIC = "orthographic",
  90533. }
  90534. /**
  90535. * The mime-type of the image
  90536. */
  90537. const enum ImageMimeType {
  90538. /**
  90539. * JPEG Mime-type
  90540. */
  90541. JPEG = "image/jpeg",
  90542. /**
  90543. * PNG Mime-type
  90544. */
  90545. PNG = "image/png",
  90546. }
  90547. /**
  90548. * The alpha rendering mode of the material
  90549. */
  90550. const enum MaterialAlphaMode {
  90551. /**
  90552. * The alpha value is ignored and the rendered output is fully opaque
  90553. */
  90554. OPAQUE = "OPAQUE",
  90555. /**
  90556. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  90557. */
  90558. MASK = "MASK",
  90559. /**
  90560. * 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)
  90561. */
  90562. BLEND = "BLEND",
  90563. }
  90564. /**
  90565. * The type of the primitives to render
  90566. */
  90567. const enum MeshPrimitiveMode {
  90568. /**
  90569. * Points
  90570. */
  90571. POINTS = 0,
  90572. /**
  90573. * Lines
  90574. */
  90575. LINES = 1,
  90576. /**
  90577. * Line Loop
  90578. */
  90579. LINE_LOOP = 2,
  90580. /**
  90581. * Line Strip
  90582. */
  90583. LINE_STRIP = 3,
  90584. /**
  90585. * Triangles
  90586. */
  90587. TRIANGLES = 4,
  90588. /**
  90589. * Triangle Strip
  90590. */
  90591. TRIANGLE_STRIP = 5,
  90592. /**
  90593. * Triangle Fan
  90594. */
  90595. TRIANGLE_FAN = 6,
  90596. }
  90597. /**
  90598. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  90599. */
  90600. const enum TextureMagFilter {
  90601. /**
  90602. * Nearest
  90603. */
  90604. NEAREST = 9728,
  90605. /**
  90606. * Linear
  90607. */
  90608. LINEAR = 9729,
  90609. }
  90610. /**
  90611. * Minification filter. All valid values correspond to WebGL enums
  90612. */
  90613. const enum TextureMinFilter {
  90614. /**
  90615. * Nearest
  90616. */
  90617. NEAREST = 9728,
  90618. /**
  90619. * Linear
  90620. */
  90621. LINEAR = 9729,
  90622. /**
  90623. * Nearest Mip-Map Nearest
  90624. */
  90625. NEAREST_MIPMAP_NEAREST = 9984,
  90626. /**
  90627. * Linear Mipmap Nearest
  90628. */
  90629. LINEAR_MIPMAP_NEAREST = 9985,
  90630. /**
  90631. * Nearest Mipmap Linear
  90632. */
  90633. NEAREST_MIPMAP_LINEAR = 9986,
  90634. /**
  90635. * Linear Mipmap Linear
  90636. */
  90637. LINEAR_MIPMAP_LINEAR = 9987,
  90638. }
  90639. /**
  90640. * S (U) wrapping mode. All valid values correspond to WebGL enums
  90641. */
  90642. const enum TextureWrapMode {
  90643. /**
  90644. * Clamp to Edge
  90645. */
  90646. CLAMP_TO_EDGE = 33071,
  90647. /**
  90648. * Mirrored Repeat
  90649. */
  90650. MIRRORED_REPEAT = 33648,
  90651. /**
  90652. * Repeat
  90653. */
  90654. REPEAT = 10497,
  90655. }
  90656. /**
  90657. * glTF Property
  90658. */
  90659. interface IProperty {
  90660. /**
  90661. * Dictionary object with extension-specific objects
  90662. */
  90663. extensions?: {
  90664. [key: string]: any;
  90665. };
  90666. /**
  90667. * Application-Specific data
  90668. */
  90669. extras?: any;
  90670. }
  90671. /**
  90672. * glTF Child of Root Property
  90673. */
  90674. interface IChildRootProperty extends IProperty {
  90675. /**
  90676. * The user-defined name of this object
  90677. */
  90678. name?: string;
  90679. }
  90680. /**
  90681. * Indices of those attributes that deviate from their initialization value
  90682. */
  90683. interface IAccessorSparseIndices extends IProperty {
  90684. /**
  90685. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  90686. */
  90687. bufferView: number;
  90688. /**
  90689. * The offset relative to the start of the bufferView in bytes. Must be aligned
  90690. */
  90691. byteOffset?: number;
  90692. /**
  90693. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  90694. */
  90695. componentType: AccessorComponentType;
  90696. }
  90697. /**
  90698. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  90699. */
  90700. interface IAccessorSparseValues extends IProperty {
  90701. /**
  90702. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  90703. */
  90704. bufferView: number;
  90705. /**
  90706. * The offset relative to the start of the bufferView in bytes. Must be aligned
  90707. */
  90708. byteOffset?: number;
  90709. }
  90710. /**
  90711. * Sparse storage of attributes that deviate from their initialization value
  90712. */
  90713. interface IAccessorSparse extends IProperty {
  90714. /**
  90715. * The number of attributes encoded in this sparse accessor
  90716. */
  90717. count: number;
  90718. /**
  90719. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  90720. */
  90721. indices: IAccessorSparseIndices;
  90722. /**
  90723. * 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
  90724. */
  90725. values: IAccessorSparseValues;
  90726. }
  90727. /**
  90728. * 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
  90729. */
  90730. interface IAccessor extends IChildRootProperty {
  90731. /**
  90732. * The index of the bufferview
  90733. */
  90734. bufferView?: number;
  90735. /**
  90736. * The offset relative to the start of the bufferView in bytes
  90737. */
  90738. byteOffset?: number;
  90739. /**
  90740. * The datatype of components in the attribute
  90741. */
  90742. componentType: AccessorComponentType;
  90743. /**
  90744. * Specifies whether integer data values should be normalized
  90745. */
  90746. normalized?: boolean;
  90747. /**
  90748. * The number of attributes referenced by this accessor
  90749. */
  90750. count: number;
  90751. /**
  90752. * Specifies if the attribute is a scalar, vector, or matrix
  90753. */
  90754. type: AccessorType;
  90755. /**
  90756. * Maximum value of each component in this attribute
  90757. */
  90758. max?: number[];
  90759. /**
  90760. * Minimum value of each component in this attribute
  90761. */
  90762. min?: number[];
  90763. /**
  90764. * Sparse storage of attributes that deviate from their initialization value
  90765. */
  90766. sparse?: IAccessorSparse;
  90767. }
  90768. /**
  90769. * Targets an animation's sampler at a node's property
  90770. */
  90771. interface IAnimationChannel extends IProperty {
  90772. /**
  90773. * The index of a sampler in this animation used to compute the value for the target
  90774. */
  90775. sampler: number;
  90776. /**
  90777. * The index of the node and TRS property to target
  90778. */
  90779. target: IAnimationChannelTarget;
  90780. }
  90781. /**
  90782. * The index of the node and TRS property that an animation channel targets
  90783. */
  90784. interface IAnimationChannelTarget extends IProperty {
  90785. /**
  90786. * The index of the node to target
  90787. */
  90788. node: number;
  90789. /**
  90790. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  90791. */
  90792. path: AnimationChannelTargetPath;
  90793. }
  90794. /**
  90795. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  90796. */
  90797. interface IAnimationSampler extends IProperty {
  90798. /**
  90799. * The index of an accessor containing keyframe input values, e.g., time
  90800. */
  90801. input: number;
  90802. /**
  90803. * Interpolation algorithm
  90804. */
  90805. interpolation?: AnimationSamplerInterpolation;
  90806. /**
  90807. * The index of an accessor, containing keyframe output values
  90808. */
  90809. output: number;
  90810. }
  90811. /**
  90812. * A keyframe animation
  90813. */
  90814. interface IAnimation extends IChildRootProperty {
  90815. /**
  90816. * An array of channels, each of which targets an animation's sampler at a node's property
  90817. */
  90818. channels: IAnimationChannel[];
  90819. /**
  90820. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  90821. */
  90822. samplers: IAnimationSampler[];
  90823. }
  90824. /**
  90825. * Metadata about the glTF asset
  90826. */
  90827. interface IAsset extends IChildRootProperty {
  90828. /**
  90829. * A copyright message suitable for display to credit the content creator
  90830. */
  90831. copyright?: string;
  90832. /**
  90833. * Tool that generated this glTF model. Useful for debugging
  90834. */
  90835. generator?: string;
  90836. /**
  90837. * The glTF version that this asset targets
  90838. */
  90839. version: string;
  90840. /**
  90841. * The minimum glTF version that this asset targets
  90842. */
  90843. minVersion?: string;
  90844. }
  90845. /**
  90846. * A buffer points to binary geometry, animation, or skins
  90847. */
  90848. interface IBuffer extends IChildRootProperty {
  90849. /**
  90850. * 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
  90851. */
  90852. uri?: string;
  90853. /**
  90854. * The length of the buffer in bytes
  90855. */
  90856. byteLength: number;
  90857. }
  90858. /**
  90859. * A view into a buffer generally representing a subset of the buffer
  90860. */
  90861. interface IBufferView extends IChildRootProperty {
  90862. /**
  90863. * The index of the buffer
  90864. */
  90865. buffer: number;
  90866. /**
  90867. * The offset into the buffer in bytes
  90868. */
  90869. byteOffset?: number;
  90870. /**
  90871. * The lenth of the bufferView in bytes
  90872. */
  90873. byteLength: number;
  90874. /**
  90875. * The stride, in bytes
  90876. */
  90877. byteStride?: number;
  90878. }
  90879. /**
  90880. * An orthographic camera containing properties to create an orthographic projection matrix
  90881. */
  90882. interface ICameraOrthographic extends IProperty {
  90883. /**
  90884. * The floating-point horizontal magnification of the view. Must not be zero
  90885. */
  90886. xmag: number;
  90887. /**
  90888. * The floating-point vertical magnification of the view. Must not be zero
  90889. */
  90890. ymag: number;
  90891. /**
  90892. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  90893. */
  90894. zfar: number;
  90895. /**
  90896. * The floating-point distance to the near clipping plane
  90897. */
  90898. znear: number;
  90899. }
  90900. /**
  90901. * A perspective camera containing properties to create a perspective projection matrix
  90902. */
  90903. interface ICameraPerspective extends IProperty {
  90904. /**
  90905. * The floating-point aspect ratio of the field of view
  90906. */
  90907. aspectRatio?: number;
  90908. /**
  90909. * The floating-point vertical field of view in radians
  90910. */
  90911. yfov: number;
  90912. /**
  90913. * The floating-point distance to the far clipping plane
  90914. */
  90915. zfar?: number;
  90916. /**
  90917. * The floating-point distance to the near clipping plane
  90918. */
  90919. znear: number;
  90920. }
  90921. /**
  90922. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  90923. */
  90924. interface ICamera extends IChildRootProperty {
  90925. /**
  90926. * An orthographic camera containing properties to create an orthographic projection matrix
  90927. */
  90928. orthographic?: ICameraOrthographic;
  90929. /**
  90930. * A perspective camera containing properties to create a perspective projection matrix
  90931. */
  90932. perspective?: ICameraPerspective;
  90933. /**
  90934. * Specifies if the camera uses a perspective or orthographic projection
  90935. */
  90936. type: CameraType;
  90937. }
  90938. /**
  90939. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  90940. */
  90941. interface IImage extends IChildRootProperty {
  90942. /**
  90943. * 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
  90944. */
  90945. uri?: string;
  90946. /**
  90947. * The image's MIME type
  90948. */
  90949. mimeType?: ImageMimeType;
  90950. /**
  90951. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  90952. */
  90953. bufferView?: number;
  90954. }
  90955. /**
  90956. * Material Normal Texture Info
  90957. */
  90958. interface IMaterialNormalTextureInfo extends ITextureInfo {
  90959. /**
  90960. * The scalar multiplier applied to each normal vector of the normal texture
  90961. */
  90962. scale?: number;
  90963. }
  90964. /**
  90965. * Material Occlusion Texture Info
  90966. */
  90967. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  90968. /**
  90969. * A scalar multiplier controlling the amount of occlusion applied
  90970. */
  90971. strength?: number;
  90972. }
  90973. /**
  90974. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  90975. */
  90976. interface IMaterialPbrMetallicRoughness {
  90977. /**
  90978. * The material's base color factor
  90979. */
  90980. baseColorFactor?: number[];
  90981. /**
  90982. * The base color texture
  90983. */
  90984. baseColorTexture?: ITextureInfo;
  90985. /**
  90986. * The metalness of the material
  90987. */
  90988. metallicFactor?: number;
  90989. /**
  90990. * The roughness of the material
  90991. */
  90992. roughnessFactor?: number;
  90993. /**
  90994. * The metallic-roughness texture
  90995. */
  90996. metallicRoughnessTexture?: ITextureInfo;
  90997. }
  90998. /**
  90999. * The material appearance of a primitive
  91000. */
  91001. interface IMaterial extends IChildRootProperty {
  91002. /**
  91003. * 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
  91004. */
  91005. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  91006. /**
  91007. * The normal map texture
  91008. */
  91009. normalTexture?: IMaterialNormalTextureInfo;
  91010. /**
  91011. * The occlusion map texture
  91012. */
  91013. occlusionTexture?: IMaterialOcclusionTextureInfo;
  91014. /**
  91015. * The emissive map texture
  91016. */
  91017. emissiveTexture?: ITextureInfo;
  91018. /**
  91019. * 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
  91020. */
  91021. emissiveFactor?: number[];
  91022. /**
  91023. * The alpha rendering mode of the material
  91024. */
  91025. alphaMode?: MaterialAlphaMode;
  91026. /**
  91027. * The alpha cutoff value of the material
  91028. */
  91029. alphaCutoff?: number;
  91030. /**
  91031. * Specifies whether the material is double sided
  91032. */
  91033. doubleSided?: boolean;
  91034. }
  91035. /**
  91036. * Geometry to be rendered with the given material
  91037. */
  91038. interface IMeshPrimitive extends IProperty {
  91039. /**
  91040. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  91041. */
  91042. attributes: {
  91043. [name: string]: number;
  91044. };
  91045. /**
  91046. * The index of the accessor that contains the indices
  91047. */
  91048. indices?: number;
  91049. /**
  91050. * The index of the material to apply to this primitive when rendering
  91051. */
  91052. material?: number;
  91053. /**
  91054. * The type of primitives to render. All valid values correspond to WebGL enums
  91055. */
  91056. mode?: MeshPrimitiveMode;
  91057. /**
  91058. * 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
  91059. */
  91060. targets?: {
  91061. [name: string]: number;
  91062. }[];
  91063. }
  91064. /**
  91065. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  91066. */
  91067. interface IMesh extends IChildRootProperty {
  91068. /**
  91069. * An array of primitives, each defining geometry to be rendered with a material
  91070. */
  91071. primitives: IMeshPrimitive[];
  91072. /**
  91073. * Array of weights to be applied to the Morph Targets
  91074. */
  91075. weights?: number[];
  91076. }
  91077. /**
  91078. * A node in the node hierarchy
  91079. */
  91080. interface INode extends IChildRootProperty {
  91081. /**
  91082. * The index of the camera referenced by this node
  91083. */
  91084. camera?: number;
  91085. /**
  91086. * The indices of this node's children
  91087. */
  91088. children?: number[];
  91089. /**
  91090. * The index of the skin referenced by this node
  91091. */
  91092. skin?: number;
  91093. /**
  91094. * A floating-point 4x4 transformation matrix stored in column-major order
  91095. */
  91096. matrix?: number[];
  91097. /**
  91098. * The index of the mesh in this node
  91099. */
  91100. mesh?: number;
  91101. /**
  91102. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  91103. */
  91104. rotation?: number[];
  91105. /**
  91106. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  91107. */
  91108. scale?: number[];
  91109. /**
  91110. * The node's translation along the x, y, and z axes
  91111. */
  91112. translation?: number[];
  91113. /**
  91114. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  91115. */
  91116. weights?: number[];
  91117. }
  91118. /**
  91119. * Texture sampler properties for filtering and wrapping modes
  91120. */
  91121. interface ISampler extends IChildRootProperty {
  91122. /**
  91123. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  91124. */
  91125. magFilter?: TextureMagFilter;
  91126. /**
  91127. * Minification filter. All valid values correspond to WebGL enums
  91128. */
  91129. minFilter?: TextureMinFilter;
  91130. /**
  91131. * S (U) wrapping mode. All valid values correspond to WebGL enums
  91132. */
  91133. wrapS?: TextureWrapMode;
  91134. /**
  91135. * T (V) wrapping mode. All valid values correspond to WebGL enums
  91136. */
  91137. wrapT?: TextureWrapMode;
  91138. }
  91139. /**
  91140. * The root nodes of a scene
  91141. */
  91142. interface IScene extends IChildRootProperty {
  91143. /**
  91144. * The indices of each root node
  91145. */
  91146. nodes: number[];
  91147. }
  91148. /**
  91149. * Joints and matrices defining a skin
  91150. */
  91151. interface ISkin extends IChildRootProperty {
  91152. /**
  91153. * 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
  91154. */
  91155. inverseBindMatrices?: number;
  91156. /**
  91157. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  91158. */
  91159. skeleton?: number;
  91160. /**
  91161. * 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)
  91162. */
  91163. joints: number[];
  91164. }
  91165. /**
  91166. * A texture and its sampler
  91167. */
  91168. interface ITexture extends IChildRootProperty {
  91169. /**
  91170. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  91171. */
  91172. sampler?: number;
  91173. /**
  91174. * The index of the image used by this texture
  91175. */
  91176. source: number;
  91177. }
  91178. /**
  91179. * Reference to a texture
  91180. */
  91181. interface ITextureInfo extends IProperty {
  91182. /**
  91183. * The index of the texture
  91184. */
  91185. index: number;
  91186. /**
  91187. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  91188. */
  91189. texCoord?: number;
  91190. }
  91191. /**
  91192. * The root object for a glTF asset
  91193. */
  91194. interface IGLTF extends IProperty {
  91195. /**
  91196. * An array of accessors. An accessor is a typed view into a bufferView
  91197. */
  91198. accessors?: IAccessor[];
  91199. /**
  91200. * An array of keyframe animations
  91201. */
  91202. animations?: IAnimation[];
  91203. /**
  91204. * Metadata about the glTF asset
  91205. */
  91206. asset: IAsset;
  91207. /**
  91208. * An array of buffers. A buffer points to binary geometry, animation, or skins
  91209. */
  91210. buffers?: IBuffer[];
  91211. /**
  91212. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  91213. */
  91214. bufferViews?: IBufferView[];
  91215. /**
  91216. * An array of cameras
  91217. */
  91218. cameras?: ICamera[];
  91219. /**
  91220. * Names of glTF extensions used somewhere in this asset
  91221. */
  91222. extensionsUsed?: string[];
  91223. /**
  91224. * Names of glTF extensions required to properly load this asset
  91225. */
  91226. extensionsRequired?: string[];
  91227. /**
  91228. * An array of images. An image defines data used to create a texture
  91229. */
  91230. images?: IImage[];
  91231. /**
  91232. * An array of materials. A material defines the appearance of a primitive
  91233. */
  91234. materials?: IMaterial[];
  91235. /**
  91236. * An array of meshes. A mesh is a set of primitives to be rendered
  91237. */
  91238. meshes?: IMesh[];
  91239. /**
  91240. * An array of nodes
  91241. */
  91242. nodes?: INode[];
  91243. /**
  91244. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  91245. */
  91246. samplers?: ISampler[];
  91247. /**
  91248. * The index of the default scene
  91249. */
  91250. scene?: number;
  91251. /**
  91252. * An array of scenes
  91253. */
  91254. scenes?: IScene[];
  91255. /**
  91256. * An array of skins. A skin is defined by joints and matrices
  91257. */
  91258. skins?: ISkin[];
  91259. /**
  91260. * An array of textures
  91261. */
  91262. textures?: ITexture[];
  91263. }
  91264. /**
  91265. * The glTF validation results
  91266. * @ignore
  91267. */
  91268. interface IGLTFValidationResults {
  91269. info: {
  91270. generator: string;
  91271. hasAnimations: boolean;
  91272. hasDefaultScene: boolean;
  91273. hasMaterials: boolean;
  91274. hasMorphTargets: boolean;
  91275. hasSkins: boolean;
  91276. hasTextures: boolean;
  91277. maxAttributesUsed: number;
  91278. primitivesCount: number
  91279. };
  91280. issues: {
  91281. messages: Array<string>;
  91282. numErrors: number;
  91283. numHints: number;
  91284. numInfos: number;
  91285. numWarnings: number;
  91286. truncated: boolean
  91287. };
  91288. mimeType: string;
  91289. uri: string;
  91290. validatedAt: string;
  91291. validatorVersion: string;
  91292. }
  91293. /**
  91294. * The glTF validation options
  91295. */
  91296. interface IGLTFValidationOptions {
  91297. /** Uri to use */
  91298. uri?: string;
  91299. /** Function used to load external resources */
  91300. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  91301. /** Boolean indicating that we need to validate accessor data */
  91302. validateAccessorData?: boolean;
  91303. /** max number of issues allowed */
  91304. maxIssues?: number;
  91305. /** Ignored issues */
  91306. ignoredIssues?: Array<string>;
  91307. /** Value to override severy settings */
  91308. severityOverrides?: Object;
  91309. }
  91310. /**
  91311. * The glTF validator object
  91312. * @ignore
  91313. */
  91314. interface IGLTFValidator {
  91315. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  91316. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  91317. }
  91318. /**
  91319. * Interfaces from the EXT_lights_image_based extension
  91320. */
  91321. /** @hidden */
  91322. interface IEXTLightsImageBased_LightReferenceImageBased {
  91323. light: number;
  91324. }
  91325. /** @hidden */
  91326. interface IEXTLightsImageBased_LightImageBased extends IChildRootProperty {
  91327. intensity: number;
  91328. rotation: number[];
  91329. specularImageSize: number;
  91330. specularImages: number[][];
  91331. irradianceCoefficients: number[][];
  91332. }
  91333. /** @hidden */
  91334. interface IEXTLightsImageBased {
  91335. lights: IEXTLightsImageBased_LightImageBased[];
  91336. }
  91337. /**
  91338. * Interfaces from the EXT_mesh_gpu_instancing extension
  91339. * !!! Experimental Extension Subject to Changes !!!
  91340. */
  91341. /** @hidden */
  91342. interface IEXTMeshGpuInstancing {
  91343. mesh?: number;
  91344. attributes: { [name: string]: number };
  91345. }
  91346. /**
  91347. * Interfaces from the KHR_draco_mesh_compression extension
  91348. */
  91349. /** @hidden */
  91350. interface IKHRDracoMeshCompression {
  91351. bufferView: number;
  91352. attributes: { [name: string]: number };
  91353. }
  91354. /**
  91355. * Interfaces from the KHR_lights_punctual extension
  91356. */
  91357. /** @hidden */
  91358. const enum IKHRLightsPunctual_LightType {
  91359. DIRECTIONAL = "directional",
  91360. POINT = "point",
  91361. SPOT = "spot"
  91362. }
  91363. /** @hidden */
  91364. interface IKHRLightsPunctual_LightReference {
  91365. light: number;
  91366. }
  91367. /** @hidden */
  91368. interface IKHRLightsPunctual_Light extends IChildRootProperty {
  91369. type: IKHRLightsPunctual_LightType;
  91370. color?: number[];
  91371. intensity?: number;
  91372. range?: number;
  91373. spot?: {
  91374. innerConeAngle?: number;
  91375. outerConeAngle?: number;
  91376. };
  91377. }
  91378. /** @hidden */
  91379. interface IKHRLightsPunctual {
  91380. lights: IKHRLightsPunctual_Light[];
  91381. }
  91382. /**
  91383. * Interfaces from the KHR_materials_clearcoat extension
  91384. * !!! Experimental Extension Subject to Changes !!!
  91385. */
  91386. /** @hidden */
  91387. interface IKHRMaterialsClearcoat {
  91388. clearcoatFactor: number;
  91389. clearcoatTexture: ITextureInfo;
  91390. clearcoatRoughnessFactor: number;
  91391. clearcoatRoughnessTexture: ITextureInfo;
  91392. clearcoatNormalTexture: IMaterialNormalTextureInfo;
  91393. }
  91394. /**
  91395. * Interfaces from the KHR_materials_ior extension
  91396. * !!! Experimental Extension Subject to Changes !!!
  91397. */
  91398. /** @hidden */
  91399. interface IKHRMaterialsIor {
  91400. ior: number;
  91401. }
  91402. /**
  91403. * Interfaces from the KHR_materials_pbrSpecularGlossiness extension
  91404. */
  91405. /** @hidden */
  91406. interface IKHRMaterialsPbrSpecularGlossiness {
  91407. diffuseFactor: number[];
  91408. diffuseTexture: ITextureInfo;
  91409. specularFactor: number[];
  91410. glossinessFactor: number;
  91411. specularGlossinessTexture: ITextureInfo;
  91412. }
  91413. /**
  91414. * Interfaces from the KHR_materials_sheen extension
  91415. * !!! Experimental Extension Subject to Changes !!!
  91416. */
  91417. /** @hidden */
  91418. interface IKHRMaterialsSheen {
  91419. sheenColorFactor?: number[];
  91420. sheenColorTexture?: ITextureInfo;
  91421. sheenRoughnessFactor?: number;
  91422. sheenRoughnessTexture?: ITextureInfo;
  91423. }
  91424. /**
  91425. * Interfaces from the KHR_materials_specular extension
  91426. * !!! Experimental Extension Subject to Changes !!!
  91427. */
  91428. /** @hidden */
  91429. interface IKHRMaterialsSpecular {
  91430. specularFactor: number;
  91431. specularColorFactor: number[];
  91432. specularTexture: ITextureInfo;
  91433. }
  91434. /**
  91435. * Interfaces from the KHR_materials_transmission extension
  91436. * !!! Experimental Extension Subject to Changes !!!
  91437. */
  91438. /** @hidden */
  91439. interface IKHRMaterialsTransmission {
  91440. transmissionFactor?: number;
  91441. transmissionTexture?: ITextureInfo;
  91442. }
  91443. /**
  91444. * Interfaces from the KHR_materials_translucency extension
  91445. * !!! Experimental Extension Subject to Changes !!!
  91446. */
  91447. /** @hidden */
  91448. interface IKHRMaterialsTranslucency {
  91449. translucencyFactor?: number;
  91450. translucencyTexture?: ITextureInfo;
  91451. }
  91452. /**
  91453. * Interfaces from the KHR_materials_variants extension
  91454. * !!! Experimental Extension Subject to Changes !!!
  91455. */
  91456. /** @hidden */
  91457. interface IKHRMaterialVariants_Mapping extends IProperty {
  91458. mappings: Array<{
  91459. variants: number[];
  91460. material: number;
  91461. }>;
  91462. }
  91463. /** @hidden */
  91464. interface IKHRMaterialVariants_Variant extends IProperty {
  91465. name: string;
  91466. }
  91467. /** @hidden */
  91468. interface IKHRMaterialVariants_Variants extends IChildRootProperty {
  91469. variants: Array<IKHRMaterialVariants_Variant>;
  91470. }
  91471. /**
  91472. * Interfaces from the KHR_texture_basisu extension
  91473. * !!! Experimental Extension Subject to Changes !!!
  91474. */
  91475. /** @hidden */
  91476. interface IKHRTextureBasisU {
  91477. source: number;
  91478. }
  91479. /**
  91480. * Interfaces from the EXT_texture_webp extension
  91481. */
  91482. /** @hidden */
  91483. interface IEXTTextureWebP {
  91484. source: number;
  91485. }
  91486. /**
  91487. * Interfaces from the KHR_texture_transform extension
  91488. */
  91489. /** @hidden */
  91490. interface IKHRTextureTransform {
  91491. offset?: number[];
  91492. rotation?: number;
  91493. scale?: number[];
  91494. texCoord?: number;
  91495. }
  91496. /**
  91497. * Interfaces from the KHR_xmp_json_ld extension
  91498. * !!! Experimental Extension Subject to Changes !!!
  91499. */
  91500. /** @hidden */
  91501. interface IKHRXmpJsonLd_Gltf {
  91502. packets: Array<{
  91503. [key: string]: unknown;
  91504. }>;
  91505. }
  91506. /** @hidden */
  91507. interface IKHRXmpJsonLd_Node {
  91508. packet: number;
  91509. }
  91510. /**
  91511. * Interfaces from the MSFT_audio_emitter extension
  91512. */
  91513. /** @hidden */
  91514. interface IMSFTAudioEmitter_ClipReference {
  91515. clip: number;
  91516. weight?: number;
  91517. }
  91518. /** @hidden */
  91519. interface IMSFTAudioEmitter_EmittersReference {
  91520. emitters: number[];
  91521. }
  91522. /** @hidden */
  91523. const enum IMSFTAudioEmitter_DistanceModel {
  91524. linear = "linear",
  91525. inverse = "inverse",
  91526. exponential = "exponential",
  91527. }
  91528. /** @hidden */
  91529. interface IMSFTAudioEmitter_Emitter {
  91530. name?: string;
  91531. distanceModel?: IMSFTAudioEmitter_DistanceModel;
  91532. refDistance?: number;
  91533. maxDistance?: number;
  91534. rolloffFactor?: number;
  91535. innerAngle?: number;
  91536. outerAngle?: number;
  91537. loop?: boolean;
  91538. volume?: number;
  91539. clips: IMSFTAudioEmitter_ClipReference[];
  91540. }
  91541. /** @hidden */
  91542. const enum IMSFTAudioEmitter_AudioMimeType {
  91543. WAV = "audio/wav",
  91544. }
  91545. /** @hidden */
  91546. interface IMSFTAudioEmitter_Clip extends IProperty {
  91547. uri?: string;
  91548. bufferView?: number;
  91549. mimeType?: IMSFTAudioEmitter_AudioMimeType;
  91550. }
  91551. /** @hidden */
  91552. const enum IMSFTAudioEmitter_AnimationEventAction {
  91553. play = "play",
  91554. pause = "pause",
  91555. stop = "stop",
  91556. }
  91557. /** @hidden */
  91558. interface IMSFTAudioEmitter_AnimationEvent {
  91559. action: IMSFTAudioEmitter_AnimationEventAction;
  91560. emitter: number;
  91561. time: number;
  91562. startOffset?: number;
  91563. }
  91564. /**
  91565. * Interfaces from the MSFT_lod extension
  91566. */
  91567. /** @hidden */
  91568. interface IMSFTLOD {
  91569. ids: number[];
  91570. }
  91571. /**
  91572. * Interfaces from the EXT_meshopt_compression extension
  91573. */
  91574. /** @hidden */
  91575. interface IEXTMeshoptCompression {
  91576. buffer: number;
  91577. byteOffset?: number;
  91578. byteLength: number;
  91579. byteStride: number;
  91580. count: number;
  91581. mode: "ATTRIBUTES" | "TRIANGLES" | "INDICES";
  91582. filter?: "NONE" | "OCTAHEDRAL" | "QUATERNION" | "EXPONENTIAL";
  91583. }
  91584. }
  91585. declare module BABYLON {
  91586. /** @hidden */
  91587. export var cellPixelShader: {
  91588. name: string;
  91589. shader: string;
  91590. };
  91591. }
  91592. declare module BABYLON {
  91593. /** @hidden */
  91594. export var cellVertexShader: {
  91595. name: string;
  91596. shader: string;
  91597. };
  91598. }
  91599. declare module BABYLON {
  91600. export class CellMaterial extends BABYLON.PushMaterial {
  91601. private _diffuseTexture;
  91602. diffuseTexture: BABYLON.BaseTexture;
  91603. diffuseColor: BABYLON.Color3;
  91604. _computeHighLevel: boolean;
  91605. computeHighLevel: boolean;
  91606. private _disableLighting;
  91607. disableLighting: boolean;
  91608. private _maxSimultaneousLights;
  91609. maxSimultaneousLights: number;
  91610. constructor(name: string, scene: BABYLON.Scene);
  91611. needAlphaBlending(): boolean;
  91612. needAlphaTesting(): boolean;
  91613. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  91614. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  91615. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  91616. getAnimatables(): BABYLON.IAnimatable[];
  91617. getActiveTextures(): BABYLON.BaseTexture[];
  91618. hasTexture(texture: BABYLON.BaseTexture): boolean;
  91619. dispose(forceDisposeEffect?: boolean): void;
  91620. getClassName(): string;
  91621. clone(name: string): CellMaterial;
  91622. serialize(): any;
  91623. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  91624. }
  91625. }
  91626. declare module BABYLON {
  91627. export class CustomShaderStructure {
  91628. FragmentStore: string;
  91629. VertexStore: string;
  91630. constructor();
  91631. }
  91632. export class ShaderSpecialParts {
  91633. constructor();
  91634. Fragment_Begin: string;
  91635. Fragment_Definitions: string;
  91636. Fragment_MainBegin: string;
  91637. Fragment_Custom_Diffuse: string;
  91638. Fragment_Before_Lights: string;
  91639. Fragment_Before_Fog: string;
  91640. Fragment_Custom_Alpha: string;
  91641. Fragment_Before_FragColor: string;
  91642. Vertex_Begin: string;
  91643. Vertex_Definitions: string;
  91644. Vertex_MainBegin: string;
  91645. Vertex_Before_PositionUpdated: string;
  91646. Vertex_Before_NormalUpdated: string;
  91647. Vertex_After_WorldPosComputed: string;
  91648. Vertex_MainEnd: string;
  91649. }
  91650. export class CustomMaterial extends BABYLON.StandardMaterial {
  91651. static ShaderIndexer: number;
  91652. CustomParts: ShaderSpecialParts;
  91653. _isCreatedShader: boolean;
  91654. _createdShaderName: string;
  91655. _customUniform: string[];
  91656. _newUniforms: string[];
  91657. _newUniformInstances: {
  91658. [name: string]: any;
  91659. };
  91660. _newSamplerInstances: {
  91661. [name: string]: BABYLON.Texture;
  91662. };
  91663. _customAttributes: string[];
  91664. FragmentShader: string;
  91665. VertexShader: string;
  91666. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  91667. ReviewUniform(name: string, arr: string[]): string[];
  91668. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[]): string;
  91669. constructor(name: string, scene: BABYLON.Scene);
  91670. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  91671. AddAttribute(name: string): CustomMaterial;
  91672. Fragment_Begin(shaderPart: string): CustomMaterial;
  91673. Fragment_Definitions(shaderPart: string): CustomMaterial;
  91674. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  91675. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  91676. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  91677. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  91678. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  91679. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  91680. Vertex_Begin(shaderPart: string): CustomMaterial;
  91681. Vertex_Definitions(shaderPart: string): CustomMaterial;
  91682. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  91683. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  91684. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  91685. Vertex_After_WorldPosComputed(shaderPart: string): CustomMaterial;
  91686. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  91687. }
  91688. }
  91689. declare module BABYLON {
  91690. export class ShaderAlebdoParts {
  91691. constructor();
  91692. Fragment_Begin: string;
  91693. Fragment_Definitions: string;
  91694. Fragment_MainBegin: string;
  91695. Fragment_Custom_Albedo: string;
  91696. Fragment_Before_Lights: string;
  91697. Fragment_Custom_MetallicRoughness: string;
  91698. Fragment_Custom_MicroSurface: string;
  91699. Fragment_Before_Fog: string;
  91700. Fragment_Custom_Alpha: string;
  91701. Fragment_Before_FragColor: string;
  91702. Vertex_Begin: string;
  91703. Vertex_Definitions: string;
  91704. Vertex_MainBegin: string;
  91705. Vertex_Before_PositionUpdated: string;
  91706. Vertex_Before_NormalUpdated: string;
  91707. Vertex_After_WorldPosComputed: string;
  91708. Vertex_MainEnd: string;
  91709. }
  91710. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  91711. static ShaderIndexer: number;
  91712. CustomParts: ShaderAlebdoParts;
  91713. _isCreatedShader: boolean;
  91714. _createdShaderName: string;
  91715. _customUniform: string[];
  91716. _newUniforms: string[];
  91717. _newUniformInstances: {
  91718. [name: string]: any;
  91719. };
  91720. _newSamplerInstances: {
  91721. [name: string]: BABYLON.Texture;
  91722. };
  91723. _customAttributes: string[];
  91724. FragmentShader: string;
  91725. VertexShader: string;
  91726. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  91727. ReviewUniform(name: string, arr: string[]): string[];
  91728. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[]): string;
  91729. constructor(name: string, scene: BABYLON.Scene);
  91730. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  91731. AddAttribute(name: string): PBRCustomMaterial;
  91732. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  91733. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  91734. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  91735. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  91736. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  91737. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  91738. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  91739. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  91740. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  91741. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  91742. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  91743. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  91744. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  91745. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  91746. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  91747. Vertex_After_WorldPosComputed(shaderPart: string): PBRCustomMaterial;
  91748. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  91749. }
  91750. }
  91751. declare module BABYLON {
  91752. /** @hidden */
  91753. export var firePixelShader: {
  91754. name: string;
  91755. shader: string;
  91756. };
  91757. }
  91758. declare module BABYLON {
  91759. /** @hidden */
  91760. export var fireVertexShader: {
  91761. name: string;
  91762. shader: string;
  91763. };
  91764. }
  91765. declare module BABYLON {
  91766. export class FireMaterial extends BABYLON.PushMaterial {
  91767. private _diffuseTexture;
  91768. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  91769. private _distortionTexture;
  91770. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  91771. private _opacityTexture;
  91772. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  91773. diffuseColor: BABYLON.Color3;
  91774. speed: number;
  91775. private _scaledDiffuse;
  91776. private _lastTime;
  91777. constructor(name: string, scene: BABYLON.Scene);
  91778. needAlphaBlending(): boolean;
  91779. needAlphaTesting(): boolean;
  91780. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  91781. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  91782. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  91783. getAnimatables(): BABYLON.IAnimatable[];
  91784. getActiveTextures(): BABYLON.BaseTexture[];
  91785. hasTexture(texture: BABYLON.BaseTexture): boolean;
  91786. getClassName(): string;
  91787. dispose(forceDisposeEffect?: boolean): void;
  91788. clone(name: string): FireMaterial;
  91789. serialize(): any;
  91790. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  91791. }
  91792. }
  91793. declare module BABYLON {
  91794. /** @hidden */
  91795. export var furPixelShader: {
  91796. name: string;
  91797. shader: string;
  91798. };
  91799. }
  91800. declare module BABYLON {
  91801. /** @hidden */
  91802. export var furVertexShader: {
  91803. name: string;
  91804. shader: string;
  91805. };
  91806. }
  91807. declare module BABYLON {
  91808. export class FurMaterial extends BABYLON.PushMaterial {
  91809. private _diffuseTexture;
  91810. diffuseTexture: BABYLON.BaseTexture;
  91811. private _heightTexture;
  91812. heightTexture: BABYLON.BaseTexture;
  91813. diffuseColor: BABYLON.Color3;
  91814. furLength: number;
  91815. furAngle: number;
  91816. furColor: BABYLON.Color3;
  91817. furOffset: number;
  91818. furSpacing: number;
  91819. furGravity: BABYLON.Vector3;
  91820. furSpeed: number;
  91821. furDensity: number;
  91822. furOcclusion: number;
  91823. furTexture: BABYLON.DynamicTexture;
  91824. private _disableLighting;
  91825. disableLighting: boolean;
  91826. private _maxSimultaneousLights;
  91827. maxSimultaneousLights: number;
  91828. highLevelFur: boolean;
  91829. _meshes: BABYLON.AbstractMesh[];
  91830. private _furTime;
  91831. constructor(name: string, scene: BABYLON.Scene);
  91832. get furTime(): number;
  91833. set furTime(furTime: number);
  91834. needAlphaBlending(): boolean;
  91835. needAlphaTesting(): boolean;
  91836. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  91837. updateFur(): void;
  91838. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  91839. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  91840. getAnimatables(): BABYLON.IAnimatable[];
  91841. getActiveTextures(): BABYLON.BaseTexture[];
  91842. hasTexture(texture: BABYLON.BaseTexture): boolean;
  91843. dispose(forceDisposeEffect?: boolean): void;
  91844. clone(name: string): FurMaterial;
  91845. serialize(): any;
  91846. getClassName(): string;
  91847. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  91848. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  91849. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  91850. }
  91851. }
  91852. declare module BABYLON {
  91853. /** @hidden */
  91854. export var gradientPixelShader: {
  91855. name: string;
  91856. shader: string;
  91857. };
  91858. }
  91859. declare module BABYLON {
  91860. /** @hidden */
  91861. export var gradientVertexShader: {
  91862. name: string;
  91863. shader: string;
  91864. };
  91865. }
  91866. declare module BABYLON {
  91867. export class GradientMaterial extends BABYLON.PushMaterial {
  91868. private _maxSimultaneousLights;
  91869. maxSimultaneousLights: number;
  91870. topColor: BABYLON.Color3;
  91871. topColorAlpha: number;
  91872. bottomColor: BABYLON.Color3;
  91873. bottomColorAlpha: number;
  91874. offset: number;
  91875. scale: number;
  91876. smoothness: number;
  91877. private _disableLighting;
  91878. disableLighting: boolean;
  91879. constructor(name: string, scene: BABYLON.Scene);
  91880. needAlphaBlending(): boolean;
  91881. needAlphaTesting(): boolean;
  91882. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  91883. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  91884. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  91885. getAnimatables(): BABYLON.IAnimatable[];
  91886. dispose(forceDisposeEffect?: boolean): void;
  91887. clone(name: string): GradientMaterial;
  91888. serialize(): any;
  91889. getClassName(): string;
  91890. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  91891. }
  91892. }
  91893. declare module BABYLON {
  91894. /** @hidden */
  91895. export var gridPixelShader: {
  91896. name: string;
  91897. shader: string;
  91898. };
  91899. }
  91900. declare module BABYLON {
  91901. /** @hidden */
  91902. export var gridVertexShader: {
  91903. name: string;
  91904. shader: string;
  91905. };
  91906. }
  91907. declare module BABYLON {
  91908. /**
  91909. * The grid materials allows you to wrap any shape with a grid.
  91910. * Colors are customizable.
  91911. */
  91912. export class GridMaterial extends BABYLON.PushMaterial {
  91913. /**
  91914. * Main color of the grid (e.g. between lines)
  91915. */
  91916. mainColor: BABYLON.Color3;
  91917. /**
  91918. * Color of the grid lines.
  91919. */
  91920. lineColor: BABYLON.Color3;
  91921. /**
  91922. * The scale of the grid compared to unit.
  91923. */
  91924. gridRatio: number;
  91925. /**
  91926. * Allows setting an offset for the grid lines.
  91927. */
  91928. gridOffset: BABYLON.Vector3;
  91929. /**
  91930. * The frequency of thicker lines.
  91931. */
  91932. majorUnitFrequency: number;
  91933. /**
  91934. * The visibility of minor units in the grid.
  91935. */
  91936. minorUnitVisibility: number;
  91937. /**
  91938. * The grid opacity outside of the lines.
  91939. */
  91940. opacity: number;
  91941. /**
  91942. * Determine RBG output is premultiplied by alpha value.
  91943. */
  91944. preMultiplyAlpha: boolean;
  91945. private _opacityTexture;
  91946. opacityTexture: BABYLON.BaseTexture;
  91947. private _gridControl;
  91948. /**
  91949. * constructor
  91950. * @param name The name given to the material in order to identify it afterwards.
  91951. * @param scene The scene the material is used in.
  91952. */
  91953. constructor(name: string, scene: BABYLON.Scene);
  91954. /**
  91955. * Returns wehter or not the grid requires alpha blending.
  91956. */
  91957. needAlphaBlending(): boolean;
  91958. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  91959. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  91960. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  91961. /**
  91962. * Dispose the material and its associated resources.
  91963. * @param forceDisposeEffect will also dispose the used effect when true
  91964. */
  91965. dispose(forceDisposeEffect?: boolean): void;
  91966. clone(name: string): GridMaterial;
  91967. serialize(): any;
  91968. getClassName(): string;
  91969. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  91970. }
  91971. }
  91972. declare module BABYLON {
  91973. /** @hidden */
  91974. export var lavaPixelShader: {
  91975. name: string;
  91976. shader: string;
  91977. };
  91978. }
  91979. declare module BABYLON {
  91980. /** @hidden */
  91981. export var lavaVertexShader: {
  91982. name: string;
  91983. shader: string;
  91984. };
  91985. }
  91986. declare module BABYLON {
  91987. export class LavaMaterial extends BABYLON.PushMaterial {
  91988. private _diffuseTexture;
  91989. diffuseTexture: BABYLON.BaseTexture;
  91990. noiseTexture: BABYLON.BaseTexture;
  91991. fogColor: BABYLON.Color3;
  91992. speed: number;
  91993. movingSpeed: number;
  91994. lowFrequencySpeed: number;
  91995. fogDensity: number;
  91996. private _lastTime;
  91997. diffuseColor: BABYLON.Color3;
  91998. private _disableLighting;
  91999. disableLighting: boolean;
  92000. private _unlit;
  92001. unlit: boolean;
  92002. private _maxSimultaneousLights;
  92003. maxSimultaneousLights: number;
  92004. private _scaledDiffuse;
  92005. constructor(name: string, scene: BABYLON.Scene);
  92006. needAlphaBlending(): boolean;
  92007. needAlphaTesting(): boolean;
  92008. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  92009. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  92010. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  92011. getAnimatables(): BABYLON.IAnimatable[];
  92012. getActiveTextures(): BABYLON.BaseTexture[];
  92013. hasTexture(texture: BABYLON.BaseTexture): boolean;
  92014. dispose(forceDisposeEffect?: boolean): void;
  92015. clone(name: string): LavaMaterial;
  92016. serialize(): any;
  92017. getClassName(): string;
  92018. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  92019. }
  92020. }
  92021. declare module BABYLON {
  92022. /** @hidden */
  92023. export var mixPixelShader: {
  92024. name: string;
  92025. shader: string;
  92026. };
  92027. }
  92028. declare module BABYLON {
  92029. /** @hidden */
  92030. export var mixVertexShader: {
  92031. name: string;
  92032. shader: string;
  92033. };
  92034. }
  92035. declare module BABYLON {
  92036. export class MixMaterial extends BABYLON.PushMaterial {
  92037. /**
  92038. * Mix textures
  92039. */
  92040. private _mixTexture1;
  92041. mixTexture1: BABYLON.BaseTexture;
  92042. private _mixTexture2;
  92043. mixTexture2: BABYLON.BaseTexture;
  92044. /**
  92045. * Diffuse textures
  92046. */
  92047. private _diffuseTexture1;
  92048. diffuseTexture1: BABYLON.Texture;
  92049. private _diffuseTexture2;
  92050. diffuseTexture2: BABYLON.Texture;
  92051. private _diffuseTexture3;
  92052. diffuseTexture3: BABYLON.Texture;
  92053. private _diffuseTexture4;
  92054. diffuseTexture4: BABYLON.Texture;
  92055. private _diffuseTexture5;
  92056. diffuseTexture5: BABYLON.Texture;
  92057. private _diffuseTexture6;
  92058. diffuseTexture6: BABYLON.Texture;
  92059. private _diffuseTexture7;
  92060. diffuseTexture7: BABYLON.Texture;
  92061. private _diffuseTexture8;
  92062. diffuseTexture8: BABYLON.Texture;
  92063. /**
  92064. * Uniforms
  92065. */
  92066. diffuseColor: BABYLON.Color3;
  92067. specularColor: BABYLON.Color3;
  92068. specularPower: number;
  92069. private _disableLighting;
  92070. disableLighting: boolean;
  92071. private _maxSimultaneousLights;
  92072. maxSimultaneousLights: number;
  92073. constructor(name: string, scene: BABYLON.Scene);
  92074. needAlphaBlending(): boolean;
  92075. needAlphaTesting(): boolean;
  92076. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  92077. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  92078. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  92079. getAnimatables(): BABYLON.IAnimatable[];
  92080. getActiveTextures(): BABYLON.BaseTexture[];
  92081. hasTexture(texture: BABYLON.BaseTexture): boolean;
  92082. dispose(forceDisposeEffect?: boolean): void;
  92083. clone(name: string): MixMaterial;
  92084. serialize(): any;
  92085. getClassName(): string;
  92086. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  92087. }
  92088. }
  92089. declare module BABYLON {
  92090. /** @hidden */
  92091. export var normalPixelShader: {
  92092. name: string;
  92093. shader: string;
  92094. };
  92095. }
  92096. declare module BABYLON {
  92097. /** @hidden */
  92098. export var normalVertexShader: {
  92099. name: string;
  92100. shader: string;
  92101. };
  92102. }
  92103. declare module BABYLON {
  92104. export class NormalMaterial extends BABYLON.PushMaterial {
  92105. private _diffuseTexture;
  92106. diffuseTexture: BABYLON.BaseTexture;
  92107. diffuseColor: BABYLON.Color3;
  92108. private _disableLighting;
  92109. disableLighting: boolean;
  92110. private _maxSimultaneousLights;
  92111. maxSimultaneousLights: number;
  92112. constructor(name: string, scene: BABYLON.Scene);
  92113. needAlphaBlending(): boolean;
  92114. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  92115. needAlphaTesting(): boolean;
  92116. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  92117. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  92118. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  92119. getAnimatables(): BABYLON.IAnimatable[];
  92120. getActiveTextures(): BABYLON.BaseTexture[];
  92121. hasTexture(texture: BABYLON.BaseTexture): boolean;
  92122. dispose(forceDisposeEffect?: boolean): void;
  92123. clone(name: string): NormalMaterial;
  92124. serialize(): any;
  92125. getClassName(): string;
  92126. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  92127. }
  92128. }
  92129. declare module BABYLON {
  92130. /** @hidden */
  92131. export var shadowOnlyPixelShader: {
  92132. name: string;
  92133. shader: string;
  92134. };
  92135. }
  92136. declare module BABYLON {
  92137. /** @hidden */
  92138. export var shadowOnlyVertexShader: {
  92139. name: string;
  92140. shader: string;
  92141. };
  92142. }
  92143. declare module BABYLON {
  92144. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  92145. private _activeLight;
  92146. private _needAlphaBlending;
  92147. constructor(name: string, scene: BABYLON.Scene);
  92148. shadowColor: BABYLON.Color3;
  92149. needAlphaBlending(): boolean;
  92150. needAlphaTesting(): boolean;
  92151. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  92152. get activeLight(): BABYLON.IShadowLight;
  92153. set activeLight(light: BABYLON.IShadowLight);
  92154. private _getFirstShadowLightForMesh;
  92155. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  92156. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  92157. clone(name: string): ShadowOnlyMaterial;
  92158. serialize(): any;
  92159. getClassName(): string;
  92160. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  92161. }
  92162. }
  92163. declare module BABYLON {
  92164. /** @hidden */
  92165. export var simplePixelShader: {
  92166. name: string;
  92167. shader: string;
  92168. };
  92169. }
  92170. declare module BABYLON {
  92171. /** @hidden */
  92172. export var simpleVertexShader: {
  92173. name: string;
  92174. shader: string;
  92175. };
  92176. }
  92177. declare module BABYLON {
  92178. export class SimpleMaterial extends BABYLON.PushMaterial {
  92179. private _diffuseTexture;
  92180. diffuseTexture: BABYLON.BaseTexture;
  92181. diffuseColor: BABYLON.Color3;
  92182. private _disableLighting;
  92183. disableLighting: boolean;
  92184. private _maxSimultaneousLights;
  92185. maxSimultaneousLights: number;
  92186. constructor(name: string, scene: BABYLON.Scene);
  92187. needAlphaBlending(): boolean;
  92188. needAlphaTesting(): boolean;
  92189. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  92190. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  92191. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  92192. getAnimatables(): BABYLON.IAnimatable[];
  92193. getActiveTextures(): BABYLON.BaseTexture[];
  92194. hasTexture(texture: BABYLON.BaseTexture): boolean;
  92195. dispose(forceDisposeEffect?: boolean): void;
  92196. clone(name: string): SimpleMaterial;
  92197. serialize(): any;
  92198. getClassName(): string;
  92199. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  92200. }
  92201. }
  92202. declare module BABYLON {
  92203. /** @hidden */
  92204. export var skyPixelShader: {
  92205. name: string;
  92206. shader: string;
  92207. };
  92208. }
  92209. declare module BABYLON {
  92210. /** @hidden */
  92211. export var skyVertexShader: {
  92212. name: string;
  92213. shader: string;
  92214. };
  92215. }
  92216. declare module BABYLON {
  92217. /**
  92218. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  92219. * @see https://doc.babylonjs.com/extensions/sky
  92220. */
  92221. export class SkyMaterial extends BABYLON.PushMaterial {
  92222. /**
  92223. * Defines the overall luminance of sky in interval ]0, 1[.
  92224. */
  92225. luminance: number;
  92226. /**
  92227. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  92228. */
  92229. turbidity: number;
  92230. /**
  92231. * Defines the sky appearance (light intensity).
  92232. */
  92233. rayleigh: number;
  92234. /**
  92235. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  92236. */
  92237. mieCoefficient: number;
  92238. /**
  92239. * Defines the amount of haze particles following the Mie scattering theory.
  92240. */
  92241. mieDirectionalG: number;
  92242. /**
  92243. * Defines the distance of the sun according to the active scene camera.
  92244. */
  92245. distance: number;
  92246. /**
  92247. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  92248. * "inclined".
  92249. */
  92250. inclination: number;
  92251. /**
  92252. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  92253. * an object direction and a reference direction.
  92254. */
  92255. azimuth: number;
  92256. /**
  92257. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  92258. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  92259. */
  92260. sunPosition: BABYLON.Vector3;
  92261. /**
  92262. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  92263. * .sunPosition property.
  92264. */
  92265. useSunPosition: boolean;
  92266. /**
  92267. * Defines an offset vector used to get a horizon offset.
  92268. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  92269. */
  92270. cameraOffset: BABYLON.Vector3;
  92271. /**
  92272. * Defines the vector the skyMaterial should consider as up. (default is BABYLON.Vector3(0, 1, 0) as returned by BABYLON.Vector3.Up())
  92273. */
  92274. up: BABYLON.Vector3;
  92275. private _cameraPosition;
  92276. private _skyOrientation;
  92277. /**
  92278. * Instantiates a new sky material.
  92279. * This material allows to create dynamic and texture free
  92280. * effects for skyboxes by taking care of the atmosphere state.
  92281. * @see https://doc.babylonjs.com/extensions/sky
  92282. * @param name Define the name of the material in the scene
  92283. * @param scene Define the scene the material belong to
  92284. */
  92285. constructor(name: string, scene: BABYLON.Scene);
  92286. /**
  92287. * Specifies if the material will require alpha blending
  92288. * @returns a boolean specifying if alpha blending is needed
  92289. */
  92290. needAlphaBlending(): boolean;
  92291. /**
  92292. * Specifies if this material should be rendered in alpha test mode
  92293. * @returns false as the sky material doesn't need alpha testing.
  92294. */
  92295. needAlphaTesting(): boolean;
  92296. /**
  92297. * Get the texture used for alpha test purpose.
  92298. * @returns null as the sky material has no texture.
  92299. */
  92300. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  92301. /**
  92302. * Get if the submesh is ready to be used and all its information available.
  92303. * Child classes can use it to update shaders
  92304. * @param mesh defines the mesh to check
  92305. * @param subMesh defines which submesh to check
  92306. * @param useInstances specifies that instances should be used
  92307. * @returns a boolean indicating that the submesh is ready or not
  92308. */
  92309. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  92310. /**
  92311. * Binds the submesh to this material by preparing the effect and shader to draw
  92312. * @param world defines the world transformation matrix
  92313. * @param mesh defines the mesh containing the submesh
  92314. * @param subMesh defines the submesh to bind the material to
  92315. */
  92316. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  92317. /**
  92318. * Get the list of animatables in the material.
  92319. * @returns the list of animatables object used in the material
  92320. */
  92321. getAnimatables(): BABYLON.IAnimatable[];
  92322. /**
  92323. * Disposes the material
  92324. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  92325. */
  92326. dispose(forceDisposeEffect?: boolean): void;
  92327. /**
  92328. * Makes a duplicate of the material, and gives it a new name
  92329. * @param name defines the new name for the duplicated material
  92330. * @returns the cloned material
  92331. */
  92332. clone(name: string): SkyMaterial;
  92333. /**
  92334. * Serializes this material in a JSON representation
  92335. * @returns the serialized material object
  92336. */
  92337. serialize(): any;
  92338. /**
  92339. * Gets the current class name of the material e.g. "SkyMaterial"
  92340. * Mainly use in serialization.
  92341. * @returns the class name
  92342. */
  92343. getClassName(): string;
  92344. /**
  92345. * Creates a sky material from parsed material data
  92346. * @param source defines the JSON representation of the material
  92347. * @param scene defines the hosting scene
  92348. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  92349. * @returns a new sky material
  92350. */
  92351. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  92352. }
  92353. }
  92354. declare module BABYLON {
  92355. /** @hidden */
  92356. export var terrainPixelShader: {
  92357. name: string;
  92358. shader: string;
  92359. };
  92360. }
  92361. declare module BABYLON {
  92362. /** @hidden */
  92363. export var terrainVertexShader: {
  92364. name: string;
  92365. shader: string;
  92366. };
  92367. }
  92368. declare module BABYLON {
  92369. export class TerrainMaterial extends BABYLON.PushMaterial {
  92370. private _mixTexture;
  92371. mixTexture: BABYLON.BaseTexture;
  92372. private _diffuseTexture1;
  92373. diffuseTexture1: BABYLON.Texture;
  92374. private _diffuseTexture2;
  92375. diffuseTexture2: BABYLON.Texture;
  92376. private _diffuseTexture3;
  92377. diffuseTexture3: BABYLON.Texture;
  92378. private _bumpTexture1;
  92379. bumpTexture1: BABYLON.Texture;
  92380. private _bumpTexture2;
  92381. bumpTexture2: BABYLON.Texture;
  92382. private _bumpTexture3;
  92383. bumpTexture3: BABYLON.Texture;
  92384. diffuseColor: BABYLON.Color3;
  92385. specularColor: BABYLON.Color3;
  92386. specularPower: number;
  92387. private _disableLighting;
  92388. disableLighting: boolean;
  92389. private _maxSimultaneousLights;
  92390. maxSimultaneousLights: number;
  92391. constructor(name: string, scene: BABYLON.Scene);
  92392. needAlphaBlending(): boolean;
  92393. needAlphaTesting(): boolean;
  92394. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  92395. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  92396. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  92397. getAnimatables(): BABYLON.IAnimatable[];
  92398. getActiveTextures(): BABYLON.BaseTexture[];
  92399. hasTexture(texture: BABYLON.BaseTexture): boolean;
  92400. dispose(forceDisposeEffect?: boolean): void;
  92401. clone(name: string): TerrainMaterial;
  92402. serialize(): any;
  92403. getClassName(): string;
  92404. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  92405. }
  92406. }
  92407. declare module BABYLON {
  92408. /** @hidden */
  92409. export var triplanarPixelShader: {
  92410. name: string;
  92411. shader: string;
  92412. };
  92413. }
  92414. declare module BABYLON {
  92415. /** @hidden */
  92416. export var triplanarVertexShader: {
  92417. name: string;
  92418. shader: string;
  92419. };
  92420. }
  92421. declare module BABYLON {
  92422. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  92423. mixTexture: BABYLON.BaseTexture;
  92424. private _diffuseTextureX;
  92425. diffuseTextureX: BABYLON.BaseTexture;
  92426. private _diffuseTextureY;
  92427. diffuseTextureY: BABYLON.BaseTexture;
  92428. private _diffuseTextureZ;
  92429. diffuseTextureZ: BABYLON.BaseTexture;
  92430. private _normalTextureX;
  92431. normalTextureX: BABYLON.BaseTexture;
  92432. private _normalTextureY;
  92433. normalTextureY: BABYLON.BaseTexture;
  92434. private _normalTextureZ;
  92435. normalTextureZ: BABYLON.BaseTexture;
  92436. tileSize: number;
  92437. diffuseColor: BABYLON.Color3;
  92438. specularColor: BABYLON.Color3;
  92439. specularPower: number;
  92440. private _disableLighting;
  92441. disableLighting: boolean;
  92442. private _maxSimultaneousLights;
  92443. maxSimultaneousLights: number;
  92444. constructor(name: string, scene: BABYLON.Scene);
  92445. needAlphaBlending(): boolean;
  92446. needAlphaTesting(): boolean;
  92447. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  92448. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  92449. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  92450. getAnimatables(): BABYLON.IAnimatable[];
  92451. getActiveTextures(): BABYLON.BaseTexture[];
  92452. hasTexture(texture: BABYLON.BaseTexture): boolean;
  92453. dispose(forceDisposeEffect?: boolean): void;
  92454. clone(name: string): TriPlanarMaterial;
  92455. serialize(): any;
  92456. getClassName(): string;
  92457. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  92458. }
  92459. }
  92460. declare module BABYLON {
  92461. /** @hidden */
  92462. export var waterPixelShader: {
  92463. name: string;
  92464. shader: string;
  92465. };
  92466. }
  92467. declare module BABYLON {
  92468. /** @hidden */
  92469. export var waterVertexShader: {
  92470. name: string;
  92471. shader: string;
  92472. };
  92473. }
  92474. declare module BABYLON {
  92475. export class WaterMaterial extends BABYLON.PushMaterial {
  92476. renderTargetSize: BABYLON.Vector2;
  92477. private _bumpTexture;
  92478. bumpTexture: BABYLON.BaseTexture;
  92479. diffuseColor: BABYLON.Color3;
  92480. specularColor: BABYLON.Color3;
  92481. specularPower: number;
  92482. private _disableLighting;
  92483. disableLighting: boolean;
  92484. private _maxSimultaneousLights;
  92485. maxSimultaneousLights: number;
  92486. /**
  92487. * Defines the wind force.
  92488. */
  92489. windForce: number;
  92490. /**
  92491. * Defines the direction of the wind in the plane (X, Z).
  92492. */
  92493. windDirection: BABYLON.Vector2;
  92494. /**
  92495. * Defines the height of the waves.
  92496. */
  92497. waveHeight: number;
  92498. /**
  92499. * Defines the bump height related to the bump map.
  92500. */
  92501. bumpHeight: number;
  92502. /**
  92503. * Defines wether or not: to add a smaller moving bump to less steady waves.
  92504. */
  92505. private _bumpSuperimpose;
  92506. bumpSuperimpose: boolean;
  92507. /**
  92508. * Defines wether or not color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  92509. */
  92510. private _fresnelSeparate;
  92511. fresnelSeparate: boolean;
  92512. /**
  92513. * Defines wether or not bump Wwves modify the reflection.
  92514. */
  92515. private _bumpAffectsReflection;
  92516. bumpAffectsReflection: boolean;
  92517. /**
  92518. * Defines the water color blended with the refraction (near).
  92519. */
  92520. waterColor: BABYLON.Color3;
  92521. /**
  92522. * Defines the blend factor related to the water color.
  92523. */
  92524. colorBlendFactor: number;
  92525. /**
  92526. * Defines the water color blended with the reflection (far).
  92527. */
  92528. waterColor2: BABYLON.Color3;
  92529. /**
  92530. * Defines the blend factor related to the water color (reflection, far).
  92531. */
  92532. colorBlendFactor2: number;
  92533. /**
  92534. * Defines the maximum length of a wave.
  92535. */
  92536. waveLength: number;
  92537. /**
  92538. * Defines the waves speed.
  92539. */
  92540. waveSpeed: number;
  92541. /**
  92542. * 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.
  92543. */
  92544. waveCount: number;
  92545. /**
  92546. * Sets or gets whether or not automatic clipping should be enabled or not. Setting to true will save performances and
  92547. * will avoid calculating useless pixels in the pixel shader of the water material.
  92548. */
  92549. disableClipPlane: boolean;
  92550. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  92551. private _mesh;
  92552. private _refractionRTT;
  92553. private _reflectionRTT;
  92554. private _reflectionTransform;
  92555. private _lastTime;
  92556. private _lastDeltaTime;
  92557. private _useLogarithmicDepth;
  92558. private _waitingRenderList;
  92559. private _imageProcessingConfiguration;
  92560. private _imageProcessingObserver;
  92561. /**
  92562. * Gets a boolean indicating that current material needs to register RTT
  92563. */
  92564. get hasRenderTargetTextures(): boolean;
  92565. /**
  92566. * Constructor
  92567. */
  92568. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  92569. get useLogarithmicDepth(): boolean;
  92570. set useLogarithmicDepth(value: boolean);
  92571. get refractionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  92572. get reflectionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  92573. addToRenderList(node: any): void;
  92574. enableRenderTargets(enable: boolean): void;
  92575. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  92576. get renderTargetsEnabled(): boolean;
  92577. needAlphaBlending(): boolean;
  92578. needAlphaTesting(): boolean;
  92579. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  92580. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  92581. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  92582. private _createRenderTargets;
  92583. getAnimatables(): BABYLON.IAnimatable[];
  92584. getActiveTextures(): BABYLON.BaseTexture[];
  92585. hasTexture(texture: BABYLON.BaseTexture): boolean;
  92586. dispose(forceDisposeEffect?: boolean): void;
  92587. clone(name: string): WaterMaterial;
  92588. serialize(): any;
  92589. getClassName(): string;
  92590. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  92591. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  92592. }
  92593. }
  92594. declare module BABYLON {
  92595. /** @hidden */
  92596. export var asciiartPixelShader: {
  92597. name: string;
  92598. shader: string;
  92599. };
  92600. }
  92601. declare module BABYLON {
  92602. /**
  92603. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  92604. *
  92605. * It basically takes care rendering the font front the given font size to a texture.
  92606. * This is used later on in the postprocess.
  92607. */
  92608. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  92609. private _font;
  92610. private _text;
  92611. private _charSize;
  92612. /**
  92613. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  92614. */
  92615. get charSize(): number;
  92616. /**
  92617. * Create a new instance of the Ascii Art FontTexture class
  92618. * @param name the name of the texture
  92619. * @param font the font to use, use the W3C CSS notation
  92620. * @param text the caracter set to use in the rendering.
  92621. * @param scene the scene that owns the texture
  92622. */
  92623. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  92624. /**
  92625. * Gets the max char width of a font.
  92626. * @param font the font to use, use the W3C CSS notation
  92627. * @return the max char width
  92628. */
  92629. private getFontWidth;
  92630. /**
  92631. * Gets the max char height of a font.
  92632. * @param font the font to use, use the W3C CSS notation
  92633. * @return the max char height
  92634. */
  92635. private getFontHeight;
  92636. /**
  92637. * Clones the current AsciiArtTexture.
  92638. * @return the clone of the texture.
  92639. */
  92640. clone(): AsciiArtFontTexture;
  92641. /**
  92642. * Parses a json object representing the texture and returns an instance of it.
  92643. * @param source the source JSON representation
  92644. * @param scene the scene to create the texture for
  92645. * @return the parsed texture
  92646. */
  92647. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  92648. }
  92649. /**
  92650. * Option available in the Ascii Art Post Process.
  92651. */
  92652. export interface IAsciiArtPostProcessOptions {
  92653. /**
  92654. * The font to use following the w3c font definition.
  92655. */
  92656. font?: string;
  92657. /**
  92658. * The character set to use in the postprocess.
  92659. */
  92660. characterSet?: string;
  92661. /**
  92662. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  92663. * This number is defined between 0 and 1;
  92664. */
  92665. mixToTile?: number;
  92666. /**
  92667. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  92668. * This number is defined between 0 and 1;
  92669. */
  92670. mixToNormal?: number;
  92671. }
  92672. /**
  92673. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  92674. *
  92675. * Simmply add it to your scene and let the nerd that lives in you have fun.
  92676. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  92677. */
  92678. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  92679. /**
  92680. * The font texture used to render the char in the post process.
  92681. */
  92682. private _asciiArtFontTexture;
  92683. /**
  92684. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  92685. * This number is defined between 0 and 1;
  92686. */
  92687. mixToTile: number;
  92688. /**
  92689. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  92690. * This number is defined between 0 and 1;
  92691. */
  92692. mixToNormal: number;
  92693. /**
  92694. * Instantiates a new Ascii Art Post Process.
  92695. * @param name the name to give to the postprocess
  92696. * @camera the camera to apply the post process to.
  92697. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  92698. */
  92699. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  92700. }
  92701. }
  92702. declare module BABYLON {
  92703. /** @hidden */
  92704. export var digitalrainPixelShader: {
  92705. name: string;
  92706. shader: string;
  92707. };
  92708. }
  92709. declare module BABYLON {
  92710. /**
  92711. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  92712. *
  92713. * It basically takes care rendering the font front the given font size to a texture.
  92714. * This is used later on in the postprocess.
  92715. */
  92716. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  92717. private _font;
  92718. private _text;
  92719. private _charSize;
  92720. /**
  92721. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  92722. */
  92723. get charSize(): number;
  92724. /**
  92725. * Create a new instance of the Digital Rain FontTexture class
  92726. * @param name the name of the texture
  92727. * @param font the font to use, use the W3C CSS notation
  92728. * @param text the caracter set to use in the rendering.
  92729. * @param scene the scene that owns the texture
  92730. */
  92731. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  92732. /**
  92733. * Gets the max char width of a font.
  92734. * @param font the font to use, use the W3C CSS notation
  92735. * @return the max char width
  92736. */
  92737. private getFontWidth;
  92738. /**
  92739. * Gets the max char height of a font.
  92740. * @param font the font to use, use the W3C CSS notation
  92741. * @return the max char height
  92742. */
  92743. private getFontHeight;
  92744. /**
  92745. * Clones the current DigitalRainFontTexture.
  92746. * @return the clone of the texture.
  92747. */
  92748. clone(): DigitalRainFontTexture;
  92749. /**
  92750. * Parses a json object representing the texture and returns an instance of it.
  92751. * @param source the source JSON representation
  92752. * @param scene the scene to create the texture for
  92753. * @return the parsed texture
  92754. */
  92755. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  92756. }
  92757. /**
  92758. * Option available in the Digital Rain Post Process.
  92759. */
  92760. export interface IDigitalRainPostProcessOptions {
  92761. /**
  92762. * The font to use following the w3c font definition.
  92763. */
  92764. font?: string;
  92765. /**
  92766. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  92767. * This number is defined between 0 and 1;
  92768. */
  92769. mixToTile?: number;
  92770. /**
  92771. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  92772. * This number is defined between 0 and 1;
  92773. */
  92774. mixToNormal?: number;
  92775. }
  92776. /**
  92777. * DigitalRainPostProcess helps rendering everithing in digital rain.
  92778. *
  92779. * Simmply add it to your scene and let the nerd that lives in you have fun.
  92780. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  92781. */
  92782. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  92783. /**
  92784. * The font texture used to render the char in the post process.
  92785. */
  92786. private _digitalRainFontTexture;
  92787. /**
  92788. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  92789. * This number is defined between 0 and 1;
  92790. */
  92791. mixToTile: number;
  92792. /**
  92793. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  92794. * This number is defined between 0 and 1;
  92795. */
  92796. mixToNormal: number;
  92797. /**
  92798. * Instantiates a new Digital Rain Post Process.
  92799. * @param name the name to give to the postprocess
  92800. * @camera the camera to apply the post process to.
  92801. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  92802. */
  92803. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  92804. }
  92805. }
  92806. declare module BABYLON {
  92807. /** @hidden */
  92808. export var brickProceduralTexturePixelShader: {
  92809. name: string;
  92810. shader: string;
  92811. };
  92812. }
  92813. declare module BABYLON {
  92814. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  92815. private _numberOfBricksHeight;
  92816. private _numberOfBricksWidth;
  92817. private _jointColor;
  92818. private _brickColor;
  92819. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  92820. updateShaderUniforms(): void;
  92821. get numberOfBricksHeight(): number;
  92822. set numberOfBricksHeight(value: number);
  92823. get numberOfBricksWidth(): number;
  92824. set numberOfBricksWidth(value: number);
  92825. get jointColor(): BABYLON.Color3;
  92826. set jointColor(value: BABYLON.Color3);
  92827. get brickColor(): BABYLON.Color3;
  92828. set brickColor(value: BABYLON.Color3);
  92829. /**
  92830. * Serializes this brick procedural texture
  92831. * @returns a serialized brick procedural texture object
  92832. */
  92833. serialize(): any;
  92834. /**
  92835. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  92836. * @param parsedTexture defines parsed texture data
  92837. * @param scene defines the current scene
  92838. * @param rootUrl defines the root URL containing brick procedural texture information
  92839. * @returns a parsed Brick Procedural BABYLON.Texture
  92840. */
  92841. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  92842. }
  92843. }
  92844. declare module BABYLON {
  92845. /** @hidden */
  92846. export var cloudProceduralTexturePixelShader: {
  92847. name: string;
  92848. shader: string;
  92849. };
  92850. }
  92851. declare module BABYLON {
  92852. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  92853. private _skyColor;
  92854. private _cloudColor;
  92855. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  92856. updateShaderUniforms(): void;
  92857. get skyColor(): BABYLON.Color4;
  92858. set skyColor(value: BABYLON.Color4);
  92859. get cloudColor(): BABYLON.Color4;
  92860. set cloudColor(value: BABYLON.Color4);
  92861. /**
  92862. * Serializes this cloud procedural texture
  92863. * @returns a serialized cloud procedural texture object
  92864. */
  92865. serialize(): any;
  92866. /**
  92867. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  92868. * @param parsedTexture defines parsed texture data
  92869. * @param scene defines the current scene
  92870. * @param rootUrl defines the root URL containing cloud procedural texture information
  92871. * @returns a parsed Cloud Procedural BABYLON.Texture
  92872. */
  92873. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  92874. }
  92875. }
  92876. declare module BABYLON {
  92877. /** @hidden */
  92878. export var fireProceduralTexturePixelShader: {
  92879. name: string;
  92880. shader: string;
  92881. };
  92882. }
  92883. declare module BABYLON {
  92884. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  92885. private _time;
  92886. private _speed;
  92887. private _autoGenerateTime;
  92888. private _fireColors;
  92889. private _alphaThreshold;
  92890. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  92891. updateShaderUniforms(): void;
  92892. render(useCameraPostProcess?: boolean): void;
  92893. static get PurpleFireColors(): BABYLON.Color3[];
  92894. static get GreenFireColors(): BABYLON.Color3[];
  92895. static get RedFireColors(): BABYLON.Color3[];
  92896. static get BlueFireColors(): BABYLON.Color3[];
  92897. get autoGenerateTime(): boolean;
  92898. set autoGenerateTime(value: boolean);
  92899. get fireColors(): BABYLON.Color3[];
  92900. set fireColors(value: BABYLON.Color3[]);
  92901. get time(): number;
  92902. set time(value: number);
  92903. get speed(): BABYLON.Vector2;
  92904. set speed(value: BABYLON.Vector2);
  92905. get alphaThreshold(): number;
  92906. set alphaThreshold(value: number);
  92907. /**
  92908. * Serializes this fire procedural texture
  92909. * @returns a serialized fire procedural texture object
  92910. */
  92911. serialize(): any;
  92912. /**
  92913. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  92914. * @param parsedTexture defines parsed texture data
  92915. * @param scene defines the current scene
  92916. * @param rootUrl defines the root URL containing fire procedural texture information
  92917. * @returns a parsed Fire Procedural BABYLON.Texture
  92918. */
  92919. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  92920. }
  92921. }
  92922. declare module BABYLON {
  92923. /** @hidden */
  92924. export var grassProceduralTexturePixelShader: {
  92925. name: string;
  92926. shader: string;
  92927. };
  92928. }
  92929. declare module BABYLON {
  92930. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  92931. private _grassColors;
  92932. private _groundColor;
  92933. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  92934. updateShaderUniforms(): void;
  92935. get grassColors(): BABYLON.Color3[];
  92936. set grassColors(value: BABYLON.Color3[]);
  92937. get groundColor(): BABYLON.Color3;
  92938. set groundColor(value: BABYLON.Color3);
  92939. /**
  92940. * Serializes this grass procedural texture
  92941. * @returns a serialized grass procedural texture object
  92942. */
  92943. serialize(): any;
  92944. /**
  92945. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  92946. * @param parsedTexture defines parsed texture data
  92947. * @param scene defines the current scene
  92948. * @param rootUrl defines the root URL containing grass procedural texture information
  92949. * @returns a parsed Grass Procedural BABYLON.Texture
  92950. */
  92951. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  92952. }
  92953. }
  92954. declare module BABYLON {
  92955. /** @hidden */
  92956. export var marbleProceduralTexturePixelShader: {
  92957. name: string;
  92958. shader: string;
  92959. };
  92960. }
  92961. declare module BABYLON {
  92962. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  92963. private _numberOfTilesHeight;
  92964. private _numberOfTilesWidth;
  92965. private _amplitude;
  92966. private _jointColor;
  92967. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  92968. updateShaderUniforms(): void;
  92969. get numberOfTilesHeight(): number;
  92970. set numberOfTilesHeight(value: number);
  92971. get amplitude(): number;
  92972. set amplitude(value: number);
  92973. get numberOfTilesWidth(): number;
  92974. set numberOfTilesWidth(value: number);
  92975. get jointColor(): BABYLON.Color3;
  92976. set jointColor(value: BABYLON.Color3);
  92977. /**
  92978. * Serializes this marble procedural texture
  92979. * @returns a serialized marble procedural texture object
  92980. */
  92981. serialize(): any;
  92982. /**
  92983. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  92984. * @param parsedTexture defines parsed texture data
  92985. * @param scene defines the current scene
  92986. * @param rootUrl defines the root URL containing marble procedural texture information
  92987. * @returns a parsed Marble Procedural BABYLON.Texture
  92988. */
  92989. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  92990. }
  92991. }
  92992. declare module BABYLON {
  92993. /** @hidden */
  92994. export var normalMapProceduralTexturePixelShader: {
  92995. name: string;
  92996. shader: string;
  92997. };
  92998. }
  92999. declare module BABYLON {
  93000. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  93001. private _baseTexture;
  93002. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  93003. updateShaderUniforms(): void;
  93004. render(useCameraPostProcess?: boolean): void;
  93005. resize(size: any, generateMipMaps: any): void;
  93006. isReady(): boolean;
  93007. get baseTexture(): BABYLON.Texture;
  93008. set baseTexture(texture: BABYLON.Texture);
  93009. /**
  93010. * Serializes this normal map procedural texture
  93011. * @returns a serialized normal map procedural texture object
  93012. */
  93013. serialize(): any;
  93014. /**
  93015. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  93016. * @param parsedTexture defines parsed texture data
  93017. * @param scene defines the current scene
  93018. * @param rootUrl defines the root URL containing normal map procedural texture information
  93019. * @returns a parsed Normal Map Procedural BABYLON.Texture
  93020. */
  93021. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  93022. }
  93023. }
  93024. declare module BABYLON {
  93025. /** @hidden */
  93026. export var perlinNoiseProceduralTexturePixelShader: {
  93027. name: string;
  93028. shader: string;
  93029. };
  93030. }
  93031. declare module BABYLON {
  93032. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  93033. time: number;
  93034. timeScale: number;
  93035. translationSpeed: number;
  93036. private _currentTranslation;
  93037. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  93038. updateShaderUniforms(): void;
  93039. render(useCameraPostProcess?: boolean): void;
  93040. resize(size: any, generateMipMaps: any): void;
  93041. /**
  93042. * Serializes this perlin noise procedural texture
  93043. * @returns a serialized perlin noise procedural texture object
  93044. */
  93045. serialize(): any;
  93046. /**
  93047. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  93048. * @param parsedTexture defines parsed texture data
  93049. * @param scene defines the current scene
  93050. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  93051. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  93052. */
  93053. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  93054. }
  93055. }
  93056. declare module BABYLON {
  93057. /** @hidden */
  93058. export var roadProceduralTexturePixelShader: {
  93059. name: string;
  93060. shader: string;
  93061. };
  93062. }
  93063. declare module BABYLON {
  93064. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  93065. private _roadColor;
  93066. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  93067. updateShaderUniforms(): void;
  93068. get roadColor(): BABYLON.Color3;
  93069. set roadColor(value: BABYLON.Color3);
  93070. /**
  93071. * Serializes this road procedural texture
  93072. * @returns a serialized road procedural texture object
  93073. */
  93074. serialize(): any;
  93075. /**
  93076. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  93077. * @param parsedTexture defines parsed texture data
  93078. * @param scene defines the current scene
  93079. * @param rootUrl defines the root URL containing road procedural texture information
  93080. * @returns a parsed Road Procedural BABYLON.Texture
  93081. */
  93082. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  93083. }
  93084. }
  93085. declare module BABYLON {
  93086. /** @hidden */
  93087. export var starfieldProceduralTexturePixelShader: {
  93088. name: string;
  93089. shader: string;
  93090. };
  93091. }
  93092. declare module BABYLON {
  93093. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  93094. private _time;
  93095. private _alpha;
  93096. private _beta;
  93097. private _zoom;
  93098. private _formuparam;
  93099. private _stepsize;
  93100. private _tile;
  93101. private _brightness;
  93102. private _darkmatter;
  93103. private _distfading;
  93104. private _saturation;
  93105. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  93106. updateShaderUniforms(): void;
  93107. get time(): number;
  93108. set time(value: number);
  93109. get alpha(): number;
  93110. set alpha(value: number);
  93111. get beta(): number;
  93112. set beta(value: number);
  93113. get formuparam(): number;
  93114. set formuparam(value: number);
  93115. get stepsize(): number;
  93116. set stepsize(value: number);
  93117. get zoom(): number;
  93118. set zoom(value: number);
  93119. get tile(): number;
  93120. set tile(value: number);
  93121. get brightness(): number;
  93122. set brightness(value: number);
  93123. get darkmatter(): number;
  93124. set darkmatter(value: number);
  93125. get distfading(): number;
  93126. set distfading(value: number);
  93127. get saturation(): number;
  93128. set saturation(value: number);
  93129. /**
  93130. * Serializes this starfield procedural texture
  93131. * @returns a serialized starfield procedural texture object
  93132. */
  93133. serialize(): any;
  93134. /**
  93135. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  93136. * @param parsedTexture defines parsed texture data
  93137. * @param scene defines the current scene
  93138. * @param rootUrl defines the root URL containing startfield procedural texture information
  93139. * @returns a parsed Starfield Procedural BABYLON.Texture
  93140. */
  93141. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  93142. }
  93143. }
  93144. declare module BABYLON {
  93145. /** @hidden */
  93146. export var woodProceduralTexturePixelShader: {
  93147. name: string;
  93148. shader: string;
  93149. };
  93150. }
  93151. declare module BABYLON {
  93152. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  93153. private _ampScale;
  93154. private _woodColor;
  93155. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  93156. updateShaderUniforms(): void;
  93157. get ampScale(): number;
  93158. set ampScale(value: number);
  93159. get woodColor(): BABYLON.Color3;
  93160. set woodColor(value: BABYLON.Color3);
  93161. /**
  93162. * Serializes this wood procedural texture
  93163. * @returns a serialized wood procedural texture object
  93164. */
  93165. serialize(): any;
  93166. /**
  93167. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  93168. * @param parsedTexture defines parsed texture data
  93169. * @param scene defines the current scene
  93170. * @param rootUrl defines the root URL containing wood procedural texture information
  93171. * @returns a parsed Wood Procedural BABYLON.Texture
  93172. */
  93173. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  93174. }
  93175. }